-
Notifications
You must be signed in to change notification settings - Fork 103
Integrating brainstate
, brainevent
into brainpy
#763
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
Merged
Merged
Conversation
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
…streamline value handling
…nclude brainstate, brainunit, and brainevent
This commit introduces a `pyproject.toml` file to enable seamless installation using UV, the modern Python package installer.
All calls to bm.clear_buffer_memory() in test_aligns.py have been commented out, likely to prevent buffer clearing during test execution or debugging. Additionally, the unused reduce_axes argument and its documentation were removed from grad() in autograd.py for code simplification.
Renamed the Base class in ndarray.py to BaseArray and updated all references in related modules, including Array and Variable. Also fixed the while_loop wrapper in controls.py to correctly unpack operands for the body and condition functions. Uncommented bm.clear_buffer_memory() calls in test_aligns.py to ensure buffer memory is cleared after tests.
Introduced a private method to ensure the random state value exists and is valid. If the value is deleted, it is regenerated before being accessed.
Replaces all references to 'Array' with 'BaseArray' in type checks and imports to align with updated class naming. This improves consistency and clarity in the codebase.
Updated the _ensure_value_exists method to properly check the type of self._value and only regenerate the random state if it is not a numpy array, not a JAX Tracer, and has been deleted. This prevents unnecessary regeneration and ensures correct handling of different value types.
Updated the scan function to use correct argument names ('f' and 'pbar') for brainstate.transform.scan. Fixed while_loop to properly wrap cond_fun in a lambda, matching the expected signature.
…er in controls.py
# Conflicts: # brainpy/_src/math/object_transform/controls.py
…rts for compatibility
Updated the ifelse function to ensure branches are callable and to convert condition chains into mutually exclusive conditions, improving compatibility with brainstate. Modified while_loop to fallback to a native Python loop when the condition function modifies state, addressing issues with write states in brainstate.transform.while_loop.
Implemented __eq__, __ne__, __lt__, __le__, __gt__, and __ge__ in the Variable class to provide element-wise comparison using BaseArray behavior. This ensures Variable instances support intuitive comparison operations consistent with array semantics.
Enhanced the while_loop function to detect JIT context and avoid using Python while loops when operands are JAX tracers, raising an error instead. Updated tests to reflect correct state changes and to assert that JIT compilation fails when the condition function modifies state.
Added checks for missing fit records in Dense and OfflineTrainer to prevent errors when fit records are absent. Updated tests to reset random state for isolation and to accept both numpy and JAX arrays, improving compatibility and test reliability.
Replaces direct pytest invocation in CI with a new pytest_groups.py script that runs known problematic tests in isolation to avoid state pollution. Updates test_jit.py to reset random seeds and clear state before tests, improving test reproducibility and reliability.
Enhanced the BrainPy minimal test runner with clearer output formatting, timing for each test group, and summary statistics. Now displays pass/fail status with durations, extracts recent failures for easier debugging, and provides a concise summary of test results.
Replaces emoji icons (such as checkmarks and crosses) in test status print statements with plain text equivalents for improved readability and compatibility in environments that may not support emojis.
Enhanced pytest_groups.py to support parallel execution via pytest-xdist, updated documentation and environment variable handling, and improved isolation for problematic tests. Added new files to the isolated test list to prevent state conflicts and blocking issues. requirements-dev.txt updated to include pytest-xdist. Minor fix in test_abstract_models.py to ensure dt is set. Synchronized dt setting in environment.py with brainstate.environ.
Enhanced the output shown in GitHub Actions when tests fail by displaying detailed stdout and stderr, and providing a more comprehensive summary of failed and errored tests. This makes it easier to diagnose issues in CI by surfacing more relevant information from test failures.
…ance, reorganizing imports, and refining function definitions
This was referenced Jul 31, 2025
Closed
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.
No description provided.