Skip to content

Commit 0c5a070

Browse files
authored
fix: SupportSTDP.stdp_update keyword typo and DSRunner deprecation warning (#864)
- mixin.py: align base SupportSTDP.stdp_update placeholder keyword onn_post -> on_post. - runners.py: DSRunner.predict emitted the inputs_are_batching deprecation via `raise warnings.warn(...)` (TypeError); now warns and continues. mypy brainpy/ clean; STDP suites (91 tests) + warn-path verified.
1 parent d684af5 commit 0c5a070

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

brainpy/dnn/linear.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def offline_fit(self,
226226
self.W.value = Wff
227227
self.b.value = bias[0]
228228

229-
def stdp_update( # type: ignore[override] # base SupportSTDP.stdp_update is a permissive *args/**kwargs placeholder (with an `onn_post` typo); concrete overrides declare explicit params
229+
def stdp_update( # type: ignore[override] # base SupportSTDP.stdp_update is a permissive *args/**kwargs placeholder; concrete overrides declare explicit params
230230
self,
231231
on_pre: Optional[Dict] = None,
232232
on_post: Optional[Dict] = None,
@@ -334,7 +334,7 @@ def update(self, pre_val):
334334
post_val = pre_val @ self.weight
335335
return post_val
336336

337-
def stdp_update( # type: ignore[override] # base SupportSTDP.stdp_update is a permissive *args/**kwargs placeholder (with an `onn_post` typo); concrete overrides declare explicit params
337+
def stdp_update( # type: ignore[override] # base SupportSTDP.stdp_update is a permissive *args/**kwargs placeholder; concrete overrides declare explicit params
338338
self,
339339
on_pre: Optional[Dict] = None,
340340
on_post: Optional[Dict] = None,
@@ -397,7 +397,7 @@ def __init__(
397397
def update(self, pre_val):
398398
return pre_val * self.weight
399399

400-
def stdp_update( # type: ignore[override] # base SupportSTDP.stdp_update is a permissive *args/**kwargs placeholder (with an `onn_post` typo); concrete overrides declare explicit params
400+
def stdp_update( # type: ignore[override] # base SupportSTDP.stdp_update is a permissive *args/**kwargs placeholder; concrete overrides declare explicit params
401401
self,
402402
on_pre: Optional[Dict] = None,
403403
on_post: Optional[Dict] = None,
@@ -484,7 +484,7 @@ def __init__(
484484
def update(self, x):
485485
return x @ self.mask_fun(self.weight * self.mask)
486486

487-
def stdp_update( # type: ignore[override] # base SupportSTDP.stdp_update is a permissive *args/**kwargs placeholder (with an `onn_post` typo); concrete overrides declare explicit params
487+
def stdp_update( # type: ignore[override] # base SupportSTDP.stdp_update is a permissive *args/**kwargs placeholder; concrete overrides declare explicit params
488488
self,
489489
on_pre: Optional[Dict] = None,
490490
on_post: Optional[Dict] = None,
@@ -535,7 +535,7 @@ def __init__(
535535
w = bm.TrainVar(w)
536536
self.weight = w
537537

538-
def stdp_update( # type: ignore[override] # base SupportSTDP.stdp_update is a permissive *args/**kwargs placeholder (with an `onn_post` typo); concrete overrides declare explicit params
538+
def stdp_update( # type: ignore[override] # base SupportSTDP.stdp_update is a permissive *args/**kwargs placeholder; concrete overrides declare explicit params
539539
self,
540540
on_pre: Optional[Dict] = None,
541541
on_post: Optional[Dict] = None,

brainpy/mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,5 +544,5 @@ class SupportSTDP(MixIn):
544544
"""Support synaptic plasticity by modifying the weights.
545545
"""
546546

547-
def stdp_update(self, *args, on_pre=None, onn_post=None, **kwargs):
547+
def stdp_update(self, *args, on_pre=None, on_post=None, **kwargs):
548548
raise NotImplementedError

brainpy/runners.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,9 @@ def predict(
452452
"""
453453

454454
if inputs_are_batching is not None:
455-
raise warnings.warn( # type: ignore[misc] # latent bug: warnings.warn returns None; preserved to avoid behavior change
455+
warnings.warn(
456456
f'''
457-
`inputs_are_batching` is no longer supported.
457+
`inputs_are_batching` is no longer supported.
458458
The target mode of {self.target.mode} has already indicated the input should be batching.
459459
''',
460460
UserWarning

0 commit comments

Comments
 (0)