Skip to content
Permalink
Browse files

add function corrplot from biokit

  • Loading branch information...
sdpython committed Sep 20, 2015
1 parent a52d09e commit 1cba2200759fbc84e0efdaf45753be53bd614aaf
@@ -109,6 +109,7 @@ Versions
* **change:** update to antlr 4.5, add CSharp grammar
* **new:** new magic command ``textdiff``
* **new:** new magic command ``nb_menu`` to display a menu from all available section in the notebook
* **new:** function Corrplot copied from module biokit (works in python 3)

* **1.0 - 2014/11/10**
* **add:** add magic command ``%tail_stderr`` for class AzureClient
@@ -0,0 +1,85 @@
"""
@brief test log(time=1s)
You should indicate a time in seconds. The program ``run_unittests.py``
will sort all test files by increasing time and run them.
"""


import sys
import os
import unittest
import pandas
import string
import numpy


try:
import src
import pyquickhelper
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..")))
if path not in sys.path:
sys.path.append(path)
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
import src
import pyquickhelper

from pyquickhelper import fLOG, get_temp_folder
from src.pyensae.graph_helper import Corrplot
from pyquickhelper.pycode import fix_tkinter_issues_virtualenv


class TestGraph (unittest.TestCase):

def test_graph_corrplot(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")

if "travis" in sys.executable:
# it requires scipy which is not included in the requirements.txt
return

fix_tkinter_issues_virtualenv()
from matplotlib import pyplot as plt
plt.style.use('ggplot')

temp = get_temp_folder(__file__, "temp_corrplot")
letters = "ABCDEFGHIJKLMNOP"[0:10]
df = pandas.DataFrame(
dict(((k, numpy.random.random(10) + ord(k) - 65) for k in letters)))
df = df.corr()

fig = plt.figure(num=None, facecolor='white')
ax = plt.subplot(1, 1, 1, aspect='equal', axisbg='white')

c = Corrplot(df)
ax = c.plot(fig=fig, ax=ax)

fLOG("save")
img = os.path.join(temp, "corrplot.png")
fig.savefig(img)
fLOG("close")
plt.close('all')
fLOG("end")
assert os.path.exists(img)

if __name__ == "__main__":
unittest.main()
@@ -50,11 +50,12 @@ def test_notebook_folium(self):
temp = get_temp_folder(__file__, "temp_folium")
outfile = os.path.join(temp, 'osm.html')

if sys.platform.startswith("win") and ("anaconda" in sys.base_prefix or \
"_condavir" in sys.executable):
if sys.platform.startswith("win") and ("anaconda" in sys.base_prefix or
"_condavir" in sys.executable):
# an expected error
# jinja2.exceptions.TemplateNotFound: tiles\openstreetmap\tiles.txt
warnings.warn("test_notebook_folium not run on Anaconda, it raises that error: jinja2.exceptions.TemplateNotFound: tiles/openstreetmap/tiles.txt")
warnings.warn(
"test_notebook_folium not run on Anaconda, it raises that error: jinja2.exceptions.TemplateNotFound: tiles/openstreetmap/tiles.txt")
return

import folium
@@ -81,4 +81,5 @@ dbfread
goslate
python-linkedin
pyquickhelper
pymyinstall
pymyinstall
colormap
@@ -175,7 +175,7 @@ def write_version():
packages=packages,
package_dir=package_dir,
package_data=package_data,
install_requires=["pyquickhelper"],
install_requires=["pyquickhelper", "colormap"],
extras_require={
'graph_helper': ['matplotlib'],
'languages': ['antlr4-python3-runtime'],
@@ -4,3 +4,4 @@
"""

from .graphviz_helper import run_dot
from .corrplot import Corrplot

0 comments on commit 1cba220

Please sign in to comment.
You can’t perform that action at this time.