Skip to content

Commit

Permalink
moving contents of test_seeding into a Jupyter notebook, descretisati…
Browse files Browse the repository at this point in the history
…on refactor, parallel=False for seeding backend method
  • Loading branch information
slayoo committed Aug 1, 2024
1 parent 36ff933 commit d527536
Show file tree
Hide file tree
Showing 7 changed files with 10,471 additions and 126 deletions.
2 changes: 1 addition & 1 deletion PySDM/backends/impl_numba/methods/seeding_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class SeedingMethods(BackendMethods):
@cached_property
def _seeding(self):
@numba.njit(**self.default_jit_flags)
@numba.njit(**{**self.default_jit_flags, "parallel": False})
def body(
idx,
multiplicity,
Expand Down
4 changes: 1 addition & 3 deletions PySDM/initialisation/discretise_multiplicities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ def discretise_multiplicities(values_arg):
"""any NaN values in the input array are ignored and flagged
with zero multiplicities in the output array"""

values_int = values_arg.round().astype(np.int64)
values_int = np.where(np.isnan(values_arg), 0, values_arg).round().astype(np.int64)

if np.issubdtype(values_arg.dtype, np.floating):
if not np.logical_or(values_int > 0, np.isnan(values_arg)).all():
raise ValueError(
f"int-casting resulted in multiplicity of zero (min(y_float)={min(values_arg)})"
)

values_int = np.where(np.isnan(values_arg), 0, values_int)

percent_diff = 100 * abs(
1 - np.nansum(values_arg) / np.sum(values_int.astype(float))
)
Expand Down
2 changes: 2 additions & 0 deletions examples/PySDM_examples/seeding/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .settings import Settings
from .simulation import Simulation
Loading

0 comments on commit d527536

Please sign in to comment.