Skip to content

Commit

Permalink
Update docstrings (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
durandtibo authored Jun 27, 2024
1 parent 64ab797 commit e37d75f
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hya"
version = "0.2.2"
version = "0.2.3a0"
description = "A library of custom OmegaConf resolvers"
readme = "README.md"
authors = ["Thibaut Durand <durand.tibo+gh@gmail.com>"]
Expand Down
6 changes: 6 additions & 0 deletions src/hya/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def check_braceexpand() -> None:
Example usage:
```pycon
>>> from hya.imports import check_braceexpand
>>> check_braceexpand()
Expand All @@ -46,6 +47,7 @@ def is_braceexpand_available() -> bool:
Example usage:
```pycon
>>> from hya.imports import is_braceexpand_available
>>> is_braceexpand_available()
Expand All @@ -63,6 +65,7 @@ def check_numpy() -> None:
Example usage:
```pycon
>>> from hya.imports import check_numpy
>>> check_numpy()
Expand All @@ -86,6 +89,7 @@ def is_numpy_available() -> bool:
Example usage:
```pycon
>>> from hya.imports import is_numpy_available
>>> is_numpy_available()
Expand All @@ -103,6 +107,7 @@ def check_torch() -> None:
Example usage:
```pycon
>>> from hya.imports import check_torch
>>> check_torch()
Expand All @@ -126,6 +131,7 @@ def is_torch_available() -> bool:
Example usage:
```pycon
>>> from hya.imports import is_torch_available
>>> is_torch_available()
Expand Down
1 change: 1 addition & 0 deletions src/hya/numpy_.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def to_array_resolver(data: ArrayLike) -> np.ndarray:
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand Down
2 changes: 2 additions & 0 deletions src/hya/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ResolverRegistry:
Example usage:
```pycon
>>> from hya.registry import ResolverRegistry
>>> registry = ResolverRegistry()
>>> @registry.register("my_key")
Expand Down Expand Up @@ -86,6 +87,7 @@ def register_resolvers() -> None:
Example usage:
```pycon
>>> from hya import register_resolvers
>>> register_resolvers()
Expand Down
53 changes: 37 additions & 16 deletions src/hya/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ def add_resolver(*args: Any) -> Any:
r"""Return the addition of several objects.
Args:
*args: Specifies the values to add.
*args: The values to add.
Returns:
``arg1 + arg2 + arg3 + ... + argN``
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -50,14 +51,15 @@ def asinh_resolver(number: float) -> float:
r"""Return the inverse hyperbolic sine.
Args:
number: Specifies the number.
number: The number to transform.
Returns:
The inverse hyperbolic sine of the input number.
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -84,6 +86,7 @@ def ceildiv_resolver(dividend: float, divisor: float) -> int:
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -101,14 +104,15 @@ def exp_resolver(number: float) -> float:
r"""Return the exponential value of the input.
Args:
number: Specifies the number.
number: The number to transform.
Returns:
The exponential value of the input.
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -135,6 +139,7 @@ def floordiv_resolver(dividend: float, divisor: float) -> int:
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -152,14 +157,15 @@ def len_resolver(obj: Any) -> int:
r"""Return the length of an object.
Args:
obj: Specifies the object.
obj: The object.
Returns:
The length of the object.
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -177,15 +183,16 @@ def log_resolver(number: float, base: float = math.e) -> float:
r"""Compute logarithm of the input value to the given base.
Args:
number: Specifies the number.
base: Specifies the base.
number: The number to transform.
base: The base.
Returns:
The logarithm of the input value to the given base.
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -203,14 +210,15 @@ def log10_resolver(number: float) -> float:
r"""Compute base 10 logarithm of the input value.
Args:
number: Specifies the number.
number: The number to transform.
Returns:
The base 10 logarithm of the input value.
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -228,14 +236,15 @@ def max_resolver(*args: Any) -> Any:
r"""Return the maximum between multiple values.
Args:
*args: Specifies the values.
*args: The values.
Returns:
``max(arg1, arg2, arg3, ..., argN)``
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -253,14 +262,15 @@ def min_resolver(*args: Any) -> Any:
r"""Return the minimum between multiple values.
Args:
*args: Specifies the values.
*args: The values.
Returns:
``min(arg1, arg2, arg3, ..., argN)``
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -278,14 +288,15 @@ def mul_resolver(*args: Any) -> Any:
r"""Return the multiplication of several objects.
Args:
*args: Specifies the values to multiply.
*args: The values to multiply.
Returns:
``arg1 * arg2 * arg3 * ... * argN``
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -309,14 +320,15 @@ def neg_resolver(number: float) -> float:
r"""Return the negation (``-number``).
Args:
number: Specifies the number.
number: The number to transform.
Returns:
The negated input number.
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -334,14 +346,15 @@ def path_resolver(path: str) -> Path:
r"""Return a path object.
Args:
path: Specifies the target path.
path: The target path.
Returns:
The path object.
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -364,6 +377,7 @@ def pi_resolver() -> float:
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -390,6 +404,7 @@ def pow_resolver(value: float, exponent: float) -> float:
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -407,7 +422,7 @@ def sqrt_resolver(number: float) -> float:
r"""Return the square root of a number.
Args:
number: Specifies the number to compute the
number: The number to compute the
square root.
Returns:
Expand All @@ -416,6 +431,7 @@ def sqrt_resolver(number: float) -> float:
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -433,14 +449,15 @@ def sha256_resolver(obj: Any) -> str:
r"""Return the SHA-256 hash of the input object.
Args:
obj: Specifies the object to compute the SHA-256 hash.
obj: The object to compute the SHA-256 hash.
Returns:
The SHA-256 hash of the object.
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -458,14 +475,15 @@ def sinh_resolver(number: float) -> float:
r"""Return the hyperbolic sine.
Args:
number: Specifies the number.
number: The number to transform.
Returns:
The hyperbolic sine of the input number.
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -492,6 +510,7 @@ def sub_resolver(object1: Any, object2: Any) -> Any:
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -509,7 +528,7 @@ def to_path_resolver(path: str) -> Path:
r"""Return the input path into a ``pathlib.Path``.
Args:
path: Specifies the path to convert. This value should be
path: The path to convert. This value should be
compatible with ``pathlib.Path``.
Returns:
Expand All @@ -518,6 +537,7 @@ def to_path_resolver(path: str) -> Path:
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand All @@ -544,6 +564,7 @@ def truediv_resolver(dividend: float, divisor: float) -> float:
Example usage:
```pycon
>>> import hya
>>> from omegaconf import OmegaConf
>>> hya.register_resolvers()
Expand Down
Loading

0 comments on commit e37d75f

Please sign in to comment.