Skip to content

Commit 396caa3

Browse files
authored
Merge pull request #64 from martinRenou/fix_ndarray_issue
Component: Fix NBArrayWidget use case
2 parents 7b46c7b + 881956a commit 396caa3

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
conda-channels: conda-forge
3131

3232
- name: Conda install dependencies
33-
run: conda install python=${{ matrix.python-version }} pip nodejs=13 ipywidgets jupyter jupyterlab vtk flake8 pytest
33+
run: conda install python=${{ matrix.python-version }} pip nodejs=13 ipywidgets jupyter jupyterlab vtk flake8 pytest ipydatawidgets
3434

3535
- name: Install ipygany
3636
run: pip install -e .

ipygany/ipygany.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ def __init__(self, name, array, **kwargs):
5252
super(Component, self).__init__(name=name, array=array, **kwargs)
5353

5454
if self.min is None:
55-
self.min = np.min(self.array)
55+
self.min = np.min(self.array) if not isinstance(self.array, Widget) else np.min(self.array.array)
5656

5757
if self.max is None:
58-
self.max = np.max(self.array)
58+
self.max = np.max(self.array) if not isinstance(self.array, Widget) else np.max(self.array.array)
5959

6060

6161
class Data(_GanyWidgetBase):

tests/test_ipygany.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import numpy as np
44

5+
from ipydatawidgets import NDArrayWidget
6+
57
from ipygany import PolyMesh, Data, Component
68

79

@@ -56,3 +58,9 @@ def test_component_creation():
5658
assert comp.name == 'z'
5759
assert comp.min == 1.
5860
assert comp.max == 3.
61+
62+
comp = Component('z', NDArrayWidget(np.array([1., 2., 3.])))
63+
64+
assert comp.name == 'z'
65+
assert comp.min == 1.
66+
assert comp.max == 3.

0 commit comments

Comments
 (0)