Skip to content

Commit

Permalink
add dist sample tests for sampled and monodisperse modes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcurtis2 committed May 22, 2024
1 parent 4aecd30 commit ab6b60b
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/test_aero_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,61 @@ def test_dist_sample(args, weighting):
# assert
assert n_added > n_part * 0.5
assert n_added < n_part * 2

@staticmethod
def test_dist_sample_sampled():
# arrange
aero_data = ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL)
diams = [1, 2, 3, 4]
num_concs = [100, 200, 300]
aero_dist = ppmc.AeroDist(
aero_data,
[
{
"test_mode": {
"mass_frac": [{"H2O": [1]}],
"diam_type": "geometric",
"mode_type": "sampled",
"size_dist": [
{"diam": diams},
{"num_conc": num_concs},
],
}
}
],
)
sut = ppmc.AeroState(aero_data, *AERO_STATE_CTOR_ARG_MINIMAL)

# act
_ = sut.dist_sample(aero_dist, 1.0, 0.0, True, True)

# assert
assert (np.array(sut.diameters()) >= diams[0]).all()
assert (np.array(sut.diameters()) <= diams[-1]).all()

@staticmethod
def test_dist_sample_mono():
# arrange
aero_data = ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL)
diam = 2e-6
aero_dist = ppmc.AeroDist(
aero_data,
[
{
"test_mode": {
"mass_frac": [{"H2O": [1]}],
"diam_type": "geometric",
"mode_type": "mono",
"num_conc": 1e12,
"diam": diam,
}
}
],
)
sut = ppmc.AeroState(aero_data, *AERO_STATE_CTOR_ARG_MINIMAL)

# act
_ = sut.dist_sample(aero_dist, 1.0, 0.0, True, True)

# assert
assert np.isclose(np.array(sut.diameters()), diam).all()

0 comments on commit ab6b60b

Please sign in to comment.