Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Commit

Permalink
style: apply automated linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
megalinter-bot committed May 8, 2024
1 parent 8690111 commit fda72fc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/safeds_datasets/image/_mnist/_mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def load_mnist(path: str | Path, download: bool = True) -> tuple[ImageDataset[Co
if len(missing_files) > 0:
if download:
_download_mnist_like(

Check warning on line 93 in src/safeds_datasets/image/_mnist/_mnist.py

View check run for this annotation

Codecov / codecov/patch

src/safeds_datasets/image/_mnist/_mnist.py#L84-L93

Added lines #L84 - L93 were not covered by tests
path, {name: f_path for name, f_path in _mnist_files.items() if f_path in missing_files}, _mnist_links,
path,
{name: f_path for name, f_path in _mnist_files.items() if f_path in missing_files},
_mnist_links,
)
else:
raise FileNotFoundError(f"Could not find files {[str(path / file) for file in missing_files]}")
Expand Down Expand Up @@ -179,7 +181,9 @@ def load_kmnist(path: str | Path, download: bool = True) -> tuple[ImageDataset[C


def _load_mnist_like(
path: str | Path, files: dict[str, str], labels: dict[int, str],
path: str | Path,
files: dict[str, str],
labels: dict[int, str],
) -> tuple[ImageDataset[Column], ImageDataset[Column]]:
_init_default_device()

Check warning on line 188 in src/safeds_datasets/image/_mnist/_mnist.py

View check run for this annotation

Codecov / codecov/patch

src/safeds_datasets/image/_mnist/_mnist.py#L188

Added line #L188 was not covered by tests

Expand All @@ -196,7 +200,8 @@ def _load_mnist_like(
raise ValueError(f"Magic number mismatch. Actual {magic} != Expected 2049.")
if "train" in file_name:
train_labels = Column(

Check warning on line 202 in src/safeds_datasets/image/_mnist/_mnist.py

View check run for this annotation

Codecov / codecov/patch

src/safeds_datasets/image/_mnist/_mnist.py#L190-L202

Added lines #L190 - L202 were not covered by tests
file_name, [labels[label_index] for label_index in array("B", label_file.read())],
file_name,
[labels[label_index] for label_index in array("B", label_file.read())],
)
else:
test_labels = Column(file_name, array("B", label_file.read()))

Check warning on line 207 in src/safeds_datasets/image/_mnist/_mnist.py

View check run for this annotation

Codecov / codecov/patch

src/safeds_datasets/image/_mnist/_mnist.py#L207

Added line #L207 was not covered by tests
Expand All @@ -209,7 +214,8 @@ def _load_mnist_like(
image_tensor = torch.empty(size, 1, rows, cols)
for i in range(size):
image_tensor[i, 0] = torch.frombuffer(

Check warning on line 216 in src/safeds_datasets/image/_mnist/_mnist.py

View check run for this annotation

Codecov / codecov/patch

src/safeds_datasets/image/_mnist/_mnist.py#L209-L216

Added lines #L209 - L216 were not covered by tests
image_data[i * rows * cols : (i + 1) * rows * cols], dtype=torch.uint8,
image_data[i * rows * cols : (i + 1) * rows * cols],
dtype=torch.uint8,
).reshape(rows, cols)
image_list = _SingleSizeImageList()
image_list._tensor = image_tensor
Expand All @@ -222,7 +228,9 @@ def _load_mnist_like(
if train_image_list is None or test_image_list is None or train_labels is None or test_labels is None:
raise ValueError
return ImageDataset[Column](train_image_list, train_labels, 32, shuffle=True), ImageDataset[Column](

Check warning on line 230 in src/safeds_datasets/image/_mnist/_mnist.py

View check run for this annotation

Codecov / codecov/patch

src/safeds_datasets/image/_mnist/_mnist.py#L227-L230

Added lines #L227 - L230 were not covered by tests
test_image_list, test_labels, 32,
test_image_list,
test_labels,
32,
)


Expand Down

0 comments on commit fda72fc

Please sign in to comment.