Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Routhleck committed Jul 12, 2024
1 parent c25506c commit efe0164
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions brainunit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def set_default_magnitude(
>>> set_default_magnitude(-9) # Alternatively, use an integer to represent the exponent of 10
>>> set_default_magnitude({'m': -3, 'kg': -9}) # Set the default magnitude for 'metre' to 'milli' and 'kilogram' to 'nano'
>>> set_default_magnitude({'m': 'm', 'kg': 'n'}) # Alternatively, use a string to represent the magnitude
>>> set_default_magnitude(-3, unit=volt) # Set the default magnitude for the 'volt' unit to 'milli'
"""
global _default_magnitude
if isinstance(magnitude, int):
Expand Down Expand Up @@ -102,4 +101,4 @@ def set_default_magnitude(

global __all__
__all__ = ['math'] + _common_all + _std_units_all + _constants_all + _base_all
del _common_all, _std_units_all, _constants_all, _base_all
del _common_all, _std_units_all, _constants_all, _base_all
5 changes: 4 additions & 1 deletion brainunit/_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,7 @@ def test_set_default_magnitude_1():
assert q1.to_value() == 3e-3
assert q2.to_value() == 3e-6


def test_set_default_magnitude_2():
bu.set_default_magnitude(-3)
# from brainunit import second, ms, meter, kmeter
Expand All @@ -1522,6 +1523,7 @@ def test_set_default_magnitude_2():
assert q1.to_value() == 3e-6
assert q2.to_value() == 3e-6


def test_set_default_magnitude_3():
bu.set_default_magnitude({'s': 'm'})
from brainunit import second, ms, meter, kmeter
Expand All @@ -1545,6 +1547,7 @@ def test_set_default_magnitude_3():
assert q1.to_value() == 3e-3
assert q2.to_value() == 3e-3


def test_set_default_magnitude_4():
# volt: m=2, kg=1, s=-3, A=-1
bu.set_default_magnitude(-3)
Expand Down Expand Up @@ -1591,4 +1594,4 @@ def test_set_default_magnitude_4():
# q1 = 3 * volt
# q2 = 3 * mV
# assert q1.to_value() == 3e-3
# assert q2.to_value() == 3e-6
# assert q2.to_value() == 3e-6

0 comments on commit efe0164

Please sign in to comment.