Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Grib Processor
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Max Drexler
Grib Processor
Commits
133c16cc
Commit
133c16cc
authored
9 months ago
by
Max Drexler
Browse files
Options
Downloads
Patches
Plain Diff
testing xcd_lookup
parent
921e5100
Loading
Loading
1 merge request
!2
Switch to package setup
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
grib_processor/grib.py
+6
-5
6 additions, 5 deletions
grib_processor/grib.py
tests/test_grib.py
+20
-0
20 additions, 0 deletions
tests/test_grib.py
with
26 additions
and
5 deletions
grib_processor/grib.py
+
6
−
5
View file @
133c16cc
...
@@ -42,7 +42,7 @@ else:
...
@@ -42,7 +42,7 @@ else:
# Loaded using load_xcd_models()
# Loaded using load_xcd_models()
_XCD_MODELS
=
None
_XCD_MODELS
=
None
# default model_name, model_id
when
# default model_name, model_id
_XCD_MISSING
=
(
"
UNKWN
"
,
"
UNKWN
"
)
_XCD_MISSING
=
(
"
UNKWN
"
,
"
UNKWN
"
)
...
@@ -96,10 +96,11 @@ def load_xcd_models(
...
@@ -96,10 +96,11 @@ def load_xcd_models(
)
->
None
:
)
->
None
:
"""
Load the xcd models from the package.
"""
"""
Load the xcd models from the package.
"""
global
_XCD_MODELS
global
_XCD_MODELS
# This MUST match name of xcd file in grib_processor.data
if
_XCD_MODELS
is
None
:
data_path
=
resources
.
files
(
data
)
/
"
xcd_model_info.json
"
# This MUST match name of xcd file in grib_processor.data
with
data_path
.
open
(
"
r
"
)
as
xcd_data
:
data_path
=
resources
.
files
(
data
)
/
"
xcd_model_info.json
"
_XCD_MODELS
=
json
.
load
(
xcd_data
)
with
data_path
.
open
(
"
r
"
)
as
xcd_data
:
_XCD_MODELS
=
json
.
load
(
xcd_data
)
for
addtnl
in
addtnl_models
:
for
addtnl
in
addtnl_models
:
_XCD_MODELS
.
update
(
addtnl
)
_XCD_MODELS
.
update
(
addtnl
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_grib.py
0 → 100644
+
20
−
0
View file @
133c16cc
from
grib_processor.grib
import
xcd_lookup
,
load_xcd_models
def
test_custom_loading
():
"""
Test that loading a custom xcd model works with xcd_lookup.
Note: This is a leaky test, the custom model will be in following tests.
"""
f_lat
=
123
f_lon
=
456
rows
=
1
cols
=
5
g_id
=
6
m_name
=
"
custom_name
"
m_id
=
"
custom_id
"
c_model
=
{
str
(
f_lat
):
{
str
(
f_lon
):
{
str
(
rows
):
{
str
(
cols
):
{
str
(
g_id
):
[
m_name
,
m_id
]}}}}
}
load_xcd_models
(
c_model
)
assert
xcd_lookup
(
f_lat
,
f_lon
,
rows
,
cols
,
g_id
)
==
(
m_name
,
m_id
)
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