def test_maybe_convert_string_to_array(self): result = maybe_convert_string_to_object('x') tm.assert_numpy_array_equal(result, np.array(['x'], dtype=object)) assert result.dtype == object result = maybe_convert_string_to_object(1) assert result == 1 arr = np.array(['x', 'y'], dtype=str) result = maybe_convert_string_to_object(arr) tm.assert_numpy_array_equal(result, np.array(['x', 'y'], dtype=object)) assert result.dtype == object # unicode arr = np.array(['x', 'y']).astype('U') result = maybe_convert_string_to_object(arr) tm.assert_numpy_array_equal(result, np.array(['x', 'y'], dtype=object)) assert result.dtype == object # object arr = np.array(['x', 2], dtype=object) result = maybe_convert_string_to_object(arr) tm.assert_numpy_array_equal(result, np.array(['x', 2], dtype=object)) assert result.dtype == object
def test_maybe_convert_string_to_array(self): result = maybe_convert_string_to_object('x') tm.assert_numpy_array_equal(result, np.array(['x'], dtype=object)) assert result.dtype == object result = maybe_convert_string_to_object(1) assert result == 1 arr = np.array(['x', 'y'], dtype=str) result = maybe_convert_string_to_object(arr) tm.assert_numpy_array_equal(result, np.array(['x', 'y'], dtype=object)) assert result.dtype == object # unicode arr = np.array(['x', 'y']).astype('U') result = maybe_convert_string_to_object(arr) tm.assert_numpy_array_equal(result, np.array(['x', 'y'], dtype=object)) assert result.dtype == object # object arr = np.array(['x', 2], dtype=object) result = maybe_convert_string_to_object(arr) tm.assert_numpy_array_equal(result, np.array(['x', 2], dtype=object)) assert result.dtype == object