Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enstools-compression
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container 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
w2w
enstools-compression
Commits
d89ceb6b
Commit
d89ceb6b
authored
1 year ago
by
oriol.tinto
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for constant arrays and variables without lat_lon
parent
e899d4da
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!19
Fix issues with the analysis of arrays with constant values
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_analyzer.py
+30
-2
30 additions, 2 deletions
tests/test_analyzer.py
with
30 additions
and
2 deletions
tests/test_analyzer.py
+
30
−
2
View file @
d89ceb6b
...
...
@@ -15,6 +15,32 @@ class TestAnalyzer(TestClass):
input_path
=
input_tempdir
/
ds
analyze_files
(
file_paths
=
[
input_path
])
def
test_analyzer_constant_array
(
self
):
import
enstools.compression.xr_accessor
# noqa
import
numpy
as
np
import
xarray
as
xr
shape
=
(
100
,
100
,
100
)
data
=
np
.
zeros
(
shape
)
data_array
=
xr
.
DataArray
(
data
)
# Expect a warning about constant values
with
pytest
.
warns
(
UserWarning
,
match
=
"
All values in the variable .* are constant.
"
):
specs
,
metrics
=
data_array
.
compression
.
analyze
()
data_array
.
compression
(
specs
)
def
test_analyzer_without_lat_lon
(
self
):
import
enstools.compression.xr_accessor
# noqa
import
numpy
as
np
import
xarray
as
xr
shape
=
(
100
,
100
,
100
)
data
=
np
.
random
.
random
(
size
=
shape
)
data_array
=
xr
.
DataArray
(
data
)
specs
,
metrics
=
data_array
.
compression
.
analyze
()
data_array
.
compression
(
specs
)
def
test_zfp_analyzer
(
self
):
from
enstools.compression.api
import
analyze_files
input_tempdir
=
self
.
input_directory_path
...
...
@@ -60,8 +86,9 @@ class TestAnalyzer(TestClass):
for
var
in
metrics
:
if
abs
(
metrics
[
var
][
cr_label
]
-
thresholds
[
cr_label
])
>
TOLERANCE
:
raise
AssertionError
(
f
"
Case:
{
input_path
.
name
}
.The resulting compression ratio of
{
metrics
[
var
][
cr_label
]
:
.
2
f
}
"
f
"
x is not close enough to the target of
{
thresholds
[
cr_label
]
:
.
2
f
}
"
)
raise
AssertionError
(
f
"
Case:
{
input_path
.
name
}
.The resulting compression ratio of
{
metrics
[
var
][
cr_label
]
:
.
2
f
}
"
f
"
x is not close enough to the target of
{
thresholds
[
cr_label
]
:
.
2
f
}
"
)
def
test_sz_analyzer
(
self
):
from
enstools.compression.api
import
analyze_files
...
...
@@ -85,6 +112,7 @@ class TestAnalyzer(TestClass):
compressor
=
"
zfp
"
,
mode
=
"
rate
"
,
)
def
test_rmse
(
self
):
from
enstools.compression.api
import
analyze_files
input_tempdir
=
self
.
input_directory_path
...
...
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