Open
Description
Code example:
import PyPartMC as ppmc
from PyPartMC import si
from unittest import TestCase
aero_data = ppmc.AeroData((
{"OC": [1000 *si.kg/si.m**3, 0, 1e-3 *si.kg/si.mol, 0.001]},
))
sampled = {
"mass_frac": [{"OC": [1]}],
"diam_type": "geometric",
"mode_type": "sampled",
"size_dist": [
{"diam": [1, 2, 3, 4]},
{"num_conc": [100000, 200000, 300000]},
{"not_used": [0]}
]
}
other = {
"mass_frac": [{"OC": [1]}],
"diam_type": "geometric",
"mode_type": "log_normal",
"geom_mean_diam": 8.64 * si.nm,
"log10_geom_std_dev": 0.28,
"num_conc": 2900 / si.cm**3
}
# D1 throws an exception, as it should
with TestCase.assertRaises(TestCase, Exception):
D1 = ppmc.AeroDist(aero_data, [{"mode1":sampled}])
# this assertion should pass with the issue resolved
with TestCase.assertRaises(TestCase, Exception):
D2 = ppmc.AeroDist(aero_data, [{"mode1":other, "mode2":sampled}])
When the size_dist
parameter of a sampled-type mode has more than 2 dicts (or the dict keys aren't "diam"
and "num_conc"
) it should throw an error. This works when the sampled mode is the first mode in AeroDist
, however, it fails to throw an exception when modes of different types are present before it.
The code above should pass without errors after the issue is resolved.