Skip to content

Commit

Permalink
manually fixed some ruff issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristofferEdlund committed Oct 17, 2023
1 parent ba78fe1 commit 081f249
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion darwin/dataset/local_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Any, Dict, Iterator, List, Optional, Tuple

import numpy as np
import orjson as json
from PIL import Image as PILImage

from darwin.dataset.utils import get_classes, get_release_path, load_pil_image
Expand Down
4 changes: 2 additions & 2 deletions darwin/dataset/split_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ def _stratify_samples(
# Extract entries whose support set is 1 (it would make sklearn crash) and append the to train later
unique_labels, count = np.unique(labels, return_counts=True)
single_files = []
for l in unique_labels[count == 1]:
index = np.where(labels == l)[0][0]
for label in unique_labels[count == 1]:
index = np.where(labels == label)[0][0]
single_files.append(file_indices[index])
labels = np.delete(labels, index)
file_indices = np.delete(file_indices, index)
Expand Down
8 changes: 4 additions & 4 deletions tests/darwin/torch/dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_should_correctly_create_a_instance_seg_dataset(self, team_slug: str, te
ds = InstanceSegmentationDataset(dataset_path=root, release_name="latest")

generic_dataset_test(ds, n=20, size=(50, 50))
assert type(ds[0][1]) is dict
assert isinstance(ds[0][1], dict)


class TestSemanticSegmentationDataset:
Expand All @@ -58,7 +58,7 @@ def test_should_correctly_create_a_semantic_seg_dataset(self, team_slug: str, te
ds = SemanticSegmentationDataset(dataset_path=root, release_name="latest")

generic_dataset_test(ds, n=20, size=(50, 50))
assert type(ds[0][1]) is dict
assert isinstance(ds[0][1], dict)


class TestObjectDetectionDataset:
Expand All @@ -67,7 +67,7 @@ def test_should_correctly_create_a_object_detection_dataset(self, team_slug: str
ds = ObjectDetectionDataset(dataset_path=root, release_name="latest")

generic_dataset_test(ds, n=20, size=(50, 50))
assert type(ds[0][1]) is dict
assert isinstance(ds[0][1], dict)
img, target = ds[0]

for bbox in target["boxes"]:
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_loads_semantic_segmentation_dataset_from_polygon_annotations(
label = {k: _maybe_tensor_to_list(v) for k, v in label.items()}

assert label["image_id"] == [0]
assert type(label["mask"][0]) == list
assert isinstance(label["mask"][0], list)
assert label["height"] == 50
assert label["width"] == 50

Expand Down

0 comments on commit 081f249

Please sign in to comment.