本文整理汇总了Python中pyquickhelper.loghelper.fLOG函数的典型用法代码示例。如果您正苦于以下问题:Python fLOG函数的具体用法?Python fLOG怎么用?Python fLOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fLOG函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:sdpython,项目名称:ensae_teaching_cs,代码行数:27,代码来源:test_propagation_epidemic.py
示例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
开发者ID:sdpython,项目名称:ensae_teaching_cs,代码行数:28,代码来源:test_puzzle_girafe.py
示例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)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:25,代码来源:test_notebooks_exporter.py
示例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")
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:30,代码来源:test_encryption_cli.py
示例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",
]
)
开发者ID:sdpython,项目名称:pysqllike,代码行数:26,代码来源:test_code_style.py
示例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")
开发者ID:sdpython,项目名称:jupytalk,代码行数:26,代码来源:test_pydata2016_pydy.py
示例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)
开发者ID:sdpython,项目名称:ensae_teaching_cs,代码行数:29,代码来源:test_construction_classique.py
示例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)
开发者ID:sdpython,项目名称:mlstatpy,代码行数:31,代码来源:test_completion_profiling.py
示例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")
开发者ID:sdpython,项目名称:ensae_teaching_cs,代码行数:7,代码来源:test_LONG_1_2_3_coverage_notebook6_201710b.py
示例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")
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:7,代码来源:test_yaml_split_bug2.py
示例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))
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:29,代码来源:test_grid_benchmark.py
示例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)
开发者ID:sdpython,项目名称:pymyinstall,代码行数:7,代码来源:test_module_dependencies.py
示例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()
开发者ID:sdpython,项目名称:pyensae,代码行数:28,代码来源:test_database_join_multiple.py
示例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(_)
开发者ID:sdpython,项目名称:pymyinstall,代码行数:26,代码来源:test_download.py
示例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)
开发者ID:sdpython,项目名称:ensae_teaching_cs,代码行数:32,代码来源:test_LONG_2A_notebook_ml4.py
示例16: test_notebook_js
def test_notebook_js(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
path = os.path.abspath(os.path.split(__file__)[0])
fold = os.path.normpath(os.path.join(path, "notebooks_js"))
nbs = [os.path.join(fold, _)
for _ in os.listdir(fold) if ".ipynb" in _]
formats = ["slides", "present", "ipynb", "html",
"python", "rst", "pdf"]
if sys.platform.startswith("win"):
formats.append("docx")
temp = get_temp_folder(__file__, "temp_nb_bug_js")
res = process_notebooks(nbs, temp, temp, formats=formats)
fLOG("*****", len(res))
for _ in res:
if not os.path.exists(_[0]):
raise Exception(_[0])
check = os.path.join(temp, "using_qgrid_with_jsdf.tex")
with open(check, "r", encoding="utf8") as f:
content = f.read()
if "\\section{" not in content:
raise Exception(content)
checks = [os.path.join(temp, "reveal.js"),
os.path.join(temp, "require.js")]
for check in checks:
if not os.path.exists(check):
raise Exception(check)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:32,代码来源:test_notebooks_bug_js.py
示例17: test_interactive2_RadioWidget
def test_interactive2_RadioWidget(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
fix_tkinter_issues_virtualenv(fLOG=fLOG)
import matplotlib.pyplot as plt
def plot(amplitude, color, sele):
fig, ax = plt.subplots(figsize=(4, 3),
subplot_kw={'axisbelow': True})
ax.grid(color='w', linewidth=2, linestyle='solid')
x = np.linspace(0, 10, 1000)
ax.plot(x, amplitude * np.sin(x), color=color,
lw=5, alpha=0.4)
ax.set_xlim(0, 10)
ax.set_ylim(-1.1, 1.1)
return fig
res = StaticInteract(plot,
amplitude=RangeWidget(0.1, 0.3, 0.1, default=0.2),
color=RadioWidget(
['blue', 'green'], default='blue'),
sele=DropDownWidget(['a', 'b']))
self.assertNotEmpty(res)
ht = res.html()
self.assertNotEmpty(ht)
plt.close('all')
fLOG("end")
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:30,代码来源:test_interactive.py
示例18: _pipy_version
def _pipy_version(self, mods, nbmax=15):
error = []
annoying = []
for mod in mods:
try:
v = mod.get_pypi_version()
fLOG(mod.name, " --> ", v)
if v is None:
error.append((mod.name, "None", None))
except MissingPackageOnPyPiException as e:
error.append((mod.name, "pipy", e))
except MissingVersionOnPyPiException as ee:
error.append((mod.name, "version", ee))
except AnnoyingPackageException as eee:
annoying.append((mod.name, "?", eee))
if len(error) > nbmax:
# we accept some errors
# joblib seems to give errors from time to time
# multipledispatch
# ipython --> jupyter (transitionning)
raise MissingPackageOnPyPiException("Two many errors\n" +
"\n".join("{0}:{1}\n {2}".format(a, b, c) for a, b, c in sorted(error)))
if len(annoying) > 0:
fLOG("Annoying\n", "\n".join(str(_) for _ in annoying))
warnings.warn("ANNOYING PACKAGES\n" + "\n".join(annoying))
开发者ID:sdpython,项目名称:pymyinstall,代码行数:27,代码来源:test_LONG_all_pypi_module.py
示例19: test_install_azure
def test_install_azure(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
fold = os.path.abspath(os.path.split(__file__)[0])
temp = os.path.join(fold, "temp_download_azure")
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, _))
r1 = compare_version("2.0.0rc5", "1.0.3")
r2 = compare_version("1.0.3", "2.0.0rc5")
assert r1 * r2 < 0
assert r1 > 0
if sys.platform.startswith("win") and sys.version_info[0] >= 3:
m = find_module_install("azure")
if m.pip_options is None:
raise Exception("no pip_options, issue '{0}'".format(m))
m.fLOG = fLOG
name = m.download(temp_folder=temp)
v = get_wheel_version(name)
r = compare_version(v, "1.9.9")
if r <= 0:
raise Exception(
"unexception version for '{0}',\nshould be >= 1.9.9 not '{1}'".format(name, v))
fLOG(m.version, v, name)
assert os.path.exists(name)
assert "azure" in name
开发者ID:sdpython,项目名称:pymyinstall,代码行数:31,代码来源:test_download_azure.py
注:本文中的pyquickhelper.loghelper.fLOG函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论