Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
taldcroft opened this issue May 29, 2018 · 0 comments
Open

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

taldcroft opened this issue May 29, 2018 · 0 comments
Labels

Comments

@taldcroft
Copy link
Member

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.

@taldcroft taldcroft added the bug label May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant