日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

pythoninterp error_Python numpy.interp方法代码示例

發(fā)布時(shí)間:2025/3/15 python 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pythoninterp error_Python numpy.interp方法代码示例 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

本文整理匯總了Python中numpy.interp方法的典型用法代碼示例。如果您正苦于以下問(wèn)題:Python numpy.interp方法的具體用法?Python numpy.interp怎么用?Python numpy.interp使用的例子?那么恭喜您, 這里精選的方法代碼示例或許可以為您提供幫助。您也可以進(jìn)一步了解該方法所在模塊numpy的用法示例。

在下文中一共展示了numpy.interp方法的29個(gè)代碼示例,這些例子默認(rèn)根據(jù)受歡迎程度排序。您可以為喜歡或者感覺(jué)有用的代碼點(diǎn)贊,您的評(píng)價(jià)將有助于我們的系統(tǒng)推薦出更棒的Python代碼示例。

示例1: __init__

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def __init__(self,alpha_max,Tg,xi):

gamma=0.9+(0.05-xi)/(0.3+6*xi)

eta1=0.02+(0.05-xi)/(4+32*xi)

eta1=eta1 if eta1>0 else 0

eta2=1+(0.05-xi)/(0.08+1.6*xi)

eta2=eta2 if eta2>0.55 else 0.55

T=np.linspace(0,6,601)

alpha=[]

for t in T:

if t<0.1:

alpha.append(np.interp(t,[0,0.1],[0.45*alpha_max,eta2*alpha_max]))

elif t

alpha.append(eta2*alpha_max)

elif t<5*Tg:

alpha.append((Tg/t)**gamma*eta2*alpha_max)

else:

alpha.append((eta2*0.2**gamma-eta1*(t-5*Tg))*alpha_max)

self.__spectrum={'T':T,'alpha':alpha}

開(kāi)發(fā)者ID:zhuoju36,項(xiàng)目名稱:StructEngPy,代碼行數(shù):20,

示例2: spectrum_analysis

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def spectrum_analysis(model,n,spec):

"""

sepctrum analysis

params:

n: number of modes to use\n

spec: a list of tuples (period,acceleration response)

"""

freq,mode=eigen_mode(model,n)

M_=np.dot(mode.T,model.M)

M_=np.dot(M_,mode)

K_=np.dot(mode.T,model.K)

K_=np.dot(K_,mode)

C_=np.dot(mode.T,model.C)

C_=np.dot(C_,mode)

d_=[]

for (m_,k_,c_) in zip(M_.diag(),K_.diag(),C_.diag()):

sdof=SDOFSystem(m_,k_)

T=sdof.omega_d()

d_.append(np.interp(T,spec[0],spec[1]*m_))

d=np.dot(d_,mode)

#CQC

return d

開(kāi)發(fā)者ID:zhuoju36,項(xiàng)目名稱:StructEngPy,代碼行數(shù):25,

示例3: nan_helper

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def nan_helper(y):

"""Helper to handle indices and logical indices of NaNs.

Input:

- y, 1d numpy array with possible NaNs

Output:

- nans, logical indices of NaNs

- index, a function, with signature indices= index(logical_indices),

to convert logical indices of NaNs to 'equivalent' indices

Example:

>>> # linear interpolation of NaNs

>>> nans, x= nan_helper(y)

>>> y[nans]= np.interp(x(nans), x(~nans), y[~nans])

"""

return np.isnan(y), lambda z: z.nonzero()[0]

開(kāi)發(fā)者ID:BruceBinBoxing,項(xiàng)目名稱:Deep_Learning_Weather_Forecasting,代碼行數(shù):18,

示例4: test_control_curve_interpolated_json

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_control_curve_interpolated_json(use_parameters):

# this is a little hack-y, as the parameters don't provide access to their

# data once they've been initalised

if use_parameters:

model = load_model("reservoir_with_cc_param_values.json")

else:

model = load_model("reservoir_with_cc.json")

reservoir1 = model.nodes["reservoir1"]

model.setup()

path = os.path.join(os.path.dirname(__file__), "models", "control_curve.csv")

control_curve = pd.read_csv(path)["Control Curve"].values

values = [-8, -6, -4]

@assert_rec(model, reservoir1.cost)

def expected_cost(timestep, si):

# calculate expected cost manually and compare to parameter output

volume_factor = reservoir1._current_pc[si.global_id]

cc = control_curve[timestep.index]

return np.interp(volume_factor, [0.0, cc, 1.0], values[::-1])

model.run()

開(kāi)發(fā)者ID:pywr,項(xiàng)目名稱:pywr,代碼行數(shù):22,

示例5: test_circular_control_curve_interpolated_json

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_circular_control_curve_interpolated_json():

# this is a little hack-y, as the parameters don't provide access to their

# data once they've been initalised

model = load_model("reservoir_with_circular_cc.json")

reservoir1 = model.nodes["reservoir1"]

model.setup()

path = os.path.join(os.path.dirname(__file__), "models", "control_curve.csv")

control_curve = pd.read_csv(path)["Control Curve"].values

values = [-8, -6, -4]

@assert_rec(model, reservoir1.cost)

def expected_cost(timestep, si):

# calculate expected cost manually and compare to parameter output

volume_factor = reservoir1._current_pc[si.global_id]

cc = control_curve[timestep.index]

return np.interp(volume_factor, [0.0, cc, 1.0], values[::-1])

model.run()

開(kāi)發(fā)者ID:pywr,項(xiàng)目名稱:pywr,代碼行數(shù):19,

示例6: colormap

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def colormap(x, m=None, M=None, center=0, colors=None):

'''color a grayscale array (currently red/blue by sign)'''

if center is None:

center = 0

if colors is None:

colors = np.array(((0, 0.7, 1),

(0, 0, 0),

(1, 0, 0)),

dtype=float)

if x.shape[-1] == 1:

x = x[..., 0]

x = scale_values(x, min=m, max=M, center=center)

y = np.empty(x.shape + (3,))

for c in xrange(3):

y[..., c] = np.interp(x, (0, 0.5, 1), colors[:, c])

return y

開(kāi)發(fā)者ID:hjimce,項(xiàng)目名稱:Depth-Map-Prediction,代碼行數(shù):18,

示例7: cor_2_1d

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def cor_2_1d(cor, H, W):

bon_ceil_x, bon_ceil_y = [], []

bon_floor_x, bon_floor_y = [], []

n_cor = len(cor)

for i in range(n_cor // 2):

xys = panostretch.pano_connect_points(cor[i*2],

cor[(i*2+2) % n_cor],

z=-50, w=W, h=H)

bon_ceil_x.extend(xys[:, 0])

bon_ceil_y.extend(xys[:, 1])

for i in range(n_cor // 2):

xys = panostretch.pano_connect_points(cor[i*2+1],

cor[(i*2+3) % n_cor],

z=50, w=W, h=H)

bon_floor_x.extend(xys[:, 0])

bon_floor_y.extend(xys[:, 1])

bon_ceil_x, bon_ceil_y = sort_xy_filter_unique(bon_ceil_x, bon_ceil_y, y_small_first=True)

bon_floor_x, bon_floor_y = sort_xy_filter_unique(bon_floor_x, bon_floor_y, y_small_first=False)

bon = np.zeros((2, W))

bon[0] = np.interp(np.arange(W), bon_ceil_x, bon_ceil_y, period=W)

bon[1] = np.interp(np.arange(W), bon_floor_x, bon_floor_y, period=W)

bon = ((bon + 0.5) / H - 0.5) * np.pi

return bon

開(kāi)發(fā)者ID:sunset1995,項(xiàng)目名稱:HorizonNet,代碼行數(shù):25,

示例8: test_zero_dimensional_interpolation_point

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_zero_dimensional_interpolation_point(self):

x = np.linspace(0, 1, 5)

y = np.linspace(0, 1, 5)

x0 = np.array(.3)

assert_almost_equal(np.interp(x0, x, y), x0)

xp = np.array([0, 2, 4])

fp = np.array([1, -1, 1])

actual = np.interp(np.array(1), xp, fp)

assert_equal(actual, 0)

assert_(isinstance(actual, np.float64))

actual = np.interp(np.array(4.5), xp, fp, period=4)

assert_equal(actual, 0.5)

assert_(isinstance(actual, np.float64))

開(kāi)發(fā)者ID:Frank-qlu,項(xiàng)目名稱:recruit,代碼行數(shù):18,

示例9: test_interpolate_index_values

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_interpolate_index_values(self):

s = Series(np.nan, index=np.sort(np.random.rand(30)))

s[::3] = np.random.randn(10)

vals = s.index.values.astype(float)

result = s.interpolate(method='index')

expected = s.copy()

bad = isna(expected.values)

good = ~bad

expected = Series(np.interp(vals[bad], vals[good],

s.values[good]),

index=s.index[bad])

assert_series_equal(result[bad], expected)

# 'values' is synonymous with 'index' for the method kwarg

other_result = s.interpolate(method='values')

assert_series_equal(other_result, result)

assert_series_equal(other_result[bad], expected)

開(kāi)發(fā)者ID:Frank-qlu,項(xiàng)目名稱:recruit,代碼行數(shù):24,

示例10: sample_posterior

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def sample_posterior(self, x, n=1):

r"""

Generates :code:`n` samples from the estimated posterior

distribution for the input vector :code:`x`. The sampling

is performed by the inverse CDF method using the estimated

CDF obtained from the :code:`cdf` member function.

Arguments:

x(np.array): Array of shape `(n, m)` containing `n` inputs for which

to predict the conditional quantiles.

n(int): The number of samples to generate.

Returns:

Tuple (xs, fs) containing the :math: `x`-values in `xs` and corresponding

values of the posterior CDF :math: `F(x)` in `fs`.

"""

y_pred, qs = self.cdf(x)

p = np.random.rand(n)

y = np.interp(p, qs, y_pred)

return y

開(kāi)發(fā)者ID:atmtools,項(xiàng)目名稱:typhon,代碼行數(shù):25,

示例11: interp_batch

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def interp_batch(total_batch_x):

interp_batch_x = total_batch_x.copy()

N_batch = total_batch_x.shape[0]

for n in range(N_batch):

temp_idx = np.where(total_batch_x[n,0,:,1]==1)[0]

t1 = int(temp_idx[-1])

temp_idx = np.where(total_batch_x[n,0,:,2]==1)[0]

t2 = int(temp_idx[0])

if t2-t1<=1:

continue

interp_t = np.array(range(t1+1,t2))

for k in range(total_batch_x.shape[1]):

#temp_std = np.std(total_batch_x[n,k,total_batch_x[n,k,:,0]!=0,0])

temp_std1 = np.std(total_batch_x[n,k,total_batch_x[n,0,:,1]!=0,0])

temp_std2 = np.std(total_batch_x[n,k,total_batch_x[n,0,:,2]!=0,0])

x_p = [t1,t2]

f_p = [total_batch_x[n,k,t1,0],total_batch_x[n,k,t2,0]]

#interp_batch_x[n,k,t1+1:t2,0] = np.interp(interp_t,x_p,f_p)#+np.random.normal(0, temp_std, t2-t1-1)

interp_batch_x[n,k,t1+1:t2,0] = np.interp(interp_t,x_p,f_p)+np.random.normal(0, (temp_std1+temp_std2)*0.5, t2-t1-1)

return interp_batch_x

開(kāi)發(fā)者ID:GaoangW,項(xiàng)目名稱:TNT,代碼行數(shù):24,

示例12: interp_batch

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def interp_batch(total_batch_x):

interp_batch_x = total_batch_x.copy()

N_batch = total_batch_x.shape[0]

for n in range(N_batch):

temp_idx = np.where(total_batch_x[n,0,:,1]==1)[0]

t1 = int(temp_idx[-1])

temp_idx = np.where(total_batch_x[n,0,:,2]==1)[0]

t2 = int(temp_idx[0])

if t2-t1<=1:

continue

interp_t = np.array(range(t1+1,t2))

for k in range(total_batch_x.shape[1]):

#temp_std = np.std(total_batch_x[n,k,total_batch_x[n,k,:,0]!=0,0])

temp_std1 = np.std(total_batch_x[n,k,total_batch_x[n,0,:,1]!=0,0])

temp_std2 = np.std(total_batch_x[n,k,total_batch_x[n,0,:,2]!=0,0])

x_p = [t1,t2]

f_p = [total_batch_x[n,k,t1,0],total_batch_x[n,k,t2,0]]

#*************************************

#interp_batch_x[n,k,t1+1:t2,0] = np.interp(interp_t,x_p,f_p)+np.random.normal(0, temp_std, t2-t1-1)

#*************************************

interp_batch_x[n,k,t1+1:t2,0] = np.interp(interp_t,x_p,f_p)+np.random.normal(0, (temp_std1+temp_std2)*0.5, t2-t1-1)

return interp_batch_x

開(kāi)發(fā)者ID:GaoangW,項(xiàng)目名稱:TNT,代碼行數(shù):24,

示例13: test_complex_interp

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_complex_interp(self):

# test complex interpolation

x = np.linspace(0, 1, 5)

y = np.linspace(0, 1, 5) + (1 + np.linspace(0, 1, 5))*1.0j

x0 = 0.3

y0 = x0 + (1+x0)*1.0j

assert_almost_equal(np.interp(x0, x, y), y0)

# test complex left and right

x0 = -1

left = 2 + 3.0j

assert_almost_equal(np.interp(x0, x, y, left=left), left)

x0 = 2.0

right = 2 + 3.0j

assert_almost_equal(np.interp(x0, x, y, right=right), right)

# test complex periodic

x = [-180, -170, -185, 185, -10, -5, 0, 365]

xp = [190, -190, 350, -350]

fp = [5+1.0j, 10+2j, 3+3j, 4+4j]

y = [7.5+1.5j, 5.+1.0j, 8.75+1.75j, 6.25+1.25j, 3.+3j, 3.25+3.25j,

3.5+3.5j, 3.75+3.75j]

assert_almost_equal(np.interp(x, xp, fp, period=360), y)

開(kāi)發(fā)者ID:ryfeus,項(xiàng)目名稱:lambda-packs,代碼行數(shù):23,

示例14: linear_interpolation

?點(diǎn)贊 6

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def linear_interpolation(x, xp, fp, **kwargs):

"""Multi-dimensional linear interpolation.

Returns the multi-dimensional piecewise linear interpolant to a function with

given discrete data points (xp, fp), evaluated at x.

Note that *N and *M indicate zero or more dimensions.

Args:

x: An array of shape [*N], the x-coordinates of the interpolated values.

xp: An np.array of shape [D], the x-coordinates of the data points, must be

increasing.

fp: An np.array of shape [D, *M], the y-coordinates of the data points.

**kwargs: Keywords for np.interp.

Returns:

An array of shape [*N, *M], the interpolated values.

"""

yp = fp.reshape([fp.shape[0], -1]).transpose()

y = np.stack([np.interp(x, xp, zp, **kwargs) for zp in yp]).transpose()

return y.reshape(x.shape[:1] + fp.shape[1:]).astype(np.float32)

開(kāi)發(fā)者ID:tensorflow,項(xiàng)目名稱:tensor2tensor,代碼行數(shù):23,

示例15: _convert_to_torque_from_pwm

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def _convert_to_torque_from_pwm(self, pwm, true_motor_velocity):

"""Convert the pwm signal to torque.

Args:

pwm: The pulse width modulation.

true_motor_velocity: The true motor velocity at the current moment. It is

used to compute the back EMF voltage and the viscous damping.

Returns:

actual_torque: The torque that needs to be applied to the motor.

observed_torque: The torque observed by the sensor.

"""

observed_torque = np.clip(

self._torque_constant *

(np.asarray(pwm) * self._voltage / self._resistance),

-OBSERVED_TORQUE_LIMIT, OBSERVED_TORQUE_LIMIT)

# Net voltage is clipped at 50V by diodes on the motor controller.

voltage_net = np.clip(

np.asarray(pwm) * self._voltage -

(self._torque_constant + self._viscous_damping) *

np.asarray(true_motor_velocity), -VOLTAGE_CLIPPING, VOLTAGE_CLIPPING)

current = voltage_net / self._resistance

current_sign = np.sign(current)

current_magnitude = np.absolute(current)

# Saturate torque based on empirical current relation.

actual_torque = np.interp(current_magnitude, self._current_table,

self._torque_table)

actual_torque = np.multiply(current_sign, actual_torque)

actual_torque = np.multiply(self._strength_ratios, actual_torque)

return actual_torque, observed_torque

開(kāi)發(fā)者ID:utra-robosoccer,項(xiàng)目名稱:soccer-matlab,代碼行數(shù):32,

示例16: _convert_to_torque_from_pwm

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def _convert_to_torque_from_pwm(self, pwm, current_motor_velocity):

"""Convert the pwm signal to torque.

Args:

pwm: The pulse width modulation.

current_motor_velocity: The motor velocity at the current time step.

Returns:

actual_torque: The torque that needs to be applied to the motor.

observed_torque: The torque observed by the sensor.

"""

observed_torque = np.clip(

self._torque_constant * (pwm * self._voltage / self._resistance),

-OBSERVED_TORQUE_LIMIT, OBSERVED_TORQUE_LIMIT)

# Net voltage is clipped at 50V by diodes on the motor controller.

voltage_net = np.clip(pwm * self._voltage -

(self._torque_constant + self._viscous_damping)

* current_motor_velocity,

-VOLTAGE_CLIPPING, VOLTAGE_CLIPPING)

current = voltage_net / self._resistance

current_sign = np.sign(current)

current_magnitude = np.absolute(current)

# Saturate torque based on empirical current relation.

actual_torque = np.interp(current_magnitude, self._current_table,

self._torque_table)

actual_torque = np.multiply(current_sign, actual_torque)

return actual_torque, observed_torque

開(kāi)發(fā)者ID:utra-robosoccer,項(xiàng)目名稱:soccer-matlab,代碼行數(shù):30,

示例17: test_control_curve_interpolated

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_control_curve_interpolated(model, use_parameters):

m = model

m.timestepper.delta = 200

s = m.nodes['Storage']

o = m.nodes['Output']

s.connect(o)

cc = ConstantParameter(model, 0.8)

values = [20.0, 5.0, 0.0]

if use_parameters:

# Create the parameter using parameters for the values

parameters = [ConstantParameter(model, v) for v in values]

s.cost = p = ControlCurveInterpolatedParameter(model, s, cc, parameters=parameters)

else:

# Create the parameter using a list of values

s.cost = p = ControlCurveInterpolatedParameter(model, s, cc, values)

@assert_rec(model, p)

def expected_func(timestep, scenario_index):

v = s.initial_volume

c = cc.value(timestep, scenario_index)

if c == 1.0 and v == 100.0:

expected = values[1]

elif c == 0.0 and v == 0.0:

expected = values[1]

else:

expected = np.interp(v/100.0, [0.0, c, 1.0], values[::-1])

return expected

for control_curve in (0.0, 0.8, 1.0):

cc.set_double_variables(np.array([control_curve,]))

for initial_volume in (0.0, 10.0, 50.0, 80.0, 90.0, 100.0):

s.initial_volume = initial_volume

model.run()

開(kāi)發(fā)者ID:pywr,項(xiàng)目名稱:pywr,代碼行數(shù):38,

示例18: gen_reg_from_xy

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def gen_reg_from_xy(xy, w):

xy = xy[np.argsort(xy[:, 0])]

return np.interp(np.arange(w), xy[:, 0], xy[:, 1], period=w)

開(kāi)發(fā)者ID:sunset1995,項(xiàng)目名稱:HorizonNet,代碼行數(shù):5,

示例19: _resample_numpy

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def _resample_numpy(signal, desired_length):

resampled_signal = np.interp(

np.linspace(0.0, 1.0, desired_length, endpoint=False), # where to interpolate

np.linspace(0.0, 1.0, len(signal), endpoint=False), # known positions

signal, # known data points

)

return resampled_signal

開(kāi)發(fā)者ID:neuropsychology,項(xiàng)目名稱:NeuroKit,代碼行數(shù):9,

示例20: __call__

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def __call__(self, env, agent, step):

value = np.interp(step,

[1, self.total_steps],

[self.start_value, self.stop_value])

self.setter(env, agent, value)

開(kāi)發(fā)者ID:chainer,項(xiàng)目名稱:chainerrl,代碼行數(shù):7,

示例21: __getitem__

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def __getitem__(self, query):

"""Given query, returns the interpolated function value."""

return np.interp(query, self.inputs, self.outputs)

開(kāi)發(fā)者ID:zykls,項(xiàng)目名稱:whynot,代碼行數(shù):5,

示例22: test_exceptions

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_exceptions(self):

assert_raises(ValueError, interp, 0, [], [])

assert_raises(ValueError, interp, 0, [0], [1, 2])

assert_raises(ValueError, interp, 0, [0, 1], [1, 2], period=0)

assert_raises(ValueError, interp, 0, [], [], period=360)

assert_raises(ValueError, interp, 0, [0], [1, 2], period=360)

開(kāi)發(fā)者ID:Frank-qlu,項(xiàng)目名稱:recruit,代碼行數(shù):8,

示例23: test_basic

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_basic(self):

x = np.linspace(0, 1, 5)

y = np.linspace(0, 1, 5)

x0 = np.linspace(0, 1, 50)

assert_almost_equal(np.interp(x0, x, y), x0)

開(kāi)發(fā)者ID:Frank-qlu,項(xiàng)目名稱:recruit,代碼行數(shù):7,

示例24: test_right_left_behavior

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_right_left_behavior(self):

# Needs range of sizes to test different code paths.

# size ==1 is special cased, 1 < size < 5 is linear search, and

# size >= 5 goes through local search and possibly binary search.

for size in range(1, 10):

xp = np.arange(size, dtype=np.double)

yp = np.ones(size, dtype=np.double)

incpts = np.array([-1, 0, size - 1, size], dtype=np.double)

decpts = incpts[::-1]

incres = interp(incpts, xp, yp)

decres = interp(decpts, xp, yp)

inctgt = np.array([1, 1, 1, 1], dtype=float)

dectgt = inctgt[::-1]

assert_equal(incres, inctgt)

assert_equal(decres, dectgt)

incres = interp(incpts, xp, yp, left=0)

decres = interp(decpts, xp, yp, left=0)

inctgt = np.array([0, 1, 1, 1], dtype=float)

dectgt = inctgt[::-1]

assert_equal(incres, inctgt)

assert_equal(decres, dectgt)

incres = interp(incpts, xp, yp, right=2)

decres = interp(decpts, xp, yp, right=2)

inctgt = np.array([1, 1, 1, 2], dtype=float)

dectgt = inctgt[::-1]

assert_equal(incres, inctgt)

assert_equal(decres, dectgt)

incres = interp(incpts, xp, yp, left=0, right=2)

decres = interp(decpts, xp, yp, left=0, right=2)

inctgt = np.array([0, 1, 1, 2], dtype=float)

dectgt = inctgt[::-1]

assert_equal(incres, inctgt)

assert_equal(decres, dectgt)

開(kāi)發(fā)者ID:Frank-qlu,項(xiàng)目名稱:recruit,代碼行數(shù):39,

示例25: test_scalar_interpolation_point

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_scalar_interpolation_point(self):

x = np.linspace(0, 1, 5)

y = np.linspace(0, 1, 5)

x0 = 0

assert_almost_equal(np.interp(x0, x, y), x0)

x0 = .3

assert_almost_equal(np.interp(x0, x, y), x0)

x0 = np.float32(.3)

assert_almost_equal(np.interp(x0, x, y), x0)

x0 = np.float64(.3)

assert_almost_equal(np.interp(x0, x, y), x0)

x0 = np.nan

assert_almost_equal(np.interp(x0, x, y), x0)

開(kāi)發(fā)者ID:Frank-qlu,項(xiàng)目名稱:recruit,代碼行數(shù):15,

示例26: test_non_finite_behavior

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_non_finite_behavior(self):

x = [1, 2, 2.5, 3, 4]

xp = [1, 2, 3, 4]

fp = [1, 2, np.inf, 4]

assert_almost_equal(np.interp(x, xp, fp), [1, 2, np.inf, np.inf, 4])

fp = [1, 2, np.nan, 4]

assert_almost_equal(np.interp(x, xp, fp), [1, 2, np.nan, np.nan, 4])

開(kāi)發(fā)者ID:Frank-qlu,項(xiàng)目名稱:recruit,代碼行數(shù):9,

示例27: test_if_len_x_is_small

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_if_len_x_is_small(self):

xp = np.arange(0, 10, 0.0001)

fp = np.sin(xp)

assert_almost_equal(np.interp(np.pi, xp, fp), 0.0)

開(kāi)發(fā)者ID:Frank-qlu,項(xiàng)目名稱:recruit,代碼行數(shù):6,

示例28: test_period

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def test_period(self):

x = [-180, -170, -185, 185, -10, -5, 0, 365]

xp = [190, -190, 350, -350]

fp = [5, 10, 3, 4]

y = [7.5, 5., 8.75, 6.25, 3., 3.25, 3.5, 3.75]

assert_almost_equal(np.interp(x, xp, fp, period=360), y)

x = np.array(x, order='F').reshape(2, -1)

y = np.array(y, order='C').reshape(2, -1)

assert_almost_equal(np.interp(x, xp, fp, period=360), y)

開(kāi)發(fā)者ID:Frank-qlu,項(xiàng)目名稱:recruit,代碼行數(shù):11,

示例29: get_brain_regions

?點(diǎn)贊 5

?

# 需要導(dǎo)入模塊: import numpy [as 別名]

# 或者: from numpy import interp [as 別名]

def get_brain_regions(xyz, channels_positions=SITES_COORDINATES, brain_atlas=brat, display=False):

"""

:param xyz: numpy array of 3D coordinates corresponding to a picked track or a trajectory

the deepest point is considered the tip.

:param channels:

:param DISPLAY:

:return:

"""

"""

this is the depth along the probe (from the first point which is the deepest labeled point)

Due to the blockiness, depths may not be unique along the track so it has to be prepared

"""

d = atlas.cart2sph(xyz[:, 0] - xyz[0, 0], xyz[:, 1] - xyz[0, 1], xyz[:, 2] - xyz[0, 2])[0]

ind_depths = np.argsort(d)

d = np.sort(d)

iid = np.where(np.diff(d) >= 0)[0]

ind_depths = ind_depths[iid]

d = d[iid]

"""

Interpolate channel positions along the probe depth and get brain locations

"""

xyz_channels = np.zeros((channels_positions.shape[0], 3))

for m in np.arange(3):

xyz_channels[:, m] = np.interp(channels_positions[:, 1] / 1e6,

d[ind_depths], xyz[ind_depths, m])

brain_regions = brain_atlas.regions.get(brat.get_labels(xyz_channels))

"""

Get the best linear fit probe trajectory using points cloud

"""

track = atlas.Trajectory.fit(xyz)

return brain_regions, track

開(kāi)發(fā)者ID:int-brain-lab,項(xiàng)目名稱:ibllib,代碼行數(shù):37,

注:本文中的numpy.interp方法示例整理自Github/MSDocs等源碼及文檔管理平臺(tái),相關(guān)代碼片段篩選自各路編程大神貢獻(xiàn)的開(kāi)源項(xiàng)目,源碼版權(quán)歸原作者所有,傳播和使用請(qǐng)參考對(duì)應(yīng)項(xiàng)目的License;未經(jīng)允許,請(qǐng)勿轉(zhuǎn)載。

總結(jié)

以上是生活随笔為你收集整理的pythoninterp error_Python numpy.interp方法代码示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 麻豆精品| 双女主黄文 | 免费观看成人av | 久久久精品人妻av一区二区三区 | 黄色免费入口 | 91精品国产自产在线观看 | 国产精品久久午夜夜伦鲁鲁 | 清冷男神被c的合不拢腿男男 | 日韩福利网 | 69激情网| 亚洲成色| 国产又粗又猛又爽又黄91精品 | 国产乱偷 | 国产日本一区二区三区 | 日韩国产欧美精品 | 日韩美女激情视频 | 亚洲咪咪 | 永久精品网站 | 日韩无码精品一区二区 | 天天摸夜夜爽 | 成人涩涩视频 | 中文字幕影院 | 欧美日韩色片 | 熊出没之冬日乐翻天免费高清观看 | 欧美少妇喷水 | 俺也去综合| 嫩草影院国产 | 超碰在线香蕉 | 青青操青青 | 91免费片 | 特黄特色大片免费播放器使用方法 | 五月婷婷狠狠干 | 久久久久亚洲视频 | 国产aa毛片| 韩国在线不卡 | 天堂中文在线视频 | 日韩精品短片 | 91看片就是不一样 | 日韩欧美一区二区视频 | 亚洲国产www | 亚洲爱爱网站 | 韩国女同性做爰三级 | 国产一级淫片免费 | 特黄在线| 91成人在线观看喷潮 | 91美女高潮出水 | 欧美大片免费播放器 | 99久久婷婷国产综合精品草原 | 蜜臀视频一区二区 | 中文有码在线观看 | 成人3d动漫在线观看 | 1000部做爰免费视频 | av片在线免费看 | 精品免费国产一区二区三区 | xxx精品 | 性久久久久 | 欧美丰满老妇熟乱xxxxyyy | 美女久久久久久 | 日本成人在线免费视频 | 九九在线精品视频 | 欧美97| 亚洲欧美日韩精品色xxx | 九九一级片 | 在哪看毛片 | 天堂网在线资源 | www.一级片 | 性视频网 | 日韩av网站在线 | 强行挺进白丝老师里呻吟 | 成人黄色在线观看视频 | 国产精品视频福利 | 在线看av的网址 | 欧美日本在线看 | 免费一级片在线观看 | 两个小y头稚嫩紧窄h文 | 国产精品igao视频 | 中文字幕日产av | 欧美 日韩 国产 一区二区三区 | h网址在线观看 | 伊人网在线播放 | 奇米视频在线 | 91丨porny丨九色 | 国产视频一区二区 | 日本精品视频网站 | 成人性生交大片免费卡看 | 男人天堂视频在线观看 | 337p亚洲精品色噜噜狠狠 | 天堂av手机版 | 狠操av | 91麻豆精品久久久久蜜臀 | 成人在线免费视频 | 91视频最新地址 | 偷拍亚洲视频 | 黄色免费网 | 911国产视频| 日本一区二区精品 | www.中文字幕在线观看 | wwwsss在线观看 | 粉嫩在线|