Datasets:

function_name
stringlengths
1
63
docstring
stringlengths
50
5.89k
masked_code
stringlengths
50
882k
implementation
stringlengths
169
12.9k
start_line
int32
1
14.6k
end_line
int32
16
14.6k
file_content
stringlengths
274
882k
derivativeY
Evaluates the partial derivative with respect to y (the third argument) of the interpolated function at the given input. Parameters ---------- w : np.array or float Real values to be evaluated in the interpolated function. x : np.array or float Real values to be evaluated in the interpolated function; must be ...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def derivativeY(self,w,x,y,z): ''' Evaluates the partial derivative with respect to y (the third argument) of the interpolated function at the given input. Parameters ---------- w : np.array or float Real values to be evaluated in the interpolated functio...
445
474
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
derivativeZ
Evaluates the partial derivative with respect to z (the fourth argument) of the interpolated function at the given input. Parameters ---------- w : np.array or float Real values to be evaluated in the interpolated function. x : np.array or float Real values to be evaluated in the interpolated function; must be...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def derivativeZ(self,w,x,y,z): ''' Evaluates the partial derivative with respect to z (the fourth argument) of the interpolated function at the given input. Parameters ---------- w : np.array or float Real values to be evaluated in the interpolated functi...
476
505
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__init__
The interpolation constructor to make a new linear spline interpolation. Parameters ---------- x_list : np.array List of x values composing the grid. y_list : np.array List of y values, representing f(x) at the points in x_list. intercept_limit : float Intercept of limiting linear function. slope_limit : f...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __init__(self,x_list,y_list,intercept_limit=None,slope_limit=None,lower_extrap=False): ''' The interpolation constructor to make a new linear spline interpolation. Parameters ---------- x_list : np.array List of x values composing the grid. y_list : n...
706
749
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_evaluate
Returns the level of the interpolated function at each value in x. Only called internally by HARKinterpolator1D.__call__ (etc).
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _evaluate(self,x): ''' Returns the level of the interpolated function at each value in x. Only called internally by HARKinterpolator1D.__call__ (etc). ''' if _isscalar(x): pos = np.searchsorted(self.x_list,x) if pos == 0: y = self....
912
946
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_der
Returns the first derivative of the interpolated function at each value in x. Only called internally by HARKinterpolator1D.derivative (etc).
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _der(self,x): ''' Returns the first derivative of the interpolated function at each value in x. Only called internally by HARKinterpolator1D.derivative (etc). ''' if _isscalar(x): pos = np.searchsorted(self.x_list,x) if pos == 0: dy...
948
982
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_evalAndDer
Returns the level and first derivative of the function at each value in x. Only called internally by HARKinterpolator1D.eval_and_der (etc).
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _evalAndDer(self,x): ''' Returns the level and first derivative of the function at each value in x. Only called internally by HARKinterpolator1D.eval_and_der (etc). ''' if _isscalar(x): pos = np.searchsorted(self.x_list,x) if pos == 0: ...
985
1,026
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__init__
Constructor to make a new bilinear interpolation. Parameters ---------- f_values : numpy.array An array of size (x_n,y_n) such that f_values[i,j] = f(x_list[i],y_list[j]) x_list : numpy.array An array of x values, with length designated x_n. y_list : numpy.array An array of y values, with length designated...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __init__(self,f_values,x_list,y_list,xSearchFunc=None,ySearchFunc=None): ''' Constructor to make a new bilinear interpolation. Parameters ---------- f_values : numpy.array An array of size (x_n,y_n) such that f_values[i,j] = f(x_list[i],y_list[j]) x_l...
1,036
1,069
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_evaluate
Returns the level of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.__call__ (etc).
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _evaluate(self,x,y): ''' Returns the level of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.__call__ (etc). ''' if _isscalar(x): x_pos = max(min(self.xSearchFunc(self.x_list,x),self.x_n-1),1) y_pos = m...
1,071
1,093
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derX
Returns the derivative with respect to x of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.derivativeX.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derX(self,x,y): ''' Returns the derivative with respect to x of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.derivativeX. ''' if _isscalar(x): x_pos = max(min(self.xSearchFunc(self.x_list,x),self.x_n-1),1) ...
1,095
1,116
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derY
Returns the derivative with respect to y of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.derivativeY.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derY(self,x,y): ''' Returns the derivative with respect to y of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.derivativeY. ''' if _isscalar(x): x_pos = max(min(self.xSearchFunc(self.x_list,x),self.x_n-1),1) ...
1,118
1,139
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__init__
Constructor to make a new trilinear interpolation. Parameters ---------- f_values : numpy.array An array of size (x_n,y_n,z_n) such that f_values[i,j,k] = f(x_list[i],y_list[j],z_list[k]) x_list : numpy.array An array of x values, with length designated x_n. y_list : numpy.array An array of y values, w...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __init__(self,f_values,x_list,y_list,z_list,xSearchFunc=None,ySearchFunc=None,zSearchFunc=None): ''' Constructor to make a new trilinear interpolation. Parameters ---------- f_values : numpy.array An array of size (x_n,y_n,z_n) such that f_values[i,j,k] = ...
1,148
1,192
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_evaluate
Returns the level of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.__call__ (etc).
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _evaluate(self,x,y,z): ''' Returns the level of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.__call__ (etc). ''' if _isscalar(x): x_pos = max(min(self.xSearchFunc(self.x_list,x),self.x_n-1),1) y_pos...
1,194
1,225
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derX
Returns the derivative with respect to x of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeX.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derX(self,x,y,z): ''' Returns the derivative with respect to x of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeX. ''' if _isscalar(x): x_pos = max(min(self.xSearchFunc(self.x_list,x),self.x_n-1),1) ...
1,227
1,257
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derY
Returns the derivative with respect to y of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeY.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derY(self,x,y,z): ''' Returns the derivative with respect to y of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeY. ''' if _isscalar(x): x_pos = max(min(self.xSearchFunc(self.x_list,x),self.x_n-1),1) ...
1,259
1,289
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derZ
Returns the derivative with respect to z of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeZ.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derZ(self,x,y,z): ''' Returns the derivative with respect to z of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeZ. ''' if _isscalar(x): x_pos = max(min(self.xSearchFunc(self.x_list,x),self.x_n-1),1) ...
1,291
1,321
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__init__
Constructor to make a new quadlinear interpolation. Parameters ---------- f_values : numpy.array An array of size (w_n,x_n,y_n,z_n) such that f_values[i,j,k,l] = f(w_list[i],x_list[j],y_list[k],z_list[l]) w_list : numpy.array An array of x values, with length designated w_n. x_list : numpy.array An arr...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __init__(self,f_values,w_list,x_list,y_list,z_list,wSearchFunc=None,xSearchFunc=None,ySearchFunc=None,zSearchFunc=None): ''' Constructor to make a new quadlinear interpolation. Parameters ---------- f_values : numpy.array An array of size (w_n,x_n,y_n,z_n) su...
1,330
1,384
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_evalAndDer
Returns the level and first derivative of the function at each value in x. Only called internally by HARKinterpolator1D.eval_and_der.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _evalAndDer(self,x): ''' Returns the level and first derivative of the function at each value in x. Only called internally by HARKinterpolator1D.eval_and_der. ''' m = len(x) fx = np.zeros((m,self.funcCount)) for j in range(self.funcCount): fx[...
1,686
1,702
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_evalAndDer
Returns the level and first derivative of the function at each value in x. Only called internally by HARKinterpolator1D.eval_and_der.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _evalAndDer(self,x): ''' Returns the level and first derivative of the function at each value in x. Only called internally by HARKinterpolator1D.eval_and_der. ''' m = len(x) fx = np.zeros((m,self.funcCount)) for j in range(self.funcCount): fx[...
1,754
1,770
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__call__
Evaluate the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same shape as x. Returns ------- f_out : np.array Function evaluated at (x,y), of same shape as inputs.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __call__(self,x,y): ''' Evaluate the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same shape as x. Returns ------- f_...
1,975
1,993
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
derivativeX
Evaluate the first derivative with respect to x of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same shape as x. Returns ------- dfdx_out : np.array First derivative of function with respect to the first i...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def derivativeX(self,x,y): ''' Evaluate the first derivative with respect to x of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same sh...
1,995
2,015
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
derivativeY
Evaluate the first derivative with respect to y of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same shape as x. Returns ------- dfdy_out : np.array First derivative of function with respect to the second ...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def derivativeY(self,x,y): ''' Evaluate the first derivative with respect to y of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same sh...
2,017
2,037
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__call__
Evaluate the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same shape as x. z : np.array Third input values; should be of same shape as x. Returns ------- f_out : np.array Function evaluated at (x,y,z), of...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __call__(self,x,y,z): ''' Evaluate the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same shape as x. z : np.array Third i...
2,068
2,088
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
derivativeX
Evaluate the first derivative with respect to x of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same shape as x. z : np.array Third input values; should be of same shape as x. Returns ------- dfdx_out : n...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def derivativeX(self,x,y,z): ''' Evaluate the first derivative with respect to x of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same ...
2,090
2,112
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
derivativeY
Evaluate the first derivative with respect to y of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same shape as x. z : np.array Third input values; should be of same shape as x. Returns ------- dfdy_out : n...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def derivativeY(self,x,y,z): ''' Evaluate the first derivative with respect to y of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same ...
2,114
2,137
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
derivativeZ
Evaluate the first derivative with respect to z of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same shape as x. z : np.array Third input values; should be of same shape as x. Returns ------- dfdz_out : n...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def derivativeZ(self,x,y,z): ''' Evaluate the first derivative with respect to z of the function at given state space points. Parameters ---------- x : np.array First input values. y : np.array Second input values; should be of same ...
2,139
2,161
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__init__
Constructor for the class, generating an approximation to a function of the form f(x,y) using interpolations over f(x,y_0) for a fixed grid of y_0 values. Parameters ---------- xInterpolators : [HARKinterpolator1D] A list of 1D interpolations over the x variable. The nth element of xInterpolators represents f...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __init__(self,xInterpolators,y_values): ''' Constructor for the class, generating an approximation to a function of the form f(x,y) using interpolations over f(x,y_0) for a fixed grid of y_0 values. Parameters ---------- xInterpolators : [HARKinterpolator...
2,169
2,189
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_evaluate
Returns the level of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.__call__ (etc).
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _evaluate(self,x,y): ''' Returns the level of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.__call__ (etc). ''' if _isscalar(x): y_pos = max(min(np.searchsorted(self.y_list,y),self.y_n-1),1) alpha = (y...
2,191
2,212
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derX
Returns the derivative with respect to x of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.derivativeX.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derX(self,x,y): ''' Returns the derivative with respect to x of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.derivativeX. ''' if _isscalar(x): y_pos = max(min(np.searchsorted(self.y_list,y),self.y_n-1),1) ...
2,214
2,235
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derY
Returns the derivative with respect to y of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.derivativeY.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derY(self,x,y): ''' Returns the derivative with respect to y of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.derivativeY. ''' if _isscalar(x): y_pos = max(min(np.searchsorted(self.y_list,y),self.y_n-1),1) ...
2,237
2,256
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__init__
Constructor for the class, generating an approximation to a function of the form f(x,y,z) using interpolations over f(x,y_0,z_0) for a fixed grid of y_0 and z_0 values. Parameters ---------- xInterpolators : [[HARKinterpolator1D]] A list of lists of 1D interpolations over the x variable. The i,j-th element of...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __init__(self,xInterpolators,y_values,z_values): ''' Constructor for the class, generating an approximation to a function of the form f(x,y,z) using interpolations over f(x,y_0,z_0) for a fixed grid of y_0 and z_0 values. Parameters ---------- xInterpolat...
2,266
2,290
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_evaluate
Returns the level of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.__call__ (etc).
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _evaluate(self,x,y,z): ''' Returns the level of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.__call__ (etc). ''' if _isscalar(x): y_pos = max(min(np.searchsorted(self.y_list,y),self.y_n-1),1) z_pos ...
2,292
2,326
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derX
Returns the derivative with respect to x of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeX.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derX(self,x,y,z): ''' Returns the derivative with respect to x of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeX. ''' if _isscalar(x): y_pos = max(min(np.searchsorted(self.y_list,y),self.y_n-1),1) ...
2,328
2,362
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derY
Returns the derivative with respect to y of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeY.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derY(self,x,y,z): ''' Returns the derivative with respect to y of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeY. ''' if _isscalar(x): y_pos = max(min(np.searchsorted(self.y_list,y),self.y_n-1),1) ...
2,364
2,391
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derZ
Returns the derivative with respect to z of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeZ.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derZ(self,x,y,z): ''' Returns the derivative with respect to z of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeZ. ''' if _isscalar(x): y_pos = max(min(np.searchsorted(self.y_list,y),self.y_n-1),1) ...
2,393
2,420
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__init__
Constructor for the class, generating an approximation to a function of the form f(w,x,y,z) using interpolations over f(w,x_0,y_0,z_0) for a fixed grid of y_0 and z_0 values. Parameters ---------- wInterpolators : [[[HARKinterpolator1D]]] A list of lists of lists of 1D interpolations over the x variable. The i...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __init__(self,wInterpolators,x_values,y_values,z_values): ''' Constructor for the class, generating an approximation to a function of the form f(w,x,y,z) using interpolations over f(w,x_0,y_0,z_0) for a fixed grid of y_0 and z_0 values. Parameters ---------- ...
2,430
2,458
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__init__
Constructor for the class, generating an approximation to a function of the form f(x,y,z) using interpolations over f(x,y,z_0) for a fixed grid of z_0 values. Parameters ---------- xyInterpolators : [HARKinterpolator2D] A list of 2D interpolations over the x and y variables. The nth element of xyInterpolators...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __init__(self,xyInterpolators,z_values): ''' Constructor for the class, generating an approximation to a function of the form f(x,y,z) using interpolations over f(x,y,z_0) for a fixed grid of z_0 values. Parameters ---------- xyInterpolators : [HARKinterp...
2,720
2,740
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_evaluate
Returns the level of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.__call__ (etc).
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _evaluate(self,x,y,z): ''' Returns the level of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.__call__ (etc). ''' if _isscalar(x): z_pos = max(min(np.searchsorted(self.z_list,z),self.z_n-1),1) alpha ...
2,742
2,763
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derX
Returns the derivative with respect to x of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeX.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derX(self,x,y,z): ''' Returns the derivative with respect to x of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeX. ''' if _isscalar(x): z_pos = max(min(np.searchsorted(self.z_list,z),self.z_n-1),1) ...
2,765
2,786
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derY
Returns the derivative with respect to y of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeY.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derY(self,x,y,z): ''' Returns the derivative with respect to y of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeY. ''' if _isscalar(x): z_pos = max(min(np.searchsorted(self.z_list,z),self.z_n-1),1) ...
2,788
2,809
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derZ
Returns the derivative with respect to z of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeZ.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derZ(self,x,y,z): ''' Returns the derivative with respect to z of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator3D.derivativeZ. ''' if _isscalar(x): z_pos = max(min(np.searchsorted(self.z_list,z),self.z_n-1),1) ...
2,811
2,830
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__init__
Constructor for the class, generating an approximation to a function of the form f(w,x,y,z) using interpolations over f(w,x,y_0,z_0) for a fixed grid of y_0 and z_0 values. Parameters ---------- wxInterpolators : [[HARKinterpolator2D]] A list of lists of 2D interpolations over the w and x variables. The i,j-th...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __init__(self,wxInterpolators,y_values,z_values): ''' Constructor for the class, generating an approximation to a function of the form f(w,x,y,z) using interpolations over f(w,x,y_0,z_0) for a fixed grid of y_0 and z_0 values. Parameters ---------- wxInte...
2,842
2,867
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_evaluate
Returns the level of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator4D.__call__ (etc).
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _evaluate(self,w,x,y,z): ''' Returns the level of the interpolated function at each value in x,y,z. Only called internally by HARKinterpolator4D.__call__ (etc). ''' if _isscalar(x): y_pos = max(min(np.searchsorted(self.y_list,y),self.y_n-1),1) z_po...
2,869
2,903
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derW
Returns the derivative with respect to w of the interpolated function at each value in w,x,y,z. Only called internally by HARKinterpolator4D.derivativeW.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derW(self,w,x,y,z): ''' Returns the derivative with respect to w of the interpolated function at each value in w,x,y,z. Only called internally by HARKinterpolator4D.derivativeW. ''' # This may look strange, as we call the derivativeX() method to get the # derivat...
2,905
2,943
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derX
Returns the derivative with respect to x of the interpolated function at each value in w,x,y,z. Only called internally by HARKinterpolator4D.derivativeX.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derX(self,w,x,y,z): ''' Returns the derivative with respect to x of the interpolated function at each value in w,x,y,z. Only called internally by HARKinterpolator4D.derivativeX. ''' # This may look strange, as we call the derivativeY() method to get the # derivat...
2,945
2,983
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derY
Returns the derivative with respect to y of the interpolated function at each value in w,x,y,z. Only called internally by HARKinterpolator4D.derivativeY.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derY(self,w,x,y,z): ''' Returns the derivative with respect to y of the interpolated function at each value in w,x,y,z. Only called internally by HARKinterpolator4D.derivativeY. ''' if _isscalar(x): y_pos = max(min(np.searchsorted(self.y_list,y),self.y_n-1),1...
2,985
3,012
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_derZ
Returns the derivative with respect to z of the interpolated function at each value in w,x,y,z. Only called internally by HARKinterpolator4D.derivativeZ.
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _derZ(self,w,x,y,z): ''' Returns the derivative with respect to z of the interpolated function at each value in w,x,y,z. Only called internally by HARKinterpolator4D.derivativeZ. ''' if _isscalar(x): y_pos = max(min(np.searchsorted(self.y_list,y),self.y_n-1),1...
3,014
3,041
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
__init__
Constructor for 2D curvilinear interpolation for a function f(x,y) Parameters ---------- f_values: numpy.array A 2D array of function values such that f_values[i,j] = f(x_values[i,j],y_values[i,j]). x_values: numpy.array A 2D array of x values of the same size as f_values. y_values: numpy.array A 2D ar...
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def __init__(self,f_values,x_values,y_values): ''' Constructor for 2D curvilinear interpolation for a function f(x,y) Parameters ---------- f_values: numpy.array A 2D array of function values such that f_values[i,j] = f(x_values[i,j],y_values[i,j]). ...
3,052
3,076
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
updatePolarity
Fills in the polarity attribute of the interpolation, determining whether the "plus" (True) or "minus" (False) solution of the system of equations should be used for each sector. Needs to be called in __init__. Parameters ---------- none Returns ------- none
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def updatePolarity(self): ''' Fills in the polarity attribute of the interpolation, determining whether the "plus" (True) or "minus" (False) solution of the system of equations should be used for each sector. Needs to be called in __init__. Parameters ---------- ...
3,078
3,111
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
_evaluate
Returns the level of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.__call__ (etc).
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
def _evaluate(self,x,y): ''' Returns the level of the interpolated function at each value in x,y. Only called internally by HARKinterpolator2D.__call__ (etc). ''' x_pos, y_pos = self.findSector(x,y) alpha, beta = self.findCoords(x,y,x_pos,y_pos) # Calculate t...
3,268
3,282
''' Custom interpolation methods for representing approximations to functions. It also includes wrapper classes to enforce standard methods across classes. Each interpolation class must have a distance() method that compares itself to another instance; this is used in HARK.core's solve() method to check for solution co...
print_metrics
Prints or appends the given metrics in a csv. The resulting dataframe is of the form: client_id, round_number, hierarchy, num_samples, metric1, metric2 twebbstack, 0, , 18, 0.5, 0.89 Args: round_number: Number of the round the metrics correspond to. If 0, then the file in path is overwritten. If n...
"""Writes the given metrics in a csv.""" import numpy as np import os import pandas as pd import sys models_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(models_dir) from baseline_constants import CLIENT_ID_KEY, NUM_ROUND_KEY, NUM_SAMPLES_KEY COLUMN_NAMES = [ CLIENT_ID_KEY, ...
def print_metrics( round_number, client_ids, metrics, hierarchies, num_samples, path): """Prints or appends the given metrics in a csv. The resulting dataframe is of the form: client_id, round_number, hierarchy, num_samples, metric1, metric2 twebb...
18
61
"""Writes the given metrics in a csv.""" import numpy as np import os import pandas as pd import sys models_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(models_dir) from baseline_constants import CLIENT_ID_KEY, NUM_ROUND_KEY, NUM_SAMPLES_KEY COLUMN_NAMES = [ CLIENT_ID_KEY, ...
models
Module depends on the API version: * 2017-03-01: :mod:`v2017_03_01.models<azure.mgmt.containerregistry.v2017_03_01.models>` * 2017-10-01: :mod:`v2017_10_01.models<azure.mgmt.containerregistry.v2017_10_01.models>` * 2018-02-01-preview: :mod:`v2018_02_01_preview.models<azure.mgmt.containerregistry.v2018_02_01_preview.mo...
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes ...
@classmethod def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2017-03-01: :mod:`v2017_03_01.models<azure.mgmt.containerregistry.v2017_03_01.models>` * 2017-10-01: :mod:`v2017_10_01.models<azure.mgmt.containerregistry.v2017_10_01.models>` ...
93
146
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes ...
set_axes_equal
Set 3D plot axes to equal scale. Make axes of 3D plot have equal scale so that spheres appear as spheres and cubes as cubes. Required since `ax.axis('equal')` and `ax.set_aspect('equal')` don't work on 3D.
import os import json import numpy as np import itertools import matplotlib.pyplot as plt from mpl_toolkits.mplot3d.art3d import Line3DCollection from mpl_toolkits import mplot3d def liver_dump_init(env, name = None): liver = {'x':[],'Fes':[],'Fis':[],'Ficp':[],'volume':[],'col_p_n':[],'crash':[]} liver['vtx'...
def set_axes_equal(ax: plt.Axes,limits = None): """Set 3D plot axes to equal scale. Make axes of 3D plot have equal scale so that spheres appear as spheres and cubes as cubes. Required since `ax.axis('equal')` and `ax.set_aspect('equal')` don't work on 3D. """ if limits...
379
394
import os import json import numpy as np import itertools import matplotlib.pyplot as plt from mpl_toolkits.mplot3d.art3d import Line3DCollection from mpl_toolkits import mplot3d def liver_dump_init(env, name = None): liver = {'x':[],'Fes':[],'Fis':[],'Ficp':[],'volume':[],'col_p_n':[],'crash':[]} l...
ee_table_to_legend
Converts an Earth Engine color table to a dictionary Args: in_table (str): The input file path (*.txt) to the Earth Engine color table. out_file (str): The output file path (*.txt) to the legend dictionary.
"""Module of sample legends for some commonly used geospatial datasets. """ import os import pkg_resources # Land Cover datasets in Earth Engine https://developers.google.com/earth-engine/datasets/tags/landcover builtin_legends = { # National Land Cover Database 2016 (NLCD2016) Legend https://www.mrlc.gov/data/leg...
def ee_table_to_legend(in_table, out_file): """Converts an Earth Engine color table to a dictionary Args: in_table (str): The input file path (*.txt) to the Earth Engine color table. out_file (str): The output file path (*.txt) to the legend dictionary. """ pkg_dir = os.path.dirnam...
416
456
"""Module of sample legends for some commonly used geospatial datasets. """ import os import pkg_resources # Land Cover datasets in Earth Engine https://developers.google.com/earth-engine/datasets/tags/landcover builtin_legends = { # National Land Cover Database 2016 (NLCD2016) Legend https://www.mrlc.gov/data/leg...
files
List files in state cache diretory State is required. Optionally provide a date filter to limit results. NOTE: Cache must be populated in order to load data.
from __future__ import print_function import click from openelex.base.cache import StateCache from .utils import default_state_options, print_files # MASKED: files function (lines 8-26) @click.command(name='cache.clear', help="Delete files in state cache diretory") @default_state_options def clear(state, datefilte...
@click.command(name="cache.files", help="List files in state cache diretory") @default_state_options def files(state, datefilter=''): """List files in state cache diretory State is required. Optionally provide a date filter to limit results. NOTE: Cache must be populated in order to load data. ""...
8
26
from __future__ import print_function import click from openelex.base.cache import StateCache from .utils import default_state_options, print_files @click.command(name="cache.files", help="List files in state cache diretory") @default_state_options def files(state, datefilter=''): """List files in state cache di...
ParseOptions
Parses the command line options. In case of command line errors, it will show the usage and exit the program. @return: the options in a tuple
#!/usr/bin/python3 # # Copyright (C) 2011 Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # 1. Redistributions of source code must retain the above copyright notice, # this list o...
def ParseOptions(): """Parses the command line options. In case of command line errors, it will show the usage and exit the program. @return: the options in a tuple """ parser = optparse.OptionParser() parser.add_option("-t", dest="thread_count", default=1, type="int", help="Number ...
43
63
#!/usr/bin/python3 # # Copyright (C) 2011 Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # 1. Redistributions of source code must retain the above copyright notice, # this list o...
logits_process
Get the logits as a tuple of softmax logits ,bounding boxes and labels. Output: to matrices: logits_mat in size (dataset, 300, 1231) - top 300 logits for each image. bboxes_mat in size (dataset, 300, 4) - top 300 bboxes for each image. labels_mat in size (dataset, 300, 1) - corresponding labels. 300 for each image.
import argparse import os import os.path as osp import shutil import tempfile import json import pdb import numpy as np import pickle import pandas as pd import mmcv import torch import torch.distributed as dist from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import get_dist_info, l...
def logits_process(logits): """ Get the logits as a tuple of softmax logits ,bounding boxes and labels. Output: to matrices: logits_mat in size (dataset, 300, 1231) - top 300 logits for each image. bboxes_mat in size (dataset, 300, 4) - top 300 bboxes for each image. labels_mat in size (dataset,...
184
225
import argparse import os import os.path as osp import shutil import tempfile import json import pdb import numpy as np import pickle import pandas as pd import mmcv import torch import torch.distributed as dist from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import get_dist_info, l...
get_files_by_ymd
:param dir_path: 文件夹 :param time_start: 开始时间 :param time_end: 结束时间 :param ext: 后缀名, '.hdf5' :param pattern_ymd: 匹配时间的模式, 可以是 r".*(\d{8})_(\d{4})_" :return: list
# coding: utf-8 import errno import os import random import re from contextlib import contextmanager import h5py import numpy as np import time import yaml from datetime import datetime def write_yaml_file(yaml_dict, file_yaml): path_yaml = os.path.dirname(file_yaml) if not os.path.isdir(path_yaml): ...
def get_files_by_ymd(dir_path, time_start, time_end, ext=None, pattern_ymd=None): """ :param dir_path: 文件夹 :param time_start: 开始时间 :param time_end: 结束时间 :param ext: 后缀名, '.hdf5' :param pattern_ymd: 匹配时间的模式, 可以是 r".*(\d{8})_(\d{4})_" :return: list """ files_found = [] if pattern_y...
228
258
# coding: utf-8 import errno import os import random import re from contextlib import contextmanager import h5py import numpy as np import time import yaml from datetime import datetime def write_yaml_file(yaml_dict, file_yaml): path_yaml = os.path.dirname(file_yaml) if not os.path.isdir(path_yaml): ...
move_organ
This function allows an organ's attributes to be altered to represent it's transportation across the network. This is intended to be used with Dijkstra.shortest_path (this will be the source of the cost parameter) :param int new_location: node id representing the destination location :param cost: weight/cost associate...
from __future__ import annotations from typing import List, Tuple, Optional from network_simulator.BloodType import BloodType from network_simulator.compatibility_markers import OrganType path_structure = Optional[List[Optional[int]]] shortest_path_structure = Tuple[path_structure, float] class Organ: """ ...
def move_organ(self, new_location: int, cost: float, shortest_path: shortest_path_structure) -> None: """ This function allows an organ's attributes to be altered to represent it's transportation across the network. This is intended to be used with Dijkstra.shortes...
37
54
from __future__ import annotations from typing import List, Tuple, Optional from network_simulator.BloodType import BloodType from network_simulator.compatibility_markers import OrganType path_structure = Optional[List[Optional[int]]] shortest_path_structure = Tuple[path_structure, float] class Organ: """ ...
__init__
Initialize a new SxpConnections object with the provided RestSession. Args: session(RestSession): The RESTful session object to be used for API calls to the Identity Services Engine service. Raises: TypeError: If the parameter types are incorrect.
# -*- coding: utf-8 -*- """Cisco Identity Services Engine SXPConnections API wrapper. Copyright (c) 2021 Cisco and/or its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restr...
def __init__(self, session, object_factory, request_validator): """Initialize a new SxpConnections object with the provided RestSession. Args: session(RestSession): The RESTful session object to be used for API calls to the Identity Services Engine service. ...
56
74
# -*- coding: utf-8 -*- """Cisco Identity Services Engine SXPConnections API wrapper. Copyright (c) 2021 Cisco and/or its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restr...
get_sxp_connections_by_id
This API allows the client to get a SXP connection by ID. Args: id(basestring): id path parameter. headers(dict): Dictionary of HTTP Headers to send with the Request . **query_parameters: Additional query parameters (provides support for parameters that may be added in the future). Returns...
# -*- coding: utf-8 -*- """Cisco Identity Services Engine SXPConnections API wrapper. Copyright (c) 2021 Cisco and/or its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restr...
def get_sxp_connections_by_id(self, id, headers=None, **query_parameters): """This API allows the client to get a SXP connection by ID. Args: id(basestring): id path parameter. ...
76
145
# -*- coding: utf-8 -*- """Cisco Identity Services Engine SXPConnections API wrapper. Copyright (c) 2021 Cisco and/or its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restr...
get_sxp_connections
This API allows the client to get all the SXP connections. Filter: [name, description] To search resources by using toDate column,follow the format: DD-MON-YY (Example:13-SEP-18) Day or Year:GET /ers/config/guestuser/?filter=toDate.CONTAINS.13 Month:GET /ers/config/guestuser/?filter=toDate.CONTAINS.SEP Date...
# -*- coding: utf-8 -*- """Cisco Identity Services Engine SXPConnections API wrapper. Copyright (c) 2021 Cisco and/or its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restr...
def get_sxp_connections(self, filter=None, filter_type=None, page=None, size=None, sortasc=None, sortdsc=None, headers=N...
418
549
# -*- coding: utf-8 -*- """Cisco Identity Services Engine SXPConnections API wrapper. Copyright (c) 2021 Cisco and/or its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restr...
get_version
This API helps to retrieve the version information related to the SXP connections. Args: headers(dict): Dictionary of HTTP Headers to send with the Request . **query_parameters: Additional query parameters (provides support for parameters that may be added in the future). Returns: RestRes...
# -*- coding: utf-8 -*- """Cisco Identity Services Engine SXPConnections API wrapper. Copyright (c) 2021 Cisco and/or its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restr...
def get_version(self, headers=None, **query_parameters): """This API helps to retrieve the version information related to the SXP connections. Args: headers(dict): Dictionary of HTTP Headers to send with the Request . ...
854
913
# -*- coding: utf-8 -*- """Cisco Identity Services Engine SXPConnections API wrapper. Copyright (c) 2021 Cisco and/or its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restr...
monitor_bulk_status_sxp_connections
This API allows the client to monitor the bulk request. Args: bulkid(basestring): bulkid path parameter. headers(dict): Dictionary of HTTP Headers to send with the Request . **query_parameters: Additional query parameters (provides support for parameters that may be added in the future). R...
# -*- coding: utf-8 -*- """Cisco Identity Services Engine SXPConnections API wrapper. Copyright (c) 2021 Cisco and/or its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restr...
def monitor_bulk_status_sxp_connections(self, bulkid, headers=None, **query_parameters): """This API allows the client to monitor the bulk request. Args: b...
1,034
1,097
# -*- coding: utf-8 -*- """Cisco Identity Services Engine SXPConnections API wrapper. Copyright (c) 2021 Cisco and/or its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restr...
entropy_score
Schmieder and Edwards. Quality control and preprocessing of metagenomic datasets. (2011) Bioinformatics https://academic.oup.com/bioinformatics/article/27/6/863/236283/Quality-control-and-preprocessing-of-metagenomic
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Deals with K-mers and K-mer distribution from reads or genome """ from __future__ import print_function import os.path as op import sys import logging import math import numpy as np from collections import defaultdict from jcvi.graphics.base import ( plt, as...
def entropy_score(kmer): """ Schmieder and Edwards. Quality control and preprocessing of metagenomic datasets. (2011) Bioinformatics https://academic.oup.com/bioinformatics/article/27/6/863/236283/Quality-control-and-preprocessing-of-metagenomic """ l = len(kmer) - 2 k = l if l < 64 else 64 ...
273
290
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Deals with K-mers and K-mer distribution from reads or genome """ from __future__ import print_function import os.path as op import sys import logging import math import numpy as np from collections import defaultdict from jcvi.graphics.base import ( plt, as...
entropy
%prog entropy kmc_dump.out kmc_dump.out contains two columns: AAAAAAAAAAAGAAGAAAGAAA 34
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Deals with K-mers and K-mer distribution from reads or genome """ from __future__ import print_function import os.path as op import sys import logging import math import numpy as np from collections import defaultdict from jcvi.graphics.base import ( plt, as...
def entropy(args): """ %prog entropy kmc_dump.out kmc_dump.out contains two columns: AAAAAAAAAAAGAAGAAAGAAA 34 """ p = OptionParser(entropy.__doc__) p.add_option( "--threshold", default=0, type="int", help="Complexity needs to be above" ) opts, args = p.parse_args(args) ...
293
315
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Deals with K-mers and K-mer distribution from reads or genome """ from __future__ import print_function import os.path as op import sys import logging import math import numpy as np from collections import defaultdict from jcvi.graphics.base import ( plt, as...
model
%prog model erate Model kmer distribution given error rate. See derivation in FIONA paper: <http://bioinformatics.oxfordjournals.org/content/30/17/i356.full>
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Deals with K-mers and K-mer distribution from reads or genome """ from __future__ import print_function import os.path as op import sys import logging import math import numpy as np from collections import defaultdict from jcvi.graphics.base import ( plt, as...
def model(args): """ %prog model erate Model kmer distribution given error rate. See derivation in FIONA paper: <http://bioinformatics.oxfordjournals.org/content/30/17/i356.full> """ from scipy.stats import binom, poisson p = OptionParser(model.__doc__) p.add_option("-k", default=23, t...
476
514
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Deals with K-mers and K-mer distribution from reads or genome """ from __future__ import print_function import os.path as op import sys import logging import math import numpy as np from collections import defaultdict from jcvi.graphics.base import ( plt, as...
merylhistogram
Run meryl to dump histogram to be used in kmer.histogram(). The merylfile are the files ending in .mcidx or .mcdat.
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Deals with K-mers and K-mer distribution from reads or genome """ from __future__ import print_function import os.path as op import sys import logging import math import numpy as np from collections import defaultdict from jcvi.graphics.base import ( plt, as...
def merylhistogram(merylfile): """ Run meryl to dump histogram to be used in kmer.histogram(). The merylfile are the files ending in .mcidx or .mcdat. """ pf, sf = op.splitext(merylfile) outfile = pf + ".histogram" if need_update(merylfile, outfile): cmd = "meryl -Dh -s {0}".format(p...
762
773
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Deals with K-mers and K-mer distribution from reads or genome """ from __future__ import print_function import os.path as op import sys import logging import math import numpy as np from collections import defaultdict from jcvi.graphics.base import ( plt, as...
_gradient_of_loss
Compute the gradient of the loss function. :param target: An array with the target class (one-hot encoded). :type target: `np.ndarray` :param x: An array with the original input. :type x: `np.ndarray` :param x_adv: An array with the adversarial input. :type x_adv: `np.ndarray` :param c: Weight of the loss term aiming ...
# MIT License # # Copyright (C) IBM Corporation 2018 # # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated # documentation files (the "Software"), to deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge...
def _gradient_of_loss(self, target, x, x_adv, c): """ Compute the gradient of the loss function. :param target: An array with the target class (one-hot encoded). :type target: `np.ndarray` :param x: An array with the original input. :type x: `np.ndarray` :par...
101
137
# MIT License # # Copyright (C) IBM Corporation 2018 # # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated # documentation files (the "Software"), to deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge...
get_converter
If there is a converter old_type -> new_type, return it. Else return None. If a chain of converters is necessary, return it as a tuple or list (starting with the innermost, first-to-apply converter).
#Copyright (c) 2013 Marion Zepf #Copyright (c) 2014 Walter Bender #Permission is hereby granted, free of charge, to any person obtaining a copy #of this software and associated documentation files (the "Software"), to deal #in the Software without restriction, including without limitation the rights #to use, copy, mod...
def get_converter(old_type, new_type): """ If there is a converter old_type -> new_type, return it. Else return None. If a chain of converters is necessary, return it as a tuple or list (starting with the innermost, first-to-apply converter). """ # every type can be converted to TYPE_OBJECT if new_t...
261
309
#Copyright (c) 2013 Marion Zepf #Copyright (c) 2014 Walter Bender #Permission is hereby granted, free of charge, to any person obtaining a copy #of this software and associated documentation files (the "Software"), to deal #in the Software without restriction, including without limitation the rights #to use, copy, mod...
convert
Convert x to the new type if possible. old_type -- the type of x. If not given, it is computed.
#Copyright (c) 2013 Marion Zepf #Copyright (c) 2014 Walter Bender #Permission is hereby granted, free of charge, to any person obtaining a copy #of this software and associated documentation files (the "Software"), to deal #in the Software without restriction, including without limitation the rights #to use, copy, mod...
def convert(x, new_type, old_type=None, converter=None): """ Convert x to the new type if possible. old_type -- the type of x. If not given, it is computed. """ if not isinstance(new_type, Type): raise ValueError('%s is not a type in the type hierarchy' % (repr(new_type))) ...
312
370
#Copyright (c) 2013 Marion Zepf #Copyright (c) 2014 Walter Bender #Permission is hereby granted, free of charge, to any person obtaining a copy #of this software and associated documentation files (the "Software"), to deal #in the Software without restriction, including without limitation the rights #to use, copy, mod...
add_source
Adds a new source of absorption to the sightline. The purpose of a source is to hold multiple line models together, sometiimes with similar parameters Args: name (str): The name of the absorption source similar (dict): A dict of parameters that change with the source, not the specific line, defaul...
import numpy as np import matplotlib.pyplot as plt import bisect from lmfit import Parameters import astropy.constants as cst from edibles.models import ContinuumModel, VoigtModel from edibles.utils.edibles_spectrum import EdiblesSpectrum class Sightline: '''A model of the sightline between the telescope and the...
def add_source(self, name, similar=None): '''Adds a new source of absorption to the sightline. The purpose of a source is to hold multiple line models together, sometiimes with similar parameters Args: name (str): The name of the absorption source simila...
56
80
import numpy as np import matplotlib.pyplot as plt import bisect from lmfit import Parameters import astropy.constants as cst from edibles.models import ContinuumModel, VoigtModel from edibles.utils.edibles_spectrum import EdiblesSpectrum class Sightline: '''A model of the sightline between the telescope and the...
add_line
Adds a new line to a given absorption source. If no source is given, a new one will be created. Args: name (str): The name of the line source (str): the name of the source this line will belong to pars (dict): user input parameters guess_data (1darray): flux data to guess with
import numpy as np import matplotlib.pyplot as plt import bisect from lmfit import Parameters import astropy.constants as cst from edibles.models import ContinuumModel, VoigtModel from edibles.utils.edibles_spectrum import EdiblesSpectrum class Sightline: '''A model of the sightline between the telescope and the...
def add_line(self, name, source=None, pars=None, guess_data=None): '''Adds a new line to a given absorption source. If no source is given, a new one will be created. Args: name (str): The name of the line source (str): the name of the source this line will belong to ...
83
168
import numpy as np import matplotlib.pyplot as plt import bisect from lmfit import Parameters import astropy.constants as cst from edibles.models import ContinuumModel, VoigtModel from edibles.utils.edibles_spectrum import EdiblesSpectrum class Sightline: '''A model of the sightline between the telescope and the...
freeze
Freezes the current params, so you can still add to the model but the 'old' parameters will not change Args: prefix (str): Prefix of parameters to freeze, default: None, example: 'Telluric' freeze_cont (bool): Freeze the continuum or not, default: True unfreeze (bool): unfreezes all parameters except x...
import numpy as np import matplotlib.pyplot as plt import bisect from lmfit import Parameters import astropy.constants as cst from edibles.models import ContinuumModel, VoigtModel from edibles.utils.edibles_spectrum import EdiblesSpectrum class Sightline: '''A model of the sightline between the telescope and the...
def freeze(self, pars=None, prefix=None, freeze_cont=True, unfreeze=False): '''Freezes the current params, so you can still add to the model but the 'old' parameters will not change Args: prefix (str): Prefix of parameters to freeze, default: None, example: 'Telluric' ...
246
286
import numpy as np import matplotlib.pyplot as plt import bisect from lmfit import Parameters import astropy.constants as cst from edibles.models import ContinuumModel, VoigtModel from edibles.utils.edibles_spectrum import EdiblesSpectrum class Sightline: '''A model of the sightline between the telescope and the...
post
Bulk add group members. Permission checking: 1. only admin can perform this action.
# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAdminUser from rest_framework.response import Response from rest_framework.views import APIView from rest_framework import status from seaserv import seafile_a...
def post(self, request, group_id): """ Bulk add group members. Permission checking: 1. only admin can perform this action. """ if not request.user.admin_permissions.can_manage_group(): return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.') ...
73
138
# Copyright (c) 2012-2016 Seafile Ltd. import logging from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAdminUser from rest_framework.response import Response from rest_framework.views import APIView from rest_framework import status from seaserv import seafile_a...
demo
Output: ---------⌝ ---------- ----?????- ---------- ---------- --!!!----- --!!!----- ---------- ---------- ⌞---------
# MASKED: demo function (lines 2-28) def fill(grid: dict, value: str, start=(0, 0), stop=(0, 0)): """Using product allows for flatter loops.""" from itertools import product for coord in product(range(start[0], stop[0]), range(start[1], stop[1])): grid[coord] = value def stringify(grid: dict, ...
def demo(): """Output: ---------⌝ ---------- ----?????- ---------- ---------- --!!!----- --!!!----- ---------- ---------- ⌞--------- """ n = 10 # Construction is easy: grid = {} # Assignment is easy: grid[(0, 0)] = "⌞" grid[(n - 1, n - 1)] = "⌝" ...
2
28
def demo(): """Output: ---------⌝ ---------- ----?????- ---------- ---------- --!!!----- --!!!----- ---------- ---------- ⌞--------- """ n = 10 # Construction is easy: grid = {} # Assignment is easy: grid[(0, 0)] = "⌞" grid[(n - 1, n - 1)] = "⌝"...
reflection
8x8のブロックごとに離散コサイン変換された画像(以下DCT画像)を鏡像変換する. Parameters ---------- image:幅と高さが8の倍数である画像を表す2次元配列. 8の倍数でない場合の動作は未定義. axis:変換する軸. defalutは`axis=0` Returns ------- `image`を鏡像変換したDCT画像を表す2次元配列を返す. `image`の値は変わらない. Examples -------- >>> import numpy as np >>> a = np.arange(64).reshape((8,8)) >>> a array([[ 0, 1, 2, 3, 4...
import numpy as np from dct_image_transform.dct import dct2 # MASKED: reflection function (lines 4-64)
def reflection(image,axis=0): ''' 8x8のブロックごとに離散コサイン変換された画像(以下DCT画像)を鏡像変換する. Parameters ---------- image:幅と高さが8の倍数である画像を表す2次元配列. 8の倍数でない場合の動作は未定義. axis:変換する軸. defalutは`axis=0` Returns ------- `image`を鏡像変換したDCT画像を表す2次元配列を返す. `image`の値は変わらない. Examples -------- >>> im...
4
64
import numpy as np from dct_image_transform.dct import dct2 def reflection(image,axis=0): ''' 8x8のブロックごとに離散コサイン変換された画像(以下DCT画像)を鏡像変換する. Parameters ---------- image:幅と高さが8の倍数である画像を表す2次元配列. 8の倍数でない場合の動作は未定義. axis:変換する軸. defalutは`axis=0` Returns ------- `image`を鏡像変換したDCT画像を表す2次元...
_get_login_info
Get the login info as (username, password) First look for the manually specified credentials using username_option and password_option as keys in params dictionary. If no such credentials available look in the netrc file using the netrc_machine or _NETRC_MACHINE value. If there's no info available, return (None, None)
# coding: utf-8 from __future__ import unicode_literals import base64 import datetime import hashlib import json import netrc import os import random import re import socket import ssl import sys import time import math from ..compat import ( compat_cookiejar_Cookie, compat_cookies, compat_etree_Element, ...
def _get_login_info(self, username_option='username', password_option='password', netrc_machine=None): """ Get the login info as (username, password) First look for the manually specified credentials using username_option and password_option as keys in params dictionary. If no such c...
1,045
1,066
# coding: utf-8 from __future__ import unicode_literals import base64 import datetime import hashlib import json import netrc import os import random import re import socket import ssl import sys import time import math from ..compat import ( compat_cookiejar_Cookie, compat_cookies, compat_etree_Element, ...
_move
Conducts a section's part of moving in an alfred experiment. Raises: ValidationError: If validation of the current page fails.
# -*- coding:utf-8 -*- """ Sections organize movement between pages in an experiment. .. moduleauthor:: Johannes Brachem <jbrachem@posteo.de>, Paul Wiemann <paulwiemann@gmail.com> """ import time import typing as t from ._core import ExpMember from ._helper import inherit_kwargs from .page import _PageCore, _DefaultF...
def _move(self, direction, from_page, to_page): """ Conducts a section's part of moving in an alfred experiment. Raises: ValidationError: If validation of the current page fails. """ if direction == "forward": self._forward() elif direction ==...
625
655
# -*- coding:utf-8 -*- """ Sections organize movement between pages in an experiment. .. moduleauthor:: Johannes Brachem <jbrachem@posteo.de>, Paul Wiemann <paulwiemann@gmail.com> """ import time import typing as t from ._core import ExpMember from ._helper import inherit_kwargs from .page import _PageCore, _DefaultF...
parse_iso_duration
Parses duration string according to ISO 8601 and returns timedelta representation (it excludes year and month) http://www.datypic.com/sc/xsd/t-xsd_dayTimeDuration.html :param str value: :return dict:
import re from datetime import date, datetime, time, timedelta, timezone ISO_8601_DATETIME_REGEX = re.compile( r"^(\d{4})-?([0-1]\d)-?([0-3]\d)[t\s]?([0-2]\d:?[0-5]\d:?[0-5]\d|23:59:60|235960)(\.\d+)?(z|[+-]\d{2}:\d{2})?$", re.I, ) ISO_8601_DATE_REGEX = re.compile(r"^(\d{4})-?([0-1]\d)-?([0-3]\d)$", re.I) ISO_...
def parse_iso_duration(value: str) -> timedelta: """ Parses duration string according to ISO 8601 and returns timedelta representation (it excludes year and month) http://www.datypic.com/sc/xsd/t-xsd_dayTimeDuration.html :param str value: :return dict: """ if not ISO_8601_TIME_DURATION_REGEX...
65
90
import re from datetime import date, datetime, time, timedelta, timezone ISO_8601_DATETIME_REGEX = re.compile( r"^(\d{4})-?([0-1]\d)-?([0-3]\d)[t\s]?([0-2]\d:?[0-5]\d:?[0-5]\d|23:59:60|235960)(\.\d+)?(z|[+-]\d{2}:\d{2})?$", re.I, ) ISO_8601_DATE_REGEX = re.compile(r"^(\d{4})-?([0-1]\d)-?([0-3]\d)$", re.I) ISO_...
predict
Predict values for mean or precision Parameters ---------- params : array_like The model parameters. exog : array_like Array of predictor variables for mean. exog_precision : array_like Array of predictor variables for precision parameter. which : str - "mean" : mean, conditional expectation E(endog |...
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
def predict(self, params, exog=None, exog_precision=None, which="mean"): """Predict values for mean or precision Parameters ---------- params : array_like The model parameters. exog : array_like Array of predictor variables for mean. exog_prec...
156
219
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
_predict_precision
Predict values for precision function for given exog_precision. Parameters ---------- params : array_like The model parameters. exog_precision : array_like Array of predictor variables for precision. Returns ------- Predicted precision.
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
def _predict_precision(self, params, exog_precision=None): """Predict values for precision function for given exog_precision. Parameters ---------- params : array_like The model parameters. exog_precision : array_like Array of predictor variables for ...
221
243
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
_predict_var
predict values for conditional variance V(endog | exog) Parameters ---------- params : array_like The model parameters. exog : array_like Array of predictor variables for mean. exog_precision : array_like Array of predictor variables for precision. Returns ------- Predicted conditional variance.
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
def _predict_var(self, params, exog=None, exog_precision=None): """predict values for conditional variance V(endog | exog) Parameters ---------- params : array_like The model parameters. exog : array_like Array of predictor variables for mean. ...
245
266
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
score
Returns the score vector of the log-likelihood. http://www.tandfonline.com/doi/pdf/10.1080/00949650903389993 Parameters ---------- params : ndarray Parameter at which score is evaluated. Returns ------- score : ndarray First derivative of loglikelihood function.
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
def score(self, params): """ Returns the score vector of the log-likelihood. http://www.tandfonline.com/doi/pdf/10.1080/00949650903389993 Parameters ---------- params : ndarray Parameter at which score is evaluated. Returns ------- ...
330
350
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
score_obs
Score, first derivative of the loglikelihood for each observation. Parameters ---------- params : ndarray Parameter at which score is evaluated. Returns ------- score_obs : ndarray, 2d The first derivative of the loglikelihood function evaluated at params for each observation.
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
def score_obs(self, params): """ Score, first derivative of the loglikelihood for each observation. Parameters ---------- params : ndarray Parameter at which score is evaluated. Returns ------- score_obs : ndarray, 2d The firs...
505
525
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
hessian
Hessian, second derivative of loglikelihood function Parameters ---------- params : ndarray Parameter at which Hessian is evaluated. observed : bool If True, then the observed Hessian is returned (default). If False, then the expected information matrix is returned. Returns ------- hessian : ndarray H...
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
def hessian(self, params, observed=None): """Hessian, second derivative of loglikelihood function Parameters ---------- params : ndarray Parameter at which Hessian is evaluated. observed : bool If True, then the observed Hessian is returned (default)....
527
556
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
fit
Fit the model by maximum likelihood. Parameters ---------- start_params : array-like A vector of starting values for the regression coefficients. If None, a default is chosen. maxiter : integer The maximum number of iterations disp : bool Show convergence stats. method : str The optimization metho...
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
def fit(self, start_params=None, maxiter=1000, disp=False, method='bfgs', **kwds): """ Fit the model by maximum likelihood. Parameters ---------- start_params : array-like A vector of starting values for the regression coefficients. If No...
629
672
# -*- coding: utf-8 -*- u""" Beta regression for modeling rates and proportions. References ---------- Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in Economics and Statistics, 2011. Smithson, Michael, and Jay ...
docutilize
Convert Numpy or Google style docstring into reStructuredText format. Args: obj (str or object): Takes an object and changes it's docstrings to a reStructuredText format. Returns: str or object: A converted string or an object with replaced docstring depending on the type of the...
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # (C) British Crown copyright. The Met Office. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are me...
def docutilize(obj): """Convert Numpy or Google style docstring into reStructuredText format. Args: obj (str or object): Takes an object and changes it's docstrings to a reStructuredText format. Returns: str or object: A converted string or an object with...
57
87
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # (C) British Crown copyright. The Met Office. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are me...
with_output
Add `output` keyword only argument. Add `compression_level` option. Add `least_significant_digit` option. This is used to add extra `output`, `compression_level` and `least_significant_digit` CLI options. If `output` is provided, it saves the result of calling `wrapped` to file and returns None, otherwise it returns t...
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # (C) British Crown copyright. The Met Office. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are me...
@decorator def with_output( wrapped, *args, output=None, compression_level=1, least_significant_digit: int = None, **kwargs, ): """Add `output` keyword only argument. Add `compression_level` option. Add `least_significant_digit` option. This is used to add extra `output`, `compr...
326
371
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # (C) British Crown copyright. The Met Office. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are me...
unbracket
Convert input list with bracketed items into nested lists. >>> unbracket('foo [ bar a b ] [ baz c ] -o z'.split()) ['foo', ['bar', 'a', 'b'], ['baz', 'c'], '-o', 'z']
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # (C) British Crown copyright. The Met Office. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are me...
def unbracket(args): """Convert input list with bracketed items into nested lists. >>> unbracket('foo [ bar a b ] [ baz c ] -o z'.split()) ['foo', ['bar', 'a', 'b'], ['baz', 'c'], '-o', 'z'] """ outargs = [] stack = [] mismatch_msg = "Mismatched bracket at position %i." for i, arg in e...
438
461
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # (C) British Crown copyright. The Met Office. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are me...
constrained_inputcubelist_converter
Passes the cube and constraints onto maybe_coerce_with. Args: to_convert (str or iris.cube.CubeList): A CubeList or a filename to be loaded into a CubeList. Returns: iris.cube.CubeList: The loaded cubelist of constrained cubes.
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # (C) British Crown copyright. The Met Office. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are me...
@value_converter def constrained_inputcubelist_converter(to_convert): """Passes the cube and constraints onto maybe_coerce_with. Args: to_convert (str or iris.cube.CubeList): A CubeList or a filename to be loaded into a CubeList. Returns: iris.cu...
294
318
# -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # (C) British Crown copyright. The Met Office. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are me...
art_search
Function to retrieve the information about collections in the Art institute of Chicago Parameters: ------------- The key word that users want to search, for example: the artist's name, the title of the artwork. Returns: ------------- Status code: str if the API request went thr...
import pandas as pd import numpy as np import os import json import requests from dotenv import load_dotenv from PIL import Image from io import BytesIO from IPython.core.display import display, HTML # MASKED: art_search function (lines 11-49) def tour_search(tour): ''' Function to retrieve the informatio...
def art_search(art): ''' Function to retrieve the information about collections in the Art institute of Chicago Parameters: ------------- The key word that users want to search, for example: the artist's name, the title of the artwork. Returns: ------------- Status code: str ...
11
49
import pandas as pd import numpy as np import os import json import requests from dotenv import load_dotenv from PIL import Image from io import BytesIO from IPython.core.display import display, HTML def art_search(art): ''' Function to retrieve the information about collections in the Art institute of Chicago...
tour_search
Function to retrieve the information about tour in the Art institute of Chicago Parameters: ------------- The key word that users want to search, for example: the artist's name, the title of the artwork. Returns: ------------- Status code: str if the API request went through Dataframe: df includes the related...
import pandas as pd import numpy as np import os import json import requests from dotenv import load_dotenv from PIL import Image from io import BytesIO from IPython.core.display import display, HTML def art_search(art): ''' Function to retrieve the information about collections in the Art institute of Chicago...
def tour_search(tour): ''' Function to retrieve the information about tour in the Art institute of Chicago Parameters: ------------- The key word that users want to search, for example: the artist's name, the title of the artwork. Returns: ------------- Status code: str if ...
51
89
import pandas as pd import numpy as np import os import json import requests from dotenv import load_dotenv from PIL import Image from io import BytesIO from IPython.core.display import display, HTML def art_search(art): ''' Function to retrieve the information about collections in the Art institute of Chicago...
product_search
Function to retrieve the information about products sold in the Art institute of Chicago Parameters: ------------- pic: the title of the artwork artist: the full name of the artist Returns: ------------- Status code: str if the API request went through DataFrame: a dataframe include related info about the product...
import pandas as pd import numpy as np import os import json import requests from dotenv import load_dotenv from PIL import Image from io import BytesIO from IPython.core.display import display, HTML def art_search(art): ''' Function to retrieve the information about collections in the Art institute of Chicago...
def product_search(product_art, product_category): ''' Function to retrieve the information about products sold in the Art institute of Chicago Parameters: ------------- pic: the title of the artwork artist: the full name of the artist Returns: ------------- Status code: str ...
145
195
import pandas as pd import numpy as np import os import json import requests from dotenv import load_dotenv from PIL import Image from io import BytesIO from IPython.core.display import display, HTML def art_search(art): ''' Function to retrieve the information about collections in the Art institute of Chicago...
product_show
Function to retrieve the information about top10 products sold in the Art institute of Chicago Parameters: ------------- Type in any random word Returns: ------------- Status code: str if the API request went through DataFrame: a dataframe include related info about the top 10 products and images of the products ...
import pandas as pd import numpy as np import os import json import requests from dotenv import load_dotenv from PIL import Image from io import BytesIO from IPython.core.display import display, HTML def art_search(art): ''' Function to retrieve the information about collections in the Art institute of Chicago...
def product_show(product_art_show): ''' Function to retrieve the information about top10 products sold in the Art institute of Chicago Parameters: ------------- Type in any random word Returns: ------------- Status code: str if the API request went through DataFrame: a data...
197
241
import pandas as pd import numpy as np import os import json import requests from dotenv import load_dotenv from PIL import Image from io import BytesIO from IPython.core.display import display, HTML def art_search(art): ''' Function to retrieve the information about collections in the Art institute of Chicago...
run_mx_unary_operators_benchmarks
Runs benchmarks with the given context and precision (dtype)for all the unary operators in MXNet. Parameters ---------- ctx: mx.ctx Context to run benchmarks dtype: str, default 'float32' Precision to use for benchmarks warmup: int, default 25 Number of times to run for warmup runs: int, default 100 Nu...
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
def run_mx_unary_operators_benchmarks(ctx=mx.cpu(), dtype='float32', warmup=25, runs=100): """Runs benchmarks with the given context and precision (dtype)for all the unary operators in MXNet. Parameters ---------- ctx: mx.ctx Context to run benchmarks dtype: str, default 'float32' ...
38
62
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
pivot_table
Create a spreadsheet-style pivot table as a DataFrame. Target ``columns`` must have category dtype to infer result's ``columns``. ``index``, ``columns``, and ``aggfunc`` must be all scalar. ``values`` can be scalar or list-like. Parameters ---------- df : DataFrame index : scalar column to be index columns : scala...
import sys import numpy as np import pandas as pd from pandas.api.types import is_list_like, is_scalar from dask.dataframe import methods from dask.dataframe.core import DataFrame, Series, apply_concat_apply, map_partitions from dask.dataframe.utils import has_known_categories from dask.utils import M ##############...
def pivot_table(df, index=None, columns=None, values=None, aggfunc="mean"): """ Create a spreadsheet-style pivot table as a DataFrame. Target ``columns`` must have category dtype to infer result's ``columns``. ``index``, ``columns``, and ``aggfunc`` must be all scalar. ``values`` can be scalar or li...
172
304
import sys import numpy as np import pandas as pd from pandas.api.types import is_list_like, is_scalar from dask.dataframe import methods from dask.dataframe.core import DataFrame, Series, apply_concat_apply, map_partitions from dask.dataframe.utils import has_known_categories from dask.utils import M ##############...
parse_rule
Parse a parameter string into its constituent name, type, and pattern For example: `parse_parameter_string('<param_one:[A-z]>')` -> ('param_one', str, '[A-z]') :param parameter_string: String to parse :return: tuple containing (parameter_name, parameter_type, parameter_pattern)
# -*- coding: utf-8 -*- # import re from collections import OrderedDict from copy import deepcopy from ._http import HTTPStatus #copied from sanic router REGEX_TYPES = { 'string': (str, r'[^/]+'), 'int': (int, r'\d+'), 'number': (float, r'[0-9\\.]+'), 'alpha': (str, r'[A-Za-z]+'), } FIRST_CAP_RE = re....
def parse_rule(parameter_string): """Parse a parameter string into its constituent name, type, and pattern For example: `parse_parameter_string('<param_one:[A-z]>')` -> ('param_one', str, '[A-z]') :param parameter_string: String to parse :return: tuple containing (parameter_nam...
155
180
# -*- coding: utf-8 -*- # import re from collections import OrderedDict from copy import deepcopy from ._http import HTTPStatus #copied from sanic router REGEX_TYPES = { 'string': (str, r'[^/]+'), 'int': (int, r'\d+'), 'number': (float, r'[0-9\\.]+'), 'alpha': (str, r'[A-Za-z]+'), } FIRST_CAP_RE = re....
query
Query the "attachment page" endpoint and set the results to self.response. :param document_number: The internal PACER document ID for the item. :return: a request response object
import re from .reports import BaseReport from .utils import get_pacer_doc_id_from_doc1_url, reverse_goDLS_function from ..lib.log_tools import make_default_logger from ..lib.string_utils import force_unicode logger = make_default_logger() class AttachmentPage(BaseReport): """An object for querying and parsing ...
def query(self, document_number): """Query the "attachment page" endpoint and set the results to self.response. :param document_number: The internal PACER document ID for the item. :return: a request response object """ assert self.session is not None, \ "session...
25
39
import re from .reports import BaseReport from .utils import get_pacer_doc_id_from_doc1_url, reverse_goDLS_function from ..lib.log_tools import make_default_logger from ..lib.string_utils import force_unicode logger = make_default_logger() class AttachmentPage(BaseReport): """An object for querying and parsing ...
_extend_control_events_default
Default function for extending control event sequence. This function extends a control event sequence by duplicating the final event in the sequence. The control event sequence will be extended to have length one longer than the generated event sequence. Args: control_events: The control event sequence to extend. ...
# Copyright 2019 The Magenta Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
def _extend_control_events_default(control_events, events, state): """Default function for extending control event sequence. This function extends a control event sequence by duplicating the final event in the sequence. The control event sequence will be extended to have length one longer than the generated e...
41
59
# Copyright 2019 The Magenta Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
move_media
Move the given file, and any thumbnails, to the dest repo Args: origin_server (str): file_id (str): src_paths (MediaFilePaths): dest_paths (MediaFilePaths):
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2017 New Vector Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
def move_media(origin_server, file_id, src_paths, dest_paths): """Move the given file, and any thumbnails, to the dest repo Args: origin_server (str): file_id (str): src_paths (MediaFilePaths): dest_paths (MediaFilePaths): """ logger.info("%s/%s", origin_server, file_id)...
64
98
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2017 New Vector Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...