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

The behavior of property method in the subclass inherited from a data oriented class may need more clarification in document #8580

Open
niuiniuin opened this issue Aug 10, 2024 · 0 comments
Labels
doc Documentation related issues & PRs

Comments

@niuiniuin
Copy link

When reading the document for Inheritance of Data-Oriented classes. I simply understand the data-oriented classes have the same behavior of inheritance as ordinary python classes.

However, I find the property method rewritten in the subclass cannot override the property method with the same name in the base class if the base class is decorated with @ti.data_oriented. A simple code can be used for test as below,

import taichi as ti

@ti.data_oriented
class BaseClass(object):
    @property
    def one_property(self):
        return "Property of super-class"
    @ti.kernel
    def compute(self):
        pass
    @ti.func
    def some_function(self):
        pass

class DeviatedClass(BaseClass): 
    @property
    def one_property(self):
        return "Property of sub-class"


a = DeviatedClass()
print(a.one_property)
# output: Property of super-class

where I expect it to output "Property of sub-class". However, it gives the output of "Property of super-class".

I am wondering whether this is a bug or by design. If it is the latter, I think it is essential to explain it in more detail in the document. Since it is a different behavior with ordinary python classes, and may cause very hidden problems in some situations.

@niuiniuin niuiniuin added the doc Documentation related issues & PRs label Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Documentation related issues & PRs
Projects
Status: Untriaged
Development

No branches or pull requests

1 participant