Skip to content

Commit

Permalink
Fix "Run flake8" step failure
Browse files Browse the repository at this point in the history
Issues detected by flake8:
4     E275 missing whitespace after keyword
1     E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
6     F401 'random' imported but unused
5     F841 local variable 'biv2' is assigned to but never used
  • Loading branch information
trundev committed Nov 19, 2024
1 parent da9084e commit 1480e16
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion clifford/_conformal_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def up(self, x: MultiVector) -> MultiVector:
new_val = np.zeros(self.gaDims)
new_val[:len(old_val)] = old_val
x = self.MultiVector(value=new_val)
except(AttributeError):
except (AttributeError):
# if x is a scalar it doesnt have layout but following
# will still work
pass
Expand Down
2 changes: 1 addition & 1 deletion clifford/cga.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def __init__(self, cga, *args) -> None:
arg = float(arg)

if arg < 0:
raise(ValueError('dilation should be positive'))
raise (ValueError('dilation should be positive'))

mv = e**((-log(arg)/2.)*(self.cga.E0))

Expand Down
6 changes: 3 additions & 3 deletions clifford/test/test_clifford.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def test_2d_mv_array(self, g3, rng): # noqa: F811
# check properties of the array are preserved (no need to check both a and b)
np.testing.assert_array_equal(mv_array_a.value, value_array_a)
assert mv_array_a.value.dtype == value_array_a.dtype
assert type(mv_array_a.value) == type(value_array_a)
assert type(mv_array_a.value) is type(value_array_a)

# Check addition
mv_array_sum = mv_array_a + mv_array_b
Expand Down Expand Up @@ -806,9 +806,9 @@ def check_inv(self, A):
for m, a in enumerate(A):
for n, b in enumerate(A.inv):
if m == n:
assert(a | b == 1)
assert (a | b == 1)
else:
assert(a | b == 0)
assert (a | b == 0)

@pytest.mark.parametrize(('p', 'q'), [
(2, 0), (3, 0), (4, 0)
Expand Down
17 changes: 6 additions & 11 deletions clifford/test/test_g3c_tools.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import random
from functools import reduce
import time
import functools


import numpy as np
import numpy.testing as npt
from numpy import exp
import pytest
import numba

from clifford import Cl
from clifford.g3c import *
from clifford.tools.g3c import *
from clifford.tools.g3c.rotor_parameterisation import ga_log, ga_exp, general_logarithm, \
interpolate_rotors
from clifford.tools.g3c.rotor_parameterisation import ga_log, general_logarithm
from clifford.tools.g3c.rotor_estimation import *
from clifford.tools.g3c.object_clustering import *
from clifford.tools.g3c.scene_simplification import *
Expand Down Expand Up @@ -175,7 +170,7 @@ def test_general_logarithm_TRS(self, rng): # noqa: F811
V = (T * R * S).normal()
biv = general_logarithm(V)
V_rebuilt = biv.exp().normal()
biv2 = general_logarithm(V)
_ = general_logarithm(V)

C1 = random_point_pair(rng=rng)
C2 = (V * C1 * ~V).normal()
Expand Down Expand Up @@ -381,8 +376,8 @@ def test_closest_furthest_circle_points(self, rng): # noqa: F811
for _ in range(100):
C1 = random_circle(rng=rng)
C2 = random_circle(rng=rng)
pclose = iterative_closest_points_on_circles(C1, C2)
pfar = iterative_furthest_points_on_circles(C1, C2)
_ = iterative_closest_points_on_circles(C1, C2)
_ = iterative_furthest_points_on_circles(C1, C2)

def test_closest_points_circle_line(self, rng): # noqa: F811
"""
Expand Down Expand Up @@ -740,7 +735,7 @@ def test_rotor_between_non_overlapping_spheres(self, rng): # noqa: F811
rad = get_radius_from_sphere(C1)
t_r = generate_translation_rotor(2.5*rad*e1)
C2 = (t_r * C1 * ~t_r)(4).normal()
rad2 = get_radius_from_sphere(C2)
_ = get_radius_from_sphere(C2)
R = rotor_between_objects(C1, C2)
C3 = (R * C1 * ~R).normal()
if sum(np.abs((C2 + C3).value)) < 0.0001:
Expand Down Expand Up @@ -1021,7 +1016,7 @@ def test_assign_objects_to_objects(self, obj_gen, rng): # noqa: F811

n_repeats = 5
for i in range(n_repeats):
r = random_rotation_translation_rotor(0.001, np.pi / 32, rng=rng)
_ = random_rotation_translation_rotor(0.001, np.pi / 32, rng=rng)
object_set_a = [obj_gen(rng=rng) for i in range(20)]
object_set_b = [l for l in object_set_a]
label_a, costs_a = assign_measurements_to_objects_matrix(object_set_a, object_set_b)
Expand Down

0 comments on commit 1480e16

Please sign in to comment.