Skip to content

Commit

Permalink
Ruff conforming entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
kaschau committed Apr 5, 2024
1 parent c1ec20c commit af5a8dd
Show file tree
Hide file tree
Showing 38 changed files with 87 additions and 64 deletions.
2 changes: 1 addition & 1 deletion examples/autoIgnition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/coProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from mpi4py import MPI
from mpi4py import MPI # noqa: F401

import peregrinepy as pg
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion examples/couetteFlow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from mpi4py import MPI
from mpi4py import MPI # noqa: F401

import peregrinepy as pg
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion examples/detonationProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

from mpi4py import MPI
from mpi4py import MPI # noqa: F401
from pathlib import Path

import cantera as ct
Expand Down
2 changes: 1 addition & 1 deletion examples/normalShock.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

from mpi4py import MPI
from mpi4py import MPI # noqa: F401


import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion examples/oneDAdvection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

from mpi4py import MPI
from mpi4py import MPI # noqa: F401

import peregrinepy as pg
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion examples/oneDDiffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from mpi4py import MPI
from mpi4py import MPI # noqa: F401

import peregrinepy as pg
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion examples/realGasProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/shockCapture.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
for more.
"""

from mpi4py import MPI
from mpi4py import MPI # noqa: F401

import peregrinepy as pg
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion examples/threeDTaylorGreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

from mpi4py import MPI
from mpi4py import MPI # noqa: F401

import peregrinepy as pg
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion examples/threeDTaylorGreenSkewed.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""

from mpi4py import MPI
from mpi4py import MPI # noqa: F401

import peregrinepy as pg
import numpy as np
Expand Down
6 changes: 2 additions & 4 deletions examples/twoDEulerVortex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion runPeregrine.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
67 changes: 43 additions & 24 deletions src/peregrinepy/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
2 changes: 2 additions & 0 deletions src/peregrinepy/bcs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from . import prepInlets
from . import prepExits
from . import prepWalls

__all__ = ["prepInlets", "prepExits", "prepWalls"]
2 changes: 2 additions & 0 deletions src/peregrinepy/coproc/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .pgCoprocessor import coprocessor

__all__ = ["coprocessor"]
2 changes: 2 additions & 0 deletions src/peregrinepy/files/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .configFile import configFile

__all__ = ["configFile"]
2 changes: 2 additions & 0 deletions src/peregrinepy/grid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
from .generateHalo import generateHalo
from .metrics import metrics
from .unifySolverGrid import unifySolverGrid

__all__ = ["create", "generateHalo", "metrics", "unifySolverGrid"]
2 changes: 1 addition & 1 deletion src/peregrinepy/integrators/dualTime.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/peregrinepy/integrators/rk2.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
1 change: 0 additions & 1 deletion src/peregrinepy/integrators/rk3.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
1 change: 0 additions & 1 deletion src/peregrinepy/integrators/rk34.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
1 change: 0 additions & 1 deletion src/peregrinepy/integrators/rk4.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
1 change: 0 additions & 1 deletion src/peregrinepy/integrators/strang.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 2 additions & 0 deletions src/peregrinepy/interpolation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from . import bounds
from .blocksToBlock import blocksToBlock

__all__ = ["bounds", "blocksToBlock"]
2 changes: 2 additions & 0 deletions src/peregrinepy/misc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
from .progressBar import progressBar
from .null import null
from .createViewMirrorArray import createViewMirrorArray

__all__ = ["frozenDict", "progressBar", "null", "createViewMirrorArray"]
2 changes: 1 addition & 1 deletion src/peregrinepy/misc/createViewMirrorArray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}")
Expand Down
2 changes: 2 additions & 0 deletions src/peregrinepy/mpiComm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from . import mpiUtils
from .communicate import communicate

__all__ = ["mpiUtils", "communicate"]
6 changes: 3 additions & 3 deletions src/peregrinepy/mpiComm/communicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/peregrinepy/mpiComm/mpiUtils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mpi4py import MPI
from mpi4py import MPI # noqa: F401
from ..compute.utils import CFLmax, checkNan
import numpy as np

Expand Down
5 changes: 1 addition & 4 deletions src/peregrinepy/multiBlock/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from .topology import topology
from .grid import grid
from .restart import restart
from .solver import solver

from ..integrators import getIntegrator
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/peregrinepy/multiBlock/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/peregrinepy/multiBlock/solverBlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
4 changes: 2 additions & 2 deletions src/peregrinepy/multiBlock/solverFace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/peregrinepy/multiBlock/topologyFace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit af5a8dd

Please sign in to comment.