-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add visualization & case utility libraries
- Loading branch information
1 parent
ecdf5b1
commit b0d9461
Showing
13 changed files
with
242 additions
and
185 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import re | ||
|
||
def remove_higher_dimensional_keys(case: dict, ndims: int) -> dict: | ||
assert 1 <= ndims <= 3 | ||
|
||
rm_dims = [set(), set(['y', 'z']), set(['z'])][ndims] | ||
dim_ids = {dim: i + 1 for i, dim in enumerate(['x', 'y', 'z'])} | ||
dim_mnp = {'x': 'm', 'y': 'n', 'z': 'p'} | ||
|
||
rm_keys = set() | ||
for key in case.keys(): | ||
for dim in rm_dims: | ||
if any([ | ||
re.match(f'.+_{dim}', key), re.match(f'{dim}_.+', key), | ||
re.match(f'%{dim}', key), f'%vel({dim_ids[dim]})' in key | ||
]): | ||
rm_keys.add(key) | ||
break | ||
|
||
new_case = {k: v for k, v in case.items() if k not in rm_keys} | ||
|
||
for dim in rm_dims: | ||
new_case[dim_mnp[dim]] = 0 | ||
|
||
return new_case |
This file contains 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
This file contains 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
Oops, something went wrong.