pyd3js-array
Python port of d3-array.
Tracked version: see upstream_lock.json.
What you get
- 100% upstream export parity (for the pinned
d3-array@3.2.4): the compatibility matrix below covers every upstream export; nothing is marked[missing]. - 100% Python test coverage for
pyd3js_array(run the coverage command below). - 100% upstream
d3-arrayJS tests vendored and passing: the upstream Mocha suite underpackages/pyd3js-array/upstream/d3-array/test/is run via a pytest gate (-m upstream).
Install
From PyPI:
pip install pyd3js-array
This repo is a uv workspace monorepo. For local development:
uv sync --group dev
Usage
import pyd3js_array as ar
print(ar.extent([5, 1, 2, 3, 4]))
print(ar.min([5, 1, 2, 3, 4]))
print(ar.max([5, 1, 2, 3, 4]))
print(ar.range(2, 5))
print(ar.ticks(0, 1, 5))
print(ar.nice(0.2, 9.6, 5))
b = ar.bin().domain([0, 10]).thresholds([2, 4, 6, 8])
bins = b([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
print([(x.x0, x.x1, len(x)) for x in bins])
print(ar.bisectLeft([1, 2, 2, 3], 2))
people = [{"v": 1}, {"v": 2}, {"v": 2}, {"v": 3}]
print(ar.bisector(lambda d: d["v"]).right(people, 2))
print(ar.sum([1, 2, 3]))
print(ar.mean([1, 2, 3]))
print(ar.deviation([1, 2, 3]))
(1, 5)
1
5
[2.0, 3.0, 4.0]
[0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
(0.0, 10.0)
[(0.0, 2.0, 2), (2.0, 4.0, 2), (4.0, 6.0, 2), (6.0, 8.0, 2), (8.0, 10.0, 3)]
1
3
6.0
2.0
1.0
Accessors receive (d, i, array) (mirroring D3):
import pyd3js_array as ar
data = [{"value": 3}, {"value": 1}, {"value": 2}]
print(ar.extent(data, lambda d, i, a: d["value"]))
(1, 3)
Stability & intentional deviations
- Keyword conflicts: internally we use
range_, but the public API exports it asrangeto match D3. - Oracle parity limits: oracle tests run through JSON, so some values (e.g.
Infinity,-0,NaN) can’t be round-tripped reliably; those edge cases are covered with Python-only unit tests. - Non-determinism:
shuffle()is tested via invariants (permutation + range) rather than exact oracle equality.
Compatibility matrix
Pinned upstream inventory: docs/UPSTREAM_API.md (from d3-array@3.2.4).
Legend:
[oracle]: implemented and has oracle parity tests for representative JSON-safe cases.[unit-only: …]: implemented but oracle parity is blocked/limited (e.g. JSON round-trip, nondeterminism).[missing]: reserved for future upstream drift (should not appear for the pinned version).
Upstream exports (d3-array@3.2.4)
Adder— [unit-only: non-JSON class]InternMap— [oracle]InternSet— [oracle]ascending— [oracle]bin— [oracle]bisect— [oracle]bisectCenter— [oracle]bisectLeft— [oracle]bisectRight— [oracle]bisector— [oracle]blur— [oracle]blur2— [oracle]blurImage— [oracle]count— [oracle]cross— [oracle]cumsum— [oracle]descending— [oracle]deviation— [oracle]difference— [oracle]disjoint— [oracle]every— [oracle]extent— [oracle]fcumsum— [oracle]filter— [oracle]flatGroup— [oracle]flatRollup— [oracle]fsum— [oracle]greatest— [oracle]greatestIndex— [oracle]group— [oracle]groupSort— [oracle]groups— [oracle]histogram— [oracle]index— [oracle]indexes— [oracle]intersection— [oracle]least— [oracle]leastIndex— [oracle]map— [oracle]max— [oracle]maxIndex— [oracle]mean— [oracle]median— [oracle]medianIndex— [oracle]merge— [oracle]min— [oracle]minIndex— [oracle]mode— [oracle]nice— [oracle]pairs— [oracle]permute— [oracle]quantile— [oracle]quantileIndex— [oracle]quantileSorted— [oracle]quickselect— [oracle]range— [oracle]rank— [oracle]reduce— [oracle]reverse— [oracle]rollup— [oracle]rollups— [oracle]scan— [oracle]shuffle— [unit-only: nondeterministic]shuffler— [oracle]some— [oracle]sort— [oracle]subset— [oracle]sum— [oracle]superset— [oracle]thresholdFreedmanDiaconis— [oracle]thresholdScott— [oracle]thresholdSturges— [oracle]tickIncrement— [oracle]tickStep— [oracle]ticks— [oracle]transpose— [oracle]union— [oracle]variance— [oracle]zip— [oracle]
Testing
Run the package tests:
uv run pytest packages/pyd3js-array/tests
Coverage (Python)
uv run pytest packages/pyd3js-array/tests --cov=pyd3js_array --cov-report=term-missing
Oracle parity tests (Node)
Some tests compare behavior against real d3-array via the repo’s Node oracle:
cd tools/oracle && npm ci
uv run pytest -m oracle packages/pyd3js-array/tests
Notes:
- Oracle tests must use JSON-safe values (avoid
Infinity,-0, andNaN). - You can optionally enable local oracle caching by creating
packages/pyd3js-array/.envwith:ORACLE_CACHE=1(do not commit it).
Upstream d3-array test suite (vendored)
We vendor the pinned upstream d3-array repo (including its Mocha test suite) and run it via pytest.
uv run python scripts/vendor_upstream.py
cd packages/pyd3js-array/upstream/d3-array && npm install --legacy-peer-deps
uv run pytest -m upstream packages/pyd3js-array/tests
Documentation
- User guide:
docs/USER_GUIDE.md - Changelog:
docs/CHANGELOG.md - Design notes / history:
docs/ROADMAP.md
Metadata
Release files for pyd3js-array 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyd3js_array-0.1.1.tar.gz | 5.1 MB | Without provenance | Details for pyd3js_array-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyd3js_array-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pyd3js_array-0.1.1-py3-none-any.whl |
Total release size: 5.1 MB
Release files / pyd3js_array-0.1.1.tar.gz
| Download URL | pyd3js_array-0.1.1.tar.gz |
|---|---|
| Size | 5.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2fae1c5f911fe8fd4eb367d2d0b38c322cec2224663c930a89eae172fba1d47
|
|
BLAKE2b-256 checksum How to use checksums |
50e8150e3028c188d75568113918acef3e654a5b8bbdb84a78a27e9b99314c06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / pyd3js_array-0.1.1-py3-none-any.whl
| Download URL | pyd3js_array-0.1.1-py3-none-any.whl |
|---|---|
| Size | 56.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c34c83f2069d9be2adc2ed1fbcdc6a55706c6e649a71a9ffbf9a1c621cbc244
|
|
BLAKE2b-256 checksum How to use checksums |
7ae764e5a67e5b4c2345710049939a19ae97310d7e1c57ec44812e8843190708
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for pyd3js-array 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.