Knuth’s rule fails with simple and small array (eats up system's memory)
See original GitHub issueDescription
The knuth_bin_width
is not able to handle a small and simple array.
Expected behavior
A histogram should be generated, or an error shown explaining why it was not possible to obtain it.
Actual behavior
The function starts to gobble up the system’s memory.
Steps to Reproduce
import numpy as np
import matplotlib.pyplot as plt
from astropy.visualization import hist
arr = np.array([0.05555556, 0. , 0. , 0. , 0. ,1. , 0. , 0. , 0. , 0.5 ])
ax = plt.subplot(111)
hist(arr, bins='knuth', ax=ax)
System Details
Linux-5.5.0-050500-generic-x86_64-with-glibc2.10
>>> Python 3.8.8 (default, Feb 24 2021, 21:46:12)
[GCC 7.3.0]
>>> Numpy 1.19.2
>>> astropy 4.2
>>> Scipy 1.5.2
>>> Matplotlib 3.3.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (15 by maintainers)
Top Results From Across the Web
Structured Programming with go to Statements DONALD E ...
This study focuses largely on two issues: (a) improved syntax for iterations and error exits, making it possible to write a larger class...
Read more >Memory Is Full Error in LabVIEW - NI - Support
Solution. This error message is typically encountered when developing an application with large data sets of arrays, clusters, or waveforms. ...
Read more >Data Structures & Algorithms - Quick Guide - Tutorialspoint
When the smaller sub-problems are solved, this stage recursively combines them until they formulate a solution of the original problem. This algorithmic ...
Read more >Hints for Computer System Design - Butler Lampson
Part of the problem is avoiding circularity: the file system would like to use the virtual memory, but virtual memory depends on files....
Read more >3 SOLVING PROBLEMS BY SEARCHING - Pearson Education
A simple problem-solving agent. It first formulates a goal and a problem, searches for a sequence of actions that would solve the problem,...
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 FreeTop 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
Top GitHub Comments
@Gabriel-p Even if that is case, I think it’s better than the current code which tries to optimize a highly nonconvex function that can possibly have no minimum. A grid search with a sensible choice for the upper-bound on the number of bins seems a reasonable solution. What do you think?
PS: The max number of bins could even be an input parameter with some sensible default.
Because the issue happens inside the
optimize
call. That’s whereM
grows without bound