Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove np.bool8 support (deprecated) #6633

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion skimage/color/tests/test_delta_e.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_ciede2000_dE(dtype, channel_axis):
dE2 = deltaE_ciede2000(lab1, lab2, channel_axis=channel_axis)
assert dE2.dtype == _supported_float_type(dtype)

rtol = 1e-2 if dtype == np.float32 else 1e-4
rtol = 1e-2 if dtype == np.float32 else 6e-3
assert_allclose(dE2, data['dE'], rtol=rtol)
Comment on lines +33 to 34
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these relative tolerances set empirically or some other way? The tests fail for only the first entry in dE2 with numpy v1.24.0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure it is empirical (I think I added the 1e-2 for float32 at some point, but not sure about the original choice of 1e-4). I don't know why this particular function seems to have relatively low precision.



Expand Down
2 changes: 1 addition & 1 deletion skimage/feature/_cascade.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ cdef class Cascade:
feature_number = int(internal_nodes[0])
# list() is for Python3 fix here
lut_array = list(map(lambda x: int(x), internal_nodes[1:]))
lut = np.asarray(lut_array, dtype='uint32')
lut = np.array(lut_array).astype(np.uint32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this change important?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #6638

I think perhaps, this suggestion is better than just ignoring the warning as I currently have in #6637. I think I may just update that one with a co-authored-by commit crediting @bmorris3 as this will continue to work even after the deprecation cycle completes


# Copy array to the main LUT array
for i in range(8):
Expand Down
2 changes: 1 addition & 1 deletion skimage/segmentation/_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def relabel_sequential(label_field, offset=1):
if input_type.itemsize < required_type.itemsize:
output_type = required_type
else:
if input_type.type(out_vals[-1]) == out_vals[-1]:
if np.cast[input_type](out_vals[-1]) == out_vals[-1]:
output_type = input_type
else:
output_type = required_type
Expand Down
1 change: 0 additions & 1 deletion skimage/util/dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
for t in _integer_types}
dtype_range = {bool: (False, True),
np.bool_: (False, True),
np.bool8: (False, True),
float: (-1, 1),
np.float_: (-1, 1),
np.float16: (-1, 1),
Expand Down
4 changes: 0 additions & 4 deletions skimage/util/tests/test_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,13 @@ def test_copy():

def test_bool():
img_ = np.zeros((10, 10), bool)
img8 = np.zeros((10, 10), np.bool8)
img_[1, 1] = True
img8[1, 1] = True
for (func, dt) in [(img_as_int, np.int16),
(img_as_float, np.float64),
(img_as_uint, np.uint16),
(img_as_ubyte, np.ubyte)]:
converted_ = func(img_)
assert np.sum(converted_) == dtype_range[dt][1]
converted8 = func(img8)
assert np.sum(converted8) == dtype_range[dt][1]


def test_clobber():
Expand Down