@@ -2,11 +2,21 @@ import { describe, expect, it } from "vitest";
2
2
import { computeDefaultVisibleLabels } from "./labelsVisibility" ;
3
3
4
4
const sampleSchemaMock = {
5
+ segmentation : {
6
+ ftype : "fiftyone.core.labels.Segmentation" ,
7
+ dbField : "segmentation" ,
8
+ name : "segmentation" ,
9
+ embeddedDocType : "fiftyone.core.labels.Segmentation" ,
10
+ path : "segmentation" ,
11
+ description : null ,
12
+ info : null ,
13
+ subfield : null ,
14
+ } ,
5
15
detection : {
6
- ftype : "fiftyone.core.labels.Detections " ,
16
+ ftype : "fiftyone.core.labels.Detection " ,
7
17
dbField : "detection" ,
8
18
name : "detection" ,
9
- embeddedDocType : "fiftyone.core.labels.Detections " ,
19
+ embeddedDocType : "fiftyone.core.labels.Detection " ,
10
20
path : "detection" ,
11
21
description : null ,
12
22
info : null ,
@@ -25,12 +35,12 @@ const sampleSchemaMock = {
25
35
} as const ;
26
36
27
37
const frameSchemaMock = {
28
- detection : {
29
- ftype : "fiftyone.core.labels.Detections " ,
30
- dbField : "frames.detection " ,
31
- name : "detection " ,
32
- embeddedDocType : "fiftyone.core.labels.Detections " ,
33
- path : "detection " ,
38
+ segmentation : {
39
+ ftype : "fiftyone.core.labels.Segmentation " ,
40
+ dbField : "frames.segmentation " ,
41
+ name : "segmentation " ,
42
+ embeddedDocType : "fiftyone.core.labels.Segmentation " ,
43
+ path : "segmentation " ,
34
44
description : null ,
35
45
info : null ,
36
46
subfield : null ,
@@ -39,8 +49,8 @@ const frameSchemaMock = {
39
49
40
50
describe ( "computeDefaultVisibleLabels" , ( ) => {
41
51
it ( "returns all non-dense labels when no config is provided" , ( ) => {
42
- const allSampleLabels = [ "detection" , "classification" ] ;
43
- const allFrameLabels = [ "frames.detection " ] ;
52
+ const allSampleLabels = [ "segmentation" , " detection", "classification" ] ;
53
+ const allFrameLabels = [ "frames.segmentation " ] ;
44
54
45
55
const result = computeDefaultVisibleLabels (
46
56
sampleSchemaMock ,
@@ -50,12 +60,12 @@ describe("computeDefaultVisibleLabels", () => {
50
60
undefined
51
61
) ;
52
62
53
- expect ( result ) . toEqual ( [ "classification" ] ) ;
63
+ expect ( result ) . toEqual ( [ "detection" , " classification"] ) ;
54
64
} ) ;
55
65
56
66
it ( "respects 'include' config only" , ( ) => {
57
- const allSampleLabels = [ "detection " , "classification" , "otherLabel" ] ;
58
- const allFrameLabels = [ "frames.detection " ] ;
67
+ const allSampleLabels = [ "segmentation " , "classification" , "otherLabel" ] ;
68
+ const allFrameLabels = [ "frames.segmentation " ] ;
59
69
60
70
const result = computeDefaultVisibleLabels (
61
71
sampleSchemaMock ,
@@ -69,8 +79,8 @@ describe("computeDefaultVisibleLabels", () => {
69
79
} ) ;
70
80
71
81
it ( "respects 'exclude' config only" , ( ) => {
72
- const allSampleLabels = [ "detection " , "classification" , "otherLabel" ] ;
73
- const allFrameLabels = [ "frames.detection " ] ;
82
+ const allSampleLabels = [ "segmentation " , "classification" , "otherLabel" ] ;
83
+ const allFrameLabels = [ "frames.segmentation " ] ;
74
84
75
85
const result = computeDefaultVisibleLabels (
76
86
sampleSchemaMock ,
@@ -80,24 +90,28 @@ describe("computeDefaultVisibleLabels", () => {
80
90
{ exclude : [ "classification" ] }
81
91
) ;
82
92
83
- expect ( result ) . toEqual ( [ "detection" , "otherLabel" , "frames.detection" ] ) ;
93
+ expect ( result ) . toEqual ( [
94
+ "segmentation" ,
95
+ "otherLabel" ,
96
+ "frames.segmentation" ,
97
+ ] ) ;
84
98
} ) ;
85
99
86
100
it ( "correctly applies both include & exclude" , ( ) => {
87
- const allSampleLabels = [ "detection " , "classification" , "otherLabel" ] ;
88
- const allFrameLabels = [ "frames.detection " ] ;
101
+ const allSampleLabels = [ "segmentation " , "classification" , "otherLabel" ] ;
102
+ const allFrameLabels = [ "frames.segmentation " ] ;
89
103
90
104
const result = computeDefaultVisibleLabels (
91
105
sampleSchemaMock ,
92
106
frameSchemaMock ,
93
107
allSampleLabels ,
94
108
allFrameLabels ,
95
109
{
96
- include : [ "detection " , "classification" , "otherLabel" ] ,
110
+ include : [ "segmentation " , "classification" , "otherLabel" ] ,
97
111
exclude : [ "classification" ] ,
98
112
}
99
113
) ;
100
114
101
- expect ( result ) . toEqual ( [ "detection " , "otherLabel" ] ) ;
115
+ expect ( result ) . toEqual ( [ "segmentation " , "otherLabel" ] ) ;
102
116
} ) ;
103
117
} ) ;
0 commit comments