Skip to content

Fix isolated bugs in the topic data layer - #2533

Merged
MaartenGr merged 1 commit into
v1.0from
v1.0-isolated-bugfixes
Aug 22, 2026
Merged

Fix isolated bugs in the topic data layer#2533
MaartenGr merged 1 commit into
v1.0from
v1.0-isolated-bugfixes

Conversation

@MaartenGr

Copy link
Copy Markdown
Owner

Fixes

  • Topics.merge divided by zero for topics holding no documents, and left embedding unbound when a topic had none — silently leaking the previous loop iteration's embedding into an unrelated topic.
  • Topic.to_dict skipped c_tf_idf when the row was all zeros, losing its column count. Topics.delete creates exactly such a row, so delete multiple topics → save → load → read c_tf_idf_ raised ValueError: incompatible dimensions.
  • TopicHierarchy.to_dict dropped every node's embedding and c-TF-IDF on save.
  • TopicMapping.apply raised an opaque KeyError on an incomplete mapping. Both callers (_reduce_to_n_topics, _auto_reduce_topics) built their mapping by zipping over documents, so zero-document topics vanished from it; they now build from topic_ids(), and apply raises a message naming the omitted topics.
  • Topic.copy round-tripped through JSON; now uses deepcopy.
  • _map_predictions was dead code referencing the removed topic_mapper_.
  • topic_aspects_ raised KeyError when topic 0 was absent.
  • representative_docs_ / representative_images_ filtered on is not None against fields defaulting to [] and np.array([]), so neither filter ever fired.

Behavioural decisions

Merging topics with no documents falls back to equal weighting; merging topics without embeddings yields an empty embedding rather than raising.

@MaartenGr
MaartenGr marked this pull request as ready for review August 22, 2026 06:35
@MaartenGr
MaartenGr merged commit 9b156d2 into v1.0 Aug 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant