Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3e84f6c

Browse filesBrowse files
committed
Move features data gen to fixture
1 parent 7862618 commit 3e84f6c
Copy full SHA for 3e84f6c

File tree

Expand file treeCollapse file tree

2 files changed

+22
-15
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-15
lines changed

‎src/napari_matplotlib/tests/conftest.py

Copy file name to clipboardExpand all lines: src/napari_matplotlib/tests/conftest.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ def brain_data():
2626
return data.brain(), {"rgb": False}
2727

2828

29+
@pytest.fixture
30+
def points_with_features_data():
31+
n_points = 100
32+
np.random.seed(10)
33+
points_data = 100 * np.random.random((100, 2))
34+
points_features = {
35+
"feature_0": np.random.random((n_points,)),
36+
"feature_1": np.random.random((n_points,)),
37+
"feature_2": np.random.random((n_points,)),
38+
}
39+
40+
return points_data, {"features": points_features}
41+
42+
2943
@pytest.fixture(autouse=True, scope="session")
3044
def set_strict_qt():
3145
env_var = "NAPARI_STRICT_QT"

‎src/napari_matplotlib/tests/scatter/test_scatter_features.py

Copy file name to clipboardExpand all lines: src/napari_matplotlib/tests/scatter/test_scatter_features.py
+8-15Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,22 @@
99

1010

1111
@pytest.mark.mpl_image_compare
12-
def test_features_scatter_widget_2D(make_napari_viewer):
12+
def test_features_scatter_widget_2D(
13+
make_napari_viewer, points_with_features_data
14+
):
1315
viewer = make_napari_viewer()
1416
viewer.theme = "light"
1517
widget = FeaturesScatterWidget(viewer)
1618

17-
# make the points data
18-
n_points = 100
19-
np.random.seed(10)
20-
points_data = 100 * np.random.random((100, 2))
21-
points_features = {
22-
"feature_0": np.random.random((n_points,)),
23-
"feature_1": np.random.random((n_points,)),
24-
"feature_2": np.random.random((n_points,)),
25-
}
26-
27-
viewer.add_points(points_data, features=points_features)
19+
viewer.add_points(
20+
points_with_features_data[0], **points_with_features_data[1]
21+
)
22+
assert len(viewer.layers) == 1
2823
# De-select existing selection
2924
viewer.layers.selection.clear()
3025

3126
# Select points data and chosen features
32-
viewer.layers.selection.add(
33-
viewer.layers["points_data"]
34-
) # images need to be selected
27+
viewer.layers.selection.add(viewer.layers[0]) # images need to be selected
3528
widget.x_axis_key = "feature_0"
3629
widget.y_axis_key = "feature_1"
3730

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.