Repository navigation
Document mesa_signals and add it to the API reference - #4190
Conversation
- Add a Signals section to the experimental API reference, listing the public API in reading order with a short introduction. - Observable: document that it signals on assignment only (changes made in place to a mutable value are not observed), that changes are detected with !=, how to set an initial value, and what subscribers receive; add an example. - HasEmitters, observe, observe_class: document that handlers are held by weak reference, so a lambda or local function is silently dropped unless kept alive elsewhere; document the accepted names and signal types, including ALL. - Message: document its fields. - computed_property: document lazy recomputation, the CHANGED signal on invalidation (with only old), and the cyclical dependency error. - BaseObservable: describe what an Observable is and fallback_value. - Run the doctests in core.py as part of the test suite. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RbrUQUQAArrpH7rYQFt6KW
ObservableList no longer uses fallback_value as the old value of its first assignment (mesa#3988), so the BaseObservable docstring now uses ContinuousState, which uses it as its initial value, as the example. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RbrUQUQAArrpH7rYQFt6KW
Since mesa#4056, subscriptions survive deepcopy and pickle as far as their handlers come along. Document this in the HasEmitters docstring, which the API reference renders, including that a bound method stays subscribed only if its object is copied along with the emitter. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RbrUQUQAArrpH7rYQFt6KW
|
Thanks for documenting signal behavior and adding an executable example. @quaquel, related #4189 changes two behaviors documented here: reading before assignment and the first signal's Automated note by an AI model; it can be wrong, and maintainers make the decisions. About this bot. |
EwoutH
left a comment
There was a problem hiding this comment.
Clear docs, and nice that the example runs as a doctest.
Same note as on #4189: if that one lands first, the Observable docstring here should mention fallback_value (reading before assignment returns it, and it is the first old value) instead of saying reading always raises and old is always None.
|
I fixed the docstring as suggested. |
Observable: document that it signals on assignment only (changes made in place to a mutable value are not observed), that changes are detected with !=, how to set an initial value, and what subscribers receive; add an example.HasEmitters, observe, observe_class: document that handlers are held by weak reference, so a lambda or local function is silently dropped unless kept alive elsewhere; document the accepted names and signal types, including ALL.Message: document its fields.computed_property: document lazy recomputation, the CHANGED signal on invalidation (with only old), and the cyclical dependency error.BaseObservable: describe what an Observable is and fallback_value.Claude was used in creating this.