| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| Fixes for Monte Carlo and Rayleigh modules source code.tar.gz | 2026-10-28 | 12.5 MB | |
| Fixes for Monte Carlo and Rayleigh modules source code.zip | 2026-10-28 | 12.6 MB | |
| README.md | 2026-10-28 | 5.8 kB | |
| Totals: 3 Items | 25.1 MB | 0 | |
- Improve generation of random Mie angles, thanks @antonsoo
- Fix broken Rayleigh calculation for small spheres with absorption, thanks @antonsoo
- Bump python version to 3.15, stop testing 3.10
3.3.1 (10/28/2026)
- fix
rayleigh.efficiencies_mxsubtracting scattering from extinction. With the m = n - ik convention the absorption term is negative, soabs(absorption + qsca)gave absorption minus scattering, and qext for m = 1.5 - 1e-6j at x = 0.01 came out 21% low (thanks @antonsoo). The x**4 term now follows Bohren & Huffman'sRe(ratio**2)rather than|ratio|**2, which agrees with Mie to 2e-5 instead of 6e-4 at m = 1.5 - 1j, x = 0.1.mis conjugated first, ascore.pydoes. The Rayleighqextalso sets thealbedoandqextnormalizations, sorayleigh.S1_S2and the intensities change too - handle perfectly conducting spheres in
rayleigh. As elsewhere in the package, m.real == 0 now means a perfect conductor, which radiates a magnetic dipole b1 = -a1/2 alongside its electric one: qext = qsca = 10/3 x4, qback = 9 x4 and g = -2/5. The dielectric formulas were used before, so m = -1j gave a qext about three times the Mie value; it now agrees to 2e-5 at x = 0.01 - validate input to the
rayleighfunctions ascore.pynow does. A NaN or infinite m or x, a negative x, or a negative real part of m raisesValueError; before,rayleigh.efficiencies_mx(nan, 0.05)returned NaN andm = -1.5 - 0.1jorx = -0.05returned normal-looking efficiencies - say why
S1_S2and the functions built on it reject an array of spheres, in bothcoreandrayleigh. They vectorize over mu and describe one sphere, but an array m or x failed with numpy's "truth value of an array is ambiguous" - return
gfromrayleigh.efficiencies_mxwith the same shape and type as the other efficiencies. It was the int 0 even for an array of spheres - document the
rayleighmodule: what the approximation is, which expressions go beyond the leading Rayleigh term, its accuracy against Mie, and tested examples - support Python 3.11 through 3.15.
requires-pythonis now>=3.11, 3.10 is dropped from the classifiers, the black target versions and the CI matrix, and 3.15 is added to all three - raise
ValueErrorfor a refractive index or size parameter the kernels would misread. The kernels treat any index that failsm.real > 0as a perfect conductor, som = nanorm = -1.5silently returned the answer for a metal sphere, and an infinite m returned NaN. A NaN x raised "cannot convert float NaN to integer" on the pure-Python backend while numba returned NaN, an infinite x raised a different unhelpful error on each backend, and a negative x returned zeros.coefficients,efficiencies_mx,S1_S2and the near fields, and everything built on them, now reject a NaN or infinite m or x, a negative x, and a negative real part of m, checking every entry of an array.m.real == 0still means a perfect conductor and x = 0 is still allowed - fix
monte_carlo.mu_with_uniform_cdfreturning wrong angles for fine tables.cdfbegan at I(-1)/num rather than zero, so a target below that value left the inversion loop at index zero and interpolated against the last entry.cdfnow integrates the phase function with the trapezoidal rule, starting at exactly 0 and ending at exactly 1 (it used to end slightly above 1), so tables differ slightly from 3.3.0.cdfandmu_with_uniform_cdfalso raiseValueErrorwhen num is less than 2 (thanks @antonsoo) - replace the inversion loop in
monte_carlo.mu_with_uniform_cdfwithnp.interp - warn when
monte_carlo.cdfuses too few angles to resolve the phase function. The raw integral should be one, so aRuntimeWarningis issued when it is off by more than 1%; normalizing used to hide the error silently. A large sphere needs roughly x2 angles, because its forward peak is only about 8/x2 wide in cos(theta) - size the table inside
monte_carlo.mu_with_uniform_cdffrom x, as max(2000, 5*x**2) angles instead of a fixed 2000. At x = 100 the sampled mean cosine was 0.930 against g = 0.868; it is now 0.869. Large spheres are slower to tabulate: seconds at x = 100, about a minute at x = 300 - raise
ValueErrorfrommonte_carlo.cdfandmu_with_uniform_cdfwhen the phase function is not finite - rewrite the
monte_carlodocstrings, with tested examples of drawing random scattering angles - name the encoding on every text read and write.
open(path)andPath.read_text()decode with the locale's preferred encoding, which is UTF-8 on Linux and macOS but cp1252 on Windows, sotests/test_makefile.pypassed everywhere except the four Windows jobs, where it died on the emoji in the Makefile's echo lines. Two more latent cases are fixed alongside it: the scattnlay metadata read intests/test_scattnlay_reference.py, which survived only because that JSON happens to be pure ASCII, and thewrite_textindocs/data/generate_scattnlay_reference_fields.py - check for locale-dependent text I/O in the test suite, by walking the syntax trees
of every Python file in the repository and requiring an explicit
encoding=. The failure is invisible on the platforms this package is developed on, so a Windows-only break was waiting for whoever next added a non-ASCII character to a file something reads