fix(matplotlib): preserve Khiops right-closed bins - #33
Conversation
f46db29 to
8102a0b
Compare
|
|
|
||
| Notes | ||
| ----- | ||
| Khiops bins are right-closed, ``(lower, upper]``, while Matplotlib bins are |
There was a problem hiding this comment.
Etre plus laconique, plus orienté fonctionnalité (en masquant les détail d'implémentation):
"Khiops bins are right-closed, (lower, upper] , unlike Matplotlib bins which are left-closed [lower, upper), but the displayed plot is still correct."
Pour les autres fonctionq de l'API, utiliser une note concise très similaire:
"Khiops bins are right-closed, (lower, upper] , unlike Numpy bins which are left-closed [lower, upper)."
There was a problem hiding this comment.
done. Yes the finest histogram (after best) is not returned by the histogram nor the hist functions.
marcboulle
left a comment
There was a problem hiding this comment.
Concernant les warnings, je pense que l'on peut les passer en notes:
- la sémantique du note me parait plus indiquée que celle du warning
- cf. https://github.com/orgs/community/discussions/16925
- cf. la doc numpy.histogram qui utilise une note: https://numpy.org/doc/2.4/reference/generated/numpy.histogram.html
Concernant la PR précédente que tu as mergée:
- je l'avais approuvée, mais avec des remarques de de détail à prendre en compte (plus un review de Vladimir)
- je crois tu l'as mergée directement: pourrais tu ici prendre en compte les remarques de cette PR?
Pourrais-tu rebaser ta branche sur main pour pouvoir visualiser le nouveau site complet?
As-tu tester ta correction sur ton jeu de donnée à 6 valeurs entières (avec histogramme pathologique avant les correction)?
Shift observations by one ULP before Matplotlib rendering so values on internal boundaries retain their Khiops assignments.\n\nRefs #32
bfe3af0 to
6433b0c
Compare
|
J’ai rebasé la branche sur main et mis à jour la PR. Le site de doc complet est désormais visible dans la preview. J’ai également pris en compte les remarques restantes. |
popescu-v
left a comment
There was a problem hiding this comment.
Some stylistic comments.
But also a potential leak in case of failure in tests (see comment in point).
What
Axes.histone ULP toward-inf.Why
Khiops uses
(lower, upper]intervals, while Matplotlib uses[lower, upper). Without an adaptation, a value equal to an internal boundary is displayed in the neighboring interval, and the plotted density can differ substantially from the density computed by Khiops.Refs #32
This PR fixes Matplotlib rendering. It does not yet modify boundaries returned by
khisto.histogram: the NumPy compatibility strategy remains to be decided in the issue so that nativeHistogramResultdata is preserved and floating-point edge cases are handled correctly.How to test
uv run pytest -o addopts='' tests/plot/test_matplotlib_histogram.py -q uv run ruff check src/khisto/matplotlib/hist.py tests/plot/test_matplotlib_histogram.py uv run ruff format --check src/khisto/matplotlib/hist.py tests/plot/test_matplotlib_histogram.py uv run pre-commit run --all-filesLocal result: 19 tests passed and all hooks succeeded.
Documentation preview
khisto.histogramcompute_histogramsandHistogramResultDocumentation preview
khisto.histogramcompute_histogramsandHistogramResult