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
5 changes: 4 additions & 1 deletion datascience/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ def make_array(*elements):
>>> make_array("foo", "bar")
array(['foo', 'bar'],
dtype='<U3')
>>> make_array(True, False)
array([ True, False], dtype=bool)
>>> make_array()
array([], dtype=float64)
"""
if elements and all(isinstance(item, (int, np.integer)) for item in elements):
if elements and all(isinstance(item, (int, np.integer)) and not isinstance(item, bool) for item in elements):
# Specifically added for Windows machines where the default
# integer is int32 - see GH issue #339.
# and ensures item is not bool, see issue #622.
return np.array(elements, dtype="int64")

# Manually cast `elements` as an object due to this: https://github.com/data-8/datascience/issues/458
Expand Down
4 changes: 3 additions & 1 deletion tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def test_make_array():
assert test3.dtype == "<U3"
test4 = ds.make_array(list(range(10)))
assert test4.dtype == "object"
test5 = ds.make_array(True, False)
assert test5.dtype == "bool"


def test_percentile():
Expand Down Expand Up @@ -121,4 +123,4 @@ def __getitem__(self, index):
def __len__(self):
pass
is_sequence = IsSequence()
assert ds.is_non_string_iterable(is_sequence) == True
assert ds.is_non_string_iterable(is_sequence) == True
Loading