Skip to content
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
20 changes: 18 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
[flake8]
max-line-length = 132
ignore = E126, E127, E128, E129, E226, E241, E265, E741, F401, F403, F841, W504, W291
exclude = docs/,lm_combustion,radhydro

# E126: continuation line over-indented for hanging indent
# E127: continuation line over-indented for visual indent
# E128: continuation line under-indented for visual indent
# E129: visually indented line with same indent as next logical line
# E226: missing whitespace around arithmetic operator
# E241: multiple spaces after ','
# E265: block comment should start with '# '
# E741: do not use variables named 'I', 'O', or 'l'
# F403: 'from module import *' used; unable to detect undefined names
# F841: local variable assigned to but never used
# W504: line break after binary operator
ignore = E126, E127, E128, E129, E226, E241, E265, E741, F403, F841, W504

# F401: module imported but unused
per-file-ignores = __init__.py:F401

exclude = docs/
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ jobs:
run: pip install .

- name: Validate
run: pylint --errors-only pyro pyro/analysis
run: pylint --errors-only pyro pyro/analysis pyro/**/tests/*.py

2 changes: 1 addition & 1 deletion logo/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
XXX XXX X XX
X X
X X
"""
""" # noqa


class LogoGrid:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ defining-attr-methods = [
"__post_init__",
"initialize",
"__array_finalize__",
"setup_class", "setup_method", # for tests
]

[tool.pylint.FORMAT]
Expand Down
4 changes: 1 addition & 3 deletions pyro/advection/tests/test_advection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
from pyro.util import runparams


class TestSimulation(object):
class TestSimulation:
@classmethod
def setup_class(cls):
""" this is run once for each class before any tests """
pass

@classmethod
def teardown_class(cls):
""" this is run once for each class after all tests """
pass

def setup_method(self):
""" this is run before each test """
Expand Down
4 changes: 1 addition & 3 deletions pyro/advection_nonuniform/tests/test_advection_nonuniform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
from pyro.util import runparams


class TestSimulation(object):
class TestSimulation:
@classmethod
def setup_class(cls):
""" this is run once for each class before any tests """
pass

@classmethod
def teardown_class(cls):
""" this is run once for each class after all tests """
pass

def setup_method(self):
""" this is run before each test """
Expand Down
4 changes: 1 addition & 3 deletions pyro/compressible/tests/test_compressible.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
from pyro.util import runparams


class TestSimulation(object):
class TestSimulation:
@classmethod
def setup_class(cls):
""" this is run once for each class before any tests """
pass

@classmethod
def teardown_class(cls):
""" this is run once for each class after all tests """
pass

def setup_method(self):
""" this is run before each test """
Expand Down
2 changes: 1 addition & 1 deletion pyro/compressible/tests/test_eos.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pyro.compressible.eos as eos
from pyro.compressible import eos


def test_eos_consistency():
Expand Down
4 changes: 1 addition & 3 deletions pyro/compressible_rk/tests/test_compressible_rk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
from pyro.util import runparams


class TestSimulation(object):
class TestSimulation:
@classmethod
def setup_class(cls):
""" this is run once for each class before any tests """
pass

@classmethod
def teardown_class(cls):
""" this is run once for each class after all tests """
pass

def setup_method(self):
""" this is run before each test """
Expand Down
4 changes: 1 addition & 3 deletions pyro/compressible_sr/tests/test_compressible_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
from pyro.util import runparams


class TestSimulation(object):
class TestSimulation:
@classmethod
def setup_class(cls):
""" this is run once for each class before any tests """
pass

@classmethod
def teardown_class(cls):
""" this is run once for each class after all tests """
pass

def setup_method(self):
""" this is run before each test """
Expand Down
2 changes: 1 addition & 1 deletion pyro/compressible_sr/tests/test_eos_sr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pyro.compressible_sr.eos as eos
from pyro.compressible_sr import eos


def test_eos_consistency():
Expand Down
4 changes: 1 addition & 3 deletions pyro/diffusion/tests/test_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
from pyro.util import runparams


class TestSimulation(object):
class TestSimulation:

@classmethod
def setup_class(cls):
""" this is run once for each class before any tests """
pass

@classmethod
def teardown_class(cls):
""" this is run once for each class after all tests """
pass

def setup_method(self):
""" this is run before each test """
Expand Down
7 changes: 3 additions & 4 deletions pyro/incompressible/tests/convergence_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ def create_file(filename="convergence_errors.txt"):
# Parse all converge*.h5 outputs
# store the last file at each resolution
fnames = glob.glob("converge*.h5")
res = set([f.split("_")[1] for f in fnames])
res = list(res)
res.sort(key=int)
res = {f.split("_")[1] for f in fnames}
res = sorted(res, key=int)

simfiles = []
for r in res:
fnames = glob.glob(f"converge_{r}_*.h5")
last = max([int(f.split("_")[-1].split(".")[0]) for f in fnames])
last = max(int(f.split("_")[-1].split(".")[0]) for f in fnames)
simfiles.append(f"converge_{r}_{last:04d}.h5")

# Create the file
Expand Down
3 changes: 2 additions & 1 deletion pyro/mesh/tests/test_array_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
from numpy.testing import assert_array_equal

import pyro.mesh.array_indexer as ai
import pyro.mesh.patch as patch
from pyro.mesh import patch


# utilities
def test_buf_split():
# pylint: disable=protected-access
assert_array_equal(ai._buf_split(2), [2, 2, 2, 2])
assert_array_equal(ai._buf_split((2, 3)), [2, 3, 2, 3])

Expand Down
2 changes: 1 addition & 1 deletion pyro/mesh/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from numpy.testing import assert_array_equal

import pyro.mesh.boundary as bnd
import pyro.mesh.patch as patch
import pyro.util.io_pyro as io
from pyro.mesh import patch


def test_write_read():
Expand Down
10 changes: 3 additions & 7 deletions pyro/mesh/tests/test_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
from numpy.testing import assert_array_equal

import pyro.mesh.boundary as bnd
import pyro.mesh.patch as patch
from pyro.mesh import patch


# Grid2d tests
class TestGrid2d(object):
class TestGrid2d:
@classmethod
def setup_class(cls):
""" this is run once for each class before any tests """
pass

@classmethod
def teardown_class(cls):
""" this is run once for each class after all tests """
pass

def setup_method(self):
""" this is run before each test """
Expand Down Expand Up @@ -71,16 +69,14 @@ def test_equality(self):


# CellCenterData2d tests
class TestCellCenterData2d(object):
class TestCellCenterData2d:
@classmethod
def setup_class(cls):
""" this is run once for each class before any tests """
pass

@classmethod
def teardown_class(cls):
""" this is run once for each class after all tests """
pass

def setup_method(self):
""" this is run before each test """
Expand Down
5 changes: 2 additions & 3 deletions pyro/multigrid/tests/test_multigrid_comps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import numpy as np
from numpy.testing import assert_array_equal

import pyro.mesh.patch as patch
import pyro.multigrid.edge_coeffs as edge_coeffs
import pyro.multigrid.MG as MG
from pyro.mesh import patch
from pyro.multigrid import MG, edge_coeffs


# utilities
Expand Down
37 changes: 19 additions & 18 deletions pyro/particles/tests/test_particles.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np
from numpy.testing import assert_array_equal

import pyro.mesh.patch as patch
import pyro.particles.particles as particles
from pyro.mesh import patch
from pyro.particles import particles
from pyro.simulation_null import NullSimulation, bc_setup, grid_setup
from pyro.util import runparams

Expand All @@ -14,7 +14,7 @@ def test_particle():

n_particles = 5

for n in range(n_particles):
for _ in range(n_particles):
x, y = np.random.rand(2)
p = particles.Particle(x, y)

Expand Down Expand Up @@ -47,7 +47,6 @@ def setup_test(n_particles=50, extra_rp_params=None):
rp.params["mesh.ymin"] = 0
rp.params["mesh.ymax"] = 1
rp.params["particles.do_particles"] = 1
n_particles = n_particles

if extra_rp_params is not None:
for param, value in extra_rp_params.items():
Expand Down Expand Up @@ -77,15 +76,16 @@ def test_particles_random_gen():
np.random.seed(3287469)

ps = particles.Particles(myd, bc, n_particles, "random")
positions = set([(p.x, p.y) for p in ps.particles.values()])
positions = {(p.x, p.y) for p in ps.particles.values()}

assert len(ps.particles) == n_particles, "There should be {} particles".format(n_particles)

# reseed random number generator
np.random.seed(3287469)

correct_positions = np.random.rand(n_particles, 2)
correct_positions = set([(x, y) for (x, y) in correct_positions])
# pylint: disable-next=unnecessary-comprehension # needed to convert ndarray to tuples
correct_positions = {(x, y) for (x, y) in correct_positions}

assert positions == correct_positions, "sets are not the same"

Expand All @@ -101,12 +101,12 @@ def test_particles_grid_gen():

assert len(ps.particles) == 49, "There should be 49 particles"

positions = set([(p.x, p.y) for p in ps.particles.values()])
positions = {(p.x, p.y) for p in ps.particles.values()}

xs, step = np.linspace(0, 1, num=7, endpoint=False, retstep=True)
xs += 0.5 * step

correct_positions = set([(x, y) for x in xs for y in xs])
correct_positions = {(x, y) for x in xs for y in xs}

assert positions == correct_positions, "sets are not the same"

Expand All @@ -124,9 +124,10 @@ def test_particles_array_gen():
ps = particles.Particles(myd, bc, n_particles,
"array", pos_array=init_positions)

positions = set([(p.x, p.y) for p in ps.particles.values()])
positions = {(p.x, p.y) for p in ps.particles.values()}

correct_positions = set([(x, y) for (x, y) in init_positions])
# pylint: disable-next=unnecessary-comprehension # needed to convert ndarray to tuples
correct_positions = {(x, y) for (x, y) in init_positions}

assert positions == correct_positions, "sets are not the same"

Expand All @@ -153,12 +154,12 @@ def test_particles_advect():

ps.update_particles(1, u, v)

positions = set([(p.x, p.y) for p in ps.particles.values()])
positions = {(p.x, p.y) for p in ps.particles.values()}

xs, step = np.linspace(0, 1, num=7, endpoint=False, retstep=True)
xs += 0.5 * step

correct_positions = set([(x, y) for x in xs for y in xs])
correct_positions = {(x, y) for x in xs for y in xs}

assert positions == correct_positions, "sets are not the same"

Expand All @@ -167,9 +168,9 @@ def test_particles_advect():

ps.update_particles(0.1, u, v)

positions = set([(p.x, p.y) for p in ps.particles.values()])
positions = {(p.x, p.y) for p in ps.particles.values()}

correct_positions = set([((x+0.1) % 1, y) for x in xs for y in xs])
correct_positions = {((x+0.1) % 1, y) for x in xs for y in xs}

assert positions == correct_positions, "sets are not the same"

Expand All @@ -180,9 +181,9 @@ def test_particles_advect():
ps = particles.Particles(myd, bc, n_particles, "grid")
ps.update_particles(0.1, u, v)

positions = set([(p.x, p.y) for p in ps.particles.values()])
positions = {(p.x, p.y) for p in ps.particles.values()}

correct_positions = set([(x, (y+0.1) % 1) for x in xs for y in xs])
correct_positions = {(x, (y+0.1) % 1) for x in xs for y in xs}

assert positions == correct_positions, "sets are not the same"

Expand All @@ -192,9 +193,9 @@ def test_particles_advect():
ps = particles.Particles(myd, bc, n_particles, "grid")
ps.update_particles(0.1, u, v)

positions = set([(p.x, p.y) for p in ps.particles.values()])
positions = {(p.x, p.y) for p in ps.particles.values()}

correct_positions = set([((x+0.1) % 1, (y+0.1) % 1) for x in xs for y in xs])
correct_positions = {((x+0.1) % 1, (y+0.1) % 1) for x in xs for y in xs}

assert positions == correct_positions, "sets are not the same"

Expand Down
Loading