From ae3f2835f9c5fc102014a2f38d6fb8708e931887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dieter=20Werthm=C3=BCller?= Date: Fri, 24 May 2024 14:55:12 +0200 Subject: [PATCH] Add a test --- resmda/utils.py | 2 +- tests/.keep | 0 tests/test_utils.py | 10 ++++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) delete mode 100644 tests/.keep create mode 100644 tests/test_utils.py diff --git a/resmda/utils.py b/resmda/utils.py index d285e93..19bdae5 100644 --- a/resmda/utils.py +++ b/resmda/utils.py @@ -60,7 +60,7 @@ def rng(random=None): """ if isinstance(random, int): - return np.random.default_rng(int) + return np.random.default_rng(random) elif isinstance(random, np.random.Generator): return random else: diff --git a/tests/.keep b/tests/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 0000000..dc5c3d0 --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,10 @@ +import numpy as np + +from resmda import utils + + +def test_random(): + assert isinstance(utils.rng(), np.random.Generator) + assert isinstance(utils.rng(11), np.random.Generator) + rng = np.random.default_rng() + assert rng == utils.rng(rng)