np.random.uniform broken with units
See original GitHub issueWith numpy-1.12
In [12]: np.random.uniform(u.Quantity(10, u.deg), u.Quantity(11, u.deg))
Out[12]: -1.0
This used to work up to 1.11.3 and returned a number between 10 and 11.
I’m reporting this here first before deciding whether this should be reported upstream or fixed in astropy.
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (13 by maintainers)
Top Results From Across the Web
How to Use np.random.uniform - Sharp Sight
This tutorial explains how to use np.random.uniform (Numpy random uniform). It explains the syntax and shows clear examples.
Read more >numpy.random.uniform — NumPy v1.24 Manual
Draw samples from a uniform distribution. Samples are uniformly distributed over the half-open interval [low, high) (includes low, but excludes high) ...
Read more >Generate a random point within a circle (uniformly)
Let's look at the math that leads up to sqrt(random()) . Assume for simplicity that we're working with the unit circle, i.e. R...
Read more >Random Variables - Duke People
Example: Rejection sampling from uniform distribution; Example: Random samples from the unit circle using ... np.random.uniform(low=-1, high=1, size=(3, 4)).
Read more >jax.random package - JAX documentation - Read the Docs
The jax.random package provides a number of routines for deterministic generation of ... key, subkey = random.split(key) >>> random.uniform(subkey) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mhvk - Thank you very much for all your work on the Astropy and Numpy internals to make life better for all of us!
I checked on numpy master and both examples now error instead of giving nonsense. Obviously, it would still be nicer if they returned the right thing, but at least this issue is solved, so I’ll close it.