-
Notifications
You must be signed in to change notification settings - Fork 107
fix(analysis): fixed-point classification, nullcline selection, GD batches, plot kwargs #849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Copyright 2025 BrainX Ecosystem Limited. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ============================================================================== | ||
| import pytest | ||
|
|
||
| from brainpy.analysis import plotstyle | ||
|
|
||
|
|
||
| def test_set_markersize_updates_global(): | ||
| """Regression for P13-H1: ``set_markersize`` must update the module global | ||
| ``_markersize`` (it previously assigned to a typo local ``__markersize``).""" | ||
| original = plotstyle._markersize | ||
| try: | ||
| plotstyle.set_markersize(33) | ||
| # per-key schema entries updated | ||
| assert plotstyle.plot_schema[plotstyle.SADDLE_NODE]['markersize'] == 33 | ||
| # module global updated, not just the per-key dicts | ||
| assert plotstyle._markersize == 33 | ||
| finally: | ||
| plotstyle.set_markersize(original) | ||
|
|
||
|
|
||
| def test_set_markersize_type_check(): | ||
| with pytest.raises(TypeError): | ||
| plotstyle.set_markersize(1.5) | ||
|
|
||
|
|
||
| def test_set_plot_schema_validations(): | ||
| with pytest.raises(TypeError): | ||
| plotstyle.set_plot_schema(123) | ||
| with pytest.raises(KeyError): | ||
| plotstyle.set_plot_schema('not-a-real-fixed-point-type') | ||
| # valid update | ||
| plotstyle.set_plot_schema(plotstyle.SADDLE_NODE, color='black') | ||
| assert plotstyle.plot_schema[plotstyle.SADDLE_NODE]['color'] == 'black' | ||
|
Comment on lines
+40
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Avoid leaking global This test leaves |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Using
pophere mutatesplot_styleand assumes it is a mutable mapping, which may surprise callers or break with non-dict mappings.This changes behavior vs the previous
get: it now mutatesplot_styleand requires it to implementpop. That can silently alter a dict that callers reuse afterplot_vector_field, and can fail for genericMappinginstances. You can avoid both issues by copying before mutation (e.g.plot_style = dict(plot_style)) and popping from the copy used forstreamplot, preserving the multiple-values fix without changing the caller’s object or type contract.