diff --git a/examples/autoIgnition.py b/examples/autoIgnition.py index da773411..de86a3d7 100755 --- a/examples/autoIgnition.py +++ b/examples/autoIgnition.py @@ -5,7 +5,7 @@ """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 import peregrinepy as pg import cantera as ct import matplotlib.pyplot as plt diff --git a/examples/coProcess.py b/examples/coProcess.py index e997a250..79b919ac 100755 --- a/examples/coProcess.py +++ b/examples/coProcess.py @@ -5,7 +5,7 @@ """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 import peregrinepy as pg import numpy as np diff --git a/examples/couetteFlow.py b/examples/couetteFlow.py index cf6250e5..1a6b632a 100755 --- a/examples/couetteFlow.py +++ b/examples/couetteFlow.py @@ -5,7 +5,7 @@ """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 import peregrinepy as pg import numpy as np diff --git a/examples/detonationProfile.py b/examples/detonationProfile.py index 20559812..b5b5b29b 100755 --- a/examples/detonationProfile.py +++ b/examples/detonationProfile.py @@ -6,7 +6,7 @@ """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 from pathlib import Path import cantera as ct diff --git a/examples/normalShock.py b/examples/normalShock.py index 7604133a..39f674b6 100755 --- a/examples/normalShock.py +++ b/examples/normalShock.py @@ -6,7 +6,7 @@ """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 import matplotlib.pyplot as plt diff --git a/examples/oneDAdvection.py b/examples/oneDAdvection.py index 3014a816..669dafff 100755 --- a/examples/oneDAdvection.py +++ b/examples/oneDAdvection.py @@ -11,7 +11,7 @@ """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 import peregrinepy as pg import numpy as np diff --git a/examples/oneDDiffusion.py b/examples/oneDDiffusion.py index 115407f9..0c0e903b 100755 --- a/examples/oneDDiffusion.py +++ b/examples/oneDDiffusion.py @@ -5,7 +5,7 @@ """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 import peregrinepy as pg import numpy as np diff --git a/examples/realGasProperties.py b/examples/realGasProperties.py index c88f6151..7b279a3b 100755 --- a/examples/realGasProperties.py +++ b/examples/realGasProperties.py @@ -5,7 +5,7 @@ """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 import peregrinepy as pg import numpy as np import matplotlib.pyplot as plt diff --git a/examples/shockCapture.py b/examples/shockCapture.py index 78156d06..5fc95a06 100755 --- a/examples/shockCapture.py +++ b/examples/shockCapture.py @@ -15,7 +15,7 @@ for more. """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 import peregrinepy as pg import numpy as np diff --git a/examples/threeDTaylorGreen.py b/examples/threeDTaylorGreen.py index b297a25e..5973dfa2 100755 --- a/examples/threeDTaylorGreen.py +++ b/examples/threeDTaylorGreen.py @@ -11,7 +11,7 @@ """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 import peregrinepy as pg import numpy as np diff --git a/examples/threeDTaylorGreenSkewed.py b/examples/threeDTaylorGreenSkewed.py index 5b36635b..9af2dbe7 100755 --- a/examples/threeDTaylorGreenSkewed.py +++ b/examples/threeDTaylorGreenSkewed.py @@ -17,7 +17,7 @@ """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 import peregrinepy as pg import numpy as np diff --git a/examples/twoDEulerVortex.py b/examples/twoDEulerVortex.py index f5ef8328..d9cf2f67 100755 --- a/examples/twoDEulerVortex.py +++ b/examples/twoDEulerVortex.py @@ -11,7 +11,7 @@ """ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 import peregrinepy as pg import numpy as np from time import perf_counter @@ -91,9 +91,7 @@ def simulate(): r = np.sqrt(((xc - x0) ** 2 + (yc - y0) ** 2) / Rc**2) # u - blk.array["q"][:, :, :, 1] = uInf - (C0 * (yc - y0) / Rc**2) * np.exp( - -(r**2) / 2.0 - ) + blk.array["q"][:, :, :, 1] = uInf - (C0 * (yc - y0) / Rc**2) * np.exp(-(r**2) / 2.0) # v blk.array["q"][:, :, :, 2] = (C0 * (xc - x0) / Rc**2) * np.exp(-(r**2) / 2.0) diff --git a/runPeregrine.py b/runPeregrine.py index 6d37e887..2f823532 100755 --- a/runPeregrine.py +++ b/runPeregrine.py @@ -1,6 +1,6 @@ #!/usr/bin/env -S python -m mpi4py import sys -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 from time import perf_counter import numpy as np diff --git a/src/peregrinepy/__init__.py b/src/peregrinepy/__init__.py index 8362c8d1..85302f25 100644 --- a/src/peregrinepy/__init__.py +++ b/src/peregrinepy/__init__.py @@ -1,28 +1,47 @@ -from ast import Import +# For pytests to work, we cannot not initialize here +# since each test needs to initialize and finalize each +# time. Also for scripting, we dont need MPI. +# +# So for running real cases, we initialize in runPeregrine +# which I think makes more sense anyway. import mpi4py.rc mpi4py.rc.initialize = False -from ._version import __version__ -from . import grid -from . import writers -from . import readers - -from . import multiBlock - -from .bootstrapCase import bootstrapCase -from .consistify import consistify -from .RHS import RHS -from . import bcs -from . import thermoTransport - -from . import coproc - -from . import interpolation - -from . import files - -try: - from . import compute -except ImportError: - pass +from ._version import __version__ # noqa: E402 +from . import grid # noqa: E402 +from . import writers # noqa: E402 +from . import readers # noqa: E402 + +from . import multiBlock # noqa: E402 + +from .bootstrapCase import bootstrapCase # noqa: E402 +from .consistify import consistify # noqa: E402 +from .RHS import RHS # noqa: E402 +from . import bcs # noqa: E402 +from . import thermoTransport # noqa: E402 + +from . import coproc # noqa: E402 + +from . import interpolation # noqa: E402 + +from . import files # noqa: E402 + +from . import compute # noqa: E402 + +__all__ = [ + "__version__", + "grid", + "writers", + "readers", + "multiBlock", + "bootstrapCase", + "consistify", + "RHS", + "bcs", + "thermoTransport", + "coproc", + "interpolation", + "files", + "compute", +] diff --git a/src/peregrinepy/bcs/__init__.py b/src/peregrinepy/bcs/__init__.py index bb9543a0..e4434274 100644 --- a/src/peregrinepy/bcs/__init__.py +++ b/src/peregrinepy/bcs/__init__.py @@ -1,3 +1,5 @@ from . import prepInlets from . import prepExits from . import prepWalls + +__all__ = ["prepInlets", "prepExits", "prepWalls"] diff --git a/src/peregrinepy/coproc/__init__.py b/src/peregrinepy/coproc/__init__.py index ce346c62..1f5730c0 100644 --- a/src/peregrinepy/coproc/__init__.py +++ b/src/peregrinepy/coproc/__init__.py @@ -1 +1,3 @@ from .pgCoprocessor import coprocessor + +__all__ = ["coprocessor"] diff --git a/src/peregrinepy/files/__init__.py b/src/peregrinepy/files/__init__.py index 68885d13..4d88a74c 100644 --- a/src/peregrinepy/files/__init__.py +++ b/src/peregrinepy/files/__init__.py @@ -1 +1,3 @@ from .configFile import configFile + +__all__ = ["configFile"] diff --git a/src/peregrinepy/grid/__init__.py b/src/peregrinepy/grid/__init__.py index f7321163..6ac1b236 100644 --- a/src/peregrinepy/grid/__init__.py +++ b/src/peregrinepy/grid/__init__.py @@ -2,3 +2,5 @@ from .generateHalo import generateHalo from .metrics import metrics from .unifySolverGrid import unifySolverGrid + +__all__ = ["create", "generateHalo", "metrics", "unifySolverGrid"] diff --git a/src/peregrinepy/integrators/dualTime.py b/src/peregrinepy/integrators/dualTime.py index 226716c5..47d708ac 100644 --- a/src/peregrinepy/integrators/dualTime.py +++ b/src/peregrinepy/integrators/dualTime.py @@ -1,7 +1,7 @@ from abc import ABCMeta import numpy as np -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 from ..compute.timeIntegration import ( DTrk3s1, diff --git a/src/peregrinepy/integrators/rk2.py b/src/peregrinepy/integrators/rk2.py index 2e9b6f17..9924f99a 100644 --- a/src/peregrinepy/integrators/rk2.py +++ b/src/peregrinepy/integrators/rk2.py @@ -1,7 +1,6 @@ from abc import ABCMeta from ..RHS import RHS from ..consistify import consistify -from ..compute.utils import AEQB from ..compute.timeIntegration import rk2s1, rk2s2 diff --git a/src/peregrinepy/integrators/rk3.py b/src/peregrinepy/integrators/rk3.py index 56031077..91fb7a26 100644 --- a/src/peregrinepy/integrators/rk3.py +++ b/src/peregrinepy/integrators/rk3.py @@ -1,7 +1,6 @@ from abc import ABCMeta from ..RHS import RHS from ..consistify import consistify -from ..compute.utils import AEQB from ..compute.timeIntegration import rk3s1, rk3s2, rk3s3 diff --git a/src/peregrinepy/integrators/rk34.py b/src/peregrinepy/integrators/rk34.py index b19a52e6..471f56e3 100644 --- a/src/peregrinepy/integrators/rk34.py +++ b/src/peregrinepy/integrators/rk34.py @@ -1,7 +1,6 @@ from abc import ABCMeta from ..RHS import RHS from ..consistify import consistify -from ..compute.utils import AEQB from ..compute.timeIntegration import rk34s1, rk34s2, rk34s3, rk34s4 diff --git a/src/peregrinepy/integrators/rk4.py b/src/peregrinepy/integrators/rk4.py index d63398c8..ce75441e 100644 --- a/src/peregrinepy/integrators/rk4.py +++ b/src/peregrinepy/integrators/rk4.py @@ -1,7 +1,6 @@ from abc import ABCMeta from ..RHS import RHS from ..consistify import consistify -from ..compute.utils import AEQB from ..compute.timeIntegration import rk4s1, rk4s2, rk4s3, rk4s4 diff --git a/src/peregrinepy/integrators/strang.py b/src/peregrinepy/integrators/strang.py index 8fc9289b..b1653ee4 100644 --- a/src/peregrinepy/integrators/strang.py +++ b/src/peregrinepy/integrators/strang.py @@ -3,7 +3,6 @@ from ..consistify import consistify from scipy.integrate import ode from itertools import product -from ..compute.utils import AEQB from ..compute.timeIntegration import rk3s1, rk3s2, rk3s3 diff --git a/src/peregrinepy/interpolation/__init__.py b/src/peregrinepy/interpolation/__init__.py index 4ed6adaf..ca39a687 100644 --- a/src/peregrinepy/interpolation/__init__.py +++ b/src/peregrinepy/interpolation/__init__.py @@ -1,2 +1,4 @@ from . import bounds from .blocksToBlock import blocksToBlock + +__all__ = ["bounds", "blocksToBlock"] diff --git a/src/peregrinepy/misc/__init__.py b/src/peregrinepy/misc/__init__.py index e3e81605..5d3f85d4 100644 --- a/src/peregrinepy/misc/__init__.py +++ b/src/peregrinepy/misc/__init__.py @@ -2,3 +2,5 @@ from .progressBar import progressBar from .null import null from .createViewMirrorArray import createViewMirrorArray + +__all__ = ["frozenDict", "progressBar", "null", "createViewMirrorArray"] diff --git a/src/peregrinepy/misc/createViewMirrorArray.py b/src/peregrinepy/misc/createViewMirrorArray.py index 02c89093..228557de 100644 --- a/src/peregrinepy/misc/createViewMirrorArray.py +++ b/src/peregrinepy/misc/createViewMirrorArray.py @@ -23,7 +23,7 @@ def createViewMirrorArray(obj, names, shape): """ - if type(names) != list: + if not isinstance(names, list): names = [names] view = getattr(pgkokkos, f"view{len(shape)}") diff --git a/src/peregrinepy/mpiComm/__init__.py b/src/peregrinepy/mpiComm/__init__.py index 569232e7..04d72b5c 100644 --- a/src/peregrinepy/mpiComm/__init__.py +++ b/src/peregrinepy/mpiComm/__init__.py @@ -1,2 +1,4 @@ from . import mpiUtils from .communicate import communicate + +__all__ = ["mpiUtils", "communicate"] diff --git a/src/peregrinepy/mpiComm/communicate.py b/src/peregrinepy/mpiComm/communicate.py index f1ded0f6..584fc3ce 100644 --- a/src/peregrinepy/mpiComm/communicate.py +++ b/src/peregrinepy/mpiComm/communicate.py @@ -5,7 +5,7 @@ def communicate(mb, varis): - if type(varis) is not list: + if not isinstance(varis, list): varis = [varis] comm, rank, size = getCommRankSize() @@ -41,7 +41,7 @@ def communicate(mb, varis): sliceS = face.nodeSendSlices # Get the indices of the send slices from the numpy slice object - sliceIndxs = [s for f in sliceS for s in f if type(s) is int] + sliceIndxs = [s for f in sliceS for s in f if isinstance(s, int)] # populate the temp recv array with the unoriented send data, since its # the correct size and shape extractSendBuffer( @@ -74,7 +74,7 @@ def communicate(mb, varis): # Push back up the device face.updateDeviceView(recvName) # Get the indices of the recv slices from the numpy slice object - sliceIndxs = [s for f in sliceR for s in f if type(s) is int] + sliceIndxs = [s for f in sliceR for s in f if isinstance(s, int)] # Place the recv in the view placeRecvBuffer( getattr(blk, var), getattr(face, recvName), face, sliceIndxs diff --git a/src/peregrinepy/mpiComm/mpiUtils.py b/src/peregrinepy/mpiComm/mpiUtils.py index 7cc305d2..272ab41b 100644 --- a/src/peregrinepy/mpiComm/mpiUtils.py +++ b/src/peregrinepy/mpiComm/mpiUtils.py @@ -1,4 +1,4 @@ -from mpi4py import MPI +from mpi4py import MPI # noqa: F401 from ..compute.utils import CFLmax, checkNan import numpy as np diff --git a/src/peregrinepy/multiBlock/__init__.py b/src/peregrinepy/multiBlock/__init__.py index 4b2f3b70..b720a8ed 100644 --- a/src/peregrinepy/multiBlock/__init__.py +++ b/src/peregrinepy/multiBlock/__init__.py @@ -1,6 +1,3 @@ -from .topology import topology -from .grid import grid -from .restart import restart from .solver import solver from ..integrators import getIntegrator @@ -111,7 +108,7 @@ def setRHS(cls, config): # spatial derivatives, subgrid mode, diffusive fluxes if config["RHS"]["diffusion"]: - cls.dqdxyz = getattr(compute.utils, f"dq2FD") + cls.dqdxyz = getattr(compute.utils, "dq2FD") # Subgrid models if config["RHS"]["subgrid"] is not None: diff --git a/src/peregrinepy/multiBlock/solver.py b/src/peregrinepy/multiBlock/solver.py index 71abb5be..d0d4ecfe 100644 --- a/src/peregrinepy/multiBlock/solver.py +++ b/src/peregrinepy/multiBlock/solver.py @@ -27,7 +27,7 @@ class solver(restart): mbType = "solver" def __init__(self, nblks, spNames, ng): - assert type(spNames) is list, f"spNames must me a list not {type(spNames)}" + assert isinstance(spNames, list), f"spNames must me a list not {type(spNames)}" temp = [solverBlock(i, spNames, ng) for i in range(nblks)] super().__init__(nblks, spNames, temp) diff --git a/src/peregrinepy/multiBlock/solverBlock.py b/src/peregrinepy/multiBlock/solverBlock.py index 12e9bee6..599261df 100644 --- a/src/peregrinepy/multiBlock/solverBlock.py +++ b/src/peregrinepy/multiBlock/solverBlock.py @@ -244,13 +244,13 @@ def setBlockCommunication(self): face._setCommBuffers(self.ni, self.nj, self.nk, self.ne, self.nblki) def updateDeviceView(self, vars): - if type(vars) == str: + if isinstance(vars, str): vars = [vars] for var in vars: deep_copy(getattr(self, var), self.mirror[var]) def updateHostView(self, vars): - if type(vars) == str: + if isinstance(vars, str): vars = [vars] for var in vars: deep_copy(self.mirror[var], getattr(self, var)) diff --git a/src/peregrinepy/multiBlock/solverFace.py b/src/peregrinepy/multiBlock/solverFace.py index b8cc9b1a..c039a95c 100644 --- a/src/peregrinepy/multiBlock/solverFace.py +++ b/src/peregrinepy/multiBlock/solverFace.py @@ -381,13 +381,13 @@ def ng(self): return self._ng def updateDeviceView(self, vars): - if type(vars) == str: + if isinstance(vars, str): vars = [vars] for var in vars: deep_copy(getattr(self, var), self.mirror[var]) def updateHostView(self, vars): - if type(vars) == str: + if isinstance(vars, str): vars = [vars] for var in vars: deep_copy(self.mirror[var], getattr(self, var)) diff --git a/src/peregrinepy/multiBlock/topologyFace.py b/src/peregrinepy/multiBlock/topologyFace.py index 3ff7023c..164a0055 100644 --- a/src/peregrinepy/multiBlock/topologyFace.py +++ b/src/peregrinepy/multiBlock/topologyFace.py @@ -22,7 +22,7 @@ def nface(self): @nface.setter def nface(self, value): - assert type(value) is int, f"nface must be an integer not {type(value)}" + assert isinstance(value, int), f"nface must be an integer not {type(value)}" assert 1 <= value <= 6, "nface must be between (1,6)" self._nface = value diff --git a/src/peregrinepy/readers/readBlocksForProcs.py b/src/peregrinepy/readers/readBlocksForProcs.py index 4c9af472..7a3a5f09 100644 --- a/src/peregrinepy/readers/readBlocksForProcs.py +++ b/src/peregrinepy/readers/readBlocksForProcs.py @@ -11,7 +11,7 @@ def readBlocksForProcs(pathToFile="./Input", parallel=False): except FileNotFoundError: return None else: - from mpi4py import MPI + from mpi4py import MPI # noqa: F401 from ..mpiComm.mpiUtils import getCommRankSize try: diff --git a/src/peregrinepy/readers/readConfigFile.py b/src/peregrinepy/readers/readConfigFile.py index 3f83a65e..d5e6d3e8 100644 --- a/src/peregrinepy/readers/readConfigFile.py +++ b/src/peregrinepy/readers/readConfigFile.py @@ -8,7 +8,7 @@ def readConfigFile(filePath="./peregrine.yaml", parallel=False): with open(filePath, "r") as connFile: connIn = yaml.load(connFile, Loader=yaml.FullLoader) else: - from mpi4py import MPI + from mpi4py import MPI # noqa: F401 from ..mpiComm.mpiUtils import getCommRankSize comm, rank, size = getCommRankSize() diff --git a/tests/conftest.py b/tests/conftest.py index 671cfde4..25e5cd2b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,7 +6,7 @@ mpi4py.rc.finalize = False mpi4py.rc.initialize = False -from mpi4py import MPI +from mpi4py import MPI # noqa: E402 @pytest.fixture(scope="session")