Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Aug 12, 2024
1 parent 95fc07e commit 28c6ea7
Showing 1 changed file with 65 additions and 64 deletions.
129 changes: 65 additions & 64 deletions src/diffpy/srmise/tests/test_dataclusters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from copy import copy
import pytest

import numpy as np
import pytest

from diffpy.srmise.dataclusters import DataClusters

Expand Down Expand Up @@ -42,76 +43,76 @@ def test___eq__():
# (produce ValueError & msg "Sequences x and y must have the same length.", something like that)
# (6) Both x and y are empty array, and res is zero.


@pytest.mark.parametrize(
"inputs, expected",
[
(
# case (1)
{
"input_x": np.array([1, 2, 3]),
"input_y": np.array([3, 2, 1]),
"input_res": 4,
},
DataClusters(np.array([1, 2, 3]), np.array([3, 2, 1]), 4),
),
(
# case (6)
{
"input_x": np.array([]),
"input_y": np.array([]),
"input_res": 0,
},
DataClusters(np.array([]), np.array([]), 0),
),
],
)
"inputs, expected",
[
(
# case (1)
{
"input_x": np.array([1, 2, 3]),
"input_y": np.array([3, 2, 1]),
"input_res": 4,
},
DataClusters(np.array([1, 2, 3]), np.array([3, 2, 1]), 4),
),
(
# case (6)
{
"input_x": np.array([]),
"input_y": np.array([]),
"input_res": 0,
},
DataClusters(np.array([]), np.array([]), 0),
),
],
)
def test_set_data(inputs, expected):
actual = DataClusters(x=inputs["input_x"], y=inputs["input_y"], res=inputs["input_res"])
assert actual == expected


@pytest.mark.parametrize(
"inputs, msg",
[
(
# case (4)
{
"input_x": np.array([]),
"input_y": np.array([3, 2]),
"input_res": 4,
},
"Sequences x and y must have the same length.",
),
(
# case (5)
{
"input_x": np.array([1, 2]),
"input_y": np.array([]),
"input_res": 4,
},
"Sequences x and y must have the same length.",
),
(
# case (3)
{
"input_x": np.array([1]),
"input_y": np.array([3]),
"input_res": -1,
},
"Resolution res must be non-negative.",
),
(
# case (2)
{
"input_x": np.array([1, 2, 3]),
"input_y": np.array([3, 2, 1]),
"input_res": 0,
},
"Make trivial clustering, please make positive resolution.",
),
],
)
"inputs, msg",
[
(
# case (4)
{
"input_x": np.array([]),
"input_y": np.array([3, 2]),
"input_res": 4,
},
"Sequences x and y must have the same length.",
),
(
# case (5)
{
"input_x": np.array([1, 2]),
"input_y": np.array([]),
"input_res": 4,
},
"Sequences x and y must have the same length.",
),
(
# case (3)
{
"input_x": np.array([1]),
"input_y": np.array([3]),
"input_res": -1,
},
"Resolution res must be non-negative.",
),
(
# case (2)
{
"input_x": np.array([1, 2, 3]),
"input_y": np.array([3, 2, 1]),
"input_res": 0,
},
"Make trivial clustering, please make positive resolution.",
),
],
)
def test_set_data_order_bad(inputs, msg):
with pytest.raises(ValueError, match=msg):
DataClusters(x=inputs["input_x"], y=inputs["input_y"], res=inputs["input_res"])

0 comments on commit 28c6ea7

Please sign in to comment.