Skip to content

Commit

Permalink
Move unit_registry into __init__ so it appears in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
znicholls committed Dec 5, 2023
1 parent d1b8546 commit cdba618
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
6 changes: 6 additions & 0 deletions docs/source/api/openscm_units.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ API Reference

openscm_units.data

unit\_registry
==============

.. autodata:: unit_registry


ScmUnitRegistry
===============

Expand Down
14 changes: 13 additions & 1 deletion src/openscm_units/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@
"""
import importlib.metadata

from ._unit_registry import ScmUnitRegistry, unit_registry
from ._unit_registry import ScmUnitRegistry

__version__ = importlib.metadata.version("openscm_units")

__all__ = [
"ScmUnitRegistry",
"unit_registry",
]


unit_registry = ScmUnitRegistry()
"""
Standard unit registry
The unit registry contains all of the recognised units. Be careful, if you
edit this registry in one place then it will also be edited in any other
places that use :mod:`openscm_units`. If you want multiple, separate registries,
create multiple instances of :class:`ScmUnitRegistry`.
"""
unit_registry.add_standards()
12 changes: 0 additions & 12 deletions src/openscm_units/_unit_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,3 @@ def split_gas_mixture(
ret.append(quantity / mixture_unit * fraction_pct / 100 * constituent_unit)

return ret


unit_registry = ScmUnitRegistry()
"""
Standard unit registry
The unit registry contains all of the recognised units. Be careful, if you
edit this registry in one place then it will also be edited in any other
places that use ``openscm_units``. If you want multiple, separate registries,
create multiple instances of ``ScmUnitRegistry``.
"""
unit_registry.add_standards()

0 comments on commit cdba618

Please sign in to comment.