Skip to content

Commit

Permalink
Remove unused arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed Apr 2, 2024
1 parent 44b20ed commit 457715e
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 36 deletions.
1 change: 0 additions & 1 deletion disdrodb/api/create_directories.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ def create_l0_directory_structure(
station_name,
force,
product,
verbose=False,
):
"""Create directory structure for the first L0 DISDRODB product.
Expand Down
2 changes: 1 addition & 1 deletion disdrodb/issue/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _check_timestep_datetime_accuracy(timesteps, unit="s"):
return timesteps


def _check_timestep_string_second_accuracy(timesteps, n=19):
def _check_timestep_string_second_accuracy(timesteps):
"""Check the timesteps string are provided with second accuracy.
Note: it assumes the YYYY-mm-dd HH:MM:SS format
Expand Down
7 changes: 4 additions & 3 deletions disdrodb/l0/check_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _check_valid_range(df, dict_data_range, verbose=False):

if len(list_wrong_columns) > 0:
msg = f"Columns {list_wrong_columns} has values outside the expected data range."
log_error(logger=logger, msg=msg, verbose=False)
log_error(logger=logger, msg=msg, verbose=verbose)
raise ValueError(msg)


Expand All @@ -81,7 +81,7 @@ def _check_valid_values(df, dict_valid_values, verbose=False):

if len(list_wrong_columns) > 0:
msg = "\n".join(list_msg)
log_error(logger=logger, msg=msg, verbose=False)
log_error(logger=logger, msg=msg, verbose=verbose)
raise ValueError(f"Columns {list_wrong_columns} have invalid values.")


Expand Down Expand Up @@ -109,7 +109,7 @@ def _check_raw_fields_available(df: pd.DataFrame, sensor_name: str, verbose: boo
# Check that raw_drop_number is present
if "raw_drop_number" not in df.columns:
msg = "The 'raw_drop_number' column is not present in the dataframe."
log_error(logger=logger, msg=msg, verbose=False)
log_error(logger=logger, msg=msg, verbose=verbose)
raise ValueError(msg)

# Report additional raw arrays that are missing
Expand Down Expand Up @@ -218,4 +218,5 @@ def check_l0a_standards(df: pd.DataFrame, sensor_name: str, verbose: bool = True

def check_l0b_standards(x: str) -> None:
# - Check for realistic values after having removed the flags !!!!
x = "noqa" # noqa F841
pass
2 changes: 0 additions & 2 deletions disdrodb/l0/l0_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ def run_l0a(
product="L0A",
station_name=station_name,
force=force,
verbose=verbose,
)

# -------------------------------------------------------------------------.
Expand Down Expand Up @@ -726,7 +725,6 @@ def run_l0b_from_nc(
product="L0B",
station_name=station_name,
force=force,
verbose=verbose,
)

# -------------------------------------------------------------------------.
Expand Down
26 changes: 10 additions & 16 deletions disdrodb/l0/l0a_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _check_df_sanitizer_fun(df_sanitizer_fun):
raise ValueError("The `df_sanitizer_fun` must have only `df` as input argument!")


def _check_not_empty_dataframe(df, verbose=False):
def _check_not_empty_dataframe(df):
if len(df.index) == 0:
msg = " - The file is empty and has been skipped."
log_error(logger=logger, msg=msg, verbose=False)
Expand Down Expand Up @@ -288,7 +288,7 @@ def remove_issue_timesteps(df, issue_dict, verbose=False):
return df


def cast_column_dtypes(df: pd.DataFrame, sensor_name: str, verbose: bool = False) -> pd.DataFrame:
def cast_column_dtypes(df: pd.DataFrame, sensor_name: str) -> pd.DataFrame:
"""Convert ``'object'`` dataframe columns into DISDRODB L0A dtype standards.
Parameters
Expand All @@ -297,8 +297,6 @@ def cast_column_dtypes(df: pd.DataFrame, sensor_name: str, verbose: bool = False
Input dataframe.
sensor_name : str
Name of the sensor.
verbose : bool
Whether to verbose the processing. The default is ``False``.
Returns
-------
Expand Down Expand Up @@ -328,7 +326,7 @@ def cast_column_dtypes(df: pd.DataFrame, sensor_name: str, verbose: bool = False
return df


def coerce_corrupted_values_to_nan(df: pd.DataFrame, sensor_name: str, verbose: bool = False) -> pd.DataFrame:
def coerce_corrupted_values_to_nan(df: pd.DataFrame, sensor_name: str) -> pd.DataFrame:
"""Coerce corrupted values in dataframe numeric columns to ``np.nan``.
Parameters
Expand All @@ -337,8 +335,6 @@ def coerce_corrupted_values_to_nan(df: pd.DataFrame, sensor_name: str, verbose:
Input dataframe.
sensor_name : str
Name of the sensor.
verbose : bool
Whether to verbose the processing. The default is ``False``.
Returns
-------
Expand All @@ -361,7 +357,7 @@ def coerce_corrupted_values_to_nan(df: pd.DataFrame, sensor_name: str, verbose:
return df


def strip_string_spaces(df: pd.DataFrame, sensor_name: str, verbose: bool = False) -> pd.DataFrame:
def strip_string_spaces(df: pd.DataFrame, sensor_name: str) -> pd.DataFrame:
"""Strip leading/trailing spaces from dataframe string columns.
Parameters
Expand All @@ -370,8 +366,6 @@ def strip_string_spaces(df: pd.DataFrame, sensor_name: str, verbose: bool = Fals
Input dataframe.
sensor_name : str
Name of the sensor.
verbose : bool
Whether to verbose the processing. The default is ``False``.
Returns
-------
Expand All @@ -392,7 +386,7 @@ def strip_string_spaces(df: pd.DataFrame, sensor_name: str, verbose: bool = Fals
try:
df[column] = df[column].str.strip()
except AttributeError:
msg = f"AttributeError: The column {column} is not a string/object dtype."
msg = f"The column {column} is not a string/object dtype."
log_error(logger=logger, msg=msg, verbose=False)
raise AttributeError(msg)
return df
Expand Down Expand Up @@ -618,7 +612,7 @@ def process_raw_file(
)

# - Check if file empty
_check_not_empty_dataframe(df=df, verbose=verbose)
_check_not_empty_dataframe(df=df)

# - Check dataframe column number matches columns_names
_check_matching_column_number(df, column_names, verbose=False)
Expand All @@ -637,10 +631,10 @@ def process_raw_file(
df = remove_issue_timesteps(df, issue_dict=issue_dict, verbose=verbose)

# - Coerce numeric columns corrupted values to np.nan
df = coerce_corrupted_values_to_nan(df, sensor_name=sensor_name, verbose=verbose)
df = coerce_corrupted_values_to_nan(df, sensor_name=sensor_name)

# - Strip trailing/leading space from string columns
df = strip_string_spaces(df, sensor_name=sensor_name, verbose=verbose)
df = strip_string_spaces(df, sensor_name=sensor_name)

# - Strip first and last delimiter from the raw arrays
df = strip_delimiter_from_raw_arrays(df)
Expand All @@ -649,7 +643,7 @@ def process_raw_file(
df = remove_corrupted_rows(df)

# - Cast dataframe to dtypes
df = cast_column_dtypes(df, sensor_name=sensor_name, verbose=verbose)
df = cast_column_dtypes(df, sensor_name=sensor_name)

# - Replace nan flags values with np.nans
df = replace_nan_flags(df, sensor_name=sensor_name, verbose=verbose)
Expand Down Expand Up @@ -729,7 +723,7 @@ def write_l0a(
row_group_size=row_group_size,
)
msg = f"The Pandas Dataframe has been written as an Apache Parquet file to {filepath}."
log_info(logger=logger, msg=msg, verbose=False)
log_info(logger=logger, msg=msg, verbose=verbose)
except Exception as e:
msg = f" - The Pandas DataFrame cannot be written as an Apache Parquet file. The error is: \n {e}."
log_error(logger=logger, msg=msg, verbose=False)
Expand Down
2 changes: 1 addition & 1 deletion disdrodb/l0/l0b_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def _set_attrs_dict(ds, attrs_dict):

def _set_coordinate_attributes(ds):
# Get attributes dictionary
attrs_dict = get_coords_attrs_dict(ds)
attrs_dict = get_coords_attrs_dict()
# Set attributes
ds = _set_attrs_dict(ds, attrs_dict)
return ds
Expand Down
2 changes: 1 addition & 1 deletion disdrodb/l0/standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def get_l0b_cf_attrs_dict(sensor_name: str) -> dict:
#### Coordinates attributes


def get_coords_attrs_dict(ds):
def get_coords_attrs_dict():
"""Return dictionary with DISDRODB coordinates attributes."""
attrs_dict = {}
# Define diameter attributes
Expand Down
5 changes: 1 addition & 4 deletions disdrodb/metadata/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _get_list_all_metadata(base_dir, data_sources=None, campaign_names=None, sta
return list(set(metadata_filepaths))


def _get_list_metadata_with_data(base_dir, data_sources=None, campaign_names=None, station_names=None):
def _get_list_metadata_with_data(base_dir, data_sources=None, campaign_names=None):
"""
Get the list of metadata filepaths that have corresponding data in the DISDRODB raw archive.
Expand All @@ -159,9 +159,6 @@ def _get_list_metadata_with_data(base_dir, data_sources=None, campaign_names=Non
Name of the campaign(s) of interest.
The name(s) must be UPPER CASE.
The default is ``None``.
station_names : str or list of str
Station names of interest.
The default is ``None``.
Returns
-------
Expand Down
8 changes: 4 additions & 4 deletions disdrodb/tests/test_l0/test_l0a_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ def test_strip_string_spaces(create_test_config_files):
def test_coerce_corrupted_values_to_nan(create_test_config_files):
# Test with a valid dataframe
df = pd.DataFrame({"key_4": ["1"]})
df_out = coerce_corrupted_values_to_nan(df, sensor_name=TEST_SENSOR_NAME, verbose=False)
df_out = coerce_corrupted_values_to_nan(df, sensor_name=TEST_SENSOR_NAME)

assert df.equals(df_out)

# Test with a wrong dataframe
df = pd.DataFrame({"key_4": ["text"]})
df_out = coerce_corrupted_values_to_nan(df, sensor_name=TEST_SENSOR_NAME, verbose=False)
df_out = coerce_corrupted_values_to_nan(df, sensor_name=TEST_SENSOR_NAME)
assert pd.isnull(df_out["key_4"][0])


Expand Down Expand Up @@ -343,7 +343,7 @@ def test_cast_column_dtypes():
})
# Call the function
sensor_name = "OTT_Parsivel"
df_out = cast_column_dtypes(df, sensor_name, verbose=False)
df_out = cast_column_dtypes(df, sensor_name)
# Check that the output dataframe has the correct column types
assert str(df_out["time"].dtype) == "datetime64[s]"
assert str(df_out["station_number"].dtype) == "object"
Expand All @@ -352,7 +352,7 @@ def test_cast_column_dtypes():
# Assert raise error if can not cast
df["altitude"] = "text"
with pytest.raises(ValueError):
cast_column_dtypes(df, sensor_name, verbose=False)
cast_column_dtypes(df, sensor_name)


def test_remove_rows_with_missing_time():
Expand Down
2 changes: 1 addition & 1 deletion disdrodb/utils/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def _concatenate_datasets(list_ds, dim="time", verbose=False):
msg = "Start concatenating with xr.concat."
log_info(logger=logger, msg=msg, verbose=verbose)

ds = xr.concat(list_ds, dim="time", coords="minimal", compat="override")
ds = xr.concat(list_ds, dim=dim, coords="minimal", compat="override")

msg = "Concatenation with xr.concat has been successful."
log_info(logger=logger, msg=msg, verbose=verbose)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ select = [
# flake8-return
"RET",
# flake8-unused-arguments
# "ARG",
"ARG",
# flake8-raise
"RSE",
# flake8-pytest-style
Expand Down
1 change: 0 additions & 1 deletion tutorials/reader_preparation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@
" processed_dir=processed_dir,\n",
" station_name=station_name,\n",
" force=force,\n",
" verbose=False,\n",
" product=\"L0A\",\n",
")"
]
Expand Down

0 comments on commit 457715e

Please sign in to comment.