brainstate 0.1.0.post20250209__py2.py3-none-any.whl → 0.1.0.post20250210__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- brainstate/_state.py +93 -52
- brainstate/compile/_jit.py +0 -1
- brainstate/compile/_make_jaxpr.py +2 -2
- brainstate/compile/_util.py +1 -1
- brainstate/graph/_graph_node.py +2 -2
- brainstate/graph/_graph_operation.py +1 -1
- brainstate/nn/_dyn_impl/_inputs.py +41 -3
- brainstate/nn/_module.py +1 -2
- brainstate/util/_dict.py +6 -84
- brainstate/util/_pretty_repr.py +5 -9
- {brainstate-0.1.0.post20250209.dist-info → brainstate-0.1.0.post20250210.dist-info}/METADATA +1 -1
- {brainstate-0.1.0.post20250209.dist-info → brainstate-0.1.0.post20250210.dist-info}/RECORD +15 -15
- {brainstate-0.1.0.post20250209.dist-info → brainstate-0.1.0.post20250210.dist-info}/LICENSE +0 -0
- {brainstate-0.1.0.post20250209.dist-info → brainstate-0.1.0.post20250210.dist-info}/WHEEL +0 -0
- {brainstate-0.1.0.post20250209.dist-info → brainstate-0.1.0.post20250210.dist-info}/top_level.txt +0 -0
brainstate/_state.py
CHANGED
@@ -19,10 +19,8 @@ import contextlib
|
|
19
19
|
import dataclasses
|
20
20
|
import threading
|
21
21
|
from functools import wraps, partial
|
22
|
-
from typing import (
|
23
|
-
|
24
|
-
TypeVar, Optional, TYPE_CHECKING, Tuple, Dict, List, Sequence
|
25
|
-
)
|
22
|
+
from typing import (Any, Union, Callable, Generic, Mapping,
|
23
|
+
TypeVar, Optional, TYPE_CHECKING, Tuple, Dict, List, Sequence)
|
26
24
|
|
27
25
|
import jax
|
28
26
|
import numpy as np
|
@@ -30,7 +28,7 @@ from jax.api_util import shaped_abstractify
|
|
30
28
|
from jax.extend import source_info_util
|
31
29
|
|
32
30
|
from brainstate.typing import ArrayLike, PyTree, Missing
|
33
|
-
from brainstate.util import DictManager,
|
31
|
+
from brainstate.util import DictManager, PrettyRepr, PrettyType, PrettyAttr
|
34
32
|
|
35
33
|
__all__ = [
|
36
34
|
'State', 'ShortTermState', 'LongTermState', 'HiddenState', 'ParamState', 'TreefyState',
|
@@ -186,7 +184,7 @@ def _get_trace_stack_level() -> int:
|
|
186
184
|
return len(TRACE_CONTEXT.state_stack)
|
187
185
|
|
188
186
|
|
189
|
-
class State(Generic[A],
|
187
|
+
class State(Generic[A], PrettyRepr):
|
190
188
|
"""
|
191
189
|
The pointer to specify the dynamical data.
|
192
190
|
|
@@ -263,9 +261,8 @@ class State(Generic[A], PrettyReprTree):
|
|
263
261
|
"""
|
264
262
|
The data and its value.
|
265
263
|
"""
|
266
|
-
self.check_if_deleted()
|
267
264
|
record_state_value_read(self)
|
268
|
-
return self.
|
265
|
+
return self._read_value()
|
269
266
|
|
270
267
|
@value.setter
|
271
268
|
def value(self, v) -> None:
|
@@ -275,7 +272,14 @@ class State(Generic[A], PrettyReprTree):
|
|
275
272
|
Args:
|
276
273
|
v: The value.
|
277
274
|
"""
|
278
|
-
|
275
|
+
# NOTE: the following order is important
|
276
|
+
|
277
|
+
if isinstance(v, State): # value checking
|
278
|
+
raise ValueError('Cannot set value to a State, ' 'use `copy_from` method instead')
|
279
|
+
self._check_value_tree(v) # check the tree structure
|
280
|
+
record_state_value_write(self) # record the value by the stack (>= level)
|
281
|
+
self._been_writen = True # set the flag
|
282
|
+
self._write_value(v) # write the value
|
279
283
|
|
280
284
|
@property
|
281
285
|
def stack_level(self):
|
@@ -297,17 +301,18 @@ class State(Generic[A], PrettyReprTree):
|
|
297
301
|
"""
|
298
302
|
self._level = level
|
299
303
|
|
300
|
-
def
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
self.
|
305
|
-
|
306
|
-
|
307
|
-
|
304
|
+
def _read_value(self) -> PyTree[ArrayLike]:
|
305
|
+
"""
|
306
|
+
The interface to customize the value reading.
|
307
|
+
"""
|
308
|
+
self.check_if_deleted()
|
309
|
+
return self._value
|
310
|
+
|
311
|
+
def _write_value(self, v) -> None:
|
312
|
+
"""
|
313
|
+
The interface to customize the value writing.
|
314
|
+
"""
|
308
315
|
self._value = v
|
309
|
-
# set flag
|
310
|
-
self._been_writen = True
|
311
316
|
|
312
317
|
def restore_value(self, v) -> None:
|
313
318
|
"""
|
@@ -429,25 +434,45 @@ class State(Generic[A], PrettyReprTree):
|
|
429
434
|
del metadata['_value']
|
430
435
|
return TreefyState(type(self), self._value, **metadata)
|
431
436
|
|
432
|
-
def
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
437
|
+
def __pretty_repr__(self):
|
438
|
+
yield PrettyType(type=type(self))
|
439
|
+
for name, value in vars(self).items():
|
440
|
+
if name == '_value':
|
441
|
+
name = 'value'
|
442
|
+
if name == '_name':
|
443
|
+
if value is None:
|
444
|
+
continue
|
445
|
+
else:
|
446
|
+
name = 'name'
|
447
|
+
if name == 'tag' and value is None:
|
448
|
+
continue
|
449
|
+
if name in ['_level', '_source_info', '_been_writen']:
|
450
|
+
continue
|
451
|
+
yield PrettyAttr(name, repr(value))
|
452
|
+
|
453
|
+
def __treescope_repr__(self, path, subtree_renderer):
|
454
|
+
children = {}
|
455
|
+
for name, value in vars(self).items():
|
456
|
+
if name == '_value':
|
457
|
+
name = 'value'
|
458
|
+
if name == '_name':
|
459
|
+
if value is None:
|
460
|
+
continue
|
461
|
+
else:
|
462
|
+
name = 'name'
|
463
|
+
if name == 'tag' and value is None:
|
464
|
+
continue
|
465
|
+
if name in ['_level', '_source_info', '_been_writen']:
|
466
|
+
continue
|
467
|
+
children[name] = value
|
468
|
+
|
469
|
+
import treescope # type: ignore[import-not-found,import-untyped]
|
470
|
+
return treescope.repr_lib.render_object_constructor(
|
471
|
+
object_type=type(self),
|
472
|
+
attributes=children,
|
473
|
+
path=path,
|
474
|
+
subtree_renderer=subtree_renderer,
|
475
|
+
)
|
451
476
|
|
452
477
|
def __eq__(self, other: object) -> bool:
|
453
478
|
return type(self) is type(other) and vars(other) == vars(self)
|
@@ -784,7 +809,7 @@ class StateTraceStack(Generic[A]):
|
|
784
809
|
return StateTraceStack().merge(self, other)
|
785
810
|
|
786
811
|
|
787
|
-
class TreefyState(Generic[A],
|
812
|
+
class TreefyState(Generic[A], PrettyRepr):
|
788
813
|
"""
|
789
814
|
The state as a pytree.
|
790
815
|
"""
|
@@ -806,19 +831,35 @@ class TreefyState(Generic[A], PrettyReprTree):
|
|
806
831
|
|
807
832
|
def __delattr__(self, name: str) -> None: ...
|
808
833
|
|
809
|
-
def
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
834
|
+
def __pretty_repr__(self):
|
835
|
+
yield PrettyType(type=type(self))
|
836
|
+
yield PrettyAttr('type', self.type.__name__)
|
837
|
+
for name, value in vars(self).items():
|
838
|
+
if name == '_value':
|
839
|
+
name = 'value'
|
840
|
+
if name == '_name':
|
841
|
+
if value is None:
|
842
|
+
continue
|
843
|
+
else:
|
844
|
+
name = 'name'
|
845
|
+
if name in ['_level', '_source_info', 'type']:
|
846
|
+
continue
|
847
|
+
yield PrettyAttr(name, repr(value))
|
848
|
+
|
849
|
+
def __treescope_repr__(self, path, subtree_renderer):
|
850
|
+
children = {'type': self.type}
|
851
|
+
for name, value in vars(self).items():
|
852
|
+
if name == 'type':
|
853
|
+
continue
|
854
|
+
children[name] = value
|
855
|
+
|
856
|
+
import treescope # type: ignore[import-not-found,import-untyped]
|
857
|
+
return treescope.repr_lib.render_object_constructor(
|
858
|
+
object_type=type(self),
|
859
|
+
attributes=children,
|
860
|
+
path=path,
|
861
|
+
subtree_renderer=subtree_renderer,
|
862
|
+
)
|
822
863
|
|
823
864
|
def replace(self, value: B) -> TreefyState[B]:
|
824
865
|
"""
|
brainstate/compile/_jit.py
CHANGED
@@ -82,7 +82,6 @@ def _get_jitted_fun(
|
|
82
82
|
return fun.fun(*args, **params)
|
83
83
|
|
84
84
|
# compile the function and get the state trace
|
85
|
-
# print('Compiling ...')
|
86
85
|
state_trace = fun.compile_function_and_get_state_trace(*args, **params, return_only_write=True)
|
87
86
|
read_state_vals = state_trace.get_read_state_values(True)
|
88
87
|
|
@@ -206,7 +206,7 @@ class StatefulFunction(object):
|
|
206
206
|
self._cached_state_trace: Dict[Any, StateTraceStack] = dict()
|
207
207
|
|
208
208
|
def __repr__(self) -> str:
|
209
|
-
return (f"{self.__class__.__name__}("
|
209
|
+
return (f"{self.__class__.__name__}({self.fun}, "
|
210
210
|
f"static_argnums={self.static_argnums}, "
|
211
211
|
f"axis_env={self.axis_env}, "
|
212
212
|
f"abstracted_axes={self.abstracted_axes}, "
|
@@ -499,7 +499,7 @@ class StatefulFunction(object):
|
|
499
499
|
state_vals, out = self.jaxpr_call([st.value for st in state_trace.states], *args, **kwargs)
|
500
500
|
for st, written, val in zip(state_trace.states, state_trace.been_writen, state_vals):
|
501
501
|
if written:
|
502
|
-
st.
|
502
|
+
st.value = val
|
503
503
|
else:
|
504
504
|
st.restore_value(val)
|
505
505
|
return out
|
brainstate/compile/_util.py
CHANGED
@@ -31,7 +31,7 @@ def write_back_state_values(
|
|
31
31
|
assert len(state_trace.states) == len(state_trace.been_writen) == len(read_state_vals) == len(write_state_vals)
|
32
32
|
for st, write, val_r, val_w in zip(state_trace.states, state_trace.been_writen, read_state_vals, write_state_vals):
|
33
33
|
if write:
|
34
|
-
st.
|
34
|
+
st.value = val_w
|
35
35
|
else:
|
36
36
|
st.restore_value(val_r)
|
37
37
|
|
brainstate/graph/_graph_node.py
CHANGED
@@ -27,7 +27,7 @@ import numpy as np
|
|
27
27
|
|
28
28
|
from brainstate._state import State, TreefyState
|
29
29
|
from brainstate.typing import Key
|
30
|
-
from brainstate.util._pretty_repr import PrettyRepr,
|
30
|
+
from brainstate.util._pretty_repr import PrettyRepr, pretty_repr_avoid_duplicate, PrettyType, PrettyAttr
|
31
31
|
from ._graph_operation import register_graph_node_type
|
32
32
|
|
33
33
|
__all__ = [
|
@@ -88,7 +88,7 @@ class Node(PrettyRepr, metaclass=GraphNodeMeta):
|
|
88
88
|
"""
|
89
89
|
Pretty repr for the object.
|
90
90
|
"""
|
91
|
-
yield from
|
91
|
+
yield from pretty_repr_avoid_duplicate(self, _default_repr_object, _default_repr_attr)
|
92
92
|
|
93
93
|
def __treescope_repr__(self, path, subtree_renderer):
|
94
94
|
"""
|
@@ -609,7 +609,7 @@ def _get_children(graph_def, state_mapping, index_ref, index_ref_cache):
|
|
609
609
|
variable.update_from_ref(value)
|
610
610
|
elif isinstance(value, State):
|
611
611
|
if value._been_writen:
|
612
|
-
variable.
|
612
|
+
variable.value = value.value
|
613
613
|
else:
|
614
614
|
variable.restore_value(value.value)
|
615
615
|
else:
|
@@ -216,9 +216,37 @@ def poisson_input(
|
|
216
216
|
weight: u.Quantity,
|
217
217
|
target: State,
|
218
218
|
indices: Optional[Union[np.ndarray, jax.Array]] = None,
|
219
|
+
refractory: Optional[Union[jax.Array]] = None,
|
219
220
|
):
|
220
221
|
"""
|
221
|
-
Poisson
|
222
|
+
Generates Poisson-distributed input spikes to a target state variable.
|
223
|
+
|
224
|
+
This function simulates Poisson input to a given state, updating the target
|
225
|
+
variable with generated spikes based on the specified frequency, number of inputs,
|
226
|
+
and synaptic weight. The input can be applied to specific indices of the target
|
227
|
+
or to the entire target if indices are not provided.
|
228
|
+
|
229
|
+
Parameters
|
230
|
+
----------
|
231
|
+
freq : u.Quantity[u.Hz]
|
232
|
+
The frequency of the Poisson input in Hertz.
|
233
|
+
num_input : int
|
234
|
+
The number of input channels or neurons generating the Poisson spikes.
|
235
|
+
weight : u.Quantity
|
236
|
+
The synaptic weight applied to each spike.
|
237
|
+
target : State
|
238
|
+
The target state variable to which the Poisson input is applied.
|
239
|
+
indices : Optional[Union[np.ndarray, jax.Array]], optional
|
240
|
+
Specific indices of the target to apply the input. If None, the input is applied
|
241
|
+
to the entire target.
|
242
|
+
refractory : Optional[Union[jax.Array]], optional
|
243
|
+
A boolean array indicating which parts of the target are in a refractory state
|
244
|
+
and should not be updated. Should be the same length as the target.
|
245
|
+
|
246
|
+
Returns
|
247
|
+
-------
|
248
|
+
None
|
249
|
+
The function updates the target state in place with the generated Poisson input.
|
222
250
|
"""
|
223
251
|
freq = maybe_state(freq)
|
224
252
|
weight = maybe_state(weight)
|
@@ -291,7 +319,7 @@ def poisson_input(
|
|
291
319
|
# )
|
292
320
|
|
293
321
|
# update target variable
|
294
|
-
|
322
|
+
data = jax.tree.map(
|
295
323
|
lambda tar, x: tar + x * weight,
|
296
324
|
target.value,
|
297
325
|
inp,
|
@@ -358,9 +386,19 @@ def poisson_input(
|
|
358
386
|
# )
|
359
387
|
|
360
388
|
# update target variable
|
361
|
-
|
389
|
+
data = jax.tree.map(
|
362
390
|
lambda x, tar: tar.at[indices].add(x * weight),
|
363
391
|
inp,
|
364
392
|
tar_val,
|
365
393
|
is_leaf=u.math.is_quantity
|
366
394
|
)
|
395
|
+
|
396
|
+
if refractory is not None:
|
397
|
+
target.value = jax.tree.map(
|
398
|
+
lambda x, tar: u.math.where(refractory, tar, x),
|
399
|
+
data,
|
400
|
+
tar_val,
|
401
|
+
is_leaf=u.math.is_quantity
|
402
|
+
)
|
403
|
+
else:
|
404
|
+
target.value = data
|
brainstate/nn/_module.py
CHANGED
@@ -294,8 +294,7 @@ class Sequential(Module):
|
|
294
294
|
# the input and output shape
|
295
295
|
if first.in_size is not None:
|
296
296
|
self.in_size = first.in_size
|
297
|
-
|
298
|
-
self.out_size = tuple(in_size)
|
297
|
+
self.out_size = tuple(in_size)
|
299
298
|
|
300
299
|
def update(self, x):
|
301
300
|
"""Update function of a sequential model.
|
brainstate/util/_dict.py
CHANGED
@@ -24,12 +24,11 @@ import jax
|
|
24
24
|
|
25
25
|
from brainstate.typing import Filter, PathParts
|
26
26
|
from ._filter import to_predicate
|
27
|
-
from ._pretty_repr import PrettyRepr, PrettyType, PrettyAttr,
|
27
|
+
from ._pretty_repr import PrettyRepr, PrettyType, PrettyAttr, pretty_repr_avoid_duplicate, get_repr
|
28
28
|
from ._struct import dataclass
|
29
29
|
|
30
30
|
__all__ = [
|
31
|
-
'
|
32
|
-
'PrettyList', 'PrettyReprTree',
|
31
|
+
'NestedDict', 'FlattedDict', 'flat_mapping', 'nest_mapping',
|
33
32
|
]
|
34
33
|
|
35
34
|
A = TypeVar('A')
|
@@ -41,44 +40,6 @@ ExtractValueFn = abc.Callable[[Any], Any]
|
|
41
40
|
SetValueFn = abc.Callable[[V, Any], V]
|
42
41
|
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
class PrettyReprTree(PrettyRepr):
|
47
|
-
"""
|
48
|
-
Pretty representation of a tree.
|
49
|
-
"""
|
50
|
-
|
51
|
-
def __pretty_repr__(self):
|
52
|
-
return yield_unique_pretty_repr_items(
|
53
|
-
self,
|
54
|
-
repr_object=self._repr_object,
|
55
|
-
repr_attr=self._repr_attr,
|
56
|
-
)
|
57
|
-
|
58
|
-
def __pretty_repr_item__(self, k, v):
|
59
|
-
return k, v
|
60
|
-
|
61
|
-
def _repr_object(self, node: PrettyDict):
|
62
|
-
yield PrettyType(type(node), value_sep=': ', start='({', end='})')
|
63
|
-
|
64
|
-
def _repr_attr(self, node):
|
65
|
-
for k, v in vars(node).items():
|
66
|
-
k, v = self.__pretty_repr_item__(k, v)
|
67
|
-
if k is None:
|
68
|
-
continue
|
69
|
-
|
70
|
-
if isinstance(v, list):
|
71
|
-
v = PrettyList(v)
|
72
|
-
|
73
|
-
if isinstance(v, dict):
|
74
|
-
v = PrettyDict(v)
|
75
|
-
|
76
|
-
if isinstance(v, PrettyDict):
|
77
|
-
v = NestedStateRepr(v)
|
78
|
-
|
79
|
-
yield PrettyAttr(repr(k), v)
|
80
|
-
|
81
|
-
|
82
43
|
# the empty node is a struct.dataclass to be compatible with JAX.
|
83
44
|
@dataclass
|
84
45
|
class _EmptyNode:
|
@@ -252,10 +213,10 @@ class PrettyDict(dict, PrettyRepr):
|
|
252
213
|
|
253
214
|
def __repr__(self) -> str:
|
254
215
|
# repr the individual object with the pretty representation
|
255
|
-
return
|
216
|
+
return get_repr(self)
|
256
217
|
|
257
218
|
def __pretty_repr__(self):
|
258
|
-
yield from
|
219
|
+
yield from pretty_repr_avoid_duplicate(self, _default_repr_object, _default_repr_attr)
|
259
220
|
|
260
221
|
def split(self, *filters) -> Union[PrettyDict[K, V], Tuple[PrettyDict[K, V], ...]]:
|
261
222
|
raise NotImplementedError
|
@@ -276,20 +237,15 @@ class PrettyDict(dict, PrettyRepr):
|
|
276
237
|
|
277
238
|
|
278
239
|
def _default_repr_object(node: PrettyDict):
|
279
|
-
yield PrettyType(
|
240
|
+
yield PrettyType(type(node), value_sep=': ', start='({', end='})')
|
280
241
|
|
281
242
|
|
282
|
-
def _default_repr_attr(node):
|
243
|
+
def _default_repr_attr(node: PrettyDict):
|
283
244
|
for k, v in node.items():
|
284
|
-
if isinstance(v, list):
|
285
|
-
v = PrettyList(v)
|
286
|
-
|
287
245
|
if isinstance(v, dict):
|
288
246
|
v = PrettyDict(v)
|
289
|
-
|
290
247
|
if isinstance(v, PrettyDict):
|
291
248
|
v = NestedStateRepr(v)
|
292
|
-
|
293
249
|
yield PrettyAttr(repr(k), v)
|
294
250
|
|
295
251
|
|
@@ -779,37 +735,3 @@ def _flat_unflatten(
|
|
779
735
|
jax.tree_util.register_pytree_with_keys(FlattedDict,
|
780
736
|
_nest_flatten_with_keys,
|
781
737
|
_flat_unflatten) # type: ignore[arg-type]
|
782
|
-
|
783
|
-
|
784
|
-
@jax.tree_util.register_pytree_node_class
|
785
|
-
class PrettyList(list, PrettyRepr):
|
786
|
-
__module__ = 'brainstate.util'
|
787
|
-
|
788
|
-
def __pretty_repr__(self):
|
789
|
-
yield from yield_unique_pretty_repr_items(self, _list_repr_object, _list_repr_attr)
|
790
|
-
|
791
|
-
def __repr__(self):
|
792
|
-
return pretty_repr(self)
|
793
|
-
|
794
|
-
def tree_flatten(self):
|
795
|
-
return list(self), ()
|
796
|
-
|
797
|
-
@classmethod
|
798
|
-
def tree_unflatten(cls, aux_data, children):
|
799
|
-
return cls(children)
|
800
|
-
|
801
|
-
|
802
|
-
def _list_repr_attr(node: PrettyList):
|
803
|
-
for v in node:
|
804
|
-
if isinstance(v, list):
|
805
|
-
v = PrettyList(v)
|
806
|
-
if isinstance(v, dict):
|
807
|
-
v = PrettyDict(v)
|
808
|
-
if isinstance(v, PrettyDict):
|
809
|
-
v = NestedStateRepr(v)
|
810
|
-
yield PrettyAttr('', v)
|
811
|
-
|
812
|
-
|
813
|
-
def _list_repr_object(node: PrettyDict):
|
814
|
-
yield PrettyType('', value_sep='', start='[', end=']')
|
815
|
-
|
brainstate/util/_pretty_repr.py
CHANGED
@@ -21,11 +21,9 @@ import dataclasses
|
|
21
21
|
import threading
|
22
22
|
from abc import ABC, abstractmethod
|
23
23
|
from functools import partial
|
24
|
-
from typing import Any, Iterator, Mapping, TypeVar, Union, Callable, Optional
|
24
|
+
from typing import Any, Iterator, Mapping, TypeVar, Union, Callable, Optional
|
25
25
|
|
26
26
|
__all__ = [
|
27
|
-
'yield_unique_pretty_repr_items',
|
28
|
-
'pretty_repr',
|
29
27
|
'PrettyType',
|
30
28
|
'PrettyAttr',
|
31
29
|
'PrettyRepr',
|
@@ -82,7 +80,7 @@ class PrettyRepr(ABC):
|
|
82
80
|
|
83
81
|
def __repr__(self) -> str:
|
84
82
|
# repr the individual object with the pretty representation
|
85
|
-
return
|
83
|
+
return get_repr(self)
|
86
84
|
|
87
85
|
|
88
86
|
def _repr_elem(obj: PrettyType, elem: Any) -> str:
|
@@ -95,7 +93,7 @@ def _repr_elem(obj: PrettyType, elem: Any) -> str:
|
|
95
93
|
return f'{obj.elem_indent}{elem.start}{elem.key}{obj.value_sep}{value}{elem.end}'
|
96
94
|
|
97
95
|
|
98
|
-
def
|
96
|
+
def get_repr(obj: PrettyRepr) -> str:
|
99
97
|
"""
|
100
98
|
Get the pretty representation of an object.
|
101
99
|
"""
|
@@ -142,10 +140,9 @@ class PrettyMapping(PrettyRepr):
|
|
142
140
|
Pretty representation of a mapping.
|
143
141
|
"""
|
144
142
|
mapping: Mapping
|
145
|
-
type_name: str = ''
|
146
143
|
|
147
144
|
def __pretty_repr__(self):
|
148
|
-
yield PrettyType(type=
|
145
|
+
yield PrettyType(type='', value_sep=': ', start='{', end='}')
|
149
146
|
|
150
147
|
for key, value in self.mapping.items():
|
151
148
|
yield PrettyAttr(repr(key), value)
|
@@ -171,7 +168,7 @@ def _default_repr_attr(node):
|
|
171
168
|
yield PrettyAttr(name, repr(value))
|
172
169
|
|
173
170
|
|
174
|
-
def
|
171
|
+
def pretty_repr_avoid_duplicate(
|
175
172
|
node,
|
176
173
|
repr_object: Optional[Callable] = None,
|
177
174
|
repr_attr: Optional[Callable] = None
|
@@ -209,4 +206,3 @@ def yield_unique_pretty_repr_items(
|
|
209
206
|
finally:
|
210
207
|
if clear_seen:
|
211
208
|
CONTEXT.seen_modules_repr = None
|
212
|
-
|
{brainstate-0.1.0.post20250209.dist-info → brainstate-0.1.0.post20250210.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: brainstate
|
3
|
-
Version: 0.1.0.
|
3
|
+
Version: 0.1.0.post20250210
|
4
4
|
Summary: A ``State``-based Transformation System for Program Compilation and Augmentation.
|
5
5
|
Home-page: https://github.com/chaobrain/brainstate
|
6
6
|
Author: BrainState Developers
|
@@ -1,5 +1,5 @@
|
|
1
1
|
brainstate/__init__.py,sha256=AkZyyFkn4fB8g2aT6Rc2MO1xICPpUZuDtdze-eUQNc0,1496
|
2
|
-
brainstate/_state.py,sha256=
|
2
|
+
brainstate/_state.py,sha256=Ol-FqHWQnIKmylXHjdsY5izKQhIb0bUw3_UL-7zj4WA,29447
|
3
3
|
brainstate/_state_test.py,sha256=rJUFRSXEqrrl4qANRewY9mnDlzSbtHwBIGeZ0ku-8Dg,1650
|
4
4
|
brainstate/_utils.py,sha256=uJ6WWKq3yb05ZdktCQGLWOXsOJveL1H9pR7eev70Jes,1693
|
5
5
|
brainstate/environ.py,sha256=PZnVFWPioUBuWmwCO8wwCKrHQfP3BR-5lYPRl5i5GDA,17698
|
@@ -24,17 +24,17 @@ brainstate/compile/_conditions.py,sha256=gApsHKGQrf1QBjoKXDVL7VsoeJ2zFtSc-hFz9nb
|
|
24
24
|
brainstate/compile/_conditions_test.py,sha256=s9LF6h9LvigvgxUIugTqvgCHBIU8TXS1Ar1OlIxXfrw,8389
|
25
25
|
brainstate/compile/_error_if.py,sha256=TFvhqITKkRO9m30GdlUP4eEjJvLWQUhjkujXO9zvrWs,2689
|
26
26
|
brainstate/compile/_error_if_test.py,sha256=OdJG483IIdOrCHxtHd49OHfOxCSnSkk7GdAUOzSt8bE,2044
|
27
|
-
brainstate/compile/_jit.py,sha256
|
27
|
+
brainstate/compile/_jit.py,sha256=-Y8fyy8gc7qQT2ti4-N-74hjP_6C-D8YC5h-1unEKuI,13910
|
28
28
|
brainstate/compile/_jit_test.py,sha256=zD7kck9SQJGmUDolh9P4luKwQ21fBGje1Z4STTEXIuA,4135
|
29
29
|
brainstate/compile/_loop_collect_return.py,sha256=TrKBZhtQecTtuiVz_HOeyepde-znzjlyk0Te53-AvOE,23492
|
30
30
|
brainstate/compile/_loop_collect_return_test.py,sha256=bA-_11E8A_0jR5umEO3e409y7bb5QYDTgSL-SBaX7kQ,1802
|
31
31
|
brainstate/compile/_loop_no_collection.py,sha256=qto2__Zt2PJntkjB9AXEgraGLvNUJS483BhCXjJyqv0,7495
|
32
32
|
brainstate/compile/_loop_no_collection_test.py,sha256=oStB1CSG_iLp9sHdXd1hJNFvlxbzjck9Iy4sABoJDj4,1419
|
33
|
-
brainstate/compile/_make_jaxpr.py,sha256=
|
33
|
+
brainstate/compile/_make_jaxpr.py,sha256=Q-nwm-ibBN0ube4ZjATp924pUkrXuaeT0XgSstqkI40,33304
|
34
34
|
brainstate/compile/_make_jaxpr_test.py,sha256=3gwdiutn_PJyiweu3oPEXumxEVHKaE2xDGvkwZy2GEo,4367
|
35
35
|
brainstate/compile/_progress_bar.py,sha256=5pCMCEmbTO5XmKtzRUJGA178tuBznWKuh9Kw00wAL1I,7524
|
36
36
|
brainstate/compile/_unvmap.py,sha256=CJA6D9lUcBfvdLrpFVvC2AdTJqe9uY0Ht6PltQJyr4U,4228
|
37
|
-
brainstate/compile/_util.py,sha256=
|
37
|
+
brainstate/compile/_util.py,sha256=iKk51BHAerBFj2BTxPNdjsk3MZQiXenzpCr7Ys0iYWg,6299
|
38
38
|
brainstate/functional/__init__.py,sha256=j6-3Er4fgqWpvntzYCZVB3e5hoz-Z3aqvapITCuDri0,1107
|
39
39
|
brainstate/functional/_activations.py,sha256=S0Ok7sq5FTbmJWSejpOCHo1jpKX0gYOLy_TO2IUXM8s,21726
|
40
40
|
brainstate/functional/_activations_test.py,sha256=T___RlSrIfXwlkw8dg5A9EZMTZGDzv3a2evUwq_nYFg,13034
|
@@ -42,9 +42,9 @@ brainstate/functional/_normalization.py,sha256=i2EV7hSsqcNdcYRX2wAxjq8doHwyN9eNJ
|
|
42
42
|
brainstate/functional/_others.py,sha256=_u_Ys-LiLzDAP4zJggVwaVvirgoS3jvhXMREoS6JOkM,1737
|
43
43
|
brainstate/functional/_spikes.py,sha256=QY-2ayJkgkGELcq-bftPEaf_hJptVf_SP3fY36QvlZc,2678
|
44
44
|
brainstate/graph/__init__.py,sha256=noo4TjBg6iEhjjwk0sAGUhR7Ge-z8Vnc2rLYUvnqttw,1295
|
45
|
-
brainstate/graph/_graph_node.py,sha256=
|
45
|
+
brainstate/graph/_graph_node.py,sha256=swAokZLKswSTaq2WEhyLIs38sy_67C6maHI6T3e1hvY,8339
|
46
46
|
brainstate/graph/_graph_node_test.py,sha256=BFGfdzZFDHI0XK7hHotSVWKt3em1taGvn8FHF9NCXx8,2702
|
47
|
-
brainstate/graph/_graph_operation.py,sha256=
|
47
|
+
brainstate/graph/_graph_operation.py,sha256=UtBNP7hvxa-5i99LQJStXbFhUbl3icdfTq1oF4MeH1g,64106
|
48
48
|
brainstate/graph/_graph_operation_test.py,sha256=zjvpKjQAFWtw8YZuqOk_jmlZNb_-E8oPyNx57dyc8jI,18556
|
49
49
|
brainstate/init/__init__.py,sha256=R1dHgub47o-WJM9QkFLc7x_Q7GsyaKKDtrRHTFPpC5g,1097
|
50
50
|
brainstate/init/_base.py,sha256=B_NLS9aKNrvuj5NAlSgBbQTVev7IRvzcx8vH0J-Gq2w,1671
|
@@ -57,7 +57,7 @@ brainstate/nn/__init__.py,sha256=rxURT8J1XfBn3Vh3Dx_WzVADWn9zVriIty5KZEG-x6o,162
|
|
57
57
|
brainstate/nn/_collective_ops.py,sha256=sSjIIs1MvZA30XFFmK7iL1D_sCeh7hFd3PanCH6kgZo,6779
|
58
58
|
brainstate/nn/_exp_euler.py,sha256=yjkfSllFxGWKEAlHo5AzBizzkFj6FEVDKmFV6E2g214,3521
|
59
59
|
brainstate/nn/_exp_euler_test.py,sha256=clwRD8QR71k1jn6NrACMDEUcFMh0J9RTosoPnlYWUkw,1242
|
60
|
-
brainstate/nn/_module.py,sha256=
|
60
|
+
brainstate/nn/_module.py,sha256=HDLPvLfB7jat2VT3gBu0MxA7vfzK7xgowemitHX8Cgo,10835
|
61
61
|
brainstate/nn/_module_test.py,sha256=V4ZhiY_zYPvArkB2eeOTtZcgQrtlRyXKMbS1AJH4vC8,8893
|
62
62
|
brainstate/nn/metrics.py,sha256=iupHjSRTHYY-HmEPBC4tXWrZfF4zh1ek2NwSAA0gnwE,14738
|
63
63
|
brainstate/nn/_dyn_impl/__init__.py,sha256=Oazar7h89dp1WA2Vx4Tj7gCBhxJKH4LAUEABkBEG7vU,1462
|
@@ -65,7 +65,7 @@ brainstate/nn/_dyn_impl/_dynamics_neuron.py,sha256=cTbIn41EPYG0h3ICzKBXxpgB6wwA2
|
|
65
65
|
brainstate/nn/_dyn_impl/_dynamics_neuron_test.py,sha256=Tfzrzu7udGrLJGnqItiLWe5WT0dgduvYOgzGCnaPJQg,6317
|
66
66
|
brainstate/nn/_dyn_impl/_dynamics_synapse.py,sha256=MsbPyaiDyjungyzuK2b3exRGaMpZgmsmmNHNLjgxQKw,15269
|
67
67
|
brainstate/nn/_dyn_impl/_dynamics_synapse_test.py,sha256=t5i-HV0ii9sUNzWTEv04o26QVtQ-mCdMJcFq2MD755A,4981
|
68
|
-
brainstate/nn/_dyn_impl/_inputs.py,sha256=
|
68
|
+
brainstate/nn/_dyn_impl/_inputs.py,sha256=x4bcp7fo5SI5TC4TmyARngK-PE7OvGHprJ17Levs0ls,12937
|
69
69
|
brainstate/nn/_dyn_impl/_projection_alignpost.py,sha256=PNC1Tzx_SF2DHAHeJCufXzO_Q4qLoBpWABI45B3GRuc,876
|
70
70
|
brainstate/nn/_dyn_impl/_rate_rnns.py,sha256=dz_yT_6hJVhKulcjIARbGtmMzZqISws96CtBc6o5GOo,14768
|
71
71
|
brainstate/nn/_dyn_impl/_rate_rnns_test.py,sha256=gNgtr-a4ZiU1XF9wFG1HiJ9fLosfWchVR9Zn1x39xt4,2452
|
@@ -109,16 +109,16 @@ brainstate/random/_rand_state.py,sha256=nuoQ8GU1MfJPRNN-ZmRQsggVjoyPhaEdZmwM7_4-
|
|
109
109
|
brainstate/random/_random_for_unit.py,sha256=kGp4EUX19MXJ9Govoivbg8N0bddqOldKEI2h_TbdONY,2057
|
110
110
|
brainstate/util/__init__.py,sha256=-FWEuSKXG3mWxYphGFAy3UEuVe39lFs1GruluzdXDoI,1502
|
111
111
|
brainstate/util/_caller.py,sha256=T3bzu7-09r-6EOrU6Muca_aMXSQua_X2lXjEqb-w39w,2782
|
112
|
-
brainstate/util/_dict.py,sha256=
|
112
|
+
brainstate/util/_dict.py,sha256=Yapug-_RZQYjvd8cZ3v90_MX7rUYJDBzBnZJT6a0NXY,26178
|
113
113
|
brainstate/util/_dict_test.py,sha256=Dn0TdjX6wLBXaTD4jfYTu6cKfFHwKSxi4_3bX7kB_IA,5621
|
114
114
|
brainstate/util/_error.py,sha256=eyZ8PGFixqe2K5OEfjSDzI-2tU0ieYQoUpBP7yStlPQ,878
|
115
115
|
brainstate/util/_filter.py,sha256=1-bvFHdjeehvXeHTrCEp8xr25lopKe8d3XZGCNegq0s,4970
|
116
116
|
brainstate/util/_others.py,sha256=jsPZwP-v_5HRV-LB5F0NUsiqr04y8bmGIsu_JMyVcbQ,14762
|
117
|
-
brainstate/util/_pretty_repr.py,sha256=
|
117
|
+
brainstate/util/_pretty_repr.py,sha256=bDpU4gbkS4B8cXBkiN8kBQNmruxiJzDRF-eIqzyeYnM,5716
|
118
118
|
brainstate/util/_scaling.py,sha256=pc_eM_SZVwkY65I4tJh1ODiHNCoEhsfFXl2zBK0PLAg,7562
|
119
119
|
brainstate/util/_struct.py,sha256=KMMHcshOM20gYhSahNzWLxsTt-Rt3AeX3Uz26-rP9vI,17619
|
120
|
-
brainstate-0.1.0.
|
121
|
-
brainstate-0.1.0.
|
122
|
-
brainstate-0.1.0.
|
123
|
-
brainstate-0.1.0.
|
124
|
-
brainstate-0.1.0.
|
120
|
+
brainstate-0.1.0.post20250210.dist-info/LICENSE,sha256=VZe9u1jgUL2eCY6ZPOYgdb8KCblCHt8ECdbtJid6e1s,11550
|
121
|
+
brainstate-0.1.0.post20250210.dist-info/METADATA,sha256=__N9QGz8FFW6rXXG3_Y5YTKFd9iWM_MVddxJP74hZcI,3585
|
122
|
+
brainstate-0.1.0.post20250210.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
|
123
|
+
brainstate-0.1.0.post20250210.dist-info/top_level.txt,sha256=eQbGgKn0ptx7FDWuua0V0wr4K1VHi2iOUCYo3fUQBRA,11
|
124
|
+
brainstate-0.1.0.post20250210.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{brainstate-0.1.0.post20250209.dist-info → brainstate-0.1.0.post20250210.dist-info}/top_level.txt
RENAMED
File without changes
|