Skip to content

Commit

Permalink
Remove unused Model functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoV94 committed Jun 30, 2023
1 parent eb916f0 commit 3577573
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions pymc/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,56 +100,6 @@
]


class InstanceMethod:
"""Class for hiding references to instance methods so they can be pickled.
>>> self.method = InstanceMethod(some_object, 'method_name')
"""

def __init__(self, obj, method_name):
self.obj = obj
self.method_name = method_name

def __call__(self, *args, **kwargs):
return getattr(self.obj, self.method_name)(*args, **kwargs)


def incorporate_methods(source, destination, methods, wrapper=None, override=False):
"""
Add attributes to a destination object which point to
methods from from a source object.
Parameters
----------
source: object
The source object containing the methods.
destination: object
The destination object for the methods.
methods: list of str
Names of methods to incorporate.
wrapper: function
An optional function to allow the source method to be
wrapped. Should take the form my_wrapper(source, method_name)
and return a single value.
override: bool
If the destination object already has a method/attribute
an AttributeError will be raised if override is False (the default).
"""
for method in methods:
if hasattr(destination, method) and not override:
raise AttributeError(
f"Cannot add method {method!r}" + "to destination object as it already exists. "
"To prevent this error set 'override=True'."
)
if hasattr(source, method):
if wrapper is None:
setattr(destination, method, getattr(source, method))
else:
setattr(destination, method, wrapper(source, method))
else:
setattr(destination, method, None)


T = TypeVar("T", bound="ContextMeta")


Expand Down

0 comments on commit 3577573

Please sign in to comment.