Skip to content

Commit c904ecc

Browse files
committed
Enhance documentation for khisto-python library
- Updated the main index.rst to provide a clearer introduction to Khisto, highlighting its adaptive binning capabilities and various entry points for users. - Added a description in matplotlib/index.rst to explain the use of khisto.matplotlib.hist for adaptive histogramming, emphasizing its convenience compared to traditional plt.hist.
1 parent 490e87c commit c904ecc

7 files changed

Lines changed: 160 additions & 76 deletions

File tree

docs/api_comparison.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
API Comparison
22
==============
33

4-
This document compares the Khisto API with NumPy and Matplotlib, highlighting similarities and differences.
4+
This document compares the current Khisto APIs with NumPy and Matplotlib.
55

66
NumPy Comparison
77
----------------
@@ -155,6 +155,9 @@ Signature Comparison
155155
color=None,
156156
label=None,
157157
ax=None,
158+
edgecolor=None,
159+
linewidth=None,
160+
alpha=None,
158161
**kwargs,
159162
)
160163
@@ -180,12 +183,18 @@ Key Differences
180183
* - **Cumulative**
181184
- Supported
182185
- Supported
186+
* - **Reverse cumulative**
187+
- Supported with negative ``cumulative``
188+
- Supported with negative ``cumulative``
183189
* - **Stacked**
184190
- Supported
185191
- Not supported
186192
* - **Weights**
187193
- Supported
188194
- Not supported
195+
* - **Unsupported histogram args**
196+
- None
197+
- ``bins``, ``stacked``, and ``weights`` raise a ``TypeError``
189198
* - **Multiple datasets**
190199
- Supported
191200
- Sequences are concatenated into one dataset
@@ -228,6 +237,10 @@ Common Parameters (Same Behavior)
228237
plt.hist(data, density=True, cumulative=True)
229238
hist(data, density=True, cumulative=True)
230239
240+
# reverse cumulative view
241+
plt.hist(data, cumulative=-1)
242+
hist(data, cumulative=-1)
243+
231244
# histogram type
232245
plt.hist(data, histtype='step')
233246
hist(data, histtype='step')
@@ -316,6 +329,10 @@ Feature Matrix
316329
- No
317330
- Yes
318331
- Yes
332+
* - Reverse cumulative
333+
- No
334+
- Yes
335+
- Yes
319336
* - Plotting
320337
- No
321338
- Yes

docs/array/histogram/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
khisto.array.histogram
33
======================
44

5+
The fastest way to use Khisto: a NumPy-like ``(hist, bin_edges)`` API with
6+
adaptive bins, optional ``max_bins`` control, and no plotting overhead.
7+
58
.. automodule:: khisto.array.histogram
69

710
Main Modules
@@ -11,4 +14,5 @@ Main Modules
1114
:recursive:
1215
:nosignatures:
1316

17+
histogram
1418
api

docs/conf.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,32 @@
66
# -- Project information -----------------------------------------------------
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
88
import os
9+
import re
910
import sys
1011
from pathlib import Path
1112

12-
sys.path.append("..")
13-
sys.path.append(os.path.join("..", "src"))
13+
DOCS_DIR = Path(__file__).resolve().parent
14+
ROOT_DIR = DOCS_DIR.parent
15+
16+
sys.path.append(str(ROOT_DIR))
17+
sys.path.append(str(ROOT_DIR / "src"))
18+
19+
20+
def _read_release() -> str:
21+
init_file = ROOT_DIR / "src" / "khisto" / "__init__.py"
22+
match = re.search(
23+
r'^__version__\s*=\s*"(?P<version>[^"]+)"',
24+
init_file.read_text(encoding="utf-8"),
25+
re.MULTILINE,
26+
)
27+
if match is None:
28+
raise RuntimeError(f"Could not determine khisto version from {init_file}")
29+
return match.group("version")
1430

1531
project = 'khisto-python'
1632
copyright = '2026, The Khiops Team'
1733
author = 'The Khiops Team'
18-
release = "0.1.0" # TODO: use pyproject metadata here
34+
release = _read_release()
1935

2036
# -- General configuration ---------------------------------------------------
2137
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

docs/core/index.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
khisto.core
33
============
44

5+
Use ``khisto.core`` when you want to go beyond the default answer and inspect
6+
the full histogram series returned by the Khiops backend.
7+
58
.. automodule:: khisto.core
69

710
Main Modules
@@ -11,4 +14,6 @@ Main Modules
1114
:recursive:
1215
:nosignatures:
1316

17+
compute_histograms
18+
HistogramResult
1419
backend

docs/demo.ipynb

Lines changed: 99 additions & 71 deletions
Large diffs are not rendered by default.

docs/index.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@
66
khisto-python documentation
77
===========================
88

9-
This is the complete API reference for the Khisto Python library.
9+
Khisto helps you build histograms that look right on the first try.
10+
11+
It replaces fixed-width bin guesses with adaptive bins computed by the Khiops
12+
algorithm, so dense regions stay detailed and sparse regions stay readable.
13+
14+
Pick the entry point that matches your workflow:
15+
16+
- :doc:`demo` for a runnable tour.
17+
- :doc:`array/histogram/index` for a NumPy-like API with better bins.
18+
- :doc:`matplotlib/index` for plots that stay familiar but look sharper.
19+
- :doc:`core/index` for full access to the histogram series.
20+
- :doc:`api_comparison` for a quick comparison with NumPy and matplotlib.
1021

1122
.. toctree::
1223
:maxdepth: 2

docs/matplotlib/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
khisto.matplotlib
33
=================
44

5+
Use ``khisto.matplotlib.hist`` when you want the convenience of ``plt.hist``
6+
with bins that adapt to the data instead of flattening it.
7+
58
.. automodule:: khisto.matplotlib
69

710
Main Modules

0 commit comments

Comments
 (0)