repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
carta/ldap_tools | src/ldap_tools/client.py | Client.get_max_id | def get_max_id(self, object_type, role):
"""Get the highest used ID."""
if object_type == 'user':
objectclass = 'posixAccount'
ldap_attr = 'uidNumber'
elif object_type == 'group': # pragma: no cover
objectclass = 'posixGroup'
ldap_attr = 'gidNumbe... | python | def get_max_id(self, object_type, role):
"""Get the highest used ID."""
if object_type == 'user':
objectclass = 'posixAccount'
ldap_attr = 'uidNumber'
elif object_type == 'group': # pragma: no cover
objectclass = 'posixGroup'
ldap_attr = 'gidNumbe... | [
"def",
"get_max_id",
"(",
"self",
",",
"object_type",
",",
"role",
")",
":",
"if",
"object_type",
"==",
"'user'",
":",
"objectclass",
"=",
"'posixAccount'",
"ldap_attr",
"=",
"'uidNumber'",
"elif",
"object_type",
"==",
"'group'",
":",
"# pragma: no cover",
"obje... | Get the highest used ID. | [
"Get",
"the",
"highest",
"used",
"ID",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/client.py#L110-L142 | train | Get the highest used ID. |
smnorris/bcdata | bcdata/wcs.py | get_dem | def get_dem(bounds, out_file="dem.tif", src_crs="EPSG:3005", dst_crs="EPSG:3005", resolution=25):
"""Get 25m DEM for provided bounds, write to GeoTIFF
"""
bbox = ",".join([str(b) for b in bounds])
# todo: validate resolution units are equivalent to src_crs units
# build request
payload = {
... | python | def get_dem(bounds, out_file="dem.tif", src_crs="EPSG:3005", dst_crs="EPSG:3005", resolution=25):
"""Get 25m DEM for provided bounds, write to GeoTIFF
"""
bbox = ",".join([str(b) for b in bounds])
# todo: validate resolution units are equivalent to src_crs units
# build request
payload = {
... | [
"def",
"get_dem",
"(",
"bounds",
",",
"out_file",
"=",
"\"dem.tif\"",
",",
"src_crs",
"=",
"\"EPSG:3005\"",
",",
"dst_crs",
"=",
"\"EPSG:3005\"",
",",
"resolution",
"=",
"25",
")",
":",
"bbox",
"=",
"\",\"",
".",
"join",
"(",
"[",
"str",
"(",
"b",
")",... | Get 25m DEM for provided bounds, write to GeoTIFF | [
"Get",
"25m",
"DEM",
"for",
"provided",
"bounds",
"write",
"to",
"GeoTIFF"
] | de6b5bbc28d85e36613b51461911ee0a72a146c5 | https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wcs.py#L10-L38 | train | Get 25m DEM for provided bounds write to GeoTIFF
|
carta/ldap_tools | src/ldap_tools/commands.py | main | def main(): # pragma: no cover
"""Enter main function."""
entry_point.add_command(CLI.version)
entry_point.add_command(UserCLI.user)
entry_point.add_command(GroupCLI.group)
entry_point.add_command(AuditCLI.audit)
entry_point.add_command(KeyCLI.key)
entry_point() | python | def main(): # pragma: no cover
"""Enter main function."""
entry_point.add_command(CLI.version)
entry_point.add_command(UserCLI.user)
entry_point.add_command(GroupCLI.group)
entry_point.add_command(AuditCLI.audit)
entry_point.add_command(KeyCLI.key)
entry_point() | [
"def",
"main",
"(",
")",
":",
"# pragma: no cover",
"entry_point",
".",
"add_command",
"(",
"CLI",
".",
"version",
")",
"entry_point",
".",
"add_command",
"(",
"UserCLI",
".",
"user",
")",
"entry_point",
".",
"add_command",
"(",
"GroupCLI",
".",
"group",
")"... | Enter main function. | [
"Enter",
"main",
"function",
"."
] | 7c039304a5abaf836c7afc35cf068b4471306264 | https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/commands.py#L29-L37 | train | Enter main function. |
rgmining/common | common/decorator.py | print_args | def print_args(output=sys.stdout):
"""Decorate a function so that print arguments before calling it.
Args:
output: writable to print args. (Default: sys.stdout)
"""
def decorator(func):
"""The decorator function.
"""
@wraps(func)
def _(*args, **kwargs):
... | python | def print_args(output=sys.stdout):
"""Decorate a function so that print arguments before calling it.
Args:
output: writable to print args. (Default: sys.stdout)
"""
def decorator(func):
"""The decorator function.
"""
@wraps(func)
def _(*args, **kwargs):
... | [
"def",
"print_args",
"(",
"output",
"=",
"sys",
".",
"stdout",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"\"\"\"The decorator function.\n \"\"\"",
"@",
"wraps",
"(",
"func",
")",
"def",
"_",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")... | Decorate a function so that print arguments before calling it.
Args:
output: writable to print args. (Default: sys.stdout) | [
"Decorate",
"a",
"function",
"so",
"that",
"print",
"arguments",
"before",
"calling",
"it",
"."
] | 2462a4d54f32a82eadd7b1e28675b3c8bcd172b2 | https://github.com/rgmining/common/blob/2462a4d54f32a82eadd7b1e28675b3c8bcd172b2/common/decorator.py#L30-L47 | train | Decorator to print the arguments of a function. |
rgmining/common | common/decorator.py | constant | def constant(func):
"""Decorate a function so that the result is a constant value.
Functions wraped by this decorator will be run just one time.
The computational result will be stored and reused for any other input.
To store each result for each input, use :func:`memoized` instead.
"""
@wraps... | python | def constant(func):
"""Decorate a function so that the result is a constant value.
Functions wraped by this decorator will be run just one time.
The computational result will be stored and reused for any other input.
To store each result for each input, use :func:`memoized` instead.
"""
@wraps... | [
"def",
"constant",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"_",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"The decorated function.\n \"\"\"",
"if",
"not",
"_",
".",
"res",
":",
"_",
".",
"res",
"=",
"func... | Decorate a function so that the result is a constant value.
Functions wraped by this decorator will be run just one time.
The computational result will be stored and reused for any other input.
To store each result for each input, use :func:`memoized` instead. | [
"Decorate",
"a",
"function",
"so",
"that",
"the",
"result",
"is",
"a",
"constant",
"value",
"."
] | 2462a4d54f32a82eadd7b1e28675b3c8bcd172b2 | https://github.com/rgmining/common/blob/2462a4d54f32a82eadd7b1e28675b3c8bcd172b2/common/decorator.py#L70-L86 | train | Decorator to make a function return a constant value. |
rgmining/common | common/decorator.py | memoized | def memoized(func):
"""Decorate a function to memoize results.
Functions wraped by this decorator won't compute twice for each input.
Any results will be stored. This decorator might increase used memory
in order to shorten computational time.
"""
cache = {}
@wraps(func)
def memoized_fu... | python | def memoized(func):
"""Decorate a function to memoize results.
Functions wraped by this decorator won't compute twice for each input.
Any results will be stored. This decorator might increase used memory
in order to shorten computational time.
"""
cache = {}
@wraps(func)
def memoized_fu... | [
"def",
"memoized",
"(",
"func",
")",
":",
"cache",
"=",
"{",
"}",
"@",
"wraps",
"(",
"func",
")",
"def",
"memoized_function",
"(",
"*",
"args",
")",
":",
"\"\"\"The decorated function.\n \"\"\"",
"try",
":",
"return",
"cache",
"[",
"args",
"]",
"exc... | Decorate a function to memoize results.
Functions wraped by this decorator won't compute twice for each input.
Any results will be stored. This decorator might increase used memory
in order to shorten computational time. | [
"Decorate",
"a",
"function",
"to",
"memoize",
"results",
"."
] | 2462a4d54f32a82eadd7b1e28675b3c8bcd172b2 | https://github.com/rgmining/common/blob/2462a4d54f32a82eadd7b1e28675b3c8bcd172b2/common/decorator.py#L89-L111 | train | Decorator to memoize results. |
mkoura/dump2polarion | dump2polarion/results/dbtools.py | _open_sqlite | def _open_sqlite(db_file):
"""Opens database connection."""
db_file = os.path.expanduser(db_file)
try:
with open(db_file):
# test that the file can be accessed
pass
return sqlite3.connect(db_file, detect_types=sqlite3.PARSE_DECLTYPES)
except (IOError, sqlite3.Erro... | python | def _open_sqlite(db_file):
"""Opens database connection."""
db_file = os.path.expanduser(db_file)
try:
with open(db_file):
# test that the file can be accessed
pass
return sqlite3.connect(db_file, detect_types=sqlite3.PARSE_DECLTYPES)
except (IOError, sqlite3.Erro... | [
"def",
"_open_sqlite",
"(",
"db_file",
")",
":",
"db_file",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"db_file",
")",
"try",
":",
"with",
"open",
"(",
"db_file",
")",
":",
"# test that the file can be accessed",
"pass",
"return",
"sqlite3",
".",
"conne... | Opens database connection. | [
"Opens",
"database",
"connection",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/dbtools.py#L33-L42 | train | Opens database connection. |
mkoura/dump2polarion | dump2polarion/results/dbtools.py | import_sqlite | def import_sqlite(db_file, older_than=None, **kwargs):
"""Reads the content of the database file and returns imported data."""
conn = _open_sqlite(db_file)
cur = conn.cursor()
# get rows that were not exported yet
select = "SELECT * FROM testcases WHERE exported != 'yes'"
if older_than:
... | python | def import_sqlite(db_file, older_than=None, **kwargs):
"""Reads the content of the database file and returns imported data."""
conn = _open_sqlite(db_file)
cur = conn.cursor()
# get rows that were not exported yet
select = "SELECT * FROM testcases WHERE exported != 'yes'"
if older_than:
... | [
"def",
"import_sqlite",
"(",
"db_file",
",",
"older_than",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"_open_sqlite",
"(",
"db_file",
")",
"cur",
"=",
"conn",
".",
"cursor",
"(",
")",
"# get rows that were not exported yet",
"select",
"=",
... | Reads the content of the database file and returns imported data. | [
"Reads",
"the",
"content",
"of",
"the",
"database",
"file",
"and",
"returns",
"imported",
"data",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/dbtools.py#L46-L69 | train | Reads the content of the database file and returns imported data. |
mkoura/dump2polarion | dump2polarion/results/dbtools.py | mark_exported_sqlite | def mark_exported_sqlite(db_file, older_than=None):
"""Marks rows with verdict as exported."""
logger.debug("Marking rows in database as exported")
conn = _open_sqlite(db_file)
cur = conn.cursor()
update = "UPDATE testcases SET exported = 'yes' WHERE verdict IS NOT null AND verdict != ''"
if old... | python | def mark_exported_sqlite(db_file, older_than=None):
"""Marks rows with verdict as exported."""
logger.debug("Marking rows in database as exported")
conn = _open_sqlite(db_file)
cur = conn.cursor()
update = "UPDATE testcases SET exported = 'yes' WHERE verdict IS NOT null AND verdict != ''"
if old... | [
"def",
"mark_exported_sqlite",
"(",
"db_file",
",",
"older_than",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"Marking rows in database as exported\"",
")",
"conn",
"=",
"_open_sqlite",
"(",
"db_file",
")",
"cur",
"=",
"conn",
".",
"cursor",
"(",
")"... | Marks rows with verdict as exported. | [
"Marks",
"rows",
"with",
"verdict",
"as",
"exported",
"."
] | f4bd24e9d5070e282aad15f1e8bb514c0525cd37 | https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/dbtools.py#L72-L83 | train | Marks rows with verdict as exported. |
iLampard/x-utils | xutils/decorators.py | handle_exception | def handle_exception(logger, **kw_decorator):
"""
:param logger: logging, a logging object
:return: decorator, wraps exception loggers
"""
def decorator(query_func):
@functools.wraps(query_func)
def wrapper(*args, **kwargs):
try:
return query_func(*args, ... | python | def handle_exception(logger, **kw_decorator):
"""
:param logger: logging, a logging object
:return: decorator, wraps exception loggers
"""
def decorator(query_func):
@functools.wraps(query_func)
def wrapper(*args, **kwargs):
try:
return query_func(*args, ... | [
"def",
"handle_exception",
"(",
"logger",
",",
"*",
"*",
"kw_decorator",
")",
":",
"def",
"decorator",
"(",
"query_func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"query_func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"... | :param logger: logging, a logging object
:return: decorator, wraps exception loggers | [
":",
"param",
"logger",
":",
"logging",
"a",
"logging",
"object",
":",
"return",
":",
"decorator",
"wraps",
"exception",
"loggers"
] | 291d92832ee0e0c89bc22e10ecf2f44445e0d300 | https://github.com/iLampard/x-utils/blob/291d92832ee0e0c89bc22e10ecf2f44445e0d300/xutils/decorators.py#L22-L51 | train | A decorator that handles exceptions in a log object. |
iLampard/x-utils | xutils/decorators.py | clock | def clock(logger):
"""
:param logger: logging, a logging object
:return: decorator, wraps time
"""
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
_start = time.time()
retval = func(*args, **kwargs)
_end = time.time()
... | python | def clock(logger):
"""
:param logger: logging, a logging object
:return: decorator, wraps time
"""
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
_start = time.time()
retval = func(*args, **kwargs)
_end = time.time()
... | [
"def",
"clock",
"(",
"logger",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"_start",
"=",
"time",
".",
"time",
"(",
... | :param logger: logging, a logging object
:return: decorator, wraps time | [
":",
"param",
"logger",
":",
"logging",
"a",
"logging",
"object",
":",
"return",
":",
"decorator",
"wraps",
"time"
] | 291d92832ee0e0c89bc22e10ecf2f44445e0d300 | https://github.com/iLampard/x-utils/blob/291d92832ee0e0c89bc22e10ecf2f44445e0d300/xutils/decorators.py#L54-L71 | train | A decorator that returns a function that runs the given function every second. |
mgoral/subconvert | src/subconvert/parsing/Formats.py | SubFormat.createSubtitle | def createSubtitle(self, fps, section):
"""Returns a correct 'Subtitle' object from a text given in 'section'. If 'section' cannot
be parsed, None is returned.
By default 'section' is checked against 'subPattern' regular expression."""
matched = self._pattern.search(section)
if m... | python | def createSubtitle(self, fps, section):
"""Returns a correct 'Subtitle' object from a text given in 'section'. If 'section' cannot
be parsed, None is returned.
By default 'section' is checked against 'subPattern' regular expression."""
matched = self._pattern.search(section)
if m... | [
"def",
"createSubtitle",
"(",
"self",
",",
"fps",
",",
"section",
")",
":",
"matched",
"=",
"self",
".",
"_pattern",
".",
"search",
"(",
"section",
")",
"if",
"matched",
"is",
"not",
"None",
":",
"matchedDict",
"=",
"matched",
".",
"groupdict",
"(",
")... | Returns a correct 'Subtitle' object from a text given in 'section'. If 'section' cannot
be parsed, None is returned.
By default 'section' is checked against 'subPattern' regular expression. | [
"Returns",
"a",
"correct",
"Subtitle",
"object",
"from",
"a",
"text",
"given",
"in",
"section",
".",
"If",
"section",
"cannot",
"be",
"parsed",
"None",
"is",
"returned",
".",
"By",
"default",
"section",
"is",
"checked",
"against",
"subPattern",
"regular",
"e... | 59701e5e69ef1ca26ce7d1d766c936664aa2cb32 | https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/parsing/Formats.py#L130-L142 | train | Returns a correct Subtitle object from a text given in section. |
mgoral/subconvert | src/subconvert/parsing/Formats.py | SubFormat.formatSub | def formatSub(self, string):
"""Convert sub-type specific formatting to GSP formatting.
By default formatSub will replace 1-to-1 all occurences of subtitle specific tags with
their GSP equivalents. Due to performance reasons it will not parse given 'string' in any
other way. That means t... | python | def formatSub(self, string):
"""Convert sub-type specific formatting to GSP formatting.
By default formatSub will replace 1-to-1 all occurences of subtitle specific tags with
their GSP equivalents. Due to performance reasons it will not parse given 'string' in any
other way. That means t... | [
"def",
"formatSub",
"(",
"self",
",",
"string",
")",
":",
"string",
"=",
"string",
".",
"strip",
"(",
")",
"string",
"=",
"string",
".",
"replace",
"(",
"'{'",
",",
"'{{'",
")",
".",
"replace",
"(",
"'}'",
",",
"'}}'",
")",
"string",
"=",
"self",
... | Convert sub-type specific formatting to GSP formatting.
By default formatSub will replace 1-to-1 all occurences of subtitle specific tags with
their GSP equivalents. Due to performance reasons it will not parse given 'string' in any
other way. That means that it cannot detect exotic situations l... | [
"Convert",
"sub",
"-",
"type",
"specific",
"formatting",
"to",
"GSP",
"formatting",
".",
"By",
"default",
"formatSub",
"will",
"replace",
"1",
"-",
"to",
"-",
"1",
"all",
"occurences",
"of",
"subtitle",
"specific",
"tags",
"with",
"their",
"GSP",
"equivalent... | 59701e5e69ef1ca26ce7d1d766c936664aa2cb32 | https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/parsing/Formats.py#L155-L171 | train | Convert sub - type specific formatting to GSP formatting. |
mgoral/subconvert | src/subconvert/parsing/Formats.py | SubFormat.convertTime | def convertTime(self, frametime, which):
"""Convert FrameTime object to properly formatted string that describes subtitle start or
end time."""
SubAssert(frametime.frame >= 0, _("Negative time present."))
return frametime.frame | python | def convertTime(self, frametime, which):
"""Convert FrameTime object to properly formatted string that describes subtitle start or
end time."""
SubAssert(frametime.frame >= 0, _("Negative time present."))
return frametime.frame | [
"def",
"convertTime",
"(",
"self",
",",
"frametime",
",",
"which",
")",
":",
"SubAssert",
"(",
"frametime",
".",
"frame",
">=",
"0",
",",
"_",
"(",
"\"Negative time present.\"",
")",
")",
"return",
"frametime",
".",
"frame"
] | Convert FrameTime object to properly formatted string that describes subtitle start or
end time. | [
"Convert",
"FrameTime",
"object",
"to",
"properly",
"formatted",
"string",
"that",
"describes",
"subtitle",
"start",
"or",
"end",
"time",
"."
] | 59701e5e69ef1ca26ce7d1d766c936664aa2cb32 | https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/parsing/Formats.py#L181-L185 | train | Convert FrameTime object to properly formatted string that describes subtitle start or
end time. |
ludeeus/GHLocalApi | examples/get_units.py | device_info | async def device_info():
"""Get device info from GH."""
async with aiohttp.ClientSession() as session:
ghlocalapi = NetworkScan(LOOP, session)
result = await ghlocalapi.scan_for_units(IPRANGE)
print(result) | python | async def device_info():
"""Get device info from GH."""
async with aiohttp.ClientSession() as session:
ghlocalapi = NetworkScan(LOOP, session)
result = await ghlocalapi.scan_for_units(IPRANGE)
print(result) | [
"async",
"def",
"device_info",
"(",
")",
":",
"async",
"with",
"aiohttp",
".",
"ClientSession",
"(",
")",
"as",
"session",
":",
"ghlocalapi",
"=",
"NetworkScan",
"(",
"LOOP",
",",
"session",
")",
"result",
"=",
"await",
"ghlocalapi",
".",
"scan_for_units",
... | Get device info from GH. | [
"Get",
"device",
"info",
"from",
"GH",
"."
] | 93abdee299c4a4b65aa9dd03c77ec34e174e3c56 | https://github.com/ludeeus/GHLocalApi/blob/93abdee299c4a4b65aa9dd03c77ec34e174e3c56/examples/get_units.py#L9-L14 | train | Get device info from GH. |
noahbenson/pimms | pimms/table.py | _ndarray_assoc | def _ndarray_assoc(arr, k, v):
'_ndarray_assoc(arr, k, v) duplicates arr to a writeable array, sets arr2[k]=v, returns arr2'
arr = np.array(arr)
arr[k] = v
arr.setflags(write=False)
return arr | python | def _ndarray_assoc(arr, k, v):
'_ndarray_assoc(arr, k, v) duplicates arr to a writeable array, sets arr2[k]=v, returns arr2'
arr = np.array(arr)
arr[k] = v
arr.setflags(write=False)
return arr | [
"def",
"_ndarray_assoc",
"(",
"arr",
",",
"k",
",",
"v",
")",
":",
"arr",
"=",
"np",
".",
"array",
"(",
"arr",
")",
"arr",
"[",
"k",
"]",
"=",
"v",
"arr",
".",
"setflags",
"(",
"write",
"=",
"False",
")",
"return",
"arr"
] | _ndarray_assoc(arr, k, v) duplicates arr to a writeable array, sets arr2[k]=v, returns arr2 | [
"_ndarray_assoc",
"(",
"arr",
"k",
"v",
")",
"duplicates",
"arr",
"to",
"a",
"writeable",
"array",
"sets",
"arr2",
"[",
"k",
"]",
"=",
"v",
"returns",
"arr2"
] | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/table.py#L19-L24 | train | duplicates arr to a writeable array sets arr2 [ k ] = v returns arr2 |
noahbenson/pimms | pimms/table.py | itable | def itable(*args, **kwargs):
'''
itable(...) yields a new immutable table object from the given set of arguments. The arguments
may be any number of maps or itables followed by any number of keyword arguments. All the
entries from the arguments and keywords are collapsed left-to-right (respecting la... | python | def itable(*args, **kwargs):
'''
itable(...) yields a new immutable table object from the given set of arguments. The arguments
may be any number of maps or itables followed by any number of keyword arguments. All the
entries from the arguments and keywords are collapsed left-to-right (respecting la... | [
"def",
"itable",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# a couple things we want to check first... does our argument list reduce to just an empty",
"# itable or just a single itable?",
"if",
"len",
"(",
"args",
")",
"==",
"0",
"and",
"len",
"(",
"kwargs"... | itable(...) yields a new immutable table object from the given set of arguments. The arguments
may be any number of maps or itables followed by any number of keyword arguments. All the
entries from the arguments and keywords are collapsed left-to-right (respecting laziness),
and the resulting column s... | [
"itable",
"(",
"...",
")",
"yields",
"a",
"new",
"immutable",
"table",
"object",
"from",
"the",
"given",
"set",
"of",
"arguments",
".",
"The",
"arguments",
"may",
"be",
"any",
"number",
"of",
"maps",
"or",
"itables",
"followed",
"by",
"any",
"number",
"o... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/table.py#L402-L432 | train | Yields a new immutable table object from the given set of arguments. |
pneff/wsgiservice | wsgiservice/status.py | raise_201 | def raise_201(instance, location):
"""Abort the current request with a 201 (Created) response code. Sets the
Location header correctly. If the location does not start with a slash,
the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type i... | python | def raise_201(instance, location):
"""Abort the current request with a 201 (Created) response code. Sets the
Location header correctly. If the location does not start with a slash,
the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type i... | [
"def",
"raise_201",
"(",
"instance",
",",
"location",
")",
":",
"_set_location",
"(",
"instance",
",",
"location",
")",
"instance",
".",
"response",
".",
"status",
"=",
"201",
"raise",
"ResponseException",
"(",
"instance",
".",
"response",
")"
] | Abort the current request with a 201 (Created) response code. Sets the
Location header correctly. If the location does not start with a slash,
the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"201",
"(",
"Created",
")",
"response",
"code",
".",
"Sets",
"the",
"Location",
"header",
"correctly",
".",
"If",
"the",
"location",
"does",
"not",
"start",
"with",
"a",
"slash",
"the",
"path",
"of",
"th... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L24-L35 | train | Abort the current request with a 201 response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_204 | def raise_204(instance):
"""Abort the current request with a 204 (No Content) response code. Clears
out the body of the response.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
:raises: :class:`webob.exceptions.ResponseException` of... | python | def raise_204(instance):
"""Abort the current request with a 204 (No Content) response code. Clears
out the body of the response.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
:raises: :class:`webob.exceptions.ResponseException` of... | [
"def",
"raise_204",
"(",
"instance",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"204",
"instance",
".",
"response",
".",
"body",
"=",
"''",
"instance",
".",
"response",
".",
"body_raw",
"=",
"None",
"raise",
"ResponseException",
"(",
"insta... | Abort the current request with a 204 (No Content) response code. Clears
out the body of the response.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
:raises: :class:`webob.exceptions.ResponseException` of status 204 | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"204",
"(",
"No",
"Content",
")",
"response",
"code",
".",
"Clears",
"out",
"the",
"body",
"of",
"the",
"response",
"."
] | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L49-L60 | train | Abort the current request with a 204 response code. Clears the body of the response. |
pneff/wsgiservice | wsgiservice/status.py | raise_205 | def raise_205(instance):
"""Abort the current request with a 205 (Reset Content) response code.
Clears out the body of the response.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
:raises: :class:`webob.exceptions.ResponseException`... | python | def raise_205(instance):
"""Abort the current request with a 205 (Reset Content) response code.
Clears out the body of the response.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
:raises: :class:`webob.exceptions.ResponseException`... | [
"def",
"raise_205",
"(",
"instance",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"205",
"instance",
".",
"response",
".",
"body",
"=",
"''",
"instance",
".",
"response",
".",
"body_raw",
"=",
"None",
"raise",
"ResponseException",
"(",
"insta... | Abort the current request with a 205 (Reset Content) response code.
Clears out the body of the response.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
:raises: :class:`webob.exceptions.ResponseException` of status 205 | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"205",
"(",
"Reset",
"Content",
")",
"response",
"code",
".",
"Clears",
"out",
"the",
"body",
"of",
"the",
"response",
"."
] | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L63-L74 | train | Abort the current request with a 205 response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_301 | def raise_301(instance, location):
"""Abort the current request with a 301 (Moved Permanently) response code.
Sets the Location header correctly. If the location does not start with a
slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
... | python | def raise_301(instance, location):
"""Abort the current request with a 301 (Moved Permanently) response code.
Sets the Location header correctly. If the location does not start with a
slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
... | [
"def",
"raise_301",
"(",
"instance",
",",
"location",
")",
":",
"_set_location",
"(",
"instance",
",",
"location",
")",
"instance",
".",
"response",
".",
"status",
"=",
"301",
"raise",
"ResponseException",
"(",
"instance",
".",
"response",
")"
] | Abort the current request with a 301 (Moved Permanently) response code.
Sets the Location header correctly. If the location does not start with a
slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"301",
"(",
"Moved",
"Permanently",
")",
"response",
"code",
".",
"Sets",
"the",
"Location",
"header",
"correctly",
".",
"If",
"the",
"location",
"does",
"not",
"start",
"with",
"a",
"slash",
"the",
"path"... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L88-L99 | train | Abort the current request with a 301 ( Moved Permanentlyly response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_302 | def raise_302(instance, location):
"""Abort the current request with a 302 (Found) response code. Sets the
Location header correctly. If the location does not start with a slash,
the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type ins... | python | def raise_302(instance, location):
"""Abort the current request with a 302 (Found) response code. Sets the
Location header correctly. If the location does not start with a slash,
the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type ins... | [
"def",
"raise_302",
"(",
"instance",
",",
"location",
")",
":",
"_set_location",
"(",
"instance",
",",
"location",
")",
"instance",
".",
"response",
".",
"status",
"=",
"302",
"raise",
"ResponseException",
"(",
"instance",
".",
"response",
")"
] | Abort the current request with a 302 (Found) response code. Sets the
Location header correctly. If the location does not start with a slash,
the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"302",
"(",
"Found",
")",
"response",
"code",
".",
"Sets",
"the",
"Location",
"header",
"correctly",
".",
"If",
"the",
"location",
"does",
"not",
"start",
"with",
"a",
"slash",
"the",
"path",
"of",
"the"... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L102-L113 | train | Abort the current request with a 302 response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_303 | def raise_303(instance, location):
"""Abort the current request with a 303 (See Other) response code. Sets
the Location header correctly. If the location does not start with a
slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type... | python | def raise_303(instance, location):
"""Abort the current request with a 303 (See Other) response code. Sets
the Location header correctly. If the location does not start with a
slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type... | [
"def",
"raise_303",
"(",
"instance",
",",
"location",
")",
":",
"_set_location",
"(",
"instance",
",",
"location",
")",
"instance",
".",
"response",
".",
"status",
"=",
"303",
"raise",
"ResponseException",
"(",
"instance",
".",
"response",
")"
] | Abort the current request with a 303 (See Other) response code. Sets
the Location header correctly. If the location does not start with a
slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"303",
"(",
"See",
"Other",
")",
"response",
"code",
".",
"Sets",
"the",
"Location",
"header",
"correctly",
".",
"If",
"the",
"location",
"does",
"not",
"start",
"with",
"a",
"slash",
"the",
"path",
"of"... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L116-L127 | train | Abort the current request with a 303 response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_304 | def raise_304(instance):
"""Abort the current request with a 304 (Not Modified) response code.
Clears out the body of the response.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
:raises: :class:`webob.exceptions.ResponseException` ... | python | def raise_304(instance):
"""Abort the current request with a 304 (Not Modified) response code.
Clears out the body of the response.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
:raises: :class:`webob.exceptions.ResponseException` ... | [
"def",
"raise_304",
"(",
"instance",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"304",
"instance",
".",
"response",
".",
"body",
"=",
"''",
"instance",
".",
"response",
".",
"body_raw",
"=",
"None",
"raise",
"ResponseException",
"(",
"insta... | Abort the current request with a 304 (Not Modified) response code.
Clears out the body of the response.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
:raises: :class:`webob.exceptions.ResponseException` of status 304
.. todo: The ... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"304",
"(",
"Not",
"Modified",
")",
"response",
"code",
".",
"Clears",
"out",
"the",
"body",
"of",
"the",
"response",
"."
] | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L130-L145 | train | Abort the current request with a 304 response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_305 | def raise_305(instance, location):
"""Abort the current request with a 305 (Use Proxy) response code. Sets
the Location header correctly. If the location does not start with a
slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type... | python | def raise_305(instance, location):
"""Abort the current request with a 305 (Use Proxy) response code. Sets
the Location header correctly. If the location does not start with a
slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type... | [
"def",
"raise_305",
"(",
"instance",
",",
"location",
")",
":",
"_set_location",
"(",
"instance",
",",
"location",
")",
"instance",
".",
"response",
".",
"status",
"=",
"305",
"raise",
"ResponseException",
"(",
"instance",
".",
"response",
")"
] | Abort the current request with a 305 (Use Proxy) response code. Sets
the Location header correctly. If the location does not start with a
slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"305",
"(",
"Use",
"Proxy",
")",
"response",
"code",
".",
"Sets",
"the",
"Location",
"header",
"correctly",
".",
"If",
"the",
"location",
"does",
"not",
"start",
"with",
"a",
"slash",
"the",
"path",
"of"... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L148-L159 | train | Abort the current request with a 305 response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_307 | def raise_307(instance, location):
"""Abort the current request with a 307 (Temporary Redirect) response
code. Sets the Location header correctly. If the location does not start
with a slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
... | python | def raise_307(instance, location):
"""Abort the current request with a 307 (Temporary Redirect) response
code. Sets the Location header correctly. If the location does not start
with a slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
... | [
"def",
"raise_307",
"(",
"instance",
",",
"location",
")",
":",
"_set_location",
"(",
"instance",
",",
"location",
")",
"instance",
".",
"response",
".",
"status",
"=",
"307",
"raise",
"ResponseException",
"(",
"instance",
".",
"response",
")"
] | Abort the current request with a 307 (Temporary Redirect) response
code. Sets the Location header correctly. If the location does not start
with a slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"307",
"(",
"Temporary",
"Redirect",
")",
"response",
"code",
".",
"Sets",
"the",
"Location",
"header",
"correctly",
".",
"If",
"the",
"location",
"does",
"not",
"start",
"with",
"a",
"slash",
"the",
"path... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L162-L173 | train | Abort the current request with a 307 response. |
pneff/wsgiservice | wsgiservice/status.py | raise_400 | def raise_400(instance, msg=None):
"""Abort the current request with a 400 (Bad Request) response code. If
the message is given it's output as an error message in the response body
(correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
:ty... | python | def raise_400(instance, msg=None):
"""Abort the current request with a 400 (Bad Request) response code. If
the message is given it's output as an error message in the response body
(correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
:ty... | [
"def",
"raise_400",
"(",
"instance",
",",
"msg",
"=",
"None",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"400",
"if",
"msg",
":",
"instance",
".",
"response",
".",
"body_raw",
"=",
"{",
"'error'",
":",
"msg",
"}",
"raise",
"ResponseExce... | Abort the current request with a 400 (Bad Request) response code. If
the message is given it's output as an error message in the response body
(correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resour... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"400",
"(",
"Bad",
"Request",
")",
"response",
"code",
".",
"If",
"the",
"message",
"is",
"given",
"it",
"s",
"output",
"as",
"an",
"error",
"message",
"in",
"the",
"response",
"body",
"(",
"correctly",
... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L176-L188 | train | Abort the current request with a 400 response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_401 | def raise_401(instance, authenticate, msg=None):
"""Abort the current request with a 401 (Unauthorized) response code. If
the message is given it's output as an error message in the response body
(correctly converted to the requested MIME type). Outputs the
WWW-Authenticate header as given by the authen... | python | def raise_401(instance, authenticate, msg=None):
"""Abort the current request with a 401 (Unauthorized) response code. If
the message is given it's output as an error message in the response body
(correctly converted to the requested MIME type). Outputs the
WWW-Authenticate header as given by the authen... | [
"def",
"raise_401",
"(",
"instance",
",",
"authenticate",
",",
"msg",
"=",
"None",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"401",
"instance",
".",
"response",
".",
"headers",
"[",
"'WWW-Authenticate'",
"]",
"=",
"authenticate",
"if",
"ms... | Abort the current request with a 401 (Unauthorized) response code. If
the message is given it's output as an error message in the response body
(correctly converted to the requested MIME type). Outputs the
WWW-Authenticate header as given by the authenticate parameter.
:param instance: Resource instanc... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"401",
"(",
"Unauthorized",
")",
"response",
"code",
".",
"If",
"the",
"message",
"is",
"given",
"it",
"s",
"output",
"as",
"an",
"error",
"message",
"in",
"the",
"response",
"body",
"(",
"correctly",
"c... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L191-L205 | train | Abort the current request with a 401 response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_402 | def raise_402(instance, msg=None):
"""Abort the current request with a 402 (Payment Required) response code.
If the message is given it's output as an error message in the response
body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
... | python | def raise_402(instance, msg=None):
"""Abort the current request with a 402 (Payment Required) response code.
If the message is given it's output as an error message in the response
body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
... | [
"def",
"raise_402",
"(",
"instance",
",",
"msg",
"=",
"None",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"402",
"if",
"msg",
":",
"instance",
".",
"response",
".",
"body_raw",
"=",
"{",
"'error'",
":",
"msg",
"}",
"raise",
"ResponseExce... | Abort the current request with a 402 (Payment Required) response code.
If the message is given it's output as an error message in the response
body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.R... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"402",
"(",
"Payment",
"Required",
")",
"response",
"code",
".",
"If",
"the",
"message",
"is",
"given",
"it",
"s",
"output",
"as",
"an",
"error",
"message",
"in",
"the",
"response",
"body",
"(",
"correct... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L208-L220 | train | Abort the current request with a 402 response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_403 | def raise_403(instance, msg=None):
"""Abort the current request with a 403 (Forbidden) response code. If the
message is given it's output as an error message in the response body
(correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
:type... | python | def raise_403(instance, msg=None):
"""Abort the current request with a 403 (Forbidden) response code. If the
message is given it's output as an error message in the response body
(correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
:type... | [
"def",
"raise_403",
"(",
"instance",
",",
"msg",
"=",
"None",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"403",
"if",
"msg",
":",
"instance",
".",
"response",
".",
"body_raw",
"=",
"{",
"'error'",
":",
"msg",
"}",
"raise",
"ResponseExce... | Abort the current request with a 403 (Forbidden) response code. If the
message is given it's output as an error message in the response body
(correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"403",
"(",
"Forbidden",
")",
"response",
"code",
".",
"If",
"the",
"message",
"is",
"given",
"it",
"s",
"output",
"as",
"an",
"error",
"message",
"in",
"the",
"response",
"body",
"(",
"correctly",
"conv... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L223-L235 | train | Abort the current request with a 403 response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_405 | def raise_405(instance):
"""Abort the current request with a 405 (Method Not Allowed) response
code. Sets the ``Allow`` response header to the return value of the
:func:`Resource.get_allowed_methods` function.
:param instance: Resource instance (used to access the response)
:type instance: :class:`... | python | def raise_405(instance):
"""Abort the current request with a 405 (Method Not Allowed) response
code. Sets the ``Allow`` response header to the return value of the
:func:`Resource.get_allowed_methods` function.
:param instance: Resource instance (used to access the response)
:type instance: :class:`... | [
"def",
"raise_405",
"(",
"instance",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"405",
"instance",
".",
"response",
".",
"headers",
"[",
"'Allow'",
"]",
"=",
"instance",
".",
"get_allowed_methods",
"(",
")",
"raise",
"ResponseException",
"(",... | Abort the current request with a 405 (Method Not Allowed) response
code. Sets the ``Allow`` response header to the return value of the
:func:`Resource.get_allowed_methods` function.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
:ra... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"405",
"(",
"Method",
"Not",
"Allowed",
")",
"response",
"code",
".",
"Sets",
"the",
"Allow",
"response",
"header",
"to",
"the",
"return",
"value",
"of",
"the",
":",
"func",
":",
"Resource",
".",
"get_al... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L249-L260 | train | Abort the current request with a 405 response. |
pneff/wsgiservice | wsgiservice/status.py | raise_412 | def raise_412(instance, msg=None):
"""Abort the current request with a 412 (Precondition Failed) response
code. If the message is given it's output as an error message in the
response body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)... | python | def raise_412(instance, msg=None):
"""Abort the current request with a 412 (Precondition Failed) response
code. If the message is given it's output as an error message in the
response body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)... | [
"def",
"raise_412",
"(",
"instance",
",",
"msg",
"=",
"None",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"412",
"if",
"msg",
":",
"instance",
".",
"response",
".",
"body_raw",
"=",
"{",
"'error'",
":",
"msg",
"}",
"raise",
"ResponseExce... | Abort the current request with a 412 (Precondition Failed) response
code. If the message is given it's output as an error message in the
response body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resourc... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"412",
"(",
"Precondition",
"Failed",
")",
"response",
"code",
".",
"If",
"the",
"message",
"is",
"given",
"it",
"s",
"output",
"as",
"an",
"error",
"message",
"in",
"the",
"response",
"body",
"(",
"corr... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L296-L308 | train | Abort the current request with a 412 response. |
pneff/wsgiservice | wsgiservice/status.py | raise_415 | def raise_415(instance, msg=None):
"""Abort the current request with a 415 (Unsupported Media Type) response
code. If the message is given it's output as an error message in the
response body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the respon... | python | def raise_415(instance, msg=None):
"""Abort the current request with a 415 (Unsupported Media Type) response
code. If the message is given it's output as an error message in the
response body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the respon... | [
"def",
"raise_415",
"(",
"instance",
",",
"msg",
"=",
"None",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"415",
"if",
"msg",
":",
"instance",
".",
"response",
".",
"body_raw",
"=",
"{",
"'error'",
":",
"msg",
"}",
"raise",
"ResponseExce... | Abort the current request with a 415 (Unsupported Media Type) response
code. If the message is given it's output as an error message in the
response body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.reso... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"415",
"(",
"Unsupported",
"Media",
"Type",
")",
"response",
"code",
".",
"If",
"the",
"message",
"is",
"given",
"it",
"s",
"output",
"as",
"an",
"error",
"message",
"in",
"the",
"response",
"body",
"(",... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L311-L323 | train | Abort the current request with a 415 response. |
pneff/wsgiservice | wsgiservice/status.py | raise_500 | def raise_500(instance, msg=None):
"""Abort the current request with a 500 (Internal Server Error) response
code. If the message is given it's output as an error message in the
response body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the respons... | python | def raise_500(instance, msg=None):
"""Abort the current request with a 500 (Internal Server Error) response
code. If the message is given it's output as an error message in the
response body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the respons... | [
"def",
"raise_500",
"(",
"instance",
",",
"msg",
"=",
"None",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"500",
"if",
"msg",
":",
"instance",
".",
"response",
".",
"body_raw",
"=",
"{",
"'error'",
":",
"msg",
"}",
"raise",
"ResponseExce... | Abort the current request with a 500 (Internal Server Error) response
code. If the message is given it's output as an error message in the
response body (correctly converted to the requested MIME type).
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resou... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"500",
"(",
"Internal",
"Server",
"Error",
")",
"response",
"code",
".",
"If",
"the",
"message",
"is",
"given",
"it",
"s",
"output",
"as",
"an",
"error",
"message",
"in",
"the",
"response",
"body",
"(",
... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L326-L338 | train | Abort the current request with a 500 response code. |
pneff/wsgiservice | wsgiservice/status.py | raise_501 | def raise_501(instance):
"""Abort the current request with a 501 (Not Implemented) response code.
Sets the ``Allow`` response header to the return value of the
:func:`Resource.get_allowed_methods` function.
:param instance: Resource instance (used to access the response)
:type instance: :class:`web... | python | def raise_501(instance):
"""Abort the current request with a 501 (Not Implemented) response code.
Sets the ``Allow`` response header to the return value of the
:func:`Resource.get_allowed_methods` function.
:param instance: Resource instance (used to access the response)
:type instance: :class:`web... | [
"def",
"raise_501",
"(",
"instance",
")",
":",
"instance",
".",
"response",
".",
"status",
"=",
"501",
"instance",
".",
"response",
".",
"headers",
"[",
"'Allow'",
"]",
"=",
"instance",
".",
"get_allowed_methods",
"(",
")",
"raise",
"ResponseException",
"(",... | Abort the current request with a 501 (Not Implemented) response code.
Sets the ``Allow`` response header to the return value of the
:func:`Resource.get_allowed_methods` function.
:param instance: Resource instance (used to access the response)
:type instance: :class:`webob.resource.Resource`
:raise... | [
"Abort",
"the",
"current",
"request",
"with",
"a",
"501",
"(",
"Not",
"Implemented",
")",
"response",
"code",
".",
"Sets",
"the",
"Allow",
"response",
"header",
"to",
"the",
"return",
"value",
"of",
"the",
":",
"func",
":",
"Resource",
".",
"get_allowed_me... | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L341-L352 | train | Abort the current request with a 501 response code. |
pneff/wsgiservice | wsgiservice/status.py | _set_location | def _set_location(instance, location):
"""Sets a ``Location`` response header. If the location does not start with
a slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the request and
response)
:type instance: :class:`webob.resou... | python | def _set_location(instance, location):
"""Sets a ``Location`` response header. If the location does not start with
a slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the request and
response)
:type instance: :class:`webob.resou... | [
"def",
"_set_location",
"(",
"instance",
",",
"location",
")",
":",
"location",
"=",
"str",
"(",
"location",
")",
"if",
"not",
"location",
".",
"startswith",
"(",
"'/'",
")",
":",
"location",
"=",
"urljoin",
"(",
"instance",
".",
"request_path",
".",
"rs... | Sets a ``Location`` response header. If the location does not start with
a slash, the path of the current request is prepended.
:param instance: Resource instance (used to access the request and
response)
:type instance: :class:`webob.resource.Resource` | [
"Sets",
"a",
"Location",
"response",
"header",
".",
"If",
"the",
"location",
"does",
"not",
"start",
"with",
"a",
"slash",
"the",
"path",
"of",
"the",
"current",
"request",
"is",
"prepended",
"."
] | 03c064ac2e8c53a1aac9c7b99970f23cf79e20f4 | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/status.py#L367-L378 | train | Sets a Location response header. |
djaodjin/djaodjin-deployutils | deployutils/apps/django/templatetags/deployutils_extratags.py | no_cache | def no_cache(asset_url):
"""
Removes query parameters
"""
pos = asset_url.rfind('?')
if pos > 0:
asset_url = asset_url[:pos]
return asset_url | python | def no_cache(asset_url):
"""
Removes query parameters
"""
pos = asset_url.rfind('?')
if pos > 0:
asset_url = asset_url[:pos]
return asset_url | [
"def",
"no_cache",
"(",
"asset_url",
")",
":",
"pos",
"=",
"asset_url",
".",
"rfind",
"(",
"'?'",
")",
"if",
"pos",
">",
"0",
":",
"asset_url",
"=",
"asset_url",
"[",
":",
"pos",
"]",
"return",
"asset_url"
] | Removes query parameters | [
"Removes",
"query",
"parameters"
] | a0fe3cf3030dbbf09025c69ce75a69b326565dd8 | https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/templatetags/deployutils_extratags.py#L61-L68 | train | Removes query parameters from the url and returns the asset_url without caching it. |
SignalN/language | language/ngrams.py | __ngrams | def __ngrams(s, n=3):
""" Raw n-grams from a sequence
If the sequence is a string, it will return char-level n-grams.
If the sequence is a list of words, it will return word-level n-grams.
Note: it treats space (' ') and punctuation like any other character.
>>> ngrams('This i... | python | def __ngrams(s, n=3):
""" Raw n-grams from a sequence
If the sequence is a string, it will return char-level n-grams.
If the sequence is a list of words, it will return word-level n-grams.
Note: it treats space (' ') and punctuation like any other character.
>>> ngrams('This i... | [
"def",
"__ngrams",
"(",
"s",
",",
"n",
"=",
"3",
")",
":",
"return",
"list",
"(",
"zip",
"(",
"*",
"[",
"s",
"[",
"i",
":",
"]",
"for",
"i",
"in",
"range",
"(",
"n",
")",
"]",
")",
")"
] | Raw n-grams from a sequence
If the sequence is a string, it will return char-level n-grams.
If the sequence is a list of words, it will return word-level n-grams.
Note: it treats space (' ') and punctuation like any other character.
>>> ngrams('This is not a test!')
[(... | [
"Raw",
"n",
"-",
"grams",
"from",
"a",
"sequence"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L3-L27 | train | Returns a list of n - grams from a sequence. |
SignalN/language | language/ngrams.py | word_ngrams | def word_ngrams(s, n=3, token_fn=tokens.on_whitespace):
"""
Word-level n-grams in a string
By default, whitespace is assumed to be a word boundary.
>>> ng.word_ngrams('This is not a test!')
[('This', 'is', 'not'), ('is', 'not', 'a'), ('not', 'a', 'test!')]
If the sequence'... | python | def word_ngrams(s, n=3, token_fn=tokens.on_whitespace):
"""
Word-level n-grams in a string
By default, whitespace is assumed to be a word boundary.
>>> ng.word_ngrams('This is not a test!')
[('This', 'is', 'not'), ('is', 'not', 'a'), ('not', 'a', 'test!')]
If the sequence'... | [
"def",
"word_ngrams",
"(",
"s",
",",
"n",
"=",
"3",
",",
"token_fn",
"=",
"tokens",
".",
"on_whitespace",
")",
":",
"tokens",
"=",
"token_fn",
"(",
"s",
")",
"return",
"__ngrams",
"(",
"tokens",
",",
"n",
"=",
"min",
"(",
"len",
"(",
"tokens",
")",... | Word-level n-grams in a string
By default, whitespace is assumed to be a word boundary.
>>> ng.word_ngrams('This is not a test!')
[('This', 'is', 'not'), ('is', 'not', 'a'), ('not', 'a', 'test!')]
If the sequence's length is less than or equal to n, the n-grams are
simply the ... | [
"Word",
"-",
"level",
"n",
"-",
"grams",
"in",
"a",
"string"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L29-L51 | train | Returns a list of n - grams in a string. |
SignalN/language | language/ngrams.py | char_ngrams | def char_ngrams(s, n=3, token_fn=tokens.on_whitespace):
"""
Character-level n-grams from within the words in a string.
By default, the word boundary is assumed to be whitespace. n-grams are
not taken across word boundaries, only within words.
If a word's length is less than or equ... | python | def char_ngrams(s, n=3, token_fn=tokens.on_whitespace):
"""
Character-level n-grams from within the words in a string.
By default, the word boundary is assumed to be whitespace. n-grams are
not taken across word boundaries, only within words.
If a word's length is less than or equ... | [
"def",
"char_ngrams",
"(",
"s",
",",
"n",
"=",
"3",
",",
"token_fn",
"=",
"tokens",
".",
"on_whitespace",
")",
":",
"tokens",
"=",
"token_fn",
"(",
"s",
")",
"ngram_tuples",
"=",
"[",
"__ngrams",
"(",
"t",
",",
"n",
"=",
"min",
"(",
"len",
"(",
"... | Character-level n-grams from within the words in a string.
By default, the word boundary is assumed to be whitespace. n-grams are
not taken across word boundaries, only within words.
If a word's length is less than or equal to n, the n-grams are simply a
list with the word itself.
... | [
"Character",
"-",
"level",
"n",
"-",
"grams",
"from",
"within",
"the",
"words",
"in",
"a",
"string",
"."
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L53-L83 | train | Returns a list of n - grams from within the words in a string. |
SignalN/language | language/ngrams.py | __matches | def __matches(s1, s2, ngrams_fn, n=3):
"""
Returns the n-grams that match between two sequences
See also: SequenceMatcher.get_matching_blocks
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set:
"""
... | python | def __matches(s1, s2, ngrams_fn, n=3):
"""
Returns the n-grams that match between two sequences
See also: SequenceMatcher.get_matching_blocks
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set:
"""
... | [
"def",
"__matches",
"(",
"s1",
",",
"s2",
",",
"ngrams_fn",
",",
"n",
"=",
"3",
")",
":",
"ngrams1",
",",
"ngrams2",
"=",
"set",
"(",
"ngrams_fn",
"(",
"s1",
",",
"n",
"=",
"n",
")",
")",
",",
"set",
"(",
"ngrams_fn",
"(",
"s2",
",",
"n",
"="... | Returns the n-grams that match between two sequences
See also: SequenceMatcher.get_matching_blocks
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: | [
"Returns",
"the",
"n",
"-",
"grams",
"that",
"match",
"between",
"two",
"sequences"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L86-L101 | train | Returns the n - grams that match between two sequences
s1 and s2. |
SignalN/language | language/ngrams.py | char_matches | def char_matches(s1, s2, n=3):
"""
Character-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings
"""
return __matches(s1, s2,... | python | def char_matches(s1, s2, n=3):
"""
Character-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings
"""
return __matches(s1, s2,... | [
"def",
"char_matches",
"(",
"s1",
",",
"s2",
",",
"n",
"=",
"3",
")",
":",
"return",
"__matches",
"(",
"s1",
",",
"s2",
",",
"char_ngrams",
",",
"n",
"=",
"n",
")"
] | Character-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings | [
"Character",
"-",
"level",
"n",
"-",
"grams",
"that",
"match",
"between",
"two",
"strings"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L103-L115 | train | Returns the n - grams that match between two strings |
SignalN/language | language/ngrams.py | word_matches | def word_matches(s1, s2, n=3):
"""
Word-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings
"""
return __matches(s1, s2, word... | python | def word_matches(s1, s2, n=3):
"""
Word-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings
"""
return __matches(s1, s2, word... | [
"def",
"word_matches",
"(",
"s1",
",",
"s2",
",",
"n",
"=",
"3",
")",
":",
"return",
"__matches",
"(",
"s1",
",",
"s2",
",",
"word_ngrams",
",",
"n",
"=",
"n",
")"
] | Word-level n-grams that match between two strings
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
set: the n-grams found in both strings | [
"Word",
"-",
"level",
"n",
"-",
"grams",
"that",
"match",
"between",
"two",
"strings"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L117-L129 | train | Word - level n - grams that match between two strings
s1 and s2 are the n - grams that match between two strings
s2. |
SignalN/language | language/ngrams.py | __similarity | def __similarity(s1, s2, ngrams_fn, n=3):
"""
The fraction of n-grams matching between two sequences
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
float: the fraction of n-grams matching
"""
ngrams1, ngr... | python | def __similarity(s1, s2, ngrams_fn, n=3):
"""
The fraction of n-grams matching between two sequences
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
float: the fraction of n-grams matching
"""
ngrams1, ngr... | [
"def",
"__similarity",
"(",
"s1",
",",
"s2",
",",
"ngrams_fn",
",",
"n",
"=",
"3",
")",
":",
"ngrams1",
",",
"ngrams2",
"=",
"set",
"(",
"ngrams_fn",
"(",
"s1",
",",
"n",
"=",
"n",
")",
")",
",",
"set",
"(",
"ngrams_fn",
"(",
"s2",
",",
"n",
... | The fraction of n-grams matching between two sequences
Args:
s1: a string
s2: another string
n: an int for the n in n-gram
Returns:
float: the fraction of n-grams matching | [
"The",
"fraction",
"of",
"n",
"-",
"grams",
"matching",
"between",
"two",
"sequences"
] | 5c50c78f65bcc2c999b44d530e7412185248352d | https://github.com/SignalN/language/blob/5c50c78f65bcc2c999b44d530e7412185248352d/language/ngrams.py#L131-L145 | train | Calculates the fraction of n - grams matching between two sequences
|
markfinger/assembla | assembla/api.py | API._get_json | def _get_json(self, model, space=None, rel_path=None, extra_params=None, get_all=None):
"""
Base level method for fetching data from the API
"""
# Only API.spaces and API.event should not provide
# the `space argument
if space is None and model not in (Space, Event):
... | python | def _get_json(self, model, space=None, rel_path=None, extra_params=None, get_all=None):
"""
Base level method for fetching data from the API
"""
# Only API.spaces and API.event should not provide
# the `space argument
if space is None and model not in (Space, Event):
... | [
"def",
"_get_json",
"(",
"self",
",",
"model",
",",
"space",
"=",
"None",
",",
"rel_path",
"=",
"None",
",",
"extra_params",
"=",
"None",
",",
"get_all",
"=",
"None",
")",
":",
"# Only API.spaces and API.event should not provide",
"# the `space argument",
"if",
... | Base level method for fetching data from the API | [
"Base",
"level",
"method",
"for",
"fetching",
"data",
"from",
"the",
"API"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L42-L112 | train | Internal method for fetching the JSON data from the API. |
markfinger/assembla | assembla/api.py | API._post_json | def _post_json(self, instance, space=None, rel_path=None, extra_params=None):
"""
Base level method for updating data via the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
if space is None and model not i... | python | def _post_json(self, instance, space=None, rel_path=None, extra_params=None):
"""
Base level method for updating data via the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
if space is None and model not i... | [
"def",
"_post_json",
"(",
"self",
",",
"instance",
",",
"space",
"=",
"None",
",",
"rel_path",
"=",
"None",
",",
"extra_params",
"=",
"None",
")",
":",
"model",
"=",
"type",
"(",
"instance",
")",
"# Only API.spaces and API.event should not provide",
"# the `spac... | Base level method for updating data via the API | [
"Base",
"level",
"method",
"for",
"updating",
"data",
"via",
"the",
"API"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L114-L169 | train | Base level method for updating data via the API. |
markfinger/assembla | assembla/api.py | API._put_json | def _put_json(self, instance, space=None, rel_path=None, extra_params=None, id_field=None):
"""
Base level method for adding new data to the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
if space is None ... | python | def _put_json(self, instance, space=None, rel_path=None, extra_params=None, id_field=None):
"""
Base level method for adding new data to the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
if space is None ... | [
"def",
"_put_json",
"(",
"self",
",",
"instance",
",",
"space",
"=",
"None",
",",
"rel_path",
"=",
"None",
",",
"extra_params",
"=",
"None",
",",
"id_field",
"=",
"None",
")",
":",
"model",
"=",
"type",
"(",
"instance",
")",
"# Only API.spaces and API.even... | Base level method for adding new data to the API | [
"Base",
"level",
"method",
"for",
"adding",
"new",
"data",
"to",
"the",
"API"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L171-L221 | train | Base level method for adding new data to the API. |
markfinger/assembla | assembla/api.py | API._delete_json | def _delete_json(self, instance, space=None, rel_path=None, extra_params=None, id_field=None, append_to_path=None):
"""
Base level method for removing data from the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
... | python | def _delete_json(self, instance, space=None, rel_path=None, extra_params=None, id_field=None, append_to_path=None):
"""
Base level method for removing data from the API
"""
model = type(instance)
# Only API.spaces and API.event should not provide
# the `space argument
... | [
"def",
"_delete_json",
"(",
"self",
",",
"instance",
",",
"space",
"=",
"None",
",",
"rel_path",
"=",
"None",
",",
"extra_params",
"=",
"None",
",",
"id_field",
"=",
"None",
",",
"append_to_path",
"=",
"None",
")",
":",
"model",
"=",
"type",
"(",
"inst... | Base level method for removing data from the API | [
"Base",
"level",
"method",
"for",
"removing",
"data",
"from",
"the",
"API"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L223-L281 | train | This method deletes the data from the API. |
markfinger/assembla | assembla/api.py | API._bind_variables | def _bind_variables(self, instance, space):
"""
Bind related variables to the instance
"""
instance.api = self
if space:
instance.space = space
return instance | python | def _bind_variables(self, instance, space):
"""
Bind related variables to the instance
"""
instance.api = self
if space:
instance.space = space
return instance | [
"def",
"_bind_variables",
"(",
"self",
",",
"instance",
",",
"space",
")",
":",
"instance",
".",
"api",
"=",
"self",
"if",
"space",
":",
"instance",
".",
"space",
"=",
"space",
"return",
"instance"
] | Bind related variables to the instance | [
"Bind",
"related",
"variables",
"to",
"the",
"instance"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L283-L290 | train | Bind related variables to the instance |
markfinger/assembla | assembla/api.py | Space.tickets | def tickets(self, extra_params=None):
"""
All Tickets in this Space
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
'report': 0, # Report 0 is all tickets
}
if extra_params:
params.update(extra_params)
... | python | def tickets(self, extra_params=None):
"""
All Tickets in this Space
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
'report': 0, # Report 0 is all tickets
}
if extra_params:
params.update(extra_params)
... | [
"def",
"tickets",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"# Default params",
"params",
"=",
"{",
"'per_page'",
":",
"settings",
".",
"MAX_PER_PAGE",
",",
"'report'",
":",
"0",
",",
"# Report 0 is all tickets",
"}",
"if",
"extra_params",
":",
... | All Tickets in this Space | [
"All",
"Tickets",
"in",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L301-L321 | train | Retrieve all Tickets in this Space |
markfinger/assembla | assembla/api.py | Space.milestones | def milestones(self, extra_params=None):
"""
All Milestones in this Space
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_... | python | def milestones(self, extra_params=None):
"""
All Milestones in this Space
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_... | [
"def",
"milestones",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"# Default params",
"params",
"=",
"{",
"'per_page'",
":",
"settings",
".",
"MAX_PER_PAGE",
",",
"}",
"if",
"extra_params",
":",
"params",
".",
"update",
"(",
"extra_params",
")",
... | All Milestones in this Space | [
"All",
"Milestones",
"in",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L324-L343 | train | Retrieve all milestones in this Space |
markfinger/assembla | assembla/api.py | Space.tools | def tools(self, extra_params=None):
""""
All Tools in this Space
"""
return self.api._get_json(
SpaceTool,
space=self,
rel_path=self._build_rel_path('space_tools'),
extra_params=extra_params,
) | python | def tools(self, extra_params=None):
""""
All Tools in this Space
"""
return self.api._get_json(
SpaceTool,
space=self,
rel_path=self._build_rel_path('space_tools'),
extra_params=extra_params,
) | [
"def",
"tools",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"self",
".",
"api",
".",
"_get_json",
"(",
"SpaceTool",
",",
"space",
"=",
"self",
",",
"rel_path",
"=",
"self",
".",
"_build_rel_path",
"(",
"'space_tools'",
")",
",",
... | All Tools in this Space | [
"All",
"Tools",
"in",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L346-L355 | train | All Tools in this Space |
markfinger/assembla | assembla/api.py | Space.components | def components(self, extra_params=None):
""""
All components in this Space
"""
return self.api._get_json(
Component,
space=self,
rel_path=self._build_rel_path('ticket_components'),
extra_params=extra_params,
) | python | def components(self, extra_params=None):
""""
All components in this Space
"""
return self.api._get_json(
Component,
space=self,
rel_path=self._build_rel_path('ticket_components'),
extra_params=extra_params,
) | [
"def",
"components",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"self",
".",
"api",
".",
"_get_json",
"(",
"Component",
",",
"space",
"=",
"self",
",",
"rel_path",
"=",
"self",
".",
"_build_rel_path",
"(",
"'ticket_components'",
")"... | All components in this Space | [
"All",
"components",
"in",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L358-L367 | train | Get all components in this Space |
markfinger/assembla | assembla/api.py | Space.users | def users(self, extra_params=None):
"""
All Users with access to this Space
"""
return self.api._get_json(
User,
space=self,
rel_path=self._build_rel_path('users'),
extra_params=extra_params,
) | python | def users(self, extra_params=None):
"""
All Users with access to this Space
"""
return self.api._get_json(
User,
space=self,
rel_path=self._build_rel_path('users'),
extra_params=extra_params,
) | [
"def",
"users",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"self",
".",
"api",
".",
"_get_json",
"(",
"User",
",",
"space",
"=",
"self",
",",
"rel_path",
"=",
"self",
".",
"_build_rel_path",
"(",
"'users'",
")",
",",
"extra_para... | All Users with access to this Space | [
"All",
"Users",
"with",
"access",
"to",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L370-L379 | train | Get all Users with access to this Space. |
markfinger/assembla | assembla/api.py | Space.tags | def tags(self, extra_params=None):
""""
All Tags in this Space
"""
return self.api._get_json(
Tag,
space=self,
rel_path=self._build_rel_path('tags'),
extra_params=extra_params,
) | python | def tags(self, extra_params=None):
""""
All Tags in this Space
"""
return self.api._get_json(
Tag,
space=self,
rel_path=self._build_rel_path('tags'),
extra_params=extra_params,
) | [
"def",
"tags",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"self",
".",
"api",
".",
"_get_json",
"(",
"Tag",
",",
"space",
"=",
"self",
",",
"rel_path",
"=",
"self",
".",
"_build_rel_path",
"(",
"'tags'",
")",
",",
"extra_params"... | All Tags in this Space | [
"All",
"Tags",
"in",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L382-L391 | train | All Tags in this Space |
markfinger/assembla | assembla/api.py | Space.wiki_pages | def wiki_pages(self, extra_params=None):
"""
All Wiki Pages with access to this Space
"""
return self.api._get_json(
WikiPage,
space=self,
rel_path=self._build_rel_path('wiki_pages'),
extra_params=extra_params,
) | python | def wiki_pages(self, extra_params=None):
"""
All Wiki Pages with access to this Space
"""
return self.api._get_json(
WikiPage,
space=self,
rel_path=self._build_rel_path('wiki_pages'),
extra_params=extra_params,
) | [
"def",
"wiki_pages",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"self",
".",
"api",
".",
"_get_json",
"(",
"WikiPage",
",",
"space",
"=",
"self",
",",
"rel_path",
"=",
"self",
".",
"_build_rel_path",
"(",
"'wiki_pages'",
")",
",",... | All Wiki Pages with access to this Space | [
"All",
"Wiki",
"Pages",
"with",
"access",
"to",
"this",
"Space"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L394-L403 | train | Get all Wiki Pages with access to this Space. |
markfinger/assembla | assembla/api.py | Milestone.tickets | def tickets(self, extra_params=None):
"""
All Tickets which are a part of this Milestone
"""
return filter(
lambda ticket: ticket.get('milestone_id', None) == self['id'],
self.space.tickets(extra_params=extra_params)
) | python | def tickets(self, extra_params=None):
"""
All Tickets which are a part of this Milestone
"""
return filter(
lambda ticket: ticket.get('milestone_id', None) == self['id'],
self.space.tickets(extra_params=extra_params)
) | [
"def",
"tickets",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"return",
"filter",
"(",
"lambda",
"ticket",
":",
"ticket",
".",
"get",
"(",
"'milestone_id'",
",",
"None",
")",
"==",
"self",
"[",
"'id'",
"]",
",",
"self",
".",
"space",
"."... | All Tickets which are a part of this Milestone | [
"All",
"Tickets",
"which",
"are",
"a",
"part",
"of",
"this",
"Milestone"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L426-L433 | train | Returns a list of Tickets which are part of this Milestone. |
markfinger/assembla | assembla/api.py | Ticket.tags | def tags(self, extra_params=None):
"""
All Tags in this Ticket
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_json(
Tag,
... | python | def tags(self, extra_params=None):
"""
All Tags in this Ticket
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_json(
Tag,
... | [
"def",
"tags",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"# Default params",
"params",
"=",
"{",
"'per_page'",
":",
"settings",
".",
"MAX_PER_PAGE",
",",
"}",
"if",
"extra_params",
":",
"params",
".",
"update",
"(",
"extra_params",
")",
"ret... | All Tags in this Ticket | [
"All",
"Tags",
"in",
"this",
"Ticket"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L438-L459 | train | Retrieve all Tags in this Ticket |
markfinger/assembla | assembla/api.py | Ticket.milestone | def milestone(self, extra_params=None):
"""
The Milestone that the Ticket is a part of
"""
if self.get('milestone_id', None):
milestones = self.space.milestones(id=self['milestone_id'], extra_params=extra_params)
if milestones:
return milestones[0] | python | def milestone(self, extra_params=None):
"""
The Milestone that the Ticket is a part of
"""
if self.get('milestone_id', None):
milestones = self.space.milestones(id=self['milestone_id'], extra_params=extra_params)
if milestones:
return milestones[0] | [
"def",
"milestone",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"if",
"self",
".",
"get",
"(",
"'milestone_id'",
",",
"None",
")",
":",
"milestones",
"=",
"self",
".",
"space",
".",
"milestones",
"(",
"id",
"=",
"self",
"[",
"'milestone_id... | The Milestone that the Ticket is a part of | [
"The",
"Milestone",
"that",
"the",
"Ticket",
"is",
"a",
"part",
"of"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L462-L469 | train | Returns the Milestone that the Ticket is part of. |
markfinger/assembla | assembla/api.py | Ticket.user | def user(self, extra_params=None):
"""
The User currently assigned to the Ticket
"""
if self.get('assigned_to_id', None):
users = self.space.users(
id=self['assigned_to_id'],
extra_params=extra_params
)
if users:
... | python | def user(self, extra_params=None):
"""
The User currently assigned to the Ticket
"""
if self.get('assigned_to_id', None):
users = self.space.users(
id=self['assigned_to_id'],
extra_params=extra_params
)
if users:
... | [
"def",
"user",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"if",
"self",
".",
"get",
"(",
"'assigned_to_id'",
",",
"None",
")",
":",
"users",
"=",
"self",
".",
"space",
".",
"users",
"(",
"id",
"=",
"self",
"[",
"'assigned_to_id'",
"]",
... | The User currently assigned to the Ticket | [
"The",
"User",
"currently",
"assigned",
"to",
"the",
"Ticket"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L471-L481 | train | Returns the User currently assigned to the Ticket. |
markfinger/assembla | assembla/api.py | Ticket.component | def component(self, extra_params=None):
"""
The Component currently assigned to the Ticket
"""
if self.get('component_id', None):
components = self.space.components(id=self['component_id'], extra_params=extra_params)
if components:
return component... | python | def component(self, extra_params=None):
"""
The Component currently assigned to the Ticket
"""
if self.get('component_id', None):
components = self.space.components(id=self['component_id'], extra_params=extra_params)
if components:
return component... | [
"def",
"component",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"if",
"self",
".",
"get",
"(",
"'component_id'",
",",
"None",
")",
":",
"components",
"=",
"self",
".",
"space",
".",
"components",
"(",
"id",
"=",
"self",
"[",
"'component_id... | The Component currently assigned to the Ticket | [
"The",
"Component",
"currently",
"assigned",
"to",
"the",
"Ticket"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L483-L490 | train | Returns the Component currently assigned to the Ticket. |
markfinger/assembla | assembla/api.py | Ticket.comments | def comments(self, extra_params=None):
"""
All Comments in this Ticket
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_json(
Ticke... | python | def comments(self, extra_params=None):
"""
All Comments in this Ticket
"""
# Default params
params = {
'per_page': settings.MAX_PER_PAGE,
}
if extra_params:
params.update(extra_params)
return self.api._get_json(
Ticke... | [
"def",
"comments",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"# Default params",
"params",
"=",
"{",
"'per_page'",
":",
"settings",
".",
"MAX_PER_PAGE",
",",
"}",
"if",
"extra_params",
":",
"params",
".",
"update",
"(",
"extra_params",
")",
... | All Comments in this Ticket | [
"All",
"Comments",
"in",
"this",
"Ticket"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L493-L514 | train | Retrieve all Comments in this Ticket. |
markfinger/assembla | assembla/api.py | Ticket.write | def write(self):
"""
Create or update the Ticket on Assembla
"""
if not hasattr(self, 'space'):
raise AttributeError("A ticket must have a 'space' attribute before you can write it to Assembla.")
if self.get('number'): # Modifying an existing ticket
meth... | python | def write(self):
"""
Create or update the Ticket on Assembla
"""
if not hasattr(self, 'space'):
raise AttributeError("A ticket must have a 'space' attribute before you can write it to Assembla.")
if self.get('number'): # Modifying an existing ticket
meth... | [
"def",
"write",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'space'",
")",
":",
"raise",
"AttributeError",
"(",
"\"A ticket must have a 'space' attribute before you can write it to Assembla.\"",
")",
"if",
"self",
".",
"get",
"(",
"'number'",
... | Create or update the Ticket on Assembla | [
"Create",
"or",
"update",
"the",
"Ticket",
"on",
"Assembla"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L517-L533 | train | Write the Ticket to Assembla. |
markfinger/assembla | assembla/api.py | Ticket.delete | def delete(self):
"""
Remove the Ticket from Assembla
"""
if not hasattr(self, 'space'):
raise AttributeError("A ticket must have a 'space' attribute before you can remove it from Assembla.")
return self.space.api._delete_json(
self,
space=sel... | python | def delete(self):
"""
Remove the Ticket from Assembla
"""
if not hasattr(self, 'space'):
raise AttributeError("A ticket must have a 'space' attribute before you can remove it from Assembla.")
return self.space.api._delete_json(
self,
space=sel... | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'space'",
")",
":",
"raise",
"AttributeError",
"(",
"\"A ticket must have a 'space' attribute before you can remove it from Assembla.\"",
")",
"return",
"self",
".",
"space",
".",
"ap... | Remove the Ticket from Assembla | [
"Remove",
"the",
"Ticket",
"from",
"Assembla"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L535-L546 | train | Remove the Ticket from Assembla. |
markfinger/assembla | assembla/api.py | User.tickets | def tickets(self, extra_params=None):
"""
A User's tickets across all available spaces
"""
tickets = []
for space in self.api.spaces():
tickets += filter(
lambda ticket: ticket.get('assigned_to_id', None) == self['id'],
space.tickets(ex... | python | def tickets(self, extra_params=None):
"""
A User's tickets across all available spaces
"""
tickets = []
for space in self.api.spaces():
tickets += filter(
lambda ticket: ticket.get('assigned_to_id', None) == self['id'],
space.tickets(ex... | [
"def",
"tickets",
"(",
"self",
",",
"extra_params",
"=",
"None",
")",
":",
"tickets",
"=",
"[",
"]",
"for",
"space",
"in",
"self",
".",
"api",
".",
"spaces",
"(",
")",
":",
"tickets",
"+=",
"filter",
"(",
"lambda",
"ticket",
":",
"ticket",
".",
"ge... | A User's tickets across all available spaces | [
"A",
"User",
"s",
"tickets",
"across",
"all",
"available",
"spaces"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L559-L569 | train | A User s tickets across all available spaces. |
markfinger/assembla | assembla/api.py | WikiPage.write | def write(self):
"""
Create or update a Wiki Page on Assembla
"""
if not hasattr(self, 'space'):
raise AttributeError("A WikiPage must have a 'space' attribute before you can write it to Assembla.")
self.api = self.space.api
if self.get('id'): # We are modi... | python | def write(self):
"""
Create or update a Wiki Page on Assembla
"""
if not hasattr(self, 'space'):
raise AttributeError("A WikiPage must have a 'space' attribute before you can write it to Assembla.")
self.api = self.space.api
if self.get('id'): # We are modi... | [
"def",
"write",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'space'",
")",
":",
"raise",
"AttributeError",
"(",
"\"A WikiPage must have a 'space' attribute before you can write it to Assembla.\"",
")",
"self",
".",
"api",
"=",
"self",
".",
"s... | Create or update a Wiki Page on Assembla | [
"Create",
"or",
"update",
"a",
"Wiki",
"Page",
"on",
"Assembla"
] | 967a77a5ba718df94f60e832b6e0cf14c72426aa | https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L573-L594 | train | Creates or updates a Wiki Page on Assembla. |
Genida/dependenpy | src/dependenpy/finder.py | PackageSpec.add | def add(self, spec):
"""
Add limitations of given spec to self's.
Args:
spec (PackageSpec): another spec.
"""
for limit in spec.limit_to:
if limit not in self.limit_to:
self.limit_to.append(limit) | python | def add(self, spec):
"""
Add limitations of given spec to self's.
Args:
spec (PackageSpec): another spec.
"""
for limit in spec.limit_to:
if limit not in self.limit_to:
self.limit_to.append(limit) | [
"def",
"add",
"(",
"self",
",",
"spec",
")",
":",
"for",
"limit",
"in",
"spec",
".",
"limit_to",
":",
"if",
"limit",
"not",
"in",
"self",
".",
"limit_to",
":",
"self",
".",
"limit_to",
".",
"append",
"(",
"limit",
")"
] | Add limitations of given spec to self's.
Args:
spec (PackageSpec): another spec. | [
"Add",
"limitations",
"of",
"given",
"spec",
"to",
"self",
"s",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/finder.py#L33-L42 | train | Add limitations of given spec to self. limit_to. |
Genida/dependenpy | src/dependenpy/finder.py | PackageSpec.combine | def combine(specs):
"""
Combine package specifications' limitations.
Args:
specs (list of PackageSpec): the package specifications.
Returns:
list of PackageSpec: the new, merged list of PackageSpec.
"""
new_specs = {}
for spec in specs:
... | python | def combine(specs):
"""
Combine package specifications' limitations.
Args:
specs (list of PackageSpec): the package specifications.
Returns:
list of PackageSpec: the new, merged list of PackageSpec.
"""
new_specs = {}
for spec in specs:
... | [
"def",
"combine",
"(",
"specs",
")",
":",
"new_specs",
"=",
"{",
"}",
"for",
"spec",
"in",
"specs",
":",
"if",
"new_specs",
".",
"get",
"(",
"spec",
",",
"None",
")",
"is",
"None",
":",
"new_specs",
"[",
"spec",
"]",
"=",
"spec",
"else",
":",
"ne... | Combine package specifications' limitations.
Args:
specs (list of PackageSpec): the package specifications.
Returns:
list of PackageSpec: the new, merged list of PackageSpec. | [
"Combine",
"package",
"specifications",
"limitations",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/finder.py#L45-L61 | train | Combine package specifications with limitations. |
Genida/dependenpy | src/dependenpy/finder.py | LocalPackageFinder.find | def find(self, package, **kwargs):
"""
Find method.
Args:
package (str): package to find.
**kwargs (): additional keyword arguments.
Returns:
PackageSpec: the PackageSpec corresponding to the package, or None.
"""
if not exists(packag... | python | def find(self, package, **kwargs):
"""
Find method.
Args:
package (str): package to find.
**kwargs (): additional keyword arguments.
Returns:
PackageSpec: the PackageSpec corresponding to the package, or None.
"""
if not exists(packag... | [
"def",
"find",
"(",
"self",
",",
"package",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"exists",
"(",
"package",
")",
":",
"return",
"None",
"name",
",",
"path",
"=",
"None",
",",
"None",
"enforce_init",
"=",
"kwargs",
".",
"pop",
"(",
"'enfor... | Find method.
Args:
package (str): package to find.
**kwargs (): additional keyword arguments.
Returns:
PackageSpec: the PackageSpec corresponding to the package, or None. | [
"Find",
"method",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/finder.py#L84-L106 | train | Find method. Returns the packageSpec corresponding to the package. |
Genida/dependenpy | src/dependenpy/finder.py | InstalledPackageFinder.find | def find(self, package, **kwargs):
"""
Find method.
Args:
package (str): package to find.
**kwargs (): additional keyword arguments.
Returns:
PackageSpec: the PackageSpec corresponding to the package, or None.
"""
spec = find_spec(pac... | python | def find(self, package, **kwargs):
"""
Find method.
Args:
package (str): package to find.
**kwargs (): additional keyword arguments.
Returns:
PackageSpec: the PackageSpec corresponding to the package, or None.
"""
spec = find_spec(pac... | [
"def",
"find",
"(",
"self",
",",
"package",
",",
"*",
"*",
"kwargs",
")",
":",
"spec",
"=",
"find_spec",
"(",
"package",
")",
"if",
"spec",
"is",
"None",
":",
"return",
"None",
"limit",
"=",
"[",
"]",
"if",
"'.'",
"in",
"package",
":",
"package",
... | Find method.
Args:
package (str): package to find.
**kwargs (): additional keyword arguments.
Returns:
PackageSpec: the PackageSpec corresponding to the package, or None. | [
"Find",
"method",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/finder.py#L112-L139 | train | Find method. Returns the corresponding PackageSpec object or None if no such PackageSpec is found. |
Genida/dependenpy | src/dependenpy/finder.py | Finder.find | def find(self, package, **kwargs):
"""
Find a package using package finders.
Return the first package found.
Args:
package (str): package to find.
**kwargs (): additional keyword arguments used by finders.
Returns:
PackageSpec: if package fo... | python | def find(self, package, **kwargs):
"""
Find a package using package finders.
Return the first package found.
Args:
package (str): package to find.
**kwargs (): additional keyword arguments used by finders.
Returns:
PackageSpec: if package fo... | [
"def",
"find",
"(",
"self",
",",
"package",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"finder",
"in",
"self",
".",
"finders",
":",
"package_spec",
"=",
"finder",
".",
"find",
"(",
"package",
",",
"*",
"*",
"kwargs",
")",
"if",
"package_spec",
":",
... | Find a package using package finders.
Return the first package found.
Args:
package (str): package to find.
**kwargs (): additional keyword arguments used by finders.
Returns:
PackageSpec: if package found, else None | [
"Find",
"a",
"package",
"using",
"package",
"finders",
"."
] | df099c17cbe735c990eca9197e39cfc5eb8a4c8e | https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/finder.py#L163-L180 | train | Find a package using package finders. |
noahbenson/pimms | pimms/util.py | is_unit | def is_unit(q):
'''
is_unit(q) yields True if q is a pint unit or a string that names a pint unit and False
otherwise.
'''
if isinstance(q, six.string_types):
try: return hasattr(units, q)
except: return False
else:
cls = type(q)
return cls.__module__.startswith... | python | def is_unit(q):
'''
is_unit(q) yields True if q is a pint unit or a string that names a pint unit and False
otherwise.
'''
if isinstance(q, six.string_types):
try: return hasattr(units, q)
except: return False
else:
cls = type(q)
return cls.__module__.startswith... | [
"def",
"is_unit",
"(",
"q",
")",
":",
"if",
"isinstance",
"(",
"q",
",",
"six",
".",
"string_types",
")",
":",
"try",
":",
"return",
"hasattr",
"(",
"units",
",",
"q",
")",
"except",
":",
"return",
"False",
"else",
":",
"cls",
"=",
"type",
"(",
"... | is_unit(q) yields True if q is a pint unit or a string that names a pint unit and False
otherwise. | [
"is_unit",
"(",
"q",
")",
"yields",
"True",
"if",
"q",
"is",
"a",
"pint",
"unit",
"or",
"a",
"string",
"that",
"names",
"a",
"pint",
"unit",
"and",
"False",
"otherwise",
"."
] | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L42-L52 | train | is_unit yields True if q is a pint unit or a string that names a pint unit and False otherwise. |
noahbenson/pimms | pimms/util.py | is_quantity | def is_quantity(q):
'''
is_quantity(q) yields True if q is a pint quantity or a tuple (scalar, unit) and False
otherwise.
'''
if isinstance(q, tuple):
return len(q) == 2 and is_unit(q[1])
else:
cls = type(q)
return cls.__module__.startswith('pint.') and cls.__name__ == ... | python | def is_quantity(q):
'''
is_quantity(q) yields True if q is a pint quantity or a tuple (scalar, unit) and False
otherwise.
'''
if isinstance(q, tuple):
return len(q) == 2 and is_unit(q[1])
else:
cls = type(q)
return cls.__module__.startswith('pint.') and cls.__name__ == ... | [
"def",
"is_quantity",
"(",
"q",
")",
":",
"if",
"isinstance",
"(",
"q",
",",
"tuple",
")",
":",
"return",
"len",
"(",
"q",
")",
"==",
"2",
"and",
"is_unit",
"(",
"q",
"[",
"1",
"]",
")",
"else",
":",
"cls",
"=",
"type",
"(",
"q",
")",
"return... | is_quantity(q) yields True if q is a pint quantity or a tuple (scalar, unit) and False
otherwise. | [
"is_quantity",
"(",
"q",
")",
"yields",
"True",
"if",
"q",
"is",
"a",
"pint",
"quantity",
"or",
"a",
"tuple",
"(",
"scalar",
"unit",
")",
"and",
"False",
"otherwise",
"."
] | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L53-L62 | train | Returns True if q is a pint quantity or a tuple and False
otherwise. |
noahbenson/pimms | pimms/util.py | unit | def unit(u):
'''
unit(u) yields the pimms-library unit object for the given unit object u (which may be from a
separate pint.UnitRegistry instance).
unit(uname) yields the unit object for the given unit name uname.
unit(None) yields None.
unit(q) yields the unit of the given quantity q.
''... | python | def unit(u):
'''
unit(u) yields the pimms-library unit object for the given unit object u (which may be from a
separate pint.UnitRegistry instance).
unit(uname) yields the unit object for the given unit name uname.
unit(None) yields None.
unit(q) yields the unit of the given quantity q.
''... | [
"def",
"unit",
"(",
"u",
")",
":",
"if",
"u",
"is",
"None",
":",
"return",
"None",
"elif",
"is_unit",
"(",
"u",
")",
":",
"return",
"getattr",
"(",
"units",
",",
"str",
"(",
"u",
")",
")",
"elif",
"is_quantity",
"(",
"u",
")",
":",
"if",
"isins... | unit(u) yields the pimms-library unit object for the given unit object u (which may be from a
separate pint.UnitRegistry instance).
unit(uname) yields the unit object for the given unit name uname.
unit(None) yields None.
unit(q) yields the unit of the given quantity q. | [
"unit",
"(",
"u",
")",
"yields",
"the",
"pimms",
"-",
"library",
"unit",
"object",
"for",
"the",
"given",
"unit",
"object",
"u",
"(",
"which",
"may",
"be",
"from",
"a",
"separate",
"pint",
".",
"UnitRegistry",
"instance",
")",
".",
"unit",
"(",
"uname"... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L63-L77 | train | Returns the pimms - library unit object for the given unit object u. |
noahbenson/pimms | pimms/util.py | mag | def mag(val, u=Ellipsis):
'''
mag(scalar) yields scalar for the given scalar (numeric value without a unit).
mag(quant) yields the scalar magnitude of the quantity quant.
mag(scalar, u=u) yields scalar.
mag(quant, u=u) yields the given magnitude of the given quant after being translated into the
... | python | def mag(val, u=Ellipsis):
'''
mag(scalar) yields scalar for the given scalar (numeric value without a unit).
mag(quant) yields the scalar magnitude of the quantity quant.
mag(scalar, u=u) yields scalar.
mag(quant, u=u) yields the given magnitude of the given quant after being translated into the
... | [
"def",
"mag",
"(",
"val",
",",
"u",
"=",
"Ellipsis",
")",
":",
"if",
"not",
"is_quantity",
"(",
"val",
")",
":",
"return",
"val",
"if",
"isinstance",
"(",
"val",
",",
"tuple",
")",
":",
"val",
"=",
"units",
".",
"Quantity",
"(",
"val",
"[",
"0",
... | mag(scalar) yields scalar for the given scalar (numeric value without a unit).
mag(quant) yields the scalar magnitude of the quantity quant.
mag(scalar, u=u) yields scalar.
mag(quant, u=u) yields the given magnitude of the given quant after being translated into the
given unit u.
The quant argume... | [
"mag",
"(",
"scalar",
")",
"yields",
"scalar",
"for",
"the",
"given",
"scalar",
"(",
"numeric",
"value",
"without",
"a",
"unit",
")",
".",
"mag",
"(",
"quant",
")",
"yields",
"the",
"scalar",
"magnitude",
"of",
"the",
"quantity",
"quant",
".",
"mag",
"... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L78-L92 | train | Returns the magnitude of the object in the order of the given value. |
noahbenson/pimms | pimms/util.py | imm_array | def imm_array(q):
'''
imm_array(val) yields a version of val that is wrapped in numpy's ndarray class. If val is a
read-only numpy array, then it is returned as-is; if it is not, then it is cast copied to a
numpy array, duplicated, the read-only flag is set on the new object, and then it is returned... | python | def imm_array(q):
'''
imm_array(val) yields a version of val that is wrapped in numpy's ndarray class. If val is a
read-only numpy array, then it is returned as-is; if it is not, then it is cast copied to a
numpy array, duplicated, the read-only flag is set on the new object, and then it is returned... | [
"def",
"imm_array",
"(",
"q",
")",
":",
"if",
"is_quantity",
"(",
"q",
")",
":",
"m",
"=",
"mag",
"(",
"q",
")",
"mm",
"=",
"imm_array",
"(",
"m",
")",
"return",
"q",
"if",
"mm",
"is",
"m",
"else",
"units",
".",
"Quantity",
"(",
"mm",
",",
"u... | imm_array(val) yields a version of val that is wrapped in numpy's ndarray class. If val is a
read-only numpy array, then it is returned as-is; if it is not, then it is cast copied to a
numpy array, duplicated, the read-only flag is set on the new object, and then it is returned. | [
"imm_array",
"(",
"val",
")",
"yields",
"a",
"version",
"of",
"val",
"that",
"is",
"wrapped",
"in",
"numpy",
"s",
"ndarray",
"class",
".",
"If",
"val",
"is",
"a",
"read",
"-",
"only",
"numpy",
"array",
"then",
"it",
"is",
"returned",
"as",
"-",
"is",... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L93-L106 | train | Returns a copy of the array q with the same magnitude as the input object q. |
noahbenson/pimms | pimms/util.py | quant | def quant(val, u=Ellipsis):
'''
quant(scalar) yields a dimensionless quantity with the magnitude given by scalar.
quant(q) yields q for any quantity q; if q is not part of the pimms units registry, then a
version of q registered to pimms.units is yielded. Note that q is a quantity if
pimms.is_qu... | python | def quant(val, u=Ellipsis):
'''
quant(scalar) yields a dimensionless quantity with the magnitude given by scalar.
quant(q) yields q for any quantity q; if q is not part of the pimms units registry, then a
version of q registered to pimms.units is yielded. Note that q is a quantity if
pimms.is_qu... | [
"def",
"quant",
"(",
"val",
",",
"u",
"=",
"Ellipsis",
")",
":",
"if",
"is_quantity",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"tuple",
")",
"or",
"val",
".",
"_REGISTRY",
"is",
"not",
"units",
":",
"val",
"=",
"units",
".",
"Qu... | quant(scalar) yields a dimensionless quantity with the magnitude given by scalar.
quant(q) yields q for any quantity q; if q is not part of the pimms units registry, then a
version of q registered to pimms.units is yielded. Note that q is a quantity if
pimms.is_quantity(q) is True.
quant(x, u) yield... | [
"quant",
"(",
"scalar",
")",
"yields",
"a",
"dimensionless",
"quantity",
"with",
"the",
"magnitude",
"given",
"by",
"scalar",
".",
"quant",
"(",
"q",
")",
"yields",
"q",
"for",
"any",
"quantity",
"q",
";",
"if",
"q",
"is",
"not",
"part",
"of",
"the",
... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L107-L122 | train | Returns a new avec of avec of avec of avec of avec of avec of avec of avec of avec of avec |
noahbenson/pimms | pimms/util.py | iquant | def iquant(val, u=Ellipsis):
'''
iquant(...) is equivalent to quant(...) except that the magnitude of the return value is always
a read-only numpy array object.
'''
if u is not Ellipsis and u is not None: u = unit(u)
if is_quantity(val):
uu = unit(val)
if u is Ellipsis or u == ... | python | def iquant(val, u=Ellipsis):
'''
iquant(...) is equivalent to quant(...) except that the magnitude of the return value is always
a read-only numpy array object.
'''
if u is not Ellipsis and u is not None: u = unit(u)
if is_quantity(val):
uu = unit(val)
if u is Ellipsis or u == ... | [
"def",
"iquant",
"(",
"val",
",",
"u",
"=",
"Ellipsis",
")",
":",
"if",
"u",
"is",
"not",
"Ellipsis",
"and",
"u",
"is",
"not",
"None",
":",
"u",
"=",
"unit",
"(",
"u",
")",
"if",
"is_quantity",
"(",
"val",
")",
":",
"uu",
"=",
"unit",
"(",
"v... | iquant(...) is equivalent to quant(...) except that the magnitude of the return value is always
a read-only numpy array object. | [
"iquant",
"(",
"...",
")",
"is",
"equivalent",
"to",
"quant",
"(",
"...",
")",
"except",
"that",
"the",
"magnitude",
"of",
"the",
"return",
"value",
"is",
"always",
"a",
"read",
"-",
"only",
"numpy",
"array",
"object",
"."
] | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L123-L145 | train | equivalent to quant(... ) except that the magnitude of the return value is always an array object. |
noahbenson/pimms | pimms/util.py | like_units | def like_units(a, b):
'''
like_units(a,b) yields True if a and b can be cast to each other in terms of units and False
otherwise. Non-united units are considered dimensionless units.
'''
a = quant(0.0, a) if is_unit(a) else a if is_quantity(a) else quant(a, units.dimensionless)
b = quant(0.0, ... | python | def like_units(a, b):
'''
like_units(a,b) yields True if a and b can be cast to each other in terms of units and False
otherwise. Non-united units are considered dimensionless units.
'''
a = quant(0.0, a) if is_unit(a) else a if is_quantity(a) else quant(a, units.dimensionless)
b = quant(0.0, ... | [
"def",
"like_units",
"(",
"a",
",",
"b",
")",
":",
"a",
"=",
"quant",
"(",
"0.0",
",",
"a",
")",
"if",
"is_unit",
"(",
"a",
")",
"else",
"a",
"if",
"is_quantity",
"(",
"a",
")",
"else",
"quant",
"(",
"a",
",",
"units",
".",
"dimensionless",
")"... | like_units(a,b) yields True if a and b can be cast to each other in terms of units and False
otherwise. Non-united units are considered dimensionless units. | [
"like_units",
"(",
"a",
"b",
")",
"yields",
"True",
"if",
"a",
"and",
"b",
"can",
"be",
"cast",
"to",
"each",
"other",
"in",
"terms",
"of",
"units",
"and",
"False",
"otherwise",
".",
"Non",
"-",
"united",
"units",
"are",
"considered",
"dimensionless",
... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L146-L158 | train | Returns True if a and b can be cast to each other in terms of units and False
otherwise. |
noahbenson/pimms | pimms/util.py | qhashform | def qhashform(o):
'''
qhashform(o) yields a version of o, if possible, that yields a hash that can be reproduced
across instances. This correctly handles quantities and numpy arrays, among other things.
'''
if is_quantity(o): return ('__#quant', qhashform(mag(o)), str(o.u))
elif isinstance(o, ... | python | def qhashform(o):
'''
qhashform(o) yields a version of o, if possible, that yields a hash that can be reproduced
across instances. This correctly handles quantities and numpy arrays, among other things.
'''
if is_quantity(o): return ('__#quant', qhashform(mag(o)), str(o.u))
elif isinstance(o, ... | [
"def",
"qhashform",
"(",
"o",
")",
":",
"if",
"is_quantity",
"(",
"o",
")",
":",
"return",
"(",
"'__#quant'",
",",
"qhashform",
"(",
"mag",
"(",
"o",
")",
")",
",",
"str",
"(",
"o",
".",
"u",
")",
")",
"elif",
"isinstance",
"(",
"o",
",",
"np",... | qhashform(o) yields a version of o, if possible, that yields a hash that can be reproduced
across instances. This correctly handles quantities and numpy arrays, among other things. | [
"qhashform",
"(",
"o",
")",
"yields",
"a",
"version",
"of",
"o",
"if",
"possible",
"that",
"yields",
"a",
"hash",
"that",
"can",
"be",
"reproduced",
"across",
"instances",
".",
"This",
"correctly",
"handles",
"quantities",
"and",
"numpy",
"arrays",
"among",
... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L159-L171 | train | Returns a version of o that yields a hash that can be reproduced
across instances. |
noahbenson/pimms | pimms/util.py | save | def save(filename, obj, overwrite=False, create_directories=False):
'''
pimms.save(filename, obj) attempts to pickle the given object obj in the filename (or stream,
if given). An error is raised when this cannot be accomplished; the first argument is always
returned; though if the argument is a fil... | python | def save(filename, obj, overwrite=False, create_directories=False):
'''
pimms.save(filename, obj) attempts to pickle the given object obj in the filename (or stream,
if given). An error is raised when this cannot be accomplished; the first argument is always
returned; though if the argument is a fil... | [
"def",
"save",
"(",
"filename",
",",
"obj",
",",
"overwrite",
"=",
"False",
",",
"create_directories",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"six",
".",
"string_types",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"exp... | pimms.save(filename, obj) attempts to pickle the given object obj in the filename (or stream,
if given). An error is raised when this cannot be accomplished; the first argument is always
returned; though if the argument is a filename, it may be a differet string that refers to
the same file.
The ... | [
"pimms",
".",
"save",
"(",
"filename",
"obj",
")",
"attempts",
"to",
"pickle",
"the",
"given",
"object",
"obj",
"in",
"the",
"filename",
"(",
"or",
"stream",
"if",
"given",
")",
".",
"An",
"error",
"is",
"raised",
"when",
"this",
"cannot",
"be",
"accom... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L219-L249 | train | Save the object obj to the file filename. |
noahbenson/pimms | pimms/util.py | load | def load(filename, ureg='pimms'):
'''
pimms.load(filename) loads a pimms-formatted save-file from the given filename, which may
optionaly be a string. By default, this function forces all quantities (via the pint
module) to be loaded using the pimms.units unit registry; the option ureg can change
... | python | def load(filename, ureg='pimms'):
'''
pimms.load(filename) loads a pimms-formatted save-file from the given filename, which may
optionaly be a string. By default, this function forces all quantities (via the pint
module) to be loaded using the pimms.units unit registry; the option ureg can change
... | [
"def",
"load",
"(",
"filename",
",",
"ureg",
"=",
"'pimms'",
")",
":",
"if",
"ureg",
"is",
"not",
"None",
":",
"if",
"ureg",
"==",
"'pimms'",
":",
"ureg",
"=",
"units",
"orig_app_ureg",
"=",
"pint",
".",
"_APP_REGISTRY",
"orig_dfl_ureg",
"=",
"pint",
"... | pimms.load(filename) loads a pimms-formatted save-file from the given filename, which may
optionaly be a string. By default, this function forces all quantities (via the pint
module) to be loaded using the pimms.units unit registry; the option ureg can change
this.
If the filename is not a correc... | [
"pimms",
".",
"load",
"(",
"filename",
")",
"loads",
"a",
"pimms",
"-",
"formatted",
"save",
"-",
"file",
"from",
"the",
"given",
"filename",
"which",
"may",
"optionaly",
"be",
"a",
"string",
".",
"By",
"default",
"this",
"function",
"forces",
"all",
"qu... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L250-L280 | train | loads a pimms - formatted save - file from the given filename |
noahbenson/pimms | pimms/util.py | is_str | def is_str(arg):
'''
is_str(x) yields True if x is a string object or a 0-dim numpy array of a string and yields
False otherwise.
'''
return (isinstance(arg, six.string_types) or
is_npscalar(arg, 'string') or
is_npvalue(arg, 'string')) | python | def is_str(arg):
'''
is_str(x) yields True if x is a string object or a 0-dim numpy array of a string and yields
False otherwise.
'''
return (isinstance(arg, six.string_types) or
is_npscalar(arg, 'string') or
is_npvalue(arg, 'string')) | [
"def",
"is_str",
"(",
"arg",
")",
":",
"return",
"(",
"isinstance",
"(",
"arg",
",",
"six",
".",
"string_types",
")",
"or",
"is_npscalar",
"(",
"arg",
",",
"'string'",
")",
"or",
"is_npvalue",
"(",
"arg",
",",
"'string'",
")",
")"
] | is_str(x) yields True if x is a string object or a 0-dim numpy array of a string and yields
False otherwise. | [
"is_str",
"(",
"x",
")",
"yields",
"True",
"if",
"x",
"is",
"a",
"string",
"object",
"or",
"a",
"0",
"-",
"dim",
"numpy",
"array",
"of",
"a",
"string",
"and",
"yields",
"False",
"otherwise",
"."
] | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L282-L289 | train | Returns True if the argument is a string. |
noahbenson/pimms | pimms/util.py | numpy_type | def numpy_type(type_id):
'''
numpy_type(type) yields a tuple of valid numpy types that can represent the type specified in
the given type argument. The type argument may be a numpy type such as numpy.signedinteger, in
which case a tuple containing only it is returned. Alternately, it may be a string... | python | def numpy_type(type_id):
'''
numpy_type(type) yields a tuple of valid numpy types that can represent the type specified in
the given type argument. The type argument may be a numpy type such as numpy.signedinteger, in
which case a tuple containing only it is returned. Alternately, it may be a string... | [
"def",
"numpy_type",
"(",
"type_id",
")",
":",
"if",
"is_str",
"(",
"type_id",
")",
":",
"return",
"_numpy_type_names",
"[",
"type_id",
".",
"lower",
"(",
")",
"]",
"elif",
"isinstance",
"(",
"type_id",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
... | numpy_type(type) yields a tuple of valid numpy types that can represent the type specified in
the given type argument. The type argument may be a numpy type such as numpy.signedinteger, in
which case a tuple containing only it is returned. Alternately, it may be a string that labels
a numpy type or a ... | [
"numpy_type",
"(",
"type",
")",
"yields",
"a",
"tuple",
"of",
"valid",
"numpy",
"types",
"that",
"can",
"represent",
"the",
"type",
"specified",
"in",
"the",
"given",
"type",
"argument",
".",
"The",
"type",
"argument",
"may",
"be",
"a",
"numpy",
"type",
... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L311-L361 | train | Returns a tuple of numpy types that can be represented by the given type argument. |
noahbenson/pimms | pimms/util.py | is_nparray | def is_nparray(u, dtype=None, dims=None):
'''
is_nparray(u) yields True if u is an instance of a numpy array and False otherwise.
is_nparray(u, dtype) yields True if is_nparray(u) and the dtype of u is a sub-dtype of the given
dtype.
is_nparray(u, dtype, dims) yields True if is_nparray(u, dtype) a... | python | def is_nparray(u, dtype=None, dims=None):
'''
is_nparray(u) yields True if u is an instance of a numpy array and False otherwise.
is_nparray(u, dtype) yields True if is_nparray(u) and the dtype of u is a sub-dtype of the given
dtype.
is_nparray(u, dtype, dims) yields True if is_nparray(u, dtype) a... | [
"def",
"is_nparray",
"(",
"u",
",",
"dtype",
"=",
"None",
",",
"dims",
"=",
"None",
")",
":",
"if",
"is_quantity",
"(",
"u",
")",
":",
"return",
"is_nparray",
"(",
"mag",
"(",
"u",
")",
",",
"dtype",
"=",
"dtype",
",",
"dims",
"=",
"dims",
")",
... | is_nparray(u) yields True if u is an instance of a numpy array and False otherwise.
is_nparray(u, dtype) yields True if is_nparray(u) and the dtype of u is a sub-dtype of the given
dtype.
is_nparray(u, dtype, dims) yields True if is_nparray(u, dtype) and the number of dimensions is
equal to dims (no... | [
"is_nparray",
"(",
"u",
")",
"yields",
"True",
"if",
"u",
"is",
"an",
"instance",
"of",
"a",
"numpy",
"array",
"and",
"False",
"otherwise",
".",
"is_nparray",
"(",
"u",
"dtype",
")",
"yields",
"True",
"if",
"is_nparray",
"(",
"u",
")",
"and",
"the",
... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L363-L386 | train | A function to check if a given object is a nparray. |
noahbenson/pimms | pimms/util.py | is_npvalue | def is_npvalue(u, dtype):
'''
is_npvalue(u, dtype) yields True if u is a member of the given dtype according to numpy. The
dtype may be specified as a string (see numpy_type) or a type. Note that dtype may be None,
'any', or np.generic, but this will always return True if so.
Note that is_npval... | python | def is_npvalue(u, dtype):
'''
is_npvalue(u, dtype) yields True if u is a member of the given dtype according to numpy. The
dtype may be specified as a string (see numpy_type) or a type. Note that dtype may be None,
'any', or np.generic, but this will always return True if so.
Note that is_npval... | [
"def",
"is_npvalue",
"(",
"u",
",",
"dtype",
")",
":",
"if",
"is_quantity",
"(",
"u",
")",
":",
"return",
"is_npvalue",
"(",
"mag",
"(",
"u",
")",
",",
"dtype",
"=",
"dtype",
")",
"return",
"any",
"(",
"np",
".",
"issubdtype",
"(",
"type",
"(",
"... | is_npvalue(u, dtype) yields True if u is a member of the given dtype according to numpy. The
dtype may be specified as a string (see numpy_type) or a type. Note that dtype may be None,
'any', or np.generic, but this will always return True if so.
Note that is_npvalue(1, 'int') will yield True, while is... | [
"is_npvalue",
"(",
"u",
"dtype",
")",
"yields",
"True",
"if",
"u",
"is",
"a",
"member",
"of",
"the",
"given",
"dtype",
"according",
"to",
"numpy",
".",
"The",
"dtype",
"may",
"be",
"specified",
"as",
"a",
"string",
"(",
"see",
"numpy_type",
")",
"or",
... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L414-L427 | train | Returns True if u is a member of the given dtype. |
noahbenson/pimms | pimms/util.py | is_array | def is_array(u, dtype=None, dims=None):
'''
is_array(u) is equivalent to is_nparray(np.asarray(u)), meaning is_array(u) will always yield
True.
is_array(u, dtype) yields True if np.asarray(u) is of the given dtype, which is looked up using
numpy_type. If dtype is None, then no dtype requirement ... | python | def is_array(u, dtype=None, dims=None):
'''
is_array(u) is equivalent to is_nparray(np.asarray(u)), meaning is_array(u) will always yield
True.
is_array(u, dtype) yields True if np.asarray(u) is of the given dtype, which is looked up using
numpy_type. If dtype is None, then no dtype requirement ... | [
"def",
"is_array",
"(",
"u",
",",
"dtype",
"=",
"None",
",",
"dims",
"=",
"None",
")",
":",
"if",
"is_quantity",
"(",
"u",
")",
":",
"return",
"is_array",
"(",
"mag",
"(",
"u",
")",
",",
"dtype",
"=",
"dtype",
",",
"dims",
"=",
"dims",
")",
"el... | is_array(u) is equivalent to is_nparray(np.asarray(u)), meaning is_array(u) will always yield
True.
is_array(u, dtype) yields True if np.asarray(u) is of the given dtype, which is looked up using
numpy_type. If dtype is None, then no dtype requirement is applied.
is_array(u, dtype, dims) yields True... | [
"is_array",
"(",
"u",
")",
"is",
"equivalent",
"to",
"is_nparray",
"(",
"np",
".",
"asarray",
"(",
"u",
"))",
"meaning",
"is_array",
"(",
"u",
")",
"will",
"always",
"yield",
"True",
".",
"is_array",
"(",
"u",
"dtype",
")",
"yields",
"True",
"if",
"n... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L429-L448 | train | A simple wrapper for is_array that returns True if u is an array. |
noahbenson/pimms | pimms/util.py | curry | def curry(f, *args0, **kwargs0):
'''
curry(f, ...) yields a function equivalent to f with all following arguments and keyword
arguments passed. This is much like the partial function, but yields a function instead of
a partial object and thus is suitable for use with pimms lazy maps.
'''
def... | python | def curry(f, *args0, **kwargs0):
'''
curry(f, ...) yields a function equivalent to f with all following arguments and keyword
arguments passed. This is much like the partial function, but yields a function instead of
a partial object and thus is suitable for use with pimms lazy maps.
'''
def... | [
"def",
"curry",
"(",
"f",
",",
"*",
"args0",
",",
"*",
"*",
"kwargs0",
")",
":",
"def",
"curried_f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"f",
"(",
"*",
"(",
"args0",
"+",
"args",
")",
",",
"*",
"*",
"merge",
"(",
... | curry(f, ...) yields a function equivalent to f with all following arguments and keyword
arguments passed. This is much like the partial function, but yields a function instead of
a partial object and thus is suitable for use with pimms lazy maps. | [
"curry",
"(",
"f",
"...",
")",
"yields",
"a",
"function",
"equivalent",
"to",
"f",
"with",
"all",
"following",
"arguments",
"and",
"keyword",
"arguments",
"passed",
".",
"This",
"is",
"much",
"like",
"the",
"partial",
"function",
"but",
"yields",
"a",
"fun... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L488-L496 | train | A function that curryes a function f with all following arguments and keyword
arguments passed. |
noahbenson/pimms | pimms/util.py | is_seq | def is_seq(arg):
'''
is_seq(arg) yields True if arg is a sequential collection otherwise False; i.e., it must be a
list, tuple, persistent vector, persistent list, or numpy array.
Note that strings are not considered sequences.
'''
return isinstance(arg, (list_type, tuple_type, pyr.PVecto... | python | def is_seq(arg):
'''
is_seq(arg) yields True if arg is a sequential collection otherwise False; i.e., it must be a
list, tuple, persistent vector, persistent list, or numpy array.
Note that strings are not considered sequences.
'''
return isinstance(arg, (list_type, tuple_type, pyr.PVecto... | [
"def",
"is_seq",
"(",
"arg",
")",
":",
"return",
"isinstance",
"(",
"arg",
",",
"(",
"list_type",
",",
"tuple_type",
",",
"pyr",
".",
"PVector",
",",
"pyr",
".",
"PList",
")",
")",
"or",
"is_nparray",
"(",
"arg",
")"
] | is_seq(arg) yields True if arg is a sequential collection otherwise False; i.e., it must be a
list, tuple, persistent vector, persistent list, or numpy array.
Note that strings are not considered sequences. | [
"is_seq",
"(",
"arg",
")",
"yields",
"True",
"if",
"arg",
"is",
"a",
"sequential",
"collection",
"otherwise",
"False",
";",
"i",
".",
"e",
".",
"it",
"must",
"be",
"a",
"list",
"tuple",
"persistent",
"vector",
"persistent",
"list",
"or",
"numpy",
"array"... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L497-L504 | train | Returns True if arg is a sequential collection otherwise False. |
noahbenson/pimms | pimms/util.py | is_pseq | def is_pseq(arg):
'''
is_pseq(arg) yields True if arg is a persistent vector, a persistent list, a tuple, or a numpy
array with its writeable flag off.
'''
if is_nparray(arg): return arg.flags['WRITEABLE'] == False
return isinstance(arg, (tuple_type, pyr.PVector, pyr.PList)) | python | def is_pseq(arg):
'''
is_pseq(arg) yields True if arg is a persistent vector, a persistent list, a tuple, or a numpy
array with its writeable flag off.
'''
if is_nparray(arg): return arg.flags['WRITEABLE'] == False
return isinstance(arg, (tuple_type, pyr.PVector, pyr.PList)) | [
"def",
"is_pseq",
"(",
"arg",
")",
":",
"if",
"is_nparray",
"(",
"arg",
")",
":",
"return",
"arg",
".",
"flags",
"[",
"'WRITEABLE'",
"]",
"==",
"False",
"return",
"isinstance",
"(",
"arg",
",",
"(",
"tuple_type",
",",
"pyr",
".",
"PVector",
",",
"pyr... | is_pseq(arg) yields True if arg is a persistent vector, a persistent list, a tuple, or a numpy
array with its writeable flag off. | [
"is_pseq",
"(",
"arg",
")",
"yields",
"True",
"if",
"arg",
"is",
"a",
"persistent",
"vector",
"a",
"persistent",
"list",
"a",
"tuple",
"or",
"a",
"numpy",
"array",
"with",
"its",
"writeable",
"flag",
"off",
"."
] | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L505-L511 | train | Returns True if arg is a persistent sequence. |
noahbenson/pimms | pimms/util.py | is_int | def is_int(arg):
'''
is_int(x) yields True if x is an integer object and False otherwise; integer objects include the
standard Python integer types as well as numpy single integer arrays (i.e., where
x.shape == ()) and quantities with integer magnitudes.
'''
return (is_int(mag(arg)) if is_qu... | python | def is_int(arg):
'''
is_int(x) yields True if x is an integer object and False otherwise; integer objects include the
standard Python integer types as well as numpy single integer arrays (i.e., where
x.shape == ()) and quantities with integer magnitudes.
'''
return (is_int(mag(arg)) if is_qu... | [
"def",
"is_int",
"(",
"arg",
")",
":",
"return",
"(",
"is_int",
"(",
"mag",
"(",
"arg",
")",
")",
"if",
"is_quantity",
"(",
"arg",
")",
"else",
"True",
"if",
"isinstance",
"(",
"arg",
",",
"six",
".",
"integer_types",
")",
"else",
"is_npscalar",
"(",... | is_int(x) yields True if x is an integer object and False otherwise; integer objects include the
standard Python integer types as well as numpy single integer arrays (i.e., where
x.shape == ()) and quantities with integer magnitudes. | [
"is_int",
"(",
"x",
")",
"yields",
"True",
"if",
"x",
"is",
"an",
"integer",
"object",
"and",
"False",
"otherwise",
";",
"integer",
"objects",
"include",
"the",
"standard",
"Python",
"integer",
"types",
"as",
"well",
"as",
"numpy",
"single",
"integer",
"ar... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L513-L521 | train | Returns True if the argument is an integer object and False otherwise. |
noahbenson/pimms | pimms/util.py | is_real | def is_real(arg):
'''
is_real(x) yields True if x is a non-complex numeric object and False otherwise.
Note that is_real(i) will yield True for an integer or bool i; to check for floating-point
representations of numbers, use is_array(x, numpy.floating) or similar.
'''
return (is_real(mag(arg))... | python | def is_real(arg):
'''
is_real(x) yields True if x is a non-complex numeric object and False otherwise.
Note that is_real(i) will yield True for an integer or bool i; to check for floating-point
representations of numbers, use is_array(x, numpy.floating) or similar.
'''
return (is_real(mag(arg))... | [
"def",
"is_real",
"(",
"arg",
")",
":",
"return",
"(",
"is_real",
"(",
"mag",
"(",
"arg",
")",
")",
"if",
"is_quantity",
"(",
"arg",
")",
"else",
"True",
"if",
"isinstance",
"(",
"arg",
",",
"float",
")",
"else",
"is_npscalar",
"(",
"arg",
",",
"'r... | is_real(x) yields True if x is a non-complex numeric object and False otherwise.
Note that is_real(i) will yield True for an integer or bool i; to check for floating-point
representations of numbers, use is_array(x, numpy.floating) or similar. | [
"is_real",
"(",
"x",
")",
"yields",
"True",
"if",
"x",
"is",
"a",
"non",
"-",
"complex",
"numeric",
"object",
"and",
"False",
"otherwise",
"."
] | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L533-L542 | train | Returns True if the argument is real. |
noahbenson/pimms | pimms/util.py | is_inexact | def is_inexact(arg):
'''
is_inexact(x) yields True if x is a number represented by floating-point data (i.e., either a
non-integer real number or a complex number) and False otherwise.
'''
return (is_inexact(mag(arg)) if is_quantity(arg) else
is_npscalar(u, np.inexact) or is_npvalue(ar... | python | def is_inexact(arg):
'''
is_inexact(x) yields True if x is a number represented by floating-point data (i.e., either a
non-integer real number or a complex number) and False otherwise.
'''
return (is_inexact(mag(arg)) if is_quantity(arg) else
is_npscalar(u, np.inexact) or is_npvalue(ar... | [
"def",
"is_inexact",
"(",
"arg",
")",
":",
"return",
"(",
"is_inexact",
"(",
"mag",
"(",
"arg",
")",
")",
"if",
"is_quantity",
"(",
"arg",
")",
"else",
"is_npscalar",
"(",
"u",
",",
"np",
".",
"inexact",
")",
"or",
"is_npvalue",
"(",
"arg",
",",
"n... | is_inexact(x) yields True if x is a number represented by floating-point data (i.e., either a
non-integer real number or a complex number) and False otherwise. | [
"is_inexact",
"(",
"x",
")",
"yields",
"True",
"if",
"x",
"is",
"a",
"number",
"represented",
"by",
"floating",
"-",
"point",
"data",
"(",
"i",
".",
"e",
".",
"either",
"a",
"non",
"-",
"integer",
"real",
"number",
"or",
"a",
"complex",
"number",
")"... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L543-L549 | train | Returns True if x is an inexact number. |
noahbenson/pimms | pimms/util.py | is_complex | def is_complex(arg):
'''
is_complex(x) yields True if x is a complex numeric object and False otherwise. Note that this
includes anything representable as as a complex number such as an integer or a boolean value.
In effect, this makes this function an alias for is_number(arg).
'''
return (i... | python | def is_complex(arg):
'''
is_complex(x) yields True if x is a complex numeric object and False otherwise. Note that this
includes anything representable as as a complex number such as an integer or a boolean value.
In effect, this makes this function an alias for is_number(arg).
'''
return (i... | [
"def",
"is_complex",
"(",
"arg",
")",
":",
"return",
"(",
"is_complex",
"(",
"mag",
"(",
"arg",
")",
")",
"if",
"is_quantity",
"(",
"arg",
")",
"else",
"True",
"if",
"isinstance",
"(",
"arg",
",",
"numbers",
".",
"Complex",
")",
"else",
"is_npscalar",
... | is_complex(x) yields True if x is a complex numeric object and False otherwise. Note that this
includes anything representable as as a complex number such as an integer or a boolean value.
In effect, this makes this function an alias for is_number(arg). | [
"is_complex",
"(",
"x",
")",
"yields",
"True",
"if",
"x",
"is",
"a",
"complex",
"numeric",
"object",
"and",
"False",
"otherwise",
".",
"Note",
"that",
"this",
"includes",
"anything",
"representable",
"as",
"as",
"a",
"complex",
"number",
"such",
"as",
"an"... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L550-L558 | train | Returns True if the argument is a complex number and False otherwise. |
noahbenson/pimms | pimms/util.py | is_number | def is_number(arg):
'''
is_number(x) yields True if x is a numeric object and False otherwise.
'''
return (is_number(mag(arg)) if is_quantity(arg) else
is_npscalar(arg, 'number') or is_npvalue(arg, 'number')) | python | def is_number(arg):
'''
is_number(x) yields True if x is a numeric object and False otherwise.
'''
return (is_number(mag(arg)) if is_quantity(arg) else
is_npscalar(arg, 'number') or is_npvalue(arg, 'number')) | [
"def",
"is_number",
"(",
"arg",
")",
":",
"return",
"(",
"is_number",
"(",
"mag",
"(",
"arg",
")",
")",
"if",
"is_quantity",
"(",
"arg",
")",
"else",
"is_npscalar",
"(",
"arg",
",",
"'number'",
")",
"or",
"is_npvalue",
"(",
"arg",
",",
"'number'",
")... | is_number(x) yields True if x is a numeric object and False otherwise. | [
"is_number",
"(",
"x",
")",
"yields",
"True",
"if",
"x",
"is",
"a",
"numeric",
"object",
"and",
"False",
"otherwise",
"."
] | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L559-L564 | train | Returns True if x is a numeric object and False otherwise. |
noahbenson/pimms | pimms/util.py | _lazy_turbo_mapping | def _lazy_turbo_mapping(initial, pre_size):
'''
_lazy_turbo_mapping is a blatant copy of the pyrsistent._pmap._turbo_mapping function, except
it works for lazy maps; this seems like the only way to fully overload PMap.
'''
size = pre_size or (2 * len(initial)) or 8
buckets = size * [None]
if... | python | def _lazy_turbo_mapping(initial, pre_size):
'''
_lazy_turbo_mapping is a blatant copy of the pyrsistent._pmap._turbo_mapping function, except
it works for lazy maps; this seems like the only way to fully overload PMap.
'''
size = pre_size or (2 * len(initial)) or 8
buckets = size * [None]
if... | [
"def",
"_lazy_turbo_mapping",
"(",
"initial",
",",
"pre_size",
")",
":",
"size",
"=",
"pre_size",
"or",
"(",
"2",
"*",
"len",
"(",
"initial",
")",
")",
"or",
"8",
"buckets",
"=",
"size",
"*",
"[",
"None",
"]",
"if",
"not",
"isinstance",
"(",
"initial... | _lazy_turbo_mapping is a blatant copy of the pyrsistent._pmap._turbo_mapping function, except
it works for lazy maps; this seems like the only way to fully overload PMap. | [
"_lazy_turbo_mapping",
"is",
"a",
"blatant",
"copy",
"of",
"the",
"pyrsistent",
".",
"_pmap",
".",
"_turbo_mapping",
"function",
"except",
"it",
"works",
"for",
"lazy",
"maps",
";",
"this",
"seems",
"like",
"the",
"only",
"way",
"to",
"fully",
"overload",
"P... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L686-L700 | train | _lazy_turbo_mapping is a blatant copy of pyrsistent. _pmap. _turbo_mapping except it works for lazy maps. |
noahbenson/pimms | pimms/util.py | lazy_map | def lazy_map(initial={}, pre_size=0):
'''
lazy_map is a blatant copy of the pyrsistent.pmap function, and is used to create lazy maps.
'''
if is_lazy_map(initial): return initial
if not initial: return _EMPTY_LMAP
return _lazy_turbo_mapping(initial, pre_size) | python | def lazy_map(initial={}, pre_size=0):
'''
lazy_map is a blatant copy of the pyrsistent.pmap function, and is used to create lazy maps.
'''
if is_lazy_map(initial): return initial
if not initial: return _EMPTY_LMAP
return _lazy_turbo_mapping(initial, pre_size) | [
"def",
"lazy_map",
"(",
"initial",
"=",
"{",
"}",
",",
"pre_size",
"=",
"0",
")",
":",
"if",
"is_lazy_map",
"(",
"initial",
")",
":",
"return",
"initial",
"if",
"not",
"initial",
":",
"return",
"_EMPTY_LMAP",
"return",
"_lazy_turbo_mapping",
"(",
"initial"... | lazy_map is a blatant copy of the pyrsistent.pmap function, and is used to create lazy maps. | [
"lazy_map",
"is",
"a",
"blatant",
"copy",
"of",
"the",
"pyrsistent",
".",
"pmap",
"function",
"and",
"is",
"used",
"to",
"create",
"lazy",
"maps",
"."
] | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L702-L708 | train | lazy_map is a blatant copy of the pyrsistent. pmap function that returns a lazy map of the given initial value. |
noahbenson/pimms | pimms/util.py | lazy_value_map | def lazy_value_map(f, m, *args, **kwargs):
'''
lazy_value_map(f, mapping) yields a lazy map whose keys are the same as those of the given dict
or mapping object and whose values, for each key k are f(mapping[k]).
lazy_value_map(f, mapping, *args, **kw) additionally passes the given arguments to the fu... | python | def lazy_value_map(f, m, *args, **kwargs):
'''
lazy_value_map(f, mapping) yields a lazy map whose keys are the same as those of the given dict
or mapping object and whose values, for each key k are f(mapping[k]).
lazy_value_map(f, mapping, *args, **kw) additionally passes the given arguments to the fu... | [
"def",
"lazy_value_map",
"(",
"f",
",",
"m",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"is_map",
"(",
"m",
")",
":",
"raise",
"ValueError",
"(",
"'Non-mapping object passed to lazy_value_map'",
")",
"if",
"not",
"is_lazy_map",
"(",
... | lazy_value_map(f, mapping) yields a lazy map whose keys are the same as those of the given dict
or mapping object and whose values, for each key k are f(mapping[k]).
lazy_value_map(f, mapping, *args, **kw) additionally passes the given arguments to the function
f, so in the resulting map, each key k is ... | [
"lazy_value_map",
"(",
"f",
"mapping",
")",
"yields",
"a",
"lazy",
"map",
"whose",
"keys",
"are",
"the",
"same",
"as",
"those",
"of",
"the",
"given",
"dict",
"or",
"mapping",
"object",
"and",
"whose",
"values",
"for",
"each",
"key",
"k",
"are",
"f",
"(... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L727-L747 | train | Returns a lazy map whose keys are the same as those of the given dict
or mapping object. |
noahbenson/pimms | pimms/util.py | value_map | def value_map(f, m, *args, **kwargs):
'''
value_map(f, mapping) yields a persistent map whose keys are the same as those of the given dict
or mapping object and whose values, for each key k are f(mapping[k]).
value_map(f, mapping, *args, **kw) additionally passes the given arguments to the function
... | python | def value_map(f, m, *args, **kwargs):
'''
value_map(f, mapping) yields a persistent map whose keys are the same as those of the given dict
or mapping object and whose values, for each key k are f(mapping[k]).
value_map(f, mapping, *args, **kw) additionally passes the given arguments to the function
... | [
"def",
"value_map",
"(",
"f",
",",
"m",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"is_lazy_map",
"(",
"m",
")",
":",
"return",
"lazy_value_map",
"(",
"f",
",",
"m",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"else",
":",
... | value_map(f, mapping) yields a persistent map whose keys are the same as those of the given dict
or mapping object and whose values, for each key k are f(mapping[k]).
value_map(f, mapping, *args, **kw) additionally passes the given arguments to the function
f, so in the resulting map, each key k is mapp... | [
"value_map",
"(",
"f",
"mapping",
")",
"yields",
"a",
"persistent",
"map",
"whose",
"keys",
"are",
"the",
"same",
"as",
"those",
"of",
"the",
"given",
"dict",
"or",
"mapping",
"object",
"and",
"whose",
"values",
"for",
"each",
"key",
"k",
"are",
"f",
"... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L748-L760 | train | A value_map implementation that uses a function to map values to persistent dicts. |
noahbenson/pimms | pimms/util.py | key_map | def key_map(f, m, *args, **kwargs):
'''
key_map(f, m) is equivalent to {f(k):v for (k,v) in m.items()} except that it returns a
persistent mapping object instead of a dict. Additionally, it respects the laziness of maps
and does not evaluate the values of a lazy map that has been passed to it.
k... | python | def key_map(f, m, *args, **kwargs):
'''
key_map(f, m) is equivalent to {f(k):v for (k,v) in m.items()} except that it returns a
persistent mapping object instead of a dict. Additionally, it respects the laziness of maps
and does not evaluate the values of a lazy map that has been passed to it.
k... | [
"def",
"key_map",
"(",
"f",
",",
"m",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"is_lazy_map",
"(",
"m",
")",
":",
"from",
".",
"table",
"import",
"(",
"is_itable",
",",
"itable",
")",
"def",
"_curry_getval",
"(",
"k",
")",
":",
... | key_map(f, m) is equivalent to {f(k):v for (k,v) in m.items()} except that it returns a
persistent mapping object instead of a dict. Additionally, it respects the laziness of maps
and does not evaluate the values of a lazy map that has been passed to it.
key_map(f, m, *args, **kwargs) uses f(k, *args, *... | [
"key_map",
"(",
"f",
"m",
")",
"is",
"equivalent",
"to",
"{",
"f",
"(",
"k",
")",
":",
"v",
"for",
"(",
"k",
"v",
")",
"in",
"m",
".",
"items",
"()",
"}",
"except",
"that",
"it",
"returns",
"a",
"persistent",
"mapping",
"object",
"instead",
"of",... | 9051b86d6b858a7a13511b72c48dc21bc903dab2 | https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L761-L774 | train | A key_map implementation that uses a function to return a persistent mapping object instead of a dict. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.