Skip to content

Commit

Permalink
Deprecate corneto.K for corneto.opt
Browse files Browse the repository at this point in the history
  • Loading branch information
pablormier committed May 9, 2024
1 parent 8f50d0b commit d88006e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
26 changes: 24 additions & 2 deletions corneto/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import sys
import warnings

from corneto import _plotting as pl
from corneto._constants import *
from corneto._graph import Attr, Attributes, EdgeType, Graph
from corneto._util import info
from corneto.backend import DEFAULT_BACKEND, DEFAULT_SOLVER, available_backends
from corneto.backend import DEFAULT_BACKEND as K
from corneto.backend import DEFAULT_BACKEND as ops

# from corneto.backend import DEFAULT_BACKEND as K # deprecate
# from corneto.backend import DEFAULT_BACKEND as ops # deprecate
from corneto.backend import DEFAULT_BACKEND as opt
from corneto.backend._base import HammingLoss as hamming_loss
from corneto.backend._base import Indicator, NonZeroIndicator

Expand All @@ -19,6 +22,25 @@
)
from corneto.utils import Attr, Attributes


class DeprecatedBackend:
def __init__(self, backend):
self._backend = backend

def __getattr__(self, attr):
warnings.warn(
"'corneto.K' and 'corneto.ops' are deprecated and will be removed in a future version. Use 'corneto.opt' instead.",
DeprecationWarning,
stacklevel=2,
)
return getattr(self._backend, attr)


# Wrapping the backend instance with the DeprecatedBackend
K = DeprecatedBackend(opt)
ops = DeprecatedBackend(opt)


__all__ = [
"Attr",
"EdgeType",
Expand Down
11 changes: 1 addition & 10 deletions corneto/backend/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,7 @@ def direction(self) -> Direction:
return self._direction

def copy(self) -> "ProblemDef":
# TODO: Fix copy! add tests
return ProblemDef(
self._backend,
self._constraints,
self._objectives,
self._expressions,
self._weights,
self._direction,
self._graph,
)
raise NotImplementedError()

def _add(self, other: Any, inplace: bool = False):
if isinstance(other, ProblemDef):
Expand Down
8 changes: 8 additions & 0 deletions docs/tutorials/context-specific-metabolic-omics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [],
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
Expand Down

0 comments on commit d88006e

Please sign in to comment.