INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
valid layouts are: - default - search - inline - horizontal | def twitter_bootstrap(element, args=""):
"""
valid layouts are:
- default
- search
- inline
- horizontal
{{ form|twitter_bootstrap:"default" }}
{{ form|twitter_bootstrap:"horizontal" }}
{{ form|twitter_bootstrap:"horizontal,[xs,sm,md,lg],[1-12],[1-12]" }}
"""
element_type = ... |
Say something in the morning | def breakfast(self, message="Breakfast is ready", shout: bool = False):
"""Say something in the morning"""
return self.helper.output(message, shout) |
Say something in the afternoon | def lunch(self, message="Time for lunch", shout: bool = False):
"""Say something in the afternoon"""
return self.helper.output(message, shout) |
Say something in the evening | def dinner(self, message="Dinner is served", shout: bool = False):
"""Say something in the evening"""
return self.helper.output(message, shout) |
Command line entrypoint to reduce technote metadata. | def main():
"""Command line entrypoint to reduce technote metadata.
"""
parser = argparse.ArgumentParser(
description='Discover and ingest metadata from document sources, '
'including lsstdoc-based LaTeX documents and '
'reStructuredText-based technotes. Metad... |
Run a pipeline to process extract transform and load metadata for multiple LSST the Docs - hosted projects | async def process_ltd_doc_products(session, product_urls, github_api_token,
mongo_collection=None):
"""Run a pipeline to process extract, transform, and load metadata for
multiple LSST the Docs-hosted projects
Parameters
----------
session : `aiohttp.ClientSession... |
Ingest any kind of LSST document hosted on LSST the Docs from its source. | async def process_ltd_doc(session, github_api_token, ltd_product_url,
mongo_collection=None):
"""Ingest any kind of LSST document hosted on LSST the Docs from its
source.
Parameters
----------
session : `aiohttp.ClientSession`
Your application's aiohttp client sess... |
Allows a decorator to be called with or without keyword arguments. | def decorator(decorator_func):
"""Allows a decorator to be called with or without keyword arguments."""
assert callable(decorator_func), type(decorator_func)
def _decorator(func=None, **kwargs):
assert func is None or callable(func), type(func)
if func:
return decorator_func(fun... |
Create a GitHub token for an integration installation. | def get_installation_token(installation_id, integration_jwt):
"""Create a GitHub token for an integration installation.
Parameters
----------
installation_id : `int`
Installation ID. This is available in the URL of the integration's
**installation** ID.
integration_jwt : `bytes`
... |
Create a JSON Web Token to authenticate a GitHub Integration or installation. | def create_jwt(integration_id, private_key_path):
"""Create a JSON Web Token to authenticate a GitHub Integration or
installation.
Parameters
----------
integration_id : `int`
Integration ID. This is available from the GitHub integration's
homepage.
private_key_path : `str`
... |
r Get all macro definitions from TeX source supporting multiple declaration patterns. | def get_macros(tex_source):
r"""Get all macro definitions from TeX source, supporting multiple
declaration patterns.
Parameters
----------
tex_source : `str`
TeX source content.
Returns
-------
macros : `dict`
Keys are macro names (including leading ``\``) and values ar... |
r Get all \ def macro definition from TeX source. | def get_def_macros(tex_source):
r"""Get all ``\def`` macro definition from TeX source.
Parameters
----------
tex_source : `str`
TeX source content.
Returns
-------
macros : `dict`
Keys are macro names (including leading ``\``) and values are the
content (as `str`) o... |
r Get all \ newcommand macro definition from TeX source. | def get_newcommand_macros(tex_source):
r"""Get all ``\newcommand`` macro definition from TeX source.
Parameters
----------
tex_source : `str`
TeX source content.
Returns
-------
macros : `dict`
Keys are macro names (including leading ``\``) and values are the
conten... |
Try to load and return a module | def load(directory_name, module_name):
"""Try to load and return a module
Will add DIRECTORY_NAME to sys.path and tries to import MODULE_NAME.
For example:
load("~/.yaz", "yaz_extension")
"""
directory_name = os.path.expanduser(directory_name)
if os.path.isdir(directory_name) and directory... |
Makes a naive datetime. datetime in a given time zone aware. | def make_aware(value, timezone):
"""
Makes a naive datetime.datetime in a given time zone aware.
"""
if hasattr(timezone, 'localize') and value not in (datetime.datetime.min, datetime.datetime.max):
# available for pytz time zones
return timezone.localize(value, is_dst=None)
else:
... |
Makes an aware datetime. datetime naive in a given time zone. | def make_naive(value, timezone):
"""
Makes an aware datetime.datetime naive in a given time zone.
"""
value = value.astimezone(timezone)
if hasattr(timezone, 'normalize'):
# available for pytz time zones
value = timezone.normalize(value)
return value.replace(tzinfo=None) |
Return a Schedule object based on an lxml Element for the <schedule > tag. timezone is a tzinfo object ideally from pytz. | def from_element(root, timezone):
"""Return a Schedule object based on an lxml Element for the <schedule>
tag. timezone is a tzinfo object, ideally from pytz."""
assert root.tag == 'schedule'
if root.xpath('intervals'):
return _ScheduleIntervals(root, timezone)
elif r... |
Converts a datetime to the timezone of this Schedule. | def to_timezone(self, dt):
"""Converts a datetime to the timezone of this Schedule."""
if timezone.is_aware(dt):
return dt.astimezone(self.timezone)
else:
return timezone.make_aware(dt, self.timezone) |
Returns a list of tuples of start/ end datetimes for when the schedule is active during the provided range. | def intervals(self, range_start=datetime.datetime.min, range_end=datetime.datetime.max):
"""Returns a list of tuples of start/end datetimes for when the schedule
is active during the provided range."""
raise NotImplementedError |
Returns the next Period this event is in effect or None if the event has no remaining periods. | def next_interval(self, after=None):
"""Returns the next Period this event is in effect, or None if the event
has no remaining periods."""
if after is None:
after = timezone.now()
after = self.to_timezone(after)
return next(self.intervals(range_start=after), None) |
Does this schedule include the provided time? query should be a datetime ( naive or timezone - aware ) | def includes(self, query):
"""Does this schedule include the provided time?
query should be a datetime (naive or timezone-aware)"""
query = self.to_timezone(query)
return any(self.intervals(range_start=query, range_end=query)) |
A dict of dates - > [ Period time tuples ] representing exceptions to the base recurrence pattern. | def exceptions(self):
"""A dict of dates -> [Period time tuples] representing exceptions
to the base recurrence pattern."""
ex = {}
for sd in self.root.xpath('exceptions/exception'):
bits = str(sd.text).split(' ')
date = text_to_date(bits.pop(0))
ex.se... |
Returns a list of Period tuples for each period represented in an <exception > that falls between range_start and range_end. | def exception_periods(self, range_start=datetime.date.min, range_end=datetime.date.max):
"""Returns a list of Period tuples for each period represented in an <exception>
that falls between range_start and range_end."""
periods = []
for exception_date, exception_times in self.exceptions.i... |
Does this schedule include the provided time? query should be a datetime ( naive or timezone - aware ) | def includes(self, query):
"""Does this schedule include the provided time?
query should be a datetime (naive or timezone-aware)"""
query = self.to_timezone(query)
query_date = query.date()
query_time = query.time()
# Is the provided time an exception for this schedule?
... |
Returns an iterator of Period tuples for every day this event is in effect between range_start and range_end. | def _daily_periods(self, range_start, range_end):
"""Returns an iterator of Period tuples for every day this event is in effect, between range_start
and range_end."""
specific = set(self.exceptions.keys())
return heapq.merge(self.exception_periods(range_start, range_end), *[
... |
Returns an iterator of Period tuples for continuous stretches of time during which this event is in effect between range_start and range_end. | def intervals(self, range_start=datetime.datetime.min, range_end=datetime.datetime.max):
"""Returns an iterator of Period tuples for continuous stretches of time during
which this event is in effect, between range_start and range_end."""
# At the moment the algorithm works on periods split by c... |
Does this schedule include the provided time? query_date and query_time are date and time objects interpreted in this schedule s timezone | def includes(self, query_date, query_time=None):
"""Does this schedule include the provided time?
query_date and query_time are date and time objects, interpreted
in this schedule's timezone"""
if self.start_date and query_date < self.start_date:
return False
if self... |
Returns an iterator of Period tuples for every day this schedule is in effect between range_start and range_end. | def daily_periods(self, range_start=datetime.date.min, range_end=datetime.date.max, exclude_dates=tuple()):
"""Returns an iterator of Period tuples for every day this schedule is in effect, between range_start
and range_end."""
tz = self.timezone
period = self.period
weekdays = s... |
A Period tuple representing the daily start and end time. | def period(self):
"""A Period tuple representing the daily start and end time."""
start_time = self.root.findtext('daily_start_time')
if start_time:
return Period(text_to_time(start_time), text_to_time(self.root.findtext('daily_end_time')))
return Period(datetime.time(0, 0), ... |
A set of integers representing the weekdays the schedule recurs on with Monday = 0 and Sunday = 6. | def weekdays(self):
"""A set of integers representing the weekdays the schedule recurs on,
with Monday = 0 and Sunday = 6."""
if not self.root.xpath('days'):
return set(range(7))
return set(int(d) - 1 for d in self.root.xpath('days/day/text()')) |
A context manager that creates a temporary database. | def temp_db(db, name=None):
"""
A context manager that creates a temporary database.
Useful for automated tests.
Parameters
----------
db: object
a preconfigured DB object
name: str, optional
name of the database to be created. (default: globally unique name)
"""
if... |
Asynchronously request a URL and get the encoded text content of the body. | async def _download_text(url, session):
"""Asynchronously request a URL and get the encoded text content of the
body.
Parameters
----------
url : `str`
URL to download.
session : `aiohttp.ClientSession`
An open aiohttp session.
Returns
-------
content : `str`
... |
Asynchronously download a set of lsst - texmf BibTeX bibliographies from GitHub. | async def _download_lsst_bibtex(bibtex_names):
"""Asynchronously download a set of lsst-texmf BibTeX bibliographies from
GitHub.
Parameters
----------
bibtex_names : sequence of `str`
Names of lsst-texmf BibTeX files to download. For example:
.. code-block:: python
['ls... |
Get content of lsst - texmf bibliographies. | def get_lsst_bibtex(bibtex_filenames=None):
"""Get content of lsst-texmf bibliographies.
BibTeX content is downloaded from GitHub (``master`` branch of
https://github.com/lsst/lsst-texmf or retrieved from an in-memory cache.
Parameters
----------
bibtex_filenames : sequence of `str`, optional
... |
Make a pybtex BibliographyData instance from standard lsst - texmf bibliography files and user - supplied bibtex content. | def get_bibliography(lsst_bib_names=None, bibtex=None):
"""Make a pybtex BibliographyData instance from standard lsst-texmf
bibliography files and user-supplied bibtex content.
Parameters
----------
lsst_bib_names : sequence of `str`, optional
Names of lsst-texmf BibTeX files to include. Fo... |
Get a usable URL from a pybtex entry. | def get_url_from_entry(entry):
"""Get a usable URL from a pybtex entry.
Parameters
----------
entry : `pybtex.database.Entry`
A pybtex bibliography entry.
Returns
-------
url : `str`
Best available URL from the ``entry``.
Raises
------
NoEntryUrlError
R... |
Get and format author - year text from a pybtex entry to emulate natbib citations. | def get_authoryear_from_entry(entry, paren=False):
"""Get and format author-year text from a pybtex entry to emulate
natbib citations.
Parameters
----------
entry : `pybtex.database.Entry`
A pybtex bibliography entry.
parens : `bool`, optional
Whether to add parentheses around t... |
Extract transform and load Sphinx - based technote metadata. | async def process_sphinx_technote(session, github_api_token, ltd_product_data,
mongo_collection=None):
"""Extract, transform, and load Sphinx-based technote metadata.
Parameters
----------
session : `aiohttp.ClientSession`
Your application's aiohttp client sess... |
Reduce a technote project s metadata from multiple sources into a single JSON - LD resource. | def reduce_technote_metadata(github_url, metadata, github_data,
ltd_product_data):
"""Reduce a technote project's metadata from multiple sources into a
single JSON-LD resource.
Parameters
----------
github_url : `str`
URL of the technote's GitHub repository.
... |
Download the metadata. yaml file from a technote s GitHub repository. | async def download_metadata_yaml(session, github_url):
"""Download the metadata.yaml file from a technote's GitHub repository.
"""
metadata_yaml_url = _build_metadata_yaml_url(github_url)
async with session.get(metadata_yaml_url) as response:
response.raise_for_status()
yaml_data = await... |
Get the slug <owner >/ <repo_name > for a GitHub repository from its URL. | def parse_repo_slug_from_url(github_url):
"""Get the slug, <owner>/<repo_name>, for a GitHub repository from
its URL.
Parameters
----------
github_url : `str`
URL of a GitHub repository.
Returns
-------
repo_slug : `RepoSlug`
Repository slug with fields ``full``, ``owne... |
Make a raw content ( raw. githubusercontent. com ) URL to a file. | def make_raw_content_url(repo_slug, git_ref, file_path):
"""Make a raw content (raw.githubusercontent.com) URL to a file.
Parameters
----------
repo_slug : `str` or `RepoSlug`
The repository slug, formatted as either a `str` (``'owner/name'``)
or a `RepoSlug` object (created by `parse_r... |
Return the timezone. If none is set use system timezone | def tz(self):
"""Return the timezone. If none is set use system timezone"""
if not self._tz:
self._tz = tzlocal.get_localzone().zone
return self._tz |
Add tag ( s ) to a DayOneEntry | def add_tag(self, _tags):
"""Add tag(s) to a DayOneEntry"""
if isinstance(_tags, list):
for t in _tags:
self.tags.append(t)
else:
self.tags.append(_tags) |
Convert any timestamp into a datetime and save as _time | def time(self, t):
"""Convert any timestamp into a datetime and save as _time"""
_time = arrow.get(t).format('YYYY-MM-DDTHH:mm:ss')
self._time = datetime.datetime.strptime(_time, '%Y-%m-%dT%H:%M:%S') |
Return a dict that represents the DayOneEntry | def as_dict(self):
"""Return a dict that represents the DayOneEntry"""
entry_dict = {}
entry_dict['UUID'] = self.uuid
entry_dict['Creation Date'] = self.time
entry_dict['Time Zone'] = self.tz
if self.tags:
entry_dict['Tags'] = self.tags
entry_dict['Ent... |
Saves a DayOneEntry as a plist | def save(self, entry, with_location=True, debug=False):
"""Saves a DayOneEntry as a plist"""
entry_dict = {}
if isinstance(entry, DayOneEntry):
# Get a dict of the DayOneEntry
entry_dict = entry.as_dict()
else:
entry_dict = entry
# Set... |
Create and return full file path for DayOne entry | def _file_path(self, uid):
"""Create and return full file path for DayOne entry"""
file_name = '%s.doentry' % (uid)
return os.path.join(self.dayone_journal_path, file_name) |
Combine many files into a single file on disk. Defaults to using the time dimension. | def combine(self, members, output_file, dimension=None, start_index=None, stop_index=None, stride=None):
""" Combine many files into a single file on disk. Defaults to using the 'time' dimension. """
nco = None
try:
nco = Nco()
except BaseException:
# This is not... |
The entry point for a yaz script | def main(argv=None, white_list=None, load_yaz_extension=True):
"""The entry point for a yaz script
This will almost always be called from a python script in
the following manner:
if __name__ == "__main__":
yaz.main()
This function will perform the following steps:
1. It will ... |
Returns a tree of Task instances | def get_task_tree(white_list=None):
"""Returns a tree of Task instances
The tree is comprised of dictionaries containing strings for
keys and either dictionaries or Task instances for values.
When WHITE_LIST is given, only the tasks and plugins in this
list will become part of the task tree. The ... |
Declare a function or method to be a Yaz task | def task(func, **config):
"""Declare a function or method to be a Yaz task
@yaz.task
def talk(message: str = "Hello World!"):
return message
Or... group multiple tasks together
class Tools(yaz.Plugin):
@yaz.task
def say(self, message: str = "Hello World!"):
ret... |
Returns a list of parameters | def get_parameters(self):
"""Returns a list of parameters"""
if self.plugin_class is None:
sig = inspect.signature(self.func)
for index, parameter in enumerate(sig.parameters.values()):
if not parameter.kind in [parameter.POSITIONAL_ONLY, parameter.KEYWORD_ONLY, p... |
Returns the configuration for KEY | def get_configuration(self, key, default=None):
"""Returns the configuration for KEY"""
if key in self.config:
return self.config.get(key)
else:
return default |
Finds all yaz plugins and returns them in a __qualname__: plugin_class dictionary | def get_plugin_list():
"""Finds all yaz plugins and returns them in a __qualname__: plugin_class dictionary"""
global _yaz_plugin_classes
def get_recursively(cls, plugin_list):
for plugin in cls.__subclasses__():
if not (plugin.yaz_is_final() or plugin.__qualname__ in _yaz_plugin_classe... |
Returns an instance of a fully initialized plugin class | def get_plugin_instance(plugin_class, *args, **kwargs):
"""Returns an instance of a fully initialized plugin class
Every plugin class is kept in a plugin cache, effectively making
every plugin into a singleton object.
When a plugin has a yaz.dependency decorator, it will be called
as well, before ... |
Convert an Open511 XML document or document fragment to JSON. | def xml_to_json(root):
"""Convert an Open511 XML document or document fragment to JSON.
Takes an lxml Element object. Returns a dict ready to be JSON-serialized."""
j = {}
if len(root) == 0: # Tag with no children, return str/int
return _maybe_intify(root.text)
if len(root) == 1 and root... |
Given an lxml Element of a GML geometry returns a dict in GeoJSON format. | def gml_to_geojson(el):
"""Given an lxml Element of a GML geometry, returns a dict in GeoJSON format."""
if el.get('srsName') not in ('urn:ogc:def:crs:EPSG::4326', None):
if el.get('srsName') == 'EPSG:4326':
return _gmlv2_to_geojson(el)
else:
raise NotImplementedError("Un... |
Translates a deprecated GML 2. 0 geometry to GeoJSON | def _gmlv2_to_geojson(el):
"""Translates a deprecated GML 2.0 geometry to GeoJSON"""
tag = el.tag.replace('{%s}' % NS_GML, '')
if tag == 'Point':
coordinates = [float(c) for c in el.findtext('{%s}coordinates' % NS_GML).split(',')]
elif tag == 'LineString':
coordinates = [
[fl... |
Panflute filter function that converts content wrapped in a Para to Plain. | def deparagraph(element, doc):
"""Panflute filter function that converts content wrapped in a Para to
Plain.
Use this filter with pandoc as::
pandoc [..] --filter=lsstprojectmeta-deparagraph
Only lone paragraphs are affected. Para elements with siblings (like a
second Para) are left unaff... |
Recursively generate of all the subclasses of class cls. | def all_subclasses(cls):
""" Recursively generate of all the subclasses of class cls. """
for subclass in cls.__subclasses__():
yield subclass
for subc in all_subclasses(subclass):
yield subc |
List unique elements preserving order. Remember only the element just seen. | def unique_justseen(iterable, key=None):
"List unique elements, preserving order. Remember only the element just seen."
# unique_justseen('AAAABBBCCDAABBB') --> A B C D A B
# unique_justseen('ABBCcAD', str.lower) --> A B C A D
try:
# PY2 support
from itertools import imap as map
exce... |
Returns a normalized data array from a NetCDF4 variable. This is mostly used to normalize string types between py2 and py3. It has no effect on types other than chars/ strings | def normalize_array(var):
"""
Returns a normalized data array from a NetCDF4 variable. This is mostly
used to normalize string types between py2 and py3. It has no effect on types
other than chars/strings
"""
if np.issubdtype(var.dtype, 'S1'):
if var.dtype == str:
# Python 2 ... |
Returns a masked array with anything outside of values masked. The minv and maxv parameters take precendence over any dict values. The valid_range attribute takes precendence over the valid_min and valid_max attributes. | def generic_masked(arr, attrs=None, minv=None, maxv=None, mask_nan=True):
"""
Returns a masked array with anything outside of values masked.
The minv and maxv parameters take precendence over any dict values.
The valid_range attribute takes precendence over the valid_min and
valid_max attributes.
... |
By default this will put the interval as part of the cell_methods attribute ( NetCDF CF style ). To return interval as its own key use the combine_interval = False parameter. | def dictify_urn(urn, combine_interval=True):
"""
By default, this will put the `interval` as part of the `cell_methods`
attribute (NetCDF CF style). To return `interval` as its own key, use
the `combine_interval=False` parameter.
"""
ioos_urn = IoosUrn.from_string(urn)
if ioos_u... |
If input object is an ndarray it will be converted into a list | def default(self, obj):
"""If input object is an ndarray it will be converted into a list
"""
if isinstance(obj, np.ndarray):
return obj.tolist()
elif isinstance(obj, np.generic):
return np.asscalar(obj)
# Let the base class default method raise the TypeEr... |
If input object is an ndarray it will be converted into a dict holding dtype shape and the data base64 encoded. | def default(self, obj):
"""If input object is an ndarray it will be converted into a dict
holding dtype, shape and the data, base64 encoded.
"""
if isinstance(obj, np.ndarray):
if obj.flags['C_CONTIGUOUS']:
obj_data = obj.data
else:
... |
#mapfivo f i v o四元决定 fivo - 4 - tuple - engine #map_func diff_func ( index value * diff_args ) | def mapfivo(ol,*args,**kwargs):
'''
#mapfivo f,i,v,o四元决定 fivo-4-tuple-engine
#map_func diff_func(index,value,*diff_args)
'''
args = list(args)
lngth = args.__len__()
if(lngth==0):
diff_funcs_arr = kwargs['map_funcs']
diff_args_arr ... |
#mapfiv 共享相同的o share common other_args #map_func diff_func ( index value * common_args ) | def mapfiv(ol,map_func_args,**kwargs):
'''
#mapfiv 共享相同的o share common other_args
#map_func diff_func(index,value,*common_args)
'''
lngth = ol.__len__()
diff_funcs_arr = kwargs['map_funcs']
common_args_arr = init(lngth,map_func_args)
rslt... |
#mapivo 共享相同的f share common map_func #map_func common_func ( index value * diff_args ) | def mapivo(ol,map_func,**kwargs):
'''
#mapivo 共享相同的f share common map_func
#map_func common_func(index,value,*diff_args)
'''
lngth = ol.__len__()
common_funcs_arr = init(lngth,map_func)
diff_args_arr = kwargs['map_func_args_array']
rslt =... |
from elist. elist import * ol = [ a b c d ] def index_map_func ( index prefix suffix ): s = prefix + str ( index + 97 ) + suffix return ( s ) def value_map_func ( mapped_index ele prefix suffix ): s = prefix + mapped_index +: + str ( ele ) + suffix return ( s ) #### rslt = array_dualmap2 ( ol index_map_func = index_map... | def array_dualmap(ol,value_map_func,**kwargs):
'''
from elist.elist import *
ol = ['a','b','c','d']
def index_map_func(index,prefix,suffix):
s = prefix +str(index+97)+ suffix
return(s)
def value_map_func(mapped_index,ele,prefix,suffix):
s ... |
from elist. elist import * ol = [ 1 2 3 4 ] refl1 = [ + + + + ] refl2 = [ 7 7 7 7 ] refl3 = [ = = = = ] def index_map_func ( index ): s = < + str ( index ) + > return ( s ) def value_map_func ( mapped_index ele ref_ele1 ref_ele2 ref_ele3 prefix suffix ): s = prefix + mapped_index +: + str ( ele ) + str ( ref_ele1 ) + s... | def array_dualmap2(*refls,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4]
refl1 = ['+','+','+','+']
refl2 = [7,7,7,7]
refl3 = ['=','=','=','=']
def index_map_func(index):
s ="<"+str(index)+">"
return(s)
def value_map_fu... |
#mapfi 共享相同的o v不作为map_func参数 # share common other_args NOT take value as a param for map_func #map_func diff_func ( index * common_args ) | def mapfi(ol,map_func_args,**kwargs):
'''
#mapfi 共享相同的o,v不作为map_func参数
# share common other_args,NOT take value as a param for map_func
#map_func diff_func(index,*common_args)
'''
diff_funcs_arr = kwargs['map_funcs']
lngth = ol.__len__()
rsl... |
#mapfv 共享相同的o i不作为map_func参数 # share common other_args NOT take value as a param for map_func #map_func diff_func ( value * common_args ) | def mapfv(ol,map_func_args,*args,**kwargs):
'''
#mapfv 共享相同的o,i不作为map_func参数
# share common other_args,NOT take value as a param for map_func
#map_func diff_func(value,*common_args)
'''
args = list(args)
lngth = args.__len__()
if(lngth == 0)... |
#mapfo i不作为map_func参数 v不作为map_func参数 # NOT take value as a param for map_func NOT take index as a param for map_func #map_func diff_func ( * diff_args ) | def mapfo(ol,**kwargs):
'''
#mapfo i不作为map_func参数,v不作为map_func参数
# NOT take value as a param for map_func,NOT take index as a param for map_func
#map_func diff_func(*diff_args)
'''
diff_args_arr = kwargs['map_func_args_array']
diff_funcs_arr = k... |
from elist. elist import * ol = [ a b c d ] #1 def map_func ( index value * others ): return ( value * index + others [ 0 ] + others [ - 1 ] ) mapiv ( ol map_func tailA - tailB ) #2 mapiv2 ( ol lambda index value other: ( value * index + other ) [ - ] ) mapiv2 ( ol lambda index value other: ( value * index + other ) - ... | def mapiv2(ol,map_func,*args,**kwargs):
'''
from elist.elist import *
ol = ['a','b','c','d']
#1
def map_func(index,value,*others):
return(value * index + others[0] +others[-1])
mapiv(ol,map_func,'tailA-','tailB')
#2
mapiv2(ol,lambda index,value,oth... |
#mapvo 共享相同的f i不作为map_func参数 # share common map_func NOT take index as a param for map_func # common_func ( value * priv_args ) | def mapvo(ol,map_func,*args,**kwargs):
'''
#mapvo 共享相同的f,i不作为map_func参数
# share common map_func,NOT take index as a param for map_func
# common_func(value,*priv_args)
'''
lngth = ol.__len__()
args = list(args)
if(args.__len__()==0):
diff_args_arr = ... |
obseleted just for compatible from elist. elist import * ol = [ 1 2 3 4 ] refl1 = [ + + + + ] refl2 = [ 7 7 7 7 ] refl3 = [ = = = = ] def map_func ( ele ref_ele1 ref_ele2 ref_ele3 prefix suffix ): s = prefix +: + str ( ele ) + str ( ref_ele1 ) + str ( ref_ele2 ) + str ( ref_ele3 ) + suffix return ( s ) | def array_map2(*referls,**kwargs):
'''
obseleted just for compatible
from elist.elist import *
ol = [1,2,3,4]
refl1 = ['+','+','+','+']
refl2 = [7,7,7,7]
refl3 = ['=','=','=','=']
def map_func(ele,ref_ele1,ref_ele2,ref_ele3,prefix,suffix):
s = pref... |
#mapi v不作为map_func参数 共享相同的f 共享相同的o # NOT take value as a param for map_func # share common other_args # share common map_func # common_func ( index * common_args ) | def mapi(ol,map_func,map_func_args=[]):
'''
#mapi v不作为map_func参数,共享相同的f,共享相同的o
# NOT take value as a param for map_func
# share common other_args
# share common map_func
# common_func(index,*common_args)
'''
lngth = ol.__len__()
... |
#mapv i不作为map_func参数 共享相同的f 共享相同的o # NOT take index as a param for map_func # share common other_args # share common map_func # common_func ( value * common_args ) | def mapv(ol,map_func,map_func_args=[]):
'''
#mapv i不作为map_func参数,共享相同的f,共享相同的o
# NOT take index as a param for map_func
# share common other_args
# share common map_func
# common_func(value,*common_args)
'''
rslt = list(map(lambda ... |
obseleted just for compatible from elist. elist import * ol = [ 1 2 3 4 ] def map_func ( ele mul plus ): return ( ele * mul + plus ) | def array_map(ol,map_func,*args):
'''
obseleted,just for compatible
from elist.elist import *
ol = [1,2,3,4]
def map_func(ele,mul,plus):
return(ele*mul+plus)
array_map(ol,map_func,2,100)
'''
rslt = list(map(lambda ele:map_func(ele,*args),ol))
return(r... |
#mapo i不作为map_func参数 v不作为map_func参数 共享相同的f # NOT take index as a param for map_func # NOT take value as a param for map_func # share common map_func # common_func ( * priv_args ) | def mapo(ol,map_func,*params,**kwargs):
'''
#mapo i不作为map_func参数,v不作为map_func参数,共享相同的f
# NOT take index as a param for map_func
# NOT take value as a param for map_func
# share common map_func
# common_func(*priv_args)
'''
params = ... |
#findfivo f i v o四元决定 fivo - 4 - tuple - engine #cond_func diff_func ( index value * diff_args ) | def findfivo(ol,*args,**kwargs):
'''
#findfivo f,i,v,o四元决定 fivo-4-tuple-engine
#cond_func diff_func(index,value,*diff_args)
'''
args = list(args)
lngth = args.__len__()
if(lngth==0):
diff_funcs_arr = kwargs['cond_funcs']
diff_args_... |
#findfiv 共享相同的o share common other_args #cond_func diff_func ( index value * common_args ) | def findfiv(ol,cond_func_args,**kwargs):
'''
#findfiv 共享相同的o share common other_args
#cond_func diff_func(index,value,*common_args)
'''
lngth = ol.__len__()
diff_funcs_arr = kwargs['cond_funcs']
common_args_arr = init(lngth,map_func_args)
... |
#mapv i不作为map_func参数 共享相同的f 共享相同的o # NOT take index as a param for map_func # share common other_args # share common cond_func # common_func ( value * common_args ) | def findv(ol,cond_func,cond_func_args=[]):
'''
#mapv i不作为map_func参数,共享相同的f,共享相同的o
# NOT take index as a param for map_func
# share common other_args
# share common cond_func
# common_func(value,*common_args)
'''
rslt = []
for i... |
from elist. elist import * from elist. jprint import pobj def test_func ( ele x ): cond = ( ele > x ) return ( cond ) ol = [ 1 2 3 4 5 6 7 ] rslt = cond_select_indexes_all ( ol cond_func = test_func cond_func_args = [ 3 ] ) pobj ( rslt ) | def cond_select_indexes_all(ol,**kwargs):
'''
from elist.elist import *
from elist.jprint import pobj
def test_func(ele,x):
cond = (ele > x)
return(cond)
ol = [1,2,3,4,5,6,7]
rslt = cond_select_indexes_all(ol,cond_func = test_func, cond_func_a... |
from elist. elist import * from xdict. jprint import pobj def test_func ( ele index x ): cond1 = ( ele > x ) cond2 = ( index %2 == 0 ) cond = ( cond1 & cond2 ) return ( cond ) | def cond_select_indexes_all2(ol,**kwargs):
'''
from elist.elist import *
from xdict.jprint import pobj
def test_func(ele,index,x):
cond1 = (ele > x)
cond2 = (index %2 == 0)
cond =(cond1 & cond2)
return(cond)
ol = [1,2,3,4,5,6,7]
... |
from elist. elist import * ol = [ a b c d ] select_seqs ( ol [ 1 2 ] ) | def select_seqs(ol,seqs):
'''
from elist.elist import *
ol = ['a','b','c','d']
select_seqs(ol,[1,2])
'''
rslt =copy.deepcopy(ol)
rslt = itemgetter(*seqs)(ol)
if(seqs.__len__()==0):
rslt = []
elif(seqs.__len__()==1):
rslt = [rslt]
else:
rslt = l... |
from elist. elist import * ol = [ 1 2 3 4 ] ele = 5 id ( ol ) append ( ol ele mode = original ) ol id ( ol ) #### ol = [ 1 2 3 4 ] ele = 5 id ( ol ) new = append ( ol ele ) new id ( new ) | def append(ol,ele,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4]
ele = 5
id(ol)
append(ol,ele,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
ele = 5
id(ol)
new = append(ol,ele)
new
id(new)
''... |
from elist. elist import * ol = [ 1 2 3 4 ] id ( ol ) append_some ( ol 5 6 7 8 mode = original ) ol id ( ol ) #### ol = [ 1 2 3 4 ] id ( ol ) new = append_some ( ol 5 6 7 8 ) new id ( new ) | def append_some(ol,*eles,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4]
id(ol)
append_some(ol,5,6,7,8,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
id(ol)
new = append_some(ol,5,6,7,8)
new
id(new)
'''
i... |
from elist. elist import * ol = [ 1 2 3 4 ] ele = 5 id ( ol ) prepend ( ol ele mode = original ) ol id ( ol ) #### ol = [ 1 2 3 4 ] ele = 5 id ( ol ) new = prepend ( ol ele ) new id ( new ) | def prepend(ol,ele,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4]
ele = 5
id(ol)
prepend(ol,ele,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
ele = 5
id(ol)
new = prepend(ol,ele)
new
id(new)
... |
from elist. elist import * ol = [ 1 2 3 4 ] id ( ol ) prepend_some ( ol 5 6 7 8 mode = original ) ol id ( ol ) #### ol = [ 1 2 3 4 ] id ( ol ) new = prepend_some ( ol 5 6 7 8 ) new id ( new ) #####unshift is the same as prepend_some >>> unshift ( ol 9 10 11 12 ) [ 9 10 11 12 1 2 3 4 ] | def prepend_some(ol,*eles,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4]
id(ol)
prepend_some(ol,5,6,7,8,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
id(ol)
new = prepend_some(ol,5,6,7,8)
new
id(new)
##... |
from elist. elist import * ol = [ 1 2 3 4 ] nl = [ 5 6 7 8 ] id ( ol ) extend ( ol nl mode = original ) ol id ( ol ) #### ol = [ 1 2 3 4 ] nl = [ 5 6 7 8 ] id ( ol ) new = extend ( ol nl ) new id ( new ) | def extend(ol,nl,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4]
nl = [5,6,7,8]
id(ol)
extend(ol,nl,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
nl = [5,6,7,8]
id(ol)
new = extend(ol,nl)
new
id(... |
from elist. elist import * ol = [ 1 2 3 4 ] id ( ol ) new = push ( ol 5 6 7 ) new id ( new ) #### ol = [ 1 2 3 4 ] id ( ol ) rslt = push ( ol 5 6 7 mode = original ) rslt id ( rslt ) | def push(ol,*eles,**kwargs):
'''
from elist.elist import *
ol=[1,2,3,4]
id(ol)
new = push(ol,5,6,7)
new
id(new)
####
ol=[1,2,3,4]
id(ol)
rslt = push(ol,5,6,7,mode="original")
rslt
id(rslt)
'''
if('mode' in kwargs... |
from elist. elist import * ol = [ 1 2 3 4 ] nl = [ 5 6 7 8 ] id ( ol ) id ( nl ) prextend ( ol nl mode = original ) ol id ( ol ) #### ol = [ 1 2 3 4 ] nl = [ 5 6 7 8 ] id ( ol ) id ( nl ) new = prextend ( ol nl ) new id ( new ) | def prextend(ol,nl,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4]
nl = [5,6,7,8]
id(ol)
id(nl)
prextend(ol,nl,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
nl = [5,6,7,8]
id(ol)
id(nl)
new = pre... |
from elist. elist import * l1 = [ 1 2 3 ] l2 = [ a b c ] l3 = [ 100 200 ] id ( l1 ) id ( l2 ) id ( l3 ) arrays = [ l1 l2 l3 ] new = concat ( arrays ) new id ( new ) | def concat(*arrays):
'''
from elist.elist import *
l1 = [1,2,3]
l2 = ["a","b","c"]
l3 = [100,200]
id(l1)
id(l2)
id(l3)
arrays = [l1,l2,l3]
new = concat(arrays)
new
id(new)
'''
new = []
length = arrays.__len__()
f... |
from elist. elist import * ol = [ 1 2 3 4 ] id ( ol ) new = cdr ( ol ) new id ( new ) #### ol = [ 1 2 3 4 ] id ( ol ) rslt = cdr ( ol mode = original ) rslt id ( rslt ) | def cdr(ol,**kwargs):
'''
from elist.elist import *
ol=[1,2,3,4]
id(ol)
new = cdr(ol)
new
id(new)
####
ol=[1,2,3,4]
id(ol)
rslt = cdr(ol,mode="original")
rslt
id(rslt)
'''
if('mode' in kwargs):
mode = kwa... |
from elist. elist import * ol = [ 1 2 3 4 ] id ( ol ) new = cons ( 5 ol ) new id ( new ) #### ol = [ 1 2 3 4 ] id ( ol ) rslt = cons ( 5 ol mode = original ) rslt id ( rslt ) | def cons(head_ele,l,**kwargs):
'''
from elist.elist import *
ol=[1,2,3,4]
id(ol)
new = cons(5,ol)
new
id(new)
####
ol=[1,2,3,4]
id(ol)
rslt = cons(5,ol,mode="original")
rslt
id(rslt)
'''
if('mode' in kwargs):
... |
uniform_index ( 0 3 ) uniform_index ( - 1 3 ) uniform_index ( - 4 3 ) uniform_index ( - 3 3 ) uniform_index ( 5 3 ) | def uniform_index(index,length):
'''
uniform_index(0,3)
uniform_index(-1,3)
uniform_index(-4,3)
uniform_index(-3,3)
uniform_index(5,3)
'''
if(index<0):
rl = length+index
if(rl<0):
index = 0
else:
index = rl
elif(inde... |
from elist. elist import * ol = [ 1 2 3 4 ] ele = 5 id ( ol ) insert ( ol 2 ele mode = original ) ol id ( ol ) #### ol = [ 1 2 3 4 ] ele = 5 id ( ol ) new = insert ( ol 2 ele ) new id ( new ) | def insert(ol,start_index,ele,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4]
ele = 5
id(ol)
insert(ol,2,ele,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
ele = 5
id(ol)
new = insert(ol,2,ele)
new
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.