diff --git a/pmd_beamphysics/units.py b/pmd_beamphysics/units.py index be8befa..1b06be6 100644 --- a/pmd_beamphysics/units.py +++ b/pmd_beamphysics/units.py @@ -379,6 +379,7 @@ def nice_array(a): if np.isscalar(a): x = a elif len(a) == 1: + a = np.asarray(a) x = a[0] else: a = np.array(a) diff --git a/tests/test_nice.py b/tests/test_nice.py new file mode 100644 index 0000000..25f04d2 --- /dev/null +++ b/tests/test_nice.py @@ -0,0 +1,17 @@ +from pmd_beamphysics.units import nice_array +import numpy as np + + +def test_nice_array(): + nice_array(1) + + nice_array([1]) + + nice_array( + [ + 1, + 2, + ] + ) + + nice_array(np.array([1, 2]))