Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.pipelines
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.pipelines
Commits
b6e6a4c3
Commit
b6e6a4c3
authored
4 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Created a method that emulates isinsntace for aggregation
parent
c63f78a3
No related branches found
No related tags found
1 merge request
!32
Created a method that emulates isinsntace for aggregation
Pipeline
#40513
passed
4 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/pipelines/utils.py
+6
-6
6 additions, 6 deletions
bob/pipelines/utils.py
with
6 additions
and
6 deletions
bob/pipelines/utils.py
+
6
−
6
View file @
b6e6a4c3
...
@@ -189,7 +189,7 @@ def vstack_features(reader, paths, same_size=False, dtype=None):
...
@@ -189,7 +189,7 @@ def vstack_features(reader, paths, same_size=False, dtype=None):
return
np
.
reshape
(
all_features
,
shape
,
order
=
"
C
"
)
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.
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):
...
@@ -201,20 +201,20 @@ def isinstance_nested(instance, method, isinstance_of):
instance:
instance:
Object to be searched
Object to be searched
method
:
attribute
:
Method name
Attribute name to be recursively searched
isinstance_of:
isinstance_of:
Instance class to be searched
Instance class to be searched
"""
"""
if
method
not
in
instance
.
__dict__
:
if
not
hasattr
(
instance
,
attribute
)
:
return
False
return
False
# Checking the current object and its immediate nested
# 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
return
True
else
:
else
:
# Recursive search
# Recursive search
return
isinstance_nested
(
instance
.
__dict__
[
method
],
method
,
isinstance_of
)
return
isinstance_nested
(
getattr
(
instance
,
attribute
),
attribute
,
isinstance_of
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment