Skip to content

Commit

Permalink
Ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarow committed Aug 14, 2024
1 parent 959c86c commit 6fb2c63
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 20 deletions.
3 changes: 1 addition & 2 deletions scripts/create_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
from tempfile import TemporaryDirectory

import stactools.core.copy
from pystac import Catalog, CatalogType

import stactools.noaa_cdr.stac
from pystac import Catalog, CatalogType
from stactools.noaa_cdr.ocean_heat_content import stac as ocean_heat_content_stac
from stactools.noaa_cdr.sea_ice_concentration import stac as sea_ice_concentration_stac
from stactools.noaa_cdr.sea_surface_temperature_optimum_interpolation import (
Expand Down
3 changes: 1 addition & 2 deletions scripts/create_item_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
from tempfile import TemporaryDirectory

import orjson
from pystac import Item

import stactools.noaa_cdr.stac
from pystac import Item
from stactools.noaa_cdr.sea_ice_concentration import stac as sea_ice_stac
from stactools.noaa_cdr.sea_surface_temperature_optimum_interpolation import (
stac as oisst_stac,
Expand Down
3 changes: 1 addition & 2 deletions scripts/extract_netcdf_asset_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
from typing import Dict

import fsspec
import stactools.noaa_cdr.ocean_heat_content
import xarray
from tqdm import tqdm

import stactools.noaa_cdr.ocean_heat_content

metadata: Dict[str, Dict[str, str]] = {}
for href in tqdm(list(stactools.noaa_cdr.ocean_heat_content.iter_noaa_hrefs())):
key = os.path.splitext(os.path.basename(href))[0]
Expand Down
6 changes: 4 additions & 2 deletions src/stactools/noaa_cdr/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def build(
)
if not data_type:
raise ValueError(
f"No raster extension DataType found for numpy dtype: {data_array.dtype}"
f"No raster extension DataType found for numpy dtype:"
f"{data_array.dtype}"
)
if data_type.startswith("float"):
nodata: Any = numpy.nan
Expand Down Expand Up @@ -221,7 +222,8 @@ def needs_vertical_flip(self) -> bool:

def _parse_resolution(value: Any) -> float:
if isinstance(value, str):
# Assume that the first part is a number and the rest are units, e.g. for ocean heat content
# Assume that the first part is a number and the rest are units,
# e.g. for ocean heat content
return float(value.split(" ")[0])
else:
return float(value)
3 changes: 1 addition & 2 deletions src/stactools/noaa_cdr/sea_ice_concentration/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

import click
import pystac.utils
from click import Command, Group

import stactools.noaa_cdr.stac
from click import Command, Group
from stactools.noaa_cdr.sea_ice_concentration import stac


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import click
import pystac.utils
import stactools.noaa_cdr.stac
from click import Command, Group
from pystac import CatalogType

import stactools.noaa_cdr.stac

from . import stac


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import pystac.utils
from click import Command, Group
from pystac import ItemCollection

from stactools.noaa_cdr.sea_surface_temperature_whoi import stac


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from pystac.extensions.item_assets import AssetDefinition, ItemAssetsExtension
from pystac.extensions.raster import RasterExtension
from pystac.extensions.scientific import ScientificExtension

from stactools.noaa_cdr.profile import BandProfile

from .. import cog, dataset, stac, time
Expand Down
3 changes: 1 addition & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

import click
from click.testing import CliRunner, Result
from stactools.testing.test_data import TestData

from stactools.noaa_cdr import ocean_heat_content
from stactools.noaa_cdr.commands import create_noaa_cdr_command
from stactools.testing.test_data import TestData

external_data: Dict[str, Any] = {
"oisst-avhrr-v02r01.20220913.nc": {
Expand Down
1 change: 0 additions & 1 deletion tests/sea_ice_concentration/test_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pystac.extensions.projection import ProjectionExtension
from pystac.extensions.raster import RasterExtension
from pystac.extensions.scientific import ScientificExtension

from stactools.noaa_cdr.constants import CLASSIFICATION_EXTENSION_SCHEMA
from stactools.noaa_cdr.sea_ice_concentration import cog, stac

Expand Down
3 changes: 2 additions & 1 deletion tests/sea_surface_temperature_whoi/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def test_create_cog_items(tmp_path: Path) -> None:
"SEAFLUX-OSB-CDR_V02R00_SST_D20210831_C20211223.nc"
)
result = run_command(
f"noaa-cdr sea-surface-temperature-whoi create-cog-items {path} {tmp_path}/out.json"
f"noaa-cdr sea-surface-temperature-whoi create-cog-items {path} {tmp_path}"
"/out.json"
)
assert result.exit_code == 0, result.output
item_collection = ItemCollection.from_file(str(tmp_path / "out.json"))
Expand Down
1 change: 0 additions & 1 deletion tests/test_profile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import xarray

from stactools.noaa_cdr.profile import BandProfile

from . import test_data
Expand Down
1 change: 0 additions & 1 deletion tests/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Tuple

import pytest

from stactools.noaa_cdr import time
from stactools.noaa_cdr.time import TimeResolution

Expand Down

0 comments on commit 6fb2c63

Please sign in to comment.