Commit b6e6a4c3 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Created a method that emulates isinsntace for aggregation

parent c63f78a3
Pipeline #40513 passed with stage
in 11 minutes and 50 seconds
......@@ -189,7 +189,7 @@ def vstack_features(reader, paths, same_size=False, dtype=None):
return np.reshape(all_features, shape, order="C")
def isinstance_nested(instance, method, isinstance_of):
def isinstance_nested(instance, attribute, isinstance_of):
"""
Check if an object and its nested objects is an instance of a class.
......@@ -201,20 +201,20 @@ def isinstance_nested(instance, method, isinstance_of):
instance:
Object to be searched
method:
Method name
attribute:
Attribute name to be recursively searched
isinstance_of:
Instance class to be searched
"""
if method not in instance.__dict__:
if not hasattr(instance, attribute):
return False
# Checking the current object and its immediate nested
if isinstance(instance,isinstance_of) or isinstance(instance.__dict__[method],isinstance_of):
if isinstance(instance,isinstance_of) or isinstance(getattr(instance, attribute), isinstance_of):
return True
else:
# Recursive search
return isinstance_nested(instance.__dict__[method], method, isinstance_of)
return isinstance_nested(getattr(instance, attribute), attribute, isinstance_of)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment