Skip to content

Commit

Permalink
init units
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoming0625 committed Mar 8, 2024
1 parent 6092afa commit 14f4ac4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion brainpy/_src/math/units/all_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -8009,7 +8009,7 @@ class _Celsius:
"ambiguities when mixed with absolute temperatures defined"
"in Kelvin. Directly use 'kelvin' when you are only"
"interested in temperature differences, and add the"
"'zero_celsius' constant from the brian2.units.constants"
"'zero_celsius' constant from the brainpy._src.math.units.constants"
"module if you want to convert a temperature from Celsius to"
"Kelvin."
)
Expand Down
20 changes: 10 additions & 10 deletions brainpy/_src/math/units/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def get_or_create_dimension(*args, **kwds):
--------
The following are all definitions of the dimensions of force
>>> from brian2 import *
>>> from brainpy.math.units import *
>>> get_or_create_dimension(length=1, mass=1, time=-2)
metre * kilogram * second ** -2
>>> get_or_create_dimension(m=1, kg=1, s=-2)
Expand Down Expand Up @@ -852,7 +852,7 @@ def in_unit(x, u, precision=None):
Examples
--------
>>> from brian2 import *
>>> from brainpy.math.units import *
>>> in_unit(3 * volt, mvolt)
'3000. mV'
>>> in_unit(123123 * msecond, second, 2)
Expand Down Expand Up @@ -898,7 +898,7 @@ def in_best_unit(x, precision=None):
Examples
--------
>>> from brian2.units import *
>>> from brainpy.math.units import *
>>> in_best_unit(0.00123456 * volt)
'1.23456 mV'
>>> in_best_unit(0.00123456 * volt, 2)
Expand Down Expand Up @@ -943,7 +943,7 @@ def quantity_with_dimensions(floatval, dims):
Examples
--------
>>> from brian2 import *
>>> from brainpy.math.units import *
>>> quantity_with_dimensions(0.001, volt.dim)
1. * mvolt
Expand Down Expand Up @@ -1244,7 +1244,7 @@ def with_dimensions(value, *args, **keywords):
--------
All of these define an equivalent `Quantity` object:
>>> from brian2 import *
>>> from brainpy.math.units import *
>>> Quantity.with_dimensions(2, get_or_create_dimension(length=1))
2. * metre
>>> Quantity.with_dimensions(2, length=1)
Expand Down Expand Up @@ -1321,8 +1321,8 @@ def in_unit(self, u, precision=None, python_code=False):
Examples
--------
>>> from brian2.units import *
>>> from brian2.units.stdunits import *
>>> from brainpy.math.units import *
>>> from brainpy.math.units.stdunits import *
>>> x = 25.123456 * mV
>>> x.in_unit(volt)
'0.02512346 V'
Expand Down Expand Up @@ -1421,7 +1421,7 @@ def in_best_unit(self, precision=None, python_code=False, *regs):
Examples
--------
>>> from brian2.units import *
>>> from brainpy.math.units import *
>>> x = 0.00123456 * volt
Expand Down Expand Up @@ -2456,7 +2456,7 @@ def check_units(**au):
Examples
--------
>>> from brian2.units import *
>>> from brainpy.math.units import *
>>> @check_units(I=amp, R=ohm, wibble=metre, result=volt)
... def getvoltage(I, R, **k):
... return I*R
Expand Down Expand Up @@ -2529,7 +2529,7 @@ def check_units(**au):
>>> multiply_sum(3*nA, 4*mV, 5*nA) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
brian2.units.fundamentalunits.DimensionMismatchError: Function 'multiply_sum' expected the same arguments for arguments 'summand_1', 'summand_2', but argument 'summand_1' has unit V, while argument 'summand_2' has unit A.
DimensionMismatchError: Function 'multiply_sum' expected the same arguments for arguments 'summand_1', 'summand_2', but argument 'summand_1' has unit V, while argument 'summand_2' has unit A.
Raises
------
Expand Down
2 changes: 1 addition & 1 deletion brainpy/_src/math/units/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
have to be imported explicitly. You can use ``import ... as ...`` to import them
with shorter names, e.g.::
from brian2.units.constants import faraday_constant as F
from brainpy.math.units import faraday_constant as F
The available constants are:
Expand Down

0 comments on commit 14f4ac4

Please sign in to comment.