diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index 9fb0fd4e3438..04e020e7b0cf 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -1611,5 +1611,15 @@ def test_assign_obj_listoflists(self): a[...] = [[1,2]] assert_equal(a, [[1,2], [1,2]]) + def test_string_truncation(self): + # Ticket #1990 - Data can be truncated in creation of an array from a + # mixed sequence of numeric values and strings + for numericval in [True, 1234, 123.4, complex(1, 234)]: + for stringconversion in [str, unicode, bytes]: + b = np.array([numericval, stringconversion('xx')]) + assert_equal(stringconversion(b[0]), stringconversion(numericval)) + b = np.array([stringconversion('xx'), numericval]) + assert_equal(stringconversion(b[1]), stringconversion(numericval)) + if __name__ == "__main__": run_module_suite()