Skip to content

Commit 7012109

Browse files
committed
update
1 parent dec423b commit 7012109

4 files changed

Lines changed: 9 additions & 10 deletions

File tree

FlowCyPy/distribution/lognormal.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,11 @@ def generate(self, n_samples: int) -> AnyUnit:
254254
uniform_samples = np.clip(uniform_samples, 1e-12, 1.0 - 1e-12)
255255

256256
if self.cutoff is None:
257-
samples = np.random.lognormal(mean=mu, sigma=sigma, size=int(n_samples))
258-
return samples * self._units
257+
return np.random.lognormal(mean=mu, sigma=sigma, size=int(n_samples))
259258

260259
cutoff_value = self.cutoff.to(self._units).magnitude
261260
if cutoff_value <= 0.0:
262-
samples = np.random.lognormal(mean=mu, sigma=sigma, size=int(n_samples))
263-
return samples * self._units
261+
return np.random.lognormal(mean=mu, sigma=sigma, size=int(n_samples))
264262

265263
cdf_at_cutoff = lognorm.cdf(cutoff_value, s=sigma, scale=np.exp(mu))
266264
cdf_at_cutoff = float(np.clip(cdf_at_cutoff, 0.0, 1.0 - 1e-15))

FlowCyPy/distribution/normal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def generate(self, n_samples: int) -> AnyUnit:
225225

226226
if self.cutoff is None:
227227
samples = np.random.normal(loc=mu, scale=sigma, size=int(n_samples))
228-
return samples * self._units
228+
return samples
229229

230230
cutoff_value = self.cutoff.to(self._units).magnitude
231231

tests/python_api/distribution.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import matplotlib.pyplot as plt
44
import numpy as np
55
import pytest
6-
from TypedUnit import ureg
6+
from TypedUnit import ureg, Length
77

88
import FlowCyPy
99
from FlowCyPy import distribution as dist
@@ -42,6 +42,10 @@ def test_number_of_samples(mock_show, distribution):
4242
# Generate particle sizes
4343
sizes = distribution.generate(N_SAMPLES)
4444

45+
assert np.all(
46+
Length.check(sizes)
47+
), f"{distribution.__class__.__name__}: Generated sizes have incorrect units."
48+
4549
# Assert the shape is correct
4650
assert sizes.shape == (
4751
N_SAMPLES,

tests/python_api/workflow.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pytest
66
from TypedUnit import ureg
77

8-
import FlowCyPy
98
from FlowCyPy import FlowCytometer
109
from FlowCyPy.fluidics import (
1110
FlowCell,
@@ -28,8 +27,6 @@
2827
triggering_system,
2928
)
3029

31-
FlowCyPy.debug_mode = True # Enable debug mode for detailed logging
32-
3330

3431
# ----------------- FIXTURES -----------------
3532

@@ -275,4 +272,4 @@ def test_peak_plot(mock_show, flow_cytometer, digitizer):
275272

276273

277274
if __name__ == "__main__":
278-
pytest.main(["-W error", "-s", __file__])
275+
pytest.main(["-W error", __file__])

0 commit comments

Comments
 (0)