Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
finam
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FINAM
finam
Commits
0ea98d01
Commit
0ea98d01
authored
1 year ago
by
Sebastian Müller
🐈
Browse files
Options
Downloads
Patches
Plain Diff
Grid: add 'check_mask' argument to 'compatible_with' method
parent
e1efdc4d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!258
Grid mask support
Pipeline
#178848
passed with stages
in 5 minutes and 35 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/finam/data/grid_base.py
+11
-7
11 additions, 7 deletions
src/finam/data/grid_base.py
src/finam/data/grid_spec.py
+6
-3
6 additions, 3 deletions
src/finam/data/grid_spec.py
with
17 additions
and
10 deletions
src/finam/data/grid_base.py
+
11
−
7
View file @
0ea98d01
...
...
@@ -162,7 +162,7 @@ class Grid(GridBase):
def
__repr__
(
self
):
return
f
"
{
self
.
__class__
.
__name__
}
(
{
self
.
dim
}
D)
{
self
.
data_shape
}
"
def
compatible_with
(
self
,
other
):
def
compatible_with
(
self
,
other
,
check_mask
=
True
):
"""
Check for compatibility with other Grid.
...
...
@@ -170,15 +170,14 @@ class Grid(GridBase):
----------
other : instance of Grid
Other grid to compatibility with.
check_mask : bool, optional
Whether to check mask equality, by default True
Returns
-------
bool
compatibility
"""
return
self
==
other
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
Grid
):
return
False
...
...
@@ -196,11 +195,14 @@ class Grid(GridBase):
if
self
.
data_shape
!=
other
.
data_shape
:
return
False
if
not
check_mask_equal
(
self
,
other
):
if
check_mask
and
not
check_mask_equal
(
self
,
other
):
return
False
return
np
.
allclose
(
self
.
data_points
,
other
.
data_points
)
def
__eq__
(
self
,
other
):
return
self
.
compatible_with
(
other
)
def
export_vtk
(
self
,
path
,
...
...
@@ -429,7 +431,7 @@ class StructuredGrid(Grid):
np
.
maximum
(
dims
-
1
,
1
)
if
self
.
data_location
==
Location
.
CELLS
else
dims
)
def
compatible_with
(
self
,
other
):
def
compatible_with
(
self
,
other
,
check_mask
=
True
):
"""
Check for compatibility with other Grid.
...
...
@@ -437,6 +439,8 @@ class StructuredGrid(Grid):
----------
other : instance of Grid
Other grid to compatibility with.
check_mask : bool, optional
Whether to check mask equality, by default True
Returns
-------
...
...
@@ -463,7 +467,7 @@ class StructuredGrid(Grid):
):
return
False
if
not
check_mask_equal
(
self
,
other
):
if
check_mask
and
not
check_mask_equal
(
self
,
other
):
return
False
return
all
(
np
.
allclose
(
a
,
b
)
for
a
,
b
in
zip
(
self
.
axes
,
other
.
axes
))
...
...
This diff is collapsed.
Click to expand it.
src/finam/data/grid_spec.py
+
6
−
3
View file @
0ea98d01
...
...
@@ -36,7 +36,8 @@ class NoGrid(GridBase):
def
__repr__
(
self
):
return
f
"
{
self
.
__class__
.
__name__
}
(
{
self
.
dim
}
D)
"
def
compatible_with
(
self
,
other
):
# pylint: disable-next=unused-argument
def
compatible_with
(
self
,
other
,
check_mask
=
True
):
"""
Check for compatibility with other Grid.
...
...
@@ -44,16 +45,18 @@ class NoGrid(GridBase):
----------
other : instance of Grid
Other grid to compatibility with.
check_mask : bool, optional
Whether to check mask equality, by default True
Returns
-------
bool
compatibility
"""
return
self
==
other
return
isinstance
(
other
,
NoGrid
)
and
self
.
dim
==
other
.
dim
def
__eq__
(
self
,
other
):
return
isinstance
(
other
,
NoGrid
)
and
self
.
dim
==
other
.
dim
return
self
.
compatible_with
(
other
)
class
RectilinearGrid
(
StructuredGrid
):
...
...
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