partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
CubatureKalmanFilter.update
Update the CKF with the given measurements. On return, self.x and self.P contain the new mean and covariance of the filter. Parameters ---------- z : numpy.array of shape (dim_z) measurement vector R : numpy.array((dim_z, dim_z)), optional Measurement n...
filterpy/kalman/CubatureKalmanFilter.py
def update(self, z, R=None, hx_args=()): """ Update the CKF with the given measurements. On return, self.x and self.P contain the new mean and covariance of the filter. Parameters ---------- z : numpy.array of shape (dim_z) measurement vector R : numpy.arra...
def update(self, z, R=None, hx_args=()): """ Update the CKF with the given measurements. On return, self.x and self.P contain the new mean and covariance of the filter. Parameters ---------- z : numpy.array of shape (dim_z) measurement vector R : numpy.arra...
[ "Update", "the", "CKF", "with", "the", "given", "measurements", ".", "On", "return", "self", ".", "x", "and", "self", ".", "P", "contain", "the", "new", "mean", "and", "covariance", "of", "the", "filter", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/CubatureKalmanFilter.py#L329-L389
[ "def", "update", "(", "self", ",", "z", ",", "R", "=", "None", ",", "hx_args", "=", "(", ")", ")", ":", "if", "z", "is", "None", ":", "self", ".", "z", "=", "np", ".", "array", "(", "[", "[", "None", "]", "*", "self", ".", "dim_z", "]", "...
8123214de798ffb63db968bb0b9492ee74e77950
train
InformationFilter.update
Add a new measurement (z) to the kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update. R : np.array, scalar, or None Optionally provide R to override the measurement noise for this o...
filterpy/kalman/information_filter.py
def update(self, z, R_inv=None): """ Add a new measurement (z) to the kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update. R : np.array, scalar, or None Optionally provide R to ...
def update(self, z, R_inv=None): """ Add a new measurement (z) to the kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update. R : np.array, scalar, or None Optionally provide R to ...
[ "Add", "a", "new", "measurement", "(", "z", ")", "to", "the", "kalman", "filter", ".", "If", "z", "is", "None", "nothing", "is", "changed", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/information_filter.py#L178-L243
[ "def", "update", "(", "self", ",", "z", ",", "R_inv", "=", "None", ")", ":", "if", "z", "is", "None", ":", "self", ".", "z", "=", "None", "self", ".", "x_post", "=", "self", ".", "x", ".", "copy", "(", ")", "self", ".", "P_inv_post", "=", "se...
8123214de798ffb63db968bb0b9492ee74e77950
train
InformationFilter.predict
Predict next position. Parameters ---------- u : ndarray Optional control vector. If non-zero, it is multiplied by B to create the control input into the system.
filterpy/kalman/information_filter.py
def predict(self, u=0): """ Predict next position. Parameters ---------- u : ndarray Optional control vector. If non-zero, it is multiplied by B to create the control input into the system. """ # x = Fx + Bu A = dot(self._F_inv.T, self....
def predict(self, u=0): """ Predict next position. Parameters ---------- u : ndarray Optional control vector. If non-zero, it is multiplied by B to create the control input into the system. """ # x = Fx + Bu A = dot(self._F_inv.T, self....
[ "Predict", "next", "position", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/information_filter.py#L245-L289
[ "def", "predict", "(", "self", ",", "u", "=", "0", ")", ":", "# x = Fx + Bu", "A", "=", "dot", "(", "self", ".", "_F_inv", ".", "T", ",", "self", ".", "P_inv", ")", ".", "dot", "(", "self", ".", "_F_inv", ")", "#pylint: disable=bare-except", "try", ...
8123214de798ffb63db968bb0b9492ee74e77950
train
InformationFilter.batch_filter
Batch processes a sequences of measurements. Parameters ---------- zs : list-like list of measurements at each time step `self.dt` Missing measurements must be represented by 'None'. Rs : list-like, optional optional list of values to use for the me...
filterpy/kalman/information_filter.py
def batch_filter(self, zs, Rs=None, update_first=False, saver=None): """ Batch processes a sequences of measurements. Parameters ---------- zs : list-like list of measurements at each time step `self.dt` Missing measurements must be represented by 'None'. ...
def batch_filter(self, zs, Rs=None, update_first=False, saver=None): """ Batch processes a sequences of measurements. Parameters ---------- zs : list-like list of measurements at each time step `self.dt` Missing measurements must be represented by 'None'. ...
[ "Batch", "processes", "a", "sequences", "of", "measurements", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/information_filter.py#L291-L363
[ "def", "batch_filter", "(", "self", ",", "zs", ",", "Rs", "=", "None", ",", "update_first", "=", "False", ",", "saver", "=", "None", ")", ":", "raise", "NotImplementedError", "(", "\"this is not implemented yet\"", ")", "#pylint: disable=unreachable, no-member", "...
8123214de798ffb63db968bb0b9492ee74e77950
train
InformationFilter.F
State Transition matrix
filterpy/kalman/information_filter.py
def F(self, value): """State Transition matrix""" self._F = value self._F_inv = self.inv(self._F)
def F(self, value): """State Transition matrix""" self._F = value self._F_inv = self.inv(self._F)
[ "State", "Transition", "matrix" ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/information_filter.py#L371-L374
[ "def", "F", "(", "self", ",", "value", ")", ":", "self", ".", "_F", "=", "value", "self", ".", "_F_inv", "=", "self", ".", "inv", "(", "self", ".", "_F", ")" ]
8123214de798ffb63db968bb0b9492ee74e77950
train
runge_kutta4
computes 4th order Runge-Kutta for dy/dx. Parameters ---------- y : scalar Initial/current value for y x : scalar Initial/current value for x dx : scalar difference in x (e.g. the time step) f : ufunc(y,x) Callable function (y, x) that you supply to compute dy/d...
filterpy/common/helpers.py
def runge_kutta4(y, x, dx, f): """computes 4th order Runge-Kutta for dy/dx. Parameters ---------- y : scalar Initial/current value for y x : scalar Initial/current value for x dx : scalar difference in x (e.g. the time step) f : ufunc(y,x) Callable function ...
def runge_kutta4(y, x, dx, f): """computes 4th order Runge-Kutta for dy/dx. Parameters ---------- y : scalar Initial/current value for y x : scalar Initial/current value for x dx : scalar difference in x (e.g. the time step) f : ufunc(y,x) Callable function ...
[ "computes", "4th", "order", "Runge", "-", "Kutta", "for", "dy", "/", "dx", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/common/helpers.py#L213-L236
[ "def", "runge_kutta4", "(", "y", ",", "x", ",", "dx", ",", "f", ")", ":", "k1", "=", "dx", "*", "f", "(", "y", ",", "x", ")", "k2", "=", "dx", "*", "f", "(", "y", "+", "0.5", "*", "k1", ",", "x", "+", "0.5", "*", "dx", ")", "k3", "=",...
8123214de798ffb63db968bb0b9492ee74e77950
train
pretty_str
Generates a pretty printed NumPy array with an assignment. Optionally transposes column vectors so they are drawn on one line. Strictly speaking arr can be any time convertible by `str(arr)`, but the output may not be what you want if the type of the variable is not a scalar or an ndarray. Examples...
filterpy/common/helpers.py
def pretty_str(label, arr): """ Generates a pretty printed NumPy array with an assignment. Optionally transposes column vectors so they are drawn on one line. Strictly speaking arr can be any time convertible by `str(arr)`, but the output may not be what you want if the type of the variable is not a...
def pretty_str(label, arr): """ Generates a pretty printed NumPy array with an assignment. Optionally transposes column vectors so they are drawn on one line. Strictly speaking arr can be any time convertible by `str(arr)`, but the output may not be what you want if the type of the variable is not a...
[ "Generates", "a", "pretty", "printed", "NumPy", "array", "with", "an", "assignment", ".", "Optionally", "transposes", "column", "vectors", "so", "they", "are", "drawn", "on", "one", "line", ".", "Strictly", "speaking", "arr", "can", "be", "any", "time", "con...
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/common/helpers.py#L239-L282
[ "def", "pretty_str", "(", "label", ",", "arr", ")", ":", "def", "is_col", "(", "a", ")", ":", "\"\"\" return true if a is a column vector\"\"\"", "try", ":", "return", "a", ".", "shape", "[", "0", "]", ">", "1", "and", "a", ".", "shape", "[", "1", "]",...
8123214de798ffb63db968bb0b9492ee74e77950
train
reshape_z
ensure z is a (dim_z, 1) shaped vector
filterpy/common/helpers.py
def reshape_z(z, dim_z, ndim): """ ensure z is a (dim_z, 1) shaped vector""" z = np.atleast_2d(z) if z.shape[1] == dim_z: z = z.T if z.shape != (dim_z, 1): raise ValueError('z must be convertible to shape ({}, 1)'.format(dim_z)) if ndim == 1: z = z[:, 0] if ndim == 0:...
def reshape_z(z, dim_z, ndim): """ ensure z is a (dim_z, 1) shaped vector""" z = np.atleast_2d(z) if z.shape[1] == dim_z: z = z.T if z.shape != (dim_z, 1): raise ValueError('z must be convertible to shape ({}, 1)'.format(dim_z)) if ndim == 1: z = z[:, 0] if ndim == 0:...
[ "ensure", "z", "is", "a", "(", "dim_z", "1", ")", "shaped", "vector" ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/common/helpers.py#L303-L319
[ "def", "reshape_z", "(", "z", ",", "dim_z", ",", "ndim", ")", ":", "z", "=", "np", ".", "atleast_2d", "(", "z", ")", "if", "z", ".", "shape", "[", "1", "]", "==", "dim_z", ":", "z", "=", "z", ".", "T", "if", "z", ".", "shape", "!=", "(", ...
8123214de798ffb63db968bb0b9492ee74e77950
train
inv_diagonal
Computes the inverse of a diagonal NxN np.array S. In general this will be much faster than calling np.linalg.inv(). However, does NOT check if the off diagonal elements are non-zero. So long as S is truly diagonal, the output is identical to np.linalg.inv(). Parameters ---------- S : np.array...
filterpy/common/helpers.py
def inv_diagonal(S): """ Computes the inverse of a diagonal NxN np.array S. In general this will be much faster than calling np.linalg.inv(). However, does NOT check if the off diagonal elements are non-zero. So long as S is truly diagonal, the output is identical to np.linalg.inv(). Parameter...
def inv_diagonal(S): """ Computes the inverse of a diagonal NxN np.array S. In general this will be much faster than calling np.linalg.inv(). However, does NOT check if the off diagonal elements are non-zero. So long as S is truly diagonal, the output is identical to np.linalg.inv(). Parameter...
[ "Computes", "the", "inverse", "of", "a", "diagonal", "NxN", "np", ".", "array", "S", ".", "In", "general", "this", "will", "be", "much", "faster", "than", "calling", "np", ".", "linalg", ".", "inv", "()", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/common/helpers.py#L322-L360
[ "def", "inv_diagonal", "(", "S", ")", ":", "S", "=", "np", ".", "asarray", "(", "S", ")", "if", "S", ".", "ndim", "!=", "2", "or", "S", ".", "shape", "[", "0", "]", "!=", "S", ".", "shape", "[", "1", "]", ":", "raise", "ValueError", "(", "'...
8123214de798ffb63db968bb0b9492ee74e77950
train
outer_product_sum
Computes the sum of the outer products of the rows in A and B P = \Sum {A[i] B[i].T} for i in 0..N Notionally: P = 0 for y in A: P += np.outer(y, y) This is a standard computation for sigma points used in the UKF, ensemble Kalman filter, etc., where A would be the...
filterpy/common/helpers.py
def outer_product_sum(A, B=None): """ Computes the sum of the outer products of the rows in A and B P = \Sum {A[i] B[i].T} for i in 0..N Notionally: P = 0 for y in A: P += np.outer(y, y) This is a standard computation for sigma points used in the UKF, ensemble...
def outer_product_sum(A, B=None): """ Computes the sum of the outer products of the rows in A and B P = \Sum {A[i] B[i].T} for i in 0..N Notionally: P = 0 for y in A: P += np.outer(y, y) This is a standard computation for sigma points used in the UKF, ensemble...
[ "Computes", "the", "sum", "of", "the", "outer", "products", "of", "the", "rows", "in", "A", "and", "B" ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/common/helpers.py#L363-L414
[ "def", "outer_product_sum", "(", "A", ",", "B", "=", "None", ")", ":", "if", "B", "is", "None", ":", "B", "=", "A", "outer", "=", "np", ".", "einsum", "(", "'ij,ik->ijk'", ",", "A", ",", "B", ")", "return", "np", ".", "sum", "(", "outer", ",", ...
8123214de798ffb63db968bb0b9492ee74e77950
train
Saver.save
save the current state of the Kalman filter
filterpy/common/helpers.py
def save(self): """ save the current state of the Kalman filter""" kf = self._kf # force all attributes to be computed. this is only necessary # if the class uses properties that compute data only when # accessed for prop in self.properties: self._DL[prop[0]...
def save(self): """ save the current state of the Kalman filter""" kf = self._kf # force all attributes to be computed. this is only necessary # if the class uses properties that compute data only when # accessed for prop in self.properties: self._DL[prop[0]...
[ "save", "the", "current", "state", "of", "the", "Kalman", "filter" ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/common/helpers.py#L120-L152
[ "def", "save", "(", "self", ")", ":", "kf", "=", "self", ".", "_kf", "# force all attributes to be computed. this is only necessary", "# if the class uses properties that compute data only when", "# accessed", "for", "prop", "in", "self", ".", "properties", ":", "self", "...
8123214de798ffb63db968bb0b9492ee74e77950
train
Saver.to_array
Convert all saved attributes from a list to np.array. This may or may not work - every saved attribute must have the same shape for every instance. i.e., if `K` changes shape due to `z` changing shape then the call will raise an exception. This can also happen if the default initializa...
filterpy/common/helpers.py
def to_array(self): """ Convert all saved attributes from a list to np.array. This may or may not work - every saved attribute must have the same shape for every instance. i.e., if `K` changes shape due to `z` changing shape then the call will raise an exception. This c...
def to_array(self): """ Convert all saved attributes from a list to np.array. This may or may not work - every saved attribute must have the same shape for every instance. i.e., if `K` changes shape due to `z` changing shape then the call will raise an exception. This c...
[ "Convert", "all", "saved", "attributes", "from", "a", "list", "to", "np", ".", "array", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/common/helpers.py#L165-L185
[ "def", "to_array", "(", "self", ")", ":", "for", "key", "in", "self", ".", "keys", ":", "try", ":", "self", ".", "__dict__", "[", "key", "]", "=", "np", ".", "array", "(", "self", ".", "_DL", "[", "key", "]", ")", "except", ":", "# get back to li...
8123214de798ffb63db968bb0b9492ee74e77950
train
Saver.flatten
Flattens any np.array of column vectors into 1D arrays. Basically, this makes data readable for humans if you are just inspecting via the REPL. For example, if you have saved a KalmanFilter object with 89 epochs, self.x will be shape (89, 9, 1) (for example). After flatten is run, self.x...
filterpy/common/helpers.py
def flatten(self): """ Flattens any np.array of column vectors into 1D arrays. Basically, this makes data readable for humans if you are just inspecting via the REPL. For example, if you have saved a KalmanFilter object with 89 epochs, self.x will be shape (89, 9, 1) (for example...
def flatten(self): """ Flattens any np.array of column vectors into 1D arrays. Basically, this makes data readable for humans if you are just inspecting via the REPL. For example, if you have saved a KalmanFilter object with 89 epochs, self.x will be shape (89, 9, 1) (for example...
[ "Flattens", "any", "np", ".", "array", "of", "column", "vectors", "into", "1D", "arrays", ".", "Basically", "this", "makes", "data", "readable", "for", "humans", "if", "you", "are", "just", "inspecting", "via", "the", "REPL", ".", "For", "example", "if", ...
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/common/helpers.py#L187-L206
[ "def", "flatten", "(", "self", ")", ":", "for", "key", "in", "self", ".", "keys", ":", "try", ":", "arr", "=", "self", ".", "__dict__", "[", "key", "]", "shape", "=", "arr", ".", "shape", "if", "shape", "[", "2", "]", "==", "1", ":", "self", ...
8123214de798ffb63db968bb0b9492ee74e77950
train
IMMEstimator.update
Add a new measurement (z) to the Kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update.
filterpy/kalman/IMM.py
def update(self, z): """ Add a new measurement (z) to the Kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update. """ # run update on each filter, and save the likelihood for i...
def update(self, z): """ Add a new measurement (z) to the Kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update. """ # run update on each filter, and save the likelihood for i...
[ "Add", "a", "new", "measurement", "(", "z", ")", "to", "the", "Kalman", "filter", ".", "If", "z", "is", "None", "nothing", "is", "changed", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/IMM.py#L159-L185
[ "def", "update", "(", "self", ",", "z", ")", ":", "# run update on each filter, and save the likelihood", "for", "i", ",", "f", "in", "enumerate", "(", "self", ".", "filters", ")", ":", "f", ".", "update", "(", "z", ")", "self", ".", "likelihood", "[", "...
8123214de798ffb63db968bb0b9492ee74e77950
train
IMMEstimator.predict
Predict next state (prior) using the IMM state propagation equations. Parameters ---------- u : np.array, optional Control vector. If not `None`, it is multiplied by B to create the control input into the system.
filterpy/kalman/IMM.py
def predict(self, u=None): """ Predict next state (prior) using the IMM state propagation equations. Parameters ---------- u : np.array, optional Control vector. If not `None`, it is multiplied by B to create the control input into the system. ...
def predict(self, u=None): """ Predict next state (prior) using the IMM state propagation equations. Parameters ---------- u : np.array, optional Control vector. If not `None`, it is multiplied by B to create the control input into the system. ...
[ "Predict", "next", "state", "(", "prior", ")", "using", "the", "IMM", "state", "propagation", "equations", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/IMM.py#L187-L224
[ "def", "predict", "(", "self", ",", "u", "=", "None", ")", ":", "# compute mixed initial conditions", "xs", ",", "Ps", "=", "[", "]", ",", "[", "]", "for", "i", ",", "(", "f", ",", "w", ")", "in", "enumerate", "(", "zip", "(", "self", ".", "filte...
8123214de798ffb63db968bb0b9492ee74e77950
train
IMMEstimator._compute_state_estimate
Computes the IMM's mixed state estimate from each filter using the the mode probability self.mu to weight the estimates.
filterpy/kalman/IMM.py
def _compute_state_estimate(self): """ Computes the IMM's mixed state estimate from each filter using the the mode probability self.mu to weight the estimates. """ self.x.fill(0) for f, mu in zip(self.filters, self.mu): self.x += f.x * mu self.P.fill(...
def _compute_state_estimate(self): """ Computes the IMM's mixed state estimate from each filter using the the mode probability self.mu to weight the estimates. """ self.x.fill(0) for f, mu in zip(self.filters, self.mu): self.x += f.x * mu self.P.fill(...
[ "Computes", "the", "IMM", "s", "mixed", "state", "estimate", "from", "each", "filter", "using", "the", "the", "mode", "probability", "self", ".", "mu", "to", "weight", "the", "estimates", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/IMM.py#L226-L238
[ "def", "_compute_state_estimate", "(", "self", ")", ":", "self", ".", "x", ".", "fill", "(", "0", ")", "for", "f", ",", "mu", "in", "zip", "(", "self", ".", "filters", ",", "self", ".", "mu", ")", ":", "self", ".", "x", "+=", "f", ".", "x", "...
8123214de798ffb63db968bb0b9492ee74e77950
train
IMMEstimator._compute_mixing_probabilities
Compute the mixing probability for each filter.
filterpy/kalman/IMM.py
def _compute_mixing_probabilities(self): """ Compute the mixing probability for each filter. """ self.cbar = dot(self.mu, self.M) for i in range(self.N): for j in range(self.N): self.omega[i, j] = (self.M[i, j]*self.mu[i]) / self.cbar[j]
def _compute_mixing_probabilities(self): """ Compute the mixing probability for each filter. """ self.cbar = dot(self.mu, self.M) for i in range(self.N): for j in range(self.N): self.omega[i, j] = (self.M[i, j]*self.mu[i]) / self.cbar[j]
[ "Compute", "the", "mixing", "probability", "for", "each", "filter", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/IMM.py#L240-L248
[ "def", "_compute_mixing_probabilities", "(", "self", ")", ":", "self", ".", "cbar", "=", "dot", "(", "self", ".", "mu", ",", "self", ".", "M", ")", "for", "i", "in", "range", "(", "self", ".", "N", ")", ":", "for", "j", "in", "range", "(", "self"...
8123214de798ffb63db968bb0b9492ee74e77950
train
UnscentedKalmanFilter.predict
r""" Performs the predict step of the UKF. On return, self.x and self.P contain the predicted state (x) and covariance (P). ' Important: this MUST be called before update() is called for the first time. Parameters ---------- dt : double, optional If...
filterpy/kalman/UKF.py
def predict(self, dt=None, UT=None, fx=None, **fx_args): r""" Performs the predict step of the UKF. On return, self.x and self.P contain the predicted state (x) and covariance (P). ' Important: this MUST be called before update() is called for the first time. Parameters...
def predict(self, dt=None, UT=None, fx=None, **fx_args): r""" Performs the predict step of the UKF. On return, self.x and self.P contain the predicted state (x) and covariance (P). ' Important: this MUST be called before update() is called for the first time. Parameters...
[ "r", "Performs", "the", "predict", "step", "of", "the", "UKF", ".", "On", "return", "self", ".", "x", "and", "self", ".", "P", "contain", "the", "predicted", "state", "(", "x", ")", "and", "covariance", "(", "P", ")", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/UKF.py#L352-L396
[ "def", "predict", "(", "self", ",", "dt", "=", "None", ",", "UT", "=", "None", ",", "fx", "=", "None", ",", "*", "*", "fx_args", ")", ":", "if", "dt", "is", "None", ":", "dt", "=", "self", ".", "_dt", "if", "UT", "is", "None", ":", "UT", "=...
8123214de798ffb63db968bb0b9492ee74e77950
train
UnscentedKalmanFilter.update
Update the UKF with the given measurements. On return, self.x and self.P contain the new mean and covariance of the filter. Parameters ---------- z : numpy.array of shape (dim_z) measurement vector R : numpy.array((dim_z, dim_z)), optional Measurement n...
filterpy/kalman/UKF.py
def update(self, z, R=None, UT=None, hx=None, **hx_args): """ Update the UKF with the given measurements. On return, self.x and self.P contain the new mean and covariance of the filter. Parameters ---------- z : numpy.array of shape (dim_z) measurement vecto...
def update(self, z, R=None, UT=None, hx=None, **hx_args): """ Update the UKF with the given measurements. On return, self.x and self.P contain the new mean and covariance of the filter. Parameters ---------- z : numpy.array of shape (dim_z) measurement vecto...
[ "Update", "the", "UKF", "with", "the", "given", "measurements", ".", "On", "return", "self", ".", "x", "and", "self", ".", "P", "contain", "the", "new", "mean", "and", "covariance", "of", "the", "filter", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/UKF.py#L398-L472
[ "def", "update", "(", "self", ",", "z", ",", "R", "=", "None", ",", "UT", "=", "None", ",", "hx", "=", "None", ",", "*", "*", "hx_args", ")", ":", "if", "z", "is", "None", ":", "self", ".", "z", "=", "np", ".", "array", "(", "[", "[", "No...
8123214de798ffb63db968bb0b9492ee74e77950
train
UnscentedKalmanFilter.cross_variance
Compute cross variance of the state `x` and measurement `z`.
filterpy/kalman/UKF.py
def cross_variance(self, x, z, sigmas_f, sigmas_h): """ Compute cross variance of the state `x` and measurement `z`. """ Pxz = zeros((sigmas_f.shape[1], sigmas_h.shape[1])) N = sigmas_f.shape[0] for i in range(N): dx = self.residual_x(sigmas_f[i], x) ...
def cross_variance(self, x, z, sigmas_f, sigmas_h): """ Compute cross variance of the state `x` and measurement `z`. """ Pxz = zeros((sigmas_f.shape[1], sigmas_h.shape[1])) N = sigmas_f.shape[0] for i in range(N): dx = self.residual_x(sigmas_f[i], x) ...
[ "Compute", "cross", "variance", "of", "the", "state", "x", "and", "measurement", "z", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/UKF.py#L474-L485
[ "def", "cross_variance", "(", "self", ",", "x", ",", "z", ",", "sigmas_f", ",", "sigmas_h", ")", ":", "Pxz", "=", "zeros", "(", "(", "sigmas_f", ".", "shape", "[", "1", "]", ",", "sigmas_h", ".", "shape", "[", "1", "]", ")", ")", "N", "=", "sig...
8123214de798ffb63db968bb0b9492ee74e77950
train
UnscentedKalmanFilter.compute_process_sigmas
computes the values of sigmas_f. Normally a user would not call this, but it is useful if you need to call update more than once between calls to predict (to update for multiple simultaneous measurements), so the sigmas correctly reflect the updated state x, P.
filterpy/kalman/UKF.py
def compute_process_sigmas(self, dt, fx=None, **fx_args): """ computes the values of sigmas_f. Normally a user would not call this, but it is useful if you need to call update more than once between calls to predict (to update for multiple simultaneous measurements), so the sigma...
def compute_process_sigmas(self, dt, fx=None, **fx_args): """ computes the values of sigmas_f. Normally a user would not call this, but it is useful if you need to call update more than once between calls to predict (to update for multiple simultaneous measurements), so the sigma...
[ "computes", "the", "values", "of", "sigmas_f", ".", "Normally", "a", "user", "would", "not", "call", "this", "but", "it", "is", "useful", "if", "you", "need", "to", "call", "update", "more", "than", "once", "between", "calls", "to", "predict", "(", "to",...
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/UKF.py#L487-L503
[ "def", "compute_process_sigmas", "(", "self", ",", "dt", ",", "fx", "=", "None", ",", "*", "*", "fx_args", ")", ":", "if", "fx", "is", "None", ":", "fx", "=", "self", ".", "fx", "# calculate sigma points for given mean and covariance", "sigmas", "=", "self",...
8123214de798ffb63db968bb0b9492ee74e77950
train
UnscentedKalmanFilter.batch_filter
Performs the UKF filter over the list of measurement in `zs`. Parameters ---------- zs : list-like list of measurements at each time step `self._dt` Missing measurements must be represented by 'None'. Rs : None, np.array or list-like, default=None o...
filterpy/kalman/UKF.py
def batch_filter(self, zs, Rs=None, dts=None, UT=None, saver=None): """ Performs the UKF filter over the list of measurement in `zs`. Parameters ---------- zs : list-like list of measurements at each time step `self._dt` Missing measurements must be repr...
def batch_filter(self, zs, Rs=None, dts=None, UT=None, saver=None): """ Performs the UKF filter over the list of measurement in `zs`. Parameters ---------- zs : list-like list of measurements at each time step `self._dt` Missing measurements must be repr...
[ "Performs", "the", "UKF", "filter", "over", "the", "list", "of", "measurement", "in", "zs", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/UKF.py#L505-L612
[ "def", "batch_filter", "(", "self", ",", "zs", ",", "Rs", "=", "None", ",", "dts", "=", "None", ",", "UT", "=", "None", ",", "saver", "=", "None", ")", ":", "#pylint: disable=too-many-arguments", "try", ":", "z", "=", "zs", "[", "0", "]", "except", ...
8123214de798ffb63db968bb0b9492ee74e77950
train
UnscentedKalmanFilter.rts_smoother
Runs the Rauch-Tung-Striebal Kalman smoother on a set of means and covariances computed by the UKF. The usual input would come from the output of `batch_filter()`. Parameters ---------- Xs : numpy.array array of the means (state variable x) of the output of a Kalman ...
filterpy/kalman/UKF.py
def rts_smoother(self, Xs, Ps, Qs=None, dts=None, UT=None): """ Runs the Rauch-Tung-Striebal Kalman smoother on a set of means and covariances computed by the UKF. The usual input would come from the output of `batch_filter()`. Parameters ---------- Xs : numpy.a...
def rts_smoother(self, Xs, Ps, Qs=None, dts=None, UT=None): """ Runs the Rauch-Tung-Striebal Kalman smoother on a set of means and covariances computed by the UKF. The usual input would come from the output of `batch_filter()`. Parameters ---------- Xs : numpy.a...
[ "Runs", "the", "Rauch", "-", "Tung", "-", "Striebal", "Kalman", "smoother", "on", "a", "set", "of", "means", "and", "covariances", "computed", "by", "the", "UKF", ".", "The", "usual", "input", "would", "come", "from", "the", "output", "of", "batch_filter",...
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/UKF.py#L614-L719
[ "def", "rts_smoother", "(", "self", ",", "Xs", ",", "Ps", ",", "Qs", "=", "None", ",", "dts", "=", "None", ",", "UT", "=", "None", ")", ":", "#pylint: disable=too-many-locals, too-many-arguments", "if", "len", "(", "Xs", ")", "!=", "len", "(", "Ps", ")...
8123214de798ffb63db968bb0b9492ee74e77950
train
RadarSim.get_range
Returns slant range to the object. Call once for each new measurement at dt time from last call.
filterpy/examples/radar_sim.py
def get_range(self, process_err_pct=0.05): """ Returns slant range to the object. Call once for each new measurement at dt time from last call. """ vel = self.vel + 5 * randn() alt = self.alt + 10 * randn() self.pos += vel*self.dt err = (self.pos * proc...
def get_range(self, process_err_pct=0.05): """ Returns slant range to the object. Call once for each new measurement at dt time from last call. """ vel = self.vel + 5 * randn() alt = self.alt + 10 * randn() self.pos += vel*self.dt err = (self.pos * proc...
[ "Returns", "slant", "range", "to", "the", "object", ".", "Call", "once", "for", "each", "new", "measurement", "at", "dt", "time", "from", "last", "call", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/examples/radar_sim.py#L39-L53
[ "def", "get_range", "(", "self", ",", "process_err_pct", "=", "0.05", ")", ":", "vel", "=", "self", ".", "vel", "+", "5", "*", "randn", "(", ")", "alt", "=", "self", ".", "alt", "+", "10", "*", "randn", "(", ")", "self", ".", "pos", "+=", "vel"...
8123214de798ffb63db968bb0b9492ee74e77950
train
MMAEFilterBank.predict
Predict next position using the Kalman filter state propagation equations for each filter in the bank. Parameters ---------- u : np.array Optional control vector. If non-zero, it is multiplied by B to create the control input into the system.
filterpy/kalman/mmae.py
def predict(self, u=0): """ Predict next position using the Kalman filter state propagation equations for each filter in the bank. Parameters ---------- u : np.array Optional control vector. If non-zero, it is multiplied by B to create the contro...
def predict(self, u=0): """ Predict next position using the Kalman filter state propagation equations for each filter in the bank. Parameters ---------- u : np.array Optional control vector. If non-zero, it is multiplied by B to create the contro...
[ "Predict", "next", "position", "using", "the", "Kalman", "filter", "state", "propagation", "equations", "for", "each", "filter", "in", "the", "bank", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/mmae.py#L140-L158
[ "def", "predict", "(", "self", ",", "u", "=", "0", ")", ":", "for", "f", "in", "self", ".", "filters", ":", "f", ".", "predict", "(", "u", ")", "# save prior", "self", ".", "x_prior", "=", "self", ".", "x", ".", "copy", "(", ")", "self", ".", ...
8123214de798ffb63db968bb0b9492ee74e77950
train
MMAEFilterBank.update
Add a new measurement (z) to the Kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update. R : np.array, scalar, or None Optionally provide R to override the measurement noise for this o...
filterpy/kalman/mmae.py
def update(self, z, R=None, H=None): """ Add a new measurement (z) to the Kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update. R : np.array, scalar, or None Optionally provide R...
def update(self, z, R=None, H=None): """ Add a new measurement (z) to the Kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update. R : np.array, scalar, or None Optionally provide R...
[ "Add", "a", "new", "measurement", "(", "z", ")", "to", "the", "Kalman", "filter", ".", "If", "z", "is", "None", "nothing", "is", "changed", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/mmae.py#L160-L213
[ "def", "update", "(", "self", ",", "z", ",", "R", "=", "None", ",", "H", "=", "None", ")", ":", "if", "H", "is", "None", ":", "H", "=", "self", ".", "H", "# new probability is recursively defined as prior * likelihood", "for", "i", ",", "f", "in", "enu...
8123214de798ffb63db968bb0b9492ee74e77950
train
residual_resample
Performs the residual resampling algorithm used by particle filters. Based on observation that we don't need to use random numbers to select most of the weights. Take int(N*w^i) samples of each particle i, and then resample any remaining using a standard resampling algorithm [1] Parameters ------...
filterpy/monte_carlo/resampling.py
def residual_resample(weights): """ Performs the residual resampling algorithm used by particle filters. Based on observation that we don't need to use random numbers to select most of the weights. Take int(N*w^i) samples of each particle i, and then resample any remaining using a standard resampling a...
def residual_resample(weights): """ Performs the residual resampling algorithm used by particle filters. Based on observation that we don't need to use random numbers to select most of the weights. Take int(N*w^i) samples of each particle i, and then resample any remaining using a standard resampling a...
[ "Performs", "the", "residual", "resampling", "algorithm", "used", "by", "particle", "filters", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/monte_carlo/resampling.py#L27-L76
[ "def", "residual_resample", "(", "weights", ")", ":", "N", "=", "len", "(", "weights", ")", "indexes", "=", "np", ".", "zeros", "(", "N", ",", "'i'", ")", "# take int(N*w) copies of each weight, which ensures particles with the", "# same weight are drawn uniformly", "...
8123214de798ffb63db968bb0b9492ee74e77950
train
stratified_resample
Performs the stratified resampling algorithm used by particle filters. This algorithms aims to make selections relatively uniformly across the particles. It divides the cumulative sum of the weights into N equal divisions, and then selects one particle randomly from each division. This guarantees that ...
filterpy/monte_carlo/resampling.py
def stratified_resample(weights): """ Performs the stratified resampling algorithm used by particle filters. This algorithms aims to make selections relatively uniformly across the particles. It divides the cumulative sum of the weights into N equal divisions, and then selects one particle randomly fro...
def stratified_resample(weights): """ Performs the stratified resampling algorithm used by particle filters. This algorithms aims to make selections relatively uniformly across the particles. It divides the cumulative sum of the weights into N equal divisions, and then selects one particle randomly fro...
[ "Performs", "the", "stratified", "resampling", "algorithm", "used", "by", "particle", "filters", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/monte_carlo/resampling.py#L80-L114
[ "def", "stratified_resample", "(", "weights", ")", ":", "N", "=", "len", "(", "weights", ")", "# make N subdivisions, and chose a random position within each one", "positions", "=", "(", "random", "(", "N", ")", "+", "range", "(", "N", ")", ")", "/", "N", "ind...
8123214de798ffb63db968bb0b9492ee74e77950
train
systematic_resample
Performs the systemic resampling algorithm used by particle filters. This algorithm separates the sample space into N divisions. A single random offset is used to to choose where to sample from for all divisions. This guarantees that every sample is exactly 1/N apart. Parameters ---------- wei...
filterpy/monte_carlo/resampling.py
def systematic_resample(weights): """ Performs the systemic resampling algorithm used by particle filters. This algorithm separates the sample space into N divisions. A single random offset is used to to choose where to sample from for all divisions. This guarantees that every sample is exactly 1/N apa...
def systematic_resample(weights): """ Performs the systemic resampling algorithm used by particle filters. This algorithm separates the sample space into N divisions. A single random offset is used to to choose where to sample from for all divisions. This guarantees that every sample is exactly 1/N apa...
[ "Performs", "the", "systemic", "resampling", "algorithm", "used", "by", "particle", "filters", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/monte_carlo/resampling.py#L117-L150
[ "def", "systematic_resample", "(", "weights", ")", ":", "N", "=", "len", "(", "weights", ")", "# make N subdivisions, and choose positions with a consistent random offset", "positions", "=", "(", "random", "(", ")", "+", "np", ".", "arange", "(", "N", ")", ")", ...
8123214de798ffb63db968bb0b9492ee74e77950
train
multinomial_resample
This is the naive form of roulette sampling where we compute the cumulative sum of the weights and then use binary search to select the resampled point based on a uniformly distributed random number. Run time is O(n log n). You do not want to use this algorithm in practice; for some reason it is popular...
filterpy/monte_carlo/resampling.py
def multinomial_resample(weights): """ This is the naive form of roulette sampling where we compute the cumulative sum of the weights and then use binary search to select the resampled point based on a uniformly distributed random number. Run time is O(n log n). You do not want to use this algorithm in ...
def multinomial_resample(weights): """ This is the naive form of roulette sampling where we compute the cumulative sum of the weights and then use binary search to select the resampled point based on a uniformly distributed random number. Run time is O(n log n). You do not want to use this algorithm in ...
[ "This", "is", "the", "naive", "form", "of", "roulette", "sampling", "where", "we", "compute", "the", "cumulative", "sum", "of", "the", "weights", "and", "then", "use", "binary", "search", "to", "select", "the", "resampled", "point", "based", "on", "a", "un...
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/monte_carlo/resampling.py#L153-L176
[ "def", "multinomial_resample", "(", "weights", ")", ":", "cumulative_sum", "=", "np", ".", "cumsum", "(", "weights", ")", "cumulative_sum", "[", "-", "1", "]", "=", "1.", "# avoid round-off errors: ensures sum is exactly one", "return", "np", ".", "searchsorted", ...
8123214de798ffb63db968bb0b9492ee74e77950
train
HInfinityFilter.update
Add a new measurement `z` to the H-Infinity filter. If `z` is None, nothing is changed. Parameters ---------- z : ndarray measurement for this update.
filterpy/hinfinity/hinfinity_filter.py
def update(self, z): """ Add a new measurement `z` to the H-Infinity filter. If `z` is None, nothing is changed. Parameters ---------- z : ndarray measurement for this update. """ if z is None: return # rename for readabi...
def update(self, z): """ Add a new measurement `z` to the H-Infinity filter. If `z` is None, nothing is changed. Parameters ---------- z : ndarray measurement for this update. """ if z is None: return # rename for readabi...
[ "Add", "a", "new", "measurement", "z", "to", "the", "H", "-", "Infinity", "filter", ".", "If", "z", "is", "None", "nothing", "is", "changed", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/hinfinity/hinfinity_filter.py#L93-L142
[ "def", "update", "(", "self", ",", "z", ")", ":", "if", "z", "is", "None", ":", "return", "# rename for readability and a tiny extra bit of speed", "I", "=", "self", ".", "_I", "gamma", "=", "self", ".", "gamma", "Q", "=", "self", ".", "Q", "H", "=", "...
8123214de798ffb63db968bb0b9492ee74e77950
train
HInfinityFilter.predict
Predict next position. Parameters ---------- u : ndarray Optional control vector. If non-zero, it is multiplied by `B` to create the control input into the system.
filterpy/hinfinity/hinfinity_filter.py
def predict(self, u=0): """ Predict next position. Parameters ---------- u : ndarray Optional control vector. If non-zero, it is multiplied by `B` to create the control input into the system. """ # x = Fx + Bu self.x = dot(self.F,...
def predict(self, u=0): """ Predict next position. Parameters ---------- u : ndarray Optional control vector. If non-zero, it is multiplied by `B` to create the control input into the system. """ # x = Fx + Bu self.x = dot(self.F,...
[ "Predict", "next", "position", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/hinfinity/hinfinity_filter.py#L145-L157
[ "def", "predict", "(", "self", ",", "u", "=", "0", ")", ":", "# x = Fx + Bu", "self", ".", "x", "=", "dot", "(", "self", ".", "F", ",", "self", ".", "x", ")", "+", "dot", "(", "self", ".", "B", ",", "u", ")" ]
8123214de798ffb63db968bb0b9492ee74e77950
train
HInfinityFilter.batch_filter
Batch processes a sequences of measurements. Parameters ---------- Zs : list-like list of measurements at each time step `self.dt` Missing measurements must be represented by 'None'. update_first : bool, default=False, optional, controls whether the ...
filterpy/hinfinity/hinfinity_filter.py
def batch_filter(self, Zs,update_first=False, saver=False): """ Batch processes a sequences of measurements. Parameters ---------- Zs : list-like list of measurements at each time step `self.dt` Missing measurements must be represented by 'None'. update_...
def batch_filter(self, Zs,update_first=False, saver=False): """ Batch processes a sequences of measurements. Parameters ---------- Zs : list-like list of measurements at each time step `self.dt` Missing measurements must be represented by 'None'. update_...
[ "Batch", "processes", "a", "sequences", "of", "measurements", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/hinfinity/hinfinity_filter.py#L160-L216
[ "def", "batch_filter", "(", "self", ",", "Zs", ",", "update_first", "=", "False", ",", "saver", "=", "False", ")", ":", "n", "=", "np", ".", "size", "(", "Zs", ",", "0", ")", "# mean estimates from H-Infinity Filter", "means", "=", "zeros", "(", "(", "...
8123214de798ffb63db968bb0b9492ee74e77950
train
HInfinityFilter.get_prediction
Predicts the next state of the filter and returns it. Does not alter the state of the filter. Parameters ---------- u : ndarray optional control input Returns ------- x : ndarray State vector of the prediction.
filterpy/hinfinity/hinfinity_filter.py
def get_prediction(self, u=0): """ Predicts the next state of the filter and returns it. Does not alter the state of the filter. Parameters ---------- u : ndarray optional control input Returns ------- x : ndarray State vector of ...
def get_prediction(self, u=0): """ Predicts the next state of the filter and returns it. Does not alter the state of the filter. Parameters ---------- u : ndarray optional control input Returns ------- x : ndarray State vector of ...
[ "Predicts", "the", "next", "state", "of", "the", "filter", "and", "returns", "it", ".", "Does", "not", "alter", "the", "state", "of", "the", "filter", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/hinfinity/hinfinity_filter.py#L219-L233
[ "def", "get_prediction", "(", "self", ",", "u", "=", "0", ")", ":", "return", "dot", "(", "self", ".", "F", ",", "self", ".", "x", ")", "+", "dot", "(", "self", ".", "B", ",", "u", ")" ]
8123214de798ffb63db968bb0b9492ee74e77950
train
HInfinityFilter.V
measurement noise matrix
filterpy/hinfinity/hinfinity_filter.py
def V(self, value): """ measurement noise matrix""" if np.isscalar(value): self._V = np.array([[value]], dtype=float) else: self._V = value self._V_inv = linalg.inv(self._V)
def V(self, value): """ measurement noise matrix""" if np.isscalar(value): self._V = np.array([[value]], dtype=float) else: self._V = value self._V_inv = linalg.inv(self._V)
[ "measurement", "noise", "matrix" ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/hinfinity/hinfinity_filter.py#L266-L273
[ "def", "V", "(", "self", ",", "value", ")", ":", "if", "np", ".", "isscalar", "(", "value", ")", ":", "self", ".", "_V", "=", "np", ".", "array", "(", "[", "[", "value", "]", "]", ",", "dtype", "=", "float", ")", "else", ":", "self", ".", "...
8123214de798ffb63db968bb0b9492ee74e77950
train
SquareRootKalmanFilter.update
Add a new measurement (z) to the kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update. R2 : np.array, scalar, or None Sqrt of meaaurement noize. Optionally provide to override the me...
filterpy/kalman/square_root.py
def update(self, z, R2=None): """ Add a new measurement (z) to the kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update. R2 : np.array, scalar, or None Sqrt of meaaurement noize....
def update(self, z, R2=None): """ Add a new measurement (z) to the kalman filter. If z is None, nothing is changed. Parameters ---------- z : np.array measurement for this update. R2 : np.array, scalar, or None Sqrt of meaaurement noize....
[ "Add", "a", "new", "measurement", "(", "z", ")", "to", "the", "kalman", "filter", ".", "If", "z", "is", "None", "nothing", "is", "changed", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/square_root.py#L174-L225
[ "def", "update", "(", "self", ",", "z", ",", "R2", "=", "None", ")", ":", "if", "z", "is", "None", ":", "self", ".", "z", "=", "np", ".", "array", "(", "[", "[", "None", "]", "*", "self", ".", "dim_z", "]", ")", ".", "T", "self", ".", "x_...
8123214de798ffb63db968bb0b9492ee74e77950
train
SquareRootKalmanFilter.predict
Predict next state (prior) using the Kalman filter state propagation equations. Parameters ---------- u : np.array, optional Optional control vector. If non-zero, it is multiplied by B to create the control input into the system.
filterpy/kalman/square_root.py
def predict(self, u=0): """ Predict next state (prior) using the Kalman filter state propagation equations. Parameters ---------- u : np.array, optional Optional control vector. If non-zero, it is multiplied by B to create the control input into ...
def predict(self, u=0): """ Predict next state (prior) using the Kalman filter state propagation equations. Parameters ---------- u : np.array, optional Optional control vector. If non-zero, it is multiplied by B to create the control input into ...
[ "Predict", "next", "state", "(", "prior", ")", "using", "the", "Kalman", "filter", "state", "propagation", "equations", "." ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/square_root.py#L227-L249
[ "def", "predict", "(", "self", ",", "u", "=", "0", ")", ":", "# x = Fx + Bu", "self", ".", "x", "=", "dot", "(", "self", ".", "F", ",", "self", ".", "x", ")", "+", "dot", "(", "self", ".", "B", ",", "u", ")", "# P = FPF' + Q", "_", ",", "P2",...
8123214de798ffb63db968bb0b9492ee74e77950
train
SquareRootKalmanFilter.Q
Process uncertainty
filterpy/kalman/square_root.py
def Q(self, value): """ Process uncertainty""" self._Q = value self._Q1_2 = cholesky(self._Q, lower=True)
def Q(self, value): """ Process uncertainty""" self._Q = value self._Q1_2 = cholesky(self._Q, lower=True)
[ "Process", "uncertainty" ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/square_root.py#L286-L289
[ "def", "Q", "(", "self", ",", "value", ")", ":", "self", ".", "_Q", "=", "value", "self", ".", "_Q1_2", "=", "cholesky", "(", "self", ".", "_Q", ",", "lower", "=", "True", ")" ]
8123214de798ffb63db968bb0b9492ee74e77950
train
SquareRootKalmanFilter.P
covariance matrix
filterpy/kalman/square_root.py
def P(self, value): """ covariance matrix""" self._P = value self._P1_2 = cholesky(self._P, lower=True)
def P(self, value): """ covariance matrix""" self._P = value self._P1_2 = cholesky(self._P, lower=True)
[ "covariance", "matrix" ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/square_root.py#L312-L315
[ "def", "P", "(", "self", ",", "value", ")", ":", "self", ".", "_P", "=", "value", "self", ".", "_P1_2", "=", "cholesky", "(", "self", ".", "_P", ",", "lower", "=", "True", ")" ]
8123214de798ffb63db968bb0b9492ee74e77950
train
SquareRootKalmanFilter.R
measurement uncertainty
filterpy/kalman/square_root.py
def R(self, value): """ measurement uncertainty""" self._R = value self._R1_2 = cholesky(self._R, lower=True)
def R(self, value): """ measurement uncertainty""" self._R = value self._R1_2 = cholesky(self._R, lower=True)
[ "measurement", "uncertainty" ]
rlabbe/filterpy
python
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/square_root.py#L328-L331
[ "def", "R", "(", "self", ",", "value", ")", ":", "self", ".", "_R", "=", "value", "self", ".", "_R1_2", "=", "cholesky", "(", "self", ".", "_R", ",", "lower", "=", "True", ")" ]
8123214de798ffb63db968bb0b9492ee74e77950
train
WebSocketProtocol.process_request
This hook is called to determine if the websocket should return an HTTP response and close. Our behavior here is to start the ASGI application, and then wait for either `accept` or `close` in order to determine if we should close the connection.
uvicorn/protocols/websockets/websockets_impl.py
async def process_request(self, path, headers): """ This hook is called to determine if the websocket should return an HTTP response and close. Our behavior here is to start the ASGI application, and then wait for either `accept` or `close` in order to determine if we should ...
async def process_request(self, path, headers): """ This hook is called to determine if the websocket should return an HTTP response and close. Our behavior here is to start the ASGI application, and then wait for either `accept` or `close` in order to determine if we should ...
[ "This", "hook", "is", "called", "to", "determine", "if", "the", "websocket", "should", "return", "an", "HTTP", "response", "and", "close", "." ]
encode/uvicorn
python
https://github.com/encode/uvicorn/blob/b4c138910bb63475efd028627e10adda722e4937/uvicorn/protocols/websockets/websockets_impl.py#L73-L110
[ "async", "def", "process_request", "(", "self", ",", "path", ",", "headers", ")", ":", "path_portion", ",", "_", ",", "query_string", "=", "path", ".", "partition", "(", "\"?\"", ")", "websockets", ".", "handshake", ".", "check_request", "(", "headers", ")...
b4c138910bb63475efd028627e10adda722e4937
train
WebSocketProtocol.ws_handler
This is the main handler function for the 'websockets' implementation to call into. We just wait for close then return, and instead allow 'send' and 'receive' events to drive the flow.
uvicorn/protocols/websockets/websockets_impl.py
async def ws_handler(self, protocol, path): """ This is the main handler function for the 'websockets' implementation to call into. We just wait for close then return, and instead allow 'send' and 'receive' events to drive the flow. """ self.handshake_completed_event.set(...
async def ws_handler(self, protocol, path): """ This is the main handler function for the 'websockets' implementation to call into. We just wait for close then return, and instead allow 'send' and 'receive' events to drive the flow. """ self.handshake_completed_event.set(...
[ "This", "is", "the", "main", "handler", "function", "for", "the", "websockets", "implementation", "to", "call", "into", ".", "We", "just", "wait", "for", "close", "then", "return", "and", "instead", "allow", "send", "and", "receive", "events", "to", "drive",...
encode/uvicorn
python
https://github.com/encode/uvicorn/blob/b4c138910bb63475efd028627e10adda722e4937/uvicorn/protocols/websockets/websockets_impl.py#L131-L138
[ "async", "def", "ws_handler", "(", "self", ",", "protocol", ",", "path", ")", ":", "self", ".", "handshake_completed_event", ".", "set", "(", ")", "await", "self", ".", "closed_event", ".", "wait", "(", ")" ]
b4c138910bb63475efd028627e10adda722e4937
train
WebSocketProtocol.run_asgi
Wrapper around the ASGI callable, handling exceptions and unexpected termination states.
uvicorn/protocols/websockets/websockets_impl.py
async def run_asgi(self): """ Wrapper around the ASGI callable, handling exceptions and unexpected termination states. """ try: result = await self.app(self.scope, self.asgi_receive, self.asgi_send) except BaseException as exc: self.closed_event.se...
async def run_asgi(self): """ Wrapper around the ASGI callable, handling exceptions and unexpected termination states. """ try: result = await self.app(self.scope, self.asgi_receive, self.asgi_send) except BaseException as exc: self.closed_event.se...
[ "Wrapper", "around", "the", "ASGI", "callable", "handling", "exceptions", "and", "unexpected", "termination", "states", "." ]
encode/uvicorn
python
https://github.com/encode/uvicorn/blob/b4c138910bb63475efd028627e10adda722e4937/uvicorn/protocols/websockets/websockets_impl.py#L140-L167
[ "async", "def", "run_asgi", "(", "self", ")", ":", "try", ":", "result", "=", "await", "self", ".", "app", "(", "self", ".", "scope", ",", "self", ".", "asgi_receive", ",", "self", ".", "asgi_send", ")", "except", "BaseException", "as", "exc", ":", "...
b4c138910bb63475efd028627e10adda722e4937
train
HttpToolsProtocol.shutdown
Called by the server to commence a graceful shutdown.
uvicorn/protocols/http/httptools_impl.py
def shutdown(self): """ Called by the server to commence a graceful shutdown. """ if self.cycle is None or self.cycle.response_complete: self.transport.close() else: self.cycle.keep_alive = False
def shutdown(self): """ Called by the server to commence a graceful shutdown. """ if self.cycle is None or self.cycle.response_complete: self.transport.close() else: self.cycle.keep_alive = False
[ "Called", "by", "the", "server", "to", "commence", "a", "graceful", "shutdown", "." ]
encode/uvicorn
python
https://github.com/encode/uvicorn/blob/b4c138910bb63475efd028627e10adda722e4937/uvicorn/protocols/http/httptools_impl.py#L298-L305
[ "def", "shutdown", "(", "self", ")", ":", "if", "self", ".", "cycle", "is", "None", "or", "self", ".", "cycle", ".", "response_complete", ":", "self", ".", "transport", ".", "close", "(", ")", "else", ":", "self", ".", "cycle", ".", "keep_alive", "="...
b4c138910bb63475efd028627e10adda722e4937
train
H11Protocol.shutdown
Called by the server to commence a graceful shutdown.
uvicorn/protocols/http/h11_impl.py
def shutdown(self): """ Called by the server to commence a graceful shutdown. """ if self.cycle is None or self.cycle.response_complete: event = h11.ConnectionClosed() self.conn.send(event) self.transport.close() else: self.cycle.ke...
def shutdown(self): """ Called by the server to commence a graceful shutdown. """ if self.cycle is None or self.cycle.response_complete: event = h11.ConnectionClosed() self.conn.send(event) self.transport.close() else: self.cycle.ke...
[ "Called", "by", "the", "server", "to", "commence", "a", "graceful", "shutdown", "." ]
encode/uvicorn
python
https://github.com/encode/uvicorn/blob/b4c138910bb63475efd028627e10adda722e4937/uvicorn/protocols/http/h11_impl.py#L297-L306
[ "def", "shutdown", "(", "self", ")", ":", "if", "self", ".", "cycle", "is", "None", "or", "self", ".", "cycle", ".", "response_complete", ":", "event", "=", "h11", ".", "ConnectionClosed", "(", ")", "self", ".", "conn", ".", "send", "(", "event", ")"...
b4c138910bb63475efd028627e10adda722e4937
train
H11Protocol.timeout_keep_alive_handler
Called on a keep-alive connection if no new data is received after a short delay.
uvicorn/protocols/http/h11_impl.py
def timeout_keep_alive_handler(self): """ Called on a keep-alive connection if no new data is received after a short delay. """ if not self.transport.is_closing(): event = h11.ConnectionClosed() self.conn.send(event) self.transport.close()
def timeout_keep_alive_handler(self): """ Called on a keep-alive connection if no new data is received after a short delay. """ if not self.transport.is_closing(): event = h11.ConnectionClosed() self.conn.send(event) self.transport.close()
[ "Called", "on", "a", "keep", "-", "alive", "connection", "if", "no", "new", "data", "is", "received", "after", "a", "short", "delay", "." ]
encode/uvicorn
python
https://github.com/encode/uvicorn/blob/b4c138910bb63475efd028627e10adda722e4937/uvicorn/protocols/http/h11_impl.py#L320-L327
[ "def", "timeout_keep_alive_handler", "(", "self", ")", ":", "if", "not", "self", ".", "transport", ".", "is_closing", "(", ")", ":", "event", "=", "h11", ".", "ConnectionClosed", "(", ")", "self", ".", "conn", ".", "send", "(", "event", ")", "self", "....
b4c138910bb63475efd028627e10adda722e4937
train
build_environ
Builds a scope and request message into a WSGI environ object.
uvicorn/middleware/wsgi.py
def build_environ(scope, message, body): """ Builds a scope and request message into a WSGI environ object. """ environ = { "REQUEST_METHOD": scope["method"], "SCRIPT_NAME": "", "PATH_INFO": scope["path"], "QUERY_STRING": scope["query_string"].decode("ascii"), "SE...
def build_environ(scope, message, body): """ Builds a scope and request message into a WSGI environ object. """ environ = { "REQUEST_METHOD": scope["method"], "SCRIPT_NAME": "", "PATH_INFO": scope["path"], "QUERY_STRING": scope["query_string"].decode("ascii"), "SE...
[ "Builds", "a", "scope", "and", "request", "message", "into", "a", "WSGI", "environ", "object", "." ]
encode/uvicorn
python
https://github.com/encode/uvicorn/blob/b4c138910bb63475efd028627e10adda722e4937/uvicorn/middleware/wsgi.py#L7-L49
[ "def", "build_environ", "(", "scope", ",", "message", ",", "body", ")", ":", "environ", "=", "{", "\"REQUEST_METHOD\"", ":", "scope", "[", "\"method\"", "]", ",", "\"SCRIPT_NAME\"", ":", "\"\"", ",", "\"PATH_INFO\"", ":", "scope", "[", "\"path\"", "]", ","...
b4c138910bb63475efd028627e10adda722e4937
train
message_with_placeholders
Return an ASGI message, with any body-type content omitted and replaced with a placeholder.
uvicorn/middleware/message_logger.py
def message_with_placeholders(message): """ Return an ASGI message, with any body-type content omitted and replaced with a placeholder. """ new_message = message.copy() for attr in PLACEHOLDER_FORMAT.keys(): if message.get(attr) is not None: content = message[attr] ...
def message_with_placeholders(message): """ Return an ASGI message, with any body-type content omitted and replaced with a placeholder. """ new_message = message.copy() for attr in PLACEHOLDER_FORMAT.keys(): if message.get(attr) is not None: content = message[attr] ...
[ "Return", "an", "ASGI", "message", "with", "any", "body", "-", "type", "content", "omitted", "and", "replaced", "with", "a", "placeholder", "." ]
encode/uvicorn
python
https://github.com/encode/uvicorn/blob/b4c138910bb63475efd028627e10adda722e4937/uvicorn/middleware/message_logger.py#L11-L22
[ "def", "message_with_placeholders", "(", "message", ")", ":", "new_message", "=", "message", ".", "copy", "(", ")", "for", "attr", "in", "PLACEHOLDER_FORMAT", ".", "keys", "(", ")", ":", "if", "message", ".", "get", "(", "attr", ")", "is", "not", "None",...
b4c138910bb63475efd028627e10adda722e4937
train
setup_logger
setup root logger with ColoredFormatter.
httprunner/logger.py
def setup_logger(log_level, log_file=None): """setup root logger with ColoredFormatter.""" level = getattr(logging, log_level.upper(), None) if not level: color_print("Invalid log level: %s" % log_level, "RED") sys.exit(1) # hide traceback when log level is INFO/WARNING/ERROR/CRITICAL ...
def setup_logger(log_level, log_file=None): """setup root logger with ColoredFormatter.""" level = getattr(logging, log_level.upper(), None) if not level: color_print("Invalid log level: %s" % log_level, "RED") sys.exit(1) # hide traceback when log level is INFO/WARNING/ERROR/CRITICAL ...
[ "setup", "root", "logger", "with", "ColoredFormatter", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/logger.py#L21-L46
[ "def", "setup_logger", "(", "log_level", ",", "log_file", "=", "None", ")", ":", "level", "=", "getattr", "(", "logging", ",", "log_level", ".", "upper", "(", ")", ",", "None", ")", "if", "not", "level", ":", "color_print", "(", "\"Invalid log level: %s\""...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
log_with_color
log with color by different level
httprunner/logger.py
def log_with_color(level): """ log with color by different level """ def wrapper(text): color = log_colors_config[level.upper()] getattr(logger, level.lower())(coloring(text, color)) return wrapper
def log_with_color(level): """ log with color by different level """ def wrapper(text): color = log_colors_config[level.upper()] getattr(logger, level.lower())(coloring(text, color)) return wrapper
[ "log", "with", "color", "by", "different", "level" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/logger.py#L59-L66
[ "def", "log_with_color", "(", "level", ")", ":", "def", "wrapper", "(", "text", ")", ":", "color", "=", "log_colors_config", "[", "level", ".", "upper", "(", ")", "]", "getattr", "(", "logger", ",", "level", ".", "lower", "(", ")", ")", "(", "colorin...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
Runner._handle_skip_feature
handle skip feature for test - skip: skip current test unconditionally - skipIf: skip current test if condition is true - skipUnless: skip current test unless condition is true Args: test_dict (dict): test info Raises: SkipTest: skip test
httprunner/runner.py
def _handle_skip_feature(self, test_dict): """ handle skip feature for test - skip: skip current test unconditionally - skipIf: skip current test if condition is true - skipUnless: skip current test unless condition is true Args: test_dict (dict): test in...
def _handle_skip_feature(self, test_dict): """ handle skip feature for test - skip: skip current test unconditionally - skipIf: skip current test if condition is true - skipUnless: skip current test unless condition is true Args: test_dict (dict): test in...
[ "handle", "skip", "feature", "for", "test", "-", "skip", ":", "skip", "current", "test", "unconditionally", "-", "skipIf", ":", "skip", "current", "test", "if", "condition", "is", "true", "-", "skipUnless", ":", "skip", "current", "test", "unless", "conditio...
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/runner.py#L102-L132
[ "def", "_handle_skip_feature", "(", "self", ",", "test_dict", ")", ":", "# TODO: move skip to initialize", "skip_reason", "=", "None", "if", "\"skip\"", "in", "test_dict", ":", "skip_reason", "=", "test_dict", "[", "\"skip\"", "]", "elif", "\"skipIf\"", "in", "tes...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
Runner.do_hook_actions
call hook actions. Args: actions (list): each action in actions list maybe in two format. format1 (dict): assignment, the value returned by hook function will be assigned to variable. {"var": "${func()}"} format2 (str): only call hook functions. ...
httprunner/runner.py
def do_hook_actions(self, actions, hook_type): """ call hook actions. Args: actions (list): each action in actions list maybe in two format. format1 (dict): assignment, the value returned by hook function will be assigned to variable. {"var": "${func()}"...
def do_hook_actions(self, actions, hook_type): """ call hook actions. Args: actions (list): each action in actions list maybe in two format. format1 (dict): assignment, the value returned by hook function will be assigned to variable. {"var": "${func()}"...
[ "call", "hook", "actions", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/runner.py#L134-L168
[ "def", "do_hook_actions", "(", "self", ",", "actions", ",", "hook_type", ")", ":", "logger", ".", "log_debug", "(", "\"call {} hook actions.\"", ".", "format", "(", "hook_type", ")", ")", "for", "action", "in", "actions", ":", "if", "isinstance", "(", "actio...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
Runner.extract_output
extract output variables
httprunner/runner.py
def extract_output(self, output_variables_list): """ extract output variables """ variables_mapping = self.session_context.session_variables_mapping output = {} for variable in output_variables_list: if variable not in variables_mapping: logger.log_wa...
def extract_output(self, output_variables_list): """ extract output variables """ variables_mapping = self.session_context.session_variables_mapping output = {} for variable in output_variables_list: if variable not in variables_mapping: logger.log_wa...
[ "extract", "output", "variables" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/runner.py#L385-L402
[ "def", "extract_output", "(", "self", ",", "output_variables_list", ")", ":", "variables_mapping", "=", "self", ".", "session_context", ".", "session_variables_mapping", "output", "=", "{", "}", "for", "variable", "in", "output_variables_list", ":", "if", "variable"...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
HttpRunner._run_suite
run tests in test_suite Args: test_suite: unittest.TestSuite() Returns: list: tests_results
httprunner/api.py
def _run_suite(self, test_suite): """ run tests in test_suite Args: test_suite: unittest.TestSuite() Returns: list: tests_results """ tests_results = [] for testcase in test_suite: testcase_name = testcase.config.get("name") ...
def _run_suite(self, test_suite): """ run tests in test_suite Args: test_suite: unittest.TestSuite() Returns: list: tests_results """ tests_results = [] for testcase in test_suite: testcase_name = testcase.config.get("name") ...
[ "run", "tests", "in", "test_suite" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/api.py#L99-L118
[ "def", "_run_suite", "(", "self", ",", "test_suite", ")", ":", "tests_results", "=", "[", "]", "for", "testcase", "in", "test_suite", ":", "testcase_name", "=", "testcase", ".", "config", ".", "get", "(", "\"name\"", ")", "logger", ".", "log_info", "(", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
HttpRunner._aggregate
aggregate results Args: tests_results (list): list of (testcase, result)
httprunner/api.py
def _aggregate(self, tests_results): """ aggregate results Args: tests_results (list): list of (testcase, result) """ summary = { "success": True, "stat": { "testcases": { "total": len(tests_results), ...
def _aggregate(self, tests_results): """ aggregate results Args: tests_results (list): list of (testcase, result) """ summary = { "success": True, "stat": { "testcases": { "total": len(tests_results), ...
[ "aggregate", "results" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/api.py#L120-L160
[ "def", "_aggregate", "(", "self", ",", "tests_results", ")", ":", "summary", "=", "{", "\"success\"", ":", "True", ",", "\"stat\"", ":", "{", "\"testcases\"", ":", "{", "\"total\"", ":", "len", "(", "tests_results", ")", ",", "\"success\"", ":", "0", ","...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
HttpRunner.run_path
run testcase/testsuite file or folder. Args: path (str): testcase/testsuite file/foler path. dot_env_path (str): specified .env file path. mapping (dict): if mapping is specified, it will override variables in config block. Returns: instance: HttpRunner(...
httprunner/api.py
def run_path(self, path, dot_env_path=None, mapping=None): """ run testcase/testsuite file or folder. Args: path (str): testcase/testsuite file/foler path. dot_env_path (str): specified .env file path. mapping (dict): if mapping is specified, it will override variabl...
def run_path(self, path, dot_env_path=None, mapping=None): """ run testcase/testsuite file or folder. Args: path (str): testcase/testsuite file/foler path. dot_env_path (str): specified .env file path. mapping (dict): if mapping is specified, it will override variabl...
[ "run", "testcase", "/", "testsuite", "file", "or", "folder", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/api.py#L232-L252
[ "def", "run_path", "(", "self", ",", "path", ",", "dot_env_path", "=", "None", ",", "mapping", "=", "None", ")", ":", "# load tests", "self", ".", "exception_stage", "=", "\"load tests\"", "tests_mapping", "=", "loader", ".", "load_tests", "(", "path", ",", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
HttpRunner.run
main interface. Args: path_or_tests: str: testcase/testsuite file/foler path dict: valid testcase/testsuite data
httprunner/api.py
def run(self, path_or_tests, dot_env_path=None, mapping=None): """ main interface. Args: path_or_tests: str: testcase/testsuite file/foler path dict: valid testcase/testsuite data """ if validator.is_testcase_path(path_or_tests): ...
def run(self, path_or_tests, dot_env_path=None, mapping=None): """ main interface. Args: path_or_tests: str: testcase/testsuite file/foler path dict: valid testcase/testsuite data """ if validator.is_testcase_path(path_or_tests): ...
[ "main", "interface", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/api.py#L254-L268
[ "def", "run", "(", "self", ",", "path_or_tests", ",", "dot_env_path", "=", "None", ",", "mapping", "=", "None", ")", ":", "if", "validator", ".", "is_testcase_path", "(", "path_or_tests", ")", ":", "return", "self", ".", "run_path", "(", "path_or_tests", "...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
set_os_environ
set variables mapping to os.environ
httprunner/utils.py
def set_os_environ(variables_mapping): """ set variables mapping to os.environ """ for variable in variables_mapping: os.environ[variable] = variables_mapping[variable] logger.log_debug("Set OS environment variable: {}".format(variable))
def set_os_environ(variables_mapping): """ set variables mapping to os.environ """ for variable in variables_mapping: os.environ[variable] = variables_mapping[variable] logger.log_debug("Set OS environment variable: {}".format(variable))
[ "set", "variables", "mapping", "to", "os", ".", "environ" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L20-L25
[ "def", "set_os_environ", "(", "variables_mapping", ")", ":", "for", "variable", "in", "variables_mapping", ":", "os", ".", "environ", "[", "variable", "]", "=", "variables_mapping", "[", "variable", "]", "logger", ".", "log_debug", "(", "\"Set OS environment varia...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
unset_os_environ
set variables mapping to os.environ
httprunner/utils.py
def unset_os_environ(variables_mapping): """ set variables mapping to os.environ """ for variable in variables_mapping: os.environ.pop(variable) logger.log_debug("Unset OS environment variable: {}".format(variable))
def unset_os_environ(variables_mapping): """ set variables mapping to os.environ """ for variable in variables_mapping: os.environ.pop(variable) logger.log_debug("Unset OS environment variable: {}".format(variable))
[ "set", "variables", "mapping", "to", "os", ".", "environ" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L28-L33
[ "def", "unset_os_environ", "(", "variables_mapping", ")", ":", "for", "variable", "in", "variables_mapping", ":", "os", ".", "environ", ".", "pop", "(", "variable", ")", "logger", ".", "log_debug", "(", "\"Unset OS environment variable: {}\"", ".", "format", "(", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
build_url
prepend url with base_url unless it's already an absolute URL
httprunner/utils.py
def build_url(base_url, path): """ prepend url with base_url unless it's already an absolute URL """ if absolute_http_url_regexp.match(path): return path elif base_url: return "{}/{}".format(base_url.rstrip("/"), path.lstrip("/")) else: raise ParamsError("base url missed!")
def build_url(base_url, path): """ prepend url with base_url unless it's already an absolute URL """ if absolute_http_url_regexp.match(path): return path elif base_url: return "{}/{}".format(base_url.rstrip("/"), path.lstrip("/")) else: raise ParamsError("base url missed!")
[ "prepend", "url", "with", "base_url", "unless", "it", "s", "already", "an", "absolute", "URL" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L55-L62
[ "def", "build_url", "(", "base_url", ",", "path", ")", ":", "if", "absolute_http_url_regexp", ".", "match", "(", "path", ")", ":", "return", "path", "elif", "base_url", ":", "return", "\"{}/{}\"", ".", "format", "(", "base_url", ".", "rstrip", "(", "\"/\""...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
query_json
Do an xpath-like query with json_content. Args: json_content (dict/list/string): content to be queried. query (str): query string. delimiter (str): delimiter symbol. Returns: str: queried result. Examples: >>> json_content = { "ids": [1, 2, 3, 4], ...
httprunner/utils.py
def query_json(json_content, query, delimiter='.'): """ Do an xpath-like query with json_content. Args: json_content (dict/list/string): content to be queried. query (str): query string. delimiter (str): delimiter symbol. Returns: str: queried result. Examples: ...
def query_json(json_content, query, delimiter='.'): """ Do an xpath-like query with json_content. Args: json_content (dict/list/string): content to be queried. query (str): query string. delimiter (str): delimiter symbol. Returns: str: queried result. Examples: ...
[ "Do", "an", "xpath", "-", "like", "query", "with", "json_content", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L65-L120
[ "def", "query_json", "(", "json_content", ",", "query", ",", "delimiter", "=", "'.'", ")", ":", "raise_flag", "=", "False", "response_body", "=", "u\"response body: {}\\n\"", ".", "format", "(", "json_content", ")", "try", ":", "for", "key", "in", "query", "...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
deep_update_dict
update origin dict with override dict recursively e.g. origin_dict = {'a': 1, 'b': {'c': 2, 'd': 4}} override_dict = {'b': {'c': 3}} return: {'a': 1, 'b': {'c': 3, 'd': 4}}
httprunner/utils.py
def deep_update_dict(origin_dict, override_dict): """ update origin dict with override dict recursively e.g. origin_dict = {'a': 1, 'b': {'c': 2, 'd': 4}} override_dict = {'b': {'c': 3}} return: {'a': 1, 'b': {'c': 3, 'd': 4}} """ if not override_dict: return origin_dict for ke...
def deep_update_dict(origin_dict, override_dict): """ update origin dict with override dict recursively e.g. origin_dict = {'a': 1, 'b': {'c': 2, 'd': 4}} override_dict = {'b': {'c': 3}} return: {'a': 1, 'b': {'c': 3, 'd': 4}} """ if not override_dict: return origin_dict for ke...
[ "update", "origin", "dict", "with", "override", "dict", "recursively", "e", ".", "g", ".", "origin_dict", "=", "{", "a", ":", "1", "b", ":", "{", "c", ":", "2", "d", ":", "4", "}}", "override_dict", "=", "{", "b", ":", "{", "c", ":", "3", "}}",...
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L123-L142
[ "def", "deep_update_dict", "(", "origin_dict", ",", "override_dict", ")", ":", "if", "not", "override_dict", ":", "return", "origin_dict", "for", "key", ",", "val", "in", "override_dict", ".", "items", "(", ")", ":", "if", "isinstance", "(", "val", ",", "d...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
convert_dict_to_params
convert dict to params string Args: src_dict (dict): source mapping data structure Returns: str: string params data Examples: >>> src_dict = { "a": 1, "b": 2 } >>> convert_dict_to_params(src_dict) >>> "a=1&b=2"
httprunner/utils.py
def convert_dict_to_params(src_dict): """ convert dict to params string Args: src_dict (dict): source mapping data structure Returns: str: string params data Examples: >>> src_dict = { "a": 1, "b": 2 } >>> convert_dict_to_params(src_dict...
def convert_dict_to_params(src_dict): """ convert dict to params string Args: src_dict (dict): source mapping data structure Returns: str: string params data Examples: >>> src_dict = { "a": 1, "b": 2 } >>> convert_dict_to_params(src_dict...
[ "convert", "dict", "to", "params", "string" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L145-L166
[ "def", "convert_dict_to_params", "(", "src_dict", ")", ":", "return", "\"&\"", ".", "join", "(", "[", "\"{}={}\"", ".", "format", "(", "key", ",", "value", ")", "for", "key", ",", "value", "in", "src_dict", ".", "items", "(", ")", "]", ")" ]
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
lower_dict_keys
convert keys in dict to lower case Args: origin_dict (dict): mapping data structure Returns: dict: mapping with all keys lowered. Examples: >>> origin_dict = { "Name": "", "Request": "", "URL": "", "METHOD": "", "Headers"...
httprunner/utils.py
def lower_dict_keys(origin_dict): """ convert keys in dict to lower case Args: origin_dict (dict): mapping data structure Returns: dict: mapping with all keys lowered. Examples: >>> origin_dict = { "Name": "", "Request": "", "URL": "", ...
def lower_dict_keys(origin_dict): """ convert keys in dict to lower case Args: origin_dict (dict): mapping data structure Returns: dict: mapping with all keys lowered. Examples: >>> origin_dict = { "Name": "", "Request": "", "URL": "", ...
[ "convert", "keys", "in", "dict", "to", "lower", "case" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L169-L204
[ "def", "lower_dict_keys", "(", "origin_dict", ")", ":", "if", "not", "origin_dict", "or", "not", "isinstance", "(", "origin_dict", ",", "dict", ")", ":", "return", "origin_dict", "return", "{", "key", ".", "lower", "(", ")", ":", "value", "for", "key", "...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
deepcopy_dict
deepcopy dict data, ignore file object (_io.BufferedReader) Args: data (dict): dict data structure { 'a': 1, 'b': [2, 4], 'c': lambda x: x+1, 'd': open('LICENSE'), 'f': { 'f1': {'a1': 2}, ...
httprunner/utils.py
def deepcopy_dict(data): """ deepcopy dict data, ignore file object (_io.BufferedReader) Args: data (dict): dict data structure { 'a': 1, 'b': [2, 4], 'c': lambda x: x+1, 'd': open('LICENSE'), 'f': { ...
def deepcopy_dict(data): """ deepcopy dict data, ignore file object (_io.BufferedReader) Args: data (dict): dict data structure { 'a': 1, 'b': [2, 4], 'c': lambda x: x+1, 'd': open('LICENSE'), 'f': { ...
[ "deepcopy", "dict", "data", "ignore", "file", "object", "(", "_io", ".", "BufferedReader", ")" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L222-L255
[ "def", "deepcopy_dict", "(", "data", ")", ":", "try", ":", "return", "copy", ".", "deepcopy", "(", "data", ")", "except", "TypeError", ":", "copied_data", "=", "{", "}", "for", "key", ",", "value", "in", "data", ".", "items", "(", ")", ":", "if", "...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
ensure_mapping_format
ensure variables are in mapping format. Args: variables (list/dict): original variables Returns: dict: ensured variables in dict format Examples: >>> variables = [ {"a": 1}, {"b": 2} ] >>> print(ensure_mapping_format(variables)) ...
httprunner/utils.py
def ensure_mapping_format(variables): """ ensure variables are in mapping format. Args: variables (list/dict): original variables Returns: dict: ensured variables in dict format Examples: >>> variables = [ {"a": 1}, {"b": 2} ] ...
def ensure_mapping_format(variables): """ ensure variables are in mapping format. Args: variables (list/dict): original variables Returns: dict: ensured variables in dict format Examples: >>> variables = [ {"a": 1}, {"b": 2} ] ...
[ "ensure", "variables", "are", "in", "mapping", "format", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L258-L290
[ "def", "ensure_mapping_format", "(", "variables", ")", ":", "if", "isinstance", "(", "variables", ",", "list", ")", ":", "variables_dict", "=", "{", "}", "for", "map_dict", "in", "variables", ":", "variables_dict", ".", "update", "(", "map_dict", ")", "retur...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
extend_variables
extend raw_variables with override_variables. override_variables will merge and override raw_variables. Args: raw_variables (list): override_variables (list): Returns: dict: extended variables mapping Examples: >>> raw_variables = [{"var1": "val1"}, {"var2": "val2"...
httprunner/utils.py
def extend_variables(raw_variables, override_variables): """ extend raw_variables with override_variables. override_variables will merge and override raw_variables. Args: raw_variables (list): override_variables (list): Returns: dict: extended variables mapping Example...
def extend_variables(raw_variables, override_variables): """ extend raw_variables with override_variables. override_variables will merge and override raw_variables. Args: raw_variables (list): override_variables (list): Returns: dict: extended variables mapping Example...
[ "extend", "raw_variables", "with", "override_variables", ".", "override_variables", "will", "merge", "and", "override", "raw_variables", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L293-L327
[ "def", "extend_variables", "(", "raw_variables", ",", "override_variables", ")", ":", "if", "not", "raw_variables", ":", "override_variables_mapping", "=", "ensure_mapping_format", "(", "override_variables", ")", "return", "override_variables_mapping", "elif", "not", "ove...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
print_info
print info in mapping. Args: info_mapping (dict): input(variables) or output mapping. Examples: >>> info_mapping = { "var_a": "hello", "var_b": "world" } >>> info_mapping = { "status_code": 500 } >>> print_...
httprunner/utils.py
def print_info(info_mapping): """ print info in mapping. Args: info_mapping (dict): input(variables) or output mapping. Examples: >>> info_mapping = { "var_a": "hello", "var_b": "world" } >>> info_mapping = { "status_code"...
def print_info(info_mapping): """ print info in mapping. Args: info_mapping (dict): input(variables) or output mapping. Examples: >>> info_mapping = { "var_a": "hello", "var_b": "world" } >>> info_mapping = { "status_code"...
[ "print", "info", "in", "mapping", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L352-L400
[ "def", "print_info", "(", "info_mapping", ")", ":", "if", "not", "info_mapping", ":", "return", "content_format", "=", "\"{:<16} : {:<}\\n\"", "content", "=", "\"\\n==================== Output ====================\\n\"", "content", "+=", "content_format", ".", "format", "...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
create_scaffold
create scaffold with specified project name.
httprunner/utils.py
def create_scaffold(project_name): """ create scaffold with specified project name. """ if os.path.isdir(project_name): logger.log_warning(u"Folder {} exists, please specify a new folder name.".format(project_name)) return logger.color_print("Start to create new project: {}".format(proj...
def create_scaffold(project_name): """ create scaffold with specified project name. """ if os.path.isdir(project_name): logger.log_warning(u"Folder {} exists, please specify a new folder name.".format(project_name)) return logger.color_print("Start to create new project: {}".format(proj...
[ "create", "scaffold", "with", "specified", "project", "name", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L403-L437
[ "def", "create_scaffold", "(", "project_name", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "project_name", ")", ":", "logger", ".", "log_warning", "(", "u\"Folder {} exists, please specify a new folder name.\"", ".", "format", "(", "project_name", ")", "...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
gen_cartesian_product
generate cartesian product for lists Args: args (list of list): lists to be generated with cartesian product Returns: list: cartesian product in list Examples: >>> arg1 = [{"a": 1}, {"a": 2}] >>> arg2 = [{"x": 111, "y": 112}, {"x": 121, "y": 122}] >>> args = [arg1...
httprunner/utils.py
def gen_cartesian_product(*args): """ generate cartesian product for lists Args: args (list of list): lists to be generated with cartesian product Returns: list: cartesian product in list Examples: >>> arg1 = [{"a": 1}, {"a": 2}] >>> arg2 = [{"x": 111, "y": 112}, {"x"...
def gen_cartesian_product(*args): """ generate cartesian product for lists Args: args (list of list): lists to be generated with cartesian product Returns: list: cartesian product in list Examples: >>> arg1 = [{"a": 1}, {"a": 2}] >>> arg2 = [{"x": 111, "y": 112}, {"x"...
[ "generate", "cartesian", "product", "for", "lists" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L440-L478
[ "def", "gen_cartesian_product", "(", "*", "args", ")", ":", "if", "not", "args", ":", "return", "[", "]", "elif", "len", "(", "args", ")", "==", "1", ":", "return", "args", "[", "0", "]", "product_list", "=", "[", "]", "for", "product_item_tuple", "i...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
prettify_json_file
prettify JSON testcase format
httprunner/utils.py
def prettify_json_file(file_list): """ prettify JSON testcase format """ for json_file in set(file_list): if not json_file.endswith(".json"): logger.log_warning("Only JSON file format can be prettified, skip: {}".format(json_file)) continue logger.color_print("Start ...
def prettify_json_file(file_list): """ prettify JSON testcase format """ for json_file in set(file_list): if not json_file.endswith(".json"): logger.log_warning("Only JSON file format can be prettified, skip: {}".format(json_file)) continue logger.color_print("Start ...
[ "prettify", "JSON", "testcase", "format" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L481-L505
[ "def", "prettify_json_file", "(", "file_list", ")", ":", "for", "json_file", "in", "set", "(", "file_list", ")", ":", "if", "not", "json_file", ".", "endswith", "(", "\".json\"", ")", ":", "logger", ".", "log_warning", "(", "\"Only JSON file format can be pretti...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
omit_long_data
omit too long str/bytes
httprunner/utils.py
def omit_long_data(body, omit_len=512): """ omit too long str/bytes """ if not isinstance(body, basestring): return body body_len = len(body) if body_len <= omit_len: return body omitted_body = body[0:omit_len] appendix_str = " ... OMITTED {} CHARACTORS ...".format(body_le...
def omit_long_data(body, omit_len=512): """ omit too long str/bytes """ if not isinstance(body, basestring): return body body_len = len(body) if body_len <= omit_len: return body omitted_body = body[0:omit_len] appendix_str = " ... OMITTED {} CHARACTORS ...".format(body_le...
[ "omit", "too", "long", "str", "/", "bytes" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L508-L524
[ "def", "omit_long_data", "(", "body", ",", "omit_len", "=", "512", ")", ":", "if", "not", "isinstance", "(", "body", ",", "basestring", ")", ":", "return", "body", "body_len", "=", "len", "(", "body", ")", "if", "body_len", "<=", "omit_len", ":", "retu...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
dump_json_file
dump json data to file
httprunner/utils.py
def dump_json_file(json_data, pwd_dir_path, dump_file_name): """ dump json data to file """ class PythonObjectEncoder(json.JSONEncoder): def default(self, obj): try: return super().default(self, obj) except TypeError: return str(obj) logs_...
def dump_json_file(json_data, pwd_dir_path, dump_file_name): """ dump json data to file """ class PythonObjectEncoder(json.JSONEncoder): def default(self, obj): try: return super().default(self, obj) except TypeError: return str(obj) logs_...
[ "dump", "json", "data", "to", "file" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L527-L570
[ "def", "dump_json_file", "(", "json_data", ",", "pwd_dir_path", ",", "dump_file_name", ")", ":", "class", "PythonObjectEncoder", "(", "json", ".", "JSONEncoder", ")", ":", "def", "default", "(", "self", ",", "obj", ")", ":", "try", ":", "return", "super", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
_prepare_dump_info
prepare dump file info.
httprunner/utils.py
def _prepare_dump_info(project_mapping, tag_name): """ prepare dump file info. """ test_path = project_mapping.get("test_path") or "tests_mapping" pwd_dir_path = project_mapping.get("PWD") or os.getcwd() file_name, file_suffix = os.path.splitext(os.path.basename(test_path.rstrip("/"))) dump_file...
def _prepare_dump_info(project_mapping, tag_name): """ prepare dump file info. """ test_path = project_mapping.get("test_path") or "tests_mapping" pwd_dir_path = project_mapping.get("PWD") or os.getcwd() file_name, file_suffix = os.path.splitext(os.path.basename(test_path.rstrip("/"))) dump_file...
[ "prepare", "dump", "file", "info", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L573-L581
[ "def", "_prepare_dump_info", "(", "project_mapping", ",", "tag_name", ")", ":", "test_path", "=", "project_mapping", ".", "get", "(", "\"test_path\"", ")", "or", "\"tests_mapping\"", "pwd_dir_path", "=", "project_mapping", ".", "get", "(", "\"PWD\"", ")", "or", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
dump_logs
dump tests data to json file. the dumped file is located in PWD/logs folder. Args: json_data (list/dict): json data to dump project_mapping (dict): project info tag_name (str): tag name, loaded/parsed/summary
httprunner/utils.py
def dump_logs(json_data, project_mapping, tag_name): """ dump tests data to json file. the dumped file is located in PWD/logs folder. Args: json_data (list/dict): json data to dump project_mapping (dict): project info tag_name (str): tag name, loaded/parsed/summary """ ...
def dump_logs(json_data, project_mapping, tag_name): """ dump tests data to json file. the dumped file is located in PWD/logs folder. Args: json_data (list/dict): json data to dump project_mapping (dict): project info tag_name (str): tag name, loaded/parsed/summary """ ...
[ "dump", "tests", "data", "to", "json", "file", ".", "the", "dumped", "file", "is", "located", "in", "PWD", "/", "logs", "folder", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L584-L595
[ "def", "dump_logs", "(", "json_data", ",", "project_mapping", ",", "tag_name", ")", ":", "pwd_dir_path", ",", "dump_file_name", "=", "_prepare_dump_info", "(", "project_mapping", ",", "tag_name", ")", "dump_json_file", "(", "json_data", ",", "pwd_dir_path", ",", "...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
_check_format
check testcase format if valid
httprunner/loader.py
def _check_format(file_path, content): """ check testcase format if valid """ # TODO: replace with JSON schema validation if not content: # testcase file content is empty err_msg = u"Testcase file content is empty: {}".format(file_path) logger.log_error(err_msg) raise exc...
def _check_format(file_path, content): """ check testcase format if valid """ # TODO: replace with JSON schema validation if not content: # testcase file content is empty err_msg = u"Testcase file content is empty: {}".format(file_path) logger.log_error(err_msg) raise exc...
[ "check", "testcase", "format", "if", "valid" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/loader.py#L17-L31
[ "def", "_check_format", "(", "file_path", ",", "content", ")", ":", "# TODO: replace with JSON schema validation", "if", "not", "content", ":", "# testcase file content is empty", "err_msg", "=", "u\"Testcase file content is empty: {}\"", ".", "format", "(", "file_path", ")...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
load_yaml_file
load yaml file and check file content format
httprunner/loader.py
def load_yaml_file(yaml_file): """ load yaml file and check file content format """ with io.open(yaml_file, 'r', encoding='utf-8') as stream: yaml_content = yaml.load(stream) _check_format(yaml_file, yaml_content) return yaml_content
def load_yaml_file(yaml_file): """ load yaml file and check file content format """ with io.open(yaml_file, 'r', encoding='utf-8') as stream: yaml_content = yaml.load(stream) _check_format(yaml_file, yaml_content) return yaml_content
[ "load", "yaml", "file", "and", "check", "file", "content", "format" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/loader.py#L34-L40
[ "def", "load_yaml_file", "(", "yaml_file", ")", ":", "with", "io", ".", "open", "(", "yaml_file", ",", "'r'", ",", "encoding", "=", "'utf-8'", ")", "as", "stream", ":", "yaml_content", "=", "yaml", ".", "load", "(", "stream", ")", "_check_format", "(", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
load_json_file
load json file and check file content format
httprunner/loader.py
def load_json_file(json_file): """ load json file and check file content format """ with io.open(json_file, encoding='utf-8') as data_file: try: json_content = json.load(data_file) except exceptions.JSONDecodeError: err_msg = u"JSONDecodeError: JSON file format error:...
def load_json_file(json_file): """ load json file and check file content format """ with io.open(json_file, encoding='utf-8') as data_file: try: json_content = json.load(data_file) except exceptions.JSONDecodeError: err_msg = u"JSONDecodeError: JSON file format error:...
[ "load", "json", "file", "and", "check", "file", "content", "format" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/loader.py#L43-L55
[ "def", "load_json_file", "(", "json_file", ")", ":", "with", "io", ".", "open", "(", "json_file", ",", "encoding", "=", "'utf-8'", ")", "as", "data_file", ":", "try", ":", "json_content", "=", "json", ".", "load", "(", "data_file", ")", "except", "except...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
load_csv_file
load csv file and check file content format Args: csv_file (str): csv file path, csv file content is like below: Returns: list: list of parameters, each parameter is in dict format Examples: >>> cat csv_file username,password test1,111111 test2,222222 ...
httprunner/loader.py
def load_csv_file(csv_file): """ load csv file and check file content format Args: csv_file (str): csv file path, csv file content is like below: Returns: list: list of parameters, each parameter is in dict format Examples: >>> cat csv_file username,password te...
def load_csv_file(csv_file): """ load csv file and check file content format Args: csv_file (str): csv file path, csv file content is like below: Returns: list: list of parameters, each parameter is in dict format Examples: >>> cat csv_file username,password te...
[ "load", "csv", "file", "and", "check", "file", "content", "format" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/loader.py#L58-L98
[ "def", "load_csv_file", "(", "csv_file", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "csv_file", ")", ":", "project_working_directory", "=", "tests_def_mapping", "[", "\"PWD\"", "]", "or", "os", ".", "getcwd", "(", ")", "# make compatible wi...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
load_folder_files
load folder path, return all files endswith yml/yaml/json in list. Args: folder_path (str): specified folder path to load recursive (bool): load files recursively if True Returns: list: files endswith yml/yaml/json
httprunner/loader.py
def load_folder_files(folder_path, recursive=True): """ load folder path, return all files endswith yml/yaml/json in list. Args: folder_path (str): specified folder path to load recursive (bool): load files recursively if True Returns: list: files endswith yml/yaml/json """ ...
def load_folder_files(folder_path, recursive=True): """ load folder path, return all files endswith yml/yaml/json in list. Args: folder_path (str): specified folder path to load recursive (bool): load files recursively if True Returns: list: files endswith yml/yaml/json """ ...
[ "load", "folder", "path", "return", "all", "files", "endswith", "yml", "/", "yaml", "/", "json", "in", "list", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/loader.py#L119-L157
[ "def", "load_folder_files", "(", "folder_path", ",", "recursive", "=", "True", ")", ":", "if", "isinstance", "(", "folder_path", ",", "(", "list", ",", "set", ")", ")", ":", "files", "=", "[", "]", "for", "path", "in", "set", "(", "folder_path", ")", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
load_dot_env_file
load .env file. Args: dot_env_path (str): .env file path Returns: dict: environment variables mapping { "UserName": "debugtalk", "Password": "123456", "PROJECT_KEY": "ABCDEFGH" } Raises: exceptions.FileFormat...
httprunner/loader.py
def load_dot_env_file(dot_env_path): """ load .env file. Args: dot_env_path (str): .env file path Returns: dict: environment variables mapping { "UserName": "debugtalk", "Password": "123456", "PROJECT_KEY": "ABCDEFGH" ...
def load_dot_env_file(dot_env_path): """ load .env file. Args: dot_env_path (str): .env file path Returns: dict: environment variables mapping { "UserName": "debugtalk", "Password": "123456", "PROJECT_KEY": "ABCDEFGH" ...
[ "load", ".", "env", "file", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/loader.py#L160-L198
[ "def", "load_dot_env_file", "(", "dot_env_path", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "dot_env_path", ")", ":", "return", "{", "}", "logger", ".", "log_info", "(", "\"Loading environment variables from {}\"", ".", "format", "(", "dot_e...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
locate_file
locate filename and return absolute file path. searching will be recursive upward until current working directory. Args: start_path (str): start locating path, maybe file path or directory path Returns: str: located file path. None if file not found. Raises: exceptions.Fil...
httprunner/loader.py
def locate_file(start_path, file_name): """ locate filename and return absolute file path. searching will be recursive upward until current working directory. Args: start_path (str): start locating path, maybe file path or directory path Returns: str: located file path. None if fil...
def locate_file(start_path, file_name): """ locate filename and return absolute file path. searching will be recursive upward until current working directory. Args: start_path (str): start locating path, maybe file path or directory path Returns: str: located file path. None if fil...
[ "locate", "filename", "and", "return", "absolute", "file", "path", ".", "searching", "will", "be", "recursive", "upward", "until", "current", "working", "directory", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/loader.py#L201-L231
[ "def", "locate_file", "(", "start_path", ",", "file_name", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "start_path", ")", ":", "start_dir_path", "=", "os", ".", "path", ".", "dirname", "(", "start_path", ")", "elif", "os", ".", "path", ".", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
load_module_functions
load python module functions. Args: module: python module Returns: dict: functions mapping for specified python module { "func1_name": func1, "func2_name": func2 }
httprunner/loader.py
def load_module_functions(module): """ load python module functions. Args: module: python module Returns: dict: functions mapping for specified python module { "func1_name": func1, "func2_name": func2 } """ module_functions ...
def load_module_functions(module): """ load python module functions. Args: module: python module Returns: dict: functions mapping for specified python module { "func1_name": func1, "func2_name": func2 } """ module_functions ...
[ "load", "python", "module", "functions", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/loader.py#L238-L259
[ "def", "load_module_functions", "(", "module", ")", ":", "module_functions", "=", "{", "}", "for", "name", ",", "item", "in", "vars", "(", "module", ")", ".", "items", "(", ")", ":", "if", "validator", ".", "is_function", "(", "item", ")", ":", "module...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
__extend_with_api_ref
extend with api reference Raises: exceptions.ApiNotFound: api not found
httprunner/loader.py
def __extend_with_api_ref(raw_testinfo): """ extend with api reference Raises: exceptions.ApiNotFound: api not found """ api_name = raw_testinfo["api"] # api maybe defined in two types: # 1, individual file: each file is corresponding to one api definition # 2, api sets file: one ...
def __extend_with_api_ref(raw_testinfo): """ extend with api reference Raises: exceptions.ApiNotFound: api not found """ api_name = raw_testinfo["api"] # api maybe defined in two types: # 1, individual file: each file is corresponding to one api definition # 2, api sets file: one ...
[ "extend", "with", "api", "reference" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/loader.py#L297-L321
[ "def", "__extend_with_api_ref", "(", "raw_testinfo", ")", ":", "api_name", "=", "raw_testinfo", "[", "\"api\"", "]", "# api maybe defined in two types:", "# 1, individual file: each file is corresponding to one api definition", "# 2, api sets file: one file contains a list of api definit...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
load_folder_content
load api/testcases/testsuites definitions from folder. Args: folder_path (str): api/testcases/testsuites files folder. Returns: dict: api definition mapping. { "tests/api/basic.yml": [ {"api": {"def": "api_login", "request": {}, "validate": []}}...
httprunner/loader.py
def load_folder_content(folder_path): """ load api/testcases/testsuites definitions from folder. Args: folder_path (str): api/testcases/testsuites files folder. Returns: dict: api definition mapping. { "tests/api/basic.yml": [ {"api": {"def"...
def load_folder_content(folder_path): """ load api/testcases/testsuites definitions from folder. Args: folder_path (str): api/testcases/testsuites files folder. Returns: dict: api definition mapping. { "tests/api/basic.yml": [ {"api": {"def"...
[ "load", "api", "/", "testcases", "/", "testsuites", "definitions", "from", "folder", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/loader.py#L550-L572
[ "def", "load_folder_content", "(", "folder_path", ")", ":", "items_mapping", "=", "{", "}", "for", "file_path", "in", "load_folder_files", "(", "folder_path", ")", ":", "items_mapping", "[", "file_path", "]", "=", "load_file", "(", "file_path", ")", "return", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
load_api_folder
load api definitions from api folder. Args: api_folder_path (str): api files folder. api file should be in the following format: [ { "api": { "def": "api_login", "request": {}, ...
httprunner/loader.py
def load_api_folder(api_folder_path): """ load api definitions from api folder. Args: api_folder_path (str): api files folder. api file should be in the following format: [ { "api": { "def": "api_login", ...
def load_api_folder(api_folder_path): """ load api definitions from api folder. Args: api_folder_path (str): api files folder. api file should be in the following format: [ { "api": { "def": "api_login", ...
[ "load", "api", "definitions", "from", "api", "folder", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/loader.py#L575-L641
[ "def", "load_api_folder", "(", "api_folder_path", ")", ":", "api_definition_mapping", "=", "{", "}", "api_items_mapping", "=", "load_folder_content", "(", "api_folder_path", ")", "for", "api_file_path", ",", "api_items", "in", "api_items_mapping", ".", "items", "(", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
main_hrun
API test: parse command line options and run commands.
httprunner/cli.py
def main_hrun(): """ API test: parse command line options and run commands. """ import argparse from httprunner import logger from httprunner.__about__ import __description__, __version__ from httprunner.api import HttpRunner from httprunner.compat import is_py2 from httprunner.validator...
def main_hrun(): """ API test: parse command line options and run commands. """ import argparse from httprunner import logger from httprunner.__about__ import __description__, __version__ from httprunner.api import HttpRunner from httprunner.compat import is_py2 from httprunner.validator...
[ "API", "test", ":", "parse", "command", "line", "options", "and", "run", "commands", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/cli.py#L3-L88
[ "def", "main_hrun", "(", ")", ":", "import", "argparse", "from", "httprunner", "import", "logger", "from", "httprunner", ".", "__about__", "import", "__description__", ",", "__version__", "from", "httprunner", ".", "api", "import", "HttpRunner", "from", "httprunne...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
main_locust
Performance test with locust: parse command line options and run commands.
httprunner/cli.py
def main_locust(): """ Performance test with locust: parse command line options and run commands. """ # monkey patch ssl at beginning to avoid RecursionError when running locust. from gevent import monkey; monkey.patch_ssl() import multiprocessing import sys from httprunner import logger ...
def main_locust(): """ Performance test with locust: parse command line options and run commands. """ # monkey patch ssl at beginning to avoid RecursionError when running locust. from gevent import monkey; monkey.patch_ssl() import multiprocessing import sys from httprunner import logger ...
[ "Performance", "test", "with", "locust", ":", "parse", "command", "line", "options", "and", "run", "commands", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/cli.py#L91-L180
[ "def", "main_locust", "(", ")", ":", "# monkey patch ssl at beginning to avoid RecursionError when running locust.", "from", "gevent", "import", "monkey", "monkey", ".", "patch_ssl", "(", ")", "import", "multiprocessing", "import", "sys", "from", "httprunner", "import", "...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
is_var_or_func_exist
check if variable or function exist
httprunner/parser.py
def is_var_or_func_exist(content): """ check if variable or function exist """ if not isinstance(content, basestring): return False try: match_start_position = content.index("$", 0) except ValueError: return False while match_start_position < len(content): dolla...
def is_var_or_func_exist(content): """ check if variable or function exist """ if not isinstance(content, basestring): return False try: match_start_position = content.index("$", 0) except ValueError: return False while match_start_position < len(content): dolla...
[ "check", "if", "variable", "or", "function", "exist" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L34-L59
[ "def", "is_var_or_func_exist", "(", "content", ")", ":", "if", "not", "isinstance", "(", "content", ",", "basestring", ")", ":", "return", "False", "try", ":", "match_start_position", "=", "content", ".", "index", "(", "\"$\"", ",", "0", ")", "except", "Va...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
regex_findall_variables
extract all variable names from content, which is in format $variable Args: content (str): string content Returns: list: variables list extracted from string content Examples: >>> regex_findall_variables("$variable") ["variable"] >>> regex_findall_variables("/blog...
httprunner/parser.py
def regex_findall_variables(content): """ extract all variable names from content, which is in format $variable Args: content (str): string content Returns: list: variables list extracted from string content Examples: >>> regex_findall_variables("$variable") ["variable...
def regex_findall_variables(content): """ extract all variable names from content, which is in format $variable Args: content (str): string content Returns: list: variables list extracted from string content Examples: >>> regex_findall_variables("$variable") ["variable...
[ "extract", "all", "variable", "names", "from", "content", "which", "is", "in", "format", "$variable" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L62-L93
[ "def", "regex_findall_variables", "(", "content", ")", ":", "try", ":", "vars_list", "=", "[", "]", "for", "var_tuple", "in", "variable_regex_compile", ".", "findall", "(", "content", ")", ":", "vars_list", ".", "append", "(", "var_tuple", "[", "0", "]", "...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
parse_parameters
parse parameters and generate cartesian product. Args: parameters (list) parameters: parameter name and value in list parameter value may be in three types: (1) data list, e.g. ["iOS/10.1", "iOS/10.2", "iOS/10.3"] (2) call built-in parameterize function, "${param...
httprunner/parser.py
def parse_parameters(parameters, variables_mapping=None, functions_mapping=None): """ parse parameters and generate cartesian product. Args: parameters (list) parameters: parameter name and value in list parameter value may be in three types: (1) data list, e.g. ["iOS/10.1",...
def parse_parameters(parameters, variables_mapping=None, functions_mapping=None): """ parse parameters and generate cartesian product. Args: parameters (list) parameters: parameter name and value in list parameter value may be in three types: (1) data list, e.g. ["iOS/10.1",...
[ "parse", "parameters", "and", "generate", "cartesian", "product", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L128-L218
[ "def", "parse_parameters", "(", "parameters", ",", "variables_mapping", "=", "None", ",", "functions_mapping", "=", "None", ")", ":", "variables_mapping", "=", "variables_mapping", "or", "{", "}", "functions_mapping", "=", "functions_mapping", "or", "{", "}", "par...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
get_mapping_variable
get variable from variables_mapping. Args: variable_name (str): variable name variables_mapping (dict): variables mapping Returns: mapping variable value. Raises: exceptions.VariableNotFound: variable is not found.
httprunner/parser.py
def get_mapping_variable(variable_name, variables_mapping): """ get variable from variables_mapping. Args: variable_name (str): variable name variables_mapping (dict): variables mapping Returns: mapping variable value. Raises: exceptions.VariableNotFound: variable is n...
def get_mapping_variable(variable_name, variables_mapping): """ get variable from variables_mapping. Args: variable_name (str): variable name variables_mapping (dict): variables mapping Returns: mapping variable value. Raises: exceptions.VariableNotFound: variable is n...
[ "get", "variable", "from", "variables_mapping", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L225-L242
[ "def", "get_mapping_variable", "(", "variable_name", ",", "variables_mapping", ")", ":", "try", ":", "return", "variables_mapping", "[", "variable_name", "]", "except", "KeyError", ":", "raise", "exceptions", ".", "VariableNotFound", "(", "\"{} is not found.\"", ".", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
get_mapping_function
get function from functions_mapping, if not found, then try to check if builtin function. Args: variable_name (str): variable name variables_mapping (dict): variables mapping Returns: mapping function object. Raises: exceptions.FunctionNotFound: function is neither...
httprunner/parser.py
def get_mapping_function(function_name, functions_mapping): """ get function from functions_mapping, if not found, then try to check if builtin function. Args: variable_name (str): variable name variables_mapping (dict): variables mapping Returns: mapping function object. ...
def get_mapping_function(function_name, functions_mapping): """ get function from functions_mapping, if not found, then try to check if builtin function. Args: variable_name (str): variable name variables_mapping (dict): variables mapping Returns: mapping function object. ...
[ "get", "function", "from", "functions_mapping", "if", "not", "found", "then", "try", "to", "check", "if", "builtin", "function", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L245-L286
[ "def", "get_mapping_function", "(", "function_name", ",", "functions_mapping", ")", ":", "if", "function_name", "in", "functions_mapping", ":", "return", "functions_mapping", "[", "function_name", "]", "elif", "function_name", "in", "[", "\"parameterize\"", ",", "\"P\...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
parse_function_params
parse function params to args and kwargs. Args: params (str): function param in string Returns: dict: function meta dict { "args": [], "kwargs": {} } Examples: >>> parse_function_params("") {'args': [], 'kwargs': {}}...
httprunner/parser.py
def parse_function_params(params): """ parse function params to args and kwargs. Args: params (str): function param in string Returns: dict: function meta dict { "args": [], "kwargs": {} } Examples: >>> parse_function_pa...
def parse_function_params(params): """ parse function params to args and kwargs. Args: params (str): function param in string Returns: dict: function meta dict { "args": [], "kwargs": {} } Examples: >>> parse_function_pa...
[ "parse", "function", "params", "to", "args", "and", "kwargs", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L289-L338
[ "def", "parse_function_params", "(", "params", ")", ":", "function_meta", "=", "{", "\"args\"", ":", "[", "]", ",", "\"kwargs\"", ":", "{", "}", "}", "params_str", "=", "params", ".", "strip", "(", ")", "if", "params_str", "==", "\"\"", ":", "return", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
prepare_lazy_data
make string in content as lazy object with functions_mapping Raises: exceptions.VariableNotFound: if any variable undefined in check_variables_set
httprunner/parser.py
def prepare_lazy_data(content, functions_mapping=None, check_variables_set=None, cached=False): """ make string in content as lazy object with functions_mapping Raises: exceptions.VariableNotFound: if any variable undefined in check_variables_set """ # TODO: refactor type check if content ...
def prepare_lazy_data(content, functions_mapping=None, check_variables_set=None, cached=False): """ make string in content as lazy object with functions_mapping Raises: exceptions.VariableNotFound: if any variable undefined in check_variables_set """ # TODO: refactor type check if content ...
[ "make", "string", "in", "content", "as", "lazy", "object", "with", "functions_mapping" ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L556-L610
[ "def", "prepare_lazy_data", "(", "content", ",", "functions_mapping", "=", "None", ",", "check_variables_set", "=", "None", ",", "cached", "=", "False", ")", ":", "# TODO: refactor type check", "if", "content", "is", "None", "or", "isinstance", "(", "content", "...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
parse_lazy_data
parse lazy data with evaluated variables mapping. Notice: variables_mapping should not contain any variable or function.
httprunner/parser.py
def parse_lazy_data(content, variables_mapping=None): """ parse lazy data with evaluated variables mapping. Notice: variables_mapping should not contain any variable or function. """ # TODO: refactor type check if content is None or isinstance(content, (numeric_types, bool, type)): retur...
def parse_lazy_data(content, variables_mapping=None): """ parse lazy data with evaluated variables mapping. Notice: variables_mapping should not contain any variable or function. """ # TODO: refactor type check if content is None or isinstance(content, (numeric_types, bool, type)): retur...
[ "parse", "lazy", "data", "with", "evaluated", "variables", "mapping", ".", "Notice", ":", "variables_mapping", "should", "not", "contain", "any", "variable", "or", "function", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L613-L640
[ "def", "parse_lazy_data", "(", "content", ",", "variables_mapping", "=", "None", ")", ":", "# TODO: refactor type check", "if", "content", "is", "None", "or", "isinstance", "(", "content", ",", "(", "numeric_types", ",", "bool", ",", "type", ")", ")", ":", "...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
eval_lazy_data
evaluate data instantly. Notice: variables_mapping should not contain any variable or function.
httprunner/parser.py
def eval_lazy_data(content, variables_mapping=None, functions_mapping=None): """ evaluate data instantly. Notice: variables_mapping should not contain any variable or function. """ variables_mapping = variables_mapping or {} check_variables_set = set(variables_mapping.keys()) return parse_la...
def eval_lazy_data(content, variables_mapping=None, functions_mapping=None): """ evaluate data instantly. Notice: variables_mapping should not contain any variable or function. """ variables_mapping = variables_mapping or {} check_variables_set = set(variables_mapping.keys()) return parse_la...
[ "evaluate", "data", "instantly", ".", "Notice", ":", "variables_mapping", "should", "not", "contain", "any", "variable", "or", "function", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L643-L656
[ "def", "eval_lazy_data", "(", "content", ",", "variables_mapping", "=", "None", ",", "functions_mapping", "=", "None", ")", ":", "variables_mapping", "=", "variables_mapping", "or", "{", "}", "check_variables_set", "=", "set", "(", "variables_mapping", ".", "keys"...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
extract_variables
extract all variables in content recursively.
httprunner/parser.py
def extract_variables(content): """ extract all variables in content recursively. """ if isinstance(content, (list, set, tuple)): variables = set() for item in content: variables = variables | extract_variables(item) return variables elif isinstance(content, dict): ...
def extract_variables(content): """ extract all variables in content recursively. """ if isinstance(content, (list, set, tuple)): variables = set() for item in content: variables = variables | extract_variables(item) return variables elif isinstance(content, dict): ...
[ "extract", "all", "variables", "in", "content", "recursively", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L659-L677
[ "def", "extract_variables", "(", "content", ")", ":", "if", "isinstance", "(", "content", ",", "(", "list", ",", "set", ",", "tuple", ")", ")", ":", "variables", "=", "set", "(", ")", "for", "item", "in", "content", ":", "variables", "=", "variables", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
parse_variables_mapping
eval each prepared variable and function in variables_mapping. Args: variables_mapping (dict): { "varA": LazyString(123$varB), "varB": LazyString(456$varC), "varC": LazyString(${sum_two($a, $b)}), "a": 1, "b": 2, ...
httprunner/parser.py
def parse_variables_mapping(variables_mapping, ignore=False): """ eval each prepared variable and function in variables_mapping. Args: variables_mapping (dict): { "varA": LazyString(123$varB), "varB": LazyString(456$varC), "varC": LazyString($...
def parse_variables_mapping(variables_mapping, ignore=False): """ eval each prepared variable and function in variables_mapping. Args: variables_mapping (dict): { "varA": LazyString(123$varB), "varB": LazyString(456$varC), "varC": LazyString($...
[ "eval", "each", "prepared", "variable", "and", "function", "in", "variables_mapping", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L680-L754
[ "def", "parse_variables_mapping", "(", "variables_mapping", ",", "ignore", "=", "False", ")", ":", "run_times", "=", "0", "parsed_variables_mapping", "=", "{", "}", "while", "len", "(", "parsed_variables_mapping", ")", "!=", "len", "(", "variables_mapping", ")", ...
f259551bf9c8ba905eae5c1afcf2efea20ae0871
train
_extend_with_api
extend test with api definition, test will merge and override api definition. Args: test_dict (dict): test block, this will override api_def_dict api_def_dict (dict): api definition Examples: >>> api_def_dict = { "name": "get token 1", "request": {...}, ...
httprunner/parser.py
def _extend_with_api(test_dict, api_def_dict): """ extend test with api definition, test will merge and override api definition. Args: test_dict (dict): test block, this will override api_def_dict api_def_dict (dict): api definition Examples: >>> api_def_dict = { "n...
def _extend_with_api(test_dict, api_def_dict): """ extend test with api definition, test will merge and override api definition. Args: test_dict (dict): test block, this will override api_def_dict api_def_dict (dict): api definition Examples: >>> api_def_dict = { "n...
[ "extend", "test", "with", "api", "definition", "test", "will", "merge", "and", "override", "api", "definition", "." ]
HttpRunner/HttpRunner
python
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/parser.py#L757-L838
[ "def", "_extend_with_api", "(", "test_dict", ",", "api_def_dict", ")", ":", "# override api name", "test_dict", ".", "setdefault", "(", "\"name\"", ",", "api_def_dict", ".", "pop", "(", "\"name\"", ",", "\"api name undefined\"", ")", ")", "# override variables", "de...
f259551bf9c8ba905eae5c1afcf2efea20ae0871