Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate annotations (old) (Sourcery refactored) #318

Open
wants to merge 1 commit into
base: migrate_annotations
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions ebl/fragmentarium/application/cropped_annotations_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def find_annotations_by_sign(self, sign: str) -> Sequence[CroppedAnnotation]:
cropped_image_annotations = []
for annotation in annotations:
for annotation_elem in annotation.annotations:
cropped_sign = annotation_elem.cropped_sign
if cropped_sign:
if cropped_sign := annotation_elem.cropped_sign:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CroppedAnnotationService.find_annotations_by_sign refactored with the following changes:

cropped_sign_image = (
self._cropped_sign_image_repository.query_by_id(
cropped_sign.image_id
Expand Down
20 changes: 9 additions & 11 deletions ebl/fragmentarium/domain/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,15 @@ def from_annotations(
image_width: int, image_height: int, annotations: Sequence[Annotation]
) -> Sequence["BoundingBox"]:
return tuple(
[
BoundingBox.from_relative_coordinates(
annotation.geometry.x,
annotation.geometry.y,
annotation.geometry.width,
annotation.geometry.height,
image_width,
image_height,
)
for annotation in annotations
]
BoundingBox.from_relative_coordinates(
annotation.geometry.x,
annotation.geometry.y,
annotation.geometry.width,
annotation.geometry.height,
image_width,
image_height,
)
for annotation in annotations
Comment on lines -99 to +107
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BoundingBox.from_annotations refactored with the following changes:

)


Expand Down
11 changes: 6 additions & 5 deletions ebl/tests/test_mongo_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ def test_find_many(collection):
collection.insert_one(document_match2)
collection.insert_one(document_no_match)

assert [document for document in collection.find_many({"data": "payload"})] == [
assert list(collection.find_many({"data": "payload"})) == [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_find_many refactored with the following changes:

document_match1,
document_match2,
]


def test_find_many_document_not_found(collection):
assert list(collection.find_many({})) == []
assert not list(collection.find_many({}))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_find_many_document_not_found refactored with the following changes:



def test_aggregate(collection):
Expand All @@ -76,9 +76,10 @@ def test_aggregate(collection):
collection.insert_one(document_match2)
collection.insert_one(document_no_match)

assert [
document for document in collection.aggregate([{"$match": {"data": "payload"}}])
] == [document_match1, document_match2]
assert list(collection.aggregate([{"$match": {"data": "payload"}}])) == [
document_match1,
document_match2,
]
Comment on lines -79 to +82
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_aggregate refactored with the following changes:



def test_update(collection):
Expand Down