Skip to content

Commit

Permalink
Merge pull request #885 from FlorianPfaff/linter_fixes
Browse files Browse the repository at this point in the history
Linter fixes
  • Loading branch information
FlorianPfaff authored Oct 22, 2024
2 parents 49539ad + adeb344 commit f349965
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:
id: ml
# You can override MegaLinter flavor used to have faster performances
# More info at https://megalinter.io/latest/configuration/#shared-variables
uses: oxsecurity/megalinter/flavors/python@v7.11.1
uses: oxsecurity/megalinter/flavors/python@v8.1.0
env:
# All available variables are described in documentation
# https://megalinter.io/latest/configuration/#shared-variables
Expand Down
1 change: 1 addition & 0 deletions pyrecest/distributions/abstract_grid_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


class AbstractGridDistribution(AbstractDistributionType):
# pylint: disable=too-many-positional-arguments
@beartype
def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def sample(self, n: Union[int, int32, int64]):
return self.sample_metropolis_hastings(n)

# jscpd:ignore-start
# pylint: disable=too-many-positional-arguments
def sample_metropolis_hastings(
self,
n: Union[int, int32, int64],
Expand Down
10 changes: 9 additions & 1 deletion pyrecest/distributions/circle/circular_fourier_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CircularFourierDistribution(AbstractCircularDistribution):
Circular Fourier Distribution. This is based on my implementation for pytorch in pyDirectional
"""

# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
def __init__(
self,
transformation: str = "sqrt",
Expand Down Expand Up @@ -254,6 +254,8 @@ def get_a_b(self):
elif self.c is not None:
a = 2.0 * real(self.c)
b = -2.0 * imag(self.c[1:])
else:
raise ValueError("Need either a and b or c.")
assert (
self.n is None or (a.shape[0] + b.shape[0]) == self.n
) # Other case not implemented yet!
Expand All @@ -264,6 +266,9 @@ def get_c(self):
c = (self.a[0] + 1j * hstack((0, self.b))) * 0.5
elif self.c is not None:
c = self.c
else:
raise ValueError("Need either a and b or c.")

return c

def to_real_fd(self):
Expand All @@ -278,6 +283,9 @@ def to_real_fd(self):
n=self.n,
multiplied_by_n=self.multiplied_by_n,
)
else:
raise ValueError("Need either a and b or c.")

return fd

def get_full_c(self):
Expand Down
1 change: 1 addition & 0 deletions pyrecest/distributions/circle/sine_skewed_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class GeneralizedKSineSkewedVonMisesDistribution(AbstractCircularDistribution):
- m (int): Power of the sine term, must be a positive integer.
"""

# pylint: disable=too-many-positional-arguments
def __init__(self, mu, kappa, lambda_, k, m):
AbstractCircularDistribution.__init__(self)
self.mu = mod(mu, 2 * pi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def mean(self):
return self.mean_axis()

# jscpd:ignore-start
# pylint: disable=too-many-positional-arguments
def sample_metropolis_hastings(
self,
n: Union[int, int32, int64],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def mean(self):
return self.mean_direction()

# jscpd:ignore-start
# pylint: disable=too-many-positional-arguments
def sample_metropolis_hastings(
self,
n: Union[int, int32, int64],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def plot(self, *args, **kwargs):
elif self.dim == 3:
fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
ax.scatter(
p = ax.scatter(
self.d[:, 0], self.d[:, 1], self.d[:, 2], c="b", marker="o", s=self.w
)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def mean_2dimD(self):
return mu

# jscpd:ignore-start
# pylint: disable=too-many-positional-arguments
def sample_metropolis_hastings(
self,
n: Union[int, int32, int64],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def neg_pdf(x):
result = minimize(neg_pdf, starting_point, method="L-BFGS-B")
return result.x

# pylint: disable=too-many-positional-arguments
def sample_metropolis_hastings(
self,
n: Union[int, int32, int64],
Expand Down
2 changes: 2 additions & 0 deletions pyrecest/distributions/nonperiodic/gaussian_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def pdf(self, xs):
xs = jnp.reshape(xs, (-1, 1))

pdfvals = multivariate_normal.pdf(xs, self.mu, self.C)
else:
raise NotImplementedError("Backend not supported")

return pdfvals

Expand Down
4 changes: 3 additions & 1 deletion pyrecest/evaluation/eot_shape_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def sample_on_boundary(self, num_points: int) -> np.ndarray:
lines = [self.boundary]
elif isinstance(self.boundary, MultiLineString):
lines = list(self.boundary)
else:
raise ValueError("Unsupported boundary type")

for i in range(num_points):
# Compute total perimeter
Expand Down Expand Up @@ -157,7 +159,7 @@ def __new__(cls, radius=1, arms=5, arm_width=0.3, center=(0, 0)):
class Cross(StarShapedPolygon): # pylint: disable=abstract-method
__slots__ = Polygon.__slots__

# pylint: disable=signature-differs
# pylint: disable=signature-differs,too-many-positional-arguments
def __new__(cls, height_1, height_2, width_1, width_2, centroid=None):
# Assertions to check conditions
assert width_1 > height_2, "width_1 has to be larger than height_2"
Expand Down
2 changes: 1 addition & 1 deletion pyrecest/evaluation/evaluate_for_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


# jscpd:ignore-start
# pylint: disable=R0913,R0914
# pylint: disable=R0913,R0914,too-many-positional-arguments
def evaluate_for_file(
input_file_name: str,
filter_configs: list[dict[str, Any]],
Expand Down
2 changes: 1 addition & 1 deletion pyrecest/evaluation/evaluate_for_simulation_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


# jscpd:ignore-start
# pylint: disable=R0913,R0914
# pylint: disable=R0913,R0914,too-many-positional-arguments
def evaluate_for_simulation_config(
simulation_config: str | dict[str, Any],
filter_configs: list[dict[str, Any]],
Expand Down
2 changes: 1 addition & 1 deletion pyrecest/evaluation/evaluate_for_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .iterate_configs_and_runs import iterate_configs_and_runs


# pylint: disable=R0913,R0914
# pylint: disable=R0913,R0914, too-many-positional-arguments
def evaluate_for_variables(
groundtruths,
measurements,
Expand Down
2 changes: 1 addition & 1 deletion pyrecest/evaluation/perform_predict_update_cycles.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .configure_for_filter import configure_for_filter


# pylint: disable=too-many-arguments,too-many-locals,too-many-branches
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-positional-arguments
def perform_predict_update_cycles(
scenario_config,
filter_config,
Expand Down
2 changes: 1 addition & 1 deletion pyrecest/evaluation/summarize_filter_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .get_extract_mean import get_extract_mean


# pylint: disable=too-many-arguments,too-many-locals
# pylint: disable=too-many-arguments,too-many-locals,too-many-positional-arguments
def summarize_filter_results(
scenario_config,
filter_configs,
Expand Down
2 changes: 1 addition & 1 deletion pyrecest/filters/gprhm_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def angle_between_two_vectors(x, y):

# pylint: disable=too-many-instance-attributes
class GPRHMTracker(AbstractExtendedObjectTracker):
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
def __init__(
self,
n_base_points,
Expand Down
2 changes: 1 addition & 1 deletion pyrecest/filters/random_matrix_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


class RandomMatrixTracker(AbstractExtendedObjectTracker):
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
def __init__(
self,
kinematic_state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class TestCircularFourierDistribution(unittest.TestCase):
pyrecest.backend.__name__ == "pyrecest.jax",
reason="Not supported on this backend",
)
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
def test_fourier_conversion(
self, transformation, dist_class, mu, param_range, coeffs
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from parameterized import parameterized

# pylint: disable=redefined-builtin,no-name-in-module,no-member
# pylint: disable=no-name-in-module,no-member
from pyrecest.backend import (
all,
allclose,
Expand Down Expand Up @@ -777,6 +776,8 @@ def test_basis_function_complex(self, name, coeff_mat, expected_func):
x, y, z, mode="inclination"
)
expected_func_vals = expected_func(phi, theta)
else:
raise ValueError("Unknown test case")

npt.assert_allclose(vals_to_test, expected_func_vals, atol=1e-6)

Expand Down
2 changes: 1 addition & 1 deletion pyrecest/tests/test_evaluation_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def test_iterate_configs_and_runs(self, filter_configs):
evaluation_config,
)

# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-positional-arguments
def _validate_eval_data(
self,
scenario_config,
Expand Down

0 comments on commit f349965

Please sign in to comment.