Repository navigation
fix(matplotlib): corriger le rendu des histogrammes adaptatifs - #35
ElouenGinat wants to merge 18 commits into
Conversation
Réutiliser les fréquences Khiops pour les valeurs extrêmes et rendre visibles les classes très étroites par défaut. Refuser également le type barstacked non pris en charge. Closes #34
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The cumulative density implementation, ec edge styling, and stale notebook import remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
Updates the Matplotlib histogram adapter to preserve Khiops frequencies, improve adaptive-bin rendering, and expose hist at the package root.
Changes:
- Adds typed histogram returns and rejects unsupported stacked histograms.
- Updates plotting behavior, tests, documentation, CI, changelog, and demo metadata.
| File | Summary |
|---|---|
tests/plot/test_matplotlib_histogram.py |
Adds histogram behavior and typing tests. |
src/khisto/matplotlib/hist.py |
Implements frequency-backed plotting and return handling; cumulative density behavior and ec styling require changes. |
src/khisto/__init__.py |
Exports hist at the package root. |
sandbox/khisto_demo.ipynb |
Updates demo metadata; retains a stale _hist import that causes an import error. |
pyproject.toml |
Adds the Python 3.10 typing dependency. |
docs/index.rst |
Updates usage examples. |
docs/conf.py |
Configures Matplotlib API documentation. |
docs/api_comparison.md |
Documents unsupported histogram options. |
CHANGELOG.md |
Records the histogram changes. |
.github/workflows/ci.yaml |
Adds optional-dependency installation coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ct for unequal-width bins' Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
marcboulle
left a comment
There was a problem hiding this comment.
J'ai bien aimé la simplification de la démo ;)
Pour le reste, je n'ai fait que survolé le code rapidement. Je ne comprend pas tous les détails et le pourquoi des évolutions. C'est suite aux retours utilisateurs? ou à des tests approfondis?
J'ai quelques remarques et surtout des questions de détail.
|
|
||
| - name: Test base API without optional dependencies | ||
| run: | | ||
| uv run --isolated --no-project --with . python - <<'PY' |
There was a problem hiding this comment.
I would put this Python snippet in a separate script for easier maintenance.
| elif isinstance(patches, list): | ||
| histogram_patches = [patch for patch in patches if isinstance(patch, Polygon)] | ||
| if len(histogram_patches) != len(patches): | ||
| raise TypeError("Matplotlib returned unexpected histogram patches.") |
There was a problem hiding this comment.
I'd be more specific on the error message:
unexpected_patches = [
patch for patch in patches if not isinstance(path, Polygon)
]
...
raise TypeError(
f"Matplotlib returned unexpected histogram patches: {len(unexpected_patches)}"
f" of them are of types {', '.join(set([type(patch) for patch in unexpected_patches])}."
)There was a problem hiding this comment.
the patches are all of type Polygon or all of type BarContainer. I made the message clearer but i didn't listed all the patches in the message.
| if len(histogram_patches) != len(patches): | ||
| raise TypeError("Matplotlib returned unexpected histogram patches.") | ||
| else: | ||
| raise TypeError("Matplotlib returned unexpected histogram patches.") |
There was a problem hiding this comment.
I'd be more specific in the message here as well, specifying the type(patches) therein.
| else: | ||
| raise TypeError("Matplotlib returned unexpected histogram patches.") | ||
|
|
||
| if histtype == "bar" and not {"edgecolor", "ec"} & kwargs.keys(): |
There was a problem hiding this comment.
For more readability, I'd write this if as:
if histtype == "bar" and not {"edgecolor", "ec"}.intersection(kwargs.keys()):| @@ -6,11 +6,20 @@ | |||
|
|
|||
| from __future__ import annotations | |||
There was a problem hiding this comment.
Do we need to treat typing hints as strings here? Their eager evaluation as objects is not adequate here?
Un pyproject.toml étranger présent dans site-packages faisait planter l'import de khisto (fichier ouvert en mode texte). Le pyproject.toml du dépôt n'est désormais lu que si le paquet n'est pas installé.
Commente l'intention (rendre visibles les classes plus fines qu'un pixel) et précise le message d'erreur sur les patches inattendus.
marcboulle
left a comment
There was a problem hiding this comment.
Cela me parait bien, en tout cas d'un point de vue fonctionnel.
Un point de détail sur le CHANGELOG, à améliorer éventuellement.
Pour les tests unitaires et de non régression, je fais confiance au mainteneur.


What
histtype="barstacked".histfrom the package root and infer its return type fromhisttype.Validation
uv run pytest -quv run sphinx-build -W --keep-going -b html docs docs/_build/htmlCloses #34