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

use isinstance() to determine type rather than [] #1377

Merged
merged 8 commits into from
Jul 12, 2023

Conversation

xuelanghanbao
Copy link
Contributor

@xuelanghanbao xuelanghanbao commented Jul 8, 2023

#1376
Use isinstance() to determine tup[0] type rather than tup[0]==[]. When tup is passed in from self.w.append(array_ops_compat.hstack(wi)) in deepxde\data\fpde.py, line 474, tup[0]==[] can cause the following errors: ValueError: operands could not be broadcast together with shapes (172,) (0,)

@lululxvi
Copy link
Owner

lululxvi commented Jul 11, 2023

Good point. But here we want to check if it is an empty list, not only to check if it is a list.

@xuelanghanbao
Copy link
Contributor Author

Thank you for your explanation. I have a better understanding of the purpose of this code. So changing not is_tensor(tup[0]) to isinstance(tup[0],list) would be better, right?

@xuelanghanbao xuelanghanbao reopened this Jul 11, 2023
@lululxvi
Copy link
Owner

changing not is_tensor(tup[0]) to isinstance(tup[0],list) would be better, right?

Seems OK, but I am not 100% sure. It would be safer to use both.

use isinstance() to determine type rather than []

improve the way to check if tup[0] is empty list

add chack if tup[0] is tensor
@lululxvi lululxvi merged commit 1fbecf2 into lululxvi:master Jul 12, 2023
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