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

mnt: fixed and simplified some logic in the read_multiple function #2

Merged

Conversation

zerothi
Copy link

@zerothi zerothi commented Mar 7, 2023

It should now be able to handle more cases and more easily transfer data to a required data-structure.

Added an xyz skip function which is much faster than the read_geometry call.

Changed default all=True for the ANI file.
Changed the suffix for ANI files to be capitalized.

Added a postprocess function for post-processing the data returned by the read_multiple function. This would enable one to merge stuff etc.


Returns
-------
single entry or list from multiple reads
"""
def decorator(func):
# ensure we can access the callables
nonlocal skip_call, pre_call, post_call, postprocess
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the nonlocal ensures that the variables are kept in scope

It should now be able to handle more cases and more easily transfer
data to a required data-structure.

Added an xyz skip function which is much faster than the read_geometry
call.

Changed default all=True for the ANI file.
Changed the suffix for ANI files to be capitalized.

Added a postprocess function for post-processing the data returned
by the read_multiple function. This would enable one to merge stuff etc.

Signed-off-by: Nick Papior <[email protected]>
# they should be equivalent but skip can be used to
# skip some processing of the read data.
if skip_call is None:
skip_call = wrap_func
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I came to think that a skip_call should not do any of the pre_call and post_call since then it can be used in larger chunks of files. Say complicated files that doesn't really fit regular data files.

It may be weird for users supplying a skip call to be wrapped with the pre and post if they are not needed. It is simpler to manually put them in if needed.

r = skip_call(self, *args, **kwargs)
post_call()
return r
def multiple(*args, start=start, stop=stop, step=step, all=all, **kwargs):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fault was that * is not required when you have *args. All arguments between *args and **kwargs are keyword only arguments! So nothing needs to be changed.

@zerothi zerothi mentioned this pull request Mar 8, 2023
@tfrederiksen tfrederiksen merged commit a7f81b3 into tfrederiksen:aniSileSiesta Mar 8, 2023
@tfrederiksen
Copy link
Owner

Looks good. Thanks!

@zerothi zerothi deleted the aniSileSiesta-changes-1 branch March 8, 2023 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants