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

fix pylint line-too-long errors in tests #697

Merged
merged 8 commits into from
Apr 9, 2022
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def _setup(self):

def test_call(self, fitzhughnagumo):

# not-yet-registered ODE raises errors as soon as the approximate info operator is called.
# not-yet-registered ODE raises errors as soon as the approximate
# info operator is called.
with pytest.raises(ValueError):
approx_transition = self.approx_strategy(self.info_op).as_transition()
approx_transition.forward_realization(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def test_ivp_to_regression_problem(

# If an approximation strategy is passed, the output should be an EKF component
# which should suppoert forward_rv().
# If not, the output is a generic NonlinearGaussian (which has been tested for above.
# Recall that DiscreteEKFComponent implements NonlinearGaussian.)
# If not, the output is a generic NonlinearGaussian(which has been
# tested for above. Recall that DiscreteEKFComponent implements NonlinearGaussian.)
if approx_strategy is not None:
assert isinstance(
regprob.measurement_models[1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def dense_matrix_based_update(
np.testing.assert_allclose(
updated_belief.A.cov.todense(),
A_naive.cov.todense(),
err_msg="Covariance of system matrix estimate does not match naive implementation.",
err_msg="""Covariance of system matrix estimate does not
match naive implementation.""",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
err_msg="""Covariance of system matrix estimate does not
match naive implementation.""",
err_msg=(
"Covariance of system matrix estimate does not match naive implementation."
),

since we don't really want a line break in the error message

)

# Inverse
Expand All @@ -105,5 +106,6 @@ def dense_matrix_based_update(
np.testing.assert_allclose(
updated_belief.Ainv.cov.todense(),
Ainv_naive.cov.todense(),
err_msg="Covariance of matrix inverse estimate does not match naive implementation.",
err_msg="""Covariance of matrix inverse estimate does not
match naive implementation.""",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

)
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def dense_matrix_based_update(
np.testing.assert_allclose(
updated_belief.A.cov.todense(),
A_naive.cov.todense(),
err_msg="Covariance of system matrix estimate does not match naive implementation.",
err_msg="""Covariance of system matrix estimate does not
match naive implementation.""",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in test_matrix_based_linear_belief_update.py

)

# Inverse
Expand All @@ -111,5 +112,6 @@ def dense_matrix_based_update(
np.testing.assert_allclose(
updated_belief.Ainv.cov.todense(),
Ainv_naive.cov.todense(),
err_msg="Covariance of matrix inverse estimate does not match naive implementation.",
err_msg="""Covariance of matrix inverse estimate does not
match naive implementation.""",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in test_matrix_based_linear_belief_update.py

)
3 changes: 2 additions & 1 deletion tests/test_linops/test_arithmetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ def test_idkronecker_matmul():
k1 = IdentityKronecker(4, np.random.rand(2, 3)) # (8, 12)
k2 = IdentityKronecker(2, np.random.rand(6, 2)) # (12, 4)

# Even though the shapes fit, and IdentityKronecker @ IdentityKronecker = IdentityKronecker ....
# Even though the shapes fit, and
# IdentityKronecker @ IdentityKronecker = IdentityKronecker ....
assert k1.shape[1] == k2.shape[0]

# The result does not have a IdentityKronecker structure
Expand Down
3 changes: 2 additions & 1 deletion tests/test_linops/test_arithmetics_fallbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import numpy as np
import pytest

from probnum.linops._arithmetic_fallbacks import ( # NegatedLinearOperator,; ProductLinearOperator,; SumLinearOperator,
from probnum.linops._arithmetic_fallbacks import (
# NegatedLinearOperator,; ProductLinearOperator,; SumLinearOperator,
ScaledLinearOperator,
)
from probnum.linops._linear_operator import Matrix
Expand Down
8 changes: 4 additions & 4 deletions tests/test_randvars/test_normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def test_normal_dimension_mismatch(self):
(np.array([[-1, 0], [2, 1]]), np.eye(3)),
]:
with self.subTest():
err_msg = "Mean and kernels mismatch in normal distribution did not raise a ValueError."
err_msg = """Mean and kernels mismatch in normal distribution
did not raise a ValueError."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in test_matrix_based_linear_belief_update.py

with self.assertRaises(ValueError, msg=err_msg):
assert randvars.Normal(mean=mean, cov=cov)

Expand Down Expand Up @@ -204,9 +205,8 @@ def test_symmetric_samples(self):
B.T,
atol=1e-5,
rtol=1e-5,
msg="Sample {} from symmetric Kronecker distribution is not symmetric.".format(
i
),
msg=f"""Sample {i} from symmetric Kronecker
distribution is not symmetric.""",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in test_matrix_based_linear_belief_update.py

)

def test_indexing(self):
Expand Down
12 changes: 8 additions & 4 deletions tests/testing/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ def chi_squared_statistic(realisations, means, covs):
with (assumed) means :math:`m_1, ..., m_N` and covariances
:math:`C_1, ..., C_N`, compute the value

.. math:`\\chi^2 = \\frac{1}{Nd} \\sum_{n=1}^N (x_n - m_n)^\\top C_n^{-1}(x_n - m_n).`
.. math:`\\chi^2
= \\frac{1}{Nd} \\sum_{n=1}^N (x_n - m_n)^\\top C_n^{-1}(x_n - m_n).`

If it is roughly equal to 1, the samples are likely to correspond to given mean and covariance.
If it is roughly equal to 1, the samples are likely to correspond to given
mean and covariance.

Parameters
----------
realisations : array_like
:math:`N` realisations of a :math:`d`-dimensional random variable. Shape (N, d).
means : array_like
:math:`N`, :math:`d`-dimensional (assumed) means of a random variable. Shape (N, d).
:math:`N`, :math:`d`-dimensional (assumed) means of a random variable.
Shape (N, d).
realisations : array_like
:math:`N`, :math:`d \\times d`-dimensional (assumed) covariances of a random variable. Shape (N, d, d).
:math:`N`, :math:`d \\times d`-dimensional (assumed) covariances of a random
variable. Shape (N, d, d).
"""
if not realisations.shape == means.shape == covs.shape[:-1]:
print(realisations.shape, means.shape, covs.shape)
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@ commands =
# pylint benchmarks --disable="unused-argument,attribute-defined-outside-init,missing-function-docstring" --jobs=0 # not a work in progress, but final
pylint benchmarks --disable="unused-argument,attribute-defined-outside-init,no-else-return,no-self-use,consider-using-from-import,missing-module-docstring,missing-class-docstring,missing-function-docstring" --jobs=0
# pylint tests --disable="missing-function-docstring" --jobs=0 # not a work in progress, but final
pylint tests --disable="arguments-differ,redefined-outer-name,too-many-instance-attributes,too-many-arguments,too-many-locals,too-few-public-methods,protected-access,unnecessary-pass,unused-variable,unused-argument,unused-private-member,attribute-defined-outside-init,no-else-return,no-self-use,consider-using-from-import,duplicate-code,line-too-long,missing-module-docstring,missing-class-docstring,missing-function-docstring,missing-param-doc,missing-type-doc,missing-raises-doc,missing-return-type-doc,redundant-returns-doc" --jobs=0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this line skips running pylint on the tests entirely. Please only remove the disabled line-too-long message