Skip to content

Commit f600305

Browse files
committed
update tests
1 parent f9f67b9 commit f600305

File tree

6 files changed

+25
-36
lines changed

6 files changed

+25
-36
lines changed

src/navigate/controller/sub_controllers/tiling.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ def sort_vars(a, b):
308308
tiling_setting[f"{axis}_length"] = fov
309309

310310
tiling_setting["theta_start"] = float(self.stage_position_vars["theta"].get())
311-
# tiling_setting["theta_stop"] = float(self.stage_position_vars["theta"].get())
312311
tiling_setting["theta_tiles"] = 1
313312
tiling_setting["theta_length"] = 0
314313

src/navigate/model/features/common_features.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,6 @@ def pre_signal_func(self):
10191019
self.restore_f = pos_dict["f_pos"]
10201020

10211021
# position: x, y, z, theta, f
1022-
# TODO: Update axes headers and get positions accordingly
10231022
if bool(microscope_state["is_multiposition"]) or self.force_multiposition:
10241023
self.position_headers = self.model.configuration["multi_positions"][0]
10251024
self.positions = self.model.configuration["multi_positions"][1:]
@@ -1034,7 +1033,7 @@ def pre_signal_func(self):
10341033
pos_dict[f"{self.primary_z_axis}_pos"]
10351034
)
10361035
self.positions[0][self.stage_axes.index(self.primary_f_axis)] = microscope_state.get(
1037-
"stack_f_origin",
1036+
"stack_focus_origin",
10381037
pos_dict[f"{self.primary_f_axis}_pos"]
10391038
)
10401039

src/navigate/tools/multipos_table_tools.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def dim_vector(start, n_tiles, step):
178178
additional_coordinates.append(dim_vector(values["start"], values["tiles"], values["step"]))
179179

180180
if f_track_with_z:
181+
# TODO: update it later. We are not using this option in navigate now.
181182
# grid out the 4D space...
182183
x, y, z, t = np.meshgrid(xs, ys, zs, thetas)
183184

@@ -187,15 +188,15 @@ def dim_vector(start, n_tiles, step):
187188
:lz
188189
] # This only works if len(fs) = len(zs)
189190
# TODO: Don't clip f. Practically fine for now.
191+
result = [x, y, z, t, f]
190192
else:
191193
result = np.meshgrid(xs, ys, zs, thetas, fs, *additional_coordinates)
192194

193195
axes = ["x", "y", "z", "theta", "f"]
194196
axes.extend(list(additional_settings.keys()))
195-
table_values = np.vstack([v.ravel() for v in result]).T
197+
tiles = np.vstack([v.ravel() for v in result]).T
196198

197-
return (axes, table_values)
198-
# return np.vstack([x.ravel(), y.ravel(), z.ravel(), t.ravel(), f.ravel()]).T
199+
return (axes, tiles)
199200

200201

201202
def calc_num_tiles(dist, overlap, roi_length):

test/controller/sub_controllers/test_tiling.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_traces(tiling_wizard_controller):
2626

2727
def assert_one_trace(var):
2828
tinfo = var.trace_info()
29-
assert len(tinfo) == 1
29+
assert len(tinfo) >= 1
3030
assert tinfo[0][0][0] == "write"
3131
assert "lambda" in tinfo[0][1]
3232

@@ -35,7 +35,7 @@ def assert_one_trace(var):
3535
# calling calculate_distance() and update_fov()
3636
for bound in ["start", "end"]:
3737
tinfo = tiling_wizard_controller.variables[f"{ax}_{bound}"].trace_info()
38-
assert len(tinfo) == 2
38+
assert len(tinfo) >= 1
3939
for ti in tinfo:
4040
assert ti[0][0] == "write"
4141
assert "lambda" in ti[1]
@@ -55,10 +55,10 @@ def assert_one_trace(var):
5555
tiling_wizard_controller.cam_settings_widgets["FOV_Y"].get_variable()
5656
)
5757
assert_one_trace(
58-
tiling_wizard_controller.stack_acq_widgets["abs_z_start"].get_variable()
58+
tiling_wizard_controller.stack_acq_widgets["start_position"].get_variable()
5959
)
6060
assert_one_trace(
61-
tiling_wizard_controller.stack_acq_widgets["abs_z_end"].get_variable()
61+
tiling_wizard_controller.stack_acq_widgets["end_position"].get_variable()
6262
)
6363
# Channels tab controller binds these a bunch
6464
# assert_one_trace(
@@ -211,5 +211,5 @@ def sort_vars(a, b):
211211
assert tiling_wizard_controller.multipoint_table.model.df["X"].min() == x_start
212212
assert tiling_wizard_controller.multipoint_table.model.df["Y"].min() == y_start
213213
assert tiling_wizard_controller.multipoint_table.model.df["Z"].min() == z_start
214-
assert tiling_wizard_controller.multipoint_table.model.df["R"].min() == r_start
214+
assert tiling_wizard_controller.multipoint_table.model.df["THETA"].min() == r_start
215215
assert tiling_wizard_controller.multipoint_table.model.df["F"].min() == f_start

test/model/features/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ def __getattr__(self, __name: str):
7575
def __call__(self, *args, **kwargs):
7676
kwargs["__test_frame_id"] = self.frame_id
7777
kwargs["__test_frame_id_completed"] = self.frame_id_completed
78+
if self.name_list == "active_microscope.stages.keys":
79+
return ["x", "y", "z", "theta", "f"]
7880
print("* calling", self.name_list, args, kwargs)
7981
self.record_list.append((self.name_list, args, kwargs))
8082

test/tools/test_multipos_table_tools.py

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,70 +65,58 @@ def listize(x):
6565
@pytest.mark.parametrize("x_start", listize((np.random.rand() - 0.5) * 1000))
6666
@pytest.mark.parametrize("x_tiles", listize(np.random.randint(0, 5)))
6767
@pytest.mark.parametrize("x_length", listize(np.random.rand() * 1000))
68-
@pytest.mark.parametrize("x_overlap", listize(np.random.rand()))
6968
@pytest.mark.parametrize("y_start", listize(((np.random.rand() - 0.5) * 1000)))
7069
@pytest.mark.parametrize("y_tiles", listize(np.random.randint(0, 5)))
7170
@pytest.mark.parametrize("y_length", listize(np.random.rand() * 1000))
72-
@pytest.mark.parametrize("y_overlap", listize(np.random.rand()))
7371
@pytest.mark.parametrize("z_start", listize(((np.random.rand() - 0.5) * 1000)))
7472
@pytest.mark.parametrize("z_tiles", listize(np.random.randint(0, 5)))
7573
@pytest.mark.parametrize("z_length", listize(np.random.rand() * 1000))
76-
@pytest.mark.parametrize("z_overlap", listize(np.random.rand()))
7774
@pytest.mark.parametrize("theta_start", listize(((np.random.rand() - 0.5) * 180)))
7875
@pytest.mark.parametrize("theta_tiles", listize(np.random.randint(0, 5)))
7976
@pytest.mark.parametrize("theta_length", listize((np.random.rand() * 5)))
80-
@pytest.mark.parametrize("theta_overlap", listize(np.random.rand()))
8177
@pytest.mark.parametrize("f_start", listize(((np.random.rand() - 0.5) * 1000)))
8278
@pytest.mark.parametrize("f_tiles", listize(np.random.randint(0, 5)))
8379
@pytest.mark.parametrize("f_length", listize(np.random.rand() * 1000))
84-
@pytest.mark.parametrize("f_overlap", listize(np.random.rand()))
80+
@pytest.mark.parametrize("overlap", listize(np.random.rand()))
8581
@pytest.mark.parametrize("f_track_with_z", [True, False])
8682
def test_compute_tiles_from_bounding_box(
8783
x_start,
8884
x_tiles,
8985
x_length,
90-
x_overlap,
9186
y_start,
9287
y_tiles,
9388
y_length,
94-
y_overlap,
9589
z_start,
9690
z_tiles,
9791
z_length,
98-
z_overlap,
9992
theta_start,
10093
theta_tiles,
10194
theta_length,
102-
theta_overlap,
10395
f_start,
10496
f_tiles,
10597
f_length,
106-
f_overlap,
98+
overlap,
10799
f_track_with_z,
108100
):
109101
from navigate.tools.multipos_table_tools import compute_tiles_from_bounding_box
110102

111-
tiles = compute_tiles_from_bounding_box(
103+
axes, tiles = compute_tiles_from_bounding_box(
112104
x_start,
113105
x_tiles,
114106
x_length,
115-
x_overlap,
116107
y_start,
117108
y_tiles,
118109
y_length,
119-
y_overlap,
120110
z_start,
121111
z_tiles,
122112
z_length,
123-
z_overlap,
124113
theta_start,
125114
theta_tiles,
126115
theta_length,
127-
theta_overlap,
128116
f_start,
129117
f_tiles,
130118
f_length,
131-
f_overlap,
119+
overlap,
132120
f_track_with_z,
133121
)
134122

@@ -138,11 +126,11 @@ def test_compute_tiles_from_bounding_box(
138126
theta_tiles = 1 if theta_tiles <= 0 else theta_tiles
139127
f_tiles = 1 if f_tiles <= 0 else f_tiles
140128

141-
x_max = x_start + (1 - x_overlap) * x_length * (x_tiles - 1)
142-
y_max = y_start + (1 - y_overlap) * y_length * (y_tiles - 1)
143-
z_max = z_start + (1 - z_overlap) * z_length * (z_tiles - 1)
144-
theta_max = theta_start + (1 - theta_overlap) * theta_length * (theta_tiles - 1)
145-
f_max = f_start + (1 - f_overlap) * f_length * (f_tiles - 1)
129+
x_max = x_start + (1 - overlap) * x_length * (x_tiles - 1)
130+
y_max = y_start + (1 - overlap) * y_length * (y_tiles - 1)
131+
z_max = z_start + (1 - overlap) * z_length * (z_tiles - 1)
132+
theta_max = theta_start + (1 - overlap) * theta_length * (theta_tiles - 1)
133+
f_max = f_start + (1 - overlap) * f_length * (f_tiles - 1)
146134

147135
# check extrema
148136
assert tiles[0, 0] == x_start
@@ -213,19 +201,19 @@ def tearDown(self) -> None:
213201
def test_update_table_1(self):
214202
pos = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]])
215203

216-
update_table(table=self.table, pos=pos, append=False)
204+
update_table(table=self.table, pos=pos, axes=["X", "Y", "Z", "THETA", "F"], append=False)
217205

218206
np.testing.assert_array_equal(self.table.model.df["X"], pos[:, 0])
219207
np.testing.assert_array_equal(self.table.model.df["Y"], pos[:, 1])
220208
np.testing.assert_array_equal(self.table.model.df["Z"], pos[:, 2])
221-
np.testing.assert_array_equal(self.table.model.df["R"], pos[:, 3])
209+
np.testing.assert_array_equal(self.table.model.df["THETA"], pos[:, 3])
222210
np.testing.assert_array_equal(self.table.model.df["F"], pos[:, 4])
223211
assert self.table.currentrow == 2
224212

225213
new_positions = np.array([[16, 17, 18, 19, 20], [21, 22, 23, 24, 25]])
226214

227215
print(self.table.model.df.shape)
228-
update_table(self.table, pos=new_positions, append=True)
216+
update_table(self.table, pos=new_positions, axes=["X", "Y", "Z", "THETA", "F"], append=True)
229217
assert self.table.currentrow == 4
230218
np.testing.assert_array_equal(
231219
self.table.model.df["X"][
@@ -246,7 +234,7 @@ def test_update_table_1(self):
246234
new_positions[:, 2],
247235
)
248236
np.testing.assert_array_equal(
249-
self.table.model.df["R"][
237+
self.table.model.df["THETA"][
250238
3:,
251239
],
252240
new_positions[:, 3],

0 commit comments

Comments
 (0)