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

Added forward/backward derivatives for divergence on Cartesian grid #564

Merged
merged 2 commits into from
May 13, 2024

Conversation

david-zwicker
Copy link
Member

No description provided.


Returns:
A function that can be applied to an array of values
"""
if method not in {"central", "forward", "backward"}:

Choose a reason for hiding this comment

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

If you are using Literal, you don't need this check :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think I agree. Typing is optional in python, so a user could easily pass different values (for instance by mis-typing!) and those would not be caught at runtime. The check basically ensures that the right values were given at runtime, whereas the type hint helps developers with proper IDEs and type checking.

Choose a reason for hiding this comment

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

are you sure? Can you give an example?

If you look into the docs of Literal you can see that it is not optional, but you have to give a specified value.

But better double checking than not checking at all ;-)

@david-zwicker david-zwicker merged commit 911579f into master May 13, 2024
16 checks passed
@david-zwicker david-zwicker deleted the forw_back_diff branch May 13, 2024 11:29
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.

2 participants