Skip to content
Open
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
17 changes: 3 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,10 @@ repos:


- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.15.8
hooks:
- id: ruff
args:
- --quiet
- --fix
- --select
- F # pyflakes
- B # flake8-bugbear
- I # isort
- NPY # numpy-specific rules
- --ignore
- F405
- --ignore
- F403 # ignore import *
- id: ruff-check
args: [--quiet, --fix, --show-fixes]

- repo: https://github.com/neutrinoceros/inifix
rev: v6.1.2
Expand Down
4 changes: 3 additions & 1 deletion doc/source/plot_idefix_bench.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import matplotlib.pyplot as plt
import json

import matplotlib.pyplot as plt


def do_plot(title, bench_file, gpumodels):
with open(bench_file, 'r') as f:
benches = json.load(f)
Expand Down
2 changes: 1 addition & 1 deletion pytools/dump_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self, fh, byteorder="little"):
self.ndims = int.from_bytes(fh.read(INT_SIZE), byteorder)
dims = []
ntot = 1
for dim in range(self.ndims):
for _ in range(self.ndims):
dims.append(int.from_bytes(fh.read(INT_SIZE), byteorder))
ntot = ntot * dims[-1]
raw = struct.unpack(str(ntot) + stringchar, fh.read(mysize * ntot))
Expand Down
3 changes: 1 addition & 2 deletions pytools/idfx_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import numpy as np


__all__ = ["readIdfxFile"]
# Read .idfx files which are created
# for debug purposes by DataBlock.DumpToFile(std::string&)
Expand All @@ -27,7 +26,7 @@ def __init__(self, fh, byteorder="little"):
return
self.ndims = int.from_bytes(fh.read(INT_SIZE), byteorder)
dims = []
for dim in range(self.ndims):
for _ in range(self.ndims):
dims.append(int.from_bytes(fh.read(INT_SIZE), byteorder))
ntot = int(np.prod(dims))
raw = struct.unpack(str(ntot) + "d", fh.read(DOUBLE_SIZE * ntot))
Expand Down
5 changes: 3 additions & 2 deletions pytools/idfx_test.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import argparse
import os
import re
import shutil
import subprocess
import sys
import re

import numpy as np
import matplotlib.pyplot as plt
import numpy as np

from .dump_io import readDump


class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
Expand Down
2 changes: 1 addition & 1 deletion pytools/sod.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def solve(left_state, right_state, geometry, t, gamma=1.4, npts=500,

pos_description = ('Head of Rarefaction', 'Foot of Rarefaction',
'Contact Discontinuity', 'Shock')
positions = dict(zip(pos_description, x_positions))
positions = dict(zip(pos_description, x_positions, strict=True))

# create arrays
x, p, rho, u = create_arrays(pl, pr, xl, xr, x_positions,
Expand Down
7 changes: 4 additions & 3 deletions pytools/vtk_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
@author: glesur
"""

import warnings
import numpy as np
import os
import re
import warnings

import numpy as np

# restrict what's included with `import *` to public API
__all__ = [
Expand Down Expand Up @@ -98,7 +99,7 @@ def _load_header(self, fh, geometry=None):
native_name, _ncomp, native_dim, _dtype = d.split()
self.native_coordinates[native_name] = np.fromfile(fh, dtype=dt, count=int(native_dim))
else:
warnings.warn("Found unknown field %s" % d)
warnings.warn("Found unknown field %s" % d, stacklevel=3)
fh.readline() # skip extra linefeed (empty line)

if self.geometry is None:
Expand Down
14 changes: 14 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
target-version = "py310"

[lint]
select = [
"F", # pyflakes
"B", # flake8-bugbear
"I", # isort
"NPY", # numpy-specific rules
]
ignore = [
# allow `import *`
"F403", # undefined-local-with-import-star
"F405", # undefined-local-with-import-star-usage
]
5 changes: 3 additions & 2 deletions test/Dust/DustEnergy/python/testidefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

@author: lesurg
"""
import sys
import numpy as np
import argparse
import sys

import matplotlib.pyplot as plt
import numpy as np

parser = argparse.ArgumentParser()
parser.add_argument("-noplot",
Expand Down
1 change: 1 addition & 0 deletions test/Dust/DustEnergy/testme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))

import pytools.idfx_test as tst
Expand Down
7 changes: 5 additions & 2 deletions test/Dust/DustyShock/python/testidefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))
from pytools.vtk_io import readVTK
import argparse
import numpy as np

import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import solve_ivp

from pytools.vtk_io import readVTK

parser = argparse.ArgumentParser()
parser.add_argument("-noplot",
default=False,
Expand Down
1 change: 1 addition & 0 deletions test/Dust/DustyShock/testme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))

import pytools.idfx_test as tst
Expand Down
5 changes: 3 additions & 2 deletions test/Dust/DustyWave/python/testidefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

@author: lesurg
"""
import sys
import numpy as np
import argparse
import sys

import matplotlib.pyplot as plt
import numpy as np

parser = argparse.ArgumentParser()
parser.add_argument("-noplot",
Expand Down
1 change: 1 addition & 0 deletions test/Dust/DustyWave/testme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))

import pytools.idfx_test as tst
Expand Down
2 changes: 2 additions & 0 deletions test/HD/FargoPlanet/testme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"""
import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))

import pytools.idfx_test as tst

tolerance=1e-13
def testMe(test):
test.configure()
Expand Down
2 changes: 2 additions & 0 deletions test/HD/MachReflection/testme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"""
import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))

import pytools.idfx_test as tst


def testMe(test):
test.configure()
test.compile()
Expand Down
7 changes: 5 additions & 2 deletions test/HD/SedovBlastWave/python/testidefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))
from pytools.vtk_io import readVTK
import argparse
import numpy as np

import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import interp1d

from pytools.vtk_io import readVTK

parser = argparse.ArgumentParser()
parser.add_argument("-noplot",
default=False,
Expand Down
1 change: 1 addition & 0 deletions test/HD/SedovBlastWave/testme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))

import pytools.idfx_test as tst
Expand Down
6 changes: 4 additions & 2 deletions test/HD/ShearingBox/python/testidefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

@author: lesurg
"""
import argparse
import sys
import numpy as np

import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import solve_ivp
import argparse


#compute theoretical solution (from Balbus & Hawley 2006, using notations from Lesur 2021)
def rhs(t, y, Omega, q, k0x, k0y, k0z):
Expand Down
2 changes: 2 additions & 0 deletions test/HD/ShearingBox/testme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"""
import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))

import pytools.idfx_test as tst

tolerance=1e-15
def testMe(test):
test.configure()
Expand Down
7 changes: 5 additions & 2 deletions test/HD/ViscousDisk/python/testidefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))
from pytools.vtk_io import readVTK
import numpy as np
import argparse

import matplotlib.pyplot as plt
import numpy as np

from pytools.vtk_io import readVTK

parser = argparse.ArgumentParser()
parser.add_argument("-noplot",
Expand Down
2 changes: 2 additions & 0 deletions test/HD/ViscousDisk/testme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"""
import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))

import pytools.idfx_test as tst

tolerance=3e-15
def testMe(test):
test.configure()
Expand Down
2 changes: 2 additions & 0 deletions test/HD/ViscousFlowPastCylinder/testme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"""
import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))

import pytools.idfx_test as tst

tolerance=3e-14
def testMe(test):
test.configure()
Expand Down
9 changes: 6 additions & 3 deletions test/HD/sod-iso/python/testidefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@

import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))
from pytools.vtk_io import readVTK
from pytools import sod
import argparse
import numpy as np

import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import interp1d

from pytools import sod
from pytools.vtk_io import readVTK

parser = argparse.ArgumentParser()
parser.add_argument("-noplot",
default=False,
Expand Down
1 change: 1 addition & 0 deletions test/HD/sod-iso/testme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))

import pytools.idfx_test as tst
Expand Down
5 changes: 3 additions & 2 deletions test/HD/sod/pydefix_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pydefix as pdfx
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
import pydefix as pdfx


def output(data):

Expand Down
9 changes: 6 additions & 3 deletions test/HD/sod/python/testidefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@

import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))
from pytools.vtk_io import readVTK
from pytools import sod
import argparse
import numpy as np

import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import interp1d

from pytools import sod
from pytools.vtk_io import readVTK

parser = argparse.ArgumentParser()
parser.add_argument("-noplot",
default=False,
Expand Down
1 change: 1 addition & 0 deletions test/HD/sod/testme.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import os
import sys

sys.path.append(os.getenv("IDEFIX_DIR"))

import pytools.idfx_test as tst
Expand Down
Loading
Loading