Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ ignore = [
"BLE001", # blind-except
"C401", # unnecessary-generator-set
"C403", # unnecessary-list-comprehension-set
"C404", # unnecessary-list-comprehension-dict
"C414", # unnecessary-double-cast-or-process
"C901", # complex-structure
"D100", # undocumented-public-module
Expand Down Expand Up @@ -110,7 +109,6 @@ ignore = [
"N806", # non-lowercase-variable-in-function
"PD002", # pandas-use-of-inplace-argument
"PD011", # pandas-use-of-dot-values
"PERF401", # vmanual-list-comprehension
"PLC0415", # import-outside-top-level
"PLR0912", # too-many-branches
"PLR0913", # too-many-arguments
Expand Down Expand Up @@ -139,14 +137,10 @@ ignore = [
"PTH204", # os-path-getmtime
"PTH207", # glob
"PTH208", # os-listdir
"RET503", # implicit-return
"RET504", # unnecessary-assign
"RUF001", # ambiguous-unicode-character-string
"RUF002", # ambiguous-unicode-character-docstring
"RUF012", # mutable-class-default
"RUF013", # implicit-optional
"RUF015", # unnecessary-iterable-allocation-for-first-element
"RUF059", # unused-unpacked-variable
"S101", # assert
"S110", # try-except-pass
"S301", # suspicious-pickle-usage
Expand All @@ -156,14 +150,11 @@ ignore = [
"SIM102", # collapsible-if
"SIM105", # suppressible-exception
"SIM115", # open-file-with-context-handler
"SIM118", # in-dict-keys
"SIM212", # if-expr-with-twisted-arms
"SLF001", # private-member-access
"T201", # print
"TD002", # missing-todo-author
"TD003", # missing-todo-link
"TRY003", # raise-vanilla-args
"TRY004", # type-check-without-type-error
"TRY300", # try-consider-else
"UP031", # printf-string-formatting
]
9 changes: 4 additions & 5 deletions src/ivert/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,7 @@ def options_list(details):
from ivert.utils.configfile import Config, parse_option_descriptions

config = Config()
keys = [
k for k in config._config["DEFAULT"].keys() if k not in _OPTIONS_EXCLUDED_KEYS
]
keys = [k for k in config._config["DEFAULT"] if k not in _OPTIONS_EXCLUDED_KEYS]

if not keys:
click.echo("No configurable settings found.")
Expand Down Expand Up @@ -1502,10 +1500,11 @@ def _cache_dir():

def _fmt_size(nbytes):
"""Format a byte count as a human-readable string."""
for unit in ("B", "KB", "MB", "GB", "TB"):
if nbytes < 1024 or unit == "TB":
for unit in ("B", "KB", "MB", "GB"):
if nbytes < 1024:
return f"{nbytes:.1f} {unit}"
nbytes /= 1024
return f"{nbytes:.1f} TB"


@ivert_cli.group("cache", invoke_without_command=True)
Expand Down
5 changes: 4 additions & 1 deletion src/ivert/export_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def detect_nc_kind(nc_path: str) -> str | None:
# ---------------------------------------------------------------------------
# Core conversion
# ---------------------------------------------------------------------------
def nc_to_geodataframe(nc_path: str, classes: list = None) -> geopandas.GeoDataFrame:
def nc_to_geodataframe(
nc_path: str,
classes: list | None = None,
) -> geopandas.GeoDataFrame:
"""Read a single .nc granule file and return a GeoDataFrame.

Parameters
Expand Down
7 changes: 3 additions & 4 deletions src/ivert/icesat2_database_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import re
import shutil
from typing import ClassVar

import dateparser
import fetchez
Expand Down Expand Up @@ -417,7 +418,7 @@ def _vertical_datum_to_vertical_epsg(vertical_datum: str) -> str:
# to "ellipsoid" for any value it doesn't recognize (it does not raise), so
# passing an EPSG code straight through would be a silent no-op rather than
# an error -- always go through this lookup instead.
_EPSG_TO_GLOBATO_VERTICAL_DATUM = {
_EPSG_TO_GLOBATO_VERTICAL_DATUM: ClassVar[dict[str, str]] = {
"EPSG:4979": "ellipsoid",
"EPSG:3855": "geoid",
}
Expand Down Expand Up @@ -498,9 +499,7 @@ def _process_h5_to_nc(
use_external_masks=use_external_masks,
)

chunks = []
for chunk in stream:
chunks.append(pandas.DataFrame(chunk))
chunks = [pandas.DataFrame(chunk) for chunk in stream]

if not chunks:
return None
Expand Down
4 changes: 1 addition & 3 deletions src/ivert/plot_results_slope_centrality.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def add_lat_lons(df):
def get_slopes(df, files_dirname):
fnames = [os.path.join(files_dirname, fn) for fn in df.filename.unique()]
slope_fnames = [fn.replace("_results.h5", "_slope.tif") for fn in fnames]
fnames_dict = dict(
[(os.path.basename(fn), sfn) for fn, sfn in zip(fnames, slope_fnames)],
)
fnames_dict = {os.path.basename(fn): sfn for fn, sfn in zip(fnames, slope_fnames)}

fn_array_dict = {}
slopes = numpy.empty((len(df),), dtype=float)
Expand Down
4 changes: 2 additions & 2 deletions src/ivert/utils/query_yes_no.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def query_yes_no(question: str, default: str = "yes") -> bool:
elif default.strip().lower() in ("no", "n"):
prompt = " [y/N] "
else:
raise ValueError("invalid default answer: '%s'" % default)
raise ValueError(f"invalid default answer: '{default}'")

while True:
sys.stdout.write(question + prompt)
Expand All @@ -45,4 +45,4 @@ def interpret_yes_no(input_str: str) -> bool:
if instr[0] in ("n", "f"):
return False
# Anything else is invalid
raise ValueError("invalid boolean input: '%s'" % input_str)
raise ValueError(f"invalid boolean input: '{input_str}'")
4 changes: 2 additions & 2 deletions src/ivert/validate_dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ def _write_validation_outputs(
shared_ret_values["empty_results_filename"] = empty_results_filename
return files_to_export

base, ext = os.path.splitext(results_dataframe_file)
_base, ext = os.path.splitext(results_dataframe_file)
ext = ext.lower().strip()
if ext in (".txt", ".csv"):
results_dataframe.to_csv(results_dataframe_file)
Expand Down Expand Up @@ -2463,7 +2463,7 @@ def main(
output_dir=output_dir,
classes=classes_list,
dem_vertical_datum=input_vdatum,
interim_data_dir=(None if not datadir else datadir),
interim_data_dir=(datadir or None),
overwrite=overwrite,
delete_datafiles=delete_datafiles,
plot_results=plot_results,
Expand Down