Skip to content

Commit

Permalink
small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoming0625 committed Dec 23, 2023
1 parent 2f462a1 commit 0002e2e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion brainpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

__version__ = "2.4.6.post4"
__version__ = "2.4.6.post5"

# fundamental supporting modules
from brainpy import errors, check, tools
Expand Down
25 changes: 13 additions & 12 deletions brainpy/_src/math/ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ def sharding(self):
def addressable_shards(self):
return self._value.addressable_shards

def __check_shape_dtype(self, other_value, self_value):
if other_value.shape != self_value.shape:
raise MathError(f"The shape of the original data is {self_value.shape}, "
f"while we got {other_value.shape}.")
if other_value.dtype != self_value.dtype:
raise MathError(f"The dtype of the original data is {self_value.dtype}, "
f"while we got {other_value.dtype}.")


@property
def value(self):
# return the value
Expand All @@ -126,12 +135,8 @@ def value(self, value):
else:
value = jnp.asarray(value)
# check
if value.shape != self_value.shape:
raise MathError(f"The shape of the original data is {self_value.shape}, "
f"while we got {value.shape}.")
if value.dtype != self_value.dtype:
raise MathError(f"The dtype of the original data is {self_value.dtype}, "
f"while we got {value.dtype}.")
self.__check_shape_dtype(value, self_value)
# assign
self._value = value

def update(self, value):
Expand Down Expand Up @@ -1569,12 +1574,8 @@ def value(self, value):
else:
value = jnp.asarray(value)
# check
if value.shape != self_value.shape:
raise MathError(f"The shape of the original data is {self_value.shape}, "
f"while we got {value.shape}.")
if value.dtype != self_value.dtype:
raise MathError(f"The dtype of the original data is {self_value.dtype}, "
f"while we got {value.dtype}.")
self.__check_shape_dtype(value, self_value)
# assign
self._value = value


8 changes: 0 additions & 8 deletions brainpy/_src/math/object_transform/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,6 @@ def current_transform_number():
return len(transform_stack)


def _stack_add_read(var: 'Variable'):
pass


def _stack_add_write(var: 'Variable'):
pass


@register_pytree_node_class
class Variable(Array):
"""The pointer to specify the dynamical variable.
Expand Down

0 comments on commit 0002e2e

Please sign in to comment.