From 5065194b0458e2cb5a59cef5c143c068cccf3c06 Mon Sep 17 00:00:00 2001 From: kshitij-maths Date: Tue, 4 Nov 2025 12:01:21 +0100 Subject: [PATCH 1/3] added pyproject.toml, removed setup.py and meta.py and modified tutorials to accomodate these changes --- .gitignore | 4 +++ docs/source/conf.py | 22 ++++++++----- ezyrb/__init__.py | 1 - ezyrb/meta.py | 16 ---------- pyproject.toml | 60 ++++++++++++++++++++++++++++++++++++ setup.py | 61 ------------------------------------- tutorials/tutorial-1.py | 2 +- tutorials/tutorial-3.py | 2 +- utils/mathlab_versioning.py | 16 +++++----- 9 files changed, 88 insertions(+), 96 deletions(-) delete mode 100644 ezyrb/meta.py create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.gitignore b/.gitignore index cf9e1ba7..7eee279b 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,7 @@ target/ #Ipython Notebook .ipynb_checkpoints + +#revieweing and package modernization +ezyrb_documentation_review.md +venv_ezyrb/ diff --git a/docs/source/conf.py b/docs/source/conf.py index 17b5d1cc..3c2398dc 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -18,12 +18,22 @@ import sphinx from sphinx.errors import VersionRequirementError import sphinx_rtd_theme +import time +import importlib.metadata + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('../..')) -import ezyrb.meta as meta + + +# -- Project infirmation -------- +_DISTRIBUTION_METADATA = importlib.metadata.metadata("ezyrb") +project = _DISTRIBUTION_METADATA["Name"] +copyright = f'2016-{time.strftime("%Y")}, EZyRB contributors' +author = _DISTRIBUTION_METADATA["Author"] + # -- General configuration ------------------------------------------------ @@ -69,10 +79,6 @@ # The master toctree document. master_doc = 'index' -# General information about the project. -project = meta.__project__ -copyright = meta.__copyright__ -author = meta.__author__ # autoclass autoclass_content = 'both' @@ -82,9 +88,9 @@ # built documents. # # The short X.Y version. -version = meta.__version__ -# The full version, including alpha/beta/rc tags. +version = _DISTRIBUTION_METADATA["Version"] release = version +# The full version, including alpha/beta/rc tags. # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -287,7 +293,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, meta.__title__, u'EZyRB Documentation', + (master_doc, 'ezyrb' , u'EZyRB Documentation', [author], 1) ] diff --git a/ezyrb/__init__.py b/ezyrb/__init__.py index 54ac0b75..147140a8 100644 --- a/ezyrb/__init__.py +++ b/ezyrb/__init__.py @@ -6,7 +6,6 @@ 'ReducedOrderModel', 'PODAE', 'RegularGrid' ] -from .meta import * from .database import Database from .snapshot import Snapshot from .parameter import Parameter diff --git a/ezyrb/meta.py b/ezyrb/meta.py deleted file mode 100644 index d3c73769..00000000 --- a/ezyrb/meta.py +++ /dev/null @@ -1,16 +0,0 @@ -"""EZyRB metadata.""" - -__all__ = [ - '__project__', '__title__', '__author__', '__copyright__', '__license__', - '__version__', '__mail__', '__maintainer__', '__status__' -] - -__project__ = 'EZyRB' -__title__ = "ezyrb" -__author__ = "Nicola Demo, Marco Tezzele" -__copyright__ = "Copyright 2016-2021, EZyRB contributors" -__license__ = "MIT" -__version__ = "1.3.0" -__mail__ = 'demo.nicola@gmail.com, marcotez@gmail.com' -__maintainer__ = __author__ -__status__ = "Stable" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..8ac921f3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,60 @@ +[project] +name = "ezyrb" +version = "1.3.1" +description = "Easy Reduced Basis" +readme = "README.md" +authors = [ + {name = "Nicola Demo", email = "demo.nicola@gmail.com"}, + {name = "Marco Tezzele", email = "marcotez@gmail.com"}, + {name = "Kshitij Kumar Pandey", email = "kshitij.sxcr@gmail.com"} +] +license = { text = "MIT" } +keywords = [ + "pod", "interpolation", "reduced-basis", + "model-order-reduction", "scientific-computing" +] +dependencies = [ + "future", + "numpy", + "scipy", + "matplotlib", + "scikit-learn>=1.0", + "torch", + "datasets" +] +requires-python = ">=3.8" + +[project.optional-dependencies] +docs = [ + "sphinx", + "sphinx_rtd_theme" +] +test = [ + "pytest", + "pytest-cov" +] +dev = [ + "black", + "pylint" +] +tutorial = [ + "jupyter", + "notebook" +] + +[project.urls] +Homepage = "https://github.com/mathLab/EZyRB" +Repository = "https://github.com/mathLab/EZyRB" + +[build-system] +requires = ["setuptools>=45", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +include = ["ezyrb*"] + +[tool.black] +line-length = 80 + +[tool.isort] +profile = "black" \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index be462ec8..00000000 --- a/setup.py +++ /dev/null @@ -1,61 +0,0 @@ -from setuptools import setup, find_packages - -meta = {} -with open("ezyrb/meta.py") as fp: - exec(fp.read(), meta) - -# Package meta-data. -NAME = meta['__title__'] -DESCRIPTION = 'Easy Reduced Basis' -URL = 'https://github.com/mathLab/EZyRB' -MAIL = meta['__mail__'] -AUTHOR = meta['__author__'] -VERSION = meta['__version__'] -KEYWORDS = 'pod interpolation reduced-basis model-order-reduction' - -REQUIRED = [ - 'future', 'numpy', 'scipy', 'matplotlib', 'scikit-learn>=1.0', 'torch' -] - -EXTRAS = { - 'docs': ['sphinx', 'sphinx_rtd_theme'], - 'test': ['pytest', 'pytest-cov'], -} - -LDESCRIPTION = ( - "EZyRB is a Python package that performs a data-driven model order " - "reduction for parametrized problems exploiting the recent approaches. " - "Such techniques are able to provide a parametric model capable to " - "provide the real-time approximation of the solution of a generic " - "(potentially complex and non linear) problem. The reduced model is " - "totally built upon the numerical data obtained by the original (to " - "reduce) model, without requiring any knowledge of the equations that " - "describe this model, resulting in a well suited framework for industrial " - "contexts due to its natural capability to been integrated with " - "commercial software." -) - -setup( - name=NAME, - version=VERSION, - description=DESCRIPTION, - long_description=LDESCRIPTION, - author=AUTHOR, - author_email=MAIL, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Intended Audience :: Science/Research', - 'Topic :: Scientific/Engineering :: Mathematics' - ], - keywords=KEYWORDS, - url=URL, - license='MIT', - packages=find_packages(), - install_requires=REQUIRED, - extras_require=EXTRAS, - include_package_data=True, - zip_safe=False, -) diff --git a/tutorials/tutorial-1.py b/tutorials/tutorial-1.py index 5f3d105c..966fd478 100644 --- a/tutorials/tutorial-1.py +++ b/tutorials/tutorial-1.py @@ -82,7 +82,7 @@ def hf_to_numpy(ds): ax[i].triplot(triang, 'b-', lw=0.1) cm = ax[i].tripcolor(triang, snapshots[i]) fig.colorbar(cm, ax=ax[i]) - ax[i].set_title('($\mu_0={:5.2f}, \mu_1={:5.2f})$'.format(*param[i])) + ax[i].set_title(r'($\mu_0={:5.2f}, \mu_1={:5.2f})$'.format(*param[i])) # First of all, we create a `Database` object from the parameters and the snapshots. diff --git a/tutorials/tutorial-3.py b/tutorials/tutorial-3.py index e3cf60e7..01fa2bd7 100644 --- a/tutorials/tutorial-3.py +++ b/tutorials/tutorial-3.py @@ -203,7 +203,7 @@ def wave(t, res=256): plt.figure(figsize=(6,4)) plt.plot(N_modes[:10], s[:10]/np.max(s),"-s",color = "blue", label='POD') plt.plot(N_modes_shifted, s_shifted/np.max(s_shifted),"-o", color = "red", label='NNsPOD') -plt.ylabel('$\sigma/\sigma_{1}$', size=15) +plt.ylabel(r'$\sigma/\sigma_{1}$', size=15) plt.xlabel('Modes', size=15) plt.xlim(0, 11) plt.legend(fontsize=12) diff --git a/utils/mathlab_versioning.py b/utils/mathlab_versioning.py index 09d6dfeb..c606495e 100644 --- a/utils/mathlab_versioning.py +++ b/utils/mathlab_versioning.py @@ -4,8 +4,8 @@ module = 'ezyrb' -meta_file = os.path.join(module, 'meta.py') -version_line = r'__version__.*=.*"(.+?)"' +pyproject_file = 'pyproject.toml' +version_line = r'version.*=.*"(.+?)"' class Version: @@ -34,11 +34,11 @@ def __str__(self): def get_version(): - with open(meta_file, 'r') as fp: + with open(pyproject_file, 'r') as fp: content = fp.read() try: - found = re.search(r'__version__.*=.*"(.+?)"', content).group(1) + found = re.search(r'version.*=.*"(.+?)"', content).group(1) except AttributeError: pass @@ -48,13 +48,13 @@ def get_version(): def set_version(version): - with open(meta_file, 'r') as fp: + with open(pyproject_file, 'r') as fp: content = fp.read() - line_string = '__version__ = "{}"'.format(version) - text_after = re.sub('__version__.*=.*"(.+?)"', line_string, content) + line_string = 'version = "{}"'.format(version) + text_after = re.sub('version.*=.*"(.+?)"', line_string, content) - with open(meta_file, 'w') as fp: + with open(pyproject_file, 'w') as fp: fp.write(text_after) From 77669cd2c8b42bb325cc1ea5222779b8dbf5fa17 Mon Sep 17 00:00:00 2001 From: kshitij-maths Date: Fri, 7 Nov 2025 10:26:57 +0100 Subject: [PATCH 2/3] removed Kshitij's name from author's list --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8ac921f3..f3811887 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,6 @@ readme = "README.md" authors = [ {name = "Nicola Demo", email = "demo.nicola@gmail.com"}, {name = "Marco Tezzele", email = "marcotez@gmail.com"}, - {name = "Kshitij Kumar Pandey", email = "kshitij.sxcr@gmail.com"} ] license = { text = "MIT" } keywords = [ From a775e14e146fdbfb49a3c467648a57482facd9ee Mon Sep 17 00:00:00 2001 From: kshitij-maths Date: Fri, 7 Nov 2025 14:39:24 +0100 Subject: [PATCH 3/3] modified git ignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7eee279b..7579c8a6 100644 --- a/.gitignore +++ b/.gitignore @@ -68,5 +68,4 @@ target/ .ipynb_checkpoints #revieweing and package modernization -ezyrb_documentation_review.md venv_ezyrb/