-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NSETM-2226] Add NodeSets adapter to support custom node_sets_file (#22)
Support custom node_sets_file in extraction, neuron_classes and trial_steps
- Loading branch information
1 parent
ce3c457
commit f2d21f2
Showing
52 changed files
with
522 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Implementations.""" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Bluepysnap NodeSets implementation.""" | ||
|
||
from bluepysnap.node_sets import NodeSets | ||
|
||
from blueetl.adapters.interfaces.node_sets import NodeSetsInterface | ||
|
||
|
||
class NodeSetsImpl(NodeSetsInterface[NodeSets]): | ||
"""Bluepysnap NodeSets implementation.""" | ||
|
||
def update(self, other: NodeSetsInterface) -> None: | ||
"""Update the wrapped node sets.""" | ||
self._node_sets.update(other.instance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"""Interfaces for Simulation and Circuit.""" | ||
"""Interfaces.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Interfaces for NodeSets.""" | ||
|
||
from abc import ABC, abstractmethod | ||
from typing import Generic, TypeVar | ||
|
||
NodeSetsT = TypeVar("NodeSetsT") | ||
|
||
|
||
class NodeSetsInterface(Generic[NodeSetsT], ABC): | ||
"""NodeSets Interface.""" | ||
|
||
def __init__(self, node_sets: NodeSetsT) -> None: | ||
"""Init the NodeSets interface with the specified NodeSetsT.""" | ||
self._node_sets = node_sets | ||
|
||
@property | ||
def instance(self) -> NodeSetsT: | ||
"""Return the wrapped instance.""" | ||
return self._node_sets | ||
|
||
@abstractmethod | ||
def update(self, other: "NodeSetsInterface") -> None: | ||
"""Update the wrapped node sets.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Adapters for NodeSets.""" | ||
|
||
from pathlib import Path | ||
from typing import Optional | ||
|
||
from blueetl.adapters.base import BaseAdapter | ||
from blueetl.adapters.interfaces.node_sets import NodeSetsInterface | ||
|
||
|
||
class NodeSetsAdapter(BaseAdapter[NodeSetsInterface]): | ||
"""NodeSets Adapter.""" | ||
|
||
@classmethod | ||
def from_file(cls, filepath: Optional[Path]) -> "NodeSetsAdapter": | ||
"""Load and return a new object from file.""" | ||
# pylint: disable=import-outside-toplevel | ||
from blueetl.adapters.impl.bluepysnap.node_sets import NodeSets, NodeSetsImpl | ||
|
||
if not filepath: | ||
impl = NodeSetsImpl(NodeSets.from_dict({})) | ||
else: | ||
impl = NodeSetsImpl(NodeSets.from_file(str(filepath))) | ||
return cls(impl) | ||
|
||
def update(self, other: "NodeSetsAdapter") -> None: | ||
"""Update the node sets.""" | ||
# pylint: disable=protected-access | ||
self._ensure_impl.update(other._ensure_impl) | ||
|
||
def __ior__(self, other: "NodeSetsAdapter") -> "NodeSetsAdapter": | ||
"""Support ``A |= B``.""" | ||
self.update(other) | ||
return self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.