Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ See CONTRIBUTING.md for guidelines.
## Testing

**How has this been tested?**
<!-- Describe the tests you ran to verify your changes -->
<!-- Describe the tests_version2 you ran to verify your changes -->

```python
# Example test code or commands used
Expand Down
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies:
# Tests
tests:
- changed-files:
- any-glob-to-any-file: ['tests/**/*', '**/*test*.py']
- any-glob-to-any-file: ['tests_version2/**/*', '**/*test*.py']

# Examples
examples:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/CI-models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
pip install -e .
- name: Test with pytest
run: |
pytest tests/
pytest tests_version2/

test_macos:
runs-on: macos-latest
Expand All @@ -59,7 +59,7 @@ jobs:
pip install -e .
- name: Test with pytest
run: |
pytest tests/
pytest tests_version2/

test_windows:
runs-on: windows-latest
Expand All @@ -81,4 +81,4 @@ jobs:
pip install -e .
- name: Test with pytest
run: |
pytest tests/
pytest tests_version2/
4 changes: 1 addition & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# This workflow will install Python dependencies, run tests_version2 and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Continuous Integration
Expand Down Expand Up @@ -76,8 +76,6 @@ jobs:
python -m pip install --upgrade pip
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
pip install -e .
# pip install jax==0.4.30
# pip install jaxlib==0.4.30
- name: Test with pytest
run: |
pytest brainpy/
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ Branch naming conventions:

Run the test suite:
```bash
pytest tests/
pytest tests_version2/
```

Run specific tests:
```bash
pytest tests/test_specific.py -v
pytest tests_version2/test_specific.py -v
```

### 4. Commit Your Changes
Expand Down Expand Up @@ -203,7 +203,7 @@ def simulate_network(network, duration, dt=0.1):

Aim for high test coverage on new code:
```bash
pytest --cov=brainpy tests/
pytest --cov=brainpy tests_version2/
```

## Documentation
Expand Down
14 changes: 0 additions & 14 deletions brainpy/_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@
# limitations under the License.
# ==============================================================================

"""
Comprehensive tests for the Neuron and Synapse base classes in _base.py.

This module tests:
- Neuron base class functionality and abstract interface
- Synapse base class functionality and abstract interface
- Proper initialization and parameter handling
- State management (init_state, reset_state)
- Surrogate gradient function integration
- Reset mechanisms (soft/hard)
- Custom implementations
- Edge cases and error handling
"""

import unittest

import braintools
Expand Down
2 changes: 1 addition & 1 deletion brainpy/version2/math/einops_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, expression: str, *, allow_underscore: bool = False,
self.identifiers: Set[str] = set()
# that's axes like 2, 3, 4 or 5. Axes with size 1 are exceptional and replaced with empty composition
self.has_non_unitary_anonymous_axes: bool = False
# composition keeps structure of composite axes, see how different corner cases are handled in tests
# composition keeps structure of composite axes, see how different corner cases are handled in tests_version2
self.composition: List[Union[List[str], str]] = []
if '.' in expression:
if '...' not in expression:
Expand Down
2 changes: 1 addition & 1 deletion brainpy/version2/math/tests/test_einops.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_rearrange_consistency_numpy():


def test_rearrange_permutations_numpy():
# tests random permutation of axes against two independent numpy ways
# tests_version2 random permutation of axes against two independent numpy ways
for n_axes in range(1, 10):
input = numpy.arange(2 ** n_axes).reshape([2] * n_axes)
permutation = numpy.random.permutation(n_axes)
Expand Down
2 changes: 1 addition & 1 deletion brainpy/version2/math/tests/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class TestEnvironment(unittest.TestCase):
def test_numpy_func_return(self):
# Reset random state to ensure clean state between tests
# Reset random state to ensure clean state between tests_version2
bm.random.seed()

with bm.environment(numpy_func_return='jax_array'):
Expand Down
2 changes: 1 addition & 1 deletion brainpy/version2/math/tests/test_numpy_einsum.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def test_tf_unsupported_3(self):
s = 'ij,ij,jk->ik'
self._check(s, x, y, z)

# these tests are based on https://github.com/dask/dask/pull/3412/files
# these tests_version2 are based on https://github.com/dask/dask/pull/3412/files
@parameterized.named_parameters(
{"testcase_name": "_{}_dtype={}".format(einstr, dtype.__name__), "einstr": einstr,
"dtype": dtype}
Expand Down
16 changes: 8 additions & 8 deletions brainpy/version2/math/tests/test_numpy_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def op_record(name, nargs, dtypes, shapes, rng_factory, diff_modes,
# TODO(phawkins): np.unwrap does not correctly promote its default period
# argument under NumPy 1.21 for bfloat16 inputs. It works fine if we
# explicitly pass a bfloat16 value that does not need promition. We should
# probably add a custom test harness for unwrap that tests the period
# probably add a custom test harness for unwrap that tests_version2 the period
# argument anyway.
op_record("unwrap", 1, [t for t in float_dtypes if t != dtypes.bfloat16],
nonempty_nonscalar_array_shapes,
Expand Down Expand Up @@ -539,7 +539,7 @@ def _promote_like_jnp(fun, inexact=False):
"""Decorator that promotes the arguments of `fun` to `jnp.result_type(*args)`.

jnp and np have different type promotion semantics; this decorator allows
tests make an np reference implementation act more like an jnp
tests_version2 make an np reference implementation act more like an jnp
implementation.
"""
_promote = _promote_dtypes_inexact if inexact else _promote_dtypes
Expand Down Expand Up @@ -3056,7 +3056,7 @@ def testIdentity(self, n, dtype):
for left in [None, 0]
for right in [None, 1]
for dtype in default_dtypes
# following types lack precision for meaningful tests
# following types lack precision for meaningful tests_version2
if dtype not in [np.int8, np.int16, np.float16, jnp.bfloat16]
))
def testInterp(self, shape, dtype, period, left, right):
Expand Down Expand Up @@ -3562,7 +3562,7 @@ def testHistogramBinEdges(self, shape, dtype, bins, range, weights):
for shape in [(5,), (5, 5)]
for dtype in default_dtypes
# We only test explicit integer-valued bin edges because in other cases
# rounding errors lead to flaky tests.
# rounding errors lead to flaky tests_version2.
for bins in [np.arange(-5, 6), np.array([-5, 0, 3])]
for density in [True, False]
for weights in [True, False]
Expand Down Expand Up @@ -5108,7 +5108,7 @@ def testLongLong(self):
@jtu.ignore_warning(category=UserWarning,
message="Explicitly requested dtype.*")
def testArange(self):
# test cases inspired by dask tests at
# test cases inspired by dask tests_version2 at
# https://github.com/dask/dask/blob/main/dask/array/tests/test_creation.py#L92
np_arange = jtu.with_jax_dtype_defaults(np.arange)
self.assertAllClose(bm.arange(77).value,
Expand Down Expand Up @@ -5777,7 +5777,7 @@ def testDisableNumpyRankPromotionBroadcasting(self):
FLAGS.jax_numpy_rank_promotion = prev_flag

def testStackArrayArgument(self):
# tests https://github.com/google/jax/issues/1271
# tests_version2 https://github.com/google/jax/issues/1271
@jax.jit
def foo(x):
return bm.stack(x)
Expand Down Expand Up @@ -6050,7 +6050,7 @@ def testFromString(self):
self.assertArraysEqual(expected, actual)


# Most grad tests are at the lax level (see lax_test.py), but we add some here
# Most grad tests_version2 are at the lax level (see lax_test.py), but we add some here
# as needed for e.g. particular compound ops of interest.

GradTestSpec = collections.namedtuple(
Expand Down Expand Up @@ -6126,7 +6126,7 @@ def testOpGradSpecialValue(self, op, special_value, order):
atol={np.float32: 3e-3})

def testSincGradArrayInput(self):
# tests for a bug almost introduced in #5077
# tests_version2 for a bug almost introduced in #5077
jax.grad(lambda x: bm.sinc(x).sum())(jnp.arange(10.)) # doesn't crash

def testTakeAlongAxisIssue1521(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
if sys.platform == 'win32' and sys.version_info.minor >= 11:
pytest.skip('python 3.11 does not support.', allow_module_level=True)
else:
pytest.skip('Cannot pass tests.', allow_module_level=True)
pytest.skip('Cannot pass tests_version2.', allow_module_level=True)


class TestParallel(parameterized.TestCase):
Expand Down
64 changes: 64 additions & 0 deletions docs_version2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# BrainPy Version 2 Documentation

This directory contains documentation for BrainPy 2.x, the previous major version of BrainPy.

## Overview

BrainPy 2.x is a highly flexible and extensible framework targeting general-purpose Brain Dynamics Programming (BDP). This documentation is maintained for users who are still using BrainPy 2.x.

## Important Note

**As of September 2025, BrainPy has been upgraded to version 3.x.** If you are using BrainPy 3.x, please refer to the main documentation.

To use BrainPy 2.x APIs within version 3.x installations, update your imports:

```python
# Old version (v2.x standalone)
import brainpy as bp
import brainpy.math as bm

# Using v2.x API in BrainPy 3.x
import brainpy.version2 as bp
import brainpy.version2.math as bm
```

## Documentation Contents

- **index.rst** - Main documentation entry point
- **core_concepts.rst** - Fundamental concepts of Brain Dynamics Programming
- **tutorials.rst** - Step-by-step tutorials
- **advanced_tutorials.rst** - Advanced usage patterns
- **toolboxes.rst** - Specialized toolboxes for different applications
- **api.rst** - Complete API reference
- **FAQ.rst** - Frequently asked questions
- **brainpy-changelog.md** - Version history and changes
- **brainpylib-changelog.md** - BrainPyLib backend changes

## Building Documentation

This documentation is written in reStructuredText (RST) format and can be built using Sphinx:

```bash
cd docs_version2
make html # or use the appropriate build script
```

## Installation

For BrainPy 2.x compatibility:

```bash
pip install -U brainpy[cpu]
```

## Learn More

- [Core Concepts](core_concepts.rst) - Understand the fundamentals
- [Tutorials](tutorials.rst) - Learn through examples
- [API Documentation](api.rst) - Complete reference
- [BrainPy Examples](https://brainpy-v2.readthedocs.io/projects/examples/) - Code examples
- [BrainPy Ecosystem](https://brainmodeling.readthedocs.io) - Related projects

## Support

For questions and support, please visit the [BrainPy GitHub repository](https://github.com/brainpy/BrainPy).
2 changes: 1 addition & 1 deletion docs_version2/quickstart/simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@
"start_time": "2025-10-06T03:15:11.632401Z"
}
},
"source": "PATH = '../../tests/simulation/data/hcp.npz'",
"source": "PATH = '../../tests_version2/simulation/data/hcp.npz'",
"outputs": [],
"execution_count": 26
},
Expand Down
6 changes: 3 additions & 3 deletions docs_version2/tutorial_advanced/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ Follow these steps to contribute code:
the repository:

```bash
pytest -n auto tests/
pytest -n auto tests_version2/
```

BrainPy's test suite is quite large, so if you know the specific test file that covers your
changes, you can limit the tests to that; for example:

```bash
pytest -n auto brainpy/_src/tests/test_mixin.py
pytest -n auto brainpy/_src/tests_version2/test_mixin.py
```

You can narrow the tests further by using the `pytest -k` flag to match particular test
names:

```bash
pytest -n auto brainpy/_src/tests/test_mixin.py -k testLogSumExp
pytest -n auto brainpy/_src/tests_version2/test_mixin.py -k testLogSumExp
```

BrainPy also offers more fine-grained control over which particular tests are run;
Expand Down
Loading
Loading