Skip to content

Commit

Permalink
Handle optional parameters without implicit bool cast
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-fouque committed Oct 31, 2023
1 parent 6e7ec6a commit a0d6d25
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gensim/models/tfidfmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,16 +360,16 @@ def __init__(self, corpus=None, id2word=None, dictionary=None, wlocal=utils.iden
self.pivot = pivot
self.eps = 1e-12

if smartirs:
if smartirs is not None:
n_tf, n_df, n_n = self.smartirs
self.wlocal = partial(smartirs_wlocal, local_scheme=n_tf)
self.wglobal = partial(smartirs_wglobal, global_scheme=n_df)

if dictionary:
if dictionary is not None:
# user supplied a Dictionary object, which already contains all the
# statistics we need to construct the IDF mapping. we can skip the
# step that goes through the corpus (= an optimization).
if corpus:
if corpus is not None:
logger.warning(
"constructor received both corpus and explicit inverse document frequencies; ignoring the corpus"
)
Expand All @@ -378,17 +378,17 @@ def __init__(self, corpus=None, id2word=None, dictionary=None, wlocal=utils.iden
self.dfs = dictionary.dfs.copy()
self.term_lens = {termid: len(term) for termid, term in dictionary.items()}
self.idfs = precompute_idfs(self.wglobal, self.dfs, self.num_docs)
if not id2word:
if id2word is None:
self.id2word = dictionary
elif corpus:
elif corpus is not None:
self.initialize(corpus)
else:
# NOTE: everything is left uninitialized; presumably the model will
# be initialized in some other way
pass

# If smartirs is not None, override pivot and normalize
if not smartirs:
if smartirs is None:
return
if self.pivot is not None:
if n_n in 'ub':
Expand Down

0 comments on commit a0d6d25

Please sign in to comment.