def test_parabolic(self): """piecewise constant approximation of parabolic with n = 30, s=5, kap=2""" x = np.array( [ 1.06779661, 1.13559322, 1.20338983, 1.27118644, 1.33898305, 1.40677966, 1.47457627, 1.54237288, 1.61016949, 1.6779661 , 1.74576271, 1.81355932, 1.88135593, 1.94915254, 2.01694915, 2.08474576, 2.15254237, 2.22033898, 2.28813559, 2.3559322 , 2.42372881, 2.49152542, 2.55932203, 2.62711864, 2.69491525, 2.76271186, 2.83050847, 2.89830508, 2.96610169, 3.03389831, 3.10169492, 3.16949153, 3.23728814, 3.30508475, 3.37288136, 3.44067797, 3.50847458, 3.57627119, 3.6440678 , 3.71186441, 3.77966102, 3.84745763, 3.91525424, 3.98305085, 4.05084746, 4.11864407, 4.18644068, 4.25423729, 4.3220339 , 4.38983051, 4.45762712, 4.52542373, 4.59322034, 4.66101695, 4.72881356, 4.79661017, 4.86440678, 4.93220339, 5., 30 ]) y = 1.0/np.array( [ 0.5 , 0.51680552, 0.53332376, 0.54955473, 0.56549842, 0.58115484, 0.59652399, 0.61160586, 0.62640046, 0.64090779, 0.65512784, 0.66906061, 0.68270612, 0.69606435, 0.70913531, 0.72191899, 0.7344154 , 0.74662453, 0.75854639, 0.77018098, 0.7815283 , 0.79258834, 0.8033611 , 0.8138466 , 0.82404481, 0.83395576, 0.84357943, 0.85291583, 0.86196495, 0.8707268 , 0.87920138, 0.88738868, 0.89528871, 0.90290147, 0.91022695, 0.91726515, 0.92401609, 0.93047975, 0.93665613, 0.94254525, 0.94814708, 0.95346165, 0.95848894, 0.96322896, 0.9676817 , 0.97184717, 0.97572537, 0.97931629, 0.98261994, 0.98563631, 0.98836541, 0.99080724, 0.99296179, 0.99482907, 0.99640908, 0.99770181, 0.99870727, 0.99942545, 0.99985636, 1. ]) assert_allclose(u_piecewise_constant(x, y,[2,10]), [0.35695287, 0.87514425], atol=0.003)
def test_linear(self): """piecewise constant approximation of linear with n = 30, s=5, kap=2""" x = np.array( [ 1.06779661, 1.13559322, 1.20338983, 1.27118644, 1.33898305, 1.40677966, 1.47457627, 1.54237288, 1.61016949, 1.6779661 , 1.74576271, 1.81355932, 1.88135593, 1.94915254, 2.01694915, 2.08474576, 2.15254237, 2.22033898, 2.28813559, 2.3559322 , 2.42372881, 2.49152542, 2.55932203, 2.62711864, 2.69491525, 2.76271186, 2.83050847, 2.89830508, 2.96610169, 3.03389831, 3.10169492, 3.16949153, 3.23728814, 3.30508475, 3.37288136, 3.44067797, 3.50847458, 3.57627119, 3.6440678 , 3.71186441, 3.77966102, 3.84745763, 3.91525424, 3.98305085, 4.05084746, 4.11864407, 4.18644068, 4.25423729, 4.3220339 , 4.38983051, 4.45762712, 4.52542373, 4.59322034, 4.66101695, 4.72881356, 4.79661017, 4.86440678, 4.93220339, 5., 30 ]) y = 1.0/np.array( [ 0.5 , 0.50847458, 0.51694915, 0.52542373, 0.53389831, 0.54237288, 0.55084746, 0.55932203, 0.56779661, 0.57627119, 0.58474576, 0.59322034, 0.60169492, 0.61016949, 0.61864407, 0.62711864, 0.63559322, 0.6440678 , 0.65254237, 0.66101695, 0.66949153, 0.6779661 , 0.68644068, 0.69491525, 0.70338983, 0.71186441, 0.72033898, 0.72881356, 0.73728814, 0.74576271, 0.75423729, 0.76271186, 0.77118644, 0.77966102, 0.78813559, 0.79661017, 0.80508475, 0.81355932, 0.8220339 , 0.83050847, 0.83898305, 0.84745763, 0.8559322 , 0.86440678, 0.87288136, 0.88135593, 0.88983051, 0.89830508, 0.90677966, 0.91525424, 0.92372881, 0.93220339, 0.94067797, 0.94915254, 0.95762712, 0.96610169, 0.97457627, 0.98305085, 0.99152542, 1. ]) assert_allclose(u_piecewise_constant(x,y,[2,10]), [0.35902939, 0.88374505], atol=0.003)
def test_const_two_smear_zones_n(self): assert_allclose(u_piecewise_constant([1.5, 3,4], [2, 3, 1], 1.6, n=5), 0.41536586)
def test_const_uavg_uw_muw(self): assert_allclose(u_piecewise_constant([5,30], [2,1], [2, 10], uavg=10, uw=-3, muw=3), [4.869976 , 9.28842172])
def test_const_two_smear_zones_n_kap_m(self): assert_allclose(u_piecewise_constant([1.5, 3,], [2, 3], 1.6, n=5, kap_m=1), 0.41536586)
def test_const_two_smear_zones(self): assert_allclose(u_piecewise_constant([1.5, 3, 5,], [2, 3, 1.0], 1.6), 0.41536586)
def test_const_multi(self): assert_allclose(u_piecewise_constant([2,5,8,10], [2,2,1,1], [2, 10]), [0.4555341, 1.10736022])
def test_ideal_multi(self): assert_allclose(u_piecewise_constant([5, 10], [1, 1],[1,5,10]), [ 0. , 0.94367157, 1.14524187])
def test_ideal1(self): assert_allclose(u_piecewise_constant(10, 1,[1,5,10]), [ 0. , 0.94367157, 1.14524187])