Skip to content

Commit 8ad1e48

Browse files
committed
ruff
1 parent 0e8cf6c commit 8ad1e48

File tree

6 files changed

+6
-20
lines changed

6 files changed

+6
-20
lines changed

.github/workflows/test-package.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ jobs:
2727
- name: Install dependencies
2828
run: |
2929
python -m pip install --upgrade pip
30-
python -m pip install flake8 pytest
30+
python -m pip install ruff pytest
3131
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3232
pip install .
33-
- name: Lint with flake8
33+
- name: Lint with ruff
3434
run: |
35-
# stop the build if there are Python syntax errors or undefined names
36-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
37-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
38-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
35+
ruff check
36+
ruff format --check
3937
- name: Test with pytest
4038
run: |
4139
pytest

adirondax/simulation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class Simulation:
1313
"""
14-
Simulation: The base class for an astrophysics simulation.
14+
Simulation: The base class for a multi-physics simulation.
1515
1616
Parameters
1717
----------
@@ -20,7 +20,6 @@ class Simulation:
2020
"""
2121

2222
def __init__(self, params):
23-
2423
# simulation parameters
2524
self._params = copy.deepcopy(params)
2625
self._nt = params["simulation"]["n_timestep"]
@@ -144,10 +143,9 @@ def _evolve(self, state):
144143
self._internal["V"] = self._calc_grav_potential(state, kSq)
145144

146145
def update(i, state):
147-
148146
# Update the simulation state by one timestep
149147
# according to a 2nd-order `kick-drift-kick` scheme
150-
148+
151149
# Kick (half-step)
152150
if self.params["physics"]["quantum"] and self.params["physics"]["gravity"]:
153151
state["psi"] = quantum_kick(state["psi"], self._internal["V"], dt / 2.0)

benchmarks/benchmarks/bench_inverse_problem.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def run_forward_model(self):
5858
return jnp.mean(theta)
5959

6060
def solve_inverse_problem(self):
61-
6261
assert self.rho_target.shape[0] == 128
6362

6463
sim = adx.Simulation(self.params)

examples/euler/euler.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919

2020
def setup_simulation():
21-
2221
# Define the parameters for the simulation
2322
n = 256
2423
nt = 1500 * int(n / 128)
@@ -72,7 +71,6 @@ def setup_simulation():
7271

7372

7473
def make_plot(sim):
75-
7674
# Plot the solution
7775
plt.figure(figsize=(6, 4), dpi=80)
7876
plt.imshow(jnp.rot90(sim.state["rho"]), cmap="jet", vmin=0.8, vmax=2.2)
@@ -83,7 +81,6 @@ def make_plot(sim):
8381

8482

8583
def main():
86-
8784
sim = setup_simulation()
8885

8986
# Evolve the system (takes around 9 seconds on my macbook)

examples/schrodinger_poisson/schrodinger_poisson.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222

2323
def setup_simulation():
24-
2524
# Define the parameters for the simulation
2625
n = 128
2726
nt = 100 * int(n / 128)
@@ -54,7 +53,6 @@ def setup_simulation():
5453

5554

5655
def solve_inverse_problem(sim):
57-
5856
# Load the target density field
5957
target_data = img.imread("target.png")[:, :, 0]
6058
rho_target = jnp.flipud(jnp.array(target_data, dtype=float))
@@ -89,7 +87,6 @@ def loss_function(theta, rho_target):
8987

9088

9189
def rerun_simulation(sim, theta):
92-
9390
# Re-run the simulation with the optimal initial conditions
9491
sim.state["t"] = 0.0
9592
sim.state["psi"] = jnp.exp(1.0j * theta)
@@ -100,7 +97,6 @@ def rerun_simulation(sim, theta):
10097

10198

10299
def make_plot(psi, theta):
103-
104100
# Plot the solution
105101
plt.figure(figsize=(6, 4), dpi=80)
106102
grid = plt.GridSpec(1, 2, wspace=0.0, hspace=0.0)
@@ -130,7 +126,6 @@ def make_plot(psi, theta):
130126

131127

132128
def main():
133-
134129
sim = setup_simulation()
135130
theta = solve_inverse_problem(sim)
136131
psi = rerun_simulation(sim, theta)

tests/test_inverse_problem.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def run_forward_model():
5959

6060

6161
def solve_inverse_problem():
62-
6362
rho_target = read_target()
6463
assert rho_target.shape[0] == 128
6564

0 commit comments

Comments
 (0)