Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More useful message when caling a Map #24

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading