Skip to content

Commit 8ef3c6d

Browse files
Change "anchor not in vocabulary" to a warning
CorEx raised an error if an anchor word was provided but it was not in the vocabulary. It now throws a warning instead, so that code can run uninterrupted. Addresses #23
1 parent 7267678 commit 8ef3c6d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

corextopic/corextopic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
License: Apache V2
2020
"""
21-
21+
import warnings
2222
import numpy as np # Tested with 1.8.0
2323
from os import makedirs
2424
from os import path
@@ -356,7 +356,8 @@ def preprocess_anchors(self, anchors):
356356
if anchor in self.word2col_index:
357357
new_anchor_list.append(self.word2col_index[anchor])
358358
else:
359-
raise KeyError('Anchor word not in word column labels provided to CorEx: {}'.format(anchor))
359+
w = 'Anchor word not in word column labels provided to CorEx: {}'.format(anchor)
360+
warnings.warn(w)
360361
else:
361362
raise NameError("Provided non-index anchors to CorEx without also providing 'words'")
362363
else:

0 commit comments

Comments
 (0)