sot / chandra_aca

Chandra Aspect Camera Tools
https://sot.github.io/chandra_aca
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

star_probs.broadcast_arrays doesn't work for just one array #55

Open taldcroft opened 6 years ago

taldcroft commented 6 years ago

The code should be:

def broadcast_arrays(*args):
    is_scalar = all(np.array(arg).ndim == 0 for arg in args)
    args = np.atleast_1d(*args)

    # np.atleast_1d returns a scalar for only one arg, so need
    # to turn it into a list for the np.broadcast_arrays call.
    if not isinstance(args, list):
        args = [args]

    outs = [is_scalar] + np.broadcast_arrays(*args)
    return outs

This doesn't impact anything in star_probs, but this is a useful-enough function that I use it elsewhere.