Skip to content

Commit

Permalink
Removing f-strings for Python 3.5 compatibility + clean-up(piskvorky#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lopusz committed Dec 27, 2019
1 parent 2523089 commit 0465d22
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions gensim/test/test_fasttext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,8 +1360,8 @@ def _check_roundtrip_model_model(self, model_params):
self.assertLess(calc_max_diff(v_orig, v_loaded), MAX_WORDVEC_COMPONENT_DIFFERENCE)
except AssertionError as e:
s = e.args[0]
s += (f" (max difference for components in wordvector of \"{w}\""
f" larger than the thershold {MAX_WORDVEC_COMPONENT_DIFFERENCE})")
s += " (max difference for components in wordvector of \"%s\"" % w
s += " larger than the thershold %f" % MAX_WORDVEC_COMPONENT_DIFFERENCE
e.args = (s,)
raise e

Expand Down Expand Up @@ -1511,8 +1511,7 @@ def _create_and_save_test_model(self, out_base_fname, model_params, fasttext_cmd

cmd = fasttext_cmd + " " + model_type + " -input " + inp_fname + \
" -output " + out_base_fname + " -dim " + size + " -seed " + seed
print(cmd)
process = subprocess.run(cmd, shell=True)
subprocess.run(cmd, shell=True)

def _check_roundtrip_file_file(self, model_params):
ft_home = os.environ.get("FT_HOME", None)
Expand All @@ -1524,8 +1523,8 @@ def _check_roundtrip_file_file(self, model_params):
# fasttext tool creates both *vec and *bin files so we have to remove both, event thought *vec is unused

with temporary_file("roundtrip_file_to_file1.bin") as fpath1bin, \
temporary_file("roundtrip_file_to_file1.vec") as fpath1vec, \
temporary_file("roundtrip_file_to_file2.bin") as fpath2bin:
temporary_file("roundtrip_file_to_file2.bin") as fpath2bin, \
temporary_file("roundtrip_file_to_file1.vec") as fpath1vec: # noqa:F841

fpath1base = fpath1bin[:-4]
self._create_and_save_test_model(fpath1base, model_params, fasttext_cmd)
Expand Down

0 comments on commit 0465d22

Please sign in to comment.