Skip to content

Commit 5f2900d

Browse files
kshitij-mathskshitij-maths
andauthored
Package modernization (#266)
* add pyproject.toml * removed setup.py and meta.py * adjust tutorials --------- Co-authored-by: kshitij-maths <[email protected]>
1 parent ec65d70 commit 5f2900d

File tree

9 files changed

+86
-96
lines changed

9 files changed

+86
-96
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ target/
6666

6767
#Ipython Notebook
6868
.ipynb_checkpoints
69+
70+
#revieweing and package modernization
71+
venv_ezyrb/

docs/source/conf.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,22 @@
1818
import sphinx
1919
from sphinx.errors import VersionRequirementError
2020
import sphinx_rtd_theme
21+
import time
22+
import importlib.metadata
23+
2124

2225
# If extensions (or modules to document with autodoc) are in another directory,
2326
# add these directories to sys.path here. If the directory is relative to the
2427
# documentation root, use os.path.abspath to make it absolute, like shown here.
2528
sys.path.insert(0, os.path.abspath('../..'))
26-
import ezyrb.meta as meta
29+
30+
31+
# -- Project infirmation --------
32+
_DISTRIBUTION_METADATA = importlib.metadata.metadata("ezyrb")
33+
project = _DISTRIBUTION_METADATA["Name"]
34+
copyright = f'2016-{time.strftime("%Y")}, EZyRB contributors'
35+
author = _DISTRIBUTION_METADATA["Author"]
36+
2737

2838
# -- General configuration ------------------------------------------------
2939

@@ -69,10 +79,6 @@
6979
# The master toctree document.
7080
master_doc = 'index'
7181

72-
# General information about the project.
73-
project = meta.__project__
74-
copyright = meta.__copyright__
75-
author = meta.__author__
7682

7783
# autoclass
7884
autoclass_content = 'both'
@@ -82,9 +88,9 @@
8288
# built documents.
8389
#
8490
# The short X.Y version.
85-
version = meta.__version__
86-
# The full version, including alpha/beta/rc tags.
91+
version = _DISTRIBUTION_METADATA["Version"]
8792
release = version
93+
# The full version, including alpha/beta/rc tags.
8894

8995
# The language for content autogenerated by Sphinx. Refer to documentation
9096
# for a list of supported languages.
@@ -287,7 +293,7 @@
287293
# One entry per manual page. List of tuples
288294
# (source start file, name, description, authors, manual section).
289295
man_pages = [
290-
(master_doc, meta.__title__, u'EZyRB Documentation',
296+
(master_doc, 'ezyrb' , u'EZyRB Documentation',
291297
[author], 1)
292298
]
293299

ezyrb/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
'ReducedOrderModel', 'PODAE', 'RegularGrid'
77
]
88

9-
from .meta import *
109
from .database import Database
1110
from .snapshot import Snapshot
1211
from .parameter import Parameter

ezyrb/meta.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

pyproject.toml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[project]
2+
name = "ezyrb"
3+
version = "1.3.1"
4+
description = "Easy Reduced Basis"
5+
readme = "README.md"
6+
authors = [
7+
{name = "Nicola Demo", email = "[email protected]"},
8+
{name = "Marco Tezzele", email = "[email protected]"},
9+
]
10+
license = { text = "MIT" }
11+
keywords = [
12+
"pod", "interpolation", "reduced-basis",
13+
"model-order-reduction", "scientific-computing"
14+
]
15+
dependencies = [
16+
"future",
17+
"numpy",
18+
"scipy",
19+
"matplotlib",
20+
"scikit-learn>=1.0",
21+
"torch",
22+
"datasets"
23+
]
24+
requires-python = ">=3.8"
25+
26+
[project.optional-dependencies]
27+
docs = [
28+
"sphinx",
29+
"sphinx_rtd_theme"
30+
]
31+
test = [
32+
"pytest",
33+
"pytest-cov"
34+
]
35+
dev = [
36+
"black",
37+
"pylint"
38+
]
39+
tutorial = [
40+
"jupyter",
41+
"notebook"
42+
]
43+
44+
[project.urls]
45+
Homepage = "https://github.com/mathLab/EZyRB"
46+
Repository = "https://github.com/mathLab/EZyRB"
47+
48+
[build-system]
49+
requires = ["setuptools>=45", "wheel"]
50+
build-backend = "setuptools.build_meta"
51+
52+
[tool.setuptools.packages.find]
53+
include = ["ezyrb*"]
54+
55+
[tool.black]
56+
line-length = 80
57+
58+
[tool.isort]
59+
profile = "black"

setup.py

Lines changed: 0 additions & 61 deletions
This file was deleted.

tutorials/tutorial-1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def hf_to_numpy(ds):
8282
ax[i].triplot(triang, 'b-', lw=0.1)
8383
cm = ax[i].tripcolor(triang, snapshots[i])
8484
fig.colorbar(cm, ax=ax[i])
85-
ax[i].set_title('($\mu_0={:5.2f}, \mu_1={:5.2f})$'.format(*param[i]))
85+
ax[i].set_title(r'($\mu_0={:5.2f}, \mu_1={:5.2f})$'.format(*param[i]))
8686

8787

8888
# First of all, we create a `Database` object from the parameters and the snapshots.

tutorials/tutorial-3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def wave(t, res=256):
203203
plt.figure(figsize=(6,4))
204204
plt.plot(N_modes[:10], s[:10]/np.max(s),"-s",color = "blue", label='POD')
205205
plt.plot(N_modes_shifted, s_shifted/np.max(s_shifted),"-o", color = "red", label='NNsPOD')
206-
plt.ylabel('$\sigma/\sigma_{1}$', size=15)
206+
plt.ylabel(r'$\sigma/\sigma_{1}$', size=15)
207207
plt.xlabel('Modes', size=15)
208208
plt.xlim(0, 11)
209209
plt.legend(fontsize=12)

utils/mathlab_versioning.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55

66
module = 'ezyrb'
7-
meta_file = os.path.join(module, 'meta.py')
8-
version_line = r'__version__.*=.*"(.+?)"'
7+
pyproject_file = 'pyproject.toml'
8+
version_line = r'version.*=.*"(.+?)"'
99

1010

1111
class Version:
@@ -34,11 +34,11 @@ def __str__(self):
3434

3535

3636
def get_version():
37-
with open(meta_file, 'r') as fp:
37+
with open(pyproject_file, 'r') as fp:
3838
content = fp.read()
3939

4040
try:
41-
found = re.search(r'__version__.*=.*"(.+?)"', content).group(1)
41+
found = re.search(r'version.*=.*"(.+?)"', content).group(1)
4242
except AttributeError:
4343
pass
4444

@@ -48,13 +48,13 @@ def get_version():
4848

4949

5050
def set_version(version):
51-
with open(meta_file, 'r') as fp:
51+
with open(pyproject_file, 'r') as fp:
5252
content = fp.read()
5353

54-
line_string = '__version__ = "{}"'.format(version)
55-
text_after = re.sub('__version__.*=.*"(.+?)"', line_string, content)
54+
line_string = 'version = "{}"'.format(version)
55+
text_after = re.sub('version.*=.*"(.+?)"', line_string, content)
5656

57-
with open(meta_file, 'w') as fp:
57+
with open(pyproject_file, 'w') as fp:
5858
fp.write(text_after)
5959

6060

0 commit comments

Comments
 (0)