Skip to content

Commit 299a233

Browse files
committed
Fixed bug in get_idxs_node
1 parent 462e362 commit 299a233

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

exodus_helper/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,8 +1269,8 @@ def get_idxs_node(self, ids_node):
12691269
Returns:
12701270
A `numpy.ndarray` of node indices (int)
12711271
"""
1272-
elem_id_map = self.get_elem_id_map()
1273-
return np.array([np.where(elem_id_map == i)[0][0] for i in ids_node])
1272+
node_id_map = self.get_node_id_map()
1273+
return np.array([np.where(node_id_map == i)[0][0] for i in ids_node])
12741274

12751275
def get_info_records(self) -> list:
12761276
"""Get a list of info records where each entry in the list is one info

tests/test_exodus_helper.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,24 @@ def test_get_idxs_elem_start_blk(mesh):
654654
assert idxs[0] == 0 and idxs[1] == 2
655655

656656

657+
def test_get_idxs_elem(mesh):
658+
ids = mesh.get_elem_id_map()
659+
np.random.shuffle(ids)
660+
mesh.put_elem_id_map(ids)
661+
idxs = mesh.get_idxs_elem(ids)
662+
assert np.all(idxs == np.arange(mesh.get_num_elems()))
663+
mesh.put_elem_id_map(np.sort(ids))
664+
665+
666+
def test_get_idxs_node(mesh):
667+
ids = mesh.get_node_id_map()
668+
np.random.shuffle(ids)
669+
mesh.put_node_id_map(ids)
670+
idxs = mesh.get_idxs_node(ids)
671+
assert np.all(idxs == np.arange(mesh.get_num_nodes()))
672+
mesh.put_node_id_map(np.sort(ids))
673+
674+
657675
def test_get_info_records(mesh):
658676
assert 'info_records' in mesh.dataset.variables
659677
assert 'num_info' in mesh.dataset.dimensions

0 commit comments

Comments
 (0)