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

The solution to 49 doesn't work #79

Open
shadowfishes opened this issue May 14, 2019 · 6 comments
Open

The solution to 49 doesn't work #79

shadowfishes opened this issue May 14, 2019 · 6 comments

Comments

@shadowfishes
Copy link

I got an exception when running the 49th solution. The exception as follows:
ValueError: threshold must be numeric and non-NAN, try sys.maxsize for untruncated representation

@rougier
Copy link
Owner

rougier commented May 23, 2019

Weird. It's still working for me using numpy 1.15.2. What is your version?

@shadowfishes
Copy link
Author

shadowfishes commented May 24, 2019

Yes, you're right. It's working well under numpy 1.15.2 . The exception is caused by numpy 1.16.3 which version I used in jupyter. So, it's a version problem. I think it may be better to assign the numpy version in requirements.txt.

@rougier
Copy link
Owner

rougier commented May 24, 2019

I would be better if we find a solution that works on both version. Any idea?

@shadowfishes
Copy link
Author

I found the definition of threshold as follows:
threshold : int, optional
Total number of array elements which trigger summarization rather than full repr (default 1000).
Nan always represents that it's not a number, so the solution of 49th doesn't work well under numpy 1.16.3. I think we should use np.inf which indicate a infinite number instead, and it works on both versions. And there may be a flaw here, the threshold was set to 1000, so a (16,16) matrix couldn't trigger the summarization. A (32,32) matrix could demonstrate the problem well. So the solution should be as follows:
np.set_printoptions(threshold=np.inf)
Z = np.zeros((32,32))
print(Z)

@rougier
Copy link
Owner

rougier commented Jun 3, 2019

Nice. Can you make a PR ?

MoZhonglin pushed a commit to MoZhonglin/numpy-100 that referenced this issue Apr 10, 2020
@iamyifan
Copy link
Contributor

Try float("inf") instead of np.nan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants