mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[python] matplotlib: handle empty range histogram
This commit is contained in:
@@ -225,11 +225,17 @@ mp_obj_t modpyplot_hist(size_t n_args, const mp_obj_t *args) {
|
||||
if (n_args >= 2) {
|
||||
nBins = mp_obj_get_int(args[1]);
|
||||
}
|
||||
|
||||
mp_float_t binWidth = (max-min)/nBins;
|
||||
// Create a array of bins
|
||||
edgeItems = m_new(mp_obj_t, nBins + 1);
|
||||
// Handle empty range case
|
||||
if (max - min <= FLT_EPSILON) {
|
||||
binWidth = 1.0;
|
||||
nBins = 1;
|
||||
}
|
||||
|
||||
// Fill the bin edges list
|
||||
mp_float_t binWidth = (max-min)/nBins;
|
||||
for (int i = 0; i < nBins+1; i++) {
|
||||
edgeItems[i] = mp_obj_new_float(min+i*binWidth);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user