Skip to content

Create the Network.clone method #180

@dglmoore

Description

@dglmoore

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...>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions