本文整理汇总了Python中pyquickhelper.loghelper.fLOG函数的典型用法代码示例。如果您正苦于以下问题:Python fLOG函数的具体用法?Python fLOG怎么用?Python fLOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fLOG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_image_video_epidemic
def test_image_video_epidemic(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_image_video_epidemic")
if is_travis_or_appveyor() in ("travis",):
# pygame.error: No available video device
return
import pygame
if is_travis_or_appveyor() == "circleci":
# os.environ["SDL_VIDEODRIVER"] = "x11"
flags = pygame.NOFRAME
else:
flags = 0
pygame_simulation(pygame, fLOG=fLOG, iter=10, folder=temp, flags=flags)
files = os.listdir(temp)
self.assertTrue(len(files) > 9)
png = [os.path.join(temp, _)
for _ in files if os.path.splitext(_)[-1] == ".png"]
self.assertTrue(len(png) > 0)
out = os.path.join(temp, "epidemic.avi")
v = make_video(png, out, size=(300, 300), format="XVID")
self.assertTrue(v is not None)
示例2: test_image_video_puzzle_girafe
def test_image_video_puzzle_girafe(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_image_video_girafe")
if is_travis_or_appveyor() in ("travis",):
# pygame.error: No available video device
return
import pygame
if is_travis_or_appveyor() == "circleci":
# os.environ["SDL_VIDEODRIVER"] = "x11"
flags = pygame.NOFRAME
else:
flags = 0
pygame_simulation(pygame, fLOG=fLOG, folder=temp,
delay=200 if __name__ == "__main__" else 2,
flags=flags)
files = os.listdir(temp)
assert len(files) > 9
png = [os.path.join(temp, _)
for _ in files if os.path.splitext(_)[-1] == ".png"]
assert len(png) > 0
out = os.path.join(temp, "puzzle_girafe.avi")
v = make_video(png, out, size=(500, 500), format="XVID", fps=4)
assert v is not None
示例3: test_notebook_rst_svg
def test_notebook_rst_svg(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_nb_rst_svg")
nbs = [os.path.normpath(os.path.join(
temp, '..', "data", "rst_notebooks", "notebook_with_svg.ipynb"))]
formats = ["rst"]
res = process_notebooks(nbs, temp, temp, formats=formats, fLOG=fLOG)
name = res[0][0]
with open(name, 'r', encoding='utf-8') as f:
content = f.read()
self.assertIn('SVG in a notebook.', content)
self.assertIn('.. image::', content)
nb = 0
for line in content.split('\n'):
if '.. image::' in line:
name = line.replace('.. image::', '').strip(' \r\t')
dest = os.path.join(temp, name)
self.assertExists(dest)
nb += 1
self.assertGreater(nb, 0)
示例4: test_encrypt_decrypt
def test_encrypt_decrypt(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
password = "unittest" * 2
temp = get_temp_folder(__file__, "temp_encrypt")
temp2 = get_temp_folder(__file__, "temp_encrypt2")
tempmm = get_temp_folder(__file__, "temp_encrypt_status")
cstatus = os.path.join(tempmm, "crypt_status.txt")
cmap = os.path.join(tempmm, "crypt_map.txt")
srcf = os.path.abspath(os.path.join(temp, ".."))
sys.argv = ["", srcf, temp, password,
"--status", cstatus,
"--map", cmap]
encrypt(fLOG=fLOG)
this = __file__
sys.argv = ["", temp, temp2, password]
decrypt(fLOG=fLOG)
with open(__file__, "rb") as f:
c1 = f.read()
with open(os.path.join(temp2, os.path.split(this)[-1]), "rb") as f:
c2 = f.read()
self.assertEqual(c1, c2)
fLOG("end")
示例5: test_code_style_src
def test_code_style_src(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
if sys.version_info[0] == 2:
warnings.warn(
"skipping test_code_style because of Python 2 or " + sys.executable)
return
thi = os.path.abspath(os.path.dirname(__file__))
src_ = os.path.normpath(os.path.join(thi, "..", "..", "src"))
check_pep8(src_, fLOG=fLOG, extended=[("fLOG", _extended_refactoring)],
pylint_ignore=('C0103', 'C1801', 'R0201', 'R1705', 'W0108', 'W0613',
'W0231', 'W0212', 'C0111', 'W0107'),
skip=["Redefining built-in 'iter'",
"iter_rows.py:340",
"translation_class.py",
"translation_to_python.py:118",
"translation_to_python.py:185",
"translation_to_python.py:244",
"node_visitor_translator.py:74: E1111",
"R1720",
]
)
示例6: test_example_pydy
def test_example_pydy(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_example_pydy")
fix_tkinter_issues_virtualenv()
import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8, 8))
try:
example_pydy(ax=ax)
except Exception as e:
if 'can only concatenate list (not "tuple") to list' in str(e):
warnings.warn("Pydy needs to be updated for Python 3.7")
return
else:
raise e
self.assertNotEmpty(ax)
img = os.path.join(temp, "img.png")
fig.savefig(img)
self.assertExists(img)
if __name__ == "__main__":
fig.show()
plt.close('all')
fLOG("end")
示例7: test_fonction
def test_fonction(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
self.assertEqual(recherche([2, 3, 45], 3), 1)
self.assertEqual(recherche([2, 3, 45], 4), -1)
self.assertEqual(minindex([2, 3, 45, -1, 5]), (-1, 3))
li = range(0, 100, 2)
self.assertEqual(recherche_dichotomique(li, 48), 24)
self.assertEqual(recherche_dichotomique(li, 49), -1)
s = "case11;case12;case13|case21;case22;case23"
mat = text2mat(s, "|", ";")
t = mat2text(mat, "|", ";")
self.assertEqual(t, s)
tab = ["zero", "un", "deux"]
r = triindex(tab)
self.assertEqual(r, [('deux', 2), ('un', 1), ('zero', 0)])
li = ["un", "deux", "un", "trois"]
r = compte(li)
self.assertEqual(r, {'trois': 1, 'deux': 1, 'un': 2})
mat = [[0, 1, 2], [3, 4, 5]]
r = mat2vect(mat)
self.assertEqual(r, [0, 1, 2, 3, 4, 5])
m = vect2mat(r, 3)
self.assertEqual(m, mat)
x2 = integrale(lambda x: x, 0, 2, 1000)
self.assertEqual(x2, 2)
示例8: test_profiling
def test_profiling(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_profiling")
data = os.path.join(temp, "..", "data", "sample1000.txt")
with open(data, "r", encoding="utf-8") as f:
lines = [_.strip(" \n\r\t") for _ in f.readlines()]
def profile_exe():
res = self.gain_dynamique_moyen_par_mot(lines, [1.0] * len(lines))
return res
def prof(n, show):
pr = cProfile.Profile()
pr.enable()
profile_exe()
pr.disable()
s = io.StringIO()
ps = pstats.Stats(pr, stream=s).sort_stats('cumulative')
ps.print_stats()
rem = os.path.normpath(os.path.join(temp, "..", "..", ".."))
res = s.getvalue().replace(rem, "")
if show:
fLOG(res)
with open(os.path.join(temp, "profiling%d.txt" % n), "w") as f:
f.write(res)
prof(1, show=False)
prof(2, show=True)
示例9: test_notebook_ml_text_features
def test_notebook_ml_text_features(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
self.a_test_notebook_runner("ml_text_features", "td2a")
示例10: test_jconvert_sequence_into_batch_file_split2
def test_jconvert_sequence_into_batch_file_split2(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
self.zz_st_jconvert_sequence_into_batch_file_split2("win")
示例11: test_benchmark
def test_benchmark(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_grid_benchmark")
params = [dict(value=random.randint(10, 20), name="name%d" %
i, shortname="m%d" % i) for i in range(0, 2)]
datasets = [dict(X=pandas.DataFrame([[0, 1], [0, 1]]), name="set1", shortname="s1"),
dict(X=pandas.DataFrame([[1, 1], [1, 1]]), name="set2", shortname="s2"), ]
bench = ATestOverGridBenchMark("TestName", datasets, fLOG=fLOG, clog=temp,
cache_file=os.path.join(temp, "cache.pickle"))
bench.run(params)
df = bench.to_df()
ht = df.to_html(float_format="%1.3f", index=False)
self.assertTrue(len(df) > 0)
self.assertTrue(ht is not None)
self.assertEqual(df.shape[0], 4)
report = os.path.join(temp, "report.html")
csv = os.path.join(temp, "report.csv")
rst = os.path.join(temp, "report.rst")
bench.report(filehtml=report, filecsv=csv, filerst=rst,
title="A Title", description="description")
self.assertTrue(os.path.exists(report))
self.assertTrue(os.path.exists(csv))
self.assertTrue(os.path.exists(rst))
示例12: test_dependencies_ggplot_pip
def test_dependencies_ggplot_pip(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
if "travis" not in sys.executable:
self.common_function("ggplot", use_pip=True)
示例13: test_join_multiple2
def test_join_multiple2(self):
fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__")
filename = os.path.join(os.path.split(
__file__)[0], "data", "database_linked.zip")
temp = get_temp_folder(__file__, "temp_join_multiple2")
filename = unzip(filename, temp)
assert os.path.exists(filename)
db = Database(filename, LOG=fLOG)
db.connect()
where = {"bucket": ("==", "bu###1")}
n1 = db.JoinTreeNode("profile_QSSH", where=where,
parent_key="query", key="query")
n2 = db.JoinTreeNode("url_QSSH", where=where,
parent_key=('url', 'pos'), key=('url', 'pos'))
n1.append(n2)
sql, fields = db.inner_joins(n1, execute=False, create_index=False)
view = db.execute_view(sql)
assert view == [('facebbooklogin', 1, 0, 'bu###1', 86, 0,
'digg.com/security/Hackers_Put_Social_Networks_In_Crosshairs',
'digg.com/security/Hackers_Put_Social_Networks_In_Crosshairs',
1, 0, 1, 1, 0, 0, 0, 0)]
assert "WHERE" in sql
db.close()
示例14: test_install
def test_install(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
fold = os.path.abspath(os.path.split(__file__)[0])
temp = os.path.join(fold, "temp_download")
if not os.path.exists(temp):
os.mkdir(temp)
for _ in os.listdir(temp):
if os.path.isfile(os.path.join(temp, _)):
os.remove(os.path.join(temp, _))
if os.path.exists(os.path.join(temp, "jsdifflib-master")):
for _ in os.listdir(os.path.join(temp, "jsdifflib-master")):
os.remove(
os.path.join(
os.path.join(
temp,
"jsdifflib-master"),
_))
m = ModuleInstall("jsdifflib", "github", gitrepo="cemerick", fLOG=fLOG)
files = m.download(temp_folder=temp, unzipFile=True, source="2")
assert len(files) > 0
for _ in files:
assert os.path.exists(_)
示例15: test_notebook_runner_2a_ml
def test_notebook_runner_2a_ml(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
from ensae_teaching_cs.data import simple_database
temp = get_temp_folder(__file__, "temp_notebook2a_ml4")
keepnote = ls_notebooks("td2a_ml")
keepnote = [_ for _ in keepnote if "overfitting" in _]
shutil.copy(simple_database(), temp)
def filter(i, n):
if "SNCF" in n:
return False
if "Scraping" in n:
return False
if "deep_python" in n:
return False
if "h2o" in n:
# h2o is not working from a virtual environment
return False
if "td2a" in os.path.split(n)[-1]:
# already tested by others tests
return False
if "libraries" in n:
return False
return True
execute_notebooks(temp, keepnote, filter, fLOG=fLOG,
clean_function=clean_function_1a,
dump=ensae_teaching_cs)