Skip to content

Commit

Permalink
Improve misc doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauko Quiroga committed Aug 31, 2021
1 parent 354cbf5 commit 6aa9198
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions openfisca_core/commons/misc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

import numpy
from .typing import NDArray


def empty_clone(original: Any) -> Any:
Expand Down Expand Up @@ -40,7 +40,7 @@ def __init__(self) -> None:
return new


def stringify_array(array: numpy.ndarray) -> str:
def stringify_array(array: NDArray) -> str:
"""Generates a clean string representation of a numpy array.
Args:
Expand All @@ -51,9 +51,21 @@ def stringify_array(array: numpy.ndarray) -> str:
Examples:
>>> import numpy
>>> array = numpy.array([10, 20])
>>> stringify_array(None)
'None'
>>> array = numpy.array([10, 20.])
>>> stringify_array(array)
'[10.0, 20.0]'
>>> array = numpy.array(["10", "Twenty"])
>>> stringify_array(array)
'[10, Twenty]'
>>> array = numpy.array([list, dict(), stringify_array])
>>> stringify_array(array)
'[10, 20]'
"[<class 'list'>, {}, <function stringify_array...]"
"""

Expand Down

0 comments on commit 6aa9198

Please sign in to comment.