<s> import numpy as np <EOL> import pandas as pd <EOL> from bokeh . charts . models import CompositeGlyph <EOL> from bokeh . charts . glyphs import ( AreaGlyph , LineGlyph , PointGlyph , StepGlyph , <EOL> BarGlyph , BoxGlyph , BarGlyph ) <EOL> from bokeh . charts . operations import stack <EOL> from bokeh . charts . stats import stats <EOL> from bokeh . models import ColumnDataSource <EOL> def test_area_base_values ( test_data ) : <EOL> """<STR_LIT>""" <EOL> x = pd . Series ( test_data . array_data [ <NUM_LIT:0> ] ) <EOL> y = pd . Series ( test_data . array_data [ <NUM_LIT:1> ] ) <EOL> ag = AreaGlyph ( x = x , y = y ) <EOL> assert ag . source . data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] == <NUM_LIT:0> <EOL> assert ag . source . data [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ - <NUM_LIT:1> ] == <NUM_LIT:0> <EOL> def test_xyglyph_xy_range ( ) : <EOL> def check_bounds ( xyg , xmin = <NUM_LIT:0> , xmax = <NUM_LIT:4> , ymin = <NUM_LIT:1> , ymax = <NUM_LIT:5> ) : <EOL> assert xyg . x_min == xmin <EOL> assert xyg . x_max == xmax <EOL> assert xyg . y_min == ymin <EOL> assert xyg . y_max == ymax <EOL> for Glyph in [ LineGlyph , PointGlyph ] : <EOL> x = pd . Series ( [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> y = pd . Series ( [ <NUM_LIT:5> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> ] ) <EOL> xyg = Glyph ( x = x , y = y ) <EOL> check_bounds ( xyg ) <EOL> x [ <NUM_LIT:1> ] = x [ <NUM_LIT:2> ] = np . nan <EOL> xyg = Glyph ( x = x , y = y ) <EOL> check_bounds ( xyg ) <EOL> x [ <NUM_LIT:0> ] = np . nan <EOL> xyg = Glyph ( x = x , y = y ) <EOL> check_bounds ( xyg , xmin = <NUM_LIT:3> ) <EOL> x [ <NUM_LIT:4> ] = np . nan <EOL> xyg = Glyph ( x = x , y = y ) <EOL> check_bounds ( xyg , xmin = <NUM_LIT:3> , xmax = <NUM_LIT:3> ) <EOL> y [ <NUM_LIT:1> ] = y [ <NUM_LIT:2> ] = np . nan <EOL> xyg = Glyph ( x = x , y = y ) <EOL> check_bounds ( xyg , xmin = <NUM_LIT:3> , xmax = <NUM_LIT:3> ) <EOL> y [ <NUM_LIT:0> ] = np . nan <EOL> xyg = Glyph ( x = x , y = y ) <EOL> check_bounds ( xyg , xmin = <NUM_LIT:3> , xmax = <NUM_LIT:3> , ymax = <NUM_LIT:2> ) <EOL> y [ <NUM_LIT:4> ] = np . nan <EOL> xyg = Glyph ( x = x , y = y ) <EOL> check_bounds ( xyg , xmin = <NUM_LIT:3> , xmax = <NUM_LIT:3> , ymax = <NUM_LIT:2> , ymin = <NUM_LIT:2> ) <EOL> def test_comp_glyph_no_inputs ( ) : <EOL> cg = CompositeGlyph ( ) <EOL> assert isinstance ( cg . data , dict ) <EOL> assert isinstance ( cg . df , pd . DataFrame ) <EOL> assert isinstance ( cg . source , ColumnDataSource ) <EOL> def test_comp_glyph_array_input ( test_data ) : <EOL> cg = CompositeGlyph ( values = test_data . array_data [ <NUM_LIT:0> ] ) <EOL> assert cg . data [ '<STR_LIT>' ] is not None <EOL> def test_bar_stacking ( ) : <EOL> bar1 , bar2 , bar3 = BarGlyph ( '<STR_LIT:a>' , <NUM_LIT:5> ) , BarGlyph ( '<STR_LIT:a>' , <NUM_LIT:2> ) , BarGlyph ( '<STR_LIT:b>' , <NUM_LIT:2> ) <EOL> stack ( bar1 , bar2 , bar3 ) <EOL> assert bar1 . y_max == bar2 . y_min <EOL> assert bar3 . y_min == <NUM_LIT:0.0> <EOL> def test_area_stacking ( ) : <EOL> area1 = AreaGlyph ( x = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] , y = [ <NUM_LIT:2> , <NUM_LIT:9> , <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:10> ] ) <EOL> area2 = AreaGlyph ( x = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] , y = [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> stack ( area1 , area2 ) <EOL> area2_stacked_values = [ <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:10> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:11> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:9> , <NUM_LIT:2> , <NUM_LIT:0> ] <EOL> comparison = pd . Series ( area2_stacked_values ) - pd . Series ( area2 . df [ <EOL> '<STR_LIT>' ] . values [ <NUM_LIT:0> ] ) <EOL> assert comparison . sum ( ) == <NUM_LIT:0> <EOL> def test_boxplot ( ) : <EOL> data = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> box = BoxGlyph ( label = { '<STR_LIT>' : '<STR_LIT:a>' } , values = data , color = '<STR_LIT>' ) <EOL> assert box . q1 == <NUM_LIT> <EOL> assert box . q2 == <NUM_LIT> <EOL> assert box . q3 == <NUM_LIT> <EOL> assert box . iqr == <NUM_LIT> <EOL> assert box . w0 == <NUM_LIT> <EOL> assert box . w1 == <NUM_LIT> <EOL> def test_bar_single_value ( ) : <EOL> data = [ <NUM_LIT> ] <EOL> for stat in stats . keys ( ) : <EOL> bar = BarGlyph ( label = { '<STR_LIT>' : '<STR_LIT:a>' } , values = data , color = '<STR_LIT>' , agg = '<STR_LIT>' ) <EOL> assert bar . get_start ( ) == <NUM_LIT:0> <EOL> if stats != '<STR_LIT:count>' : <EOL> assert bar . get_end ( ) == <NUM_LIT> <EOL> else : <EOL> assert bar . get_end ( ) == <NUM_LIT:1> </s>
