Skip to content

Commit 8c965c9

Browse files
committed
Make node.higher_nodes a list, instead of a set
This way the model provides that, e.g. for each face there can be a principal neighbouring volume (master/owner) and a secondary neighbouring volume (slave).
1 parent e34cf61 commit 8c965c9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

splipy/SplineModel.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from splipy.utils import *
55
import splipy.state as state
66
import numpy as np
7-
from collections import Counter
7+
from collections import Counter, defaultdict
88
from itertools import chain, product, permutations
99

1010
try:
@@ -284,7 +284,7 @@ def __init__(self, catalogue, obj, lower_nodes):
284284
self.catalogue = catalogue
285285
self.obj = obj
286286
self.lower_nodes = lower_nodes
287-
self.higher_nodes = {}
287+
self.higher_nodes = defaultdict(list)
288288

289289
for dim_nodes in self.lower_nodes:
290290
for node in dim_nodes:
@@ -296,7 +296,7 @@ def pardim(self):
296296

297297
def assign_higher(self, node):
298298
"""Add a link to a node of higher dimension."""
299-
self.higher_nodes.setdefault(node.pardim, set()).add(node)
299+
self.higher_nodes[node.pardim].append(node)
300300

301301
def view(self, other_obj=None):
302302
"""Return a `NodeView` object of this node.
@@ -402,7 +402,7 @@ def __init__(self, pardim, interior=True):
402402
self.pardim = pardim
403403

404404
# Internal mapping from tuples of lower-order nodes to lists of nodes
405-
self.internal = {}
405+
self.internal = defaultdict(list)
406406

407407
# Function for computing orientations
408408
self.make_orientation = (
@@ -474,7 +474,7 @@ def lookup(self, obj, add=False):
474474
# nodes. This is slight overkill since some of these permutations
475475
# are invalid, but c'est la vie.
476476
for p in permutations(lower_nodes[-1]):
477-
self.internal.setdefault(p, []).append(node)
477+
self.internal[p].append(node)
478478
return node.view()
479479

480480
def add(self, obj):

0 commit comments

Comments
 (0)