Skip to content

Commit

Permalink
Release v0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dilpath committed Jul 2, 2024
2 parents 9d2879f + 877087a commit b0e0e54
Show file tree
Hide file tree
Showing 37 changed files with 555 additions and 352 deletions.
19 changes: 0 additions & 19 deletions .flake8

This file was deleted.

9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## 0.4 series

This series contains many changes related to the new `petab.v2` subpackage. `petab.v2` should not be considered stable; the `petab.v2` API may change rapidly until we release libpetab-python v1.0.0.

### 0.4.1

* Fix: keep previously-optional dependencies optional by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/298
* Add petab.v2.C by @dweindl in https://github.com/PEtab-dev/libpetab-python/pull/299

**Full Changelog**: https://github.com/PEtab-dev/libpetab-python/compare/v0.4.0...v0.4.1

### 0.4.0

**Prepare for PEtab v2**
Expand Down
1 change: 1 addition & 0 deletions doc/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ API Reference
petab.v1.visualize
petab.v1.yaml
petab.v2
petab.v2.C
petab.v2.lint
petab.v2.problem
5 changes: 0 additions & 5 deletions petab/C.py

This file was deleted.

111 changes: 53 additions & 58 deletions petab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,69 @@
PEtab global
============
.. warning::
All functions in here are deprecated. Use the respective functions from
:mod:`petab.v1` instead.
Attributes:
ENV_NUM_THREADS:
Name of environment variable to set number of threads or processes
PEtab should use for operations that can be performed in parallel.
By default, all operations are performed sequentially.
"""
import functools
import inspect
import importlib
import sys
import warnings
from functools import partial
from pathlib import Path
from warnings import warn

# deprecated imports
from petab.v1 import * # noqa: F403, F401, E402

from .v1.format_version import __format_version__ # noqa: F401, E402

# __all__ = [
# 'ENV_NUM_THREADS',
# ]

ENV_NUM_THREADS = "PETAB_NUM_THREADS"


def _deprecated_v1(func):
"""Decorator for deprecation warnings for functions."""

@functools.wraps(func)
def new_func(*args, **kwargs):
warnings.warn(
f"petab.{func.__name__} is deprecated, "
f"please use petab.v1.{func.__name__} instead.",
category=DeprecationWarning,
stacklevel=2,
__all__ = ["ENV_NUM_THREADS"]


def __getattr__(name):
if attr := globals().get(name):
return attr
if name == "v1":
return importlib.import_module("petab.v1")
if name != "__path__":
warn(
f"Accessing `petab.{name}` is deprecated and will be removed in "
f"the next major release. Please use `petab.v1.{name}` instead.",
DeprecationWarning,
stacklevel=3,
)
return func(*args, **kwargs)
return getattr(importlib.import_module("petab.v1"), name)

return new_func


def _deprecated_import_v1(module_name: str):
"""Decorator for deprecation warnings for modules."""
warn(
f"The '{module_name}' module is deprecated and will be removed "
f"in the next major release. Please use "
f"'petab.v1.{module_name.removeprefix('petab.')}' "
"instead.",
DeprecationWarning,
stacklevel=2,
)


__all__ = [
x
for x in dir(sys.modules[__name__])
if not x.startswith("_")
and x not in {"sys", "warnings", "functools", "warn", "inspect"}
]


# apply decorator to all functions in the module
for name in __all__:
obj = globals().get(name)
if callable(obj) and inspect.isfunction(obj):
globals()[name] = _deprecated_v1(obj)
del name, obj
def v1getattr(name, module):
if name != "__path__":
warn(
f"Accessing `petab.{name}` is deprecated and will be removed in "
f"the next major release. Please use `petab.v1.{name}` instead.",
DeprecationWarning,
stacklevel=3,
)
try:
return module.__dict__[name]
except KeyError:
raise AttributeError(name) from None


# Create dummy modules for all old modules
v1_root = Path(__file__).resolve().parent / "v1"
v1_objects = [f.relative_to(v1_root) for f in v1_root.rglob("*")]
for v1_object in v1_objects:
if "__pycache__" in str(v1_object):
continue
if v1_object.suffix not in ["", ".py"]:
continue
if not (v1_root / v1_object).exists():
raise ValueError(v1_root / v1_object)
v1_object_parts = [*v1_object.parts[:-1], v1_object.stem]
module_name = ".".join(["petab", *v1_object_parts])

try:
real_module = importlib.import_module(
f"petab.v1.{'.'.join(v1_object_parts)}"
)
real_module.__getattr__ = partial(v1getattr, module=real_module)
sys.modules[module_name] = real_module
except ModuleNotFoundError:
pass
7 changes: 0 additions & 7 deletions petab/calculate.py

This file was deleted.

7 changes: 0 additions & 7 deletions petab/composite_problem.py

This file was deleted.

8 changes: 0 additions & 8 deletions petab/conditions.py

This file was deleted.

7 changes: 0 additions & 7 deletions petab/core.py

This file was deleted.

9 changes: 0 additions & 9 deletions petab/lint.py

This file was deleted.

7 changes: 0 additions & 7 deletions petab/mapping.py

This file was deleted.

9 changes: 0 additions & 9 deletions petab/math/__init__.py

This file was deleted.

5 changes: 0 additions & 5 deletions petab/math/sympify.py

This file was deleted.

7 changes: 0 additions & 7 deletions petab/measurements.py

This file was deleted.

7 changes: 0 additions & 7 deletions petab/models/__init__.py

This file was deleted.

7 changes: 0 additions & 7 deletions petab/models/model.py

This file was deleted.

7 changes: 0 additions & 7 deletions petab/models/pysb_model.py

This file was deleted.

5 changes: 0 additions & 5 deletions petab/models/sbml_model.py

This file was deleted.

8 changes: 0 additions & 8 deletions petab/observables.py

This file was deleted.

7 changes: 0 additions & 7 deletions petab/parameter_mapping.py

This file was deleted.

7 changes: 0 additions & 7 deletions petab/parameters.py

This file was deleted.

7 changes: 0 additions & 7 deletions petab/simplify.py

This file was deleted.

8 changes: 0 additions & 8 deletions petab/simulate.py

This file was deleted.

Loading

0 comments on commit b0e0e54

Please sign in to comment.