Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove most pytest warnings #1478

Merged
merged 1 commit into from
Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions pint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,6 @@ def get_application_registry():
return application_registry


def test():
"""Run all tests.

Returns
-------
unittest.TestResult
"""
from .testsuite import run

return run()


# Enumerate all user-facing objects
# Hint to intersphinx that, when building objects.inv, these objects must be registered
# under the top-level module and not in their original submodules
Expand Down
2 changes: 1 addition & 1 deletion pint/testsuite/test_compat_downcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def array(request):
elif request.param == "masked_array":
# Create sample masked array as an upper triangular matrix.
return np.ma.masked_array(
np.arange(25, dtype=np.float).reshape((5, 5)),
np.arange(25, dtype=float).reshape((5, 5)),
mask=np.logical_not(np.triu(np.ones((5, 5)))),
)
elif request.param == "dask_array":
Expand Down
1 change: 1 addition & 0 deletions pint/testsuite/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ def test_issue_1300(self):

if np is not None:

@pytest.mark.filterwarnings("ignore::pint.UnitStrippedWarning")
@pytest.mark.parametrize(
"callable",
[
Expand Down
8 changes: 4 additions & 4 deletions pint/testsuite/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def test_addition_with_incompatible_scalar(self):
op.add(b, a)

def test_power(self):
arr = np.array(range(3), dtype=np.float)
arr = np.array(range(3), dtype=float)
q = self.Q_(arr, "meter")

for op_ in [op.pow, op.ipow, np.power]:
Expand Down Expand Up @@ -523,7 +523,7 @@ def test_cbrt(self):
@pytest.mark.xfail
@helpers.requires_numpy
def test_exponentiation_array_exp_2(self):
arr = np.array(range(3), dtype=np.float)
arr = np.array(range(3), dtype=float)
# q = self.Q_(copy.copy(arr), None)
q = self.Q_(copy.copy(arr), "meter")
arr_cp = copy.copy(arr)
Expand Down Expand Up @@ -990,8 +990,8 @@ def test_shape_numpy_func(self):
assert np.shape(self.q) == (2, 2)

@helpers.requires_array_function_protocol()
def test_alen_numpy_func(self):
assert np.alen(self.q) == 2
def test_len_numpy_func(self):
assert len(self.q) == 2

@helpers.requires_array_function_protocol()
def test_ndim_numpy_func(self):
Expand Down
36 changes: 18 additions & 18 deletions pint/testsuite/test_quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,8 +1221,8 @@ def test_inplace_addition(self, input_tuple, expected):
(q1v, q1u), (q2v, q2u) = input_tuple
# update input tuple with new values to have correct values on failure
input_tuple = (
(np.array([q1v] * 2, dtype=np.float), q1u),
(np.array([q2v] * 2, dtype=np.float), q2u),
(np.array([q1v] * 2, dtype=float), q1u),
(np.array([q2v] * 2, dtype=float), q2u),
)
Q_ = self.Q_
qin1, qin2 = input_tuple
Expand All @@ -1232,7 +1232,7 @@ def test_inplace_addition(self, input_tuple, expected):
with pytest.raises(OffsetUnitCalculusError):
op.iadd(q1_cp, q2)
else:
expected = np.array([expected[0]] * 2, dtype=np.float), expected[1]
expected = np.array([expected[0]] * 2, dtype=float), expected[1]
assert op.iadd(q1_cp, q2).units == Q_(*expected).units
q1_cp = copy.copy(q1)
helpers.assert_quantity_almost_equal(
Expand Down Expand Up @@ -1300,8 +1300,8 @@ def test_inplace_subtraction(self, input_tuple, expected):
(q1v, q1u), (q2v, q2u) = input_tuple
# update input tuple with new values to have correct values on failure
input_tuple = (
(np.array([q1v] * 2, dtype=np.float), q1u),
(np.array([q2v] * 2, dtype=np.float), q2u),
(np.array([q1v] * 2, dtype=float), q1u),
(np.array([q2v] * 2, dtype=float), q2u),
)
Q_ = self.Q_
qin1, qin2 = input_tuple
Expand All @@ -1311,7 +1311,7 @@ def test_inplace_subtraction(self, input_tuple, expected):
with pytest.raises(OffsetUnitCalculusError):
op.isub(q1_cp, q2)
else:
expected = np.array([expected[0]] * 2, dtype=np.float), expected[1]
expected = np.array([expected[0]] * 2, dtype=float), expected[1]
assert op.isub(q1_cp, q2).units == Q_(*expected).units
q1_cp = copy.copy(q1)
helpers.assert_quantity_almost_equal(
Expand Down Expand Up @@ -1378,8 +1378,8 @@ def test_inplace_multiplication(self, input_tuple, expected):
(q1v, q1u), (q2v, q2u) = input_tuple
# update input tuple with new values to have correct values on failure
input_tuple = (
(np.array([q1v] * 2, dtype=np.float), q1u),
(np.array([q2v] * 2, dtype=np.float), q2u),
(np.array([q1v] * 2, dtype=float), q1u),
(np.array([q2v] * 2, dtype=float), q2u),
)
Q_ = self.Q_
qin1, qin2 = input_tuple
Expand All @@ -1389,7 +1389,7 @@ def test_inplace_multiplication(self, input_tuple, expected):
with pytest.raises(OffsetUnitCalculusError):
op.imul(q1_cp, q2)
else:
expected = np.array([expected[0]] * 2, dtype=np.float), expected[1]
expected = np.array([expected[0]] * 2, dtype=float), expected[1]
assert op.imul(q1_cp, q2).units == Q_(*expected).units
q1_cp = copy.copy(q1)
helpers.assert_quantity_almost_equal(
Expand Down Expand Up @@ -1458,8 +1458,8 @@ def test_inplace_truedivision(self, input_tuple, expected):
(q1v, q1u), (q2v, q2u) = input_tuple
# update input tuple with new values to have correct values on failure
input_tuple = (
(np.array([q1v] * 2, dtype=np.float), q1u),
(np.array([q2v] * 2, dtype=np.float), q2u),
(np.array([q1v] * 2, dtype=float), q1u),
(np.array([q2v] * 2, dtype=float), q2u),
)
Q_ = self.Q_
qin1, qin2 = input_tuple
Expand All @@ -1469,7 +1469,7 @@ def test_inplace_truedivision(self, input_tuple, expected):
with pytest.raises(OffsetUnitCalculusError):
op.itruediv(q1_cp, q2)
else:
expected = np.array([expected[0]] * 2, dtype=np.float), expected[1]
expected = np.array([expected[0]] * 2, dtype=float), expected[1]
assert op.itruediv(q1_cp, q2).units == Q_(*expected).units
q1_cp = copy.copy(q1)
helpers.assert_quantity_almost_equal(
Expand Down Expand Up @@ -1524,8 +1524,8 @@ def test_inplace_multiplication_with_autoconvert(self, input_tuple, expected):
(q1v, q1u), (q2v, q2u) = input_tuple
# update input tuple with new values to have correct values on failure
input_tuple = (
(np.array([q1v] * 2, dtype=np.float), q1u),
(np.array([q2v] * 2, dtype=np.float), q2u),
(np.array([q1v] * 2, dtype=float), q1u),
(np.array([q2v] * 2, dtype=float), q2u),
)
Q_ = self.Q_
qin1, qin2 = input_tuple
Expand All @@ -1535,7 +1535,7 @@ def test_inplace_multiplication_with_autoconvert(self, input_tuple, expected):
with pytest.raises(OffsetUnitCalculusError):
op.imul(q1_cp, q2)
else:
expected = np.array([expected[0]] * 2, dtype=np.float), expected[1]
expected = np.array([expected[0]] * 2, dtype=float), expected[1]
assert op.imul(q1_cp, q2).units == Q_(*expected).units
q1_cp = copy.copy(q1)
helpers.assert_quantity_almost_equal(
Expand Down Expand Up @@ -1664,7 +1664,7 @@ def test_inplace_exponentiation(self, input_tuple, expected):
in1, in2 = input_tuple
if type(in1) is tuple and type(in2) is tuple:
(q1v, q1u), (q2v, q2u) = in1, in2
in1 = self.Q_(*(np.array([q1v] * 2, dtype=np.float), q1u))
in1 = self.Q_(*(np.array([q1v] * 2, dtype=float), q1u))
in2 = self.Q_(q2v, q2u)
elif not type(in1) is tuple and type(in2) is tuple:
in2 = self.Q_(*in2)
Expand All @@ -1683,12 +1683,12 @@ def test_inplace_exponentiation(self, input_tuple, expected):
else:
if type(expected_copy[i]) is tuple:
expected = self.Q_(
np.array([expected_copy[i][0]] * 2, dtype=np.float),
np.array([expected_copy[i][0]] * 2, dtype=float),
expected_copy[i][1],
)
assert op.ipow(in1_cp, in2).units == expected.units
else:
expected = np.array([expected_copy[i]] * 2, dtype=np.float)
expected = np.array([expected_copy[i]] * 2, dtype=float)

in1_cp = copy.copy(in1)
helpers.assert_quantity_almost_equal(op.ipow(in1_cp, in2), expected)
Expand Down