Skip to content

Commit 715361e

Browse files
chaoming0625oujago
andauthored
Rollback (#789)
* remove version2 * remove .version2 import * fix: create static directory and remove version-specific announcements from conf.py * refactor: rename experimental directories and update imports to state-based * refactor: update imports to use brainpy.state_based and clean up code structure * refactor: update imports to use brainpy.state_based and remove deprecated version notes * refactor: update documentation to reflect module renaming from version2 to main namespace --------- Co-authored-by: oujago <[email protected]>
1 parent 09c55da commit 715361e

File tree

573 files changed

+1907
-2109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

573 files changed

+1907
-2109
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ cython_debug/
233233
/docs/_static/logos/
234234
/docs/_build/
235235
/docs/changelog.md
236-
/docs_version3/_build/
237-
/docs_version3/_static/logos/
238-
/docs_version3/changelog.md
236+
/docs_state_based/_build/
237+
/docs_state_based/_static/logos/
238+
/docs_state_based/changelog.md
239239
/examples_version2/dynamics_training/data/
240240
/docs/

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
BrainPy is a flexible, efficient, and extensible framework for computational neuroscience and brain-inspired computation based on the Just-In-Time (JIT) compilation. It provides an integrative ecosystem for brain dynamics programming, including brain dynamics **building**, **simulation**, **training**, **analysis**, etc.
1818

1919
- **Source**: https://github.com/brainpy/BrainPy
20-
- **Documentation (brainpy v3.0)**: https://brainpy.readthedocs.io/
21-
- **Documentation (brainpy v2.0)**: https://brainpy-v2.readthedocs.io/
20+
- **Documentation**: https://brainpy.readthedocs.io/
21+
- **Documentation (state-based)**: https://brainpy-state.readthedocs.io/
2222
- **Bug reports**: https://github.com/brainpy/BrainPy/issues
2323
- **Ecosystem**: https://brainmodeling.readthedocs.io/
2424

brainpy/__init__.py

Lines changed: 170 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
# Copyright 2025 BrainX Ecosystem Limited. All Rights Reserved.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,87 +14,172 @@
1314
# limitations under the License.
1415
# ==============================================================================
1516

16-
__version__ = "3.0.0"
17-
__version_info__ = (3, 0, 0)
18-
19-
from . import mixin
20-
from . import version2
21-
from ._base import *
22-
from ._base import __all__ as base_all
23-
from ._errors import *
24-
from ._errors import __all__ as errors_all
25-
from ._exponential import *
26-
from ._exponential import __all__ as exp_all
27-
from ._inputs import *
28-
from ._inputs import __all__ as inputs_all
29-
from ._lif import *
30-
from ._lif import __all__ as neuron_all
31-
from ._projection import *
32-
from ._projection import __all__ as proj_all
33-
from ._readout import *
34-
from ._readout import __all__ as readout_all
35-
from ._stp import *
36-
from ._stp import __all__ as stp_all
37-
from ._synapse import *
38-
from ._synapse import __all__ as synapse_all
39-
from ._synaptic_projection import *
40-
from ._synaptic_projection import __all__ as synproj_all
41-
from ._synouts import *
42-
from ._synouts import __all__ as synout_all
43-
44-
__main__ = ['version2', 'mixin'] + errors_all + inputs_all + neuron_all + readout_all + stp_all + synapse_all
45-
__main__ = __main__ + synout_all + base_all + exp_all + proj_all + synproj_all
46-
del errors_all, inputs_all, neuron_all, readout_all, stp_all, synapse_all, synout_all, base_all
47-
del exp_all, proj_all, synproj_all
48-
49-
50-
# Deprecation warnings for brainpy.xxx -> brainpy.version2.xxx
51-
def __getattr__(name):
52-
"""Provide deprecation warnings for moved modules."""
53-
import warnings
54-
55-
if hasattr(version2, name):
56-
warnings.warn(
57-
f"Accessing 'brainpy.{name}' is deprecated. "
58-
f"Please use 'brainpy.version2.{name}' instead.",
59-
DeprecationWarning,
60-
stacklevel=2
61-
)
62-
return getattr(version2, name)
63-
64-
raise AttributeError(f"'brainpy' has no attribute '{name}'")
65-
66-
67-
def __dir__():
68-
"""Return list of attributes including deprecated ones for tab completion."""
69-
# Get the default attributes
70-
default_attrs = list(globals().keys())
71-
72-
# Add all public attributes from version2 for discoverability
73-
version2_attrs = [attr for attr in dir(version2) if not attr.startswith('_')]
74-
75-
# Combine and return unique attributes
76-
return sorted(set(default_attrs + version2_attrs))
77-
78-
79-
# Register deprecated modules in sys.modules to support "import brainpy.xxx" syntax
80-
import sys as _sys
81-
82-
_deprecated_modules = [
83-
'math', 'check', 'tools', 'connect', 'initialize', 'init', 'conn',
84-
'optim', 'losses', 'measure', 'inputs', 'encoding', 'checkpoints',
85-
'algorithms', 'integrators', 'ode', 'sde', 'fde',
86-
'dnn', 'layers', 'dyn', 'running', 'train', 'analysis',
87-
'channels', 'neurons', 'rates', 'synapses', 'synouts', 'synplast',
88-
'visualization', 'visualize', 'types', 'modes', 'context',
89-
'helpers', 'delay', 'dynsys', 'runners', 'transform', 'dynold'
90-
]
91-
92-
# Create wrapper modules that show deprecation warnings
93-
for _mod_name in _deprecated_modules:
94-
if hasattr(version2, _mod_name):
95-
_sys.modules[f'brainpy.{_mod_name}'] = getattr(version2, _mod_name)
96-
97-
del _sys, _mod_name, _deprecated_modules
98-
99-
version2.__version__ = __version__
17+
__version__ = "3.0.1"
18+
__version_info__ = (3, 0, 1)
19+
20+
21+
from brainpy import _errors as errors
22+
from brainpy import mixin
23+
# fundamental supporting modules
24+
from brainpy import check, tools
25+
# Part: Math Foundation #
26+
# ----------------------- #
27+
# math foundation
28+
from brainpy import math
29+
# Part: Toolbox #
30+
# --------------- #
31+
# modules of toolbox
32+
from . import (
33+
connect, # synaptic connection
34+
initialize, # weight initialization
35+
optim, # gradient descent optimizers
36+
losses, # loss functions
37+
measure, # methods for data analysis
38+
inputs, # methods for generating input currents
39+
encoding, # encoding schema
40+
checkpoints, # checkpoints
41+
check, # error checking
42+
algorithms, # online or offline training algorithms
43+
)
44+
from .math import BrainPyObject
45+
46+
# convenient alias
47+
conn = connect
48+
init = initialize
49+
50+
# numerical integrators
51+
from brainpy import integrators
52+
from brainpy.integrators import ode, sde, fde
53+
from brainpy.integrators.base import (Integrator as Integrator)
54+
from brainpy.integrators.joint_eq import (JointEq as JointEq)
55+
from brainpy.integrators.runner import (IntegratorRunner as IntegratorRunner)
56+
from brainpy.integrators.ode.generic import (odeint as odeint)
57+
from brainpy.integrators.sde.generic import (sdeint as sdeint)
58+
from brainpy.integrators.fde.generic import (fdeint as fdeint)
59+
60+
# Part: Models #
61+
# -------------- #
62+
63+
# base classes
64+
from brainpy.dynsys import (
65+
DynamicalSystem as DynamicalSystem,
66+
DynSysGroup as DynSysGroup, # collectors
67+
Sequential as Sequential,
68+
Dynamic as Dynamic, # category
69+
Projection as Projection,
70+
receive_update_input, # decorators
71+
receive_update_output,
72+
not_receive_update_input,
73+
not_receive_update_output,
74+
)
75+
76+
DynamicalSystemNS = DynamicalSystem
77+
Network = DynSysGroup
78+
# delays
79+
from brainpy.delay import (
80+
VarDelay as VarDelay,
81+
)
82+
83+
# building blocks
84+
from brainpy import (
85+
dnn, layers, # module for dnn layers
86+
dyn, # module for modeling dynamics
87+
)
88+
89+
NeuGroup = NeuGroupNS = dyn.NeuDyn
90+
dyn.DynamicalSystem = DynamicalSystem
91+
92+
# common tools
93+
from brainpy.context import (share as share)
94+
from brainpy.helpers import (
95+
reset_level as reset_level,
96+
reset_state as reset_state,
97+
save_state as save_state,
98+
load_state as load_state,
99+
clear_input as clear_input
100+
)
101+
102+
# Part: Running #
103+
# --------------- #
104+
from brainpy.runners import (DSRunner as DSRunner)
105+
from brainpy.transform import (LoopOverTime as LoopOverTime, )
106+
from brainpy import (running as running)
107+
108+
# Part: Training #
109+
# ---------------- #
110+
from brainpy.train.base import (DSTrainer as DSTrainer, )
111+
from brainpy.train.back_propagation import (BPTT as BPTT,
112+
BPFF as BPFF, )
113+
from brainpy.train.online import (OnlineTrainer as OnlineTrainer,
114+
ForceTrainer as ForceTrainer, )
115+
from brainpy.train.offline import (OfflineTrainer as OfflineTrainer,
116+
RidgeTrainer as RidgeTrainer, )
117+
118+
# Part: Analysis #
119+
# ---------------- #
120+
from brainpy import (analysis as analysis)
121+
122+
# Part: Others #
123+
# ---------------- #
124+
import brainpy.visualization as visualize
125+
126+
# Part: Deprecations #
127+
# -------------------- #
128+
from brainpy import train
129+
from brainpy import (
130+
channels, # channel models
131+
neurons, # neuron groups
132+
synapses, # synapses
133+
rates, # rate models
134+
synouts, # synaptic output
135+
synplast, # synaptic plasticity
136+
)
137+
from brainpy.math.object_transform.base import (
138+
Base as Base,
139+
)
140+
141+
from brainpy.math.object_transform.collectors import (
142+
ArrayCollector as ArrayCollector,
143+
Collector as Collector,
144+
)
145+
146+
147+
from brainpy.deprecations import deprecation_getattr
148+
149+
optimizers = optim
150+
151+
152+
153+
if __name__ == '__main__':
154+
connect
155+
initialize, # weight initialization
156+
optim, # gradient descent optimizers
157+
losses, # loss functions
158+
measure, # methods for data analysis
159+
inputs, # methods for generating input currents
160+
encoding, # encoding schema
161+
checkpoints, # checkpoints
162+
check, # error checking
163+
mixin, # mixin classes
164+
algorithms, # online or offline training algorithms
165+
check, tools, errors, math
166+
BrainPyObject,
167+
integrators, ode, sde, fde
168+
Integrator, JointEq, IntegratorRunner, odeint, sdeint, fdeint
169+
DynamicalSystem, DynSysGroup, Sequential, Dynamic, Projection
170+
receive_update_input, receive_update_output, not_receive_update_input, not_receive_update_output
171+
VarDelay
172+
dnn, layers, dyn
173+
NeuGroup, NeuGroupNS
174+
share
175+
reset_level, reset_state, save_state, load_state, clear_input
176+
DSRunner, LoopOverTime, running
177+
DSTrainer, BPTT, BPFF, OnlineTrainer, ForceTrainer,
178+
OfflineTrainer, RidgeTrainer
179+
analysis
180+
visualize
181+
train
182+
channels, neurons, synapses, rates, state_based, synouts, synplast
183+
modes
184+
Base
185+
ArrayCollector, Collector, errors
File renamed without changes.

brainpy/version2/algorithms/offline.py renamed to brainpy/algorithms/offline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import numpy as np
2020
from jax.lax import while_loop
2121

22-
import brainpy.version2.math as bm
23-
from brainpy.version2.math.object_transform.base import BrainPyObject
24-
from brainpy.version2.types import ArrayType
22+
import brainpy.math as bm
23+
from brainpy.math.object_transform.base import BrainPyObject
24+
from brainpy.types import ArrayType
2525
from .utils import (Sigmoid,
2626
Regularization,
2727
L1Regularization,

brainpy/version2/algorithms/online.py renamed to brainpy/algorithms/online.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import jax.numpy as jnp
1818
from jax import vmap
1919

20-
import brainpy.version2.math as bm
21-
from brainpy.version2.math.object_transform.base import BrainPyObject
20+
import brainpy.math as bm
21+
from brainpy.math.object_transform.base import BrainPyObject
2222

2323
__all__ = [
2424
# brainpy_object class

brainpy/version2/algorithms/utils.py renamed to brainpy/algorithms/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# ==============================================================================
1616
from itertools import combinations_with_replacement
1717

18-
import brainpy.version2.math as bm
18+
import brainpy.math as bm
1919

2020
__all__ = [
2121
'Sigmoid',
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)