From d972a2524e522c7890135ad4369dc4697182c244 Mon Sep 17 00:00:00 2001 From: Rosona Eldred Date: Tue, 22 Jul 2025 13:12:24 +0200 Subject: [PATCH 1/4] wrapped json in StringIO object. --- opti/problem.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opti/problem.py b/opti/problem.py index 63433fb..c9b5b97 100644 --- a/opti/problem.py +++ b/opti/problem.py @@ -1,5 +1,6 @@ import json import os +from io import StringIO from typing import Callable, Dict, List, Optional, Tuple, Union import numpy as np @@ -87,10 +88,10 @@ def __init__( self.f = f if isinstance(data, dict): - data = pd.read_json(json.dumps(data), orient="split") + data = pd.read_json(StringIO(json.dumps(data)), orient="split") if isinstance(optima, dict): - optima = pd.read_json(json.dumps(optima), orient="split") + optima = pd.read_json(StringIO(json.dumps(optima)), orient="split") self.set_data(data) self.set_optima(optima) From efab488a4f525b8415b10295210035bf1fe0b9f2 Mon Sep 17 00:00:00 2001 From: Rosona Eldred Date: Tue, 22 Jul 2025 13:56:07 +0200 Subject: [PATCH 2/4] added pyproject.toml --- .gitignore | 4 +++ pyproject.toml | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index 47d6da7..5591030 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,7 @@ __pycache__ .idea build dist + +# uv +.venv/ +uv.lock diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a0328ee --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,80 @@ +[build-system] +requires = ["setuptools", "setuptools_scm[toml]", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "mopti" +dynamic = ["version"] +description = "Tools for experimental design and multi-objective optimization" +authors = [ + {name = "BASF SE"} +] +license = {text = "BSD-3-Clause"} +readme = "README.md" +requires-python = ">=3.7" +keywords = [ + "Bayesian optimization", + "Multi-objective optimization", + "Experimental design", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3 :: Only", + "License :: OSI Approved :: BSD License", + "Topic :: Scientific/Engineering", + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", +] +dependencies = [ + "numpy", + "pandas", + "scipy>=1.7", +] + +[dependency-groups] +tests = [ + "pytest", + "scikit-learn", +] +docs = [ + "mkdocs", + "mkdocs-material", + "mkdocstrings[python]", +] +dev = [ + "pytest", + "scikit-learn", + "mkdocs", + "mkdocs-material", + "mkdocstrings[python]", + "pre-commit", +] + +[tool.setuptools] +packages = ["opti"] + +[tool.setuptools.package-data] +"*" = ["problems/data/*"] + +[tool.setuptools_scm] +write_to = "opti/_version.py" + +[tool.ruff] +line-length = 88 + +[tool.ruff.lint] +ignore = [ + "E501", # don't enforce for comments and docstrings +] +select = ["B", "C", "E", "F", "W", "I"] + +[tool.uv] +dev-dependencies = [ + "pytest", + "scikit-learn", + "mkdocs", + "mkdocs-material", + "mkdocstrings[python]", + "pre-commit", +] +package = true From b21b76f4168470c2177c34424f24c3f0b0d43038 Mon Sep 17 00:00:00 2001 From: Rosona Eldred Date: Tue, 22 Jul 2025 14:04:18 +0200 Subject: [PATCH 3/4] row_stack to vstack replacement --- opti/sampling/polytope.py | 2 +- test/test_sampling.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opti/sampling/polytope.py b/opti/sampling/polytope.py index 6a0354e..5edf70a 100644 --- a/opti/sampling/polytope.py +++ b/opti/sampling/polytope.py @@ -116,7 +116,7 @@ def _get_AbNx(parameters, constraints): # add the inequality constraints corresponding to the box bounds lower = parameters.bounds.loc["min"] upper = parameters.bounds.loc["max"] - A_ineq = np.row_stack([-np.eye(nD), np.eye(nD)]) + A_ineq = np.vstack([-np.eye(nD), np.eye(nD)]) b_ineq = np.r_[-np.array(lower), np.array(upper)] if sum(~is_eq) > 0: diff --git a/test/test_sampling.py b/test/test_sampling.py index 3951406..a4e8d59 100644 --- a/test/test_sampling.py +++ b/test/test_sampling.py @@ -46,7 +46,7 @@ def test_sphere_sampling(): def test_polytope_chebyshev_center(): - A = np.row_stack([-np.eye(3), np.eye(3)]) + A = np.vstack([-np.eye(3), np.eye(3)]) b = np.r_[-np.zeros(3), np.ones(3)] x0 = polytope._chebyshev_center(A, b) assert np.allclose(x0, [0.5, 0.5, 0.5]) From 9aa7614d4c2c95fde8257b3084cd88cd73534ed6 Mon Sep 17 00:00:00 2001 From: Rosona Eldred Date: Tue, 22 Jul 2025 14:07:09 +0200 Subject: [PATCH 4/4] might've messed up the pipeline with my pyproject.toml, so deleted --- pyproject.toml | 80 -------------------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index a0328ee..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,80 +0,0 @@ -[build-system] -requires = ["setuptools", "setuptools_scm[toml]", "wheel"] -build-backend = "setuptools.build_meta" - -[project] -name = "mopti" -dynamic = ["version"] -description = "Tools for experimental design and multi-objective optimization" -authors = [ - {name = "BASF SE"} -] -license = {text = "BSD-3-Clause"} -readme = "README.md" -requires-python = ">=3.7" -keywords = [ - "Bayesian optimization", - "Multi-objective optimization", - "Experimental design", -] -classifiers = [ - "Development Status :: 4 - Beta", - "Programming Language :: Python :: 3 :: Only", - "License :: OSI Approved :: BSD License", - "Topic :: Scientific/Engineering", - "Intended Audience :: Science/Research", - "Intended Audience :: Developers", -] -dependencies = [ - "numpy", - "pandas", - "scipy>=1.7", -] - -[dependency-groups] -tests = [ - "pytest", - "scikit-learn", -] -docs = [ - "mkdocs", - "mkdocs-material", - "mkdocstrings[python]", -] -dev = [ - "pytest", - "scikit-learn", - "mkdocs", - "mkdocs-material", - "mkdocstrings[python]", - "pre-commit", -] - -[tool.setuptools] -packages = ["opti"] - -[tool.setuptools.package-data] -"*" = ["problems/data/*"] - -[tool.setuptools_scm] -write_to = "opti/_version.py" - -[tool.ruff] -line-length = 88 - -[tool.ruff.lint] -ignore = [ - "E501", # don't enforce for comments and docstrings -] -select = ["B", "C", "E", "F", "W", "I"] - -[tool.uv] -dev-dependencies = [ - "pytest", - "scikit-learn", - "mkdocs", - "mkdocs-material", - "mkdocstrings[python]", - "pre-commit", -] -package = true