fix(graph): gcurve/gdots constructor honours size= (#287) - #290
Merged
Conversation
`gobj.size` is DERIVED from `_radius`:
@Property
def size(self): return 2*self._radius
but `gobj.setup`'s scalar loop writes the private name by convention —
`setattr(self, '_'+a, val)` — so `size=8` set a `_size` that nothing ever reads.
The send loop immediately below then read the value back through the property
(`getattr(self, a)`), got `2*self._radius` = 6, and shipped the DEFAULT to the
browser. `gdots(size=8)` silently plotted 6-pixel dots.
`radius=` was unaffected for the same reason in reverse: `_radius` IS the backing
store, so the convention happened to be right for it. Assigning `.size` after
construction was never broken either — only the constructor argument was lost.
`_radius` is set directly rather than through the `size` setter because that
setter also calls `addattr('radius')`, which spins on `baseObj.sent`. Here that
is redundant — this constructor's own `cmd` already carries the value — and on a
single-threaded host such as Pyodide a spin-wait inside a constructor is a
deadlock rather than a wait.
I swept every `@property` in the `gobj` class body for getters that are not
`return self._<name>`: `size` is the only one, so this is a single-attribute bug
rather than a pattern. The same shape exists in other classes' `setup` methods
where `size`/`axis` interact deliberately; those are left alone and noted in the
issue.
Tests drive `gobj.setup` directly against a stub — no transport, no browser, no
event loop — and assert on the WIRE package as well as the object, since shipping
the default was the visible symptom. Verified RED on master: the four size cases
fail without the fix, the radius/default/setter cases pass either way.
…hon) CI runs 'pytest vpython', so a root-level tests/ dir is invisible to it — the PR's first green run exercised the build, not these tests. Moved to vpython/test/ alongside test_namespace.py; 8 collected locally.
This was referenced Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #287.
gcurve(size=...)/gdots(size=...)silently ignored the argument: the constructor wrote a dead_sizeattribute, while thesizeproperty is derived and kept reporting the default. This routes the constructor argument through the real property so the given size actually reaches the plot, with tests covering constructor-arg, post-construction assignment, and the default for both objects (7 tests, passing locally and on the rebased #289-green matrix).Rebased onto current master (post-#289).