在第一部分一切正常。我得到了一个印刷品:“1.5588”
favoriteBtn = (CheckBox) findViewById(R.id.favorite_toggle);
favoriteBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if(isChecked){
Toast.makeText(HomeActivity.this, "changed", Toast.LENGTH_SHORT);
addFavorite(url);
}else{
Toast.makeText(HomeActivity.this, "again changed", Toast.LENGTH_SHORT);
removeFavorite(url);
}
}
});
但是当使用以下数据时,我收到消息“ValueError:x_new中的值低于插值范围。” :
from scipy import interpolate
x = [0., -1.7388, -1.7064, -1.6776, -1.6452, -1.6452, -1.6128, -1.584, -1.5516, -1.5192, -1.5192, -1.4868, -1.458, -1.4256, -1.3968, -1.3968, -1.3644, -1.332, -1.2996, -1.2708, -1.2708, -1.2384, -1.206, -1.1772, -1.1448, -1.1448, -1.1124, -1.0836, -1.0512, -1.0188, -1.0188, -0.9864, -0.954, -0.9252, -0.8928, -0.8928, -0.8604, -0.8316, -0.7956, -0.7956, -0.7704, -0.738, -0.7056, -0.6732, -0.6732, -0.6444, -0.612, -0.5832, -0.5508, -0.5184, -0.5184, -0.486, -0.4572, -0.4248, -0.396, -0.396, -0.36, -0.3312, -0.2988, -0.27, -0.27, -0.2376, -0.2052, -0.1728, -0.144, -0.144, -0.1116, -0.0792, -0.0468, -0.018, -0.018, 0.0108, 0.0396, 0.072, 0.1044, 0.1044, 0.1368, 0.1656, 0.198, 0.2268, 0.2268, 0.2592, 0.2916, 0.324, 0.3528, 0.3528, 0.3852, 0.4176, 0.4464, 0.4788, 0.4788, 0.5076, 0.54, 0.5724, 0.6048, 0.6048, 0.6372, 0.666, 0.6984, 0.7272, 0.7272, 0.7632, 0.792, 0.8208, 0.8532, 0.8532, 0.8856, 0.9144, 0.9504, 0.9792, 0.9792, 1.0116, 1.0404, 1.0728, 1.1052, 1.1052, 1.134, 1.1664, 1.1988, 1.2312, 1.2312, 1.26, 1.2924, 1.3248, 1.3536, 1.3536, 1.386, 1.4184, 1.4472, 1.4796, 1.4796, 1.512, 1.5408, 1.5768, 1.6056, 1.638, 1.638, 1.6668, 1.6992, 1.7316, 1.7316, 1.7604, 1.7928, 1.7676, 1.7676]
y = [0., 54., 55., 70., 69., 71., 68., 68., 73., 65., 71., 78., 78., 79., 80., 81., 84., 78., 79., 82., 89., 92., 95., 101., 99., 101., 106., 102., 97., 110., 115., 105., 109., 102., 98., 104., 108., 106., 112., 104., 111., 119., 123., 129., 135., 135., 144., 141., 146., 143., 151., 149., 159., 166., 168., 169., 171., 176., 181., 177., 176., 185., 182., 187., 185., 186., 186., 177., 174., 172., 181., 183., 183., 183., 185., 175., 180., 189., 185., 183., 185., 188., 192., 185., 186., 195., 194., 196., 201., 205., 205., 207., 201., 201., 204., 208., 193., 199., 187., 179., 172., 176., 172., 172., 160., 148., 147., 139., 144., 154., 145., 146., 156., 148., 151., 153., 147., 148., 136., 134., 122., 117., 119., 121., 119., 118., 120., 114., 117., 113., 109., 102., 101., 100., 106., 102., 96., 101., 96., 96., 94., 92., 86., 87., 90.]
yh = np.max(y)/2
n = len(x)
interpfunc = interpolate.interp1d(y[n/2:],x[n/2:], kind = 'linear')
x2 = interpfunc(yh)
print x2