Skip to content

Commit

Permalink
Apply linting to src/
Browse files Browse the repository at this point in the history
  • Loading branch information
NickleDave committed May 5, 2024
1 parent 33f578b commit 84c316b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
9 changes: 4 additions & 5 deletions src/vak/config/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,17 @@ class DatasetConfig:
name: str | None = field(
converter=attr.converters.optional(str), default=None
)
params : dict | None = field(
params: dict | None = field(
# we default to an empty dict instead of None
# so we can still do **['dataset']['params'] everywhere we do when params are specified
converter=attr.converters.optional(dict), default={}
converter=attr.converters.optional(dict),
default={},
)

@classmethod
def from_config_dict(cls, config_dict: dict) -> DatasetConfig:

return cls(
**config_dict
)
return cls(**config_dict)

def asdict(self):
"""Convert this :class:`DatasetConfig` instance
Expand Down
2 changes: 1 addition & 1 deletion src/vak/datasets/frame_classification/window_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def shape(self):
tmp_item = self.__getitem__(tmp_x_ind)
# used by vak functions that need to determine size of window,
# e.g. when initializing a neural network model
return tmp_item['frames'].shape
return tmp_item["frames"].shape

def _load_frames(self, frames_path):
"""Helper function that loads "frames",
Expand Down
4 changes: 2 additions & 2 deletions src/vak/eval/eval_.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ def eval(
f"value for ``{path_name}`` not recognized as a file: {path}"
)

dataset_path = pathlib.Path(dataset_config['path'])
dataset_path = pathlib.Path(dataset_config["path"])
if not dataset_path.exists() or not dataset_path.is_dir():
raise NotADirectoryError(
f"`dataset_path` not found or not recognized as a directory: {dataset_path}"
)

model_name = model_config['name']
model_name = model_config["name"]
try:
model_family = models.registry.MODEL_FAMILY_FROM_NAME[model_name]
except KeyError as e:
Expand Down
4 changes: 2 additions & 2 deletions src/vak/eval/frame_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def eval_frame_classification_model(
f"value for ``{path_name}`` not recognized as a file: {path}"
)

dataset_path = pathlib.Path(dataset_config['path'])
dataset_path = pathlib.Path(dataset_config["path"])
if not dataset_path.exists() or not dataset_path.is_dir():
raise NotADirectoryError(
f"`dataset_path` not found or not recognized as a directory: {dataset_path}"
Expand Down Expand Up @@ -143,7 +143,7 @@ def eval_frame_classification_model(
)
transform_params = {
"spect_standardizer": spect_standardizer,
"window_size": window_size
"window_size": window_size,
}

item_transform = transforms.defaults.get_default_transform(
Expand Down
4 changes: 3 additions & 1 deletion src/vak/learncurve/frame_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ def learning_curve_for_frame_classification_model(

# ---- main loop that creates "learning curve" ---------------------------------------------------------------------
logger.info("Starting training for learning curve.")
model_name = model_config["name"] # used below when getting checkpoint path, etc
model_name = model_config[
"name"
] # used below when getting checkpoint path, etc
for train_dur, replicate_num in to_do:
logger.info(
f"Training model with training set of size: {train_dur}s, replicate number {replicate_num}.",
Expand Down
3 changes: 2 additions & 1 deletion src/vak/predict/parametric_umap.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def predict_with_parametric_umap_model(
# TODO: fix this when we build transforms into datasets
transform_params = {
"padding": dataset_config["params"].get(
"padding", models.convencoder_umap.get_default_padding(metadata.shape)
"padding",
models.convencoder_umap.get_default_padding(metadata.shape),
)
}
item_transform = transforms.defaults.get_default_transform(
Expand Down
6 changes: 3 additions & 3 deletions src/vak/train/frame_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def train_frame_classification_model(
f"value for ``{path_name}`` not recognized as a file: {path}"
)

dataset_path = pathlib.Path(dataset_config['path'])
dataset_path = pathlib.Path(dataset_config["path"])
if not dataset_path.exists() or not dataset_path.is_dir():
raise NotADirectoryError(
f"`dataset_path` not found or not recognized as a directory: {dataset_path}"
Expand Down Expand Up @@ -209,7 +209,7 @@ def train_frame_classification_model(
)
spect_standardizer = None

model_name = model_config['name']
model_name = model_config["name"]
# TODO: move this into datapipe once each datapipe uses a fixed set of transforms
# that will require adding `spect_standardizer`` as a parameter to the datapipe,
# maybe rename to `frames_standardizer`?
Expand All @@ -233,7 +233,7 @@ def train_frame_classification_model(
split="train",
subset=subset,
item_transform=train_transform,
**dataset_config['params'],
**dataset_config["params"],
)
logger.info(
f"Duration of WindowDataset used for training, in seconds: {train_dataset.duration}",
Expand Down
4 changes: 2 additions & 2 deletions src/vak/train/train_.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ def train(
f"value for ``{path_name}`` not recognized as a file: {path}"
)

dataset_path = pathlib.Path(dataset_config['path'])
dataset_path = pathlib.Path(dataset_config["path"])
if not dataset_path.exists() or not dataset_path.is_dir():
raise NotADirectoryError(
f"`dataset_path` not found or not recognized as a directory: {dataset_path}"
)

model_name = model_config['name']
model_name = model_config["name"]
try:
model_family = models.registry.MODEL_FAMILY_FROM_NAME[model_name]
except KeyError as e:
Expand Down

0 comments on commit 84c316b

Please sign in to comment.