Search is not available for this dataset
text stringlengths 75 104k |
|---|
def make_full_ivar():
""" take the scatters and skylines and make final ivars """
# skylines come as an ivar
# don't use them for now, because I don't really trust them...
# skylines = np.load("%s/skylines.npz" %DATA_DIR)['arr_0']
ref_flux = np.load("%s/ref_flux_all.npz" %DATA_DIR)['arr_0']
re... |
def _sinusoid(x, p, L, y):
""" Return the sinusoid cont func evaluated at input x for the continuum.
Parameters
----------
x: float or np.array
data, input to function
p: ndarray
coefficients of fitting function
L: float
width of x data
y: float or np.array
... |
def _weighted_median(values, weights, quantile):
""" Calculate a weighted median for values above a particular quantile cut
Used in pseudo continuum normalization
Parameters
----------
values: np ndarray of floats
the values to take the median of
weights: np ndarray of floats
t... |
def _find_cont_gaussian_smooth(wl, fluxes, ivars, w):
""" Returns the weighted mean block of spectra
Parameters
----------
wl: numpy ndarray
wavelength vector
flux: numpy ndarray
block of flux values
ivar: numpy ndarray
block of ivar values
L: float
width of... |
def _cont_norm_gaussian_smooth(dataset, L):
""" Continuum normalize by dividing by a Gaussian-weighted smoothed spectrum
Parameters
----------
dataset: Dataset
the dataset to continuum normalize
L: float
the width of the Gaussian used for weighting
Returns
-------
datas... |
def _find_cont_fitfunc(fluxes, ivars, contmask, deg, ffunc, n_proc=1):
""" Fit a continuum to a continuum pixels in a segment of spectra
Functional form can be either sinusoid or chebyshev, with specified degree
Parameters
----------
fluxes: numpy ndarray of shape (nstars, npixels)
trainin... |
def _find_cont_fitfunc_regions(fluxes, ivars, contmask, deg, ranges, ffunc,
n_proc=1):
""" Run fit_cont, dealing with spectrum in regions or chunks
This is useful if a spectrum has gaps.
Parameters
----------
fluxes: ndarray of shape (nstars, npixels)
trainin... |
def _find_cont_running_quantile(wl, fluxes, ivars, q, delta_lambda,
verbose=False):
""" Perform continuum normalization using a running quantile
Parameters
----------
wl: numpy ndarray
wavelength vector
fluxes: numpy ndarray of shape (nstars, npixels)
... |
def _cont_norm_running_quantile_mp(wl, fluxes, ivars, q, delta_lambda,
n_proc=2, verbose=False):
"""
The same as _cont_norm_running_quantile() above,
but using multi-processing.
Bo Zhang (NAOC)
"""
nStar = fluxes.shape[0]
# start mp.Pool
mp_results = ... |
def _cont_norm_running_quantile_regions(wl, fluxes, ivars, q, delta_lambda,
ranges, verbose=True):
""" Perform continuum normalization using running quantile, for spectrum
that comes in chunks
"""
print("contnorm.py: continuum norm using running quantile")
pri... |
def _cont_norm_running_quantile_regions_mp(wl, fluxes, ivars, q, delta_lambda,
ranges, n_proc=2, verbose=False):
"""
Perform continuum normalization using running quantile, for spectrum
that comes in chunks.
The same as _cont_norm_running_quantile_regions(),
... |
def _cont_norm(fluxes, ivars, cont):
""" Continuum-normalize a continuous segment of spectra.
Parameters
----------
fluxes: numpy ndarray
pixel intensities
ivars: numpy ndarray
inverse variances, parallel to fluxes
contmask: boolean mask
True indicates that pixel is co... |
def _cont_norm_regions(fluxes, ivars, cont, ranges):
""" Perform continuum normalization for spectra in chunks
Useful for spectra that have gaps
Parameters
---------
fluxes: numpy ndarray
pixel intensities
ivars: numpy ndarray
inverse variances, parallel to fluxes
cont: num... |
def train(self, ds):
""" Run training step: solve for best-fit spectral model """
if self.useErrors:
self.coeffs, self.scatters, self.new_tr_labels, self.chisqs, self.pivots, self.scales = _train_model_new(ds)
else:
self.coeffs, self.scatters, self.chisqs, self.pivots, se... |
def infer_spectra(self, ds):
"""
After inferring labels for the test spectra,
infer the model spectra and update the dataset
model_spectra attribute.
Parameters
----------
ds: Dataset object
"""
lvec_all = _get_lvec(ds.test_label_vals, se... |
def plot_contpix(self, x, y, contpix_x, contpix_y, figname):
""" Plot baseline spec with continuum pix overlaid
Parameters
----------
"""
fig, axarr = plt.subplots(2, sharex=True)
plt.xlabel(r"Wavelength $\lambda (\AA)$")
plt.xlim(min(x), max(x))
ax = ax... |
def diagnostics_contpix(self, data, nchunks=10, fig = "baseline_spec_with_cont_pix"):
""" Call plot_contpix once for each nth of the spectrum """
if data.contmask is None:
print("No contmask set")
else:
coeffs_all = self.coeffs
wl = data.wl
baselin... |
def diagnostics_plot_chisq(self, ds, figname = "modelfit_chisqs.png"):
""" Produce a set of diagnostic plots for the model
Parameters
----------
(optional) chisq_dist_plot_name: str
Filename of output saved plot
"""
label_names = ds.get_plotting_labels()
... |
def calc_mass(nu_max, delta_nu, teff):
""" asteroseismic scaling relations """
NU_MAX = 3140.0 # microHz
DELTA_NU = 135.03 # microHz
TEFF = 5777.0
return (nu_max/NU_MAX)**3 * (delta_nu/DELTA_NU)**(-4) * (teff/TEFF)**1.5 |
def calc_mass_2(mh,cm,nm,teff,logg):
""" Table A2 in Martig 2016 """
CplusN = calc_sum(mh,cm,nm)
t = teff/4000.
return (95.8689 - 10.4042*mh - 0.7266*mh**2
+ 41.3642*cm - 5.3242*cm*mh - 46.7792*cm**2
+ 15.0508*nm - 0.9342*nm*mh - 30.5159*nm*cm - 1.6083*nm**2
- 67.6093... |
def corner(xs, bins=20, range=None, weights=None, color="k",
smooth=None, smooth1d=None,
labels=None, label_kwargs=None,
show_titles=False, title_fmt=".2f", title_kwargs=None,
truths=None, truth_color="#4682b4",
scale_hist=False, quantiles=None, verbose=False, fig=... |
def quantile(x, q, weights=None):
"""
Like numpy.percentile, but:
* Values of q are quantiles [0., 1.] rather than percentiles [0., 100.]
* scalar q not supported (q must be iterable)
* optional weights on x
"""
if weights is None:
return np.percentile(x, [100. * qi for qi in q])
... |
def hist2d(x, y, bins=20, range=None, weights=None, levels=None, smooth=None,
ax=None, color=None, plot_datapoints=True, plot_density=True,
plot_contours=True, no_fill_contours=False, fill_contours=False,
contour_kwargs=None, contourf_kwargs=None, data_kwargs=None,
**kwargs):... |
def calc_dist(lamost_point, training_points, coeffs):
""" avg dist from one lamost point to nearest 10 training points """
diff2 = (training_points - lamost_point)**2
dist = np.sqrt(np.sum(diff2*coeffs, axis=1))
return np.mean(dist[dist.argsort()][0:10]) |
def make_classifier(self, name, ids, labels):
"""Entrenar un clasificador SVM sobre los textos cargados.
Crea un clasificador que se guarda en el objeto bajo el nombre `name`.
Args:
name (str): Nombre para el clasidicador.
ids (list): Se espera una lista de N ids de tex... |
def retrain(self, name, ids, labels):
"""Reentrenar parcialmente un clasificador SVM.
Args:
name (str): Nombre para el clasidicador.
ids (list): Se espera una lista de N ids de textos ya almacenados
en el TextClassifier.
labels (list): Se espera una l... |
def classify(self, classifier_name, examples, max_labels=None,
goodness_of_fit=False):
"""Usar un clasificador SVM para etiquetar textos nuevos.
Args:
classifier_name (str): Nombre del clasidicador a usar.
examples (list or str): Se espera un ejemplo o una lista... |
def _make_text_vectors(self, examples):
"""Funcion para generar los vectores tf-idf de una lista de textos.
Args:
examples (list or str): Se espera un ejemplo o una lista de:
o bien ids, o bien textos.
Returns:
textvec (sparse matrix): Devuelve una matriz... |
def get_similar(self, example, max_similars=3, similarity_cutoff=None,
term_diff_max_rank=10, filter_list=None,
term_diff_cutoff=None):
"""Devuelve textos similares al ejemplo dentro de los textos entrenados.
Nota:
Usa la distancia de coseno del vecto... |
def reload_texts(self, texts, ids, vocabulary=None):
"""Calcula los vectores de terminos de textos y los almacena.
A diferencia de :func:`~TextClassifier.TextClassifier.store_text` esta
funcion borra cualquier informacion almacenada y comienza el conteo
desde cero. Se usa para redefinir... |
def name_suggest(q=None, datasetKey=None, rank=None, limit=100, offset=None, **kwargs):
'''
A quick and simple autocomplete service that returns up to 20 name usages by
doing prefix matching against the scientific name. Results are ordered by relevance.
:param q: [str] Simple search parameter. The value for th... |
def dataset_metrics(uuid, **kwargs):
'''
Get details on a GBIF dataset.
:param uuid: [str] One or more dataset UUIDs. See examples.
References: http://www.gbif.org/developer/registry#datasetMetrics
Usage::
from pygbif import registry
registry.dataset_metrics(uuid='3f8a1297-3259-4700-91fc-acc4170b27ce')
... |
def datasets(data = 'all', type = None, uuid = None, query = None, id = None,
limit = 100, offset = None, **kwargs):
'''
Search for datasets and dataset metadata.
:param data: [str] The type of data to get. Default: ``all``
:param type: [str] Type of dataset, options include ``OCCURRENCE``, etc.
:param uui... |
def dataset_suggest(q=None, type=None, keyword=None, owningOrg=None,
publishingOrg=None, hostingOrg=None, publishingCountry=None, decade=None,
limit = 100, offset = None, **kwargs):
'''
Search that returns up to 20 matching datasets. Results are ordered by relevance.
:param q: [str] Query term(s) for full text s... |
def dataset_search(q=None, type=None, keyword=None,
owningOrg=None, publishingOrg=None, hostingOrg=None, decade=None,
publishingCountry = None, facet = None, facetMincount=None,
facetMultiselect = None, hl = False, limit = 100, offset = None,
**kwargs):
'''
Full text search across all datasets. Results are ordere... |
def wkt_rewind(x, digits = None):
'''
reverse WKT winding order
:param x: [str] WKT string
:param digits: [int] number of digits after decimal to use for the return string.
by default, we use the mean number of digits in your string.
:return: a string
Usage::
from py... |
def occ_issues_lookup(issue=None, code=None):
'''
Lookup occurrence issue definitions and short codes
:param issue: Full name of issue, e.g, CONTINENT_COUNTRY_MISMATCH
:param code: an issue short code, e.g. ccm
Usage
pygbif.occ_issues_lookup(issue = 'CONTINENT_COUNTRY_MISMATCH')
pygbif.occ... |
def search(taxonKey=None, repatriated=None,
kingdomKey=None, phylumKey=None, classKey=None, orderKey=None,
familyKey=None, genusKey=None, subgenusKey=None, scientificName=None,
country=None, publishingCountry=None, hasCoordinate=None, typeStatus=None,
recordNumber=None, lastInterpreted=None, continent=N... |
def networks(data = 'all', uuid = None, q = None, identifier = None,
identifierType = None, limit = 100, offset = None, **kwargs):
'''
Networks metadata.
Note: there's only 1 network now, so there's not a lot you can do with this method.
:param data: [str] The type of data to get. Default: ``all``
:param ... |
def map(source = 'density', z = 0, x = 0, y = 0, format = '@1x.png',
srs='EPSG:4326', bin=None, hexPerTile=None, style='classic.point',
taxonKey=None, country=None, publishingCountry=None, publisher=None,
datasetKey=None, year=None, basisOfRecord=None, **kwargs):
'''
GBIF maps API
:param sou... |
def name_usage(key = None, name = None, data = 'all', language = None,
datasetKey = None, uuid = None, sourceId = None, rank = None, shortname = None,
limit = 100, offset = None, **kwargs):
'''
Lookup details for specific names in all taxonomies in GBIF.
:param key: [fixnum] A GBIF key for a taxon
:param name: [... |
def _check_environ(variable, value):
"""check if a variable is present in the environmental variables"""
if is_not_none(value):
return value
else:
value = os.environ.get(variable)
if is_none(value):
stop(''.join([variable,
""" not supplied and no... |
def download(queries, user=None, pwd=None,
email=None, pred_type='and'):
"""
Spin up a download request for GBIF occurrence data.
:param queries: One or more of query arguments to kick of a download job.
See Details.
:type queries: str or list
:param pred_type: (character) One ... |
def download_list(user=None, pwd=None, limit=20, offset=0):
"""
Lists the downloads created by a user.
:param user: [str] A user name, look at env var ``GBIF_USER`` first
:param pwd: [str] Your password, look at env var ``GBIF_PWD`` first
:param limit: [int] Number of records to return. Default: ``... |
def download_get(key, path=".", **kwargs):
"""
Get a download from GBIF.
:param key: [str] A key generated from a request, like that from ``download``
:param path: [str] Path to write zip file to. Default: ``"."``, with a ``.zip`` appended to the end.
:param **kwargs**: Further named arguments pass... |
def main_pred_type(self, value):
"""set main predicate combination type
:param value: (character) One of ``equals`` (``=``), ``and`` (``&``), ``or`` (``|``),
``lessThan`` (``<``), ``lessThanOrEquals`` (``<=``), ``greaterThan`` (``>``),
``greaterThanOrEquals`` (``>=``), ``in``, ``within`... |
def add_predicate(self, key, value, predicate_type='equals'):
"""
add key, value, type combination of a predicate
:param key: query KEY parameter
:param value: the value used in the predicate
:param predicate_type: the type of predicate (e.g. ``equals``)
"""
if p... |
def _extract_values(values_list):
"""extract values from either file or list
:param values_list: list or file name (str) with list of values
"""
values = []
# check if file or list of values to iterate
if isinstance(values_list, str):
with open(values_list) a... |
def add_iterative_predicate(self, key, values_list):
"""add an iterative predicate with a key and set of values
which it can be equal to in and or function.
The individual predicates are specified with the type ``equals`` and
combined with a type ``or``.
The main reason for this... |
def get(key, **kwargs):
'''
Gets details for a single, interpreted occurrence
:param key: [int] A GBIF occurrence key
:return: A dictionary, of results
Usage::
from pygbif import occurrences
occurrences.get(key = 1258202889)
occurrences.get(key = 1227768771)
occur... |
def get_verbatim(key, **kwargs):
'''
Gets a verbatim occurrence record without any interpretation
:param key: [int] A GBIF occurrence key
:return: A dictionary, of results
Usage::
from pygbif import occurrences
occurrences.get_verbatim(key = 1258202889)
occurrences.get_ve... |
def get_fragment(key, **kwargs):
'''
Get a single occurrence fragment in its raw form (xml or json)
:param key: [int] A GBIF occurrence key
:return: A dictionary, of results
Usage::
from pygbif import occurrences
occurrences.get_fragment(key = 1052909293)
occurrences.get_... |
def name_backbone(name, rank=None, kingdom=None, phylum=None, clazz=None,
order=None, family=None, genus=None, strict=False, verbose=False,
offset=None, limit=100, **kwargs):
'''
Lookup names in the GBIF backbone taxonomy.
:param name: [str] Full scientific name potentially with authorship (required)
:para... |
def name_parser(name, **kwargs):
'''
Parse taxon names using the GBIF name parser
:param name: [str] A character vector of scientific names. (required)
reference: http://www.gbif.org/developer/species#parser
Usage::
from pygbif import species
species.name_parser('x Agropogon littoralis')
... |
def name_lookup(q=None, rank=None, higherTaxonKey=None, status=None, isExtinct=None,
habitat=None, nameType=None, datasetKey=None, nomenclaturalStatus=None,
limit=100, offset=None, facet=False, facetMincount=None, facetMultiselect=None,
type=None, hl=False, verbose=False, **kwargs):
'''
Lookup names in all taxonom... |
def count(taxonKey=None, basisOfRecord=None, country=None, isGeoreferenced=None,
datasetKey=None, publishingCountry=None, typeStatus=None,
issue=None, year=None, **kwargs):
'''
Returns occurrence counts for a predefined set of dimensions
:param taxonKey: [int] A GBIF occurrence identifier
:para... |
def count_year(year, **kwargs):
'''
Lists occurrence counts by year
:param year: [int] year range, e.g., ``1990,2000``. Does not support ranges like ``asterisk,2010``
:return: dict
Usage::
from pygbif import occurrences
occurrences.count_year(year = '1990,2000')
'''
... |
def count_datasets(taxonKey = None, country = None, **kwargs):
'''
Lists occurrence counts for datasets that cover a given taxon or country
:param taxonKey: [int] Taxon key
:param country: [str] A country, two letter code
:return: dict
Usage::
from pygbif import occurrences
... |
def count_countries(publishingCountry, **kwargs):
'''
Lists occurrence counts for all countries covered by the data published by the given country
:param publishingCountry: [str] A two letter country code
:return: dict
Usage::
from pygbif import occurrences
occurrences.co... |
def count_publishingcountries(country, **kwargs):
'''
Lists occurrence counts for all countries that publish data about the given country
:param country: [str] A country, two letter code
:return: dict
Usage::
from pygbif import occurrences
occurrences.count_publishingcoun... |
def _detect_notebook() -> bool:
"""Detect if code is running in a Jupyter Notebook.
This isn't 100% correct but seems good enough
Returns
-------
bool
True if it detects this is a notebook, otherwise False.
"""
try:
from IPython import get_ipython
from ipykernel im... |
def _merge_layout(x: go.Layout, y: go.Layout) -> go.Layout:
"""Merge attributes from two layouts."""
xjson = x.to_plotly_json()
yjson = y.to_plotly_json()
if 'shapes' in yjson and 'shapes' in xjson:
xjson['shapes'] += yjson['shapes']
yjson.update(xjson)
return go.Layout(yjson) |
def _try_pydatetime(x):
"""Try to convert to pandas objects to datetimes.
Plotly doesn't know how to handle them.
"""
try:
# for datetimeindex
x = [y.isoformat() for y in x.to_pydatetime()]
except AttributeError:
pass
try:
# for generic series
x = [y.isof... |
def spark_shape(points, shapes, fill=None, color='blue', width=5, yindex=0, heights=None):
"""TODO: Docstring for spark.
Parameters
----------
points : array-like
shapes : array-like
fill : array-like, optional
Returns
-------
Chart
"""
assert len(points) == len(shapes) + ... |
def vertical(x, ymin=0, ymax=1, color=None, width=None, dash=None, opacity=None):
"""Draws a vertical line from `ymin` to `ymax`.
Parameters
----------
xmin : int, optional
xmax : int, optional
color : str, optional
width : number, optional
Returns
-------
Chart
"""
li... |
def horizontal(y, xmin=0, xmax=1, color=None, width=None, dash=None, opacity=None):
"""Draws a horizontal line from `xmin` to `xmax`.
Parameters
----------
xmin : int, optional
xmax : int, optional
color : str, optional
width : number, optional
Returns
-------
Chart
"""
... |
def line(
x=None,
y=None,
label=None,
color=None,
width=None,
dash=None,
opacity=None,
mode='lines+markers',
yaxis=1,
fill=None,
text="",
markersize=6,
):
"""Draws connected dots.
Parameters
----------
x : array-like, optional
y : array-like, optional... |
def line3d(
x, y, z, label=None, color=None, width=None, dash=None, opacity=None, mode='lines+markers'
):
"""Create a 3d line chart."""
x = np.atleast_1d(x)
y = np.atleast_1d(y)
z = np.atleast_1d(z)
assert x.shape == y.shape
assert y.shape == z.shape
lineattr = {}
if color:
l... |
def scatter(
x=None,
y=None,
label=None,
color=None,
width=None,
dash=None,
opacity=None,
markersize=6,
yaxis=1,
fill=None,
text="",
mode='markers',
):
"""Draws dots.
Parameters
----------
x : array-like, optional
y : array-like, optional
label : ... |
def bar(x=None, y=None, label=None, mode='group', yaxis=1, opacity=None):
"""Create a bar chart.
Parameters
----------
x : array-like, optional
y : TODO, optional
label : TODO, optional
mode : 'group' or 'stack', default 'group'
opacity : TODO, optional
Returns
-------
Char... |
def heatmap(z, x=None, y=None, colorscale='Viridis'):
"""Create a heatmap.
Parameters
----------
z : TODO
x : TODO, optional
y : TODO, optional
colorscale : TODO, optional
Returns
-------
Chart
"""
z = np.atleast_1d(z)
data = [go.Heatmap(z=z, x=x, y=y, colorscale=... |
def fill_zero(
x=None,
y=None,
label=None,
color=None,
width=None,
dash=None,
opacity=None,
mode='lines+markers',
**kargs
):
"""Fill to zero.
Parameters
----------
x : array-like, optional
y : TODO, optional
label : TODO, optional
Returns
-------
... |
def fill_between(
x=None,
ylow=None,
yhigh=None,
label=None,
color=None,
width=None,
dash=None,
opacity=None,
mode='lines+markers',
**kargs
):
"""Fill between `ylow` and `yhigh`.
Parameters
----------
x : array-like, optional
ylow : TODO, optional
yhigh :... |
def rug(x, label=None, opacity=None):
"""Rug chart.
Parameters
----------
x : array-like, optional
label : TODO, optional
opacity : TODO, optional
Returns
-------
Chart
"""
x = _try_pydatetime(x)
x = np.atleast_1d(x)
data = [
go.Scatter(
x=x,
... |
def surface(x, y, z):
"""Surface plot.
Parameters
----------
x : array-like, optional
y : array-like, optional
z : array-like, optional
Returns
-------
Chart
"""
data = [go.Surface(x=x, y=y, z=z)]
return Chart(data=data) |
def hist(x, mode='overlay', label=None, opacity=None, horz=False, histnorm=None):
"""Histogram.
Parameters
----------
x : array-like
mode : str, optional
label : TODO, optional
opacity : float, optional
horz : bool, optional
histnorm : None, "percent", "probability", "density", "pro... |
def hist2d(x, y, label=None, opacity=None):
"""2D Histogram.
Parameters
----------
x : array-like, optional
y : array-like, optional
label : TODO, optional
opacity : float, optional
Returns
-------
Chart
"""
x = np.atleast_1d(x)
y = np.atleast_1d(y)
data = [go.... |
def ytickangle(self, angle, index=1):
"""Set the angle of the y-axis tick labels.
Parameters
----------
value : int
Angle in degrees
index : int, optional
Y-axis index
Returns
-------
Chart
"""
self.layout['yaxis'... |
def ylabelsize(self, size, index=1):
"""Set the size of the label.
Parameters
----------
size : int
Returns
-------
Chart
"""
self.layout['yaxis' + str(index)]['titlefont']['size'] = size
return self |
def yticksize(self, size, index=1):
"""Set the tick font size.
Parameters
----------
size : int
Returns
-------
Chart
"""
self.layout['yaxis' + str(index)]['tickfont']['size'] = size
return self |
def ytickvals(self, values, index=1):
"""Set the tick values.
Parameters
----------
values : array-like
Returns
-------
Chart
"""
self.layout['yaxis' + str(index)]['tickvals'] = values
return self |
def yticktext(self, labels, index=1):
"""Set the tick labels.
Parameters
----------
labels : array-like
Returns
-------
Chart
"""
self.layout['yaxis' + str(index)]['ticktext'] = labels
return self |
def ylim(self, low, high, index=1):
"""Set yaxis limits.
Parameters
----------
low : number
high : number
index : int, optional
Returns
-------
Chart
"""
self.layout['yaxis' + str(index)]['range'] = [low, high]
return sel... |
def ydtick(self, dtick, index=1):
"""Set the tick distance."""
self.layout['yaxis' + str(index)]['dtick'] = dtick
return self |
def ynticks(self, nticks, index=1):
"""Set the number of ticks."""
self.layout['yaxis' + str(index)]['nticks'] = nticks
return self |
def show(
self,
filename: Optional[str] = None,
show_link: bool = True,
auto_open: bool = True,
detect_notebook: bool = True,
) -> None:
"""Display the chart.
Parameters
----------
filename : str, optional
Save plot to this filenam... |
def save(
self,
filename: Optional[str] = None,
show_link: bool = True,
auto_open: bool = False,
output: str = 'file',
plotlyjs: bool = True,
) -> str:
"""Save the chart to an html file."""
if filename is None:
filename = NamedTemporaryFile... |
def RegisterMethod(cls, *args, **kwargs):
"""
**RegisterMethod**
RegisterMethod(f, library_path, alias=None, original_name=None, doc=None, wrapped=None, explanation="", method_type=utils.identity, explain=True)
`classmethod` for registering functions as methods of this class.
**Arguments**
* **f** : the... |
def RegisterAt(cls, *args, **kwargs):
"""
**RegisterAt**
RegisterAt(n, f, library_path, alias=None, original_name=None, doc=None, wrapped=None, explanation="", method_type=utils.identity, explain=True, _return_type=None)
Most of the time you don't want to register an method as such, that is, you don't car... |
def PatchAt(cls, n, module, method_wrapper=None, module_alias=None, method_name_modifier=utils.identity, blacklist_predicate=_False, whitelist_predicate=_True, return_type_predicate=_None, getmembers_predicate=inspect.isfunction, admit_private=False, explanation=""):
"""
This classmethod lets you easily patch a... |
def get_method_sig(method):
""" Given a function, it returns a string that pretty much looks how the
function signature_ would be written in python.
:param method: a python method
:return: A string similar describing the pythong method signature_.
eg: "my_method(first_argArg, second_arg=42, third_a... |
def Pipe(self, *sequence, **kwargs):
"""
`Pipe` runs any `phi.dsl.Expression`. Its highly inspired by Elixir's [|> (pipe)](https://hexdocs.pm/elixir/Kernel.html#%7C%3E/2) operator.
**Arguments**
* ***sequence**: any variable amount of expressions. All expressions inside of `sequence` will be composed together... |
def ThenAt(self, n, f, *_args, **kwargs):
"""
`ThenAt` enables you to create a partially apply many arguments to a function, the returned partial expects a single arguments which will be applied at the `n`th position of the original function.
**Arguments**
* **n**: position at which the created partial will a... |
def Then0(self, f, *args, **kwargs):
"""
`Then0(f, ...)` is equivalent to `ThenAt(0, f, ...)`. Checkout `phi.builder.Builder.ThenAt` for more information.
"""
return self.ThenAt(0, f, *args, **kwargs) |
def Then(self, f, *args, **kwargs):
"""
`Then(f, ...)` is equivalent to `ThenAt(1, f, ...)`. Checkout `phi.builder.Builder.ThenAt` for more information.
"""
return self.ThenAt(1, f, *args, **kwargs) |
def Then2(self, f, arg1, *args, **kwargs):
"""
`Then2(f, ...)` is equivalent to `ThenAt(2, f, ...)`. Checkout `phi.builder.Builder.ThenAt` for more information.
"""
args = (arg1,) + args
return self.ThenAt(2, f, *args, **kwargs) |
def Then3(self, f, arg1, arg2, *args, **kwargs):
"""
`Then3(f, ...)` is equivalent to `ThenAt(3, f, ...)`. Checkout `phi.builder.Builder.ThenAt` for more information.
"""
args = (arg1, arg2) + args
return self.ThenAt(3, f, *args, **kwargs) |
def Then4(self, f, arg1, arg2, arg3, *args, **kwargs):
"""
`Then4(f, ...)` is equivalent to `ThenAt(4, f, ...)`. Checkout `phi.builder.Builder.ThenAt` for more information.
"""
args = (arg1, arg2, arg3) + args
return self.ThenAt(4, f, *args, **kwargs) |
def Then5(self, f, arg1, arg2, arg3, arg4, *args, **kwargs):
"""
`Then5(f, ...)` is equivalent to `ThenAt(5, f, ...)`. Checkout `phi.builder.Builder.ThenAt` for more information.
"""
args = (arg1, arg2, arg3, arg4) + args
return self.ThenAt(5, f, *args, **kwargs) |
def List(self, *branches, **kwargs):
"""
While `Seq` is sequential, `phi.dsl.Expression.List` allows you to split the computation and get back a list with the result of each path. While the list literal should be the most incarnation of this expresion, it can actually be any iterable (implements `__iter__`) tha... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.