Skip to content

Commit

Permalink
apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
leiterrl committed Dec 18, 2024
1 parent 6bd9802 commit d563803
Show file tree
Hide file tree
Showing 30 changed files with 73 additions and 40 deletions.
1 change: 1 addition & 0 deletions pdebench/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""

from __future__ import annotations

import logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
"""

from __future__ import annotations

import logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
"""

from __future__ import annotations

import random
Expand All @@ -165,6 +166,7 @@

logger = logging.getLogger(__name__)


def _pass(carry):
return carry

Expand Down Expand Up @@ -233,7 +235,6 @@ def _show(_carry):
t, tsave, steps, i_save, dt, u, uu = lax.while_loop(cond_fun, _body_fun, carry)
return uu.at[-1].set(u)


@jax.jit
def simulation_fn(i, carry):
u, t, dt, steps, tsave = carry
Expand Down
1 change: 1 addition & 0 deletions pdebench/data_gen/data_gen_NLE/BurgersEq/burgers_Hydra.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
"""

from __future__ import annotations

import logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
"""

from __future__ import annotations

import logging
Expand Down Expand Up @@ -233,7 +234,6 @@ def _show(_carry):
t, tsave, steps, i_save, dt, u, uu = lax.while_loop(cond_fun, _body_fun, carry)
return uu.at[-1].set(u)


@jax.jit
def simulation_fn(i, carry):
u, t, dt, steps, tsave = carry
Expand Down
1 change: 0 additions & 1 deletion pdebench/data_gen/gen_radial_dam_break.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def main(config: DictConfig):
# Change back to the hydra working directory
os.chdir(temp_path)


work_path = Path(config.work_dir)
output_path = work_path / config.data_dir / config.output_path
if not output_path.is_dir():
Expand Down
35 changes: 16 additions & 19 deletions pdebench/data_gen/notebooks/Analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
}
],
"source": [
"data_path = resolve_path('${WORKING_DIR}/*/*/*/*/*/*.h5', idx=-1, unique=False)\n",
"print(data_path) # noqa: T201\n"
"data_path = resolve_path(\"${WORKING_DIR}/*/*/*/*/*/*.h5\", idx=-1, unique=False)\n",
"print(data_path) # noqa: T201"
]
},
{
Expand All @@ -97,7 +97,7 @@
}
],
"source": [
"data_f = h5py.File(data_path, 'r')\n",
"data_f = h5py.File(data_path, \"r\")\n",
"data_f.keys()"
]
},
Expand All @@ -118,7 +118,7 @@
}
],
"source": [
"data_f['particles'].shape"
"data_f[\"particles\"].shape"
]
},
{
Expand All @@ -140,16 +140,15 @@
}
],
"source": [
"\n",
"columns = 5\n",
"fsize = 12\n",
"\n",
"arr = data_f['particles'][0, :columns, :, :, 0]\n",
"arr = data_f[\"particles\"][0, :columns, :, :, 0]\n",
"\n",
"fig = plt.figure(figsize=(fsize, fsize/columns))\n",
"plt.imshow(rearrange(arr, 't x y -> x (t y)'))\n",
"fig = plt.figure(figsize=(fsize, fsize / columns))\n",
"plt.imshow(rearrange(arr, \"t x y -> x (t y)\"))\n",
"plt.gca().set_axis_off()\n",
"plt.tight_layout(pad = 1)\n",
"plt.tight_layout(pad=1)\n",
"plt.show()"
]
},
Expand All @@ -172,16 +171,15 @@
}
],
"source": [
"\n",
"columns = 5\n",
"fsize = 12\n",
"\n",
"arr = data_f['particles'][0, 1000:1000+columns, :, :, 0]\n",
"arr = data_f[\"particles\"][0, 1000 : 1000 + columns, :, :, 0]\n",
"\n",
"fig = plt.figure(figsize=(fsize, fsize/columns))\n",
"plt.imshow(rearrange(arr, 't x y -> x (t y)'))\n",
"fig = plt.figure(figsize=(fsize, fsize / columns))\n",
"plt.imshow(rearrange(arr, \"t x y -> x (t y)\"))\n",
"plt.gca().set_axis_off()\n",
"plt.tight_layout(pad = 1)\n",
"plt.tight_layout(pad=1)\n",
"plt.show()"
]
},
Expand All @@ -204,16 +202,15 @@
}
],
"source": [
"\n",
"columns = 5\n",
"fsize = 12\n",
"\n",
"arr = data_f['force'][:columns, :, :, 0]\n",
"arr = data_f[\"force\"][:columns, :, :, 0]\n",
"\n",
"fig = plt.figure(figsize=(fsize, fsize/columns))\n",
"plt.imshow(rearrange(arr, 'b x y -> x (b y)'))\n",
"fig = plt.figure(figsize=(fsize, fsize / columns))\n",
"plt.imshow(rearrange(arr, \"b x y -> x (b y)\"))\n",
"plt.gca().set_axis_off()\n",
"plt.tight_layout(pad = 1)\n",
"plt.tight_layout(pad=1)\n",
"plt.show()"
]
},
Expand Down
2 changes: 1 addition & 1 deletion pdebench/data_gen/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@author: timot
"""

from __future__ import annotations

import os
Expand Down Expand Up @@ -63,6 +64,5 @@ def main(config: DictConfig):
)



if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion pdebench/data_gen/src/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Author : John Kim, Simon Brown, Timothy Praditia
PDE Simulation packages
"""

from __future__ import annotations

import h5py
Expand All @@ -18,7 +19,7 @@ def plot_data(data, t, dim, channel, t_fraction, config, filename):
plt.figure()
plt.title(f"$t={t[t_idx]}$")
if dim == 1:
with h5py.File(config.data_path, 'r') as h5_file:
with h5py.File(config.data_path, "r") as h5_file:
x = np.array(h5_file["grid"]["x"], dtype="f")
plt.plot(x.squeeze(), data[t_idx, ..., channel])
plt.xlabel("$x$")
Expand Down
2 changes: 0 additions & 2 deletions pdebench/data_gen/src/sim_diff_react.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,3 @@ def rc_ode(self, t, y): # noqa: ARG002

# Stack the time derivative into a single array y_t
return np.concatenate((u_t, v_t))


1 change: 1 addition & 0 deletions pdebench/data_gen/src/sim_ns_incomp_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Author : John Kim, Ran Zhang, Dan MacKinlay
PDE Simulation packages
"""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions pdebench/data_gen/src/sim_radial_dam_break.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

logger = logging.getLogger(__name__)


class Basic2DScenario(ABC):
name = ""

Expand Down
2 changes: 1 addition & 1 deletion pdebench/data_gen/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def matching_paths(glob_exp):
return a list of paths matching a glob expression
"""
path = os.path.expandvars(Path(glob_exp).expanduser())
return list(Path(path).glob('*'))
return list(Path(path).glob("*"))


def resolve_path(path, idx=None, unique=True):
Expand Down
3 changes: 2 additions & 1 deletion pdebench/data_gen/src/vorticity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
r""" Generate vorticity field :math:`\boldsymbol{\omega} = \nabla \times \boldsymbol{v}` given
r"""Generate vorticity field :math:`\boldsymbol{\omega} = \nabla \times \boldsymbol{v}` given
velocity field :math:`\boldsymbol{v}` using numerical approximation.
Assuming the velocitiy field of shape [n, sx, sy, sz, 3] (5D) consists of a trajectory of equidistant cells,
Expand All @@ -15,6 +15,7 @@
for approximating the vorticity field.
"""

from __future__ import annotations

import jax
Expand Down
5 changes: 3 additions & 2 deletions pdebench/data_gen/velocity2vorticity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" Convert velocity- to vorticity field assuming 3D CFD exampe was downloaded.
The resulting .hdf5 file does not store pressure and density.
"""Convert velocity- to vorticity field assuming 3D CFD exampe was downloaded.
The resulting .hdf5 file does not store pressure and density.
"""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions pdebench/models/analyse_result_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
"""

from __future__ import annotations

import _pickle as cPickle
Expand Down
1 change: 1 addition & 0 deletions pdebench/models/analyse_result_inverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
"""

from __future__ import annotations

import matplotlib.pyplot as plt
Expand Down
1 change: 1 addition & 0 deletions pdebench/models/fno/fno.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

from __future__ import annotations

import torch
Expand Down
1 change: 1 addition & 0 deletions pdebench/models/fno/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# np.random.seed(0)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")


def run_training(
if_training,
continue_training,
Expand Down
1 change: 1 addition & 0 deletions pdebench/models/fno/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
"""

from __future__ import annotations

import math as mt
Expand Down
1 change: 1 addition & 0 deletions pdebench/models/inverse/inverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
"""

from __future__ import annotations

import pyro
Expand Down
1 change: 1 addition & 0 deletions pdebench/models/inverse/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
"""

from __future__ import annotations

import logging
Expand Down
2 changes: 2 additions & 0 deletions pdebench/models/inverse/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
"""

from __future__ import annotations

import logging
Expand All @@ -157,6 +158,7 @@

logger = logging.getLogger(__name__)


def plot_ic_solution_mcmc(
latent,
x,
Expand Down
Loading

0 comments on commit d563803

Please sign in to comment.