Skip to content

Commit

Permalink
ENH: a better repr for unyt arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Sep 25, 2021
1 parent 51b3ddb commit 05bb1c7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion unyt/_array_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def decorator(func):

@implements(np.array2string)
def array2string(a, *args, **kwargs):
return np.array2string._implementation(a, *args, **kwargs) + f" {a.units}"
return np.array2string._implementation(a, *args, **kwargs) + f", units={str(a.units)!r}"


def _get_conversion_factor(out, units) -> float:
Expand Down
2 changes: 1 addition & 1 deletion unyt/tests/test_array_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def test_array_repr():
arr = [1, 2, 3] * cm
assert np.array_repr(arr) == "unyt_array([1, 2, 3] cm)"
assert np.array_repr(arr) == "unyt_array([1, 2, 3], units='cm')"


def test_dot_vectors():
Expand Down

0 comments on commit 05bb1c7

Please sign in to comment.