_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q14200
_explode_lines
train
def _explode_lines(shape): """ Return a list of LineStrings which make up the shape. """ if shape.geom_type == 'LineString': return [shape] elif shape.geom_type == 'MultiLineString': return shape.geoms elif shape.geom_type == 'GeometryCollection': lines = [] fo...
python
{ "resource": "" }
q14201
_orient
train
def _orient(shape): """ The Shapely version of the orient function appears to only work on Polygons, and fails on MultiPolygons. This is a quick wrapper to allow orienting of either. """ assert shape.geom_type in ('Polygon', 'MultiPolygon') if shape.geom_type == 'Polygon': return o...
python
{ "resource": "" }
q14202
GeomEncoder.parseGeometry
train
def parseGeometry(self, geometry): """ A factory method for creating objects of the correct OpenGIS type. """ self.coordinates = [] self.index = [] self.position = 0 self.lastX = 0 self.lastY = 0 self.isPoly = False self.isPoint...
python
{ "resource": "" }
q14203
calc_buffered_bounds
train
def calc_buffered_bounds( format, bounds, meters_per_pixel_dim, layer_name, geometry_type, buffer_cfg): """ Calculate the buffered bounds per format per layer based on config. """ if not buffer_cfg: return bounds format_buffer_cfg = buffer_cfg.get(format.extension) if f...
python
{ "resource": "" }
q14204
_intersect_multipolygon
train
def _intersect_multipolygon(shape, tile_bounds, clip_bounds): """ Return the parts of the MultiPolygon shape which overlap the tile_bounds, each clipped to the clip_bounds. This can be used to extract only the parts of a multipolygon which are actually visible in the tile, while keeping those parts ...
python
{ "resource": "" }
q14205
_clip_shape
train
def _clip_shape(shape, buffer_padded_bounds, is_clipped, clip_factor): """ Return the shape clipped to a clip_factor expansion of buffer_padded_bounds if is_clipped is True. Otherwise return the original shape, or None if the shape does not intersect buffer_padded_bounds at all. This is used to red...
python
{ "resource": "" }
q14206
BasicIDTokenHandler.now
train
def now(self): """ Capture time. """ if self._now is None: # Compute the current time only once per instance self._now = datetime.utcnow() return self._now
python
{ "resource": "" }
q14207
BasicIDTokenHandler.claim_exp
train
def claim_exp(self, data): """ Required expiration time. """ expiration = getattr(settings, 'OAUTH_ID_TOKEN_EXPIRATION', 30) expires = self.now + timedelta(seconds=expiration) return timegm(expires.utctimetuple())
python
{ "resource": "" }
q14208
Command._clean_required_args
train
def _clean_required_args(self, url, redirect_uri, client_type): """ Validate and clean the command's arguments. Arguments: url (str): Client's application URL. redirect_uri (str): Client application's OAuth2 callback URI. client_type (str): Client's type, ind...
python
{ "resource": "" }
q14209
Command._parse_options
train
def _parse_options(self, options): """Parse the command's options. Arguments: options (dict): Options with which the command was called. Raises: CommandError, if a user matching the provided username does not exist. """ for key in ('username', 'client_na...
python
{ "resource": "" }
q14210
AccessTokenView.access_token_response_data
train
def access_token_response_data(self, access_token, response_type=None, nonce=''): """ Return `access_token` fields for OAuth2, and add `id_token` fields for OpenID Connect according to the `access_token` scope. """ # Clear the scope for requests that do not use OpenID Connect. ...
python
{ "resource": "" }
q14211
AccessTokenView.get_id_token
train
def get_id_token(self, access_token, nonce): """ Return an ID token for the given Access Token. """ claims_string = self.request.POST.get('claims') claims_request = json.loads(claims_string) if claims_string else {} return oidc.id_token(access_token, nonce, claims_request)
python
{ "resource": "" }
q14212
AccessTokenView.encode_id_token
train
def encode_id_token(self, id_token): """ Return encoded ID token. """ # Encode the ID token using the `client_secret`. # # TODO: Using the `client_secret` is not ideal, since it is transmitted # over the wire in some authentication flows. A better alternative i...
python
{ "resource": "" }
q14213
UserInfoView.get
train
def get(self, request, *_args, **_kwargs): """ Respond to a UserInfo request. Two optional query parameters are accepted, scope and claims. See the references above for more details. """ access_token = self.access_token scope_string = request.GET.get('scope') ...
python
{ "resource": "" }
q14214
UserInfoView.userinfo_claims
train
def userinfo_claims(self, access_token, scope_request, claims_request): """ Return the claims for the requested parameters. """ id_token = oidc.userinfo(access_token, scope_request, claims_request) return id_token.claims
python
{ "resource": "" }
q14215
collect
train
def collect(handlers, access_token, scope_request=None, claims_request=None): """ Collect all the claims values from the `handlers`. Arguments: handlers (list): List of claim :class:`Handler` classes. access_token (:class:AccessToken): Associated access token. scope_request (list): List o...
python
{ "resource": "" }
q14216
_collect_scopes
train
def _collect_scopes(handlers, scopes, user, client): """ Get a set of all the authorized scopes according to the handlers. """ results = set() data = {'user': user, 'client': client} def visitor(scope_name, func): claim_names = func(data) # If the claim_names is None, it means that the...
python
{ "resource": "" }
q14217
_collect_names
train
def _collect_names(handlers, scopes, user, client): """ Get the names of the claims supported by the handlers for the requested scope. """ results = set() data = {'user': user, 'client': client} def visitor(_scope_name, func): claim_names = func(data) # If the claim_names is None, it ...
python
{ "resource": "" }
q14218
_collect_values
train
def _collect_values(handlers, names, user, client, values): """ Get the values from the handlers of the requested claims. """ results = {} def visitor(claim_name, func): data = {'user': user, 'client': client} data.update(values.get(claim_name) or {}) claim_value = func(data) ...
python
{ "resource": "" }
q14219
_validate_claim_values
train
def _validate_claim_values(name, value, ignore_errors): """ Helper for `validate_claim_request` """ results = {'essential': False} for key, value in value.iteritems(): if key in CLAIM_REQUEST_FIELDS: results[key] = value else: if not ignore_errors: msg...
python
{ "resource": "" }
q14220
_visit_handlers
train
def _visit_handlers(handlers, visitor, prefix, suffixes): """ Use visitor partern to collect information from handlers """ results = [] for handler in handlers: for suffix in suffixes: func = getattr(handler, '{}_{}'.format(prefix, suffix).lower(), None) if func: ...
python
{ "resource": "" }
q14221
CreateView.update_model
train
def update_model(self, model): """ trivial implementation for simple data in the form, using the model prefix. """ for k, v in self.parse_form().items(): setattr(model, k, v)
python
{ "resource": "" }
q14222
locale_negotiator
train
def locale_negotiator(request): """Locale negotiator base on the `Accept-Language` header""" locale = 'en' if request.accept_language: locale = request.accept_language.best_match(LANGUAGES) locale = LANGUAGES.get(locale, 'en') return locale
python
{ "resource": "" }
q14223
main
train
def main(global_config, **settings): """ Get a PyShop WSGI application configured with settings. """ if sys.version_info[0] < 3: reload(sys) sys.setdefaultencoding('utf-8') settings = dict(settings) # Scoping sessions for Pyramid ensure session are commit/rollback # after th...
python
{ "resource": "" }
q14224
User.by_login
train
def by_login(cls, session, login, local=True): """ Get a user from a given login. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :param login: the user login :type login: unicode :return: the associated user :rtype: :class...
python
{ "resource": "" }
q14225
User.by_credentials
train
def by_credentials(cls, session, login, password): """ Get a user from given credentials :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :param login: username :type login: unicode :param password: user password :type passw...
python
{ "resource": "" }
q14226
User.get_locals
train
def get_locals(cls, session, **kwargs): """ Get all local users. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :return: local users :rtype: generator of :class:`pyshop.models.User` """ return cls.find(session, ...
python
{ "resource": "" }
q14227
User.validate
train
def validate(self, session): """ Validate that the current user can be saved. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :return: ``True`` :rtype: bool :raise: :class:`pyshop.helpers.sqla.ModelError` if user is not valid ...
python
{ "resource": "" }
q14228
Classifier.by_name
train
def by_name(cls, session, name, **kwargs): """ Get a classifier from a given name. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :param name: name of the classifier :type name: `unicode :return: classifier instance :rtype...
python
{ "resource": "" }
q14229
Package.sorted_releases
train
def sorted_releases(self): """ Releases sorted by version. """ releases = [(parse_version(release.version), release) for release in self.releases] releases.sort(reverse=True) return [release[1] for release in releases]
python
{ "resource": "" }
q14230
Package.by_filter
train
def by_filter(cls, session, opts, **kwargs): """ Get packages from given filters. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :param opts: filtering options :type opts: `dict :return: package instances :rtype: generator...
python
{ "resource": "" }
q14231
Package.by_owner
train
def by_owner(cls, session, owner_name): """ Get packages from a given owner username. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :param owner_name: owner username :type owner_name: unicode :return: package instances :r...
python
{ "resource": "" }
q14232
Package.by_maintainer
train
def by_maintainer(cls, session, maintainer_name): """ Get package from a given maintainer name. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :param maintainer_name: maintainer username :type maintainer_name: unicode :return: pac...
python
{ "resource": "" }
q14233
Package.get_locals
train
def get_locals(cls, session): """ Get all local packages. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :return: package instances :rtype: generator of :class:`pyshop.models.Package` """ return cls.find(session, ...
python
{ "resource": "" }
q14234
Package.get_mirrored
train
def get_mirrored(cls, session): """ Get all mirrored packages. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :return: package instances :rtype: generator of :class:`pyshop.models.Package` """ return cls.find(session, ...
python
{ "resource": "" }
q14235
Release.by_version
train
def by_version(cls, session, package_name, version): """ Get release for a given version. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :param package_name: package name :type package_name: unicode :param version: version ...
python
{ "resource": "" }
q14236
Release.by_classifiers
train
def by_classifiers(cls, session, classifiers): """ Get releases for given classifiers. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :param classifiers: classifiers :type classifiers: unicode :return: release instances :r...
python
{ "resource": "" }
q14237
Release.search
train
def search(cls, session, opts, operator): """ Get releases for given filters. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :param opts: filtering options :type opts: dict :param operator: filtering options joining operator (`and...
python
{ "resource": "" }
q14238
ReleaseFile.by_release
train
def by_release(cls, session, package_name, version): """ Get release files for a given package name and for a given version. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :param package_name: package name :type package_name: unico...
python
{ "resource": "" }
q14239
ReleaseFile.by_filename
train
def by_filename(cls, session, release, filename): """ Get a release file for a given release and a given filename. :param session: SQLAlchemy session :type session: :class:`sqlalchemy.Session` :param release: release :type release: :class:`pyshop.models.Release` ...
python
{ "resource": "" }
q14240
add_urlhelpers
train
def add_urlhelpers(event): """ Add helpers to the template engine. """ event['static_url'] = lambda x: static_path(x, event['request']) event['route_url'] = lambda name, *args, **kwargs: \ route_path(name, event['request'], *args, **kwargs) event['parse_rest'] = parse_rest event['has...
python
{ "resource": "" }
q14241
list_packages
train
def list_packages(request): """ Retrieve a list of the package names registered with the package index. Returns a list of name strings. """ session = DBSession() names = [p.name for p in Package.all(session, order_by=Package.name)] return names
python
{ "resource": "" }
q14242
package_releases
train
def package_releases(request, package_name, show_hidden=False): """ Retrieve a list of the releases registered for the given package_name. Returns a list with all version strings if show_hidden is True or only the non-hidden ones otherwise.""" session = DBSession() package = Package.by_name(sess...
python
{ "resource": "" }
q14243
package_roles
train
def package_roles(request, package_name): """ Retrieve a list of users and their attributes roles for a given package_name. Role is either 'Maintainer' or 'Owner'. """ session = DBSession() package = Package.by_name(session, package_name) owners = [('Owner', o.name) for o in package.owners] ...
python
{ "resource": "" }
q14244
release_downloads
train
def release_downloads(request, package_name, version): """ Retrieve a list of files and download count for a given package and release version. """ session = DBSession() release_files = ReleaseFile.by_release(session, package_name, version) if release_files: release_files = [(f.relea...
python
{ "resource": "" }
q14245
search
train
def search(request, spec, operator='and'): """ Search the package database using the indicated search spec. The spec may include any of the keywords described in the above list (except 'stable_version' and 'classifiers'), for example: {'description': 'spam'} will search description fields. With...
python
{ "resource": "" }
q14246
set_proxy
train
def set_proxy(proxy_url, transport_proxy=None): """Create the proxy to PyPI XML-RPC Server""" global proxy, PYPI_URL PYPI_URL = proxy_url proxy = xmlrpc.ServerProxy( proxy_url, transport=RequestsTransport(proxy_url.startswith('https://')), allow_none=True)
python
{ "resource": "" }
q14247
authbasic
train
def authbasic(request): """ Authentification basic, Upload pyshop repository access """ if len(request.environ.get('HTTP_AUTHORIZATION', '')) > 0: auth = request.environ.get('HTTP_AUTHORIZATION') scheme, data = auth.split(None, 1) assert scheme.lower() == 'basic' data = b...
python
{ "resource": "" }
q14248
decode_b64
train
def decode_b64(data): '''Wrapper for b64decode, without having to struggle with bytestrings.''' byte_string = data.encode('utf-8') decoded = base64.b64decode(byte_string) return decoded.decode('utf-8')
python
{ "resource": "" }
q14249
encode_b64
train
def encode_b64(data): '''Wrapper for b64encode, without having to struggle with bytestrings.''' byte_string = data.encode('utf-8') encoded = base64.b64encode(byte_string) return encoded.decode('utf-8')
python
{ "resource": "" }
q14250
de_shift_kernel
train
def de_shift_kernel(kernel, shift_x, shift_y, iterations=20): """ de-shifts a shifted kernel to the center of a pixel. This is performed iteratively. The input kernel is the solution of a linear interpolated shift of a sharper kernel centered in the middle of the pixel. To find the de-shifted kernel, ...
python
{ "resource": "" }
q14251
center_kernel
train
def center_kernel(kernel, iterations=20): """ given a kernel that might not be perfectly centered, this routine computes its light weighted center and then moves the center in an iterative process such that it is centered :param kernel: 2d array (odd numbers) :param iterations: int, number of itera...
python
{ "resource": "" }
q14252
subgrid_kernel
train
def subgrid_kernel(kernel, subgrid_res, odd=False, num_iter=100): """ creates a higher resolution kernel with subgrid resolution as an interpolation of the original kernel in an iterative approach :param kernel: initial kernel :param subgrid_res: subgrid resolution required :return: kernel with...
python
{ "resource": "" }
q14253
pixel_kernel
train
def pixel_kernel(point_source_kernel, subgrid_res=7): """ converts a pixelised kernel of a point source to a kernel representing a uniform extended pixel :param point_source_kernel: :param subgrid_res: :return: convolution kernel for an extended pixel """ kernel_subgrid = subgrid_kernel(poi...
python
{ "resource": "" }
q14254
split_kernel
train
def split_kernel(kernel, kernel_subgrid, subsampling_size, subgrid_res): """ pixel kernel and subsampling kernel such that the convolution of both applied on an image can be performed, i.e. smaller subsampling PSF and hole in larger PSF :param kernel: PSF kernel of the size of the pixel :param kern...
python
{ "resource": "" }
q14255
NFW.density
train
def density(self, R, Rs, rho0): """ three dimenstional NFW profile :param R: radius of interest :type R: float/numpy array :param Rs: scale radius :type Rs: float :param rho0: density normalization (characteristic density) :type rho0: float :retur...
python
{ "resource": "" }
q14256
NFW._alpha2rho0
train
def _alpha2rho0(self, theta_Rs, Rs): """ convert angle at Rs into rho0 """ rho0 = theta_Rs / (4. * Rs ** 2 * (1. + np.log(1. / 2.))) return rho0
python
{ "resource": "" }
q14257
NFW._rho02alpha
train
def _rho02alpha(self, rho0, Rs): """ convert rho0 to angle at Rs :param rho0: :param Rs: :return: """ theta_Rs = rho0 * (4 * Rs ** 2 * (1 + np.log(1. / 2.))) return theta_Rs
python
{ "resource": "" }
q14258
LightModel.param_name_list
train
def param_name_list(self): """ returns the list of all parameter names :return: list of list of strings (for each light model separately) """ name_list = [] for func in self.func_list: name_list.append(func.param_names) return name_list
python
{ "resource": "" }
q14259
LightModel.total_flux
train
def total_flux(self, kwargs_list, norm=False, k=None): """ Computes the total flux of each individual light profile. This allows to estimate the total flux as well as lenstronomy amp to magnitude conversions. Not all models are supported :param kwargs_list: list of keyword arguments cor...
python
{ "resource": "" }
q14260
SersicUtil.k_bn
train
def k_bn(self, n, Re): """ returns normalisation of the sersic profile such that Re is the half light radius given n_sersic slope """ bn = self.b_n(n) k = bn*Re**(-1./n) return k, bn
python
{ "resource": "" }
q14261
SersicUtil._total_flux
train
def _total_flux(self, r_eff, I_eff, n_sersic): """ computes total flux of a Sersic profile :param r_eff: projected half light radius :param I_eff: surface brightness at r_eff (in same units as r_eff) :param n_sersic: Sersic index :return: integrated flux to infinity ...
python
{ "resource": "" }
q14262
Galkin.sigma2_R
train
def sigma2_R(self, R, kwargs_mass, kwargs_light, kwargs_anisotropy): """ returns unweighted los velocity dispersion for a specified projected radius :param R: 2d projected radius (in angular units) :param kwargs_mass: mass model parameters (following lenstronomy lens model conventions) ...
python
{ "resource": "" }
q14263
make_grid_with_coordtransform
train
def make_grid_with_coordtransform(numPix, deltapix, subgrid_res=1, left_lower=False, inverse=True): """ same as make_grid routine, but returns the transformaton matrix and shift between coordinates and pixel :param numPix: :param deltapix: :param subgrid_res: :param left_lower: sets the zero po...
python
{ "resource": "" }
q14264
grid_from_coordinate_transform
train
def grid_from_coordinate_transform(numPix, Mpix2coord, ra_at_xy_0, dec_at_xy_0): """ return a grid in x and y coordinates that satisfy the coordinate system :param numPix: :param Mpix2coord: :param ra_at_xy_0: :param dec_at_xy_0: :return: """ a = np.arange(numPix) matrix = np.d...
python
{ "resource": "" }
q14265
displaceAbs
train
def displaceAbs(x, y, sourcePos_x, sourcePos_y): """ calculates a grid of distances to the observer in angel :param mapped_cartcoord: mapped cartesian coordinates :type mapped_cartcoord: numpy array (n,2) :param sourcePos: source position :type sourcePos: numpy vector [x0,y0] :returns: arr...
python
{ "resource": "" }
q14266
CoreSersic.function
train
def function(self, x, y, amp, R_sersic, Re, n_sersic, gamma, e1, e2, center_x=0, center_y=0, alpha=3.): """ returns Core-Sersic function """ phi_G, q = param_util.ellipticity2phi_q(e1, e2) Rb = R_sersic x_shift = x - center_x y_shift = y - center_y cos_ph...
python
{ "resource": "" }
q14267
CNFW.density
train
def density(self, R, Rs, rho0, r_core): """ three dimenstional truncated NFW profile :param R: radius of interest :type R: float/numpy array :param Rs: scale radius :type Rs: float :param rho0: density normalization (central core density) :type rho0: floa...
python
{ "resource": "" }
q14268
PSF.set_pixel_size
train
def set_pixel_size(self, deltaPix): """ update pixel size :param deltaPix: :return: """ self._pixel_size = deltaPix if self.psf_type == 'GAUSSIAN': try: del self._kernel_point_source except: pass
python
{ "resource": "" }
q14269
PSF.psf_convolution
train
def psf_convolution(self, grid, grid_scale, psf_subgrid=False, subgrid_res=1): """ convolves a given pixel grid with a PSF """ psf_type = self.psf_type if psf_type == 'NONE': return grid elif psf_type == 'GAUSSIAN': sigma = self._sigma_gaussian/gri...
python
{ "resource": "" }
q14270
TimeDelayLikelihood._logL_delays
train
def _logL_delays(self, delays_model, delays_measured, delays_errors): """ log likelihood of modeled delays vs measured time delays under considerations of errors :param delays_model: n delays of the model (not relative delays) :param delays_measured: relative delays (1-2,1-3,1-4) relati...
python
{ "resource": "" }
q14271
LensModelPlot.plot_main
train
def plot_main(self, with_caustics=False, image_names=False): """ print the main plots together in a joint frame :return: """ f, axes = plt.subplots(2, 3, figsize=(16, 8)) self.data_plot(ax=axes[0, 0]) self.model_plot(ax=axes[0, 1], image_names=True) self...
python
{ "resource": "" }
q14272
LensModelPlot.plot_separate
train
def plot_separate(self): """ plot the different model components separately :return: """ f, axes = plt.subplots(2, 3, figsize=(16, 8)) self.decomposition_plot(ax=axes[0, 0], text='Lens light', lens_light_add=True, unconvolved=True) self.decomposition_plot(ax=axe...
python
{ "resource": "" }
q14273
LensModelPlot.plot_subtract_from_data_all
train
def plot_subtract_from_data_all(self): """ subtract model components from data :return: """ f, axes = plt.subplots(2, 3, figsize=(16, 8)) self.subtract_from_data_plot(ax=axes[0, 0], text='Data') self.subtract_from_data_plot(ax=axes[0, 1], text='Data - Point Sour...
python
{ "resource": "" }
q14274
PolarShapelets._chi_lr
train
def _chi_lr(self,r, phi, nl,nr,beta): """ computes the generalized polar basis function in the convention of Massey&Refregier eqn 8 :param nl: left basis :type nl: int :param nr: right basis :type nr: int :param beta: beta --the characteristic scale typically cho...
python
{ "resource": "" }
q14275
TNFW.nfwPot
train
def nfwPot(self, R, Rs, rho0, r_trunc): """ lensing potential of NFW profile :param R: radius of interest :type R: float/numpy array :param Rs: scale radius :type Rs: float :param rho0: density normalization (characteristic density) :type rho0: float ...
python
{ "resource": "" }
q14276
TNFW._g
train
def _g(self, x, tau): """ analytic solution of integral for NFW profile to compute deflection angel and gamma :param x: R/Rs :type x: float >0 """ return tau ** 2 * (tau ** 2 + 1) ** -2 * ( (tau ** 2 + 1 + 2 * (x ** 2 - 1)) * self.F(x) + tau * np.pi + (ta...
python
{ "resource": "" }
q14277
transform_e1e2
train
def transform_e1e2(x, y, e1, e2, center_x=0, center_y=0): """ maps the coordinates x, y with eccentricities e1 e2 into a new elliptical coordiante system :param x: :param y: :param e1: :param e2: :param center_x: :param center_y: :return: """ x_shift = x - center_x y_shi...
python
{ "resource": "" }
q14278
LensProp.time_delays
train
def time_delays(self, kwargs_lens, kwargs_ps, kappa_ext=0): """ predicts the time delays of the image positions :param kwargs_lens: lens model parameters :param kwargs_ps: point source parameters :param kappa_ext: external convergence (optional) :return: time delays at i...
python
{ "resource": "" }
q14279
LensProp.velocity_dispersion
train
def velocity_dispersion(self, kwargs_lens, kwargs_lens_light, lens_light_model_bool_list=None, aniso_param=1, r_eff=None, R_slit=0.81, dR_slit=0.1, psf_fwhm=0.7, num_evaluate=1000): """ computes the LOS velocity dispersion of the lens within a slit of size R_slit x dR_slit an...
python
{ "resource": "" }
q14280
Moffat.function
train
def function(self, x, y, amp, alpha, beta, center_x, center_y): """ returns Moffat profile """ x_shift = x - center_x y_shift = y - center_y return amp * (1. + (x_shift**2+y_shift**2)/alpha**2)**(-beta)
python
{ "resource": "" }
q14281
Sampler.mcmc_CH
train
def mcmc_CH(self, walkerRatio, n_run, n_burn, mean_start, sigma_start, threadCount=1, init_pos=None, mpi=False): """ runs mcmc on the parameter space given parameter bounds with CosmoHammerSampler returns the chain """ lowerLimit, upperLimit = self.lower_limit, self.upper_limit ...
python
{ "resource": "" }
q14282
Param.image2source_plane
train
def image2source_plane(self, kwargs_source, kwargs_lens, image_plane=False): """ maps the image plane position definition of the source plane :param kwargs_source: :param kwargs_lens: :return: """ kwargs_source_copy = copy.deepcopy(kwargs_source) for i, k...
python
{ "resource": "" }
q14283
Param.update_lens_scaling
train
def update_lens_scaling(self, kwargs_cosmo, kwargs_lens, inverse=False): """ multiplies the scaling parameters of the profiles :param args: :param kwargs_lens: :param i: :param inverse: :return: """ kwargs_lens_updated = copy.deepcopy(kwargs_lens)...
python
{ "resource": "" }
q14284
Param.print_setting
train
def print_setting(self): """ prints the setting of the parameter class :return: """ num, param_list = self.num_param() num_linear = self.num_param_linear() print("The following model options are chosen:") print("Lens models:", self._lens_model_list) ...
python
{ "resource": "" }
q14285
MultiExposures._array2image_list
train
def _array2image_list(self, array): """ maps 1d vector of joint exposures in list of 2d images of single exposures :param array: 1d numpy array :return: list of 2d numpy arrays of size of exposures """ image_list = [] k = 0 for i in range(self._num_bands...
python
{ "resource": "" }
q14286
Solver.check_solver
train
def check_solver(self, image_x, image_y, kwargs_lens): """ returns the precision of the solver to match the image position :param kwargs_lens: full lens model (including solved parameters) :param image_x: point source in image :param image_y: point source in image :retur...
python
{ "resource": "" }
q14287
LensCosmo.nfw_angle2physical
train
def nfw_angle2physical(self, Rs_angle, theta_Rs): """ converts the angular parameters into the physical ones for an NFW profile :param theta_Rs: observed bending angle at the scale radius in units of arcsec :param Rs: scale radius in units of arcsec :return: M200, r200, Rs_physi...
python
{ "resource": "" }
q14288
LensCosmo.nfw_physical2angle
train
def nfw_physical2angle(self, M, c): """ converts the physical mass and concentration parameter of an NFW profile into the lensing quantities :param M: mass enclosed 200 rho_crit in units of M_sun :param c: NFW concentration parameter (r200/r_s) :return: theta_Rs (observed bendin...
python
{ "resource": "" }
q14289
sqrt
train
def sqrt(inputArray, scale_min=None, scale_max=None): """Performs sqrt scaling of the input numpy array. @type inputArray: numpy array @param inputArray: image data array @type scale_min: float @param scale_min: minimum data value @type scale_max: float @param scale_max: maximum data value ...
python
{ "resource": "" }
q14290
LikelihoodModule.effectiv_num_data_points
train
def effectiv_num_data_points(self, kwargs_lens, kwargs_source, kwargs_lens_light, kwargs_ps): """ returns the effective number of data points considered in the X2 estimation to compute the reduced X2 value """ num_linear = 0 if self._image_likelihood is True: num_line...
python
{ "resource": "" }
q14291
JeansSolver.sigma_r2
train
def sigma_r2(self, r, kwargs_profile, kwargs_anisotropy, kwargs_light): """ solves radial Jeans equation """ if self._mass_profile == 'power_law': if self._anisotropy_type == 'r_ani': if self._light_profile == 'Hernquist': sigma_r = self.po...
python
{ "resource": "" }
q14292
MCMCSampler.mcmc_emcee
train
def mcmc_emcee(self, n_walkers, n_run, n_burn, mean_start, sigma_start): """ returns the mcmc analysis of the parameter space """ sampler = emcee.EnsembleSampler(n_walkers, self.cosmoParam.numParam, self.chain.likelihood) p0 = emcee.utils.sample_ball(mean_start, sigma_start, n_wa...
python
{ "resource": "" }
q14293
data_configure_simple
train
def data_configure_simple(numPix, deltaPix, exposure_time=1, sigma_bkg=1, inverse=False): """ configures the data keyword arguments with a coordinate grid centered at zero. :param numPix: number of pixel (numPix x numPix) :param deltaPix: pixel size (in angular units) :param exposure_time: exposure...
python
{ "resource": "" }
q14294
findOverlap
train
def findOverlap(x_mins, y_mins, min_distance): """ finds overlapping solutions, deletes multiples and deletes non-solutions and if it is not a solution, deleted as well """ n = len(x_mins) idex = [] for i in range(n): if i == 0: pass else: for j in range(0...
python
{ "resource": "" }
q14295
Data.covariance_matrix
train
def covariance_matrix(self, data, background_rms=1, exposure_map=1, noise_map=None, verbose=False): """ returns a diagonal matrix for the covariance estimation which describes the error Notes: - the exposure map must be positive definite. Values that deviate too much from the mean expo...
python
{ "resource": "" }
q14296
LensEquationSolver.image_position_stochastic
train
def image_position_stochastic(self, source_x, source_y, kwargs_lens, search_window=10, precision_limit=10**(-10), arrival_time_sort=True, x_center=0, y_center=0, num_random=1000, verbose=False): """ Solves the lens equation stochastical...
python
{ "resource": "" }
q14297
LensEquationSolver.image_position_from_source
train
def image_position_from_source(self, sourcePos_x, sourcePos_y, kwargs_lens, min_distance=0.1, search_window=10, precision_limit=10**(-10), num_iter_max=100, arrival_time_sort=True, initial_guess_cut=True, verbose=False, x_center=0, y_center=0, num_ra...
python
{ "resource": "" }
q14298
PointSourceParam.check_positive_flux
train
def check_positive_flux(cls, kwargs_ps): """ check whether inferred linear parameters are positive :param kwargs_ps: :return: bool """ pos_bool = True for kwargs in kwargs_ps: point_amp = kwargs['point_amp'] for amp in point_amp: ...
python
{ "resource": "" }
q14299
FittingSequence.best_fit_likelihood
train
def best_fit_likelihood(self): """ returns the log likelihood of the best fit model of the current state of this class :return: log likelihood, float """ kwargs_lens, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_cosmo = self.best_fit(bijective=False) param_class =...
python
{ "resource": "" }