diff --git a/brainpy/__init__.py b/brainpy/__init__.py index 8b9d35c5..0f0b1b4f 100644 --- a/brainpy/__init__.py +++ b/brainpy/__init__.py @@ -14,7 +14,7 @@ # limitations under the License. # ============================================================================== -__version__ = "2.7.6" +__version__ = "2.7.7" __version_info__ = tuple(map(int, __version__.split("."))) from brainpy import _errors as errors @@ -133,20 +133,14 @@ synouts, # synaptic output synplast, # synaptic plasticity ) -from brainpy.math.object_transform.base import ( - Base as Base, -) +from brainpy.math.object_transform.base import Base as Base from brainpy.math.object_transform.collectors import ( ArrayCollector as ArrayCollector, Collector as Collector, ) -from brainpy.deprecations import deprecation_getattr - optimizers = optim - # New package from brainpy import state - diff --git a/brainpy/dnn/linear.py b/brainpy/dnn/linear.py index 87dd0435..a38e5d38 100644 --- a/brainpy/dnn/linear.py +++ b/brainpy/dnn/linear.py @@ -19,8 +19,12 @@ import jax import jax.numpy as jnp import numpy as np -from brainevent import csr_on_pre, csr2csc_on_post -from brainevent import dense_on_pre, dense_on_post +from brainevent import ( + update_csr_on_binary_pre, + update_csr_on_binary_post, + update_dense_on_binary_pre, + update_dense_on_binary_post, +) from brainpy import connect, initialize as init from brainpy import math as bm @@ -226,11 +230,11 @@ def stdp_update( if on_pre is not None: spike = on_pre['spike'] trace = on_pre['trace'] - self.W.value = dense_on_pre(self.W.value, spike, trace, w_min, w_max) + self.W.value = update_dense_on_binary_pre(self.W.value, spike, trace, w_min, w_max) if on_post is not None: spike = on_post['spike'] trace = on_post['trace'] - self.W.value = dense_on_post(self.W.value, trace, spike, w_min, w_max) + self.W.value = update_dense_on_binary_post(self.W.value, trace, spike, w_min, w_max) Linear = Dense @@ -321,11 +325,11 @@ def stdp_update( if on_pre is not None: spike = on_pre['spike'] trace = on_pre['trace'] - self.weight.value = dense_on_pre(self.weight.value, spike, trace, w_min, w_max) + self.weight.value = update_dense_on_binary_pre(self.weight.value, spike, trace, w_min, w_max) if on_post is not None: spike = on_post['spike'] trace = on_post['trace'] - self.weight.value = dense_on_post(self.weight.value, trace, spike, w_min, w_max) + self.weight.value = update_dense_on_binary_post(self.weight.value, trace, spike, w_min, w_max) class OneToOne(Layer, SupportSTDP): @@ -449,11 +453,11 @@ def stdp_update( if on_pre is not None: spike = on_pre['spike'] trace = on_pre['trace'] - self.weight.value = dense_on_pre(self.weight.value, spike, trace, w_min, w_max) + self.weight.value = update_dense_on_binary_pre(self.weight.value, spike, trace, w_min, w_max) if on_post is not None: spike = on_post['spike'] trace = on_post['trace'] - self.weight.value = dense_on_post(self.weight.value, trace, spike, w_min, w_max) + self.weight.value = update_dense_on_binary_post(self.weight.value, trace, spike, w_min, w_max) class _CSRLayer(Layer, SupportSTDP): @@ -500,7 +504,7 @@ def stdp_update( if on_pre is not None: # update on presynaptic spike spike = on_pre['spike'] trace = on_pre['trace'] - self.weight.value = csr_on_pre( + self.weight.value = update_csr_on_binary_pre( self.weight.value, self.indices, self.indptr, spike, trace, w_min, w_max, shape=(spike.shape[0], trace.shape[0]), ) @@ -512,7 +516,7 @@ def stdp_update( ) spike = on_post['spike'] trace = on_post['trace'] - self.weight.value = csr2csc_on_post( + self.weight.value = update_csr_on_binary_post( self.weight.value, self._pre_ids, self._post_indptr, self.w_indices, trace, spike, w_min, w_max, shape=(trace.shape[0], spike.shape[0]), diff --git a/brainpy/initialize/base.py b/brainpy/initialize/base.py index 96dde401..a14e9792 100644 --- a/brainpy/initialize/base.py +++ b/brainpy/initialize/base.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2025 BrainX Ecosystem Limited. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== + +# -*- coding: utf-8 -*- + import abc __all__ = [ diff --git a/brainpy/math/compat_numpy.py b/brainpy/math/compat_numpy.py index 870543ee..250a447d 100644 --- a/brainpy/math/compat_numpy.py +++ b/brainpy/math/compat_numpy.py @@ -36,7 +36,7 @@ 'lcm', 'gcd', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh', 'cos', 'cosh', 'sin', 'sinc', 'sinh', 'tan', 'tanh', 'deg2rad', 'hypot', 'rad2deg', 'degrees', 'radians', 'round', - 'around', 'round_', 'rint', 'floor', 'ceil', 'trunc', 'fix', 'prod', + 'around', 'round_', 'rint', 'floor', 'ceil', 'trunc', 'prod', 'sum', 'diff', 'median', 'nancumprod', 'nancumsum', 'nanprod', 'nansum', 'cumprod', 'cumsum', 'ediff1d', 'cross', 'isfinite', 'isinf', 'isnan', 'signbit', 'copysign', 'nextafter', 'ldexp', 'frexp', 'convolve', @@ -397,7 +397,6 @@ def msort(a): floor = _compatible_with_brainpy_array(jnp.floor) ceil = _compatible_with_brainpy_array(jnp.ceil) trunc = _compatible_with_brainpy_array(jnp.trunc) -fix = _compatible_with_brainpy_array(jnp.fix) prod = _compatible_with_brainpy_array(jnp.prod) sum = _compatible_with_brainpy_array(jnp.sum) diff --git a/brainpy/math/event/csr_matmat.py b/brainpy/math/event/csr_matmat.py index 63158dc9..c33d1103 100644 --- a/brainpy/math/event/csr_matmat.py +++ b/brainpy/math/event/csr_matmat.py @@ -59,7 +59,7 @@ def csrmm( if isinstance(matrix, Array): matrix = matrix.value - matrix = brainevent.EventArray(matrix) + matrix = brainevent.BinaryArray(matrix) csr = brainevent.CSR((data, indices, indptr), shape=shape) if transpose: return matrix @ csr diff --git a/brainpy/math/event/csr_matvec.py b/brainpy/math/event/csr_matvec.py index d64e9b10..8be45244 100644 --- a/brainpy/math/event/csr_matvec.py +++ b/brainpy/math/event/csr_matvec.py @@ -84,7 +84,7 @@ def csrmv( if isinstance(events, Array): events = events.value - events = brainevent.EventArray(events) + events = brainevent.BinaryArray(events) csr = brainevent.CSR((data, indices, indptr), shape=shape) if transpose: return events @ csr diff --git a/brainpy/math/jitconn/event_matvec.py b/brainpy/math/jitconn/event_matvec.py index b22fcb00..042bad16 100644 --- a/brainpy/math/jitconn/event_matvec.py +++ b/brainpy/math/jitconn/event_matvec.py @@ -49,8 +49,8 @@ def event_mv_prob_homo( if isinstance(weight, Array): weight = weight.value - events = brainevent.EventArray(events) - csr = brainevent.JITCHomoR((weight, conn_prob, seed), shape=shape, corder=outdim_parallel) + events = brainevent.BinaryArray(events) + csr = brainevent.JITCScalarR((weight, conn_prob, seed), shape=shape, corder=outdim_parallel) if transpose: return events @ csr else: @@ -75,7 +75,7 @@ def event_mv_prob_uniform( seed = np.random.randint(0, 1000000000) if isinstance(events, Array): events = events.value - events = brainevent.EventArray(events) + events = brainevent.BinaryArray(events) if isinstance(w_low, Array): w_low = w_low.value if isinstance(w_high, Array): @@ -106,7 +106,7 @@ def event_mv_prob_normal( seed = np.random.randint(0, 1000000000) if isinstance(events, Array): events = events.value - events = brainevent.EventArray(events) + events = brainevent.BinaryArray(events) if isinstance(w_mu, Array): w_mu = w_mu.value if isinstance(w_sigma, Array): diff --git a/brainpy/math/jitconn/matvec.py b/brainpy/math/jitconn/matvec.py index cd13f5c6..094f758e 100644 --- a/brainpy/math/jitconn/matvec.py +++ b/brainpy/math/jitconn/matvec.py @@ -96,7 +96,7 @@ def mv_prob_homo( if isinstance(weight, Array): weight = weight.value - csr = brainevent.JITCHomoR((weight, conn_prob, seed), shape=shape, corder=outdim_parallel) + csr = brainevent.JITCScalarR((weight, conn_prob, seed), shape=shape, corder=outdim_parallel) if transpose: return vector @ csr else: @@ -290,7 +290,7 @@ def get_homo_weight_matrix( """ if seed is None: seed = np.random.randint(0, 1000000000) - csr = brainevent.JITCHomoR((weight, conn_prob, seed), shape=shape, corder=outdim_parallel) + csr = brainevent.JITCScalarR((weight, conn_prob, seed), shape=shape, corder=outdim_parallel) if transpose: csr = csr.T return csr.todense() diff --git a/brainpy/state/README.md b/brainpy/state/README.md index 4d610359..229742af 100644 --- a/brainpy/state/README.md +++ b/brainpy/state/README.md @@ -1,4 +1,4 @@ -# `brainpy.state` - State-based Brain Dynamics Programming +# `brainpy.state` ## Overview @@ -37,7 +37,7 @@ pip install brainpy -U For development or to install the state module separately: ```bash -pip install brainpy_state -U +pip install brainpy.state -U ``` ## Usage diff --git a/brainpy/state/__init__.py b/brainpy/state/__init__.py index 4f9491a4..407d5954 100644 --- a/brainpy/state/__init__.py +++ b/brainpy/state/__init__.py @@ -16,5 +16,6 @@ from brainpy_state import * from brainpy_state import __all__ - - +if __name__ == '__main__': + print(LIF) + print(__all__) diff --git a/pyproject.toml b/pyproject.toml index 5db3f845..dc5164c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,6 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", @@ -41,7 +40,7 @@ dependencies = [ "tqdm", "brainstate>=0.2.7", "brainunit", - "brainevent>=0.0.4", + "brainevent>=0.0.7", "braintools>=0.0.9", 'brainpy_state>=0.0.3', ] diff --git a/requirements.txt b/requirements.txt index 726f19bb..b8e3db57 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ numpy brainunit -brainevent>=0.0.4 +brainevent>=0.0.7 braintools>=0.1.0 brainstate>=0.2.7 brainpy_state>=0.0.2