From c95e4d8b5b202928bdbd0a5222501cc9009f20f7 Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Mon, 14 Aug 2023 17:40:42 +0200 Subject: [PATCH 1/3] Made AnnotatedImage mutable --- src/annotated_image.jl | 2 +- test/annotated_image_tests.jl | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/annotated_image.jl b/src/annotated_image.jl index b6ddd82..3b41e9d 100644 --- a/src/annotated_image.jl +++ b/src/annotated_image.jl @@ -1,6 +1,6 @@ abstract type AbstractAnnotatedImage end -struct AnnotatedImage <: AbstractAnnotatedImage +mutable struct AnnotatedImage <: AbstractAnnotatedImage annotations::Vector{AbstractImageAnnotation} image_file_path::Union{String, Nothing} image_height::Union{Int, Nothing} diff --git a/test/annotated_image_tests.jl b/test/annotated_image_tests.jl index 4e22594..50dea6a 100644 --- a/test/annotated_image_tests.jl +++ b/test/annotated_image_tests.jl @@ -19,6 +19,18 @@ using Test @test length(get_annotations(annotated_image)) == 2 end + @testset "Mutability" begin + annotated_image = AnnotatedImage() + annotated_image.annotations = [ImageAnnotation(1)] + annotated_image.image_file_path = "path/to/image" + annotated_image.image_height = 3 + annotated_image.image_width = 4 + @test annotated_image.annotations == [ImageAnnotation(1)] + @test annotated_image.image_file_path == "path/to/image" + @test annotated_image.image_height == 3 + @test annotated_image.image_width == 4 + end + @testset "Equality" begin @test AnnotatedImage() == AnnotatedImage() @test AnnotatedImage([ImageAnnotation(1)]) == AnnotatedImage([ImageAnnotation(1)]) From e2b94a81f35ee320772bca5690b9b06a7eeeab2d Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Mon, 14 Aug 2023 22:06:52 +0200 Subject: [PATCH 2/3] Made BoundingBoxAnnotation mutable --- src/bounding_box_annotation.jl | 2 +- test/bounding_box_annotation_tests.jl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bounding_box_annotation.jl b/src/bounding_box_annotation.jl index d028a7c..b417c6e 100644 --- a/src/bounding_box_annotation.jl +++ b/src/bounding_box_annotation.jl @@ -1,4 +1,4 @@ -struct BoundingBoxAnnotation{L, T} <: AbstractObjectAnnotation{L, T} +mutable struct BoundingBoxAnnotation{L, T} <: AbstractObjectAnnotation{L, T} rect::Rect2{T} annotation::ImageAnnotation{L} end diff --git a/test/bounding_box_annotation_tests.jl b/test/bounding_box_annotation_tests.jl index f10b58f..8901808 100644 --- a/test/bounding_box_annotation_tests.jl +++ b/test/bounding_box_annotation_tests.jl @@ -48,6 +48,14 @@ using Test end end + @testset "Mutability" begin + annotation = BoundingBoxAnnotation(Point2(1.0, 2.0), 3.0, 4.0, "car") + annotation.rect = Rect2(Point2(2.0, 3.0), 4.0, 5.0) + annotation.annotation = ImageAnnotation("person") + @test annotation.rect == Rect2(Point2(2.0, 3.0), 4.0, 5.0) + @test annotation.annotation == ImageAnnotation("person") + end + @testset "Equality" begin @test BoundingBoxAnnotation(Point2(1.0, 2.0), 3.0, 4.0, "car") == BoundingBoxAnnotation(Point2(1.0, 2.0), 3.0, 4.0, "car") @test BoundingBoxAnnotation(Point2(1.0, 2.0), 3.0, 4.0, "car") != BoundingBoxAnnotation(Point2(1.0, 2.0), 3.0, 4.0, "person") From 84dbcbff58666c5bc4a0df8ba9f5c461431089fe Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Mon, 14 Aug 2023 22:13:16 +0200 Subject: [PATCH 3/3] Made Label mutable --- src/label.jl | 2 +- test/label_tests.jl | 12 ++++++++++++ test/runtests.jl | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/label_tests.jl diff --git a/src/label.jl b/src/label.jl index 5f0e228..3e3dd9e 100644 --- a/src/label.jl +++ b/src/label.jl @@ -1,6 +1,6 @@ abstract type AbstractLabel end -struct Label{T} <: AbstractLabel +mutable struct Label{T} <: AbstractLabel value::T attributes::Dict{String, Any} end diff --git a/test/label_tests.jl b/test/label_tests.jl new file mode 100644 index 0000000..0025b6b --- /dev/null +++ b/test/label_tests.jl @@ -0,0 +1,12 @@ +using ImageAnnotations +using Test + +@testset "Label" begin + @testset "Mutability" begin + label = Label("person") + label.value = "car" + label.attributes = Dict("colour" => "red") + @test label.value == "car" + @test label.attributes == Dict("colour" => "red") + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 429671a..2c02212 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,6 +9,7 @@ using Test include("oriented_bounding_box_annotation_tests.jl") include("polygon_annotation_tests.jl") include("iou_tests.jl") + include("label_tests.jl") include("annotated_image_tests.jl") include("data_set_tests.jl") end