-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_cmplot.py
28 lines (20 loc) · 8.82 KB
/
test_cmplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from pandas import read_json
from cmplot import cmplot
from plotly.graph_objects import Figure
import pytest
IRIS_JSON = '{"Sepal.Length":{"1":5.1,"2":4.9,"3":4.7,"4":4.6,"5":5.0,"6":5.4,"7":4.6,"8":5.0,"9":4.4,"10":4.9,"11":5.4,"12":4.8,"13":4.8,"14":4.3,"15":5.8,"16":5.7,"17":5.4,"18":5.1,"19":5.7,"20":5.1,"21":5.4,"22":5.1,"23":4.6,"24":5.1,"25":4.8,"26":5.0,"27":5.0,"28":5.2,"29":5.2,"30":4.7,"31":4.8,"32":5.4,"33":5.2,"34":5.5,"35":4.9,"36":5.0,"37":5.5,"38":4.9,"39":4.4,"40":5.1,"41":5.0,"42":4.5,"43":4.4,"44":5.0,"45":5.1,"46":4.8,"47":5.1,"48":4.6,"49":5.3,"50":5.0,"51":7.0,"52":6.4,"53":6.9,"54":5.5,"55":6.5,"56":5.7,"57":6.3,"58":4.9,"59":6.6,"60":5.2,"61":5.0,"62":5.9,"63":6.0,"64":6.1,"65":5.6,"66":6.7,"67":5.6,"68":5.8,"69":6.2,"70":5.6,"71":5.9,"72":6.1,"73":6.3,"74":6.1,"75":6.4,"76":6.6,"77":6.8,"78":6.7,"79":6.0,"80":5.7,"81":5.5,"82":5.5,"83":5.8,"84":6.0,"85":5.4,"86":6.0,"87":6.7,"88":6.3,"89":5.6,"90":5.5,"91":5.5,"92":6.1,"93":5.8,"94":5.0,"95":5.6,"96":5.7,"97":5.7,"98":6.2,"99":5.1,"100":5.7,"101":6.3,"102":5.8,"103":7.1,"104":6.3,"105":6.5,"106":7.6,"107":4.9,"108":7.3,"109":6.7,"110":7.2,"111":6.5,"112":6.4,"113":6.8,"114":5.7,"115":5.8,"116":6.4,"117":6.5,"118":7.7,"119":7.7,"120":6.0,"121":6.9,"122":5.6,"123":7.7,"124":6.3,"125":6.7,"126":7.2,"127":6.2,"128":6.1,"129":6.4,"130":7.2,"131":7.4,"132":7.9,"133":6.4,"134":6.3,"135":6.1,"136":7.7,"137":6.3,"138":6.4,"139":6.0,"140":6.9,"141":6.7,"142":6.9,"143":5.8,"144":6.8,"145":6.7,"146":6.7,"147":6.3,"148":6.5,"149":6.2,"150":5.9},"Sepal.Width":{"1":3.5,"2":3.0,"3":3.2,"4":3.1,"5":3.6,"6":3.9,"7":3.4,"8":3.4,"9":2.9,"10":3.1,"11":3.7,"12":3.4,"13":3.0,"14":3.0,"15":4.0,"16":4.4,"17":3.9,"18":3.5,"19":3.8,"20":3.8,"21":3.4,"22":3.7,"23":3.6,"24":3.3,"25":3.4,"26":3.0,"27":3.4,"28":3.5,"29":3.4,"30":3.2,"31":3.1,"32":3.4,"33":4.1,"34":4.2,"35":3.1,"36":3.2,"37":3.5,"38":3.6,"39":3.0,"40":3.4,"41":3.5,"42":2.3,"43":3.2,"44":3.5,"45":3.8,"46":3.0,"47":3.8,"48":3.2,"49":3.7,"50":3.3,"51":3.2,"52":3.2,"53":3.1,"54":2.3,"55":2.8,"56":2.8,"57":3.3,"58":2.4,"59":2.9,"60":2.7,"61":2.0,"62":3.0,"63":2.2,"64":2.9,"65":2.9,"66":3.1,"67":3.0,"68":2.7,"69":2.2,"70":2.5,"71":3.2,"72":2.8,"73":2.5,"74":2.8,"75":2.9,"76":3.0,"77":2.8,"78":3.0,"79":2.9,"80":2.6,"81":2.4,"82":2.4,"83":2.7,"84":2.7,"85":3.0,"86":3.4,"87":3.1,"88":2.3,"89":3.0,"90":2.5,"91":2.6,"92":3.0,"93":2.6,"94":2.3,"95":2.7,"96":3.0,"97":2.9,"98":2.9,"99":2.5,"100":2.8,"101":3.3,"102":2.7,"103":3.0,"104":2.9,"105":3.0,"106":3.0,"107":2.5,"108":2.9,"109":2.5,"110":3.6,"111":3.2,"112":2.7,"113":3.0,"114":2.5,"115":2.8,"116":3.2,"117":3.0,"118":3.8,"119":2.6,"120":2.2,"121":3.2,"122":2.8,"123":2.8,"124":2.7,"125":3.3,"126":3.2,"127":2.8,"128":3.0,"129":2.8,"130":3.0,"131":2.8,"132":3.8,"133":2.8,"134":2.8,"135":2.6,"136":3.0,"137":3.4,"138":3.1,"139":3.0,"140":3.1,"141":3.1,"142":3.1,"143":2.7,"144":3.2,"145":3.3,"146":3.0,"147":2.5,"148":3.0,"149":3.4,"150":3.0},"Petal.Length":{"1":1.4,"2":1.4,"3":1.3,"4":1.5,"5":1.4,"6":1.7,"7":1.4,"8":1.5,"9":1.4,"10":1.5,"11":1.5,"12":1.6,"13":1.4,"14":1.1,"15":1.2,"16":1.5,"17":1.3,"18":1.4,"19":1.7,"20":1.5,"21":1.7,"22":1.5,"23":1.0,"24":1.7,"25":1.9,"26":1.6,"27":1.6,"28":1.5,"29":1.4,"30":1.6,"31":1.6,"32":1.5,"33":1.5,"34":1.4,"35":1.5,"36":1.2,"37":1.3,"38":1.4,"39":1.3,"40":1.5,"41":1.3,"42":1.3,"43":1.3,"44":1.6,"45":1.9,"46":1.4,"47":1.6,"48":1.4,"49":1.5,"50":1.4,"51":4.7,"52":4.5,"53":4.9,"54":4.0,"55":4.6,"56":4.5,"57":4.7,"58":3.3,"59":4.6,"60":3.9,"61":3.5,"62":4.2,"63":4.0,"64":4.7,"65":3.6,"66":4.4,"67":4.5,"68":4.1,"69":4.5,"70":3.9,"71":4.8,"72":4.0,"73":4.9,"74":4.7,"75":4.3,"76":4.4,"77":4.8,"78":5.0,"79":4.5,"80":3.5,"81":3.8,"82":3.7,"83":3.9,"84":5.1,"85":4.5,"86":4.5,"87":4.7,"88":4.4,"89":4.1,"90":4.0,"91":4.4,"92":4.6,"93":4.0,"94":3.3,"95":4.2,"96":4.2,"97":4.2,"98":4.3,"99":3.0,"100":4.1,"101":6.0,"102":5.1,"103":5.9,"104":5.6,"105":5.8,"106":6.6,"107":4.5,"108":6.3,"109":5.8,"110":6.1,"111":5.1,"112":5.3,"113":5.5,"114":5.0,"115":5.1,"116":5.3,"117":5.5,"118":6.7,"119":6.9,"120":5.0,"121":5.7,"122":4.9,"123":6.7,"124":4.9,"125":5.7,"126":6.0,"127":4.8,"128":4.9,"129":5.6,"130":5.8,"131":6.1,"132":6.4,"133":5.6,"134":5.1,"135":5.6,"136":6.1,"137":5.6,"138":5.5,"139":4.8,"140":5.4,"141":5.6,"142":5.1,"143":5.1,"144":5.9,"145":5.7,"146":5.2,"147":5.0,"148":5.2,"149":5.4,"150":5.1},"Petal.Width":{"1":0.2,"2":0.2,"3":0.2,"4":0.2,"5":0.2,"6":0.4,"7":0.3,"8":0.2,"9":0.2,"10":0.1,"11":0.2,"12":0.2,"13":0.1,"14":0.1,"15":0.2,"16":0.4,"17":0.4,"18":0.3,"19":0.3,"20":0.3,"21":0.2,"22":0.4,"23":0.2,"24":0.5,"25":0.2,"26":0.2,"27":0.4,"28":0.2,"29":0.2,"30":0.2,"31":0.2,"32":0.4,"33":0.1,"34":0.2,"35":0.2,"36":0.2,"37":0.2,"38":0.1,"39":0.2,"40":0.2,"41":0.3,"42":0.3,"43":0.2,"44":0.6,"45":0.4,"46":0.3,"47":0.2,"48":0.2,"49":0.2,"50":0.2,"51":1.4,"52":1.5,"53":1.5,"54":1.3,"55":1.5,"56":1.3,"57":1.6,"58":1.0,"59":1.3,"60":1.4,"61":1.0,"62":1.5,"63":1.0,"64":1.4,"65":1.3,"66":1.4,"67":1.5,"68":1.0,"69":1.5,"70":1.1,"71":1.8,"72":1.3,"73":1.5,"74":1.2,"75":1.3,"76":1.4,"77":1.4,"78":1.7,"79":1.5,"80":1.0,"81":1.1,"82":1.0,"83":1.2,"84":1.6,"85":1.5,"86":1.6,"87":1.5,"88":1.3,"89":1.3,"90":1.3,"91":1.2,"92":1.4,"93":1.2,"94":1.0,"95":1.3,"96":1.2,"97":1.3,"98":1.3,"99":1.1,"100":1.3,"101":2.5,"102":1.9,"103":2.1,"104":1.8,"105":2.2,"106":2.1,"107":1.7,"108":1.8,"109":1.8,"110":2.5,"111":2.0,"112":1.9,"113":2.1,"114":2.0,"115":2.4,"116":2.3,"117":1.8,"118":2.2,"119":2.3,"120":1.5,"121":2.3,"122":2.0,"123":2.0,"124":1.8,"125":2.1,"126":1.8,"127":1.8,"128":1.8,"129":2.1,"130":1.6,"131":1.9,"132":2.0,"133":2.2,"134":1.5,"135":1.4,"136":2.3,"137":2.4,"138":1.8,"139":1.8,"140":2.1,"141":2.4,"142":2.3,"143":1.9,"144":2.3,"145":2.5,"146":2.3,"147":1.9,"148":2.0,"149":2.3,"150":1.8},"Species":{"1":"setosa","2":"setosa","3":"setosa","4":"setosa","5":"setosa","6":"setosa","7":"setosa","8":"setosa","9":"setosa","10":"setosa","11":"setosa","12":"setosa","13":"setosa","14":"setosa","15":"setosa","16":"setosa","17":"setosa","18":"setosa","19":"setosa","20":"setosa","21":"setosa","22":"setosa","23":"setosa","24":"setosa","25":"setosa","26":"setosa","27":"setosa","28":"setosa","29":"setosa","30":"setosa","31":"setosa","32":"setosa","33":"setosa","34":"setosa","35":"setosa","36":"setosa","37":"setosa","38":"setosa","39":"setosa","40":"setosa","41":"setosa","42":"setosa","43":"setosa","44":"setosa","45":"setosa","46":"setosa","47":"setosa","48":"setosa","49":"setosa","50":"setosa","51":"versicolor","52":"versicolor","53":"versicolor","54":"versicolor","55":"versicolor","56":"versicolor","57":"versicolor","58":"versicolor","59":"versicolor","60":"versicolor","61":"versicolor","62":"versicolor","63":"versicolor","64":"versicolor","65":"versicolor","66":"versicolor","67":"versicolor","68":"versicolor","69":"versicolor","70":"versicolor","71":"versicolor","72":"versicolor","73":"versicolor","74":"versicolor","75":"versicolor","76":"versicolor","77":"versicolor","78":"versicolor","79":"versicolor","80":"versicolor","81":"versicolor","82":"versicolor","83":"versicolor","84":"versicolor","85":"versicolor","86":"versicolor","87":"versicolor","88":"versicolor","89":"versicolor","90":"versicolor","91":"versicolor","92":"versicolor","93":"versicolor","94":"versicolor","95":"versicolor","96":"versicolor","97":"versicolor","98":"versicolor","99":"versicolor","100":"versicolor","101":"virginica","102":"virginica","103":"virginica","104":"virginica","105":"virginica","106":"virginica","107":"virginica","108":"virginica","109":"virginica","110":"virginica","111":"virginica","112":"virginica","113":"virginica","114":"virginica","115":"virginica","116":"virginica","117":"virginica","118":"virginica","119":"virginica","120":"virginica","121":"virginica","122":"virginica","123":"virginica","124":"virginica","125":"virginica","126":"virginica","127":"virginica","128":"virginica","129":"virginica","130":"virginica","131":"virginica","132":"virginica","133":"virginica","134":"virginica","135":"virginica","136":"virginica","137":"virginica","138":"virginica","139":"virginica","140":"virginica","141":"virginica","142":"virginica","143":"virginica","144":"virginica","145":"virginica","146":"virginica","147":"virginica","148":"virginica","149":"virginica","150":"virginica"}}'
df = read_json(IRIS_JSON)
def test_cmplot_traces_generation():
(traces, layout) = (cmplot(df, xcol="Species",
ycol=["Sepal.Length", "Petal.Length"],
colorrange=3,
pointshapes=["star-triangle-up", "star-diamond", "star-square"],
side="both",
pointsmaxdisplayed=3,
title="Iris dataset; Anderson, Edgar (1935) Fisher, R. A. (1936)"
))
def test_plot_of_cmplot():
Figure(*cmplot(df, xcol="Species"))
def test_symbol_not_present():
with pytest.raises(ValueError):
cmplot(df, xcol="Species", ycol=["Sepallll", "Petal.Length"])