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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.DS_Store
Thumbs.db
.ipynb_checkpoints/
.venv/
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ dependencies = [
"numpy",
]

[tool.setuptools]
py-modules = ["diffusion_model"]
[tool.setuptools.packages.find]
where = ["src"]

[tool.pytest.ini_options]
pythonpath = ["src"]
22 changes: 0 additions & 22 deletions diffusion_model.py → src/diffusion_model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os
import sys
import tomllib

import numpy as np
Expand Down Expand Up @@ -95,23 +93,3 @@ def load_params_from_path(filepath):
with open(filepath, "rb") as stream:
params = tomllib.load(stream)
return params


if __name__ == "__main__":
import matplotlib as mpl
import mpl_ascii

mpl_ascii.AXES_WIDTH = 70
mpl_ascii.AXES_HEIGHT = 15

mpl.use("module://mpl_ascii")

filepath = "diffusion.toml"

if os.path.isfile(filepath):
params = load_params_from_path(filepath)
else:
params = {}
concentration = run_diffusion_model(**params)

np.savetxt(sys.stdout, concentration, fmt="%.6f")
23 changes: 23 additions & 0 deletions src/diffusion_model/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import sys

import matplotlib as mpl
import mpl_ascii
import numpy as np

from diffusion_model import load_params_from_path, run_diffusion_model

mpl_ascii.AXES_WIDTH = 70
mpl_ascii.AXES_HEIGHT = 15

mpl.use("module://mpl_ascii")

filepath = "diffusion.toml"

if os.path.isfile(filepath):
params = load_params_from_path(filepath)
else:
params = {}
concentration = run_diffusion_model(**params)

np.savetxt(sys.stdout, concentration, fmt="%.6f")