Skip to content

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

Open
@niuiniuin

Description

@niuiniuin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docDocumentation related issues & PRs

    Type

    No type

    Projects

    Status

    Untriaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions