Skip to content

Commit

Permalink
flake8 & black
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjimenez committed Sep 25, 2021
1 parent aa6774c commit 9d055e9
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions test/test_gso.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ def calculate(x, y):
# Function peak coordinates
peak_coordinates = [[1.28, 0.0], [0.0, 1.58], [-0.46, -0.63]]

assert found_peaks(peak_coordinates, 2, gso.swarm.glowworms,
minimum_matches=2, tolerance=0.1)
assert found_peaks(
peak_coordinates, 2, gso.swarm.glowworms, minimum_matches=2, tolerance=0.1
)


def test_rastrigin():

class Rastrigin(ObjectiveFunction):
"""Rastrigin function"""

Expand All @@ -76,8 +76,8 @@ def __call__(self, coordinates):

@staticmethod
def calculate(x, y):
return (
20.0 + (x*x - 10.0*cos(2*pi*x) + y*y - 10.0*cos(2*pi*y))
return 20.0 + (
x * x - 10.0 * cos(2 * pi * x) + y * y - 10.0 * cos(2 * pi * y)
)

objective_function = Rastrigin()
Expand All @@ -98,10 +98,29 @@ def calculate(x, y):
gso.run(50)

# Function peak coordinates
peak_coordinates = [[0.5, 0.5], [1.0, 1.0], [1.5, 1.5], [2.0, 2.0], [2.5, 2.5],
[-0.5, -0.5], [-1.0, -1.0], [-1.5, -1.5], [-2.0, -2.0], [-2.5, -2.5],
[0.5, -0.5], [1.0, -1.0], [1.5, -1.5], [2.0, -2.0], [2.5, -2.5],
[-0.5, 0.5], [-1.0, 1.0], [-1.5, 1.5], [-2.0, 2.0], [-2.5, 2.5]]

assert found_peaks(peak_coordinates, 2, gso.swarm.glowworms,
minimum_matches=4, tolerance=0.1)
peak_coordinates = [
[0.5, 0.5],
[1.0, 1.0],
[1.5, 1.5],
[2.0, 2.0],
[2.5, 2.5],
[-0.5, -0.5],
[-1.0, -1.0],
[-1.5, -1.5],
[-2.0, -2.0],
[-2.5, -2.5],
[0.5, -0.5],
[1.0, -1.0],
[1.5, -1.5],
[2.0, -2.0],
[2.5, -2.5],
[-0.5, 0.5],
[-1.0, 1.0],
[-1.5, 1.5],
[-2.0, 2.0],
[-2.5, 2.5],
]

assert found_peaks(
peak_coordinates, 2, gso.swarm.glowworms, minimum_matches=4, tolerance=0.1
)

0 comments on commit 9d055e9

Please sign in to comment.