Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2579,7 +2579,7 @@ def flatten_sequence(iterable):

"""
for elm in iter(iterable):
if hasattr(elm, '__iter__'):
if hasattr(elm, "__iter__") and not isinstance(elm, (str, bytes)):
yield from flatten_sequence(elm)
else:
yield elm
Expand Down
7 changes: 7 additions & 0 deletions numpy/ma/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,13 @@ def test_flatten_structured_array(self):
control = np.array([[[1., 1.], ], [[2., 2.], ]], dtype=float)
assert_equal(test, control)
assert_equal(test.dtype, control.dtype)
# for strings
ndtype = [('a', 'U5'), ('b', [('c', 'U5')])]
arr = np.array([('NumPy', ('array',)), ('array', ('numpy',))], dtype=ndtype)
test = flatten_structured_array(arr)
control = np.array([['NumPy', 'array'], ['array', 'numpy']], dtype='U5')
assert_equal(test, control)
assert_equal(test.dtype, control.dtype)

def test_void0d(self):
# Test creating a mvoid object
Expand Down
Loading