Skip to content

Commit

Permalink
patch numpy unit stripping inconsistency (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjohnsen authored May 8, 2024
1 parent 33a1778 commit 8c7ca57
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions cleo/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ def coords_from_xyz(x: Quantity, y: Quantity, z: Quantity) -> Quantity:
return (
np.concatenate(
[
np.reshape(x, (*x.shape, 1)),
np.reshape(y, (*y.shape, 1)),
np.reshape(z, (*z.shape, 1)),
np.reshape(x / meter, (*x.shape, 1)),
np.reshape(y / meter, (*y.shape, 1)),
np.reshape(z / meter, (*z.shape, 1)),
],
axis=-1,
)
Expand Down
5 changes: 3 additions & 2 deletions cleo/ephys/spiking.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ def connect_to_neuron_group(
getattr(self.probe, f"{dim}s"),
indexing="ij",
)
dist2 += (dim_ng - dim_probe) ** 2
distances = np.sqrt(dist2) * meter # since units stripped
# proactively strip units to avoid numpy maybe doing so
dist2 += (dim_ng / mm - dim_probe / mm) ** 2
distances = np.sqrt(dist2) * mm
# probs is n_neurons by n_channels
probs = self._detection_prob_for_distance(distances)
# cut off to get indices of neurons to monitor
Expand Down
2 changes: 1 addition & 1 deletion cleo/imaging/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def add_self_to_plot(
coords = (
np.concatenate(
[
coords_from_ng(ng)[i_targets]
coords_from_ng(ng)[i_targets] / meter
for ng, i_targets in zip(
self.neuron_groups, self.i_targets_per_injct
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cleosim"
version = "0.14.2"
version = "0.14.3"
description = "Cleo: the Closed-Loop, Electrophysiology, and Optogenetics experiment simulation testbed"
authors = [
"Kyle Johnsen <kyle@kjohnsen.org>",
Expand Down
2 changes: 1 addition & 1 deletion tests/imaging/test_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_target_neurons_in_plane(rand_seed):
assert np.sum(np.sqrt(ng.x**2 + ng.y**2) < img_width / 2) == len(i_targets)

# noise_focus_factor (nff) smaller for bigger soma
ng.z = rng.uniform(focus_depth - 30 * um, focus_depth + 30 * um, ng.N) * meter
ng.z = rng.uniform(focus_depth / um - 30, focus_depth / um + 30, ng.N) * um
i_targets, nff, cop = target_neurons_in_plane(ng, focus_depth, img_width)
i_targets_bigger, nff_bigger, cop_bigger = target_neurons_in_plane(
ng, focus_depth, img_width, soma_radius=20 * um
Expand Down

0 comments on commit 8c7ca57

Please sign in to comment.