@@ -675,12 +675,12 @@ def test_labels_hash_auto_generation(self):
675
675
from ami .ml .models import AlgorithmCategoryMap
676
676
677
677
# Test data
678
- test_labels = ["coleoptera" , "diptera" , "lepidoptera" ]
679
678
test_data = [
680
679
{"index" : 0 , "label" : "coleoptera" },
681
680
{"index" : 1 , "label" : "diptera" },
682
681
{"index" : 2 , "label" : "lepidoptera" },
683
682
]
683
+ test_labels = AlgorithmCategoryMap .labels_from_data (test_data )
684
684
685
685
# Create instance using objects.create()
686
686
category_map = AlgorithmCategoryMap .objects .create (labels = test_labels , data = test_data , version = "test-v1" )
@@ -696,3 +696,22 @@ def test_labels_hash_auto_generation(self):
696
696
category_map2 = AlgorithmCategoryMap .objects .create (labels = test_labels , data = test_data , version = "test-v2" )
697
697
698
698
self .assertEqual (category_map .labels_hash , category_map2 .labels_hash )
699
+
700
+ def test_labels_data_conversion_methods (self ):
701
+ from ami .ml .models import AlgorithmCategoryMap
702
+
703
+ # Test data
704
+ test_data = [
705
+ {"index" : 0 , "label" : "coleoptera" },
706
+ {"index" : 1 , "label" : "diptera" },
707
+ {"index" : 2 , "label" : "lepidoptera" },
708
+ ]
709
+ test_labels = AlgorithmCategoryMap .labels_from_data (test_data )
710
+
711
+ # Convert labels to data and back
712
+ converted_data = AlgorithmCategoryMap .data_from_labels (test_labels )
713
+ converted_labels = AlgorithmCategoryMap .labels_from_data (converted_data )
714
+
715
+ # Verify conversions are correct
716
+ self .assertEqual (test_data , converted_data )
717
+ self .assertEqual (test_labels , converted_labels )
0 commit comments