I've noticed that the python==3.12 test fails occasionally, specifically tests/test_shapes.py::test_ellipticity_ryden04. Can you have a look @Saransh-cpp?
Logs
```
> e2 = ellipticity_ryden04(-1.85, 0.89, 0.222, [0.056, 0.067])
tests/test_shapes.py:65:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
mu = -1.85, sigma = 0.89, gamma = 0.222, sigma_gamma = [0.056, 0.067]
size = None
def ellipticity_ryden04(mu, sigma, gamma, sigma_gamma, size=None, *, rng=None): # noqa: PLR0913
r"""
Ellipticity distribution following Ryden (2004).
The ellipticities are sampled by randomly projecting a 3D ellipsoid with
principal axes :math:`A > B > C` [1]_. The distribution of :math:`\log(1 -
B/A)` is normal with mean :math:`\mu` and standard deviation :math:`\sigma`.
The distribution of :math:`1 - C/B` is normal with mean :math:`\gamma` and
standard deviation :math:`\sigma_\gamma` [2]_. Both distributions are
truncated to produce ratios in the range 0 to 1 using rejection sampling.
Parameters
----------
mu : array_like
Mean of the truncated normal for :math:`\log(1 - B/A)`.
sigma : array_like
Standard deviation for :math:`\log(1 - B/A)`.
gamma : array_like
Mean of the truncated normal for :math:`1 - C/B`.
sigma_gamma : array_like
Standard deviation for :math:`1 - C/B`.
size : int or tuple of ints or None
Sample size. If ``None``, the size is inferred from the parameters.
rng : :class:`~numpy.random.Generator`, optional
Random number generator. If not given, a default RNG will be used.
Returns
-------
eps : array_like
Array of :term:`ellipticity` from projected axis ratios.
References
----------
.. [1] Ryden B. S., 2004, ApJ, 601, 214.
.. [2] Padilla N. D., Strauss M. A., 2008, MNRAS, 388, 1321.
"""
# default RNG if not provided
if rng is None:
rng = np.random.default_rng()
# draw gamma and epsilon from truncated normal -- eq.s (10)-(11)
# first sample unbounded normal, then rejection sample truncation
eps = rng.normal(mu, sigma, size=size)
bad = eps > 0
while np.any(bad):
> eps[bad] = rng.normal(mu, sigma, size=eps[bad].shape)
E TypeError: 'float' object is not subscriptable
glass/shapes.py:146: TypeError
```
Describe the Bug
I've noticed that the
python==3.12
test fails occasionally, specificallytests/test_shapes.py::test_ellipticity_ryden04
. Can you have a look @Saransh-cpp?Logs
``` > e2 = ellipticity_ryden04(-1.85, 0.89, 0.222, [0.056, 0.067]) tests/test_shapes.py:65: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ mu = -1.85, sigma = 0.89, gamma = 0.222, sigma_gamma = [0.056, 0.067] size = None def ellipticity_ryden04(mu, sigma, gamma, sigma_gamma, size=None, *, rng=None): # noqa: PLR0913 r""" Ellipticity distribution following Ryden (2004). The ellipticities are sampled by randomly projecting a 3D ellipsoid with principal axes :math:`A > B > C` [1]_. The distribution of :math:`\log(1 - B/A)` is normal with mean :math:`\mu` and standard deviation :math:`\sigma`. The distribution of :math:`1 - C/B` is normal with mean :math:`\gamma` and standard deviation :math:`\sigma_\gamma` [2]_. Both distributions are truncated to produce ratios in the range 0 to 1 using rejection sampling. Parameters ---------- mu : array_like Mean of the truncated normal for :math:`\log(1 - B/A)`. sigma : array_like Standard deviation for :math:`\log(1 - B/A)`. gamma : array_like Mean of the truncated normal for :math:`1 - C/B`. sigma_gamma : array_like Standard deviation for :math:`1 - C/B`. size : int or tuple of ints or None Sample size. If ``None``, the size is inferred from the parameters. rng : :class:`~numpy.random.Generator`, optional Random number generator. If not given, a default RNG will be used. Returns ------- eps : array_like Array of :term:`ellipticity` from projected axis ratios. References ---------- .. [1] Ryden B. S., 2004, ApJ, 601, 214. .. [2] Padilla N. D., Strauss M. A., 2008, MNRAS, 388, 1321. """ # default RNG if not provided if rng is None: rng = np.random.default_rng() # draw gamma and epsilon from truncated normal -- eq.s (10)-(11) # first sample unbounded normal, then rejection sample truncation eps = rng.normal(mu, sigma, size=size) bad = eps > 0 while np.any(bad): > eps[bad] = rng.normal(mu, sigma, size=eps[bad].shape) E TypeError: 'float' object is not subscriptable glass/shapes.py:146: TypeError ```To Reproduce
Expected Behaviour
No response
Actual Behaviour
No response
Version In Use
2024.2.dev47+g2611eeb.d20240918
Additional Context