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.

Knuth’s rule fails with simple and small array (eats up system's memory)

See original GitHub issue

Description

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:open
  • Created 3 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
mircacommented, Sep 27, 2021

@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.

1reaction
Gabriel-pcommented, Mar 13, 2021

Because the issue happens inside the optimize call. That’s where M grows without bound

Read more comments on GitHub >

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

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