Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoming0625 committed Jun 8, 2024
1 parent 59f8fe0 commit c225fd9
Show file tree
Hide file tree
Showing 10 changed files with 811 additions and 652 deletions.
12 changes: 9 additions & 3 deletions brainunit/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,11 +947,17 @@ def __init__(
self,
value: Any,
dtype: bst.typing.DTypeLike = None,
unit: Dimension = DIMENSIONLESS,
unit: Union[Dimension, 'Unit'] = DIMENSIONLESS,
):
if isinstance(unit, Unit):
s = unit.value
unit = unit.unit
else:
s = None

if isinstance(value, numbers.Number) and _allow_python_scalar_value:
self._unit = unit
self._value = value
self._value = (value if s is None else (value * s))
return

if isinstance(value, (list, tuple)):
Expand Down Expand Up @@ -984,7 +990,7 @@ def __init__(
raise TypeError(f"Invalid type for value: {type(value)}")

# value
self._value = value
self._value = (value if s is None else (value * s))

# unit
self._unit = unit
Expand Down
2 changes: 1 addition & 1 deletion brainunit/math/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from jax.tree_util import tree_map

from brainunit import Quantity
from .._base import Quantity


def _as_jax_array_(obj):
Expand Down
42 changes: 42 additions & 0 deletions docs/apis/brainunit.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
``brainunit`` module
====================

.. currentmodule:: brainunit
.. automodule:: brainunit



Base Classes
------------

.. autosummary::
:toctree: generated/
:nosignatures:
:template: classtemplate.rst

Quantity
Unit
DIMENSIONLESS
DimensionMismatchError


Helper Functions
----------------

.. autosummary::
:toctree: generated/
:nosignatures:
:template: classtemplate.rst

get_or_create_dimension
get_unit
get_basic_unit
is_unitless
have_same_unit
in_unit
in_best_unit
register_new_unit
check_units
is_scalar_type
fail_for_dimension_mismatch

76 changes: 0 additions & 76 deletions docs/apis/functional.rst

This file was deleted.

58 changes: 29 additions & 29 deletions docs/apis/init.rst → docs/apis/math.rst
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
``brainunit.init`` module
==========================

.. currentmodule:: brainunit.init
.. automodule:: brainunit.init

.. autosummary::
:toctree: generated/

parameter
state
noise
to_size
Initializer
ZeroInit
Constant
Identity
Normal
TruncatedNormal
Uniform
VarianceScaling
KaimingUniform
KaimingNormal
XavierUniform
XavierNormal
LecunUniform
LecunNormal
Orthogonal
DeltaOrthogonal
``brainunit.init`` module
==========================

.. currentmodule:: brainunit.init
.. automodule:: brainunit.init

.. autosummary::
:toctree: generated/

parameter
state
noise
to_size
Initializer
ZeroInit
Constant
Identity
Normal
TruncatedNormal
Uniform
VarianceScaling
KaimingUniform
KaimingNormal
XavierUniform
XavierNormal
LecunUniform
LecunNormal
Orthogonal
DeltaOrthogonal
121 changes: 0 additions & 121 deletions docs/apis/metric.rst

This file was deleted.

50 changes: 0 additions & 50 deletions docs/apis/optim.rst

This file was deleted.

Loading

0 comments on commit c225fd9

Please sign in to comment.