From aac031b5cb147ff01e196d1fac03b8a1a08c4c87 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 16:22:37 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pysimulators/operators.py | 8 +++++--- tests/test_operators.py | 4 +--- tests/test_quantities.py | 34 ++++++++++++++++++---------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/pysimulators/operators.py b/src/pysimulators/operators.py index 329c325..8942d54 100644 --- a/src/pysimulators/operators.py +++ b/src/pysimulators/operators.py @@ -177,9 +177,11 @@ def partition_init(self, *args, **keywords): n = len(partitionin) argss = tuple( tuple( - a[i] - if class_args[j] in partition_args and not isscalarlike(a) - else a + ( + a[i] + if class_args[j] in partition_args and not isscalarlike(a) + else a + ) for j, a in enumerate(args) ) for i in range(n) diff --git a/tests/test_operators.py b/tests/test_operators.py index 98268aa..e3e02cb 100644 --- a/tests/test_operators.py +++ b/tests/test_operators.py @@ -77,9 +77,7 @@ def assert_partioning_chunk(cls, op, value, key): nn = ( max(n1, n2) if partitionin is None - else 1 - if isscalarlike(partitionin) - else len(partitionin) + else 1 if isscalarlike(partitionin) else len(partitionin) ) if n1 != n2 and not isscalarlike(value) and not isscalarlike(key): # the partitioned arguments do not have the same length diff --git a/tests/test_quantities.py b/tests/test_quantities.py index e5ffaea..876f97b 100644 --- a/tests/test_quantities.py +++ b/tests/test_quantities.py @@ -174,22 +174,24 @@ def test_function(array, func): @pytest.mark.parametrize( 'value, expected_type', - [ - (Quantity(1), float), - (Quantity(1, dtype='float32'), np.float32), - (Quantity(1.0), float), - (Quantity(complex(1, 0)), np.complex128), - (Quantity(1.0, dtype=np.complex64), np.complex64), - (Quantity(1.0, dtype=np.complex128), np.complex128), - (Quantity(np.array(complex(1, 0))), complex), - (Quantity(np.array(np.complex64(1.0))), np.complex64), - (Quantity(np.array(np.complex128(1.0))), complex), - ] - + [ - (Quantity(1.0, dtype=np.complex256), np.complex256), - ] - if hasattr(np, 'complex256') - else [], + ( + [ + (Quantity(1), float), + (Quantity(1, dtype='float32'), np.float32), + (Quantity(1.0), float), + (Quantity(complex(1, 0)), np.complex128), + (Quantity(1.0, dtype=np.complex64), np.complex64), + (Quantity(1.0, dtype=np.complex128), np.complex128), + (Quantity(np.array(complex(1, 0))), complex), + (Quantity(np.array(np.complex64(1.0))), np.complex64), + (Quantity(np.array(np.complex128(1.0))), complex), + ] + + [ + (Quantity(1.0, dtype=np.complex256), np.complex256), + ] + if hasattr(np, 'complex256') + else [] + ), ) def test_dtype(value, expected_type): assert value.dtype == expected_type