<s> '''<STR_LIT>''' <EOL> import pandas as pd <EOL> import numpy as np <EOL> import scipy . stats as spystats <EOL> import nose . tools as nt <EOL> from scipy . special import gamma <EOL> from pandas . util . testing import assert_almost_equal <EOL> from climatic import toolbox <EOL> class TestToolbox ( ) : <EOL> '''<STR_LIT>''' <EOL> def setup ( self ) : <EOL> bins = np . arange ( <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:1> ) <EOL> Vmean = <NUM_LIT:9> <EOL> A = <NUM_LIT:9> <EOL> k = <NUM_LIT:2> <EOL> AVmean = Vmean / ( gamma ( <NUM_LIT:1> + <NUM_LIT:1> / k ) ) <EOL> step_size = bins [ <NUM_LIT:1> ] - bins [ <NUM_LIT:0> ] <EOL> self . rv_A = spystats . exponweib ( <NUM_LIT:1> , k , scale = A , floc = <NUM_LIT:0> ) <EOL> self . rv_Vmean = spystats . exponweib ( <NUM_LIT:1> , k , scale = AVmean , floc = <NUM_LIT:0> ) <EOL> hourly_A = self . rv_A . pdf ( bins ) * <NUM_LIT> * step_size <EOL> normed_A = hourly_A / hourly_A . sum ( ) <EOL> hourly_Vmean = self . rv_Vmean . pdf ( bins ) * <NUM_LIT> * step_size <EOL> normed_Vmean = hourly_Vmean / hourly_Vmean . sum ( ) <EOL> self . hourlyA = pd . DataFrame ( { '<STR_LIT>' : hourly_A , <EOL> '<STR_LIT>' : normed_A } , <EOL> index = bins ) <EOL> self . hourlyVmean = pd . DataFrame ( { '<STR_LIT>' : hourly_Vmean , <EOL> '<STR_LIT>' : normed_Vmean } , <EOL> index = bins ) <EOL> def test_weib_hourly_Ak ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . weibull = toolbox . weibull_hourly ( k = <NUM_LIT:2> , A = <NUM_LIT:9> ) <EOL> assert_almost_equal ( self . weibull , self . hourlyA ) <EOL> nt . assert_almost_equal ( self . weibull [ '<STR_LIT>' ] . sum ( ) , <NUM_LIT:1> ) <EOL> def test_weib_hourly_AVmean ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . weibullv = toolbox . weibull_hourly ( k = <NUM_LIT:2> , Vmean = <NUM_LIT:9> ) <EOL> assert_almost_equal ( self . weibullv , self . hourlyA ) <EOL> nt . assert_almost_equal ( self . weibullv [ '<STR_LIT>' ] . sum ( ) , <NUM_LIT:1> ) <EOL> def test_bins ( self ) : <EOL> '''<STR_LIT>''' <EOL> bin1 = np . arange ( <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0.5> ) <EOL> bin2 = np . arange ( <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:0.1> ) <EOL> self . halfbins = toolbox . weibull_hourly ( k = <NUM_LIT:2> , A = <NUM_LIT:9> , bins = bin1 ) <EOL> self . tenthbins = toolbox . weibull_hourly ( k = <NUM_LIT:2> , A = <NUM_LIT:9> , bins = bin2 ) <EOL> nt . assert_greater_equal ( <NUM_LIT> , self . halfbins [ '<STR_LIT>' ] . sum ( ) ) <EOL> nt . assert_less_equal ( <NUM_LIT> , self . halfbins [ '<STR_LIT>' ] . sum ( ) ) <EOL> nt . assert_greater_equal ( <NUM_LIT> , self . tenthbins [ '<STR_LIT>' ] . sum ( ) ) <EOL> nt . assert_less_equal ( <NUM_LIT> , self . tenthbins [ '<STR_LIT>' ] . sum ( ) ) </s>
