@@ -579,3 +579,64 @@ def test_topics_keeps_rows_and_probabilities_consistent_through_a_merge():
579579 assert set (topics .predictions ) <= set (topics .topic_ids ())
580580 assert topics .probabilities .shape == (19 , len (topics .topic_ids ()))
581581 assert topics .probabilities [0 ].sum () == pytest .approx (1.0 )
582+
583+
584+ # --------------------------------------------------------------------------------------
585+ # get_topic_info columns
586+ # --------------------------------------------------------------------------------------
587+
588+
589+ def test_representation_is_the_whole_word_list ():
590+ """0.17 returned every word; a `str(...)` here silently truncated to the top five."""
591+ topics = build_topics ({0 : 4 })
592+ words = [(f"word{ index } " , 1.0 - index / 100 ) for index in range (10 )]
593+ topics .set_data (representations = {"Main" : {0 : Keywords (data = words )}})
594+
595+ info = topics [0 ].to_info_dict ()
596+
597+ assert info ["Representation" ] == [f"word{ index } " for index in range (10 )]
598+
599+
600+ def test_aspect_columns_are_word_lists_too ():
601+ """An aspect had the same bug, and `str(rep)` was never meaningful in a table."""
602+ topics = build_topics ({0 : 4 })
603+ topics .set_data (representations = {"Main" : {0 : Keywords (data = [("cat" , 0.8 )])}})
604+ topics .set_data (representations = {"Visual" : {0 : Images (data = "collage" , captions = ["a cat" ])}})
605+
606+ info = topics [0 ].to_info_dict ()
607+
608+ assert info ["Visual" ] == ["a cat" ]
609+
610+
611+ def test_name_carries_the_topic_id ():
612+ """What tells two topics with similar keywords apart, and what 0.17's `Name` had."""
613+ topics = build_topics ({0 : 4 })
614+ topics .set_data (representations = {"Main" : {0 : Keywords (data = [("cat" , 0.9 ), ("dog" , 0.8 )])}})
615+
616+ assert topics [0 ].name == "0_cat_dog"
617+ assert topics [0 ].to_info_dict ()["Name" ] == "0_cat_dog"
618+
619+
620+ def test_a_user_label_is_never_prefixed ():
621+ """`set_topic_labels("Politics")` should not become `0_Politics`."""
622+ topics = build_topics ({0 : 4 })
623+ topics [0 ]._label = "Politics"
624+
625+ assert topics [0 ].name == "Politics"
626+
627+
628+ def test_label_stays_unprefixed ():
629+ """`TopicHierarchy` names its nodes from `label`, which 0.17 left unprefixed."""
630+ topics = build_topics ({0 : 4 })
631+ topics .set_data (representations = {"Main" : {0 : Keywords (data = [("cat" , 0.9 ), ("dog" , 0.8 )])}})
632+
633+ assert topics [0 ].label == "cat_dog"
634+
635+
636+ def test_representative_documents_are_not_truncated ():
637+ """`get_topic_info` is a data accessor; the display layer already elides long text."""
638+ topics = build_topics ({0 : 4 })
639+ long_document = "word " * 200
640+ topics .set_data (representative_documents = {0 : [long_document ]})
641+
642+ assert topics [0 ].to_info_dict ()["Representative_Docs" ] == [long_document ]
0 commit comments