Skip to content

Commit

Permalink
Fix documentation hidden by list handler (#241)
Browse files Browse the repository at this point in the history
Fixed documentation hidden by list handler
  • Loading branch information
HannahSi authored Sep 10, 2019
1 parent c7eb7d3 commit 1392988
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
32 changes: 17 additions & 15 deletions aguaclara/core/utility.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Utility functions and features
This module provides functions and features for scientific calculations and
This module provides functions and features for scientific calculations and
complex function inputs.
Example:
Expand All @@ -13,10 +13,11 @@
import numpy as np
from math import log10, floor, ceil
import warnings
import functools

def optional_units(arg_positions, keys):
"""Wrap a function so that arguments may optionally have units.
This should be used as a function decorator; it will not do anything
meaningful unless it is appended with a ``@`` before another function.
Expand All @@ -33,7 +34,7 @@ def stepper(num, step=10, func=round):
- ``keys (str list)``: Names of positional and keyword arguments with
optional units
"""
# func is the function that is being decorated, and *args/**kwargs are the
# func is the function that is being decorated, and *args/**kwargs are the
# arguments being passed to that function.
def decorator(func):
def wrapper(*args, **kwargs):
Expand Down Expand Up @@ -62,7 +63,7 @@ def round_sig_figs(num, figs=4):
Args:
- ``num (float)``: Value to be rounded (optional units)
- ``figs (int)``: Number of significant digits to be rounded to
- ``figs (int)``: Number of significant digits to be rounded to
(recommended, defaults to 4)
"""
# Prevents undefined log10(0) if num is already 0
Expand All @@ -77,7 +78,7 @@ def round_sf(num, figs=4):
Args:
- ``num (float)``: Value to be rounded (optional units)
- ``figs (int)``: Number of significant digits to be rounded to
- ``figs (int)``: Number of significant digits to be rounded to
(recommended, defaults to 4)
Note: This function will be deprecated after 21 Dec 2019. Use
Expand All @@ -93,13 +94,13 @@ def round_sf(num, figs=4):
@optional_units([0, 1], ['num', 'step'])
def _stepper(num, step=10, func=round):
"""Round a number to be a multiple of some step.
Args:
- ``num (float)``: Value to be rounded (optional units)
- ``step (float)``: Factor to which ``num`` will be rounded (defaults
to 10).
- ``func (function)``: Rounding function to use (defaults to round())
Note:
``step`` must have the same dimensionality as ``num``, but not
necessarily the same units (e.g. ``num``: meters and ``step``:
Expand All @@ -111,12 +112,12 @@ def _stepper(num, step=10, func=round):

def round_step(num, step=10):
"""Round a number to be a multiple of some step.
Args:
- ``num (float)``: Value to be rounded (optional units)
- ``step (float)``: Factor to which ``num`` will be rounded (defaults
to 10).
Note:
``step`` must have the same dimensionality as ``num``, but not
necessarily the same units (e.g. ``num``: meters and ``step``:
Expand All @@ -134,12 +135,12 @@ def floor_step(num, step=10):

def stepceil_with_units(param, step, unit):
"""Round a number up to be a multiple of some step.
Args:
- ``param (float)``: Value to be rounded (optional units)
- ``step (float)``: Factor to which ``param`` will be rounded
- ``unit (Quantity)``: units of ``step``
Note: this function will be deprecated after 21 Dec 2019. Use ceil_step
instead.
"""
Expand Down Expand Up @@ -178,7 +179,7 @@ def ceil_nearest(x, array):

def _minmax(*args, func=np.max):
"""Get the minuimum/maximum value of some Pint quantities with units.
Args:
- ``func (function)``: the min/max function being used.
Expand All @@ -203,7 +204,7 @@ def _minmax(*args, func=np.max):

def max(*args):
"""Get the maximum value of some Pint quantities with units.
Note:
- All quantities must have the same dimensionality, but can have
different units.
Expand All @@ -222,7 +223,7 @@ def min(*args):

def get_sdr(spec):
"""Get the SDR of a string ``spec`` with the form \"sdrXX\".
Args:
- ``spec (str)``: The specification string to be parsed."""
if spec[:3] != "sdr":
Expand All @@ -232,6 +233,7 @@ def get_sdr(spec):
def list_handler(HandlerResult="nparray"):
"""Wraps a function to handle list inputs."""
def decorate(func):
@functools.wraps(func) # For Sphinx documentation of decorated functions
def wrapper(*args, **kwargs):
"""Run through the wrapped function once for each array element.
Expand Down Expand Up @@ -367,7 +369,7 @@ def check_range(*args):

def array_qtys_to_strs(lst):
"""Convert Pint quantities in a NumPy array to strings.
Args:
- ``lst (numpy.ndarray Quantity)``: a list of values that has a Pint
unit attached to it
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name = 'aguaclara',
version = '0.1.7',
version = '0.1.8',
description = (
'An open-source Python package for designing and performing research '
'on AguaClara water treatment plants.'
Expand Down

0 comments on commit 1392988

Please sign in to comment.