question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

np.random.uniform broken with units

See original GitHub issue

With 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:closed
  • Created 6 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
cdeilcommented, Apr 19, 2017

@mhvk - Thank you very much for all your work on the Astropy and Numpy internals to make life better for all of us!

0reactions
mhvkcommented, Apr 18, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found