Skip to content

Commit 2b53eb6

Browse files
authored
Update to accept numpy 2.0, doesn't seem to be any problem (#136)
* Update to accept numpy 2.0, doesn't seem to be any problem * Update version * Update tests on tox.ini * Updated changelog * Cleaning up cue_widgets to reduce warnings * Fix warnings for checkablewidget
1 parent f378cc4 commit 2b53eb6

10 files changed

Lines changed: 36 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## v0.2.1
4+
5+
Updated to support numpy 2.0
6+
7+
## v0.2.0
8+
9+
Full-fledged implementation.
10+
311
## v0.1.0
412

513
First official release.

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jupyterlab-widgets = "==3.0.13"
2020
kiwisolver = "==1.4.7"
2121
matplotlib = "==3.9.4"
2222
matplotlib-inline = "==0.1.7"
23-
numpy = "==1.26.4"
23+
numpy = "==2.3.5"
2424
packaging = "==24.2"
2525
parso = "==0.8.4"
2626
pexpect = "==4.9.0"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ classifiers = [
3030
]
3131
dependencies = [
3232
"ipywidgets>=8.0.0",
33-
"numpy<2.0.0",
33+
"numpy<3.0",
3434
"widget_code_input>=4.0.17",
3535
"matplotlib",
3636
"termcolor"

src/scwidgets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.2.0"
1+
__version__ = "0.2.1"
22
__authors__ = "the scicode-widgets developer team"
33

44
from .check import * # noqa: F403

src/scwidgets/check/_asserts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,5 +307,5 @@ def assert_numpy_sub_dtype(
307307

308308

309309
assert_numpy_floating_sub_dtype = functools.partial(
310-
assert_numpy_sub_dtype, numpy_type=np.floating
310+
assert_numpy_sub_dtype, numpy_type=float
311311
)

src/scwidgets/check/_widget_check_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CheckableWidget:
2626
"""
2727

2828
def __init__(
29-
self, check_registry: Optional[CheckRegistry], name: Optional[str] = None
29+
self, check_registry: Optional[CheckRegistry] = None, name: Optional[str] = None
3030
):
3131
self._check_registry = check_registry
3232
if self._check_registry is not None:

src/scwidgets/cue/_widget_cue.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CueWidget:
2020

2121
def __init__(
2222
self,
23-
widgets_to_observe: Union[List[Widget], Widget],
23+
widgets_to_observe: Union[List[Widget], Widget, None] = None,
2424
traits_to_observe: Union[
2525
str, Sentinel, List[Union[str, Sentinel, List[str]]]
2626
] = "value",
@@ -30,7 +30,9 @@ def __init__(
3030
):
3131
self._widgets_to_observe: List[Widget] = []
3232
self._traits_to_observe: List[Union[str, Sentinel, List[str]]] = []
33-
self.set_widgets_to_observe(widgets_to_observe, traits_to_observe)
33+
if widgets_to_observe is not None:
34+
# normal usage (your explicit calls)
35+
self.set_widgets_to_observe(widgets_to_observe, traits_to_observe)
3436

3537
self.cued = cued
3638

src/scwidgets/cue/_widget_reset_cue_button.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def __init__(
7575

7676
self._css_style = css_style
7777

78-
Button.__init__(self, *args, **kwargs)
78+
tooltip = kwargs.pop("button_tooltip", None)
79+
Button.__init__(self, *args, tooltip=tooltip, **kwargs)
7980

8081
if widgets_to_observe is None:
8182
widgets_to_observe = []
@@ -88,7 +89,12 @@ def __init__(
8889
if cued is None:
8990
cued = any([cue_widget.cued for cue_widget in cue_widgets])
9091

91-
CueWidget.__init__(self, widgets_to_observe, traits_to_observe, cued)
92+
CueWidget.__init__(
93+
self,
94+
widgets_to_observe=widgets_to_observe,
95+
traits_to_observe=traits_to_observe,
96+
cued=cued,
97+
)
9298
self._cue_widgets = cue_widgets
9399

94100
self.on_click(self._on_click)

tests/test_widgets.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ def test_reset_cue_button(
819819

820820
# Check if unused text input does not effect cueing of button
821821
unused_text_input.send_keys("a")
822-
time.sleep(0.1)
822+
time.sleep(0.5)
823823
assert unused_text_input.get_attribute("value") == "Unuseda"
824824
assert (
825825
sum(
@@ -847,7 +847,7 @@ def test_reset_cue_button(
847847
)
848848
assert not (reset_cue_button.is_enabled())
849849
else:
850-
time.sleep(0.1)
850+
time.sleep(0.5)
851851
assert reset_cue_button.is_enabled()
852852

853853
# Checks if two more widgets are cued on change
@@ -884,7 +884,7 @@ def test_reset_cue_button(
884884
)
885885
assert not (reset_cue_button.is_enabled())
886886
else:
887-
time.sleep(0.1)
887+
time.sleep(0.5)
888888
assert reset_cue_button.is_enabled()
889889

890890
assert (
@@ -993,7 +993,7 @@ def test_button_clicks(
993993
# button is obscured so we need to click with action on the cell
994994
ActionChains(driver).click(nb_cell).perform()
995995
check_all_widgets_button.click()
996-
time.sleep(0.1)
996+
time.sleep(0.5)
997997
outputs = nb_cell.find_elements(By.CLASS_NAME, OUTPUT_CLASS_NAME)
998998
assert (
999999
sum(
@@ -1011,7 +1011,7 @@ def test_button_clicks(
10111011
WebDriverWait(driver, 5).until(
10121012
expected_conditions.element_to_be_clickable(set_all_references_button)
10131013
).click()
1014-
time.sleep(0.1)
1014+
time.sleep(0.5)
10151015
outputs = nb_cell.find_elements(By.CLASS_NAME, OUTPUT_CLASS_NAME)
10161016
assert (
10171017
sum(
@@ -1029,7 +1029,7 @@ def test_button_clicks(
10291029
WebDriverWait(driver, 5).until(
10301030
expected_conditions.element_to_be_clickable(check_all_widgets_button)
10311031
).click()
1032-
time.sleep(0.1)
1032+
time.sleep(0.5)
10331033
outputs = nb_cell.find_elements(By.CLASS_NAME, OUTPUT_CLASS_NAME)
10341034
assert (
10351035
sum(

tox.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ setenv =
3131
deps =
3232
pytest<8.0.0
3333
pytest-rerunfailures
34-
pytest-html<4.0.0,
34+
pytest-html<4.0.0
3535
# selenium juypter notebook tests
3636
jupyterlab==3.6.5
3737
# fixing selenium version to have backwards-compatibility with pytest-selenium
@@ -41,8 +41,8 @@ deps =
4141
jupytext==1.15.0
4242
imageio
4343
# we fix matplotlib for consistent image tests
44-
matplotlib==3.7.2
45-
numpy<2.0.0
44+
matplotlib==3.7.3
45+
numpy<3.0
4646
scikit-image
4747
ipympl
4848
commands =
@@ -74,8 +74,8 @@ deps =
7474
jupytext==1.15.0
7575
imageio
7676
# we fix matplotlib for consistent image tests
77-
matplotlib==3.7.2
78-
numpy<2.0.0
77+
matplotlib==3.7.3
78+
numpy<3.0
7979
scikit-image
8080
ipympl
8181
commands =

0 commit comments

Comments
 (0)