repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
astropy/photutils
photutils/psf/epsf.py
_py2intround
def _py2intround(a): """ Round the input to the nearest integer. If two integers are equally close, rounding is done away from 0. """ data = np.asanyarray(a) value = np.where(data >= 0, np.floor(data + 0.5), np.ceil(data - 0.5)).astype(int) if not hasattr(a, '__iter__...
python
def _py2intround(a): """ Round the input to the nearest integer. If two integers are equally close, rounding is done away from 0. """ data = np.asanyarray(a) value = np.where(data >= 0, np.floor(data + 0.5), np.ceil(data - 0.5)).astype(int) if not hasattr(a, '__iter__...
[ "def", "_py2intround", "(", "a", ")", ":", "data", "=", "np", ".", "asanyarray", "(", "a", ")", "value", "=", "np", ".", "where", "(", "data", ">=", "0", ",", "np", ".", "floor", "(", "data", "+", "0.5", ")", ",", "np", ".", "ceil", "(", "dat...
Round the input to the nearest integer. If two integers are equally close, rounding is done away from 0.
[ "Round", "the", "input", "to", "the", "nearest", "integer", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L845-L859
train
astropy/photutils
photutils/psf/epsf.py
_interpolate_missing_data
def _interpolate_missing_data(data, mask, method='cubic'): """ Interpolate missing data as identified by the ``mask`` keyword. Parameters ---------- data : 2D `~numpy.ndarray` An array containing the 2D image. mask : 2D bool `~numpy.ndarray` A 2D booleen mask array with the sam...
python
def _interpolate_missing_data(data, mask, method='cubic'): """ Interpolate missing data as identified by the ``mask`` keyword. Parameters ---------- data : 2D `~numpy.ndarray` An array containing the 2D image. mask : 2D bool `~numpy.ndarray` A 2D booleen mask array with the sam...
[ "def", "_interpolate_missing_data", "(", "data", ",", "mask", ",", "method", "=", "'cubic'", ")", ":", "from", "scipy", "import", "interpolate", "data_interp", "=", "np", ".", "array", "(", "data", ",", "copy", "=", "True", ")", "if", "len", "(", "data_i...
Interpolate missing data as identified by the ``mask`` keyword. Parameters ---------- data : 2D `~numpy.ndarray` An array containing the 2D image. mask : 2D bool `~numpy.ndarray` A 2D booleen mask array with the same shape as the input ``data``, where a `True` value indicates t...
[ "Interpolate", "missing", "data", "as", "identified", "by", "the", "mask", "keyword", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L862-L916
train
astropy/photutils
photutils/psf/epsf.py
EPSFFitter._fit_star
def _fit_star(self, epsf, star, fitter, fitter_kwargs, fitter_has_fit_info, fit_boxsize): """ Fit an ePSF model to a single star. The input ``epsf`` will usually be modified by the fitting routine in this function. Make a copy before calling this function if t...
python
def _fit_star(self, epsf, star, fitter, fitter_kwargs, fitter_has_fit_info, fit_boxsize): """ Fit an ePSF model to a single star. The input ``epsf`` will usually be modified by the fitting routine in this function. Make a copy before calling this function if t...
[ "def", "_fit_star", "(", "self", ",", "epsf", ",", "star", ",", "fitter", ",", "fitter_kwargs", ",", "fitter_has_fit_info", ",", "fit_boxsize", ")", ":", "if", "fit_boxsize", "is", "not", "None", ":", "try", ":", "xcenter", ",", "ycenter", "=", "star", "...
Fit an ePSF model to a single star. The input ``epsf`` will usually be modified by the fitting routine in this function. Make a copy before calling this function if the original is needed.
[ "Fit", "an", "ePSF", "model", "to", "a", "single", "star", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L146-L238
train
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._init_img_params
def _init_img_params(param): """ Initialize 2D image-type parameters that can accept either a single or two values. """ if param is not None: param = np.atleast_1d(param) if len(param) == 1: param = np.repeat(param, 2) return para...
python
def _init_img_params(param): """ Initialize 2D image-type parameters that can accept either a single or two values. """ if param is not None: param = np.atleast_1d(param) if len(param) == 1: param = np.repeat(param, 2) return para...
[ "def", "_init_img_params", "(", "param", ")", ":", "if", "param", "is", "not", "None", ":", "param", "=", "np", ".", "atleast_1d", "(", "param", ")", "if", "len", "(", "param", ")", "==", "1", ":", "param", "=", "np", ".", "repeat", "(", "param", ...
Initialize 2D image-type parameters that can accept either a single or two values.
[ "Initialize", "2D", "image", "-", "type", "parameters", "that", "can", "accept", "either", "a", "single", "or", "two", "values", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L369-L380
train
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._create_initial_epsf
def _create_initial_epsf(self, stars): """ Create an initial `EPSFModel` object. The initial ePSF data are all zeros. If ``shape`` is not specified, the shape of the ePSF data array is determined from the shape of the input ``stars`` and the oversampling factor. If the...
python
def _create_initial_epsf(self, stars): """ Create an initial `EPSFModel` object. The initial ePSF data are all zeros. If ``shape`` is not specified, the shape of the ePSF data array is determined from the shape of the input ``stars`` and the oversampling factor. If the...
[ "def", "_create_initial_epsf", "(", "self", ",", "stars", ")", ":", "oversampling", "=", "self", ".", "oversampling", "shape", "=", "self", ".", "shape", "# define the ePSF shape", "if", "shape", "is", "not", "None", ":", "shape", "=", "np", ".", "atleast_1d...
Create an initial `EPSFModel` object. The initial ePSF data are all zeros. If ``shape`` is not specified, the shape of the ePSF data array is determined from the shape of the input ``stars`` and the oversampling factor. If the size is even along any axis, it will be made odd b...
[ "Create", "an", "initial", "EPSFModel", "object", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L382-L430
train
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._resample_residual
def _resample_residual(self, star, epsf): """ Compute a normalized residual image in the oversampled ePSF grid. A normalized residual image is calculated by subtracting the normalized ePSF model from the normalized star at the location of the star in the undersampled gri...
python
def _resample_residual(self, star, epsf): """ Compute a normalized residual image in the oversampled ePSF grid. A normalized residual image is calculated by subtracting the normalized ePSF model from the normalized star at the location of the star in the undersampled gri...
[ "def", "_resample_residual", "(", "self", ",", "star", ",", "epsf", ")", ":", "# find the integer index of EPSFStar pixels in the oversampled", "# ePSF grid", "x", "=", "epsf", ".", "_oversampling", "[", "0", "]", "*", "star", ".", "_xidx_centered", "y", "=", "eps...
Compute a normalized residual image in the oversampled ePSF grid. A normalized residual image is calculated by subtracting the normalized ePSF model from the normalized star at the location of the star in the undersampled grid. The normalized residual image is then resampled fr...
[ "Compute", "a", "normalized", "residual", "image", "in", "the", "oversampled", "ePSF", "grid", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L432-L484
train
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._resample_residuals
def _resample_residuals(self, stars, epsf): """ Compute normalized residual images for all the input stars. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object The ePSF model. Retu...
python
def _resample_residuals(self, stars, epsf): """ Compute normalized residual images for all the input stars. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object The ePSF model. Retu...
[ "def", "_resample_residuals", "(", "self", ",", "stars", ",", "epsf", ")", ":", "shape", "=", "(", "stars", ".", "n_good_stars", ",", "epsf", ".", "shape", "[", "0", "]", ",", "epsf", ".", "shape", "[", "1", "]", ")", "star_imgs", "=", "np", ".", ...
Compute normalized residual images for all the input stars. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object The ePSF model. Returns ------- star_imgs : 3D `~numpy.ndarray` ...
[ "Compute", "normalized", "residual", "images", "for", "all", "the", "input", "stars", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L486-L509
train
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._smooth_epsf
def _smooth_epsf(self, epsf_data): """ Smooth the ePSF array by convolving it with a kernel. Parameters ---------- epsf_data : 2D `~numpy.ndarray` A 2D array containing the ePSF image. Returns ------- result : 2D `~numpy.ndarray` ...
python
def _smooth_epsf(self, epsf_data): """ Smooth the ePSF array by convolving it with a kernel. Parameters ---------- epsf_data : 2D `~numpy.ndarray` A 2D array containing the ePSF image. Returns ------- result : 2D `~numpy.ndarray` ...
[ "def", "_smooth_epsf", "(", "self", ",", "epsf_data", ")", ":", "from", "scipy", ".", "ndimage", "import", "convolve", "if", "self", ".", "smoothing_kernel", "is", "None", ":", "return", "epsf_data", "elif", "self", ".", "smoothing_kernel", "==", "'quartic'", ...
Smooth the ePSF array by convolving it with a kernel. Parameters ---------- epsf_data : 2D `~numpy.ndarray` A 2D array containing the ePSF image. Returns ------- result : 2D `~numpy.ndarray` The smoothed (convolved) ePSF data.
[ "Smooth", "the", "ePSF", "array", "by", "convolving", "it", "with", "a", "kernel", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L511-L571
train
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._recenter_epsf
def _recenter_epsf(self, epsf_data, epsf, centroid_func=centroid_com, box_size=5, maxiters=20, center_accuracy=1.0e-4): """ Calculate the center of the ePSF data and shift the data so the ePSF center is at the center of the ePSF data array. Parameters ----...
python
def _recenter_epsf(self, epsf_data, epsf, centroid_func=centroid_com, box_size=5, maxiters=20, center_accuracy=1.0e-4): """ Calculate the center of the ePSF data and shift the data so the ePSF center is at the center of the ePSF data array. Parameters ----...
[ "def", "_recenter_epsf", "(", "self", ",", "epsf_data", ",", "epsf", ",", "centroid_func", "=", "centroid_com", ",", "box_size", "=", "5", ",", "maxiters", "=", "20", ",", "center_accuracy", "=", "1.0e-4", ")", ":", "# Define an EPSFModel for the input data. This...
Calculate the center of the ePSF data and shift the data so the ePSF center is at the center of the ePSF data array. Parameters ---------- epsf_data : 2D `~numpy.ndarray` A 2D array containing the ePSF image. epsf : `EPSFModel` object The ePSF model. ...
[ "Calculate", "the", "center", "of", "the", "ePSF", "data", "and", "shift", "the", "data", "so", "the", "ePSF", "center", "is", "at", "the", "center", "of", "the", "ePSF", "data", "array", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L573-L671
train
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder._build_epsf_step
def _build_epsf_step(self, stars, epsf=None): """ A single iteration of improving an ePSF. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object, optional The initial ePSF model. If not inpu...
python
def _build_epsf_step(self, stars, epsf=None): """ A single iteration of improving an ePSF. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object, optional The initial ePSF model. If not inpu...
[ "def", "_build_epsf_step", "(", "self", ",", "stars", ",", "epsf", "=", "None", ")", ":", "if", "len", "(", "stars", ")", "<", "1", ":", "raise", "ValueError", "(", "'stars must contain at least one EPSFStar or '", "'LinkedEPSFStar object.'", ")", "if", "epsf", ...
A single iteration of improving an ePSF. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. epsf : `EPSFModel` object, optional The initial ePSF model. If not input, then the ePSF will be built from scratch. ...
[ "A", "single", "iteration", "of", "improving", "an", "ePSF", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L673-L755
train
astropy/photutils
photutils/psf/epsf.py
EPSFBuilder.build_epsf
def build_epsf(self, stars, init_epsf=None): """ Iteratively build an ePSF from star cutouts. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. init_epsf : `EPSFModel` object, optional The initial ePSF model. If ...
python
def build_epsf(self, stars, init_epsf=None): """ Iteratively build an ePSF from star cutouts. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. init_epsf : `EPSFModel` object, optional The initial ePSF model. If ...
[ "def", "build_epsf", "(", "self", ",", "stars", ",", "init_epsf", "=", "None", ")", ":", "iter_num", "=", "0", "center_dist_sq", "=", "self", ".", "center_accuracy_sq", "+", "1.", "centers", "=", "stars", ".", "cutout_center_flat", "n_stars", "=", "stars", ...
Iteratively build an ePSF from star cutouts. Parameters ---------- stars : `EPSFStars` object The stars used to build the ePSF. init_epsf : `EPSFModel` object, optional The initial ePSF model. If not input, then the ePSF will be built from scratch. ...
[ "Iteratively", "build", "an", "ePSF", "from", "star", "cutouts", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/epsf.py#L757-L842
train
astropy/photutils
photutils/psf/models.py
FittableImageModel._set_oversampling
def _set_oversampling(self, value): """ This is a private method because it's used in the initializer by the ``oversampling`` """ try: value = np.atleast_1d(value).astype(float) if len(value) == 1: value = np.repeat(value, 2) excep...
python
def _set_oversampling(self, value): """ This is a private method because it's used in the initializer by the ``oversampling`` """ try: value = np.atleast_1d(value).astype(float) if len(value) == 1: value = np.repeat(value, 2) excep...
[ "def", "_set_oversampling", "(", "self", ",", "value", ")", ":", "try", ":", "value", "=", "np", ".", "atleast_1d", "(", "value", ")", ".", "astype", "(", "float", ")", "if", "len", "(", "value", ")", "==", "1", ":", "value", "=", "np", ".", "rep...
This is a private method because it's used in the initializer by the ``oversampling``
[ "This", "is", "a", "private", "method", "because", "it", "s", "used", "in", "the", "initializer", "by", "the", "oversampling" ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L234-L249
train
astropy/photutils
photutils/psf/models.py
FittableImageModel.evaluate
def evaluate(self, x, y, flux, x_0, y_0, use_oversampling=True): """ Evaluate the model on some input variables and provided model parameters. Parameters ---------- use_oversampling : bool, optional Whether to use the oversampling factor to calculate the ...
python
def evaluate(self, x, y, flux, x_0, y_0, use_oversampling=True): """ Evaluate the model on some input variables and provided model parameters. Parameters ---------- use_oversampling : bool, optional Whether to use the oversampling factor to calculate the ...
[ "def", "evaluate", "(", "self", ",", "x", ",", "y", ",", "flux", ",", "x_0", ",", "y_0", ",", "use_oversampling", "=", "True", ")", ":", "if", "use_oversampling", ":", "xi", "=", "self", ".", "_oversampling", "[", "0", "]", "*", "(", "np", ".", "...
Evaluate the model on some input variables and provided model parameters. Parameters ---------- use_oversampling : bool, optional Whether to use the oversampling factor to calculate the model pixel indices. The default is `True`, which means the inpu...
[ "Evaluate", "the", "model", "on", "some", "input", "variables", "and", "provided", "model", "parameters", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L453-L486
train
astropy/photutils
photutils/psf/models.py
GriddedPSFModel._find_bounds_1d
def _find_bounds_1d(data, x): """ Find the index of the lower bound where ``x`` should be inserted into ``a`` to maintain order. The index of the upper bound is the index of the lower bound plus 2. Both bound indices must be within the array. Parameters -------...
python
def _find_bounds_1d(data, x): """ Find the index of the lower bound where ``x`` should be inserted into ``a`` to maintain order. The index of the upper bound is the index of the lower bound plus 2. Both bound indices must be within the array. Parameters -------...
[ "def", "_find_bounds_1d", "(", "data", ",", "x", ")", ":", "idx", "=", "np", ".", "searchsorted", "(", "data", ",", "x", ")", "if", "idx", "==", "0", ":", "idx0", "=", "0", "elif", "idx", "==", "len", "(", "data", ")", ":", "# pragma: no cover", ...
Find the index of the lower bound where ``x`` should be inserted into ``a`` to maintain order. The index of the upper bound is the index of the lower bound plus 2. Both bound indices must be within the array. Parameters ---------- data : 1D `~numpy.ndarray` ...
[ "Find", "the", "index", "of", "the", "lower", "bound", "where", "x", "should", "be", "inserted", "into", "a", "to", "maintain", "order", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L582-L612
train
astropy/photutils
photutils/psf/models.py
GriddedPSFModel._bilinear_interp
def _bilinear_interp(xyref, zref, xi, yi): """ Perform bilinear interpolation of four 2D arrays located at points on a regular grid. Parameters ---------- xyref : list of 4 (x, y) pairs A list of 4 ``(x, y)`` pairs that form a rectangle. refdata : 3D...
python
def _bilinear_interp(xyref, zref, xi, yi): """ Perform bilinear interpolation of four 2D arrays located at points on a regular grid. Parameters ---------- xyref : list of 4 (x, y) pairs A list of 4 ``(x, y)`` pairs that form a rectangle. refdata : 3D...
[ "def", "_bilinear_interp", "(", "xyref", ",", "zref", ",", "xi", ",", "yi", ")", ":", "if", "len", "(", "xyref", ")", "!=", "4", ":", "raise", "ValueError", "(", "'xyref must contain only 4 (x, y) pairs'", ")", "if", "zref", ".", "shape", "[", "0", "]", ...
Perform bilinear interpolation of four 2D arrays located at points on a regular grid. Parameters ---------- xyref : list of 4 (x, y) pairs A list of 4 ``(x, y)`` pairs that form a rectangle. refdata : 3D `~numpy.ndarray` A 3D `~numpy.ndarray` of shape ``...
[ "Perform", "bilinear", "interpolation", "of", "four", "2D", "arrays", "located", "at", "points", "on", "a", "regular", "grid", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L651-L706
train
astropy/photutils
photutils/psf/models.py
GriddedPSFModel.evaluate
def evaluate(self, x, y, flux, x_0, y_0): """ Evaluate the `GriddedPSFModel` for the input parameters. """ # NOTE: this is needed because the PSF photometry routines input # length-1 values instead of scalars. TODO: fix the photometry # routines. if not np.issca...
python
def evaluate(self, x, y, flux, x_0, y_0): """ Evaluate the `GriddedPSFModel` for the input parameters. """ # NOTE: this is needed because the PSF photometry routines input # length-1 values instead of scalars. TODO: fix the photometry # routines. if not np.issca...
[ "def", "evaluate", "(", "self", ",", "x", ",", "y", ",", "flux", ",", "x_0", ",", "y_0", ")", ":", "# NOTE: this is needed because the PSF photometry routines input", "# length-1 values instead of scalars. TODO: fix the photometry", "# routines.", "if", "not", "np", ".",...
Evaluate the `GriddedPSFModel` for the input parameters.
[ "Evaluate", "the", "GriddedPSFModel", "for", "the", "input", "parameters", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L708-L742
train
astropy/photutils
photutils/psf/models.py
IntegratedGaussianPRF.evaluate
def evaluate(self, x, y, flux, x_0, y_0, sigma): """Model function Gaussian PSF model.""" return (flux / 4 * ((self._erf((x - x_0 + 0.5) / (np.sqrt(2) * sigma)) - self._erf((x - x_0 - 0.5) / (np.sqrt(2) * sigma))) * (self._erf((y - y_0 + 0.5) / (np.sqr...
python
def evaluate(self, x, y, flux, x_0, y_0, sigma): """Model function Gaussian PSF model.""" return (flux / 4 * ((self._erf((x - x_0 + 0.5) / (np.sqrt(2) * sigma)) - self._erf((x - x_0 - 0.5) / (np.sqrt(2) * sigma))) * (self._erf((y - y_0 + 0.5) / (np.sqr...
[ "def", "evaluate", "(", "self", ",", "x", ",", "y", ",", "flux", ",", "x_0", ",", "y_0", ",", "sigma", ")", ":", "return", "(", "flux", "/", "4", "*", "(", "(", "self", ".", "_erf", "(", "(", "x", "-", "x_0", "+", "0.5", ")", "/", "(", "n...
Model function Gaussian PSF model.
[ "Model", "function", "Gaussian", "PSF", "model", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L819-L826
train
astropy/photutils
photutils/psf/models.py
PRFAdapter.evaluate
def evaluate(self, x, y, flux, x_0, y_0): """The evaluation function for PRFAdapter.""" if self.xname is None: dx = x - x_0 else: dx = x setattr(self.psfmodel, self.xname, x_0) if self.xname is None: dy = y - y_0 else: ...
python
def evaluate(self, x, y, flux, x_0, y_0): """The evaluation function for PRFAdapter.""" if self.xname is None: dx = x - x_0 else: dx = x setattr(self.psfmodel, self.xname, x_0) if self.xname is None: dy = y - y_0 else: ...
[ "def", "evaluate", "(", "self", ",", "x", ",", "y", ",", "flux", ",", "x_0", ",", "y_0", ")", ":", "if", "self", ".", "xname", "is", "None", ":", "dx", "=", "x", "-", "x_0", "else", ":", "dx", "=", "x", "setattr", "(", "self", ".", "psfmodel"...
The evaluation function for PRFAdapter.
[ "The", "evaluation", "function", "for", "PRFAdapter", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/models.py#L895-L915
train
astropy/photutils
photutils/isophote/isophote.py
_isophote_list_to_table
def _isophote_list_to_table(isophote_list): """ Convert an `~photutils.isophote.IsophoteList` instance to a `~astropy.table.QTable`. Parameters ---------- isophote_list : list of `~photutils.isophote.Isophote` or a `~photutils.isophote.IsophoteList` instance A list of isophotes. Re...
python
def _isophote_list_to_table(isophote_list): """ Convert an `~photutils.isophote.IsophoteList` instance to a `~astropy.table.QTable`. Parameters ---------- isophote_list : list of `~photutils.isophote.Isophote` or a `~photutils.isophote.IsophoteList` instance A list of isophotes. Re...
[ "def", "_isophote_list_to_table", "(", "isophote_list", ")", ":", "properties", "=", "OrderedDict", "(", ")", "properties", "[", "'sma'", "]", "=", "'sma'", "properties", "[", "'intens'", "]", "=", "'intens'", "properties", "[", "'int_err'", "]", "=", "'intens...
Convert an `~photutils.isophote.IsophoteList` instance to a `~astropy.table.QTable`. Parameters ---------- isophote_list : list of `~photutils.isophote.Isophote` or a `~photutils.isophote.IsophoteList` instance A list of isophotes. Returns ------- result : `~astropy.table.QTable` ...
[ "Convert", "an", "~photutils", ".", "isophote", ".", "IsophoteList", "instance", "to", "a", "~astropy", ".", "table", ".", "QTable", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L730-L768
train
astropy/photutils
photutils/isophote/isophote.py
Isophote._compute_fluxes
def _compute_fluxes(self): """ Compute integrated flux inside ellipse, as well as inside a circle defined with the same semimajor axis. Pixels in a square section enclosing circle are scanned; the distance of each pixel to the isophote center is compared both with the se...
python
def _compute_fluxes(self): """ Compute integrated flux inside ellipse, as well as inside a circle defined with the same semimajor axis. Pixels in a square section enclosing circle are scanned; the distance of each pixel to the isophote center is compared both with the se...
[ "def", "_compute_fluxes", "(", "self", ")", ":", "# Compute limits of square array that encloses circle.", "sma", "=", "self", ".", "sample", ".", "geometry", ".", "sma", "x0", "=", "self", ".", "sample", ".", "geometry", ".", "x0", "y0", "=", "self", ".", "...
Compute integrated flux inside ellipse, as well as inside a circle defined with the same semimajor axis. Pixels in a square section enclosing circle are scanned; the distance of each pixel to the isophote center is compared both with the semimajor axis length and with the length of the ...
[ "Compute", "integrated", "flux", "inside", "ellipse", "as", "well", "as", "inside", "a", "circle", "defined", "with", "the", "same", "semimajor", "axis", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L176-L221
train
astropy/photutils
photutils/isophote/isophote.py
Isophote._compute_deviations
def _compute_deviations(self, sample, n): """ Compute deviations from a perfect ellipse, based on the amplitudes and errors for harmonic "n". Note that we first subtract the first and second harmonics from the raw data. """ try: coeffs = fit_first_and_second_...
python
def _compute_deviations(self, sample, n): """ Compute deviations from a perfect ellipse, based on the amplitudes and errors for harmonic "n". Note that we first subtract the first and second harmonics from the raw data. """ try: coeffs = fit_first_and_second_...
[ "def", "_compute_deviations", "(", "self", ",", "sample", ",", "n", ")", ":", "try", ":", "coeffs", "=", "fit_first_and_second_harmonics", "(", "self", ".", "sample", ".", "values", "[", "0", "]", ",", "self", ".", "sample", ".", "values", "[", "2", "]...
Compute deviations from a perfect ellipse, based on the amplitudes and errors for harmonic "n". Note that we first subtract the first and second harmonics from the raw data.
[ "Compute", "deviations", "from", "a", "perfect", "ellipse", "based", "on", "the", "amplitudes", "and", "errors", "for", "harmonic", "n", ".", "Note", "that", "we", "first", "subtract", "the", "first", "and", "second", "harmonics", "from", "the", "raw", "data...
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L223-L257
train
astropy/photutils
photutils/isophote/isophote.py
Isophote._compute_errors
def _compute_errors(self): """ Compute parameter errors based on the diagonal of the covariance matrix of the four harmonic coefficients for harmonics n=1 and n=2. """ try: coeffs = fit_first_and_second_harmonics(self.sample.values[0], ...
python
def _compute_errors(self): """ Compute parameter errors based on the diagonal of the covariance matrix of the four harmonic coefficients for harmonics n=1 and n=2. """ try: coeffs = fit_first_and_second_harmonics(self.sample.values[0], ...
[ "def", "_compute_errors", "(", "self", ")", ":", "try", ":", "coeffs", "=", "fit_first_and_second_harmonics", "(", "self", ".", "sample", ".", "values", "[", "0", "]", ",", "self", ".", "sample", ".", "values", "[", "2", "]", ")", "covariance", "=", "c...
Compute parameter errors based on the diagonal of the covariance matrix of the four harmonic coefficients for harmonics n=1 and n=2.
[ "Compute", "parameter", "errors", "based", "on", "the", "diagonal", "of", "the", "covariance", "matrix", "of", "the", "four", "harmonic", "coefficients", "for", "harmonics", "n", "=", "1", "and", "n", "=", "2", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L259-L295
train
astropy/photutils
photutils/isophote/isophote.py
Isophote.fix_geometry
def fix_geometry(self, isophote): """ Fix the geometry of a problematic isophote to be identical to the input isophote. This method should be called when the fitting goes berserk and delivers an isophote with bad geometry, such as ellipticity > 1 or another meaningless s...
python
def fix_geometry(self, isophote): """ Fix the geometry of a problematic isophote to be identical to the input isophote. This method should be called when the fitting goes berserk and delivers an isophote with bad geometry, such as ellipticity > 1 or another meaningless s...
[ "def", "fix_geometry", "(", "self", ",", "isophote", ")", ":", "self", ".", "sample", ".", "geometry", ".", "eps", "=", "isophote", ".", "sample", ".", "geometry", ".", "eps", "self", ".", "sample", ".", "geometry", ".", "pa", "=", "isophote", ".", "...
Fix the geometry of a problematic isophote to be identical to the input isophote. This method should be called when the fitting goes berserk and delivers an isophote with bad geometry, such as ellipticity > 1 or another meaningless situation. This is not a problem in itself when...
[ "Fix", "the", "geometry", "of", "a", "problematic", "isophote", "to", "be", "identical", "to", "the", "input", "isophote", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L297-L318
train
astropy/photutils
photutils/isophote/isophote.py
IsophoteList.get_closest
def get_closest(self, sma): """ Return the `~photutils.isophote.Isophote` instance that has the closest semimajor axis length to the input semimajor axis. Parameters ---------- sma : float The semimajor axis length. Returns ------- is...
python
def get_closest(self, sma): """ Return the `~photutils.isophote.Isophote` instance that has the closest semimajor axis length to the input semimajor axis. Parameters ---------- sma : float The semimajor axis length. Returns ------- is...
[ "def", "get_closest", "(", "self", ",", "sma", ")", ":", "index", "=", "(", "np", ".", "abs", "(", "self", ".", "sma", "-", "sma", ")", ")", ".", "argmin", "(", ")", "return", "self", ".", "_list", "[", "index", "]" ]
Return the `~photutils.isophote.Isophote` instance that has the closest semimajor axis length to the input semimajor axis. Parameters ---------- sma : float The semimajor axis length. Returns ------- isophote : `~photutils.isophote.Isophote` instance...
[ "Return", "the", "~photutils", ".", "isophote", ".", "Isophote", "instance", "that", "has", "the", "closest", "semimajor", "axis", "length", "to", "the", "input", "semimajor", "axis", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/isophote/isophote.py#L468-L485
train
astropy/photutils
photutils/utils/interpolation.py
interpolate_masked_data
def interpolate_masked_data(data, mask, error=None, background=None): """ Interpolate over masked pixels in data and optional error or background images. The value of masked pixels are replaced by the mean value of the connected neighboring non-masked pixels. This function is intended for sing...
python
def interpolate_masked_data(data, mask, error=None, background=None): """ Interpolate over masked pixels in data and optional error or background images. The value of masked pixels are replaced by the mean value of the connected neighboring non-masked pixels. This function is intended for sing...
[ "def", "interpolate_masked_data", "(", "data", ",", "mask", ",", "error", "=", "None", ",", "background", "=", "None", ")", ":", "if", "data", ".", "shape", "!=", "mask", ".", "shape", ":", "raise", "ValueError", "(", "'data and mask must have the same shape'"...
Interpolate over masked pixels in data and optional error or background images. The value of masked pixels are replaced by the mean value of the connected neighboring non-masked pixels. This function is intended for single, isolated masked pixels (e.g. hot/warm pixels). Parameters ---------- ...
[ "Interpolate", "over", "masked", "pixels", "in", "data", "and", "optional", "error", "or", "background", "images", "." ]
cc9bb4534ab76bac98cb5f374a348a2573d10401
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/utils/interpolation.py#L289-L370
train
google/pyringe
pyringe/plugins/inject_sentinel.py
SentinelInjectPlugin.ThreadsWithRunningExecServers
def ThreadsWithRunningExecServers(self): """Returns a list of tids of inferior threads with open exec servers.""" socket_dir = '/tmp/pyringe_%s' % self.inferior.pid if os.path.isdir(socket_dir): return [int(fname[:-9]) for fname in os.listdir(socket_dir) if fname.endswith('...
python
def ThreadsWithRunningExecServers(self): """Returns a list of tids of inferior threads with open exec servers.""" socket_dir = '/tmp/pyringe_%s' % self.inferior.pid if os.path.isdir(socket_dir): return [int(fname[:-9]) for fname in os.listdir(socket_dir) if fname.endswith('...
[ "def", "ThreadsWithRunningExecServers", "(", "self", ")", ":", "socket_dir", "=", "'/tmp/pyringe_%s'", "%", "self", ".", "inferior", ".", "pid", "if", "os", ".", "path", ".", "isdir", "(", "socket_dir", ")", ":", "return", "[", "int", "(", "fname", "[", ...
Returns a list of tids of inferior threads with open exec servers.
[ "Returns", "a", "list", "of", "tids", "of", "inferior", "threads", "with", "open", "exec", "servers", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/inject_sentinel.py#L46-L53
train
google/pyringe
pyringe/plugins/inject_sentinel.py
SentinelInjectPlugin.SendToExecSocket
def SendToExecSocket(self, code, tid=None): """Inject python code into exec socket.""" response = self._SendToExecSocketRaw(json.dumps(code), tid) return json.loads(response)
python
def SendToExecSocket(self, code, tid=None): """Inject python code into exec socket.""" response = self._SendToExecSocketRaw(json.dumps(code), tid) return json.loads(response)
[ "def", "SendToExecSocket", "(", "self", ",", "code", ",", "tid", "=", "None", ")", ":", "response", "=", "self", ".", "_SendToExecSocketRaw", "(", "json", ".", "dumps", "(", "code", ")", ",", "tid", ")", "return", "json", ".", "loads", "(", "response",...
Inject python code into exec socket.
[ "Inject", "python", "code", "into", "exec", "socket", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/inject_sentinel.py#L55-L58
train
google/pyringe
pyringe/plugins/inject_sentinel.py
SentinelInjectPlugin.CloseExecSocket
def CloseExecSocket(self, tid=None): """Send closing request to exec socket.""" response = self._SendToExecSocketRaw('__kill__', tid) if response != '__kill_ack__': logging.warning('May not have succeeded in closing socket, make sure ' 'using execsocks().')
python
def CloseExecSocket(self, tid=None): """Send closing request to exec socket.""" response = self._SendToExecSocketRaw('__kill__', tid) if response != '__kill_ack__': logging.warning('May not have succeeded in closing socket, make sure ' 'using execsocks().')
[ "def", "CloseExecSocket", "(", "self", ",", "tid", "=", "None", ")", ":", "response", "=", "self", ".", "_SendToExecSocketRaw", "(", "'__kill__'", ",", "tid", ")", "if", "response", "!=", "'__kill_ack__'", ":", "logging", ".", "warning", "(", "'May not have ...
Send closing request to exec socket.
[ "Send", "closing", "request", "to", "exec", "socket", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/inject_sentinel.py#L79-L84
train
google/pyringe
pyringe/plugins/read_only.py
ReadonlyPlugin.Backtrace
def Backtrace(self, to_string=False): """Get a backtrace of the current position.""" if self.inferior.is_running: res = self.inferior.Backtrace() if to_string: return res print res else: logging.error('Not attached to any process.')
python
def Backtrace(self, to_string=False): """Get a backtrace of the current position.""" if self.inferior.is_running: res = self.inferior.Backtrace() if to_string: return res print res else: logging.error('Not attached to any process.')
[ "def", "Backtrace", "(", "self", ",", "to_string", "=", "False", ")", ":", "if", "self", ".", "inferior", ".", "is_running", ":", "res", "=", "self", ".", "inferior", ".", "Backtrace", "(", ")", "if", "to_string", ":", "return", "res", "print", "res", ...
Get a backtrace of the current position.
[ "Get", "a", "backtrace", "of", "the", "current", "position", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/read_only.py#L52-L60
train
google/pyringe
pyringe/plugins/read_only.py
ReadonlyPlugin.ListThreads
def ListThreads(self): """List the currently running python threads. Returns: A list of the inferior's thread idents, or None if the debugger is not attached to any process. """ if self.inferior.is_running: return self.inferior.threads logging.error('Not attached to any process.')...
python
def ListThreads(self): """List the currently running python threads. Returns: A list of the inferior's thread idents, or None if the debugger is not attached to any process. """ if self.inferior.is_running: return self.inferior.threads logging.error('Not attached to any process.')...
[ "def", "ListThreads", "(", "self", ")", ":", "if", "self", ".", "inferior", ".", "is_running", ":", "return", "self", ".", "inferior", ".", "threads", "logging", ".", "error", "(", "'Not attached to any process.'", ")", "return", "[", "]" ]
List the currently running python threads. Returns: A list of the inferior's thread idents, or None if the debugger is not attached to any process.
[ "List", "the", "currently", "running", "python", "threads", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/read_only.py#L86-L96
train
google/pyringe
pyringe/payload/gdb_service.py
PyFrameObjectPtr.extract_filename
def extract_filename(self): """Alternative way of getting the executed file which inspects globals.""" globals_gdbval = self._gdbval['f_globals'].cast(GdbCache.DICT) global_dict = libpython.PyDictObjectPtr(globals_gdbval) for key, value in global_dict.iteritems(): if str(key.proxyval(set())) == '_...
python
def extract_filename(self): """Alternative way of getting the executed file which inspects globals.""" globals_gdbval = self._gdbval['f_globals'].cast(GdbCache.DICT) global_dict = libpython.PyDictObjectPtr(globals_gdbval) for key, value in global_dict.iteritems(): if str(key.proxyval(set())) == '_...
[ "def", "extract_filename", "(", "self", ")", ":", "globals_gdbval", "=", "self", ".", "_gdbval", "[", "'f_globals'", "]", ".", "cast", "(", "GdbCache", ".", "DICT", ")", "global_dict", "=", "libpython", ".", "PyDictObjectPtr", "(", "globals_gdbval", ")", "fo...
Alternative way of getting the executed file which inspects globals.
[ "Alternative", "way", "of", "getting", "the", "executed", "file", "which", "inspects", "globals", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L157-L163
train
google/pyringe
pyringe/payload/gdb_service.py
GdbService._UnserializableObjectFallback
def _UnserializableObjectFallback(self, obj): """Handles sanitizing of unserializable objects for Json. For instances of heap types, we take the class dict, augment it with the instance's __dict__, tag it and transmit it over to the RPC client to be reconstructed there. (Works with both old and new sty...
python
def _UnserializableObjectFallback(self, obj): """Handles sanitizing of unserializable objects for Json. For instances of heap types, we take the class dict, augment it with the instance's __dict__, tag it and transmit it over to the RPC client to be reconstructed there. (Works with both old and new sty...
[ "def", "_UnserializableObjectFallback", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "libpython", ".", "PyInstanceObjectPtr", ")", ":", "# old-style classes use 'classobj'/'instance'", "# get class attribute dictionary", "in_class", "=", "obj", ...
Handles sanitizing of unserializable objects for Json. For instances of heap types, we take the class dict, augment it with the instance's __dict__, tag it and transmit it over to the RPC client to be reconstructed there. (Works with both old and new style classes) Args: obj: The object to Json-s...
[ "Handles", "sanitizing", "of", "unserializable", "objects", "for", "Json", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L208-L271
train
google/pyringe
pyringe/payload/gdb_service.py
GdbService._AcceptRPC
def _AcceptRPC(self): """Reads RPC request from stdin and processes it, writing result to stdout. Returns: True as long as execution is to be continued, False otherwise. Raises: RpcException: if no function was specified in the RPC or no such API function exists. """ request =...
python
def _AcceptRPC(self): """Reads RPC request from stdin and processes it, writing result to stdout. Returns: True as long as execution is to be continued, False otherwise. Raises: RpcException: if no function was specified in the RPC or no such API function exists. """ request =...
[ "def", "_AcceptRPC", "(", "self", ")", ":", "request", "=", "self", ".", "_ReadObject", "(", ")", "if", "request", "[", "'func'", "]", "==", "'__kill__'", ":", "self", ".", "ClearBreakpoints", "(", ")", "self", ".", "_WriteObject", "(", "'__kill_ack__'", ...
Reads RPC request from stdin and processes it, writing result to stdout. Returns: True as long as execution is to be continued, False otherwise. Raises: RpcException: if no function was specified in the RPC or no such API function exists.
[ "Reads", "RPC", "request", "from", "stdin", "and", "processes", "it", "writing", "result", "to", "stdout", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L293-L311
train
google/pyringe
pyringe/payload/gdb_service.py
GdbService._UnpackGdbVal
def _UnpackGdbVal(self, gdb_value): """Unpacks gdb.Value objects and returns the best-matched python object.""" val_type = gdb_value.type.code if val_type == gdb.TYPE_CODE_INT or val_type == gdb.TYPE_CODE_ENUM: return int(gdb_value) if val_type == gdb.TYPE_CODE_VOID: return None if val_t...
python
def _UnpackGdbVal(self, gdb_value): """Unpacks gdb.Value objects and returns the best-matched python object.""" val_type = gdb_value.type.code if val_type == gdb.TYPE_CODE_INT or val_type == gdb.TYPE_CODE_ENUM: return int(gdb_value) if val_type == gdb.TYPE_CODE_VOID: return None if val_t...
[ "def", "_UnpackGdbVal", "(", "self", ",", "gdb_value", ")", ":", "val_type", "=", "gdb_value", ".", "type", ".", "code", "if", "val_type", "==", "gdb", ".", "TYPE_CODE_INT", "or", "val_type", "==", "gdb", ".", "TYPE_CODE_ENUM", ":", "return", "int", "(", ...
Unpacks gdb.Value objects and returns the best-matched python object.
[ "Unpacks", "gdb", ".", "Value", "objects", "and", "returns", "the", "best", "-", "matched", "python", "object", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L313-L326
train
google/pyringe
pyringe/payload/gdb_service.py
GdbService.EnsureGdbPosition
def EnsureGdbPosition(self, pid, tid, frame_depth): """Make sure our position matches the request. Args: pid: The process ID of the target process tid: The python thread ident of the target thread frame_depth: The 'depth' of the requested frame in the frame stack Raises: PositionUna...
python
def EnsureGdbPosition(self, pid, tid, frame_depth): """Make sure our position matches the request. Args: pid: The process ID of the target process tid: The python thread ident of the target thread frame_depth: The 'depth' of the requested frame in the frame stack Raises: PositionUna...
[ "def", "EnsureGdbPosition", "(", "self", ",", "pid", ",", "tid", ",", "frame_depth", ")", ":", "position", "=", "[", "pid", ",", "tid", ",", "frame_depth", "]", "if", "not", "pid", ":", "return", "if", "not", "self", ".", "IsAttached", "(", ")", ":",...
Make sure our position matches the request. Args: pid: The process ID of the target process tid: The python thread ident of the target thread frame_depth: The 'depth' of the requested frame in the frame stack Raises: PositionUnavailableException: If the requested process, thread or fram...
[ "Make", "sure", "our", "position", "matches", "the", "request", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L335-L378
train
google/pyringe
pyringe/payload/gdb_service.py
GdbService.IsSymbolFileSane
def IsSymbolFileSane(self, position): """Performs basic sanity check by trying to look up a bunch of symbols.""" pos = [position[0], None, None] self.EnsureGdbPosition(*pos) try: if GdbCache.DICT and GdbCache.TYPE and GdbCache.INTERP_HEAD: # pylint: disable=pointless-statement tsta...
python
def IsSymbolFileSane(self, position): """Performs basic sanity check by trying to look up a bunch of symbols.""" pos = [position[0], None, None] self.EnsureGdbPosition(*pos) try: if GdbCache.DICT and GdbCache.TYPE and GdbCache.INTERP_HEAD: # pylint: disable=pointless-statement tsta...
[ "def", "IsSymbolFileSane", "(", "self", ",", "position", ")", ":", "pos", "=", "[", "position", "[", "0", "]", ",", "None", ",", "None", "]", "self", ".", "EnsureGdbPosition", "(", "*", "pos", ")", "try", ":", "if", "GdbCache", ".", "DICT", "and", ...
Performs basic sanity check by trying to look up a bunch of symbols.
[ "Performs", "basic", "sanity", "check", "by", "trying", "to", "look", "up", "a", "bunch", "of", "symbols", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L392-L433
train
google/pyringe
pyringe/payload/gdb_service.py
GdbService.Detach
def Detach(self): """Detaches from the inferior. If not attached, this is a no-op.""" # We have to work around the python APIs weirdness :\ if not self.IsAttached(): return None # Gdb doesn't drain any pending SIGINTs it may have sent to the inferior # when it simply detaches. We can do this b...
python
def Detach(self): """Detaches from the inferior. If not attached, this is a no-op.""" # We have to work around the python APIs weirdness :\ if not self.IsAttached(): return None # Gdb doesn't drain any pending SIGINTs it may have sent to the inferior # when it simply detaches. We can do this b...
[ "def", "Detach", "(", "self", ")", ":", "# We have to work around the python APIs weirdness :\\", "if", "not", "self", ".", "IsAttached", "(", ")", ":", "return", "None", "# Gdb doesn't drain any pending SIGINTs it may have sent to the inferior", "# when it simply detaches. We ca...
Detaches from the inferior. If not attached, this is a no-op.
[ "Detaches", "from", "the", "inferior", ".", "If", "not", "attached", "this", "is", "a", "no", "-", "op", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L449-L467
train
google/pyringe
pyringe/payload/gdb_service.py
GdbService.Call
def Call(self, position, function_call): """Perform a function call in the inferior. WARNING: Since Gdb's concept of threads can't be directly identified with python threads, the function call will be made from what has to be assumed is an arbitrary thread. This *will* interrupt the inferior. Continuin...
python
def Call(self, position, function_call): """Perform a function call in the inferior. WARNING: Since Gdb's concept of threads can't be directly identified with python threads, the function call will be made from what has to be assumed is an arbitrary thread. This *will* interrupt the inferior. Continuin...
[ "def", "Call", "(", "self", ",", "position", ",", "function_call", ")", ":", "self", ".", "EnsureGdbPosition", "(", "position", "[", "0", "]", ",", "None", ",", "None", ")", "if", "not", "gdb", ".", "selected_thread", "(", ")", ".", "is_stopped", "(", ...
Perform a function call in the inferior. WARNING: Since Gdb's concept of threads can't be directly identified with python threads, the function call will be made from what has to be assumed is an arbitrary thread. This *will* interrupt the inferior. Continuing it after the call is the responsibility of...
[ "Perform", "a", "function", "call", "in", "the", "inferior", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L492-L511
train
google/pyringe
pyringe/payload/gdb_service.py
GdbService.ExecuteRaw
def ExecuteRaw(self, position, command): """Send a command string to gdb.""" self.EnsureGdbPosition(position[0], None, None) return gdb.execute(command, to_string=True)
python
def ExecuteRaw(self, position, command): """Send a command string to gdb.""" self.EnsureGdbPosition(position[0], None, None) return gdb.execute(command, to_string=True)
[ "def", "ExecuteRaw", "(", "self", ",", "position", ",", "command", ")", ":", "self", ".", "EnsureGdbPosition", "(", "position", "[", "0", "]", ",", "None", ",", "None", ")", "return", "gdb", ".", "execute", "(", "command", ",", "to_string", "=", "True"...
Send a command string to gdb.
[ "Send", "a", "command", "string", "to", "gdb", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L513-L516
train
google/pyringe
pyringe/payload/gdb_service.py
GdbService._GetGdbThreadMapping
def _GetGdbThreadMapping(self, position): """Gets a mapping from python tid to gdb thread num. There's no way to get the thread ident from a gdb thread. We only get the "ID of the thread, as assigned by GDB", which is completely useless for everything except talking to gdb. So in order to translate b...
python
def _GetGdbThreadMapping(self, position): """Gets a mapping from python tid to gdb thread num. There's no way to get the thread ident from a gdb thread. We only get the "ID of the thread, as assigned by GDB", which is completely useless for everything except talking to gdb. So in order to translate b...
[ "def", "_GetGdbThreadMapping", "(", "self", ",", "position", ")", ":", "if", "len", "(", "gdb", ".", "selected_inferior", "(", ")", ".", "threads", "(", ")", ")", "==", "1", ":", "# gdb's output for info threads changes and only displays PID. We cheat.", "return", ...
Gets a mapping from python tid to gdb thread num. There's no way to get the thread ident from a gdb thread. We only get the "ID of the thread, as assigned by GDB", which is completely useless for everything except talking to gdb. So in order to translate between these two, we have to execute 'info th...
[ "Gets", "a", "mapping", "from", "python", "tid", "to", "gdb", "thread", "num", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L518-L545
train
google/pyringe
pyringe/payload/gdb_service.py
GdbService._Inject
def _Inject(self, position, call): """Injects evaluation of 'call' in a safe location in the inferior. Due to the way these injected function calls work, gdb must not be killed until the call has returned. If that happens, the inferior will be sent SIGTRAP upon attempting to return from the dummy frame...
python
def _Inject(self, position, call): """Injects evaluation of 'call' in a safe location in the inferior. Due to the way these injected function calls work, gdb must not be killed until the call has returned. If that happens, the inferior will be sent SIGTRAP upon attempting to return from the dummy frame...
[ "def", "_Inject", "(", "self", ",", "position", ",", "call", ")", ":", "self", ".", "EnsureGdbPosition", "(", "position", "[", "0", "]", ",", "position", "[", "1", "]", ",", "None", ")", "self", ".", "ClearBreakpoints", "(", ")", "self", ".", "_AddTh...
Injects evaluation of 'call' in a safe location in the inferior. Due to the way these injected function calls work, gdb must not be killed until the call has returned. If that happens, the inferior will be sent SIGTRAP upon attempting to return from the dummy frame gdb constructs for us, and will most ...
[ "Injects", "evaluation", "of", "call", "in", "a", "safe", "location", "in", "the", "inferior", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L557-L587
train
google/pyringe
pyringe/payload/gdb_service.py
GdbService._BacktraceFromFramePtr
def _BacktraceFromFramePtr(self, frame_ptr): """Assembles and returns what looks exactly like python's backtraces.""" # expects frame_ptr to be a gdb.Value frame_objs = [PyFrameObjectPtr(frame) for frame in self._IterateChainedList(frame_ptr, 'f_back')] # We want to output tracebacks ...
python
def _BacktraceFromFramePtr(self, frame_ptr): """Assembles and returns what looks exactly like python's backtraces.""" # expects frame_ptr to be a gdb.Value frame_objs = [PyFrameObjectPtr(frame) for frame in self._IterateChainedList(frame_ptr, 'f_back')] # We want to output tracebacks ...
[ "def", "_BacktraceFromFramePtr", "(", "self", ",", "frame_ptr", ")", ":", "# expects frame_ptr to be a gdb.Value", "frame_objs", "=", "[", "PyFrameObjectPtr", "(", "frame", ")", "for", "frame", "in", "self", ".", "_IterateChainedList", "(", "frame_ptr", ",", "'f_bac...
Assembles and returns what looks exactly like python's backtraces.
[ "Assembles", "and", "returns", "what", "looks", "exactly", "like", "python", "s", "backtraces", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/gdb_service.py#L597-L615
train
google/pyringe
pyringe/inferior.py
GdbProxy.Kill
def Kill(self): """Send death pill to Gdb and forcefully kill it if that doesn't work.""" try: if self.is_running: self.Detach() if self._Execute('__kill__') == '__kill_ack__': # acknowledged, let's give it some time to die in peace time.sleep(0.1) except (TimeoutError, P...
python
def Kill(self): """Send death pill to Gdb and forcefully kill it if that doesn't work.""" try: if self.is_running: self.Detach() if self._Execute('__kill__') == '__kill_ack__': # acknowledged, let's give it some time to die in peace time.sleep(0.1) except (TimeoutError, P...
[ "def", "Kill", "(", "self", ")", ":", "try", ":", "if", "self", ".", "is_running", ":", "self", ".", "Detach", "(", ")", "if", "self", ".", "_Execute", "(", "'__kill__'", ")", "==", "'__kill_ack__'", ":", "# acknowledged, let's give it some time to die in peac...
Send death pill to Gdb and forcefully kill it if that doesn't work.
[ "Send", "death", "pill", "to", "Gdb", "and", "forcefully", "kill", "it", "if", "that", "doesn", "t", "work", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L202-L222
train
google/pyringe
pyringe/inferior.py
GdbProxy.Version
def Version(): """Gets the version of gdb as a 3-tuple. The gdb devs seem to think it's a good idea to make --version output multiple lines of welcome text instead of just the actual version, so we ignore everything it outputs after the first line. Returns: The installed version of gdb in the...
python
def Version(): """Gets the version of gdb as a 3-tuple. The gdb devs seem to think it's a good idea to make --version output multiple lines of welcome text instead of just the actual version, so we ignore everything it outputs after the first line. Returns: The installed version of gdb in the...
[ "def", "Version", "(", ")", ":", "output", "=", "subprocess", ".", "check_output", "(", "[", "'gdb'", ",", "'--version'", "]", ")", ".", "split", "(", "'\\n'", ")", "[", "0", "]", "# Example output (Arch linux):", "# GNU gdb (GDB) 7.7", "# Example output (Debian...
Gets the version of gdb as a 3-tuple. The gdb devs seem to think it's a good idea to make --version output multiple lines of welcome text instead of just the actual version, so we ignore everything it outputs after the first line. Returns: The installed version of gdb in the form (<major>, ...
[ "Gets", "the", "version", "of", "gdb", "as", "a", "3", "-", "tuple", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L229-L272
train
google/pyringe
pyringe/inferior.py
GdbProxy._JsonDecodeDict
def _JsonDecodeDict(self, data): """Json object decode hook that automatically converts unicode objects.""" rv = {} for key, value in data.iteritems(): if isinstance(key, unicode): key = self._TryStr(key) if isinstance(value, unicode): value = self._TryStr(value) elif isins...
python
def _JsonDecodeDict(self, data): """Json object decode hook that automatically converts unicode objects.""" rv = {} for key, value in data.iteritems(): if isinstance(key, unicode): key = self._TryStr(key) if isinstance(value, unicode): value = self._TryStr(value) elif isins...
[ "def", "_JsonDecodeDict", "(", "self", ",", "data", ")", ":", "rv", "=", "{", "}", "for", "key", ",", "value", "in", "data", ".", "iteritems", "(", ")", ":", "if", "isinstance", "(", "key", ",", "unicode", ")", ":", "key", "=", "self", ".", "_Try...
Json object decode hook that automatically converts unicode objects.
[ "Json", "object", "decode", "hook", "that", "automatically", "converts", "unicode", "objects", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L305-L319
train
google/pyringe
pyringe/inferior.py
GdbProxy._Execute
def _Execute(self, funcname, *args, **kwargs): """Send an RPC request to the gdb-internal python. Blocks for 3 seconds by default and returns any results. Args: funcname: the name of the function to call. *args: the function's arguments. **kwargs: Only the key 'wait_for_completion' is ins...
python
def _Execute(self, funcname, *args, **kwargs): """Send an RPC request to the gdb-internal python. Blocks for 3 seconds by default and returns any results. Args: funcname: the name of the function to call. *args: the function's arguments. **kwargs: Only the key 'wait_for_completion' is ins...
[ "def", "_Execute", "(", "self", ",", "funcname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "wait_for_completion", "=", "kwargs", ".", "get", "(", "'wait_for_completion'", ",", "False", ")", "rpc_dict", "=", "{", "'func'", ":", "funcname", ",",...
Send an RPC request to the gdb-internal python. Blocks for 3 seconds by default and returns any results. Args: funcname: the name of the function to call. *args: the function's arguments. **kwargs: Only the key 'wait_for_completion' is inspected, which decides whether to wait forever ...
[ "Send", "an", "RPC", "request", "to", "the", "gdb", "-", "internal", "python", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L325-L355
train
google/pyringe
pyringe/inferior.py
GdbProxy._Recv
def _Recv(self, timeout): """Receive output from gdb. This reads gdb's stdout and stderr streams, returns a single line of gdb's stdout or rethrows any exceptions thrown from within gdb as well as it can. Args: timeout: floating point number of seconds after which to abort. A value of ...
python
def _Recv(self, timeout): """Receive output from gdb. This reads gdb's stdout and stderr streams, returns a single line of gdb's stdout or rethrows any exceptions thrown from within gdb as well as it can. Args: timeout: floating point number of seconds after which to abort. A value of ...
[ "def", "_Recv", "(", "self", ",", "timeout", ")", ":", "buf", "=", "''", "# The messiness of this stems from the \"duck-typiness\" of this function.", "# The timeout parameter of poll has different semantics depending on whether", "# it's <=0, >0, or None. Yay.", "wait_for_line", "=", ...
Receive output from gdb. This reads gdb's stdout and stderr streams, returns a single line of gdb's stdout or rethrows any exceptions thrown from within gdb as well as it can. Args: timeout: floating point number of seconds after which to abort. A value of None or TIMEOUT_FOREVER means "th...
[ "Receive", "output", "from", "gdb", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L361-L429
train
google/pyringe
pyringe/inferior.py
Inferior.needsattached
def needsattached(func): """Decorator to prevent commands from being used when not attached.""" @functools.wraps(func) def wrap(self, *args, **kwargs): if not self.attached: raise PositionError('Not attached to any process.') return func(self, *args, **kwargs) return wrap
python
def needsattached(func): """Decorator to prevent commands from being used when not attached.""" @functools.wraps(func) def wrap(self, *args, **kwargs): if not self.attached: raise PositionError('Not attached to any process.') return func(self, *args, **kwargs) return wrap
[ "def", "needsattached", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrap", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "attached", ":", "raise", "PositionError", "...
Decorator to prevent commands from being used when not attached.
[ "Decorator", "to", "prevent", "commands", "from", "being", "used", "when", "not", "attached", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L458-L466
train
google/pyringe
pyringe/inferior.py
Inferior.Reinit
def Reinit(self, pid, auto_symfile_loading=True): """Reinitializes the object with a new pid. Since all modes might need access to this object at any time, this object needs to be long-lived. To make this clear in the API, this shorthand is supplied. Args: pid: the pid of the target process ...
python
def Reinit(self, pid, auto_symfile_loading=True): """Reinitializes the object with a new pid. Since all modes might need access to this object at any time, this object needs to be long-lived. To make this clear in the API, this shorthand is supplied. Args: pid: the pid of the target process ...
[ "def", "Reinit", "(", "self", ",", "pid", ",", "auto_symfile_loading", "=", "True", ")", ":", "self", ".", "ShutDownGdb", "(", ")", "self", ".", "__init__", "(", "pid", ",", "auto_symfile_loading", ",", "architecture", "=", "self", ".", "arch", ")" ]
Reinitializes the object with a new pid. Since all modes might need access to this object at any time, this object needs to be long-lived. To make this clear in the API, this shorthand is supplied. Args: pid: the pid of the target process auto_symfile_loading: whether the symbol file should...
[ "Reinitializes", "the", "object", "with", "a", "new", "pid", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/inferior.py#L472-L484
train
google/pyringe
pyringe/plugins/inject.py
InjectPlugin.InjectString
def InjectString(self, codestring, wait_for_completion=True): """Try to inject python code into current thread. Args: codestring: Python snippet to execute in inferior. (may contain newlines) wait_for_completion: Block until execution of snippet has completed. """ if self.inferior.is_runnin...
python
def InjectString(self, codestring, wait_for_completion=True): """Try to inject python code into current thread. Args: codestring: Python snippet to execute in inferior. (may contain newlines) wait_for_completion: Block until execution of snippet has completed. """ if self.inferior.is_runnin...
[ "def", "InjectString", "(", "self", ",", "codestring", ",", "wait_for_completion", "=", "True", ")", ":", "if", "self", ".", "inferior", ".", "is_running", "and", "self", ".", "inferior", ".", "gdb", ".", "IsAttached", "(", ")", ":", "try", ":", "self", ...
Try to inject python code into current thread. Args: codestring: Python snippet to execute in inferior. (may contain newlines) wait_for_completion: Block until execution of snippet has completed.
[ "Try", "to", "inject", "python", "code", "into", "current", "thread", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/inject.py#L40-L57
train
google/pyringe
pyringe/payload/libpython.py
PyObjectPtr.field
def field(self, name): ''' Get the gdb.Value for the given field within the PyObject, coping with some python 2 versus python 3 differences. Various libpython types are defined using the "PyObject_HEAD" and "PyObject_VAR_HEAD" macros. In Python 2, this these are defined...
python
def field(self, name): ''' Get the gdb.Value for the given field within the PyObject, coping with some python 2 versus python 3 differences. Various libpython types are defined using the "PyObject_HEAD" and "PyObject_VAR_HEAD" macros. In Python 2, this these are defined...
[ "def", "field", "(", "self", ",", "name", ")", ":", "if", "self", ".", "is_null", "(", ")", ":", "raise", "NullPyObjectPtr", "(", "self", ")", "if", "name", "==", "'ob_type'", ":", "pyo_ptr", "=", "self", ".", "_gdbval", ".", "cast", "(", "PyObjectPt...
Get the gdb.Value for the given field within the PyObject, coping with some python 2 versus python 3 differences. Various libpython types are defined using the "PyObject_HEAD" and "PyObject_VAR_HEAD" macros. In Python 2, this these are defined so that "ob_type" and (for a var o...
[ "Get", "the", "gdb", ".", "Value", "for", "the", "given", "field", "within", "the", "PyObject", "coping", "with", "some", "python", "2", "versus", "python", "3", "differences", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L131-L163
train
google/pyringe
pyringe/payload/libpython.py
PyObjectPtr.write_repr
def write_repr(self, out, visited): ''' Write a string representation of the value scraped from the inferior process to "out", a file-like object. ''' # Default implementation: generate a proxy value and write its repr # However, this could involve a lot of work for compl...
python
def write_repr(self, out, visited): ''' Write a string representation of the value scraped from the inferior process to "out", a file-like object. ''' # Default implementation: generate a proxy value and write its repr # However, this could involve a lot of work for compl...
[ "def", "write_repr", "(", "self", ",", "out", ",", "visited", ")", ":", "# Default implementation: generate a proxy value and write its repr", "# However, this could involve a lot of work for complicated objects,", "# so for derived classes we specialize this", "return", "out", ".", ...
Write a string representation of the value scraped from the inferior process to "out", a file-like object.
[ "Write", "a", "string", "representation", "of", "the", "value", "scraped", "from", "the", "inferior", "process", "to", "out", "a", "file", "-", "like", "object", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L262-L270
train
google/pyringe
pyringe/payload/libpython.py
PyObjectPtr.from_pyobject_ptr
def from_pyobject_ptr(cls, gdbval): ''' Try to locate the appropriate derived class dynamically, and cast the pointer accordingly. ''' try: p = PyObjectPtr(gdbval) cls = cls.subclass_from_type(p.type()) return cls(gdbval, cast_to=cls.get_gdb_ty...
python
def from_pyobject_ptr(cls, gdbval): ''' Try to locate the appropriate derived class dynamically, and cast the pointer accordingly. ''' try: p = PyObjectPtr(gdbval) cls = cls.subclass_from_type(p.type()) return cls(gdbval, cast_to=cls.get_gdb_ty...
[ "def", "from_pyobject_ptr", "(", "cls", ",", "gdbval", ")", ":", "try", ":", "p", "=", "PyObjectPtr", "(", "gdbval", ")", "cls", "=", "cls", ".", "subclass_from_type", "(", "p", ".", "type", "(", ")", ")", "return", "cls", "(", "gdbval", ",", "cast_t...
Try to locate the appropriate derived class dynamically, and cast the pointer accordingly.
[ "Try", "to", "locate", "the", "appropriate", "derived", "class", "dynamically", "and", "cast", "the", "pointer", "accordingly", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L340-L353
train
google/pyringe
pyringe/payload/libpython.py
HeapTypeObjectPtr.proxyval
def proxyval(self, visited): ''' Support for new-style classes. Currently we just locate the dictionary using a transliteration to python of _PyObject_GetDictPtr, ignoring descriptors ''' # Guard against infinite loops: if self.as_address() in visited: ...
python
def proxyval(self, visited): ''' Support for new-style classes. Currently we just locate the dictionary using a transliteration to python of _PyObject_GetDictPtr, ignoring descriptors ''' # Guard against infinite loops: if self.as_address() in visited: ...
[ "def", "proxyval", "(", "self", ",", "visited", ")", ":", "# Guard against infinite loops:", "if", "self", ".", "as_address", "(", ")", "in", "visited", ":", "return", "ProxyAlreadyVisited", "(", "'<...>'", ")", "visited", ".", "add", "(", "self", ".", "as_a...
Support for new-style classes. Currently we just locate the dictionary using a transliteration to python of _PyObject_GetDictPtr, ignoring descriptors
[ "Support", "for", "new", "-", "style", "classes", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L459-L479
train
google/pyringe
pyringe/payload/libpython.py
PyCodeObjectPtr.addr2line
def addr2line(self, addrq): ''' Get the line number for a given bytecode offset Analogous to PyCode_Addr2Line; translated from pseudocode in Objects/lnotab_notes.txt ''' co_lnotab = self.pyop_field('co_lnotab').proxyval(set()) # Initialize lineno to co_firstline...
python
def addr2line(self, addrq): ''' Get the line number for a given bytecode offset Analogous to PyCode_Addr2Line; translated from pseudocode in Objects/lnotab_notes.txt ''' co_lnotab = self.pyop_field('co_lnotab').proxyval(set()) # Initialize lineno to co_firstline...
[ "def", "addr2line", "(", "self", ",", "addrq", ")", ":", "co_lnotab", "=", "self", ".", "pyop_field", "(", "'co_lnotab'", ")", ".", "proxyval", "(", "set", "(", ")", ")", "# Initialize lineno to co_firstlineno as per PyCode_Addr2Line", "# not 0, as lnotab_notes.txt ha...
Get the line number for a given bytecode offset Analogous to PyCode_Addr2Line; translated from pseudocode in Objects/lnotab_notes.txt
[ "Get", "the", "line", "number", "for", "a", "given", "bytecode", "offset" ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L592-L611
train
google/pyringe
pyringe/payload/libpython.py
PyFrameObjectPtr.current_line
def current_line(self): '''Get the text of the current source line as a string, with a trailing newline character''' if self.is_optimized_out(): return '(frame information optimized out)' with open(self.filename(), 'r') as f: all_lines = f.readlines() ...
python
def current_line(self): '''Get the text of the current source line as a string, with a trailing newline character''' if self.is_optimized_out(): return '(frame information optimized out)' with open(self.filename(), 'r') as f: all_lines = f.readlines() ...
[ "def", "current_line", "(", "self", ")", ":", "if", "self", ".", "is_optimized_out", "(", ")", ":", "return", "'(frame information optimized out)'", "with", "open", "(", "self", ".", "filename", "(", ")", ",", "'r'", ")", "as", "f", ":", "all_lines", "=", ...
Get the text of the current source line as a string, with a trailing newline character
[ "Get", "the", "text", "of", "the", "current", "source", "line", "as", "a", "string", "with", "a", "trailing", "newline", "character" ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L889-L897
train
google/pyringe
pyringe/payload/libpython.py
Frame.select
def select(self): '''If supported, select this frame and return True; return False if unsupported Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12 onwards, but absent on Ubuntu buildbot''' if not hasattr(self._gdbframe, 'select'): print ('Unabl...
python
def select(self): '''If supported, select this frame and return True; return False if unsupported Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12 onwards, but absent on Ubuntu buildbot''' if not hasattr(self._gdbframe, 'select'): print ('Unabl...
[ "def", "select", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ".", "_gdbframe", ",", "'select'", ")", ":", "print", "(", "'Unable to select frame: '", "'this build of gdb does not expose a gdb.Frame.select method'", ")", "return", "False", "self", "."...
If supported, select this frame and return True; return False if unsupported Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12 onwards, but absent on Ubuntu buildbot
[ "If", "supported", "select", "this", "frame", "and", "return", "True", ";", "return", "False", "if", "unsupported" ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L1173-L1183
train
google/pyringe
pyringe/payload/libpython.py
Frame.get_index
def get_index(self): '''Calculate index of frame, starting at 0 for the newest frame within this thread''' index = 0 # Go down until you reach the newest frame: iter_frame = self while iter_frame.newer(): index += 1 iter_frame = iter_frame.newer() ...
python
def get_index(self): '''Calculate index of frame, starting at 0 for the newest frame within this thread''' index = 0 # Go down until you reach the newest frame: iter_frame = self while iter_frame.newer(): index += 1 iter_frame = iter_frame.newer() ...
[ "def", "get_index", "(", "self", ")", ":", "index", "=", "0", "# Go down until you reach the newest frame:", "iter_frame", "=", "self", "while", "iter_frame", ".", "newer", "(", ")", ":", "index", "+=", "1", "iter_frame", "=", "iter_frame", ".", "newer", "(", ...
Calculate index of frame, starting at 0 for the newest frame within this thread
[ "Calculate", "index", "of", "frame", "starting", "at", "0", "for", "the", "newest", "frame", "within", "this", "thread" ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L1185-L1194
train
google/pyringe
pyringe/payload/libpython.py
Frame.is_evalframeex
def is_evalframeex(self): '''Is this a PyEval_EvalFrameEx frame?''' if self._gdbframe.name() == 'PyEval_EvalFrameEx': ''' I believe we also need to filter on the inline struct frame_id.inline_depth, only regarding frames with an inline depth of 0 as actual...
python
def is_evalframeex(self): '''Is this a PyEval_EvalFrameEx frame?''' if self._gdbframe.name() == 'PyEval_EvalFrameEx': ''' I believe we also need to filter on the inline struct frame_id.inline_depth, only regarding frames with an inline depth of 0 as actual...
[ "def", "is_evalframeex", "(", "self", ")", ":", "if", "self", ".", "_gdbframe", ".", "name", "(", ")", "==", "'PyEval_EvalFrameEx'", ":", "'''\n I believe we also need to filter on the inline\n struct frame_id.inline_depth, only regarding frames with\n ...
Is this a PyEval_EvalFrameEx frame?
[ "Is", "this", "a", "PyEval_EvalFrameEx", "frame?" ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L1196-L1210
train
google/pyringe
pyringe/payload/libpython.py
Frame.get_selected_python_frame
def get_selected_python_frame(cls): '''Try to obtain the Frame for the python code in the selected frame, or None''' frame = cls.get_selected_frame() while frame: if frame.is_evalframeex(): return frame frame = frame.older() # Not found: ...
python
def get_selected_python_frame(cls): '''Try to obtain the Frame for the python code in the selected frame, or None''' frame = cls.get_selected_frame() while frame: if frame.is_evalframeex(): return frame frame = frame.older() # Not found: ...
[ "def", "get_selected_python_frame", "(", "cls", ")", ":", "frame", "=", "cls", ".", "get_selected_frame", "(", ")", "while", "frame", ":", "if", "frame", ".", "is_evalframeex", "(", ")", ":", "return", "frame", "frame", "=", "frame", ".", "older", "(", "...
Try to obtain the Frame for the python code in the selected frame, or None
[ "Try", "to", "obtain", "the", "Frame", "for", "the", "python", "code", "in", "the", "selected", "frame", "or", "None" ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L1240-L1251
train
google/pyringe
pyringe/repl.py
DebuggingConsole.ListCommands
def ListCommands(self): """Print a list of currently available commands and their descriptions.""" print 'Available commands:' commands = dict(self.commands) for plugin in self.plugins: commands.update(plugin.commands) for com in sorted(commands): if not com.startswith('_'): self...
python
def ListCommands(self): """Print a list of currently available commands and their descriptions.""" print 'Available commands:' commands = dict(self.commands) for plugin in self.plugins: commands.update(plugin.commands) for com in sorted(commands): if not com.startswith('_'): self...
[ "def", "ListCommands", "(", "self", ")", ":", "print", "'Available commands:'", "commands", "=", "dict", "(", "self", ".", "commands", ")", "for", "plugin", "in", "self", ".", "plugins", ":", "commands", ".", "update", "(", "plugin", ".", "commands", ")", ...
Print a list of currently available commands and their descriptions.
[ "Print", "a", "list", "of", "currently", "available", "commands", "and", "their", "descriptions", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/repl.py#L102-L110
train
google/pyringe
pyringe/repl.py
DebuggingConsole.StatusLine
def StatusLine(self): """Generate the colored line indicating plugin status.""" pid = self.inferior.pid curthread = None threadnum = 0 if pid: if not self.inferior.is_running: logging.warning('Inferior is not running.') self.Detach() pid = None else: try: ...
python
def StatusLine(self): """Generate the colored line indicating plugin status.""" pid = self.inferior.pid curthread = None threadnum = 0 if pid: if not self.inferior.is_running: logging.warning('Inferior is not running.') self.Detach() pid = None else: try: ...
[ "def", "StatusLine", "(", "self", ")", ":", "pid", "=", "self", ".", "inferior", ".", "pid", "curthread", "=", "None", "threadnum", "=", "0", "if", "pid", ":", "if", "not", "self", ".", "inferior", ".", "is_running", ":", "logging", ".", "warning", "...
Generate the colored line indicating plugin status.
[ "Generate", "the", "colored", "line", "indicating", "plugin", "status", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/repl.py#L121-L147
train
google/pyringe
pyringe/repl.py
DebuggingConsole.Attach
def Attach(self, pid): """Attach to the process with the given pid.""" if self.inferior.is_running: answer = raw_input('Already attached to process ' + str(self.inferior.pid) + '. Detach? [y]/n ') if answer and answer != 'y' and answer != 'yes': ...
python
def Attach(self, pid): """Attach to the process with the given pid.""" if self.inferior.is_running: answer = raw_input('Already attached to process ' + str(self.inferior.pid) + '. Detach? [y]/n ') if answer and answer != 'y' and answer != 'yes': ...
[ "def", "Attach", "(", "self", ",", "pid", ")", ":", "if", "self", ".", "inferior", ".", "is_running", ":", "answer", "=", "raw_input", "(", "'Already attached to process '", "+", "str", "(", "self", ".", "inferior", ".", "pid", ")", "+", "'. Detach? [y]/n ...
Attach to the process with the given pid.
[ "Attach", "to", "the", "process", "with", "the", "given", "pid", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/repl.py#L149-L161
train
google/pyringe
pyringe/plugins/gdb_shell.py
GdbPlugin.StartGdb
def StartGdb(self): """Hands control over to a new gdb process.""" if self.inferior.is_running: self.inferior.ShutDownGdb() program_arg = 'program %d ' % self.inferior.pid else: program_arg = '' os.system('gdb ' + program_arg + ' '.join(self.gdb_args)) reset_position = raw_input('R...
python
def StartGdb(self): """Hands control over to a new gdb process.""" if self.inferior.is_running: self.inferior.ShutDownGdb() program_arg = 'program %d ' % self.inferior.pid else: program_arg = '' os.system('gdb ' + program_arg + ' '.join(self.gdb_args)) reset_position = raw_input('R...
[ "def", "StartGdb", "(", "self", ")", ":", "if", "self", ".", "inferior", ".", "is_running", ":", "self", ".", "inferior", ".", "ShutDownGdb", "(", ")", "program_arg", "=", "'program %d '", "%", "self", ".", "inferior", ".", "pid", "else", ":", "program_a...
Hands control over to a new gdb process.
[ "Hands", "control", "over", "to", "a", "new", "gdb", "process", "." ]
76dff5d1ac29cd5e7bf32677654a83291a15ad8a
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/plugins/gdb_shell.py#L38-L48
train
WojciechMula/pyahocorasick
py/pyahocorasick.py
Trie.__get_node
def __get_node(self, word): """ Private function retrieving a final node of trie for given word Returns node or None, if the trie doesn't contain the word. """ node = self.root for c in word: try: node = node.children[c] except KeyError: return None return node
python
def __get_node(self, word): """ Private function retrieving a final node of trie for given word Returns node or None, if the trie doesn't contain the word. """ node = self.root for c in word: try: node = node.children[c] except KeyError: return None return node
[ "def", "__get_node", "(", "self", ",", "word", ")", ":", "node", "=", "self", ".", "root", "for", "c", "in", "word", ":", "try", ":", "node", "=", "node", ".", "children", "[", "c", "]", "except", "KeyError", ":", "return", "None", "return", "node"...
Private function retrieving a final node of trie for given word Returns node or None, if the trie doesn't contain the word.
[ "Private", "function", "retrieving", "a", "final", "node", "of", "trie", "for", "given", "word" ]
53842f783fbe3fa77d53cde1ac251b23c3cbed02
https://github.com/WojciechMula/pyahocorasick/blob/53842f783fbe3fa77d53cde1ac251b23c3cbed02/py/pyahocorasick.py#L55-L70
train
WojciechMula/pyahocorasick
py/pyahocorasick.py
Trie.get
def get(self, word, default=nil): """ Retrieves output value associated with word. If there is no word returns default value, and if default is not given rises KeyError. """ node = self.__get_node(word) output = nil if node: output = node.output if output is nil: if default is nil: raise ...
python
def get(self, word, default=nil): """ Retrieves output value associated with word. If there is no word returns default value, and if default is not given rises KeyError. """ node = self.__get_node(word) output = nil if node: output = node.output if output is nil: if default is nil: raise ...
[ "def", "get", "(", "self", ",", "word", ",", "default", "=", "nil", ")", ":", "node", "=", "self", ".", "__get_node", "(", "word", ")", "output", "=", "nil", "if", "node", ":", "output", "=", "node", ".", "output", "if", "output", "is", "nil", ":...
Retrieves output value associated with word. If there is no word returns default value, and if default is not given rises KeyError.
[ "Retrieves", "output", "value", "associated", "with", "word", "." ]
53842f783fbe3fa77d53cde1ac251b23c3cbed02
https://github.com/WojciechMula/pyahocorasick/blob/53842f783fbe3fa77d53cde1ac251b23c3cbed02/py/pyahocorasick.py#L73-L92
train
WojciechMula/pyahocorasick
py/pyahocorasick.py
Trie.items
def items(self): """ Generator returning all keys and values stored in a trie. """ L = [] def aux(node, s): s = s + node.char if node.output is not nil: L.append((s, node.output)) for child in node.children.values(): if child is not node: aux(child, s) aux(self.root, '') return it...
python
def items(self): """ Generator returning all keys and values stored in a trie. """ L = [] def aux(node, s): s = s + node.char if node.output is not nil: L.append((s, node.output)) for child in node.children.values(): if child is not node: aux(child, s) aux(self.root, '') return it...
[ "def", "items", "(", "self", ")", ":", "L", "=", "[", "]", "def", "aux", "(", "node", ",", "s", ")", ":", "s", "=", "s", "+", "node", ".", "char", "if", "node", ".", "output", "is", "not", "nil", ":", "L", ".", "append", "(", "(", "s", ",...
Generator returning all keys and values stored in a trie.
[ "Generator", "returning", "all", "keys", "and", "values", "stored", "in", "a", "trie", "." ]
53842f783fbe3fa77d53cde1ac251b23c3cbed02
https://github.com/WojciechMula/pyahocorasick/blob/53842f783fbe3fa77d53cde1ac251b23c3cbed02/py/pyahocorasick.py#L113-L129
train
WojciechMula/pyahocorasick
py/pyahocorasick.py
Trie.add_word
def add_word(self, word, value): """ Adds word and associated value. If word already exists, its value is replaced. """ if not word: return node = self.root for c in word: try: node = node.children[c] except KeyError: n = TrieNode(c) node.children[c] = n node = n node.output ...
python
def add_word(self, word, value): """ Adds word and associated value. If word already exists, its value is replaced. """ if not word: return node = self.root for c in word: try: node = node.children[c] except KeyError: n = TrieNode(c) node.children[c] = n node = n node.output ...
[ "def", "add_word", "(", "self", ",", "word", ",", "value", ")", ":", "if", "not", "word", ":", "return", "node", "=", "self", ".", "root", "for", "c", "in", "word", ":", "try", ":", "node", "=", "node", ".", "children", "[", "c", "]", "except", ...
Adds word and associated value. If word already exists, its value is replaced.
[ "Adds", "word", "and", "associated", "value", "." ]
53842f783fbe3fa77d53cde1ac251b23c3cbed02
https://github.com/WojciechMula/pyahocorasick/blob/53842f783fbe3fa77d53cde1ac251b23c3cbed02/py/pyahocorasick.py#L151-L169
train
WojciechMula/pyahocorasick
py/pyahocorasick.py
Trie.exists
def exists(self, word): """ Checks if whole word is present in the trie. """ node = self.__get_node(word) if node: return bool(node.output != nil) else: return False
python
def exists(self, word): """ Checks if whole word is present in the trie. """ node = self.__get_node(word) if node: return bool(node.output != nil) else: return False
[ "def", "exists", "(", "self", ",", "word", ")", ":", "node", "=", "self", ".", "__get_node", "(", "word", ")", "if", "node", ":", "return", "bool", "(", "node", ".", "output", "!=", "nil", ")", "else", ":", "return", "False" ]
Checks if whole word is present in the trie.
[ "Checks", "if", "whole", "word", "is", "present", "in", "the", "trie", "." ]
53842f783fbe3fa77d53cde1ac251b23c3cbed02
https://github.com/WojciechMula/pyahocorasick/blob/53842f783fbe3fa77d53cde1ac251b23c3cbed02/py/pyahocorasick.py#L180-L189
train
WojciechMula/pyahocorasick
py/pyahocorasick.py
Trie.make_automaton
def make_automaton(self): """ Converts trie to Aho-Corasick automaton. """ queue = deque() # 1. for i in range(256): c = chr(i) if c in self.root.children: node = self.root.children[c] node.fail = self.root # f(s) = 0 queue.append(node) else: self.root.children[c] = self.root #...
python
def make_automaton(self): """ Converts trie to Aho-Corasick automaton. """ queue = deque() # 1. for i in range(256): c = chr(i) if c in self.root.children: node = self.root.children[c] node.fail = self.root # f(s) = 0 queue.append(node) else: self.root.children[c] = self.root #...
[ "def", "make_automaton", "(", "self", ")", ":", "queue", "=", "deque", "(", ")", "# 1.", "for", "i", "in", "range", "(", "256", ")", ":", "c", "=", "chr", "(", "i", ")", "if", "c", "in", "self", ".", "root", ".", "children", ":", "node", "=", ...
Converts trie to Aho-Corasick automaton.
[ "Converts", "trie", "to", "Aho", "-", "Corasick", "automaton", "." ]
53842f783fbe3fa77d53cde1ac251b23c3cbed02
https://github.com/WojciechMula/pyahocorasick/blob/53842f783fbe3fa77d53cde1ac251b23c3cbed02/py/pyahocorasick.py#L200-L226
train
WojciechMula/pyahocorasick
py/pyahocorasick.py
Trie.iter_long
def iter_long(self, string): """ Generator performs a modified Aho-Corasick search string algorithm, which maches only the longest word. """ state = self.root last = None index = 0 while index < len(string): c = string[index] if c in state.children: state = state.children[c] if state....
python
def iter_long(self, string): """ Generator performs a modified Aho-Corasick search string algorithm, which maches only the longest word. """ state = self.root last = None index = 0 while index < len(string): c = string[index] if c in state.children: state = state.children[c] if state....
[ "def", "iter_long", "(", "self", ",", "string", ")", ":", "state", "=", "self", ".", "root", "last", "=", "None", "index", "=", "0", "while", "index", "<", "len", "(", "string", ")", ":", "c", "=", "string", "[", "index", "]", "if", "c", "in", ...
Generator performs a modified Aho-Corasick search string algorithm, which maches only the longest word.
[ "Generator", "performs", "a", "modified", "Aho", "-", "Corasick", "search", "string", "algorithm", "which", "maches", "only", "the", "longest", "word", "." ]
53842f783fbe3fa77d53cde1ac251b23c3cbed02
https://github.com/WojciechMula/pyahocorasick/blob/53842f783fbe3fa77d53cde1ac251b23c3cbed02/py/pyahocorasick.py#L254-L292
train
WojciechMula/pyahocorasick
py/pyahocorasick.py
Trie.find_all
def find_all(self, string, callback): """ Wrapper on iter method, callback gets an iterator result """ for index, output in self.iter(string): callback(index, output)
python
def find_all(self, string, callback): """ Wrapper on iter method, callback gets an iterator result """ for index, output in self.iter(string): callback(index, output)
[ "def", "find_all", "(", "self", ",", "string", ",", "callback", ")", ":", "for", "index", ",", "output", "in", "self", ".", "iter", "(", "string", ")", ":", "callback", "(", "index", ",", "output", ")" ]
Wrapper on iter method, callback gets an iterator result
[ "Wrapper", "on", "iter", "method", "callback", "gets", "an", "iterator", "result" ]
53842f783fbe3fa77d53cde1ac251b23c3cbed02
https://github.com/WojciechMula/pyahocorasick/blob/53842f783fbe3fa77d53cde1ac251b23c3cbed02/py/pyahocorasick.py#L294-L299
train
WojciechMula/pyahocorasick
setup.py
get_long_description
def get_long_description(): """ Strip the content index from the long description. """ import codecs with codecs.open('README.rst', encoding='UTF-8') as f: readme = [line for line in f if not line.startswith('.. contents::')] return ''.join(readme)
python
def get_long_description(): """ Strip the content index from the long description. """ import codecs with codecs.open('README.rst', encoding='UTF-8') as f: readme = [line for line in f if not line.startswith('.. contents::')] return ''.join(readme)
[ "def", "get_long_description", "(", ")", ":", "import", "codecs", "with", "codecs", ".", "open", "(", "'README.rst'", ",", "encoding", "=", "'UTF-8'", ")", "as", "f", ":", "readme", "=", "[", "line", "for", "line", "in", "f", "if", "not", "line", ".", ...
Strip the content index from the long description.
[ "Strip", "the", "content", "index", "from", "the", "long", "description", "." ]
53842f783fbe3fa77d53cde1ac251b23c3cbed02
https://github.com/WojciechMula/pyahocorasick/blob/53842f783fbe3fa77d53cde1ac251b23c3cbed02/setup.py#L19-L26
train
jreese/markdown-pp
MarkdownPP/Modules/YoutubeEmbed.py
YoutubeEmbed._add_play_button
def _add_play_button(self, image_url, image_path): """Try to add a play button to the screenshot.""" try: from PIL import Image from tempfile import NamedTemporaryFile import urllib try: urlretrieve = urllib.request.urlretrieve ...
python
def _add_play_button(self, image_url, image_path): """Try to add a play button to the screenshot.""" try: from PIL import Image from tempfile import NamedTemporaryFile import urllib try: urlretrieve = urllib.request.urlretrieve ...
[ "def", "_add_play_button", "(", "self", ",", "image_url", ",", "image_path", ")", ":", "try", ":", "from", "PIL", "import", "Image", "from", "tempfile", "import", "NamedTemporaryFile", "import", "urllib", "try", ":", "urlretrieve", "=", "urllib", ".", "request...
Try to add a play button to the screenshot.
[ "Try", "to", "add", "a", "play", "button", "to", "the", "screenshot", "." ]
fba644c08176abef4ea5ad36b5b60d32379bddac
https://github.com/jreese/markdown-pp/blob/fba644c08176abef4ea5ad36b5b60d32379bddac/MarkdownPP/Modules/YoutubeEmbed.py#L71-L101
train
jreese/markdown-pp
MarkdownPP/Processor.py
Processor.process
def process(self): """ This method handles the actual processing of Modules and Transforms """ self.modules.sort(key=lambda x: x.priority) for module in self.modules: transforms = module.transform(self.data) transforms.sort(key=lambda x: x.linenum, revers...
python
def process(self): """ This method handles the actual processing of Modules and Transforms """ self.modules.sort(key=lambda x: x.priority) for module in self.modules: transforms = module.transform(self.data) transforms.sort(key=lambda x: x.linenum, revers...
[ "def", "process", "(", "self", ")", ":", "self", ".", "modules", ".", "sort", "(", "key", "=", "lambda", "x", ":", "x", ".", "priority", ")", "for", "module", "in", "self", ".", "modules", ":", "transforms", "=", "module", ".", "transform", "(", "s...
This method handles the actual processing of Modules and Transforms
[ "This", "method", "handles", "the", "actual", "processing", "of", "Modules", "and", "Transforms" ]
fba644c08176abef4ea5ad36b5b60d32379bddac
https://github.com/jreese/markdown-pp/blob/fba644c08176abef4ea5ad36b5b60d32379bddac/MarkdownPP/Processor.py#L42-L71
train
jpvanhal/inflection
inflection.py
_irregular
def _irregular(singular, plural): """ A convenience function to add appropriate rules to plurals and singular for irregular words. :param singular: irregular word in singular form :param plural: irregular word in plural form """ def caseinsensitive(string): return ''.join('[' + char...
python
def _irregular(singular, plural): """ A convenience function to add appropriate rules to plurals and singular for irregular words. :param singular: irregular word in singular form :param plural: irregular word in plural form """ def caseinsensitive(string): return ''.join('[' + char...
[ "def", "_irregular", "(", "singular", ",", "plural", ")", ":", "def", "caseinsensitive", "(", "string", ")", ":", "return", "''", ".", "join", "(", "'['", "+", "char", "+", "char", ".", "upper", "(", ")", "+", "']'", "for", "char", "in", "string", ...
A convenience function to add appropriate rules to plurals and singular for irregular words. :param singular: irregular word in singular form :param plural: irregular word in plural form
[ "A", "convenience", "function", "to", "add", "appropriate", "rules", "to", "plurals", "and", "singular", "for", "irregular", "words", "." ]
ad195ab72b193b57bb4cf68396c4cd8a62f1fe6c
https://github.com/jpvanhal/inflection/blob/ad195ab72b193b57bb4cf68396c4cd8a62f1fe6c/inflection.py#L89-L139
train
jpvanhal/inflection
inflection.py
camelize
def camelize(string, uppercase_first_letter=True): """ Convert strings to CamelCase. Examples:: >>> camelize("device_type") "DeviceType" >>> camelize("device_type", False) "deviceType" :func:`camelize` can be thought of as a inverse of :func:`underscore`, although ...
python
def camelize(string, uppercase_first_letter=True): """ Convert strings to CamelCase. Examples:: >>> camelize("device_type") "DeviceType" >>> camelize("device_type", False) "deviceType" :func:`camelize` can be thought of as a inverse of :func:`underscore`, although ...
[ "def", "camelize", "(", "string", ",", "uppercase_first_letter", "=", "True", ")", ":", "if", "uppercase_first_letter", ":", "return", "re", ".", "sub", "(", "r\"(?:^|_)(.)\"", ",", "lambda", "m", ":", "m", ".", "group", "(", "1", ")", ".", "upper", "(",...
Convert strings to CamelCase. Examples:: >>> camelize("device_type") "DeviceType" >>> camelize("device_type", False) "deviceType" :func:`camelize` can be thought of as a inverse of :func:`underscore`, although there are some cases where that does not hold:: >>> ca...
[ "Convert", "strings", "to", "CamelCase", "." ]
ad195ab72b193b57bb4cf68396c4cd8a62f1fe6c
https://github.com/jpvanhal/inflection/blob/ad195ab72b193b57bb4cf68396c4cd8a62f1fe6c/inflection.py#L142-L166
train
jpvanhal/inflection
inflection.py
parameterize
def parameterize(string, separator='-'): """ Replace special characters in a string so that it may be used as part of a 'pretty' URL. Example:: >>> parameterize(u"Donald E. Knuth") 'donald-e-knuth' """ string = transliterate(string) # Turn unwanted chars into the separator...
python
def parameterize(string, separator='-'): """ Replace special characters in a string so that it may be used as part of a 'pretty' URL. Example:: >>> parameterize(u"Donald E. Knuth") 'donald-e-knuth' """ string = transliterate(string) # Turn unwanted chars into the separator...
[ "def", "parameterize", "(", "string", ",", "separator", "=", "'-'", ")", ":", "string", "=", "transliterate", "(", "string", ")", "# Turn unwanted chars into the separator", "string", "=", "re", ".", "sub", "(", "r\"(?i)[^a-z0-9\\-_]+\"", ",", "separator", ",", ...
Replace special characters in a string so that it may be used as part of a 'pretty' URL. Example:: >>> parameterize(u"Donald E. Knuth") 'donald-e-knuth'
[ "Replace", "special", "characters", "in", "a", "string", "so", "that", "it", "may", "be", "used", "as", "part", "of", "a", "pretty", "URL", "." ]
ad195ab72b193b57bb4cf68396c4cd8a62f1fe6c
https://github.com/jpvanhal/inflection/blob/ad195ab72b193b57bb4cf68396c4cd8a62f1fe6c/inflection.py#L258-L279
train
jpvanhal/inflection
inflection.py
pluralize
def pluralize(word): """ Return the plural form of a word. Examples:: >>> pluralize("post") "posts" >>> pluralize("octopus") "octopi" >>> pluralize("sheep") "sheep" >>> pluralize("CamelOctopus") "CamelOctopi" """ if not word or word....
python
def pluralize(word): """ Return the plural form of a word. Examples:: >>> pluralize("post") "posts" >>> pluralize("octopus") "octopi" >>> pluralize("sheep") "sheep" >>> pluralize("CamelOctopus") "CamelOctopi" """ if not word or word....
[ "def", "pluralize", "(", "word", ")", ":", "if", "not", "word", "or", "word", ".", "lower", "(", ")", "in", "UNCOUNTABLES", ":", "return", "word", "else", ":", "for", "rule", ",", "replacement", "in", "PLURALS", ":", "if", "re", ".", "search", "(", ...
Return the plural form of a word. Examples:: >>> pluralize("post") "posts" >>> pluralize("octopus") "octopi" >>> pluralize("sheep") "sheep" >>> pluralize("CamelOctopus") "CamelOctopi"
[ "Return", "the", "plural", "form", "of", "a", "word", "." ]
ad195ab72b193b57bb4cf68396c4cd8a62f1fe6c
https://github.com/jpvanhal/inflection/blob/ad195ab72b193b57bb4cf68396c4cd8a62f1fe6c/inflection.py#L282-L304
train
jpvanhal/inflection
inflection.py
underscore
def underscore(word): """ Make an underscored, lowercase form from the expression in the string. Example:: >>> underscore("DeviceType") "device_type" As a rule of thumb you can think of :func:`underscore` as the inverse of :func:`camelize`, though there are cases where that does n...
python
def underscore(word): """ Make an underscored, lowercase form from the expression in the string. Example:: >>> underscore("DeviceType") "device_type" As a rule of thumb you can think of :func:`underscore` as the inverse of :func:`camelize`, though there are cases where that does n...
[ "def", "underscore", "(", "word", ")", ":", "word", "=", "re", ".", "sub", "(", "r\"([A-Z]+)([A-Z][a-z])\"", ",", "r'\\1_\\2'", ",", "word", ")", "word", "=", "re", ".", "sub", "(", "r\"([a-z\\d])([A-Z])\"", ",", "r'\\1_\\2'", ",", "word", ")", "word", "...
Make an underscored, lowercase form from the expression in the string. Example:: >>> underscore("DeviceType") "device_type" As a rule of thumb you can think of :func:`underscore` as the inverse of :func:`camelize`, though there are cases where that does not hold:: >>> camelize(un...
[ "Make", "an", "underscored", "lowercase", "form", "from", "the", "expression", "in", "the", "string", "." ]
ad195ab72b193b57bb4cf68396c4cd8a62f1fe6c
https://github.com/jpvanhal/inflection/blob/ad195ab72b193b57bb4cf68396c4cd8a62f1fe6c/inflection.py#L395-L414
train
libvips/pyvips
pyvips/vobject.py
VipsObject.print_all
def print_all(msg): """Print all objects. Print a table of all active libvips objects. Handy for debugging. """ gc.collect() logger.debug(msg) vips_lib.vips_object_print_all() logger.debug()
python
def print_all(msg): """Print all objects. Print a table of all active libvips objects. Handy for debugging. """ gc.collect() logger.debug(msg) vips_lib.vips_object_print_all() logger.debug()
[ "def", "print_all", "(", "msg", ")", ":", "gc", ".", "collect", "(", ")", "logger", ".", "debug", "(", "msg", ")", "vips_lib", ".", "vips_object_print_all", "(", ")", "logger", ".", "debug", "(", ")" ]
Print all objects. Print a table of all active libvips objects. Handy for debugging.
[ "Print", "all", "objects", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/vobject.py#L22-L32
train
libvips/pyvips
pyvips/vobject.py
VipsObject.get_typeof
def get_typeof(self, name): """Get the GType of a GObject property. This function returns 0 if the property does not exist. """ # logger.debug('VipsObject.get_typeof: self = %s, name = %s', # str(self), name) pspec = self._get_pspec(name) if pspec...
python
def get_typeof(self, name): """Get the GType of a GObject property. This function returns 0 if the property does not exist. """ # logger.debug('VipsObject.get_typeof: self = %s, name = %s', # str(self), name) pspec = self._get_pspec(name) if pspec...
[ "def", "get_typeof", "(", "self", ",", "name", ")", ":", "# logger.debug('VipsObject.get_typeof: self = %s, name = %s',", "# str(self), name)", "pspec", "=", "self", ".", "_get_pspec", "(", "name", ")", "if", "pspec", "is", "None", ":", "# need to clear any...
Get the GType of a GObject property. This function returns 0 if the property does not exist.
[ "Get", "the", "GType", "of", "a", "GObject", "property", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/vobject.py#L52-L68
train
libvips/pyvips
pyvips/vobject.py
VipsObject.get_blurb
def get_blurb(self, name): """Get the blurb for a GObject property.""" c_str = gobject_lib.g_param_spec_get_blurb(self._get_pspec(name)) return _to_string(c_str)
python
def get_blurb(self, name): """Get the blurb for a GObject property.""" c_str = gobject_lib.g_param_spec_get_blurb(self._get_pspec(name)) return _to_string(c_str)
[ "def", "get_blurb", "(", "self", ",", "name", ")", ":", "c_str", "=", "gobject_lib", ".", "g_param_spec_get_blurb", "(", "self", ".", "_get_pspec", "(", "name", ")", ")", "return", "_to_string", "(", "c_str", ")" ]
Get the blurb for a GObject property.
[ "Get", "the", "blurb", "for", "a", "GObject", "property", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/vobject.py#L70-L74
train
libvips/pyvips
pyvips/vobject.py
VipsObject.get
def get(self, name): """Get a GObject property. The value of the property is converted to a Python value. """ logger.debug('VipsObject.get: name = %s', name) pspec = self._get_pspec(name) if pspec is None: raise Error('Property not found.') gtype =...
python
def get(self, name): """Get a GObject property. The value of the property is converted to a Python value. """ logger.debug('VipsObject.get: name = %s', name) pspec = self._get_pspec(name) if pspec is None: raise Error('Property not found.') gtype =...
[ "def", "get", "(", "self", ",", "name", ")", ":", "logger", ".", "debug", "(", "'VipsObject.get: name = %s'", ",", "name", ")", "pspec", "=", "self", ".", "_get_pspec", "(", "name", ")", "if", "pspec", "is", "None", ":", "raise", "Error", "(", "'Proper...
Get a GObject property. The value of the property is converted to a Python value.
[ "Get", "a", "GObject", "property", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/vobject.py#L76-L95
train
libvips/pyvips
pyvips/vobject.py
VipsObject.set
def set(self, name, value): """Set a GObject property. The value is converted to the property type, if possible. """ logger.debug('VipsObject.set: name = %s, value = %s', name, value) gtype = self.get_typeof(name) gv = pyvips.GValue() gv.set_type(gtype) ...
python
def set(self, name, value): """Set a GObject property. The value is converted to the property type, if possible. """ logger.debug('VipsObject.set: name = %s, value = %s', name, value) gtype = self.get_typeof(name) gv = pyvips.GValue() gv.set_type(gtype) ...
[ "def", "set", "(", "self", ",", "name", ",", "value", ")", ":", "logger", ".", "debug", "(", "'VipsObject.set: name = %s, value = %s'", ",", "name", ",", "value", ")", "gtype", "=", "self", ".", "get_typeof", "(", "name", ")", "gv", "=", "pyvips", ".", ...
Set a GObject property. The value is converted to the property type, if possible.
[ "Set", "a", "GObject", "property", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/vobject.py#L97-L112
train
libvips/pyvips
pyvips/vobject.py
VipsObject.set_string
def set_string(self, string_options): """Set a series of properties using a string. For example:: 'fred=12, tile' '[fred=12]' """ vo = ffi.cast('VipsObject *', self.pointer) cstr = _to_bytes(string_options) result = vips_lib.vips_object_set_fro...
python
def set_string(self, string_options): """Set a series of properties using a string. For example:: 'fred=12, tile' '[fred=12]' """ vo = ffi.cast('VipsObject *', self.pointer) cstr = _to_bytes(string_options) result = vips_lib.vips_object_set_fro...
[ "def", "set_string", "(", "self", ",", "string_options", ")", ":", "vo", "=", "ffi", ".", "cast", "(", "'VipsObject *'", ",", "self", ".", "pointer", ")", "cstr", "=", "_to_bytes", "(", "string_options", ")", "result", "=", "vips_lib", ".", "vips_object_se...
Set a series of properties using a string. For example:: 'fred=12, tile' '[fred=12]'
[ "Set", "a", "series", "of", "properties", "using", "a", "string", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/vobject.py#L114-L128
train
libvips/pyvips
pyvips/vobject.py
VipsObject.get_description
def get_description(self): """Get the description of a GObject.""" vo = ffi.cast('VipsObject *', self.pointer) return _to_string(vips_lib.vips_object_get_description(vo))
python
def get_description(self): """Get the description of a GObject.""" vo = ffi.cast('VipsObject *', self.pointer) return _to_string(vips_lib.vips_object_get_description(vo))
[ "def", "get_description", "(", "self", ")", ":", "vo", "=", "ffi", ".", "cast", "(", "'VipsObject *'", ",", "self", ".", "pointer", ")", "return", "_to_string", "(", "vips_lib", ".", "vips_object_get_description", "(", "vo", ")", ")" ]
Get the description of a GObject.
[ "Get", "the", "description", "of", "a", "GObject", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/vobject.py#L130-L134
train
libvips/pyvips
pyvips/voperation.py
Operation.generate_sphinx_all
def generate_sphinx_all(): """Generate sphinx documentation. This generates a .rst file for all auto-generated image methods. Use it to regenerate the docs with something like:: $ python -c \ "import pyvips; pyvips.Operation.generate_sphinx_all()" > x And copy-paste the fi...
python
def generate_sphinx_all(): """Generate sphinx documentation. This generates a .rst file for all auto-generated image methods. Use it to regenerate the docs with something like:: $ python -c \ "import pyvips; pyvips.Operation.generate_sphinx_all()" > x And copy-paste the fi...
[ "def", "generate_sphinx_all", "(", ")", ":", "# generate list of all nicknames we can generate docstrings for", "all_nicknames", "=", "[", "]", "def", "add_nickname", "(", "gtype", ",", "a", ",", "b", ")", ":", "nickname", "=", "nickname_find", "(", "gtype", ")", ...
Generate sphinx documentation. This generates a .rst file for all auto-generated image methods. Use it to regenerate the docs with something like:: $ python -c \ "import pyvips; pyvips.Operation.generate_sphinx_all()" > x And copy-paste the file contents into doc/vimage.rst in the...
[ "Generate", "sphinx", "documentation", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/voperation.py#L482-L535
train
libvips/pyvips
pyvips/vregion.py
Region.new
def new(image): """Make a region on an image. Returns: A new :class:`.Region`. Raises: :class:`.Error` """ pointer = vips_lib.vips_region_new(image.pointer) if pointer == ffi.NULL: raise Error('unable to make region') retur...
python
def new(image): """Make a region on an image. Returns: A new :class:`.Region`. Raises: :class:`.Error` """ pointer = vips_lib.vips_region_new(image.pointer) if pointer == ffi.NULL: raise Error('unable to make region') retur...
[ "def", "new", "(", "image", ")", ":", "pointer", "=", "vips_lib", ".", "vips_region_new", "(", "image", ".", "pointer", ")", "if", "pointer", "==", "ffi", ".", "NULL", ":", "raise", "Error", "(", "'unable to make region'", ")", "return", "pyvips", ".", "...
Make a region on an image. Returns: A new :class:`.Region`. Raises: :class:`.Error`
[ "Make", "a", "region", "on", "an", "image", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/vregion.py#L21-L36
train
libvips/pyvips
pyvips/vregion.py
Region.fetch
def fetch(self, x, y, w, h): """Fill a region with pixel data. Pixels are filled with data! Returns: Pixel data. Raises: :class:`.Error` """ if not at_least_libvips(8, 8): raise Error('libvips too old') psize = ffi.new('si...
python
def fetch(self, x, y, w, h): """Fill a region with pixel data. Pixels are filled with data! Returns: Pixel data. Raises: :class:`.Error` """ if not at_least_libvips(8, 8): raise Error('libvips too old') psize = ffi.new('si...
[ "def", "fetch", "(", "self", ",", "x", ",", "y", ",", "w", ",", "h", ")", ":", "if", "not", "at_least_libvips", "(", "8", ",", "8", ")", ":", "raise", "Error", "(", "'libvips too old'", ")", "psize", "=", "ffi", ".", "new", "(", "'size_t *'", ")"...
Fill a region with pixel data. Pixels are filled with data! Returns: Pixel data. Raises: :class:`.Error`
[ "Fill", "a", "region", "with", "pixel", "data", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/vregion.py#L52-L74
train
libvips/pyvips
pyvips/gvalue.py
GValue.gtype_to_python
def gtype_to_python(gtype): """Map a gtype to the name of the Python type we use to represent it. """ fundamental = gobject_lib.g_type_fundamental(gtype) if gtype in GValue._gtype_to_python: return GValue._gtype_to_python[gtype] if fundamental in GValue._gtype_to_p...
python
def gtype_to_python(gtype): """Map a gtype to the name of the Python type we use to represent it. """ fundamental = gobject_lib.g_type_fundamental(gtype) if gtype in GValue._gtype_to_python: return GValue._gtype_to_python[gtype] if fundamental in GValue._gtype_to_p...
[ "def", "gtype_to_python", "(", "gtype", ")", ":", "fundamental", "=", "gobject_lib", ".", "g_type_fundamental", "(", "gtype", ")", "if", "gtype", "in", "GValue", ".", "_gtype_to_python", ":", "return", "GValue", ".", "_gtype_to_python", "[", "gtype", "]", "if"...
Map a gtype to the name of the Python type we use to represent it.
[ "Map", "a", "gtype", "to", "the", "name", "of", "the", "Python", "type", "we", "use", "to", "represent", "it", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/gvalue.py#L75-L86
train
libvips/pyvips
pyvips/gvalue.py
GValue.to_enum
def to_enum(gtype, value): """Turn a string into an enum value ready to be passed into libvips. """ if isinstance(value, basestring if _is_PY2 else str): enum_value = vips_lib.vips_enum_from_nick(b'pyvips', gtype, _to_bytes(valu...
python
def to_enum(gtype, value): """Turn a string into an enum value ready to be passed into libvips. """ if isinstance(value, basestring if _is_PY2 else str): enum_value = vips_lib.vips_enum_from_nick(b'pyvips', gtype, _to_bytes(valu...
[ "def", "to_enum", "(", "gtype", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "basestring", "if", "_is_PY2", "else", "str", ")", ":", "enum_value", "=", "vips_lib", ".", "vips_enum_from_nick", "(", "b'pyvips'", ",", "gtype", ",", "_to_byte...
Turn a string into an enum value ready to be passed into libvips.
[ "Turn", "a", "string", "into", "an", "enum", "value", "ready", "to", "be", "passed", "into", "libvips", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/gvalue.py#L89-L103
train
libvips/pyvips
pyvips/gvalue.py
GValue.from_enum
def from_enum(gtype, enum_value): """Turn an int back into an enum string. """ pointer = vips_lib.vips_enum_nick(gtype, enum_value) if pointer == ffi.NULL: raise Error('value not in enum') return _to_string(pointer)
python
def from_enum(gtype, enum_value): """Turn an int back into an enum string. """ pointer = vips_lib.vips_enum_nick(gtype, enum_value) if pointer == ffi.NULL: raise Error('value not in enum') return _to_string(pointer)
[ "def", "from_enum", "(", "gtype", ",", "enum_value", ")", ":", "pointer", "=", "vips_lib", ".", "vips_enum_nick", "(", "gtype", ",", "enum_value", ")", "if", "pointer", "==", "ffi", ".", "NULL", ":", "raise", "Error", "(", "'value not in enum'", ")", "retu...
Turn an int back into an enum string.
[ "Turn", "an", "int", "back", "into", "an", "enum", "string", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/gvalue.py#L106-L115
train
libvips/pyvips
pyvips/gvalue.py
GValue.set
def set(self, value): """Set a GValue. The value is converted to the type of the GValue, if possible, and assigned. """ # logger.debug('GValue.set: value = %s', value) gtype = self.gvalue.g_type fundamental = gobject_lib.g_type_fundamental(gtype) if g...
python
def set(self, value): """Set a GValue. The value is converted to the type of the GValue, if possible, and assigned. """ # logger.debug('GValue.set: value = %s', value) gtype = self.gvalue.g_type fundamental = gobject_lib.g_type_fundamental(gtype) if g...
[ "def", "set", "(", "self", ",", "value", ")", ":", "# logger.debug('GValue.set: value = %s', value)", "gtype", "=", "self", ".", "gvalue", ".", "g_type", "fundamental", "=", "gobject_lib", ".", "g_type_fundamental", "(", "gtype", ")", "if", "gtype", "==", "GValu...
Set a GValue. The value is converted to the type of the GValue, if possible, and assigned.
[ "Set", "a", "GValue", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/gvalue.py#L139-L228
train
libvips/pyvips
pyvips/gvalue.py
GValue.get
def get(self): """Get the contents of a GValue. The contents of the GValue are read out as a Python type. """ # logger.debug('GValue.get: self = %s', self) gtype = self.gvalue.g_type fundamental = gobject_lib.g_type_fundamental(gtype) result = None if...
python
def get(self): """Get the contents of a GValue. The contents of the GValue are read out as a Python type. """ # logger.debug('GValue.get: self = %s', self) gtype = self.gvalue.g_type fundamental = gobject_lib.g_type_fundamental(gtype) result = None if...
[ "def", "get", "(", "self", ")", ":", "# logger.debug('GValue.get: self = %s', self)", "gtype", "=", "self", ".", "gvalue", ".", "g_type", "fundamental", "=", "gobject_lib", ".", "g_type_fundamental", "(", "gtype", ")", "result", "=", "None", "if", "gtype", "==",...
Get the contents of a GValue. The contents of the GValue are read out as a Python type.
[ "Get", "the", "contents", "of", "a", "GValue", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/gvalue.py#L230-L314
train
libvips/pyvips
examples/cod.py
to_polar
def to_polar(image): """Transform image coordinates to polar. The image is transformed so that it is wrapped around a point in the centre. Vertical straight lines become circles or segments of circles, horizontal straight lines become radial spokes. """ # xy image, origin in the centre, scaled ...
python
def to_polar(image): """Transform image coordinates to polar. The image is transformed so that it is wrapped around a point in the centre. Vertical straight lines become circles or segments of circles, horizontal straight lines become radial spokes. """ # xy image, origin in the centre, scaled ...
[ "def", "to_polar", "(", "image", ")", ":", "# xy image, origin in the centre, scaled to fit image to a circle", "xy", "=", "pyvips", ".", "Image", ".", "xyz", "(", "image", ".", "width", ",", "image", ".", "height", ")", "xy", "-=", "[", "image", ".", "width",...
Transform image coordinates to polar. The image is transformed so that it is wrapped around a point in the centre. Vertical straight lines become circles or segments of circles, horizontal straight lines become radial spokes.
[ "Transform", "image", "coordinates", "to", "polar", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/examples/cod.py#L12-L30
train
libvips/pyvips
examples/cod.py
to_rectangular
def to_rectangular(image): """Transform image coordinates to rectangular. The image is transformed so that it is unwrapped from a point in the centre. Circles or segments of circles become vertical straight lines, radial lines become horizontal lines. """ # xy image, vertical scaled to 360 degr...
python
def to_rectangular(image): """Transform image coordinates to rectangular. The image is transformed so that it is unwrapped from a point in the centre. Circles or segments of circles become vertical straight lines, radial lines become horizontal lines. """ # xy image, vertical scaled to 360 degr...
[ "def", "to_rectangular", "(", "image", ")", ":", "# xy image, vertical scaled to 360 degrees", "xy", "=", "pyvips", ".", "Image", ".", "xyz", "(", "image", ".", "width", ",", "image", ".", "height", ")", "xy", "*=", "[", "1", ",", "360.0", "/", "image", ...
Transform image coordinates to rectangular. The image is transformed so that it is unwrapped from a point in the centre. Circles or segments of circles become vertical straight lines, radial lines become horizontal lines.
[ "Transform", "image", "coordinates", "to", "rectangular", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/examples/cod.py#L33-L51
train
libvips/pyvips
pyvips/error.py
_to_string
def _to_string(x): """Convert to a unicode string. If x is a byte string, assume it is utf-8 and decode to a Python unicode string. You must call this on text strings you get back from libvips. """ if x == ffi.NULL: x = 'NULL' else: x = ffi.string(x) if isinstance(x, by...
python
def _to_string(x): """Convert to a unicode string. If x is a byte string, assume it is utf-8 and decode to a Python unicode string. You must call this on text strings you get back from libvips. """ if x == ffi.NULL: x = 'NULL' else: x = ffi.string(x) if isinstance(x, by...
[ "def", "_to_string", "(", "x", ")", ":", "if", "x", "==", "ffi", ".", "NULL", ":", "x", "=", "'NULL'", "else", ":", "x", "=", "ffi", ".", "string", "(", "x", ")", "if", "isinstance", "(", "x", ",", "byte_type", ")", ":", "x", "=", "x", ".", ...
Convert to a unicode string. If x is a byte string, assume it is utf-8 and decode to a Python unicode string. You must call this on text strings you get back from libvips.
[ "Convert", "to", "a", "unicode", "string", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/error.py#L33-L47
train
libvips/pyvips
pyvips/vinterpolate.py
Interpolate.new
def new(name): """Make a new interpolator by name. Make a new interpolator from the libvips class nickname. For example:: inter = pyvips.Interpolator.new('bicubic') You can get a list of all supported interpolators from the command-line with:: $ vips -l interp...
python
def new(name): """Make a new interpolator by name. Make a new interpolator from the libvips class nickname. For example:: inter = pyvips.Interpolator.new('bicubic') You can get a list of all supported interpolators from the command-line with:: $ vips -l interp...
[ "def", "new", "(", "name", ")", ":", "# logger.debug('VipsInterpolate.new: name = %s', name)", "vi", "=", "vips_lib", ".", "vips_interpolate_new", "(", "_to_bytes", "(", "name", ")", ")", "if", "vi", "==", "ffi", ".", "NULL", ":", "raise", "Error", "(", "'no s...
Make a new interpolator by name. Make a new interpolator from the libvips class nickname. For example:: inter = pyvips.Interpolator.new('bicubic') You can get a list of all supported interpolators from the command-line with:: $ vips -l interpolate See for exa...
[ "Make", "a", "new", "interpolator", "by", "name", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/vinterpolate.py#L21-L44
train
libvips/pyvips
pyvips/vimage.py
_run_cmplx
def _run_cmplx(fn, image): """Run a complex function on a non-complex image. The image needs to be complex, or have an even number of bands. The input can be int, the output is always float or double. """ original_format = image.format if image.format != 'complex' and image.format != 'dpcomple...
python
def _run_cmplx(fn, image): """Run a complex function on a non-complex image. The image needs to be complex, or have an even number of bands. The input can be int, the output is always float or double. """ original_format = image.format if image.format != 'complex' and image.format != 'dpcomple...
[ "def", "_run_cmplx", "(", "fn", ",", "image", ")", ":", "original_format", "=", "image", ".", "format", "if", "image", ".", "format", "!=", "'complex'", "and", "image", ".", "format", "!=", "'dpcomplex'", ":", "if", "image", ".", "bands", "%", "2", "!=...
Run a complex function on a non-complex image. The image needs to be complex, or have an even number of bands. The input can be int, the output is always float or double.
[ "Run", "a", "complex", "function", "on", "a", "non", "-", "complex", "image", "." ]
f4d9334d2e3085b4b058129f14ac17a7872b109b
https://github.com/libvips/pyvips/blob/f4d9334d2e3085b4b058129f14ac17a7872b109b/pyvips/vimage.py#L50-L82
train