Skip to content

Commit

Permalink
update doc (#3)
Browse files Browse the repository at this point in the history
* update doc

* update doc
  • Loading branch information
chaoming0625 authored Jun 8, 2024
1 parent 59f8fe0 commit 7d4ad73
Show file tree
Hide file tree
Showing 13 changed files with 794 additions and 657 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
6 changes: 2 additions & 4 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ API Documentation
:maxdepth: 1

apis/changelog.md
apis/functional.rst
apis/init.rst
apis/metric.rst
apis/optim.rst
apis/brainunit.rst
apis/brainunit.math.rst

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

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

.. autosummary::
:toctree: generated/

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.

29 changes: 0 additions & 29 deletions docs/apis/init.rst

This file was deleted.

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 7d4ad73

Please sign in to comment.