brainstate 0.1.0.post20250127__py2.py3-none-any.whl → 0.1.0.post20250129__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.
@@ -216,9 +216,14 @@ 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
222
  Poisson Input to the given :py:class:`brainstate.State`.
223
+
224
+ Args:
225
+ freq:
226
+ refractory: should be the same length with ``target``.
222
227
  """
223
228
  freq = maybe_state(freq)
224
229
  weight = maybe_state(weight)
@@ -291,7 +296,7 @@ def poisson_input(
291
296
  # )
292
297
 
293
298
  # update target variable
294
- target.value = jax.tree.map(
299
+ data = jax.tree.map(
295
300
  lambda tar, x: tar + x * weight,
296
301
  target.value,
297
302
  inp,
@@ -358,9 +363,19 @@ def poisson_input(
358
363
  # )
359
364
 
360
365
  # update target variable
361
- target.value = jax.tree.map(
366
+ data = jax.tree.map(
362
367
  lambda x, tar: tar.at[indices].add(x * weight),
363
368
  inp,
364
369
  tar_val,
365
370
  is_leaf=u.math.is_quantity
366
371
  )
372
+
373
+ if refractory is not None:
374
+ target.value = jax.tree.map(
375
+ lambda x, tar: u.math.where(refractory, tar, x),
376
+ data,
377
+ tar_val,
378
+ is_leaf=u.math.is_quantity
379
+ )
380
+ else:
381
+ target.value = data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: brainstate
3
- Version: 0.1.0.post20250127
3
+ Version: 0.1.0.post20250129
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
@@ -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=QOUpAb2YJOE78uAvIS8Ep6MFcQHV-V6uRwmYvk5p9bk,11385
68
+ brainstate/nn/_dyn_impl/_inputs.py,sha256=72-UnT-hpG03EvSYx72ldDhbgZwmaoOYxxkANpX6xpo,11779
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
@@ -117,8 +117,8 @@ brainstate/util/_others.py,sha256=jsPZwP-v_5HRV-LB5F0NUsiqr04y8bmGIsu_JMyVcbQ,14
117
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.post20250127.dist-info/LICENSE,sha256=VZe9u1jgUL2eCY6ZPOYgdb8KCblCHt8ECdbtJid6e1s,11550
121
- brainstate-0.1.0.post20250127.dist-info/METADATA,sha256=-j8gDuJN37nbSkijFC9TtG5UbflMZZWK-sftY7fkeps,3585
122
- brainstate-0.1.0.post20250127.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
123
- brainstate-0.1.0.post20250127.dist-info/top_level.txt,sha256=eQbGgKn0ptx7FDWuua0V0wr4K1VHi2iOUCYo3fUQBRA,11
124
- brainstate-0.1.0.post20250127.dist-info/RECORD,,
120
+ brainstate-0.1.0.post20250129.dist-info/LICENSE,sha256=VZe9u1jgUL2eCY6ZPOYgdb8KCblCHt8ECdbtJid6e1s,11550
121
+ brainstate-0.1.0.post20250129.dist-info/METADATA,sha256=g93rl2oDT8uoaL4wbHVDFtC7Y5F3kuuebI64WBKUTc0,3585
122
+ brainstate-0.1.0.post20250129.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
123
+ brainstate-0.1.0.post20250129.dist-info/top_level.txt,sha256=eQbGgKn0ptx7FDWuua0V0wr4K1VHi2iOUCYo3fUQBRA,11
124
+ brainstate-0.1.0.post20250129.dist-info/RECORD,,