Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create the Network.clone method #180

Open
dglmoore opened this issue Sep 9, 2019 · 0 comments
Open

Create the Network.clone method #180

dglmoore opened this issue Sep 9, 2019 · 0 comments

Comments

@dglmoore
Copy link
Contributor

dglmoore commented Sep 9, 2019

Description

Sometimes it's useful to be able to copy a network, particularly given we have mutating methods. As a motivating example, consider the global s_pombe network. If the user computes the its attractors, the result is cached inside of the global s_pombe object. This is bad hygiene!

Proposed API

class Network(LandscapeMixin, StateSpace):
    @abstractmethod
    def clone(self):
        pass

class WTNetwork(BooleanNetwork):
    def clone(self):
        return WTNetwork(np.copy(self.weights),
                         np.copy(self.thresholds),
                         np.copy(self.names),
                         self.theta)

Example Usage

>>> from neet.boolean.examples import s_pombe

>>> s_pombe_copy = s_pombe.clone()
<neet.boolean.wtnetwork.WTNetwork object at 0x...>
>>> s_pombe_copy.landscape()
<neet.boolean.wtnetwork.WTNetwork object at 0x...>

>>> s_pombe.landscape_data
None
>>> s_pombe_copy.landscape_data
<neet.landscape.LandscapeData object at 0x...>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant