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

allow parsing function to add_py_function #549

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

martinvonk
Copy link
Contributor

@martinvonk martinvonk commented Nov 14, 2024

This PR allows for parsing a function/callable to the PstFrom.add_py_function method.

Originally, only a file name is allowed. This (separate) file was read, and the corresponding function in the file was added to the PstFrom class. Now you can directly add a function, available in the same script as the one where the PstFrom class is initialized.

Solves #527

@briochh
Copy link
Collaborator

briochh commented Nov 14, 2024

Hi @martinvonk, this looks like a nice touch. Do you think you could add to or amend a test to run this option? There should already be one in pst_from_tests that is hackily doing it the old way with a function in the current file.

@coveralls
Copy link

coveralls commented Nov 14, 2024

Coverage Status

coverage: 79.631% (+0.07%) from 79.565%
when pulling 8a52226 on martinvonk:py_function_callable
into 459eda8 on pypest:develop.

@martinvonk
Copy link
Contributor Author

martinvonk commented Nov 15, 2024

There are multiple test where the current method with __file__ is tested. So I took one line in the tests with:
pf.add_py_function(__file__, '_gen_dummy_obs_file()')
and replaced it with:
pf.add_py_function(_gen_dummy_obs_file, '_gen_dummy_obs_file()')

Hopefully that is what you wanted me to do :)

@briochh briochh merged commit 6080911 into pypest:develop Nov 15, 2024
14 checks passed
@briochh
Copy link
Collaborator

briochh commented Nov 15, 2024

Thank @martinvonk, good addition!

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