Skip to content

Commit

Permalink
Adjust tests and revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoryPetrochenkov-NOAA committed Mar 25, 2024
1 parent 57d45f7 commit 79d7544
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1,091 deletions.
25 changes: 24 additions & 1 deletion src/gval/utils/loading_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Union, Optional, Tuple, Iterable
from numbers import Number
import ast
from collections import Counter

import pandas as pd
import rioxarray as rxr
Expand Down Expand Up @@ -262,13 +263,32 @@ def stac_to_df(
Raises
------
ValueError
Allow and block lists should be mutually exclusive
ValueError
No entries in DataFrame due to nonexistent asset
ValueError
There are no assets in this query to run a catalog comparison
"""

item_dfs, compare_idx = [], 1

# Check for mutually exclusive lists
if (
len(
list(
(
Counter(attribute_allow_list) & Counter(attribute_block_list)
).elements()
)
)
> 0
):
raise ValueError(
"There are no assets in this query to run a catalog comparison"
)

# Iterate through each STAC Item and make a unique row for each asset
for item in stac_items:
item_dict = item.to_dict()
Expand Down Expand Up @@ -297,7 +317,10 @@ def stac_to_df(
dfs.append(concat_df.loc[:, ~concat_df.columns.duplicated()])

if len(dfs) < 1:
raise ValueError()
raise ValueError(
"There are no assets in this query to run a catalog comparison. "
"Please revisit original query."
)

item_dfs.append(pd.concat(dfs, ignore_index=True))

Expand Down
Loading

0 comments on commit 79d7544

Please sign in to comment.