-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix default math parameter setting bug (#572)
* [math] fix the default setting in `brainpy.math` * [doc] upgrade math doc
- Loading branch information
1 parent
26fe126
commit 8320edc
Showing
7 changed files
with
83 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import unittest | ||
|
||
import brainpy.math as bm | ||
|
||
|
||
class TestDefaults(unittest.TestCase): | ||
def test_dt(self): | ||
with bm.environment(dt=1.0): | ||
self.assertEqual(bm.dt, 1.0) | ||
self.assertEqual(bm.get_dt(), 1.0) | ||
|
||
def test_bool(self): | ||
with bm.environment(bool_=bm.int32): | ||
self.assertTrue(bm.bool_ == bm.int32) | ||
self.assertTrue(bm.get_bool() == bm.int32) | ||
|
||
def test_int(self): | ||
with bm.environment(int_=bm.int32): | ||
self.assertTrue(bm.int == bm.int32) | ||
self.assertTrue(bm.get_int() == bm.int32) | ||
|
||
def test_float(self): | ||
with bm.environment(float_=bm.float32): | ||
self.assertTrue(bm.float_ == bm.float32) | ||
self.assertTrue(bm.get_float() == bm.float32) | ||
|
||
def test_complex(self): | ||
with bm.environment(complex_=bm.complex64): | ||
self.assertTrue(bm.complex_ == bm.complex64) | ||
self.assertTrue(bm.get_complex() == bm.complex64) | ||
|
||
def test_mode(self): | ||
mode = bm.TrainingMode() | ||
with bm.environment(mode=mode): | ||
self.assertTrue(bm.mode == mode) | ||
self.assertTrue(bm.get_mode() == mode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Default Math Parameters | ||
======================= | ||
|
||
.. currentmodule:: brainpy.math | ||
.. automodule:: brainpy.math | ||
|
||
.. autosummary:: | ||
:toctree: generated/ | ||
:nosignatures: | ||
|
||
mode | ||
membrane_scaling | ||
dt | ||
bool_ | ||
int_ | ||
ti_int | ||
float_ | ||
ti_float | ||
complex_ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters