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
3
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
92f671f6
Commit
92f671f6
authored
4 months ago
by
Sebastian Müller
🐈
Browse files
Options
Downloads
Patches
Plain Diff
data.tools: move 'filled' to mask tools
parent
51d62c8d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!286
Add mask to Info object
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/finam/data/tools/__init__.py
+1
-1
1 addition, 1 deletion
src/finam/data/tools/__init__.py
src/finam/data/tools/core.py
+0
-35
0 additions, 35 deletions
src/finam/data/tools/core.py
src/finam/data/tools/mask.py
+35
-0
35 additions, 0 deletions
src/finam/data/tools/mask.py
with
36 additions
and
36 deletions
src/finam/data/tools/__init__.py
+
1
−
1
View file @
92f671f6
...
...
@@ -3,7 +3,6 @@
from
.core
import
(
assert_type
,
check
,
filled
,
full
,
full_like
,
has_time_axis
,
...
...
@@ -15,6 +14,7 @@ from .info import Info
from
.mask
import
(
Mask
,
check_data_covers_domain
,
filled
,
from_compressed
,
has_masked_values
,
is_masked_array
,
...
...
This diff is collapsed.
Click to expand it.
src/finam/data/tools/core.py
+
0
−
35
View file @
92f671f6
...
...
@@ -337,41 +337,6 @@ def _check_shape(shape, grid):
)
def
filled
(
data
,
fill_value
=
None
):
"""
Return input as an array with masked data replaced by a fill value.
This routine respects quantified and un-quantified data.
Parameters
----------
data : :class:`pint.Quantity` or :class:`numpy.ndarray` or :class:`numpy.ma.MaskedArray`
The reference object input.
fill_value : array_like, optional
The value to use for invalid entries. Can be scalar or non-scalar.
If non-scalar, the resulting ndarray must be broadcastable over
input array. Default is None, in which case, the `fill_value`
attribute of the array is used instead.
Returns
-------
pint.Quantity or numpy.ndarray
New object with the same shape and type as other,
with the data filled with fill_value.
Units will be taken from the input if present.
See also
--------
:func:`numpy.ma.filled`:
Numpy routine doing the same.
"""
if
not
is_masked_array
(
data
):
return
data
if
is_quantified
(
data
):
return
UNITS
.
Quantity
(
data
.
magnitude
.
filled
(
fill_value
),
data
.
units
)
return
data
.
filled
(
fill_value
)
def
assert_type
(
cls
,
slot
,
obj
,
types
):
"""
Type assertion.
"""
for
t
in
types
:
...
...
This diff is collapsed.
Click to expand it.
src/finam/data/tools/mask.py
+
35
−
0
View file @
92f671f6
...
...
@@ -55,6 +55,41 @@ def has_masked_values(data):
return
np
.
ma
.
is_masked
(
data
)
def
filled
(
data
,
fill_value
=
None
):
"""
Return input as an array with masked data replaced by a fill value.
This routine respects quantified and un-quantified data.
Parameters
----------
data : :class:`pint.Quantity` or :class:`numpy.ndarray` or :class:`numpy.ma.MaskedArray`
The reference object input.
fill_value : array_like, optional
The value to use for invalid entries. Can be scalar or non-scalar.
If non-scalar, the resulting ndarray must be broadcastable over
input array. Default is None, in which case, the `fill_value`
attribute of the array is used instead.
Returns
-------
pint.Quantity or numpy.ndarray
New object with the same shape and type as other,
with the data filled with fill_value.
Units will be taken from the input if present.
See also
--------
:func:`numpy.ma.filled`:
Numpy routine doing the same.
"""
if
not
is_masked_array
(
data
):
return
data
if
is_quantified
(
data
):
return
UNITS
.
Quantity
(
data
.
magnitude
.
filled
(
fill_value
),
data
.
units
)
return
data
.
filled
(
fill_value
)
def
to_masked
(
data
,
**
kwargs
):
"""
Return a masked version of the data.
...
...
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