Add the ability to convert from/to awkward array#108
Open
AreWeDreaming wants to merge 14 commits intoiterorganization:developfrom
Open
Add the ability to convert from/to awkward array#108AreWeDreaming wants to merge 14 commits intoiterorganization:developfrom
AreWeDreaming wants to merge 14 commits intoiterorganization:developfrom
Conversation
- Wrangling works - Unwrangling awkward data needs work
Author
|
I am holding off on running black to keep the diff clean |
| from typing import List, Tuple | ||
|
|
||
| import numpy | ||
| import awkward as ak |
Collaborator
There was a problem hiding this comment.
Can be removed from here and moved to actual usage..
Author
There was a problem hiding this comment.
Moved awkwardization into the wrangler.py
| if hdf5_dim == 0: | ||
| return self.filled_data[path][()].value | ||
| else: | ||
| return ak.Array(self.recursively_convert_to_list(path, tuple(), shape[:hdf5_dim], 0)) |
Collaborator
There was a problem hiding this comment.
Check if awkward is available
try:
import awkward as ak
except ImportError as exc:
raise ImportError(
"awkward-array is required"
"Install it with: pip install imas-python[awkward]"
) from exc
Need to add awkward dependency in pyproject.toml
imas/wrangler.py
Outdated
| return ids_locations | ||
|
|
||
| def unwrangle( | ||
| locations: List[str], ids_dict: Dict[str, IDSToplevel], version="3.41.0" |
Collaborator
There was a problem hiding this comment.
version is not used here
Author
There was a problem hiding this comment.
That's because I didn't know how to convert between IMAS versions. I would like to do to an automatic version transformation using this target version.
prasad-sawantdesai
requested changes
Mar 18, 2026
Handle version propagation more cleanly Co-authored-by: Prasad <prasad.sawantdesai@gmail.com>
Remove preference for specific version Co-authored-by: Prasad <prasad.sawantdesai@gmail.com>
…-Python into awkward_array_support
…is provided in unwrangle
AreWeDreaming
commented
Mar 20, 2026
| failed_locations = [] | ||
| for key in ids_locations: | ||
| ids = ids_dict[key] | ||
| if target_version is not None: |
Author
There was a problem hiding this comment.
This also should compare versions strings so we don't convert if we are already in the correct version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The tests (
imas/test/test_wrangle.py) that I have designed are passing now.The
wrangler.pyadds two functions,wrangleandunwrangle.wranglemethod takes the flat representation of the data and wrangles into the nested IDS.unwranglemethod takes a dictionary of ids and uses theIDSTensorizerto flatten out a defined list of entries.