Skip to content

Commit

Permalink
More useful message when caling a Map
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Apr 25, 2024
1 parent 44e1ff2 commit a910cb2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pyop3/ir/lower.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ def compile(expr: Instruction, name="mykernel"):
textwrap.dedent(
"""
#include <stdlib.h>
int32_t cmpfunc(const void * a, const void * b) {
return ( *(int32_t*)a - *(int32_t*)b );
}
Expand Down
13 changes: 8 additions & 5 deletions pyop3/itree/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,14 @@ def __init__(self, connectivity, name=None, *, numbering=None) -> None:

def __call__(self, index):
if isinstance(index, (ContextFreeIndex, ContextFreeCalledMap)):
leaf_target_paths = tuple(
freeze({mcpt.target_axis: mcpt.target_component})
for path in index.leaf_target_paths
for mcpt in self.connectivity[path]
)
try:
leaf_target_paths = tuple(
freeze({mcpt.target_axis: mcpt.target_component})
for path in index.leaf_target_paths
for mcpt in self.connectivity[path]
)
except KeyError:
raise KeyError(f"Map does not have a suitable 'from index' that matches the provided index: {index.leaf_target_paths}")
return ContextFreeCalledMap(self, index, leaf_target_paths)
else:
return CalledMap(self, index)
Expand Down

0 comments on commit a910cb2

Please sign in to comment.