Skip to content

Commit

Permalink
Fix pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
s9latimm committed Oct 20, 2024
1 parent 8dbb275 commit 0d95c9d
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 25 deletions.
8 changes: 4 additions & 4 deletions src/base/model/algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def load(path: Path) -> Real:
if path.exists():
value = path.read_text(encoding='utf-8').strip()
return Real(float(value))
else:
logging.error(f'{path} does not exist')
logging.error(f'{path} does not exist')
raise FileNotFoundError


class Integer:
Expand All @@ -103,5 +103,5 @@ def load(path: Path) -> Integer:
if path.exists():
value = path.read_text(encoding='utf-8').strip()
return Integer(int(value))
else:
logging.error(f'{path} does not exist')
logging.error(f'{path} does not exist')
raise FileNotFoundError
7 changes: 6 additions & 1 deletion src/base/model/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def arrange(start: float, stop: float, step: float, center=False) -> list[float]
start = start + step / 2
stop = stop - step / 2

if not step > 0:
if step <= 0:
return []

r = []
Expand All @@ -50,6 +50,7 @@ def __init__(self, x: float | Real, y: float | Real) -> None:
self.__y = Real(float(y))

def __eq__(self, coordinate: tuple[float, float] | Coordinate) -> bool:
# pylint: disable=protected-access
c = Coordinate(*coordinate)
return self.__x == c.__x and self.__y == c.__y

Expand All @@ -66,17 +67,20 @@ def __str__(self) -> str:
return self.__repr__()

def __add__(self, coordinate: tuple[float, float] | Coordinate) -> Coordinate:
# pylint: disable=protected-access
c = Coordinate(*coordinate)
return Coordinate(self.__x + c.__x, self.__y + c.__y)

def __radd__(self, coordinate: tuple[float, float] | Coordinate) -> Coordinate:
return self.__add__(coordinate)

def __sub__(self, coordinate: tuple[float, float] | Coordinate) -> Coordinate:
# pylint: disable=protected-access
c = Coordinate(*coordinate)
return Coordinate(self.__x - c.__x, self.__y - c.__y)

def __rsub__(self, coordinate: tuple[float, float] | Coordinate) -> Coordinate:
# pylint: disable=protected-access
c = Coordinate(*coordinate)
return Coordinate(c.__x - self.__x, c.__y - self.__y)

Expand All @@ -92,6 +96,7 @@ def __truediv__(self, factor: float) -> Coordinate:
return Coordinate(self.__x / factor, self.__y / factor)

def distance(self, coordinate: tuple[float, float] | Coordinate) -> float:
# pylint: disable=protected-access
c = Coordinate(*coordinate)
return np.sqrt(float(self.__x - c.__x)**2 + float(self.__y - c.__y)**2)

Expand Down
5 changes: 2 additions & 3 deletions src/nse/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ def main(
logging.info(model)
logging.info(f'PARAMETERS: {len(model)}')

if grade:
logging.info('PLOT: Setup')
plot_setup(experiment, identifier)
logging.info('PLOT: Setup')
plot_setup(experiment, identifier)

timer = Stopwatch()
if n > 0:
Expand Down
1 change: 0 additions & 1 deletion src/nse/model/experiments/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(
foam,
)

step = .1
stride = step / 2

# inlet
Expand Down
1 change: 0 additions & 1 deletion src/nse/model/experiments/empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(
foam,
)

step = step
stride = step / 2

# inlet
Expand Down
17 changes: 9 additions & 8 deletions src/nse/model/experiments/foam.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,25 @@ def __dir(path: Path) -> int | None:
def main():
step = .1
nu = 0.01
inlet = 1

name = f'step-{step:.3f}-{nu:.3f}-{inlet:.3f}'.replace('.', '_')
flow = 1

m = Grid(Axis('x', 0, 10).arrange(step, True), Axis('y', 0, 2).arrange(step, True))
f = Foam(
name,
m,
m.x,
m.y,
step,
Figure(Line((0, 0), (10, 0)), Line((0, 2), (10, 2))),
Figure(Rectangle((0, 0), (1, 1))),
nu,
1,
flow,
)
d = m.transform(f.knowledge)

f.knowledge.save(OUTPUT_DIR / 'foam' / 'foam_uvp.csv')

plot_seismic(
name,
f.name,
m.x,
m.y,
[
Expand All @@ -166,7 +167,7 @@ def main():
)

plot_stream(
'OpenFOAM Streamlines',
f.name,
m.x,
m.y,
d.u,
Expand All @@ -177,7 +178,7 @@ def main():
)

plot_arrows(
'OpenFOAM Arrows',
f.name,
m.x,
m.y,
d.u,
Expand Down
1 change: 0 additions & 1 deletion src/nse/model/experiments/slalom.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(
foam,
)

step = .1
stride = step / 2

# inlet
Expand Down
1 change: 0 additions & 1 deletion src/nse/model/experiments/slit.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(
foam,
)

step = .1
stride = step / 2

# inlet
Expand Down
1 change: 0 additions & 1 deletion src/nse/model/experiments/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __init__(
supervised,
)

step = .1
stride = step / 2

# inlet
Expand Down
5 changes: 3 additions & 2 deletions src/nse/model/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ def __iter__(self) -> tp.Iterator[Loss]:

@staticmethod
def load(path: Path) -> Losses:
# pylint: disable=protected-access
if path.exists():
loss = Losses()
lines = path.read_text(encoding='utf-8').strip().splitlines()
for line in lines:
loss.__losses.append(Loss(*line.strip().split(',')))
return loss
else:
logging.error(f'{path} does not exist')
logging.error(f'{path} does not exist')
raise FileNotFoundError
4 changes: 2 additions & 2 deletions src/nse/model/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ def load(path: Path) -> Record:
if path.exists():
u, v, p = path.read_text(encoding='utf-8').strip().split(',')
return Record(float(u), float(v), float(p))
else:
logging.error(f'{path} does not exist')
logging.error(f'{path} does not exist')
raise FileNotFoundError

0 comments on commit 0d95c9d

Please sign in to comment.