Skip to content

Commit

Permalink
CatmaidNeuron multiplication/division: do not change -1 radii
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Apr 18, 2021
1 parent e3bebc5 commit 7686ade
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pymaid/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,24 @@ def __eq__(self, other):

return res

def __mul__(self, other):
"""Implement multiplication for coordinates (nodes, connectors)."""
# Exclude missing radii from multiplication
is_missing = self.nodes.radius == -1
n = super().__mul__(other)
n.nodes.loc[is_missing, 'radius'] = -1

return n

def __truediv__(self, other):
"""Implement division for coordinates (nodes, connectors)."""
# Exclude missing radii from division
is_missing = self.nodes.radius == -1
n = super().__mul__(other)
n.nodes.loc[is_missing, 'radius'] = -1

return n

def __hash__(self):
# DO NOT REMOVE THIS! When defining __eq__ in subclass, _hash__ will
# not be inherited and we have to explicitly define it
Expand Down

0 comments on commit 7686ade

Please sign in to comment.