Merged
Conversation
eval_functions.py - add asteval functions, replacing eval - change find_identifiers to use astval_get_ast_names - defaults in generate_namespace are no longer generated for builtins - prepare_expression() added - eval_hdf refactored pyproject.toml - added asteval tests - eval 'np.max' changed to 'max' in tests - tests pass
eval_functions.py
- added d_*name* pattern to generate_namespace
- added to doc strings about this
- removed check_unsafe_eval as no longer required
- added generate_image_roi_slice() although not currently used.
- added create_interpreter() although not currently used
hdfmap_class.py
- added __call__('expression') behaviour
examples
- added example_eval_hdf.py
docs
- various changes to README.md, docs
tests
- added additional tests to test_hdfmap_class.py for eval patterns
- corrected test in test_edge_cases.py for asteval
- all tests pass
PeterC-DLS
reviewed
Jul 28, 2025
PeterC-DLS
reviewed
Jul 28, 2025
PeterC-DLS
reviewed
Jul 28, 2025
src/hdfmap/eval_functions.py
Outdated
| @@ -261,56 +252,58 @@ def generate_namespace(hdf_file: h5py.File, hdf_namespace: dict[str, str], ident | |||
| for name in identifiers | |||
| if name.startswith('s_') and hdf_namespace.get(name[2:]) and hdf_namespace[name[2:]] in hdf_file | |||
Collaborator
There was a problem hiding this comment.
Make this a function and re-use it. Also you can simplify to hdf_namespace.get(name[:2]) in hdf_file
PeterC-DLS
reviewed
Jul 28, 2025
PeterC-DLS
reviewed
Jul 28, 2025
Co-authored-by: Peter Chang <peter.chang@diamond.ac.uk>
…into replace_evil_eval_with_asteval
PeterC-DLS
reviewed
Jul 28, 2025
also: - changes to docs - added example eval_performance_time.py
Collaborator
Author
|
Thanks very much @PeterC-DLS for the review! I'll merge this now. |
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.
Add asteval as a dependency and add some new behaviours for the eval_hdf function.
This provides a fix for #27
Main changes
eval_functions.py
hdfmap_class.py
pyproject.toml
examples
docs
tests
np.removed in expressions as asteval populates namespace with numpy functions