-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[bug] Fix name collision in ti.dataclass #6737
Conversation
✅ Deploy Preview for docsite-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Use foo = ti.Struct(...)
if type(foo) is ti.Struct:
# do something
pass Use If setter has the same requirements as class Struct(TaichiOperations):
# remove _register_members, _make_getter and _make_setter
def __getattr__(self, name):
try:
return self[name]
except KeyError:
raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") from None
def __setattr__(self, name, value):
if name not in self.entries:
return super().__setattr__(name, value)
self[name] = value This implementation has an additional benefit: raise correct Error( |
Sounds good! @YouJiacheng Are you interested in sending a PR for this?
Because in taichi scope |
Hmmm, IIUC attribute assignment will be handled by the AST transformer as well. I will send a PR for this after my final exam(2023.1.4). |
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Issue: fix #6652
Brief Summary
Properties should be added to a certain
Struct
instance instead of theStruct
class itself.