clenspy.utils.scalar_array_output¶
- clenspy.utils.scalar_array_output(method)[source]¶
Decorator: return a Python scalar if the method’s first positional argument was scalar-like and the result really is a single number; otherwise return the array unchanged.
NOTE: the size check is not belt-and-braces, it is required. A scalar first argument does not imply a scalar result: NfwProfile.fourier with an array
m200and a scalarklegitimately returns one value per halo. The earlier version keyed only on the argument and called.item()unconditionally, which raisedValueError: can only convert an array of size 1for exactly that call – a real combination, just one no test happened to make.- Parameters:
method (callable) – Method with signature
(self, x, ...)returning an array-like.- Returns:
callable – Wrapped method with the same signature.