Skip to content

Commit

Permalink
Merge pull request #2913 from nicolossus/fix_issue_2790
Browse files Browse the repository at this point in the history
Add support for more addition operations for `NodeCollection`
  • Loading branch information
heplesser authored Sep 10, 2023
2 parents 0d9715d + ce57bad commit ee4cf9b
Show file tree
Hide file tree
Showing 11 changed files with 1,258 additions and 877 deletions.
20 changes: 14 additions & 6 deletions pynest/nest/lib/hl_api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@
Classes defining the different PyNEST types
"""

from ..ll_api import sli_func, sps, sr, spp, take_array_index
import json
import numbers
from math import floor, log

import numpy

from .. import pynestkernel as kernel
from ..ll_api import sli_func, spp, sps, sr, take_array_index
from .hl_api_helper import (
broadcast,
get_parameters,
Expand All @@ -35,10 +41,6 @@
)
from .hl_api_simulation import GetKernelStatus

import numpy
import json
from math import floor, log

try:
import pandas

Expand Down Expand Up @@ -216,10 +218,16 @@ def __iter__(self):

def __add__(self, other):
if not isinstance(other, NodeCollection):
raise NotImplementedError()
if isinstance(other, numbers.Number) and other == 0:
other = NodeCollection()
else:
raise TypeError(f"Cannot add object of type '{type(other).__name__}' to 'NodeCollection'")

return sli_func("join", self._datum, other._datum)

def __radd__(self, other):
return self + other

def __getitem__(self, key):
if isinstance(key, slice):
if key.start is None:
Expand Down
Loading

0 comments on commit ee4cf9b

Please sign in to comment.