Skip to content

Commit

Permalink
hist.m: Test for equal bin spacing using a numeric tolerance (bug #66…
Browse files Browse the repository at this point in the history
…753)

* hist.m: Compare spacing of bins and assume equality if difference is less
than "eps (max (x))" (numeric tolerance that scales with size of input).
  • Loading branch information
Rik committed Feb 5, 2025
1 parent f486c0a commit 662edeb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/plot/draw/hist.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
equal_bin_spacing = ! isempty (strfind (typeinfo (x), "range"));
if (! equal_bin_spacing)
diffs = diff (x);
if (all (diffs == diffs(1)))
if (! any ((diffs - diffs(1)) > eps (max (x))))
equal_bin_spacing = true;
endif
endif
Expand Down

0 comments on commit 662edeb

Please sign in to comment.