Composition line charts bridge NaN gaps (pre-existing in 0.0.8)

Aperta
#556 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
numpy, python

Direzione di ricerca

Start by comparing the composition line payload and rendering path with the native xy.pyplot exports, which preserve gaps; the issue provides a minimal reproduction and a 100,000-point decimation case. Trace how invalid samples are removed and how M4 decimation handles gaps, then inspect the relevant specification and news fragment. Done means direct lines and decimated lines preserve separate segments for invalid x or y values, including with clipping, zoom, and streaming append, while finite-data behavior and native pyplot gap behavior remain intact.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Composition line charts remove invalid samples and connect the surviving points across the missing interval. This invents continuity where the data should have a gap.

Classification: pre-existing bug, reproduced in published PyPI xy==0.0.8 and xy==0.0.9a1. This is not a regression introduced by the alpha and is tracked as a follow-up, not a blocker for the 0.0.9 release.

Reproduction

Install either published version in a clean environment:

uv venv --python 3.11 .venv
uv pip install --python .venv/bin/python 'xy==0.0.9a1'
.venv/bin/python repro.py

Save this as repro.py:

from pathlib import Path

import numpy as np
import xy

chart = xy.line_chart(
    xy.line(np.arange(6), [0.0, 1.0, np.nan, np.nan, 1.0, 0.0]),
    width=800,
    height=420,
)
Path("gap.html").write_text(chart.to_html())
Path("gap.svg").write_text(chart.to_svg())
Path("gap.png").write_bytes(chart.to_png(scale=1))
print(xy.__version__)
print(chart.figure().build_payload()[0]["traces"])

Open the HTML in a browser and inspect the PNG/SVG. Repeat in a separate environment with xy==0.0.8.

Actual: one continuous line connects x=1 to x=4, crossing the missing x=2 and x=3 samples. The direct payload contains six input points but only four emitted marks, without preserving the gap between the surviving points.

Expected: two observed segments, x=0→1 and x=4→5, with no connecting line between them.

This contradicts design-dossier §19: Nulls, NaN, and gaps: invalid samples must create line breaks, including after decimation, while invalid values stay out of GPU buffers.

Verified scope and evidence
Case PyPI 0.0.8 PyPI 0.0.9a1
Composition, direct line with NaN y Bridges gap Bridges gap
Composition, direct line with NaN x Bridges gap Bridges gap
Composition, 100,000-point M4-decimated line with NaN y Bridges gap Bridges gap
Equivalent native xy.pyplot SVG/PNG exports Preserve gaps Preserve gaps

For the NaN-x case, use x = np.arange(6, dtype=float); x[2:4] = np.nan and y = [0, 1, 1, 1, 1, 0].

For the decimated case:

x = np.arange(100_000, dtype=float)
y = np.ones(len(x))
y[30_000:70_000] = np.nan
chart = xy.line_chart(xy.line(x, y), width=800, height=420)

The composition SVG has one path/move in all three cases; the equivalent pyplot exports have disjoint segments. PNGs were inspected visually, and the small direct example was also confirmed in a real Chromium browser. The same problem is visible in an ordinary datetime revenue report with missing days.

Environment: Linux x86_64, CPython 3.11.15, NumPy 2.4.6, native XY core, independent PyPI installations with no editable checkout or installed-package patches. Browser confirmation used Chromium with software WebGL.

Acceptance criteria
  • Preserve gap boundaries for invalid x or y samples in direct line payloads.
  • Preserve boundaries through M4 decimation; buckets must not span missing intervals.
  • Browser, PNG, and SVG show separate observed segments without NaNs in GPU buffers.
  • Cover multiple gaps, clipping/zoom, and streaming append while preserving finite-data behavior.
  • Keep native pyplot gap behavior intact and update the relevant specification and news fragment with the fix.
Lingua principale
Python
Stelle
1.9k
Fork
79
Merge medio
1g 39m
PR unite (30g)
22

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di reflex-dev/xy

Tutte le issue di reflex-dev/xy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.