Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add a lambdify func. that throws ModuleNotFoundError when numpy missing #432

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

Merged
merged 3 commits into from
Mar 20, 2023

Conversation

bjodah
Copy link
Contributor

@bjodah bjodah commented Feb 14, 2023

Currently numpy is an optional dependency. Which is confusing since we don't define lambdify, Lambdify and LambdifyCSE when it's missing.

This PR aims to reduce the surprise/confusion when that situation arises.

cf. sympy/sympy#24673 (comment)

Comment on lines 59 to 60
def lambdify(args, exprs, **kwargs):
raise ModuleNotFoundError("Cannot import numpy, which is required for `lambdify` to work")
Copy link
Member

Choose a reason for hiding this comment

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

Use a __getattr__ method here and raise an AttributeError with this error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, didn't know you could. Today I learned.. since 3.7 apparently.

@isuruf isuruf added this to the 0.10.0 milestone Mar 20, 2023
@isuruf
Copy link
Member

isuruf commented Mar 20, 2023

Merging without appveyor for now as the queue is long. Will revert if appveyor fails.

Thanks @bjodah

@isuruf isuruf merged commit 7b617f9 into symengine:master Mar 20, 2023
@bjodah bjodah deleted the define-lambdify-even-without-numpy branch March 21, 2023 05:59
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