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 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ionelmc/python-aspectlib | src/aspectlib/__init__.py | weave | def weave(target, aspects, **options):
"""
Send a message to a recipient
Args:
target (string, class, instance, function or builtin):
The object to weave.
aspects (:py:obj:`aspectlib.Aspect`, function decorator or list of):
The aspects to apply to the object.
... | python | def weave(target, aspects, **options):
"""
Send a message to a recipient
Args:
target (string, class, instance, function or builtin):
The object to weave.
aspects (:py:obj:`aspectlib.Aspect`, function decorator or list of):
The aspects to apply to the object.
... | [
"def",
"weave",
"(",
"target",
",",
"aspects",
",",
"*",
"*",
"options",
")",
":",
"if",
"not",
"callable",
"(",
"aspects",
")",
":",
"if",
"not",
"hasattr",
"(",
"aspects",
",",
"'__iter__'",
")",
":",
"raise",
"ExpectedAdvice",
"(",
"'%s must be an `As... | Send a message to a recipient
Args:
target (string, class, instance, function or builtin):
The object to weave.
aspects (:py:obj:`aspectlib.Aspect`, function decorator or list of):
The aspects to apply to the object.
subclasses (bool):
If ``True``, subcla... | [
"Send",
"a",
"message",
"to",
"a",
"recipient"
] | 7dba7651ab76160b9ce66c9c11e770f7844e95ec | https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/__init__.py#L366-L506 | train |
ionelmc/python-aspectlib | src/aspectlib/__init__.py | weave_instance | def weave_instance(instance, aspect, methods=NORMAL_METHODS, lazy=False, bag=BrokenBag, **options):
"""
Low-level weaver for instances.
.. warning:: You should not use this directly.
:returns: An :obj:`aspectlib.Rollback` object.
"""
if bag.has(instance):
return Nothing
entangleme... | python | def weave_instance(instance, aspect, methods=NORMAL_METHODS, lazy=False, bag=BrokenBag, **options):
"""
Low-level weaver for instances.
.. warning:: You should not use this directly.
:returns: An :obj:`aspectlib.Rollback` object.
"""
if bag.has(instance):
return Nothing
entangleme... | [
"def",
"weave_instance",
"(",
"instance",
",",
"aspect",
",",
"methods",
"=",
"NORMAL_METHODS",
",",
"lazy",
"=",
"False",
",",
"bag",
"=",
"BrokenBag",
",",
"*",
"*",
"options",
")",
":",
"if",
"bag",
".",
"has",
"(",
"instance",
")",
":",
"return",
... | Low-level weaver for instances.
.. warning:: You should not use this directly.
:returns: An :obj:`aspectlib.Rollback` object. | [
"Low",
"-",
"level",
"weaver",
"for",
"instances",
"."
] | 7dba7651ab76160b9ce66c9c11e770f7844e95ec | https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/__init__.py#L524-L555 | train |
ionelmc/python-aspectlib | src/aspectlib/__init__.py | weave_module | def weave_module(module, aspect, methods=NORMAL_METHODS, lazy=False, bag=BrokenBag, **options):
"""
Low-level weaver for "whole module weaving".
.. warning:: You should not use this directly.
:returns: An :obj:`aspectlib.Rollback` object.
"""
if bag.has(module):
return Nothing
ent... | python | def weave_module(module, aspect, methods=NORMAL_METHODS, lazy=False, bag=BrokenBag, **options):
"""
Low-level weaver for "whole module weaving".
.. warning:: You should not use this directly.
:returns: An :obj:`aspectlib.Rollback` object.
"""
if bag.has(module):
return Nothing
ent... | [
"def",
"weave_module",
"(",
"module",
",",
"aspect",
",",
"methods",
"=",
"NORMAL_METHODS",
",",
"lazy",
"=",
"False",
",",
"bag",
"=",
"BrokenBag",
",",
"*",
"*",
"options",
")",
":",
"if",
"bag",
".",
"has",
"(",
"module",
")",
":",
"return",
"Noth... | Low-level weaver for "whole module weaving".
.. warning:: You should not use this directly.
:returns: An :obj:`aspectlib.Rollback` object. | [
"Low",
"-",
"level",
"weaver",
"for",
"whole",
"module",
"weaving",
"."
] | 7dba7651ab76160b9ce66c9c11e770f7844e95ec | https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/__init__.py#L558-L586 | train |
ionelmc/python-aspectlib | src/aspectlib/__init__.py | weave_class | def weave_class(klass, aspect, methods=NORMAL_METHODS, subclasses=True, lazy=False,
owner=None, name=None, aliases=True, bases=True, bag=BrokenBag):
"""
Low-level weaver for classes.
.. warning:: You should not use this directly.
"""
assert isclass(klass), "Can't weave %r. Must be a... | python | def weave_class(klass, aspect, methods=NORMAL_METHODS, subclasses=True, lazy=False,
owner=None, name=None, aliases=True, bases=True, bag=BrokenBag):
"""
Low-level weaver for classes.
.. warning:: You should not use this directly.
"""
assert isclass(klass), "Can't weave %r. Must be a... | [
"def",
"weave_class",
"(",
"klass",
",",
"aspect",
",",
"methods",
"=",
"NORMAL_METHODS",
",",
"subclasses",
"=",
"True",
",",
"lazy",
"=",
"False",
",",
"owner",
"=",
"None",
",",
"name",
"=",
"None",
",",
"aliases",
"=",
"True",
",",
"bases",
"=",
... | Low-level weaver for classes.
.. warning:: You should not use this directly. | [
"Low",
"-",
"level",
"weaver",
"for",
"classes",
"."
] | 7dba7651ab76160b9ce66c9c11e770f7844e95ec | https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/__init__.py#L589-L666 | train |
ionelmc/python-aspectlib | src/aspectlib/__init__.py | patch_module | def patch_module(module, name, replacement, original=UNSPECIFIED, aliases=True, location=None, **_bogus_options):
"""
Low-level attribute patcher.
:param module module: Object to patch.
:param str name: Attribute to patch
:param replacement: The replacement value.
:param original: The original ... | python | def patch_module(module, name, replacement, original=UNSPECIFIED, aliases=True, location=None, **_bogus_options):
"""
Low-level attribute patcher.
:param module module: Object to patch.
:param str name: Attribute to patch
:param replacement: The replacement value.
:param original: The original ... | [
"def",
"patch_module",
"(",
"module",
",",
"name",
",",
"replacement",
",",
"original",
"=",
"UNSPECIFIED",
",",
"aliases",
"=",
"True",
",",
"location",
"=",
"None",
",",
"*",
"*",
"_bogus_options",
")",
":",
"rollback",
"=",
"Rollback",
"(",
")",
"seen... | Low-level attribute patcher.
:param module module: Object to patch.
:param str name: Attribute to patch
:param replacement: The replacement value.
:param original: The original value (in case the object beeing patched uses descriptors or is plain weird).
:param bool aliases: If ``True`` patch all t... | [
"Low",
"-",
"level",
"attribute",
"patcher",
"."
] | 7dba7651ab76160b9ce66c9c11e770f7844e95ec | https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/__init__.py#L685-L734 | train |
ionelmc/python-aspectlib | src/aspectlib/__init__.py | patch_module_function | def patch_module_function(module, target, aspect, force_name=None, bag=BrokenBag, **options):
"""
Low-level patcher for one function from a specified module.
.. warning:: You should not use this directly.
:returns: An :obj:`aspectlib.Rollback` object.
"""
logdebug("patch_module_function (modul... | python | def patch_module_function(module, target, aspect, force_name=None, bag=BrokenBag, **options):
"""
Low-level patcher for one function from a specified module.
.. warning:: You should not use this directly.
:returns: An :obj:`aspectlib.Rollback` object.
"""
logdebug("patch_module_function (modul... | [
"def",
"patch_module_function",
"(",
"module",
",",
"target",
",",
"aspect",
",",
"force_name",
"=",
"None",
",",
"bag",
"=",
"BrokenBag",
",",
"*",
"*",
"options",
")",
":",
"logdebug",
"(",
"\"patch_module_function (module=%s, target=%s, aspect=%s, force_name=%s, **... | Low-level patcher for one function from a specified module.
.. warning:: You should not use this directly.
:returns: An :obj:`aspectlib.Rollback` object. | [
"Low",
"-",
"level",
"patcher",
"for",
"one",
"function",
"from",
"a",
"specified",
"module",
"."
] | 7dba7651ab76160b9ce66c9c11e770f7844e95ec | https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/__init__.py#L737-L748 | train |
mjuenema/python-TSIP | tsip/llapi.py | unframe | def unframe(packet):
"""
Strip leading DLE and trailing DLE/ETX from packet.
:param packet: TSIP packet with leading DLE and trailing DLE/ETX.
:type packet: Binary string.
:return: TSIP packet with leading DLE and trailing DLE/ETX removed.
:raise: ``ValueError`` if `packet` does not start with ... | python | def unframe(packet):
"""
Strip leading DLE and trailing DLE/ETX from packet.
:param packet: TSIP packet with leading DLE and trailing DLE/ETX.
:type packet: Binary string.
:return: TSIP packet with leading DLE and trailing DLE/ETX removed.
:raise: ``ValueError`` if `packet` does not start with ... | [
"def",
"unframe",
"(",
"packet",
")",
":",
"if",
"is_framed",
"(",
"packet",
")",
":",
"return",
"packet",
".",
"lstrip",
"(",
"CHR_DLE",
")",
".",
"rstrip",
"(",
"CHR_ETX",
")",
".",
"rstrip",
"(",
"CHR_DLE",
")",
"else",
":",
"raise",
"ValueError",
... | Strip leading DLE and trailing DLE/ETX from packet.
:param packet: TSIP packet with leading DLE and trailing DLE/ETX.
:type packet: Binary string.
:return: TSIP packet with leading DLE and trailing DLE/ETX removed.
:raise: ``ValueError`` if `packet` does not start with DLE and end in DLE/ETX. | [
"Strip",
"leading",
"DLE",
"and",
"trailing",
"DLE",
"/",
"ETX",
"from",
"packet",
"."
] | e02b68d05772127ea493cd639b3d5f8fb73df402 | https://github.com/mjuenema/python-TSIP/blob/e02b68d05772127ea493cd639b3d5f8fb73df402/tsip/llapi.py#L41-L56 | train |
mjuenema/python-TSIP | tsip/llapi.py | stuff | def stuff(packet):
"""
Add byte stuffing to TSIP packet.
:param packet: TSIP packet with byte stuffing. The packet must already
have been stripped or `ValueError` will be raised.
:type packet: Binary string.
:return: Packet with byte stuffing.
"""
if is_framed(packet):
rais... | python | def stuff(packet):
"""
Add byte stuffing to TSIP packet.
:param packet: TSIP packet with byte stuffing. The packet must already
have been stripped or `ValueError` will be raised.
:type packet: Binary string.
:return: Packet with byte stuffing.
"""
if is_framed(packet):
rais... | [
"def",
"stuff",
"(",
"packet",
")",
":",
"if",
"is_framed",
"(",
"packet",
")",
":",
"raise",
"ValueError",
"(",
"'packet contains leading DLE and trailing DLE/ETX'",
")",
"else",
":",
"return",
"packet",
".",
"replace",
"(",
"CHR_DLE",
",",
"CHR_DLE",
"+",
"C... | Add byte stuffing to TSIP packet.
:param packet: TSIP packet with byte stuffing. The packet must already
have been stripped or `ValueError` will be raised.
:type packet: Binary string.
:return: Packet with byte stuffing. | [
"Add",
"byte",
"stuffing",
"to",
"TSIP",
"packet",
".",
":",
"param",
"packet",
":",
"TSIP",
"packet",
"with",
"byte",
"stuffing",
".",
"The",
"packet",
"must",
"already",
"have",
"been",
"stripped",
"or",
"ValueError",
"will",
"be",
"raised",
".",
":",
... | e02b68d05772127ea493cd639b3d5f8fb73df402 | https://github.com/mjuenema/python-TSIP/blob/e02b68d05772127ea493cd639b3d5f8fb73df402/tsip/llapi.py#L59-L72 | train |
mjuenema/python-TSIP | tsip/llapi.py | unstuff | def unstuff(packet):
"""
Remove byte stuffing from a TSIP packet.
:param packet: TSIP packet with byte stuffing. The packet must already
have been stripped or `ValueError` will be raised.
:type packet: Binary string.
:return: Packet without byte stuffing.
"""
if is_framed(packet):... | python | def unstuff(packet):
"""
Remove byte stuffing from a TSIP packet.
:param packet: TSIP packet with byte stuffing. The packet must already
have been stripped or `ValueError` will be raised.
:type packet: Binary string.
:return: Packet without byte stuffing.
"""
if is_framed(packet):... | [
"def",
"unstuff",
"(",
"packet",
")",
":",
"if",
"is_framed",
"(",
"packet",
")",
":",
"raise",
"ValueError",
"(",
"'packet contains leading DLE and trailing DLE/ETX'",
")",
"else",
":",
"return",
"packet",
".",
"replace",
"(",
"CHR_DLE",
"+",
"CHR_DLE",
",",
... | Remove byte stuffing from a TSIP packet.
:param packet: TSIP packet with byte stuffing. The packet must already
have been stripped or `ValueError` will be raised.
:type packet: Binary string.
:return: Packet without byte stuffing. | [
"Remove",
"byte",
"stuffing",
"from",
"a",
"TSIP",
"packet",
"."
] | e02b68d05772127ea493cd639b3d5f8fb73df402 | https://github.com/mjuenema/python-TSIP/blob/e02b68d05772127ea493cd639b3d5f8fb73df402/tsip/llapi.py#L76-L90 | train |
spacetelescope/stsci.tools | lib/stsci/tools/iterfile.py | parseFilename | def parseFilename(filename):
"""
Parse out filename from any specified extensions.
Returns rootname and string version of extension name.
Modified from 'pydrizzle.fileutil' to allow this
module to be independent of PyDrizzle/MultiDrizzle.
"""
# Parse out any extension speci... | python | def parseFilename(filename):
"""
Parse out filename from any specified extensions.
Returns rootname and string version of extension name.
Modified from 'pydrizzle.fileutil' to allow this
module to be independent of PyDrizzle/MultiDrizzle.
"""
# Parse out any extension speci... | [
"def",
"parseFilename",
"(",
"filename",
")",
":",
"# Parse out any extension specified in filename",
"_indx",
"=",
"filename",
".",
"find",
"(",
"'['",
")",
"if",
"_indx",
">",
"0",
":",
"# Read extension name provided",
"_fname",
"=",
"filename",
"[",
":",
"_ind... | Parse out filename from any specified extensions.
Returns rootname and string version of extension name.
Modified from 'pydrizzle.fileutil' to allow this
module to be independent of PyDrizzle/MultiDrizzle. | [
"Parse",
"out",
"filename",
"from",
"any",
"specified",
"extensions",
".",
"Returns",
"rootname",
"and",
"string",
"version",
"of",
"extension",
"name",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/iterfile.py#L111-L153 | train |
spacetelescope/stsci.tools | lib/stsci/tools/iterfile.py | IterFitsFile._shape | def _shape(self):
""" Returns the shape of the data array associated with this file."""
hdu = self.open()
_shape = hdu.shape
if not self.inmemory:
self.close()
del hdu
return _shape | python | def _shape(self):
""" Returns the shape of the data array associated with this file."""
hdu = self.open()
_shape = hdu.shape
if not self.inmemory:
self.close()
del hdu
return _shape | [
"def",
"_shape",
"(",
"self",
")",
":",
"hdu",
"=",
"self",
".",
"open",
"(",
")",
"_shape",
"=",
"hdu",
".",
"shape",
"if",
"not",
"self",
".",
"inmemory",
":",
"self",
".",
"close",
"(",
")",
"del",
"hdu",
"return",
"_shape"
] | Returns the shape of the data array associated with this file. | [
"Returns",
"the",
"shape",
"of",
"the",
"data",
"array",
"associated",
"with",
"this",
"file",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/iterfile.py#L35-L42 | train |
spacetelescope/stsci.tools | lib/stsci/tools/iterfile.py | IterFitsFile._data | def _data(self):
""" Returns the data array associated with this file/extenstion."""
hdu = self.open()
_data = hdu.data.copy()
if not self.inmemory:
self.close()
del hdu
return _data | python | def _data(self):
""" Returns the data array associated with this file/extenstion."""
hdu = self.open()
_data = hdu.data.copy()
if not self.inmemory:
self.close()
del hdu
return _data | [
"def",
"_data",
"(",
"self",
")",
":",
"hdu",
"=",
"self",
".",
"open",
"(",
")",
"_data",
"=",
"hdu",
".",
"data",
".",
"copy",
"(",
")",
"if",
"not",
"self",
".",
"inmemory",
":",
"self",
".",
"close",
"(",
")",
"del",
"hdu",
"return",
"_data... | Returns the data array associated with this file/extenstion. | [
"Returns",
"the",
"data",
"array",
"associated",
"with",
"this",
"file",
"/",
"extenstion",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/iterfile.py#L44-L51 | train |
spacetelescope/stsci.tools | lib/stsci/tools/iterfile.py | IterFitsFile.type | def type(self):
""" Returns the shape of the data array associated with this file."""
hdu = self.open()
_type = hdu.data.dtype.name
if not self.inmemory:
self.close()
del hdu
return _type | python | def type(self):
""" Returns the shape of the data array associated with this file."""
hdu = self.open()
_type = hdu.data.dtype.name
if not self.inmemory:
self.close()
del hdu
return _type | [
"def",
"type",
"(",
"self",
")",
":",
"hdu",
"=",
"self",
".",
"open",
"(",
")",
"_type",
"=",
"hdu",
".",
"data",
".",
"dtype",
".",
"name",
"if",
"not",
"self",
".",
"inmemory",
":",
"self",
".",
"close",
"(",
")",
"del",
"hdu",
"return",
"_t... | Returns the shape of the data array associated with this file. | [
"Returns",
"the",
"shape",
"of",
"the",
"data",
"array",
"associated",
"with",
"this",
"file",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/iterfile.py#L53-L60 | train |
spacetelescope/stsci.tools | lib/stsci/tools/iterfile.py | IterFitsFile.open | def open(self):
""" Opens the file for subsequent access. """
if self.handle is None:
self.handle = fits.open(self.fname, mode='readonly')
if self.extn:
if len(self.extn) == 1:
hdu = self.handle[self.extn[0]]
else:
hdu = self.... | python | def open(self):
""" Opens the file for subsequent access. """
if self.handle is None:
self.handle = fits.open(self.fname, mode='readonly')
if self.extn:
if len(self.extn) == 1:
hdu = self.handle[self.extn[0]]
else:
hdu = self.... | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"self",
".",
"handle",
"is",
"None",
":",
"self",
".",
"handle",
"=",
"fits",
".",
"open",
"(",
"self",
".",
"fname",
",",
"mode",
"=",
"'readonly'",
")",
"if",
"self",
".",
"extn",
":",
"if",
"len",
... | Opens the file for subsequent access. | [
"Opens",
"the",
"file",
"for",
"subsequent",
"access",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/iterfile.py#L62-L77 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | ActiveMeasurement.overlapsWith | def overlapsWith(self, targetStartTime, duration):
"""
Tests if the given times overlap with this measurement.
:param targetStartTime: the target start time.
:param duration: the duration
:return: true if the given times overlap with this measurement.
"""
targetEn... | python | def overlapsWith(self, targetStartTime, duration):
"""
Tests if the given times overlap with this measurement.
:param targetStartTime: the target start time.
:param duration: the duration
:return: true if the given times overlap with this measurement.
"""
targetEn... | [
"def",
"overlapsWith",
"(",
"self",
",",
"targetStartTime",
",",
"duration",
")",
":",
"targetEndTime",
"=",
"targetStartTime",
"+",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"0",
",",
"seconds",
"=",
"duration",
")",
"return",
"(",
"self",
".",
"sta... | Tests if the given times overlap with this measurement.
:param targetStartTime: the target start time.
:param duration: the duration
:return: true if the given times overlap with this measurement. | [
"Tests",
"if",
"the",
"given",
"times",
"overlap",
"with",
"this",
"measurement",
".",
":",
"param",
"targetStartTime",
":",
"the",
"target",
"start",
"time",
".",
":",
"param",
"duration",
":",
"the",
"duration",
":",
"return",
":",
"true",
"if",
"the",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L98-L107 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | ActiveMeasurement.updateDeviceStatus | def updateDeviceStatus(self, deviceName, state, reason=None):
"""
Updates the current device status.
:param deviceName: the device name.
:param state: the state.
:param reason: the reason for the change.
:return:
"""
logger.info('Updating recording device ... | python | def updateDeviceStatus(self, deviceName, state, reason=None):
"""
Updates the current device status.
:param deviceName: the device name.
:param state: the state.
:param reason: the reason for the change.
:return:
"""
logger.info('Updating recording device ... | [
"def",
"updateDeviceStatus",
"(",
"self",
",",
"deviceName",
",",
"state",
",",
"reason",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"'Updating recording device state for '",
"+",
"deviceName",
"+",
"' to '",
"+",
"state",
".",
"name",
"+",
"(",
"''"... | Updates the current device status.
:param deviceName: the device name.
:param state: the state.
:param reason: the reason for the change.
:return: | [
"Updates",
"the",
"current",
"device",
"status",
".",
":",
"param",
"deviceName",
":",
"the",
"device",
"name",
".",
":",
"param",
"state",
":",
"the",
"state",
".",
":",
"param",
"reason",
":",
"the",
"reason",
"for",
"the",
"change",
".",
":",
"retur... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L109-L129 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | ActiveMeasurement.stillRecording | def stillRecording(self, deviceId, dataCount):
"""
For a device that is recording, updates the last timestamp so we now when we last received data.
:param deviceId: the device id.
:param dataCount: the no of items of data recorded in this batch.
:return:
"""
statu... | python | def stillRecording(self, deviceId, dataCount):
"""
For a device that is recording, updates the last timestamp so we now when we last received data.
:param deviceId: the device id.
:param dataCount: the no of items of data recorded in this batch.
:return:
"""
statu... | [
"def",
"stillRecording",
"(",
"self",
",",
"deviceId",
",",
"dataCount",
")",
":",
"status",
"=",
"self",
".",
"recordingDevices",
"[",
"deviceId",
"]",
"if",
"status",
"is",
"not",
"None",
":",
"if",
"status",
"[",
"'state'",
"]",
"==",
"MeasurementStatus... | For a device that is recording, updates the last timestamp so we now when we last received data.
:param deviceId: the device id.
:param dataCount: the no of items of data recorded in this batch.
:return: | [
"For",
"a",
"device",
"that",
"is",
"recording",
"updates",
"the",
"last",
"timestamp",
"so",
"we",
"now",
"when",
"we",
"last",
"received",
"data",
".",
":",
"param",
"deviceId",
":",
"the",
"device",
"id",
".",
":",
"param",
"dataCount",
":",
"the",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L131-L142 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | CompleteMeasurement.inflate | def inflate(self):
"""
loads the recording into memory and returns it as a Signal
:return:
"""
if self.measurementParameters['accelerometerEnabled']:
if len(self.data) == 0:
logger.info('Loading measurement data for ' + self.name)
self.... | python | def inflate(self):
"""
loads the recording into memory and returns it as a Signal
:return:
"""
if self.measurementParameters['accelerometerEnabled']:
if len(self.data) == 0:
logger.info('Loading measurement data for ' + self.name)
self.... | [
"def",
"inflate",
"(",
"self",
")",
":",
"if",
"self",
".",
"measurementParameters",
"[",
"'accelerometerEnabled'",
"]",
":",
"if",
"len",
"(",
"self",
".",
"data",
")",
"==",
"0",
":",
"logger",
".",
"info",
"(",
"'Loading measurement data for '",
"+",
"s... | loads the recording into memory and returns it as a Signal
:return: | [
"loads",
"the",
"recording",
"into",
"memory",
"and",
"returns",
"it",
"as",
"a",
"Signal",
":",
"return",
":"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L178-L190 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController._sweep | def _sweep(self):
"""
Checks the state of each measurement and verifies their state, if an active measurement is now complete then
passes them to the completed measurement set, if failed then to the failed set, if failed and old then evicts.
:return:
"""
while self.runnin... | python | def _sweep(self):
"""
Checks the state of each measurement and verifies their state, if an active measurement is now complete then
passes them to the completed measurement set, if failed then to the failed set, if failed and old then evicts.
:return:
"""
while self.runnin... | [
"def",
"_sweep",
"(",
"self",
")",
":",
"while",
"self",
".",
"running",
":",
"for",
"am",
"in",
"list",
"(",
"self",
".",
"activeMeasurements",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"# devices were allocated and have ... | Checks the state of each measurement and verifies their state, if an active measurement is now complete then
passes them to the completed measurement set, if failed then to the failed set, if failed and old then evicts.
:return: | [
"Checks",
"the",
"state",
"of",
"each",
"measurement",
"and",
"verifies",
"their",
"state",
"if",
"an",
"active",
"measurement",
"is",
"now",
"complete",
"then",
"passes",
"them",
"to",
"the",
"completed",
"measurement",
"set",
"if",
"failed",
"then",
"to",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L233-L266 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.schedule | def schedule(self, name, duration, startTime, description=None):
"""
Schedules a new measurement with the given name.
:param name:
:param duration:
:param startTime:
:param description:
:return: a tuple
boolean: measurement was scheduled if true
... | python | def schedule(self, name, duration, startTime, description=None):
"""
Schedules a new measurement with the given name.
:param name:
:param duration:
:param startTime:
:param description:
:return: a tuple
boolean: measurement was scheduled if true
... | [
"def",
"schedule",
"(",
"self",
",",
"name",
",",
"duration",
",",
"startTime",
",",
"description",
"=",
"None",
")",
":",
"if",
"self",
".",
"_clashes",
"(",
"startTime",
",",
"duration",
")",
":",
"return",
"False",
",",
"MEASUREMENT_TIMES_CLASH",
"else"... | Schedules a new measurement with the given name.
:param name:
:param duration:
:param startTime:
:param description:
:return: a tuple
boolean: measurement was scheduled if true
message: description, generally only used as an error code | [
"Schedules",
"a",
"new",
"measurement",
"with",
"the",
"given",
"name",
".",
":",
"param",
"name",
":",
":",
"param",
"duration",
":",
":",
"param",
"startTime",
":",
":",
"param",
"description",
":",
":",
"return",
":",
"a",
"tuple",
"boolean",
":",
"... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L302-L333 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController._clashes | def _clashes(self, startTime, duration):
"""
verifies that this measurement does not clash with an already scheduled measurement.
:param startTime: the start time.
:param duration: the duration.
:return: true if the measurement is allowed.
"""
return [m for m in s... | python | def _clashes(self, startTime, duration):
"""
verifies that this measurement does not clash with an already scheduled measurement.
:param startTime: the start time.
:param duration: the duration.
:return: true if the measurement is allowed.
"""
return [m for m in s... | [
"def",
"_clashes",
"(",
"self",
",",
"startTime",
",",
"duration",
")",
":",
"return",
"[",
"m",
"for",
"m",
"in",
"self",
".",
"activeMeasurements",
"if",
"m",
".",
"overlapsWith",
"(",
"startTime",
",",
"duration",
")",
"]"
] | verifies that this measurement does not clash with an already scheduled measurement.
:param startTime: the start time.
:param duration: the duration.
:return: true if the measurement is allowed. | [
"verifies",
"that",
"this",
"measurement",
"does",
"not",
"clash",
"with",
"an",
"already",
"scheduled",
"measurement",
".",
":",
"param",
"startTime",
":",
"the",
"start",
"time",
".",
":",
"param",
"duration",
":",
"the",
"duration",
".",
":",
"return",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L335-L342 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.startMeasurement | def startMeasurement(self, measurementId, deviceId):
"""
Starts the measurement for the device.
:param deviceId: the device that is starting.
:param measurementId: the measurement that is started.
:return: true if it started (i.e. device and measurement exists).
"""
... | python | def startMeasurement(self, measurementId, deviceId):
"""
Starts the measurement for the device.
:param deviceId: the device that is starting.
:param measurementId: the measurement that is started.
:return: true if it started (i.e. device and measurement exists).
"""
... | [
"def",
"startMeasurement",
"(",
"self",
",",
"measurementId",
",",
"deviceId",
")",
":",
"am",
",",
"handler",
"=",
"self",
".",
"getDataHandler",
"(",
"measurementId",
",",
"deviceId",
")",
"if",
"am",
"is",
"not",
"None",
":",
"am",
".",
"status",
"=",... | Starts the measurement for the device.
:param deviceId: the device that is starting.
:param measurementId: the measurement that is started.
:return: true if it started (i.e. device and measurement exists). | [
"Starts",
"the",
"measurement",
"for",
"the",
"device",
".",
":",
"param",
"deviceId",
":",
"the",
"device",
"that",
"is",
"starting",
".",
":",
"param",
"measurementId",
":",
"the",
"measurement",
"that",
"is",
"started",
".",
":",
"return",
":",
"true",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L344-L358 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.getDataHandler | def getDataHandler(self, measurementId, deviceId):
"""
finds the handler.
:param measurementId: the measurement
:param deviceId: the device.
:return: active measurement and handler
"""
am = next((m for m in self.activeMeasurements if m.id == measurementId), None)
... | python | def getDataHandler(self, measurementId, deviceId):
"""
finds the handler.
:param measurementId: the measurement
:param deviceId: the device.
:return: active measurement and handler
"""
am = next((m for m in self.activeMeasurements if m.id == measurementId), None)
... | [
"def",
"getDataHandler",
"(",
"self",
",",
"measurementId",
",",
"deviceId",
")",
":",
"am",
"=",
"next",
"(",
"(",
"m",
"for",
"m",
"in",
"self",
".",
"activeMeasurements",
"if",
"m",
".",
"id",
"==",
"measurementId",
")",
",",
"None",
")",
"if",
"a... | finds the handler.
:param measurementId: the measurement
:param deviceId: the device.
:return: active measurement and handler | [
"finds",
"the",
"handler",
".",
":",
"param",
"measurementId",
":",
"the",
"measurement",
":",
"param",
"deviceId",
":",
"the",
"device",
".",
":",
"return",
":",
"active",
"measurement",
"and",
"handler"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L360-L375 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.recordData | def recordData(self, measurementId, deviceId, data):
"""
Passes the data to the handler.
:param deviceId: the device the data comes from.
:param measurementId: the measurement id.
:param data: the data.
:return: true if the data was handled.
"""
am, handle... | python | def recordData(self, measurementId, deviceId, data):
"""
Passes the data to the handler.
:param deviceId: the device the data comes from.
:param measurementId: the measurement id.
:param data: the data.
:return: true if the data was handled.
"""
am, handle... | [
"def",
"recordData",
"(",
"self",
",",
"measurementId",
",",
"deviceId",
",",
"data",
")",
":",
"am",
",",
"handler",
"=",
"self",
".",
"getDataHandler",
"(",
"measurementId",
",",
"deviceId",
")",
"if",
"handler",
"is",
"not",
"None",
":",
"am",
".",
... | Passes the data to the handler.
:param deviceId: the device the data comes from.
:param measurementId: the measurement id.
:param data: the data.
:return: true if the data was handled. | [
"Passes",
"the",
"data",
"to",
"the",
"handler",
".",
":",
"param",
"deviceId",
":",
"the",
"device",
"the",
"data",
"comes",
"from",
".",
":",
"param",
"measurementId",
":",
"the",
"measurement",
"id",
".",
":",
"param",
"data",
":",
"the",
"data",
".... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L377-L392 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.completeMeasurement | def completeMeasurement(self, measurementId, deviceId):
"""
Completes the measurement session.
:param deviceId: the device id.
:param measurementId: the measurement id.
:return: true if it was completed.
"""
am, handler = self.getDataHandler(measurementId, deviceI... | python | def completeMeasurement(self, measurementId, deviceId):
"""
Completes the measurement session.
:param deviceId: the device id.
:param measurementId: the measurement id.
:return: true if it was completed.
"""
am, handler = self.getDataHandler(measurementId, deviceI... | [
"def",
"completeMeasurement",
"(",
"self",
",",
"measurementId",
",",
"deviceId",
")",
":",
"am",
",",
"handler",
"=",
"self",
".",
"getDataHandler",
"(",
"measurementId",
",",
"deviceId",
")",
"if",
"handler",
"is",
"not",
"None",
":",
"handler",
".",
"st... | Completes the measurement session.
:param deviceId: the device id.
:param measurementId: the measurement id.
:return: true if it was completed. | [
"Completes",
"the",
"measurement",
"session",
".",
":",
"param",
"deviceId",
":",
"the",
"device",
"id",
".",
":",
"param",
"measurementId",
":",
"the",
"measurement",
"id",
".",
":",
"return",
":",
"true",
"if",
"it",
"was",
"completed",
"."
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L394-L407 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.failMeasurement | def failMeasurement(self, measurementId, deviceName, failureReason=None):
"""
Fails the measurement session.
:param deviceName: the device name.
:param measurementId: the measurement name.
:param failureReason: why it failed.
:return: true if it was completed.
"""... | python | def failMeasurement(self, measurementId, deviceName, failureReason=None):
"""
Fails the measurement session.
:param deviceName: the device name.
:param measurementId: the measurement name.
:param failureReason: why it failed.
:return: true if it was completed.
"""... | [
"def",
"failMeasurement",
"(",
"self",
",",
"measurementId",
",",
"deviceName",
",",
"failureReason",
"=",
"None",
")",
":",
"am",
",",
"handler",
"=",
"self",
".",
"getDataHandler",
"(",
"measurementId",
",",
"deviceName",
")",
"if",
"handler",
"is",
"not",... | Fails the measurement session.
:param deviceName: the device name.
:param measurementId: the measurement name.
:param failureReason: why it failed.
:return: true if it was completed. | [
"Fails",
"the",
"measurement",
"session",
".",
":",
"param",
"deviceName",
":",
"the",
"device",
"name",
".",
":",
"param",
"measurementId",
":",
"the",
"measurement",
"name",
".",
":",
"param",
"failureReason",
":",
"why",
"it",
"failed",
".",
":",
"retur... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L409-L423 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController._deleteCompletedMeasurement | def _deleteCompletedMeasurement(self, measurementId):
"""
Deletes the named measurement from the completed measurement store if it exists.
:param measurementId:
:return:
String: error messages
Integer: count of measurements deleted
"""
message, cou... | python | def _deleteCompletedMeasurement(self, measurementId):
"""
Deletes the named measurement from the completed measurement store if it exists.
:param measurementId:
:return:
String: error messages
Integer: count of measurements deleted
"""
message, cou... | [
"def",
"_deleteCompletedMeasurement",
"(",
"self",
",",
"measurementId",
")",
":",
"message",
",",
"count",
",",
"deleted",
"=",
"self",
".",
"deleteFrom",
"(",
"measurementId",
",",
"self",
".",
"completeMeasurements",
")",
"if",
"count",
"is",
"0",
":",
"m... | Deletes the named measurement from the completed measurement store if it exists.
:param measurementId:
:return:
String: error messages
Integer: count of measurements deleted | [
"Deletes",
"the",
"named",
"measurement",
"from",
"the",
"completed",
"measurement",
"store",
"if",
"it",
"exists",
".",
":",
"param",
"measurementId",
":",
":",
"return",
":",
"String",
":",
"error",
"messages",
"Integer",
":",
"count",
"of",
"measurements",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L434-L445 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.reloadCompletedMeasurements | def reloadCompletedMeasurements(self):
"""
Reloads the completed measurements from the backing store.
"""
from pathlib import Path
reloaded = [self.load(x.resolve()) for x in Path(self.dataDir).glob('*/*/*') if x.is_dir()]
logger.info('Reloaded ' + str(len(reloaded)) + ' ... | python | def reloadCompletedMeasurements(self):
"""
Reloads the completed measurements from the backing store.
"""
from pathlib import Path
reloaded = [self.load(x.resolve()) for x in Path(self.dataDir).glob('*/*/*') if x.is_dir()]
logger.info('Reloaded ' + str(len(reloaded)) + ' ... | [
"def",
"reloadCompletedMeasurements",
"(",
"self",
")",
":",
"from",
"pathlib",
"import",
"Path",
"reloaded",
"=",
"[",
"self",
".",
"load",
"(",
"x",
".",
"resolve",
"(",
")",
")",
"for",
"x",
"in",
"Path",
"(",
"self",
".",
"dataDir",
")",
".",
"gl... | Reloads the completed measurements from the backing store. | [
"Reloads",
"the",
"completed",
"measurements",
"from",
"the",
"backing",
"store",
"."
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L469-L477 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.getMeasurements | def getMeasurements(self, measurementStatus=None):
"""
Gets all available measurements.
:param measurementStatus return only the measurements in the given state.
:return:
"""
if measurementStatus is None:
return self.activeMeasurements + self.completeMeasureme... | python | def getMeasurements(self, measurementStatus=None):
"""
Gets all available measurements.
:param measurementStatus return only the measurements in the given state.
:return:
"""
if measurementStatus is None:
return self.activeMeasurements + self.completeMeasureme... | [
"def",
"getMeasurements",
"(",
"self",
",",
"measurementStatus",
"=",
"None",
")",
":",
"if",
"measurementStatus",
"is",
"None",
":",
"return",
"self",
".",
"activeMeasurements",
"+",
"self",
".",
"completeMeasurements",
"+",
"self",
".",
"failedMeasurements",
"... | Gets all available measurements.
:param measurementStatus return only the measurements in the given state.
:return: | [
"Gets",
"all",
"available",
"measurements",
".",
":",
"param",
"measurementStatus",
"return",
"only",
"the",
"measurements",
"in",
"the",
"given",
"state",
".",
":",
"return",
":"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L479-L494 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.getMeasurement | def getMeasurement(self, measurementId, measurementStatus=None):
"""
Gets the measurement with the given id.
:param measurementId: the id.
:param measurementStatus: the status of the requested measurement.
:return: the matching measurement or none if it doesn't exist.
"""... | python | def getMeasurement(self, measurementId, measurementStatus=None):
"""
Gets the measurement with the given id.
:param measurementId: the id.
:param measurementStatus: the status of the requested measurement.
:return: the matching measurement or none if it doesn't exist.
"""... | [
"def",
"getMeasurement",
"(",
"self",
",",
"measurementId",
",",
"measurementStatus",
"=",
"None",
")",
":",
"return",
"next",
"(",
"(",
"x",
"for",
"x",
"in",
"self",
".",
"getMeasurements",
"(",
"measurementStatus",
")",
"if",
"x",
".",
"id",
"==",
"me... | Gets the measurement with the given id.
:param measurementId: the id.
:param measurementStatus: the status of the requested measurement.
:return: the matching measurement or none if it doesn't exist. | [
"Gets",
"the",
"measurement",
"with",
"the",
"given",
"id",
".",
":",
"param",
"measurementId",
":",
"the",
"id",
".",
":",
"param",
"measurementStatus",
":",
"the",
"status",
"of",
"the",
"requested",
"measurement",
".",
":",
"return",
":",
"the",
"matchi... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L496-L503 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.store | def store(self, measurement):
"""
Writes the measurement metadata to disk on completion.
:param activeMeasurement: the measurement that has completed.
:returns the persisted metadata.
"""
os.makedirs(self._getPathToMeasurementMetaDir(measurement.idAsPath), exist_ok=True)
... | python | def store(self, measurement):
"""
Writes the measurement metadata to disk on completion.
:param activeMeasurement: the measurement that has completed.
:returns the persisted metadata.
"""
os.makedirs(self._getPathToMeasurementMetaDir(measurement.idAsPath), exist_ok=True)
... | [
"def",
"store",
"(",
"self",
",",
"measurement",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"_getPathToMeasurementMetaDir",
"(",
"measurement",
".",
"idAsPath",
")",
",",
"exist_ok",
"=",
"True",
")",
"output",
"=",
"marshal",
"(",
"measurement",
"... | Writes the measurement metadata to disk on completion.
:param activeMeasurement: the measurement that has completed.
:returns the persisted metadata. | [
"Writes",
"the",
"measurement",
"metadata",
"to",
"disk",
"on",
"completion",
".",
":",
"param",
"activeMeasurement",
":",
"the",
"measurement",
"that",
"has",
"completed",
".",
":",
"returns",
"the",
"persisted",
"metadata",
"."
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L505-L515 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.load | def load(self, path):
"""
Loads a CompletedMeasurement from the path.á
:param path: the path at which the data is found.
:return: the measurement
"""
meta = self._loadMetaFromJson(path)
return CompleteMeasurement(meta, self.dataDir) if meta is not None else None | python | def load(self, path):
"""
Loads a CompletedMeasurement from the path.á
:param path: the path at which the data is found.
:return: the measurement
"""
meta = self._loadMetaFromJson(path)
return CompleteMeasurement(meta, self.dataDir) if meta is not None else None | [
"def",
"load",
"(",
"self",
",",
"path",
")",
":",
"meta",
"=",
"self",
".",
"_loadMetaFromJson",
"(",
"path",
")",
"return",
"CompleteMeasurement",
"(",
"meta",
",",
"self",
".",
"dataDir",
")",
"if",
"meta",
"is",
"not",
"None",
"else",
"None"
] | Loads a CompletedMeasurement from the path.á
:param path: the path at which the data is found.
:return: the measurement | [
"Loads",
"a",
"CompletedMeasurement",
"from",
"the",
"path",
".",
"á",
":",
"param",
"path",
":",
"the",
"path",
"at",
"which",
"the",
"data",
"is",
"found",
".",
":",
"return",
":",
"the",
"measurement"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L517-L524 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController._loadMetaFromJson | def _loadMetaFromJson(self, path):
"""
Reads the json meta into memory.
:return: the meta.
"""
try:
with (path / 'metadata.json').open() as infile:
return json.load(infile)
except FileNotFoundError:
logger.error('Metadata does not e... | python | def _loadMetaFromJson(self, path):
"""
Reads the json meta into memory.
:return: the meta.
"""
try:
with (path / 'metadata.json').open() as infile:
return json.load(infile)
except FileNotFoundError:
logger.error('Metadata does not e... | [
"def",
"_loadMetaFromJson",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"with",
"(",
"path",
"/",
"'metadata.json'",
")",
".",
"open",
"(",
")",
"as",
"infile",
":",
"return",
"json",
".",
"load",
"(",
"infile",
")",
"except",
"FileNotFoundError",
... | Reads the json meta into memory.
:return: the meta. | [
"Reads",
"the",
"json",
"meta",
"into",
"memory",
".",
":",
"return",
":",
"the",
"meta",
"."
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L526-L536 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController.editMeasurement | def editMeasurement(self, measurementId, data):
"""
Edits the specified measurement with the provided data.
:param measurementId: the measurement id.
:param data: the data to update.
:return: true if the measurement was edited
"""
oldMeasurement = self.getMeasur... | python | def editMeasurement(self, measurementId, data):
"""
Edits the specified measurement with the provided data.
:param measurementId: the measurement id.
:param data: the data to update.
:return: true if the measurement was edited
"""
oldMeasurement = self.getMeasur... | [
"def",
"editMeasurement",
"(",
"self",
",",
"measurementId",
",",
"data",
")",
":",
"oldMeasurement",
"=",
"self",
".",
"getMeasurement",
"(",
"measurementId",
",",
"measurementStatus",
"=",
"MeasurementStatus",
".",
"COMPLETE",
")",
"if",
"oldMeasurement",
":",
... | Edits the specified measurement with the provided data.
:param measurementId: the measurement id.
:param data: the data to update.
:return: true if the measurement was edited | [
"Edits",
"the",
"specified",
"measurement",
"with",
"the",
"provided",
"data",
".",
":",
"param",
"measurementId",
":",
"the",
"measurement",
"id",
".",
":",
"param",
"data",
":",
"the",
"data",
"to",
"update",
".",
":",
"return",
":",
"true",
"if",
"the... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L544-L601 | train |
3ll3d00d/vibe | backend/src/analyser/common/measurementcontroller.py | MeasurementController._filterCopy | def _filterCopy(self, dataFile, newStart, newEnd, newDataDir):
"""
Copies the data file to a new file in the tmp dir, filtering it according to newStart and newEnd and adjusting
the times as appropriate so it starts from 0.
:param dataFile: the input file.
:param newStart: the n... | python | def _filterCopy(self, dataFile, newStart, newEnd, newDataDir):
"""
Copies the data file to a new file in the tmp dir, filtering it according to newStart and newEnd and adjusting
the times as appropriate so it starts from 0.
:param dataFile: the input file.
:param newStart: the n... | [
"def",
"_filterCopy",
"(",
"self",
",",
"dataFile",
",",
"newStart",
",",
"newEnd",
",",
"newDataDir",
")",
":",
"import",
"csv",
"pathToData",
"=",
"os",
".",
"path",
".",
"split",
"(",
"dataFile",
")",
"dataFileName",
"=",
"pathToData",
"[",
"1",
"]",
... | Copies the data file to a new file in the tmp dir, filtering it according to newStart and newEnd and adjusting
the times as appropriate so it starts from 0.
:param dataFile: the input file.
:param newStart: the new start time.
:param newEnd: the new end time.
:param newDataDir: ... | [
"Copies",
"the",
"data",
"file",
"to",
"a",
"new",
"file",
"in",
"the",
"tmp",
"dir",
"filtering",
"it",
"according",
"to",
"newStart",
"and",
"newEnd",
"and",
"adjusting",
"the",
"times",
"as",
"appropriate",
"so",
"it",
"starts",
"from",
"0",
".",
":",... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/measurementcontroller.py#L603-L635 | train |
spacetelescope/stsci.tools | lib/stsci/tools/check_files.py | checkFiles | def checkFiles(filelist,ivmlist = None):
"""
- Converts waiver fits sciece and data quality files to MEF format
- Converts GEIS science and data quality files to MEF format
- Checks for stis association tables and splits them into single imsets
- Removes files with EXPTIME=0 and the corresponding iv... | python | def checkFiles(filelist,ivmlist = None):
"""
- Converts waiver fits sciece and data quality files to MEF format
- Converts GEIS science and data quality files to MEF format
- Checks for stis association tables and splits them into single imsets
- Removes files with EXPTIME=0 and the corresponding iv... | [
"def",
"checkFiles",
"(",
"filelist",
",",
"ivmlist",
"=",
"None",
")",
":",
"toclose",
"=",
"False",
"if",
"isinstance",
"(",
"filelist",
"[",
"0",
"]",
",",
"str",
")",
":",
"toclose",
"=",
"True",
"newfilelist",
",",
"ivmlist",
"=",
"checkFITSFormat",... | - Converts waiver fits sciece and data quality files to MEF format
- Converts GEIS science and data quality files to MEF format
- Checks for stis association tables and splits them into single imsets
- Removes files with EXPTIME=0 and the corresponding ivm files
- Removes files with NGOODPIX == 0 (to ex... | [
"-",
"Converts",
"waiver",
"fits",
"sciece",
"and",
"data",
"quality",
"files",
"to",
"MEF",
"format",
"-",
"Converts",
"GEIS",
"science",
"and",
"data",
"quality",
"files",
"to",
"MEF",
"format",
"-",
"Checks",
"for",
"stis",
"association",
"tables",
"and",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L20-L62 | train |
spacetelescope/stsci.tools | lib/stsci/tools/check_files.py | checkFITSFormat | def checkFITSFormat(filelist, ivmlist=None):
"""
This code will check whether or not files are GEIS or WAIVER FITS and
convert them to MEF if found. It also keeps the IVMLIST consistent with
the input filelist, in the case that some inputs get dropped during
the check/conversion.
"""
if ivml... | python | def checkFITSFormat(filelist, ivmlist=None):
"""
This code will check whether or not files are GEIS or WAIVER FITS and
convert them to MEF if found. It also keeps the IVMLIST consistent with
the input filelist, in the case that some inputs get dropped during
the check/conversion.
"""
if ivml... | [
"def",
"checkFITSFormat",
"(",
"filelist",
",",
"ivmlist",
"=",
"None",
")",
":",
"if",
"ivmlist",
"is",
"None",
":",
"ivmlist",
"=",
"[",
"None",
"for",
"l",
"in",
"filelist",
"]",
"sci_ivm",
"=",
"list",
"(",
"zip",
"(",
"filelist",
",",
"ivmlist",
... | This code will check whether or not files are GEIS or WAIVER FITS and
convert them to MEF if found. It also keeps the IVMLIST consistent with
the input filelist, in the case that some inputs get dropped during
the check/conversion. | [
"This",
"code",
"will",
"check",
"whether",
"or",
"not",
"files",
"are",
"GEIS",
"or",
"WAIVER",
"FITS",
"and",
"convert",
"them",
"to",
"MEF",
"if",
"found",
".",
"It",
"also",
"keeps",
"the",
"IVMLIST",
"consistent",
"with",
"the",
"input",
"filelist",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L64-L86 | train |
spacetelescope/stsci.tools | lib/stsci/tools/check_files.py | check_exptime | def check_exptime(filelist):
"""
Removes files with EXPTIME==0 from filelist.
"""
toclose = False
removed_files = []
for f in filelist:
if isinstance(f, str):
f = fits.open(f)
toclose = True
try:
exptime = f[0].header['EXPTIME']
except... | python | def check_exptime(filelist):
"""
Removes files with EXPTIME==0 from filelist.
"""
toclose = False
removed_files = []
for f in filelist:
if isinstance(f, str):
f = fits.open(f)
toclose = True
try:
exptime = f[0].header['EXPTIME']
except... | [
"def",
"check_exptime",
"(",
"filelist",
")",
":",
"toclose",
"=",
"False",
"removed_files",
"=",
"[",
"]",
"for",
"f",
"in",
"filelist",
":",
"if",
"isinstance",
"(",
"f",
",",
"str",
")",
":",
"f",
"=",
"fits",
".",
"open",
"(",
"f",
")",
"toclos... | Removes files with EXPTIME==0 from filelist. | [
"Removes",
"files",
"with",
"EXPTIME",
"==",
"0",
"from",
"filelist",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L139-L164 | train |
spacetelescope/stsci.tools | lib/stsci/tools/check_files.py | checkNGOODPIX | def checkNGOODPIX(filelist):
"""
Only for ACS, WFC3 and STIS, check NGOODPIX
If all pixels are 'bad' on all chips, exclude this image
from further processing.
Similar checks requiring comparing 'driz_sep_bits' against
WFPC2 c1f.fits arrays and NICMOS DQ arrays will need to be
done separately... | python | def checkNGOODPIX(filelist):
"""
Only for ACS, WFC3 and STIS, check NGOODPIX
If all pixels are 'bad' on all chips, exclude this image
from further processing.
Similar checks requiring comparing 'driz_sep_bits' against
WFPC2 c1f.fits arrays and NICMOS DQ arrays will need to be
done separately... | [
"def",
"checkNGOODPIX",
"(",
"filelist",
")",
":",
"toclose",
"=",
"False",
"removed_files",
"=",
"[",
"]",
"supported_instruments",
"=",
"[",
"'ACS'",
",",
"'STIS'",
",",
"'WFC3'",
"]",
"for",
"inputfile",
"in",
"filelist",
":",
"if",
"isinstance",
"(",
"... | Only for ACS, WFC3 and STIS, check NGOODPIX
If all pixels are 'bad' on all chips, exclude this image
from further processing.
Similar checks requiring comparing 'driz_sep_bits' against
WFPC2 c1f.fits arrays and NICMOS DQ arrays will need to be
done separately (and later). | [
"Only",
"for",
"ACS",
"WFC3",
"and",
"STIS",
"check",
"NGOODPIX",
"If",
"all",
"pixels",
"are",
"bad",
"on",
"all",
"chips",
"exclude",
"this",
"image",
"from",
"further",
"processing",
".",
"Similar",
"checks",
"requiring",
"comparing",
"driz_sep_bits",
"agai... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L166-L201 | train |
spacetelescope/stsci.tools | lib/stsci/tools/check_files.py | stisObsCount | def stisObsCount(input):
"""
Input: A stis multiextension file
Output: Number of stis science extensions in input
"""
count = 0
toclose = False
if isinstance(input, str):
input = fits.open(input)
toclose = True
for ext in input:
if 'extname' in ext.header:
... | python | def stisObsCount(input):
"""
Input: A stis multiextension file
Output: Number of stis science extensions in input
"""
count = 0
toclose = False
if isinstance(input, str):
input = fits.open(input)
toclose = True
for ext in input:
if 'extname' in ext.header:
... | [
"def",
"stisObsCount",
"(",
"input",
")",
":",
"count",
"=",
"0",
"toclose",
"=",
"False",
"if",
"isinstance",
"(",
"input",
",",
"str",
")",
":",
"input",
"=",
"fits",
".",
"open",
"(",
"input",
")",
"toclose",
"=",
"True",
"for",
"ext",
"in",
"in... | Input: A stis multiextension file
Output: Number of stis science extensions in input | [
"Input",
":",
"A",
"stis",
"multiextension",
"file",
"Output",
":",
"Number",
"of",
"stis",
"science",
"extensions",
"in",
"input"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L221-L237 | train |
spacetelescope/stsci.tools | lib/stsci/tools/check_files.py | splitStis | def splitStis(stisfile, sci_count):
"""
Split a STIS association file into multiple imset MEF files.
Split the corresponding spt file if present into single spt files.
If an spt file can't be split or is missing a Warning is printed.
Returns
-------
names: list
a list with the name... | python | def splitStis(stisfile, sci_count):
"""
Split a STIS association file into multiple imset MEF files.
Split the corresponding spt file if present into single spt files.
If an spt file can't be split or is missing a Warning is printed.
Returns
-------
names: list
a list with the name... | [
"def",
"splitStis",
"(",
"stisfile",
",",
"sci_count",
")",
":",
"newfiles",
"=",
"[",
"]",
"toclose",
"=",
"False",
"if",
"isinstance",
"(",
"stisfile",
",",
"str",
")",
":",
"f",
"=",
"fits",
".",
"open",
"(",
"stisfile",
")",
"toclose",
"=",
"True... | Split a STIS association file into multiple imset MEF files.
Split the corresponding spt file if present into single spt files.
If an spt file can't be split or is missing a Warning is printed.
Returns
-------
names: list
a list with the names of the new flt files. | [
"Split",
"a",
"STIS",
"association",
"file",
"into",
"multiple",
"imset",
"MEF",
"files",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L239-L340 | train |
spacetelescope/stsci.tools | lib/stsci/tools/check_files.py | stisExt2PrimKw | def stisExt2PrimKw(stisfiles):
"""
Several kw which are usually in the primary header
are in the extension header for STIS. They are copied to
the primary header for convenience.
List if kw:
'DATE-OBS', 'EXPEND', 'EXPSTART', 'EXPTIME'
"""
kw_list = ['DATE-OBS', 'EXPE... | python | def stisExt2PrimKw(stisfiles):
"""
Several kw which are usually in the primary header
are in the extension header for STIS. They are copied to
the primary header for convenience.
List if kw:
'DATE-OBS', 'EXPEND', 'EXPSTART', 'EXPTIME'
"""
kw_list = ['DATE-OBS', 'EXPE... | [
"def",
"stisExt2PrimKw",
"(",
"stisfiles",
")",
":",
"kw_list",
"=",
"[",
"'DATE-OBS'",
",",
"'EXPEND'",
",",
"'EXPSTART'",
",",
"'EXPTIME'",
"]",
"for",
"sfile",
"in",
"stisfiles",
":",
"toclose",
"=",
"False",
"if",
"isinstance",
"(",
"sfile",
",",
"str"... | Several kw which are usually in the primary header
are in the extension header for STIS. They are copied to
the primary header for convenience.
List if kw:
'DATE-OBS', 'EXPEND', 'EXPSTART', 'EXPTIME' | [
"Several",
"kw",
"which",
"are",
"usually",
"in",
"the",
"primary",
"header",
"are",
"in",
"the",
"extension",
"header",
"for",
"STIS",
".",
"They",
"are",
"copied",
"to",
"the",
"primary",
"header",
"for",
"convenience",
".",
"List",
"if",
"kw",
":",
"D... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L342-L365 | train |
spacetelescope/stsci.tools | lib/stsci/tools/check_files.py | convert2fits | def convert2fits(sci_ivm):
"""
Checks if a file is in WAIVER of GEIS format and converts it to MEF
"""
removed_files = []
translated_names = []
newivmlist = []
for file in sci_ivm:
#find out what the input is
# if science file is not found on disk, add it to removed_files fo... | python | def convert2fits(sci_ivm):
"""
Checks if a file is in WAIVER of GEIS format and converts it to MEF
"""
removed_files = []
translated_names = []
newivmlist = []
for file in sci_ivm:
#find out what the input is
# if science file is not found on disk, add it to removed_files fo... | [
"def",
"convert2fits",
"(",
"sci_ivm",
")",
":",
"removed_files",
"=",
"[",
"]",
"translated_names",
"=",
"[",
"]",
"newivmlist",
"=",
"[",
"]",
"for",
"file",
"in",
"sci_ivm",
":",
"#find out what the input is",
"# if science file is not found on disk, add it to remo... | Checks if a file is in WAIVER of GEIS format and converts it to MEF | [
"Checks",
"if",
"a",
"file",
"is",
"in",
"WAIVER",
"of",
"GEIS",
"format",
"and",
"converts",
"it",
"to",
"MEF"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L408-L452 | train |
spacetelescope/stsci.tools | lib/stsci/tools/check_files.py | waiver2mef | def waiver2mef(sciname, newname=None, convert_dq=True, writefits=True):
"""
Converts a GEIS science file and its corresponding
data quality file (if present) to MEF format
Writes out both files to disk.
Returns the new name of the science image.
"""
if isinstance(sciname, fits.HDUList):
... | python | def waiver2mef(sciname, newname=None, convert_dq=True, writefits=True):
"""
Converts a GEIS science file and its corresponding
data quality file (if present) to MEF format
Writes out both files to disk.
Returns the new name of the science image.
"""
if isinstance(sciname, fits.HDUList):
... | [
"def",
"waiver2mef",
"(",
"sciname",
",",
"newname",
"=",
"None",
",",
"convert_dq",
"=",
"True",
",",
"writefits",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"sciname",
",",
"fits",
".",
"HDUList",
")",
":",
"filename",
"=",
"sciname",
".",
"file... | Converts a GEIS science file and its corresponding
data quality file (if present) to MEF format
Writes out both files to disk.
Returns the new name of the science image. | [
"Converts",
"a",
"GEIS",
"science",
"file",
"and",
"its",
"corresponding",
"data",
"quality",
"file",
"(",
"if",
"present",
")",
"to",
"MEF",
"format",
"Writes",
"out",
"both",
"files",
"to",
"disk",
".",
"Returns",
"the",
"new",
"name",
"of",
"the",
"sc... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L454-L510 | train |
spacetelescope/stsci.tools | lib/stsci/tools/check_files.py | geis2mef | def geis2mef(sciname, convert_dq=True):
"""
Converts a GEIS science file and its corresponding
data quality file (if present) to MEF format
Writes out both files to disk.
Returns the new name of the science image.
"""
clobber = True
mode = 'update'
memmap = True
# Input was speci... | python | def geis2mef(sciname, convert_dq=True):
"""
Converts a GEIS science file and its corresponding
data quality file (if present) to MEF format
Writes out both files to disk.
Returns the new name of the science image.
"""
clobber = True
mode = 'update'
memmap = True
# Input was speci... | [
"def",
"geis2mef",
"(",
"sciname",
",",
"convert_dq",
"=",
"True",
")",
":",
"clobber",
"=",
"True",
"mode",
"=",
"'update'",
"memmap",
"=",
"True",
"# Input was specified as a GEIS image, but no FITS copy",
"# exists. Read it in with 'readgeis' and make a copy",
"# then o... | Converts a GEIS science file and its corresponding
data quality file (if present) to MEF format
Writes out both files to disk.
Returns the new name of the science image. | [
"Converts",
"a",
"GEIS",
"science",
"file",
"and",
"its",
"corresponding",
"data",
"quality",
"file",
"(",
"if",
"present",
")",
"to",
"MEF",
"format",
"Writes",
"out",
"both",
"files",
"to",
"disk",
".",
"Returns",
"the",
"new",
"name",
"of",
"the",
"sc... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/check_files.py#L513-L568 | train |
ianepperson/pyredminews | redmine/redmine.py | Issue.journals | def journals(self):
"""
Retrieve journals attribute for this very Issue
"""
try:
target = self._item_path
json_data = self._redmine.get(target % str(self.id),
parms={'include': 'journals'})
data = self._redmine... | python | def journals(self):
"""
Retrieve journals attribute for this very Issue
"""
try:
target = self._item_path
json_data = self._redmine.get(target % str(self.id),
parms={'include': 'journals'})
data = self._redmine... | [
"def",
"journals",
"(",
"self",
")",
":",
"try",
":",
"target",
"=",
"self",
".",
"_item_path",
"json_data",
"=",
"self",
".",
"_redmine",
".",
"get",
"(",
"target",
"%",
"str",
"(",
"self",
".",
"id",
")",
",",
"parms",
"=",
"{",
"'include'",
":",... | Retrieve journals attribute for this very Issue | [
"Retrieve",
"journals",
"attribute",
"for",
"this",
"very",
"Issue"
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L239-L256 | train |
ianepperson/pyredminews | redmine/redmine.py | Issue.save | def save(self, notes=None):
'''Save all changes back to Redmine with optional notes.'''
# Capture the notes if given
if notes:
self._changes['notes'] = notes
# Call the base-class save function
super(Issue, self).save() | python | def save(self, notes=None):
'''Save all changes back to Redmine with optional notes.'''
# Capture the notes if given
if notes:
self._changes['notes'] = notes
# Call the base-class save function
super(Issue, self).save() | [
"def",
"save",
"(",
"self",
",",
"notes",
"=",
"None",
")",
":",
"# Capture the notes if given",
"if",
"notes",
":",
"self",
".",
"_changes",
"[",
"'notes'",
"]",
"=",
"notes",
"# Call the base-class save function",
"super",
"(",
"Issue",
",",
"self",
")",
"... | Save all changes back to Redmine with optional notes. | [
"Save",
"all",
"changes",
"back",
"to",
"Redmine",
"with",
"optional",
"notes",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L258-L265 | train |
ianepperson/pyredminews | redmine/redmine.py | Issue.set_status | def set_status(self, new_status, notes=None):
'''Save all changes and set to the given new_status'''
self.status_id = new_status
try:
self.status['id'] = self.status_id
# We don't have the id to name mapping, so blank the name
self.status['name'] = None
... | python | def set_status(self, new_status, notes=None):
'''Save all changes and set to the given new_status'''
self.status_id = new_status
try:
self.status['id'] = self.status_id
# We don't have the id to name mapping, so blank the name
self.status['name'] = None
... | [
"def",
"set_status",
"(",
"self",
",",
"new_status",
",",
"notes",
"=",
"None",
")",
":",
"self",
".",
"status_id",
"=",
"new_status",
"try",
":",
"self",
".",
"status",
"[",
"'id'",
"]",
"=",
"self",
".",
"status_id",
"# We don't have the id to name mapping... | Save all changes and set to the given new_status | [
"Save",
"all",
"changes",
"and",
"set",
"to",
"the",
"given",
"new_status"
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L267-L276 | train |
ianepperson/pyredminews | redmine/redmine.py | Issue.resolve | def resolve(self, notes=None):
'''Save all changes and resolve this issue'''
self.set_status(self._redmine.ISSUE_STATUS_ID_RESOLVED, notes=notes) | python | def resolve(self, notes=None):
'''Save all changes and resolve this issue'''
self.set_status(self._redmine.ISSUE_STATUS_ID_RESOLVED, notes=notes) | [
"def",
"resolve",
"(",
"self",
",",
"notes",
"=",
"None",
")",
":",
"self",
".",
"set_status",
"(",
"self",
".",
"_redmine",
".",
"ISSUE_STATUS_ID_RESOLVED",
",",
"notes",
"=",
"notes",
")"
] | Save all changes and resolve this issue | [
"Save",
"all",
"changes",
"and",
"resolve",
"this",
"issue"
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L278-L280 | train |
ianepperson/pyredminews | redmine/redmine.py | Issue.close | def close(self, notes=None):
'''Save all changes and close this issue'''
self.set_status(self._redmine.ISSUE_STATUS_ID_CLOSED, notes=notes) | python | def close(self, notes=None):
'''Save all changes and close this issue'''
self.set_status(self._redmine.ISSUE_STATUS_ID_CLOSED, notes=notes) | [
"def",
"close",
"(",
"self",
",",
"notes",
"=",
"None",
")",
":",
"self",
".",
"set_status",
"(",
"self",
".",
"_redmine",
".",
"ISSUE_STATUS_ID_CLOSED",
",",
"notes",
"=",
"notes",
")"
] | Save all changes and close this issue | [
"Save",
"all",
"changes",
"and",
"close",
"this",
"issue"
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L282-L284 | train |
ianepperson/pyredminews | redmine/redmine.py | Redmine_Wiki_Pages_Manager._objectify | def _objectify(self, json_data=None, data={}):
'''Return an object derived from the given json data.'''
if json_data:
# Parse the data
try:
data = json.loads(json_data)
except ValueError:
# If parsing failed, then raise the string which... | python | def _objectify(self, json_data=None, data={}):
'''Return an object derived from the given json data.'''
if json_data:
# Parse the data
try:
data = json.loads(json_data)
except ValueError:
# If parsing failed, then raise the string which... | [
"def",
"_objectify",
"(",
"self",
",",
"json_data",
"=",
"None",
",",
"data",
"=",
"{",
"}",
")",
":",
"if",
"json_data",
":",
"# Parse the data",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"json_data",
")",
"except",
"ValueError",
":",
"# If ... | Return an object derived from the given json data. | [
"Return",
"an",
"object",
"derived",
"from",
"the",
"given",
"json",
"data",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L610-L635 | train |
ianepperson/pyredminews | redmine/redmine.py | Redmine_Wiki_Pages_Manager.new | def new(self, page_name, **dict):
'''
Create a new item with the provided dict information
at the given page_name. Returns the new item.
As of version 2.2 of Redmine, this doesn't seem to function.
'''
self._item_new_path = '/projects/%s/wiki/%s.json' % \
(s... | python | def new(self, page_name, **dict):
'''
Create a new item with the provided dict information
at the given page_name. Returns the new item.
As of version 2.2 of Redmine, this doesn't seem to function.
'''
self._item_new_path = '/projects/%s/wiki/%s.json' % \
(s... | [
"def",
"new",
"(",
"self",
",",
"page_name",
",",
"*",
"*",
"dict",
")",
":",
"self",
".",
"_item_new_path",
"=",
"'/projects/%s/wiki/%s.json'",
"%",
"(",
"self",
".",
"_project",
".",
"identifier",
",",
"page_name",
")",
"# Call the base class new method",
"r... | Create a new item with the provided dict information
at the given page_name. Returns the new item.
As of version 2.2 of Redmine, this doesn't seem to function. | [
"Create",
"a",
"new",
"item",
"with",
"the",
"provided",
"dict",
"information",
"at",
"the",
"given",
"page_name",
".",
"Returns",
"the",
"new",
"item",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L638-L648 | train |
ianepperson/pyredminews | redmine/redmine.py | Redmine._set_version | def _set_version(self, version):
'''
Set up this object based on the capabilities of the
known versions of Redmine
'''
# Store the version we are evaluating
self.version = version or None
# To evaluate the version capabilities,
# assume the best-case if no... | python | def _set_version(self, version):
'''
Set up this object based on the capabilities of the
known versions of Redmine
'''
# Store the version we are evaluating
self.version = version or None
# To evaluate the version capabilities,
# assume the best-case if no... | [
"def",
"_set_version",
"(",
"self",
",",
"version",
")",
":",
"# Store the version we are evaluating",
"self",
".",
"version",
"=",
"version",
"or",
"None",
"# To evaluate the version capabilities,",
"# assume the best-case if no version is provided.",
"version_check",
"=",
"... | Set up this object based on the capabilities of the
known versions of Redmine | [
"Set",
"up",
"this",
"object",
"based",
"on",
"the",
"capabilities",
"of",
"the",
"known",
"versions",
"of",
"Redmine"
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine.py#L744-L783 | train |
3ll3d00d/vibe | backend/src/analyser/common/config.py | loadTargetState | def loadTargetState(targetStateConfig, existingTargetState=None):
"""
extracts a new TargetState object from the specified configuration
:param targetStateConfig: the config dict.
:param existingTargetState: the existing state
:return:
"""
from analyser.common.targetstatecontroller import Ta... | python | def loadTargetState(targetStateConfig, existingTargetState=None):
"""
extracts a new TargetState object from the specified configuration
:param targetStateConfig: the config dict.
:param existingTargetState: the existing state
:return:
"""
from analyser.common.targetstatecontroller import Ta... | [
"def",
"loadTargetState",
"(",
"targetStateConfig",
",",
"existingTargetState",
"=",
"None",
")",
":",
"from",
"analyser",
".",
"common",
".",
"targetstatecontroller",
"import",
"TargetState",
"targetState",
"=",
"TargetState",
"(",
")",
"if",
"existingTargetState",
... | extracts a new TargetState object from the specified configuration
:param targetStateConfig: the config dict.
:param existingTargetState: the existing state
:return: | [
"extracts",
"a",
"new",
"TargetState",
"object",
"from",
"the",
"specified",
"configuration",
":",
"param",
"targetStateConfig",
":",
"the",
"config",
"dict",
".",
":",
"param",
"existingTargetState",
":",
"the",
"existing",
"state",
":",
"return",
":"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/config.py#L58-L87 | train |
spacetelescope/stsci.tools | lib/stsci/tools/bitmask.py | interpret_bit_flags | def interpret_bit_flags(bit_flags, flip_bits=None):
"""
Converts input bit flags to a single integer value (bitmask) or `None`.
When input is a list of flags (either a Python list of integer flags or a
sting of comma- or '+'-separated list of flags), the returned bitmask
is obtained by summing inpu... | python | def interpret_bit_flags(bit_flags, flip_bits=None):
"""
Converts input bit flags to a single integer value (bitmask) or `None`.
When input is a list of flags (either a Python list of integer flags or a
sting of comma- or '+'-separated list of flags), the returned bitmask
is obtained by summing inpu... | [
"def",
"interpret_bit_flags",
"(",
"bit_flags",
",",
"flip_bits",
"=",
"None",
")",
":",
"has_flip_bits",
"=",
"flip_bits",
"is",
"not",
"None",
"flip_bits",
"=",
"bool",
"(",
"flip_bits",
")",
"allow_non_flags",
"=",
"False",
"if",
"_is_int",
"(",
"bit_flags"... | Converts input bit flags to a single integer value (bitmask) or `None`.
When input is a list of flags (either a Python list of integer flags or a
sting of comma- or '+'-separated list of flags), the returned bitmask
is obtained by summing input flags.
.. note::
In order to flip the bits of the... | [
"Converts",
"input",
"bit",
"flags",
"to",
"a",
"single",
"integer",
"value",
"(",
"bitmask",
")",
"or",
"None",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/bitmask.py#L89-L242 | train |
spacetelescope/stsci.tools | lib/stsci/tools/bitmask.py | bitfield_to_boolean_mask | def bitfield_to_boolean_mask(bitfield, ignore_flags=0, flip_bits=None,
good_mask_value=True, dtype=np.bool_):
"""
bitfield_to_boolean_mask(bitfield, ignore_flags=None, flip_bits=None, \
good_mask_value=True, dtype=numpy.bool\_)
Converts an array of bit fields to a boolean (or in... | python | def bitfield_to_boolean_mask(bitfield, ignore_flags=0, flip_bits=None,
good_mask_value=True, dtype=np.bool_):
"""
bitfield_to_boolean_mask(bitfield, ignore_flags=None, flip_bits=None, \
good_mask_value=True, dtype=numpy.bool\_)
Converts an array of bit fields to a boolean (or in... | [
"def",
"bitfield_to_boolean_mask",
"(",
"bitfield",
",",
"ignore_flags",
"=",
"0",
",",
"flip_bits",
"=",
"None",
",",
"good_mask_value",
"=",
"True",
",",
"dtype",
"=",
"np",
".",
"bool_",
")",
":",
"bitfield",
"=",
"np",
".",
"asarray",
"(",
"bitfield",
... | bitfield_to_boolean_mask(bitfield, ignore_flags=None, flip_bits=None, \
good_mask_value=True, dtype=numpy.bool\_)
Converts an array of bit fields to a boolean (or integer) mask array
according to a bitmask constructed from the supplied bit flags (see
``ignore_flags`` parameter).
This function is partic... | [
"bitfield_to_boolean_mask",
"(",
"bitfield",
"ignore_flags",
"=",
"None",
"flip_bits",
"=",
"None",
"\\",
"good_mask_value",
"=",
"True",
"dtype",
"=",
"numpy",
".",
"bool",
"\\",
"_",
")",
"Converts",
"an",
"array",
"of",
"bit",
"fields",
"to",
"a",
"boolea... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/bitmask.py#L245-L438 | train |
spacetelescope/stsci.tools | lib/stsci/tools/bitmask.py | interpret_bits_value | def interpret_bits_value(val):
"""
Converts input bits value from string to a single integer value or None.
If a comma- or '+'-separated set of values are provided, they are summed.
.. note::
In order to flip the bits of the final result (after summation),
for input of `str` type, prepe... | python | def interpret_bits_value(val):
"""
Converts input bits value from string to a single integer value or None.
If a comma- or '+'-separated set of values are provided, they are summed.
.. note::
In order to flip the bits of the final result (after summation),
for input of `str` type, prepe... | [
"def",
"interpret_bits_value",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"int",
")",
"or",
"val",
"is",
"None",
":",
"return",
"val",
"else",
":",
"val",
"=",
"str",
"(",
"val",
")",
".",
"strip",
"(",
")",
"if",
"val",
".",
"sta... | Converts input bits value from string to a single integer value or None.
If a comma- or '+'-separated set of values are provided, they are summed.
.. note::
In order to flip the bits of the final result (after summation),
for input of `str` type, prepend '~' to the input string. '~' must
... | [
"Converts",
"input",
"bits",
"value",
"from",
"string",
"to",
"a",
"single",
"integer",
"value",
"or",
"None",
".",
"If",
"a",
"comma",
"-",
"or",
"+",
"-",
"separated",
"set",
"of",
"values",
"are",
"provided",
"they",
"are",
"summed",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/bitmask.py#L443-L509 | train |
spacetelescope/stsci.tools | lib/stsci/tools/bitmask.py | bitmask2mask | def bitmask2mask(bitmask, ignore_bits, good_mask_value=1, dtype=np.bool_):
"""
bitmask2mask(bitmask, ignore_bits, good_mask_value=1, dtype=numpy.bool\_)
Interprets an array of bit flags and converts it to a "binary" mask array.
This function is particularly useful to convert data quality arrays to
b... | python | def bitmask2mask(bitmask, ignore_bits, good_mask_value=1, dtype=np.bool_):
"""
bitmask2mask(bitmask, ignore_bits, good_mask_value=1, dtype=numpy.bool\_)
Interprets an array of bit flags and converts it to a "binary" mask array.
This function is particularly useful to convert data quality arrays to
b... | [
"def",
"bitmask2mask",
"(",
"bitmask",
",",
"ignore_bits",
",",
"good_mask_value",
"=",
"1",
",",
"dtype",
"=",
"np",
".",
"bool_",
")",
":",
"if",
"not",
"np",
".",
"issubdtype",
"(",
"bitmask",
".",
"dtype",
",",
"np",
".",
"integer",
")",
":",
"ra... | bitmask2mask(bitmask, ignore_bits, good_mask_value=1, dtype=numpy.bool\_)
Interprets an array of bit flags and converts it to a "binary" mask array.
This function is particularly useful to convert data quality arrays to
binary masks.
Parameters
----------
bitmask : numpy.ndarray
An arra... | [
"bitmask2mask",
"(",
"bitmask",
"ignore_bits",
"good_mask_value",
"=",
"1",
"dtype",
"=",
"numpy",
".",
"bool",
"\\",
"_",
")",
"Interprets",
"an",
"array",
"of",
"bit",
"flags",
"and",
"converts",
"it",
"to",
"a",
"binary",
"mask",
"array",
".",
"This",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/bitmask.py#L514-L623 | train |
titilambert/pyhydroquebec | pyhydroquebec/output.py | output_text | def output_text(account, all_data, show_hourly=False):
"""Format data to get a readable output."""
print("""
#################################
# Hydro Quebec data for account #
# {}
#################################""".format(account))
for contract, data in all_data.items():
data['contract'] = contr... | python | def output_text(account, all_data, show_hourly=False):
"""Format data to get a readable output."""
print("""
#################################
# Hydro Quebec data for account #
# {}
#################################""".format(account))
for contract, data in all_data.items():
data['contract'] = contr... | [
"def",
"output_text",
"(",
"account",
",",
"all_data",
",",
"show_hourly",
"=",
"False",
")",
":",
"print",
"(",
"\"\"\"\n#################################\n# Hydro Quebec data for account #\n# {}\n#################################\"\"\"",
".",
"format",
"(",
"account",
")",
... | Format data to get a readable output. | [
"Format",
"data",
"to",
"get",
"a",
"readable",
"output",
"."
] | 4ea1374a63944413889c147d91961eda0605d4fd | https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/output.py#L14-L91 | train |
titilambert/pyhydroquebec | pyhydroquebec/output.py | output_influx | def output_influx(data):
"""Print data using influxDB format."""
for contract in data:
# Pop yesterdays data
yesterday_data = data[contract]['yesterday_hourly_consumption']
del data[contract]['yesterday_hourly_consumption']
# Print general data
out = "pyhydroquebec,cont... | python | def output_influx(data):
"""Print data using influxDB format."""
for contract in data:
# Pop yesterdays data
yesterday_data = data[contract]['yesterday_hourly_consumption']
del data[contract]['yesterday_hourly_consumption']
# Print general data
out = "pyhydroquebec,cont... | [
"def",
"output_influx",
"(",
"data",
")",
":",
"for",
"contract",
"in",
"data",
":",
"# Pop yesterdays data",
"yesterday_data",
"=",
"data",
"[",
"contract",
"]",
"[",
"'yesterday_hourly_consumption'",
"]",
"del",
"data",
"[",
"contract",
"]",
"[",
"'yesterday_h... | Print data using influxDB format. | [
"Print",
"data",
"using",
"influxDB",
"format",
"."
] | 4ea1374a63944413889c147d91961eda0605d4fd | https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/output.py#L94-L130 | train |
spacetelescope/stsci.tools | lib/stsci/tools/capable.py | which_darwin_linkage | def which_darwin_linkage(force_otool_check=False):
""" Convenience function. Returns one of ('x11', 'aqua') in answer to the
question of whether this is an X11-linked Python/tkinter, or a natively
built (framework, Aqua) one. This is only for OSX.
This relies on the assumption that on OSX, PyObjC is i... | python | def which_darwin_linkage(force_otool_check=False):
""" Convenience function. Returns one of ('x11', 'aqua') in answer to the
question of whether this is an X11-linked Python/tkinter, or a natively
built (framework, Aqua) one. This is only for OSX.
This relies on the assumption that on OSX, PyObjC is i... | [
"def",
"which_darwin_linkage",
"(",
"force_otool_check",
"=",
"False",
")",
":",
"# sanity check",
"assert",
"sys",
".",
"platform",
"==",
"'darwin'",
",",
"'Incorrect usage, not on OSX'",
"# If not forced to run otool, then make some quick and dirty",
"# simple checks/assumption... | Convenience function. Returns one of ('x11', 'aqua') in answer to the
question of whether this is an X11-linked Python/tkinter, or a natively
built (framework, Aqua) one. This is only for OSX.
This relies on the assumption that on OSX, PyObjC is installed
in the Framework builds of Python. If it does... | [
"Convenience",
"function",
".",
"Returns",
"one",
"of",
"(",
"x11",
"aqua",
")",
"in",
"answer",
"to",
"the",
"question",
"of",
"whether",
"this",
"is",
"an",
"X11",
"-",
"linked",
"Python",
"/",
"tkinter",
"or",
"a",
"natively",
"built",
"(",
"framework... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/capable.py#L26-L86 | train |
spacetelescope/stsci.tools | lib/stsci/tools/capable.py | get_dc_owner | def get_dc_owner(raises, mask_if_self):
""" Convenience function to return owner of /dev/console.
If raises is True, this raises an exception on any error.
If not, it returns any error string as the owner name.
If owner is self, and if mask_if_self, returns "<self>"."""
try:
from pwd import ... | python | def get_dc_owner(raises, mask_if_self):
""" Convenience function to return owner of /dev/console.
If raises is True, this raises an exception on any error.
If not, it returns any error string as the owner name.
If owner is self, and if mask_if_self, returns "<self>"."""
try:
from pwd import ... | [
"def",
"get_dc_owner",
"(",
"raises",
",",
"mask_if_self",
")",
":",
"try",
":",
"from",
"pwd",
"import",
"getpwuid",
"owner_uid",
"=",
"os",
".",
"stat",
"(",
"'/dev/console'",
")",
".",
"st_uid",
"self_uid",
"=",
"os",
".",
"getuid",
"(",
")",
"if",
... | Convenience function to return owner of /dev/console.
If raises is True, this raises an exception on any error.
If not, it returns any error string as the owner name.
If owner is self, and if mask_if_self, returns "<self>". | [
"Convenience",
"function",
"to",
"return",
"owner",
"of",
"/",
"dev",
"/",
"console",
".",
"If",
"raises",
"is",
"True",
"this",
"raises",
"an",
"exception",
"on",
"any",
"error",
".",
"If",
"not",
"it",
"returns",
"any",
"error",
"string",
"as",
"the",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/capable.py#L89-L106 | train |
fitnr/convertdate | convertdate/bahai.py | to_jd | def to_jd(year, month, day):
'''Determine Julian day from Bahai date'''
gy = year - 1 + EPOCH_GREGORIAN_YEAR
if month != 20:
m = 0
else:
if isleap(gy + 1):
m = -14
else:
m = -15
return gregorian.to_jd(gy, 3, 20) + (19 * (month - 1)) + m + day | python | def to_jd(year, month, day):
'''Determine Julian day from Bahai date'''
gy = year - 1 + EPOCH_GREGORIAN_YEAR
if month != 20:
m = 0
else:
if isleap(gy + 1):
m = -14
else:
m = -15
return gregorian.to_jd(gy, 3, 20) + (19 * (month - 1)) + m + day | [
"def",
"to_jd",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"gy",
"=",
"year",
"-",
"1",
"+",
"EPOCH_GREGORIAN_YEAR",
"if",
"month",
"!=",
"20",
":",
"m",
"=",
"0",
"else",
":",
"if",
"isleap",
"(",
"gy",
"+",
"1",
")",
":",
"m",
"=",
"-... | Determine Julian day from Bahai date | [
"Determine",
"Julian",
"day",
"from",
"Bahai",
"date"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/bahai.py#L29-L40 | train |
fitnr/convertdate | convertdate/bahai.py | from_jd | def from_jd(jd):
'''Calculate Bahai date from Julian day'''
jd = trunc(jd) + 0.5
g = gregorian.from_jd(jd)
gy = g[0]
bstarty = EPOCH_GREGORIAN_YEAR
if jd <= gregorian.to_jd(gy, 3, 20):
x = 1
else:
x = 0
# verify this next line...
bys = gy - (bstarty + (((gregorian.... | python | def from_jd(jd):
'''Calculate Bahai date from Julian day'''
jd = trunc(jd) + 0.5
g = gregorian.from_jd(jd)
gy = g[0]
bstarty = EPOCH_GREGORIAN_YEAR
if jd <= gregorian.to_jd(gy, 3, 20):
x = 1
else:
x = 0
# verify this next line...
bys = gy - (bstarty + (((gregorian.... | [
"def",
"from_jd",
"(",
"jd",
")",
":",
"jd",
"=",
"trunc",
"(",
"jd",
")",
"+",
"0.5",
"g",
"=",
"gregorian",
".",
"from_jd",
"(",
"jd",
")",
"gy",
"=",
"g",
"[",
"0",
"]",
"bstarty",
"=",
"EPOCH_GREGORIAN_YEAR",
"if",
"jd",
"<=",
"gregorian",
".... | Calculate Bahai date from Julian day | [
"Calculate",
"Bahai",
"date",
"from",
"Julian",
"day"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/bahai.py#L43-L69 | train |
fitnr/convertdate | convertdate/mayan.py | to_jd | def to_jd(baktun, katun, tun, uinal, kin):
'''Determine Julian day from Mayan long count'''
return EPOCH + (baktun * 144000) + (katun * 7200) + (tun * 360) + (uinal * 20) + kin | python | def to_jd(baktun, katun, tun, uinal, kin):
'''Determine Julian day from Mayan long count'''
return EPOCH + (baktun * 144000) + (katun * 7200) + (tun * 360) + (uinal * 20) + kin | [
"def",
"to_jd",
"(",
"baktun",
",",
"katun",
",",
"tun",
",",
"uinal",
",",
"kin",
")",
":",
"return",
"EPOCH",
"+",
"(",
"baktun",
"*",
"144000",
")",
"+",
"(",
"katun",
"*",
"7200",
")",
"+",
"(",
"tun",
"*",
"360",
")",
"+",
"(",
"uinal",
... | Determine Julian day from Mayan long count | [
"Determine",
"Julian",
"day",
"from",
"Mayan",
"long",
"count"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L36-L38 | train |
fitnr/convertdate | convertdate/mayan.py | from_jd | def from_jd(jd):
'''Calculate Mayan long count from Julian day'''
d = jd - EPOCH
baktun = trunc(d / 144000)
d = (d % 144000)
katun = trunc(d / 7200)
d = (d % 7200)
tun = trunc(d / 360)
d = (d % 360)
uinal = trunc(d / 20)
kin = int((d % 20))
return (baktun, katun, tun, uinal,... | python | def from_jd(jd):
'''Calculate Mayan long count from Julian day'''
d = jd - EPOCH
baktun = trunc(d / 144000)
d = (d % 144000)
katun = trunc(d / 7200)
d = (d % 7200)
tun = trunc(d / 360)
d = (d % 360)
uinal = trunc(d / 20)
kin = int((d % 20))
return (baktun, katun, tun, uinal,... | [
"def",
"from_jd",
"(",
"jd",
")",
":",
"d",
"=",
"jd",
"-",
"EPOCH",
"baktun",
"=",
"trunc",
"(",
"d",
"/",
"144000",
")",
"d",
"=",
"(",
"d",
"%",
"144000",
")",
"katun",
"=",
"trunc",
"(",
"d",
"/",
"7200",
")",
"d",
"=",
"(",
"d",
"%",
... | Calculate Mayan long count from Julian day | [
"Calculate",
"Mayan",
"long",
"count",
"from",
"Julian",
"day"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L41-L53 | train |
fitnr/convertdate | convertdate/mayan.py | to_haab | def to_haab(jd):
'''Determine Mayan Haab "month" and day from Julian day'''
# Number of days since the start of the long count
lcount = trunc(jd) + 0.5 - EPOCH
# Long Count begins 348 days after the start of the cycle
day = (lcount + 348) % 365
count = day % 20
month = trunc(day / 20)
... | python | def to_haab(jd):
'''Determine Mayan Haab "month" and day from Julian day'''
# Number of days since the start of the long count
lcount = trunc(jd) + 0.5 - EPOCH
# Long Count begins 348 days after the start of the cycle
day = (lcount + 348) % 365
count = day % 20
month = trunc(day / 20)
... | [
"def",
"to_haab",
"(",
"jd",
")",
":",
"# Number of days since the start of the long count",
"lcount",
"=",
"trunc",
"(",
"jd",
")",
"+",
"0.5",
"-",
"EPOCH",
"# Long Count begins 348 days after the start of the cycle",
"day",
"=",
"(",
"lcount",
"+",
"348",
")",
"%... | Determine Mayan Haab "month" and day from Julian day | [
"Determine",
"Mayan",
"Haab",
"month",
"and",
"day",
"from",
"Julian",
"day"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L66-L76 | train |
fitnr/convertdate | convertdate/mayan.py | to_tzolkin | def to_tzolkin(jd):
'''Determine Mayan Tzolkin "month" and day from Julian day'''
lcount = trunc(jd) + 0.5 - EPOCH
day = amod(lcount + 4, 13)
name = amod(lcount + 20, 20)
return int(day), TZOLKIN_NAMES[int(name) - 1] | python | def to_tzolkin(jd):
'''Determine Mayan Tzolkin "month" and day from Julian day'''
lcount = trunc(jd) + 0.5 - EPOCH
day = amod(lcount + 4, 13)
name = amod(lcount + 20, 20)
return int(day), TZOLKIN_NAMES[int(name) - 1] | [
"def",
"to_tzolkin",
"(",
"jd",
")",
":",
"lcount",
"=",
"trunc",
"(",
"jd",
")",
"+",
"0.5",
"-",
"EPOCH",
"day",
"=",
"amod",
"(",
"lcount",
"+",
"4",
",",
"13",
")",
"name",
"=",
"amod",
"(",
"lcount",
"+",
"20",
",",
"20",
")",
"return",
... | Determine Mayan Tzolkin "month" and day from Julian day | [
"Determine",
"Mayan",
"Tzolkin",
"month",
"and",
"day",
"from",
"Julian",
"day"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L79-L84 | train |
fitnr/convertdate | convertdate/mayan.py | _haab_count | def _haab_count(day, month):
'''Return the count of the given haab in the cycle. e.g. 0 Pop == 1, 5 Wayeb' == 365'''
if day < 0 or day > 19:
raise IndexError("Invalid day number")
try:
i = HAAB_MONTHS.index(month)
except ValueError:
raise ValueError("'{0}' is not a valid Haab' m... | python | def _haab_count(day, month):
'''Return the count of the given haab in the cycle. e.g. 0 Pop == 1, 5 Wayeb' == 365'''
if day < 0 or day > 19:
raise IndexError("Invalid day number")
try:
i = HAAB_MONTHS.index(month)
except ValueError:
raise ValueError("'{0}' is not a valid Haab' m... | [
"def",
"_haab_count",
"(",
"day",
",",
"month",
")",
":",
"if",
"day",
"<",
"0",
"or",
"day",
">",
"19",
":",
"raise",
"IndexError",
"(",
"\"Invalid day number\"",
")",
"try",
":",
"i",
"=",
"HAAB_MONTHS",
".",
"index",
"(",
"month",
")",
"except",
"... | Return the count of the given haab in the cycle. e.g. 0 Pop == 1, 5 Wayeb' == 365 | [
"Return",
"the",
"count",
"of",
"the",
"given",
"haab",
"in",
"the",
"cycle",
".",
"e",
".",
"g",
".",
"0",
"Pop",
"==",
"1",
"5",
"Wayeb",
"==",
"365"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L111-L121 | train |
fitnr/convertdate | convertdate/mayan.py | tzolkin_generator | def tzolkin_generator(number=None, name=None):
'''For a given tzolkin name/number combination, return a generator
that gives cycle, starting with the input'''
# By default, it will start at the beginning
number = number or 13
name = name or "Ajaw"
if number > 13:
raise ValueError("Inva... | python | def tzolkin_generator(number=None, name=None):
'''For a given tzolkin name/number combination, return a generator
that gives cycle, starting with the input'''
# By default, it will start at the beginning
number = number or 13
name = name or "Ajaw"
if number > 13:
raise ValueError("Inva... | [
"def",
"tzolkin_generator",
"(",
"number",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"# By default, it will start at the beginning",
"number",
"=",
"number",
"or",
"13",
"name",
"=",
"name",
"or",
"\"Ajaw\"",
"if",
"number",
">",
"13",
":",
"raise",
"... | For a given tzolkin name/number combination, return a generator
that gives cycle, starting with the input | [
"For",
"a",
"given",
"tzolkin",
"name",
"/",
"number",
"combination",
"return",
"a",
"generator",
"that",
"gives",
"cycle",
"starting",
"with",
"the",
"input"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L145-L164 | train |
fitnr/convertdate | convertdate/mayan.py | longcount_generator | def longcount_generator(baktun, katun, tun, uinal, kin):
'''Generate long counts, starting with input'''
j = to_jd(baktun, katun, tun, uinal, kin)
while True:
yield from_jd(j)
j = j + 1 | python | def longcount_generator(baktun, katun, tun, uinal, kin):
'''Generate long counts, starting with input'''
j = to_jd(baktun, katun, tun, uinal, kin)
while True:
yield from_jd(j)
j = j + 1 | [
"def",
"longcount_generator",
"(",
"baktun",
",",
"katun",
",",
"tun",
",",
"uinal",
",",
"kin",
")",
":",
"j",
"=",
"to_jd",
"(",
"baktun",
",",
"katun",
",",
"tun",
",",
"uinal",
",",
"kin",
")",
"while",
"True",
":",
"yield",
"from_jd",
"(",
"j"... | Generate long counts, starting with input | [
"Generate",
"long",
"counts",
"starting",
"with",
"input"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L167-L173 | train |
fitnr/convertdate | convertdate/mayan.py | next_haab | def next_haab(month, jd):
'''For a given haab month and a julian day count, find the next start of that month on or after the JDC'''
if jd < EPOCH:
raise IndexError("Input day is before Mayan epoch.")
hday, hmonth = to_haab(jd)
if hmonth == month:
days = 1 - hday
else:
cou... | python | def next_haab(month, jd):
'''For a given haab month and a julian day count, find the next start of that month on or after the JDC'''
if jd < EPOCH:
raise IndexError("Input day is before Mayan epoch.")
hday, hmonth = to_haab(jd)
if hmonth == month:
days = 1 - hday
else:
cou... | [
"def",
"next_haab",
"(",
"month",
",",
"jd",
")",
":",
"if",
"jd",
"<",
"EPOCH",
":",
"raise",
"IndexError",
"(",
"\"Input day is before Mayan epoch.\"",
")",
"hday",
",",
"hmonth",
"=",
"to_haab",
"(",
"jd",
")",
"if",
"hmonth",
"==",
"month",
":",
"day... | For a given haab month and a julian day count, find the next start of that month on or after the JDC | [
"For",
"a",
"given",
"haab",
"month",
"and",
"a",
"julian",
"day",
"count",
"find",
"the",
"next",
"start",
"of",
"that",
"month",
"on",
"or",
"after",
"the",
"JDC"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L176-L194 | train |
fitnr/convertdate | convertdate/mayan.py | next_tzolkin | def next_tzolkin(tzolkin, jd):
'''For a given tzolk'in day, and a julian day count, find the next occurrance of that tzolk'in after the date'''
if jd < EPOCH:
raise IndexError("Input day is before Mayan epoch.")
count1 = _tzolkin_count(*to_tzolkin(jd))
count2 = _tzolkin_count(*tzolkin)
add... | python | def next_tzolkin(tzolkin, jd):
'''For a given tzolk'in day, and a julian day count, find the next occurrance of that tzolk'in after the date'''
if jd < EPOCH:
raise IndexError("Input day is before Mayan epoch.")
count1 = _tzolkin_count(*to_tzolkin(jd))
count2 = _tzolkin_count(*tzolkin)
add... | [
"def",
"next_tzolkin",
"(",
"tzolkin",
",",
"jd",
")",
":",
"if",
"jd",
"<",
"EPOCH",
":",
"raise",
"IndexError",
"(",
"\"Input day is before Mayan epoch.\"",
")",
"count1",
"=",
"_tzolkin_count",
"(",
"*",
"to_tzolkin",
"(",
"jd",
")",
")",
"count2",
"=",
... | For a given tzolk'in day, and a julian day count, find the next occurrance of that tzolk'in after the date | [
"For",
"a",
"given",
"tzolk",
"in",
"day",
"and",
"a",
"julian",
"day",
"count",
"find",
"the",
"next",
"occurrance",
"of",
"that",
"tzolk",
"in",
"after",
"the",
"date"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L197-L206 | train |
fitnr/convertdate | convertdate/mayan.py | next_tzolkin_haab | def next_tzolkin_haab(tzolkin, haab, jd):
'''For a given haab-tzolk'in combination, and a Julian day count, find the next occurrance of the combination after the date'''
# get H & T of input jd, and their place in the 18,980 day cycle
haabcount = _haab_count(*to_haab(jd))
haab_desired_count = _haab_coun... | python | def next_tzolkin_haab(tzolkin, haab, jd):
'''For a given haab-tzolk'in combination, and a Julian day count, find the next occurrance of the combination after the date'''
# get H & T of input jd, and their place in the 18,980 day cycle
haabcount = _haab_count(*to_haab(jd))
haab_desired_count = _haab_coun... | [
"def",
"next_tzolkin_haab",
"(",
"tzolkin",
",",
"haab",
",",
"jd",
")",
":",
"# get H & T of input jd, and their place in the 18,980 day cycle",
"haabcount",
"=",
"_haab_count",
"(",
"*",
"to_haab",
"(",
"jd",
")",
")",
"haab_desired_count",
"=",
"_haab_count",
"(",
... | For a given haab-tzolk'in combination, and a Julian day count, find the next occurrance of the combination after the date | [
"For",
"a",
"given",
"haab",
"-",
"tzolk",
"in",
"combination",
"and",
"a",
"Julian",
"day",
"count",
"find",
"the",
"next",
"occurrance",
"of",
"the",
"combination",
"after",
"the",
"date"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L209-L230 | train |
fitnr/convertdate | convertdate/mayan.py | haab_monthcalendar | def haab_monthcalendar(baktun=None, katun=None, tun=None, uinal=None, kin=None, jdc=None):
'''For a given long count, return a calender of the current haab month, divided into tzolkin "weeks"'''
if not jdc:
jdc = to_jd(baktun, katun, tun, uinal, kin)
haab_number, haab_month = to_haab(jdc)
first... | python | def haab_monthcalendar(baktun=None, katun=None, tun=None, uinal=None, kin=None, jdc=None):
'''For a given long count, return a calender of the current haab month, divided into tzolkin "weeks"'''
if not jdc:
jdc = to_jd(baktun, katun, tun, uinal, kin)
haab_number, haab_month = to_haab(jdc)
first... | [
"def",
"haab_monthcalendar",
"(",
"baktun",
"=",
"None",
",",
"katun",
"=",
"None",
",",
"tun",
"=",
"None",
",",
"uinal",
"=",
"None",
",",
"kin",
"=",
"None",
",",
"jdc",
"=",
"None",
")",
":",
"if",
"not",
"jdc",
":",
"jdc",
"=",
"to_jd",
"(",... | For a given long count, return a calender of the current haab month, divided into tzolkin "weeks" | [
"For",
"a",
"given",
"long",
"count",
"return",
"a",
"calender",
"of",
"the",
"current",
"haab",
"month",
"divided",
"into",
"tzolkin",
"weeks"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/mayan.py#L241-L267 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Item._update_data | def _update_data(self, data={}):
'''Update the data in this object.'''
# Store the changes to prevent this update from affecting it
pending_changes = self._changes or {}
try:
del self._changes
except:
pass
# Map custom fields into our custom fiel... | python | def _update_data(self, data={}):
'''Update the data in this object.'''
# Store the changes to prevent this update from affecting it
pending_changes = self._changes or {}
try:
del self._changes
except:
pass
# Map custom fields into our custom fiel... | [
"def",
"_update_data",
"(",
"self",
",",
"data",
"=",
"{",
"}",
")",
":",
"# Store the changes to prevent this update from affecting it",
"pending_changes",
"=",
"self",
".",
"_changes",
"or",
"{",
"}",
"try",
":",
"del",
"self",
".",
"_changes",
"except",
":",
... | Update the data in this object. | [
"Update",
"the",
"data",
"in",
"this",
"object",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L77-L109 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Item._remap_tag_to_tag_id | def _remap_tag_to_tag_id(cls, tag, new_data):
'''Remaps a given changed field from tag to tag_id.'''
try:
value = new_data[tag]
except:
# If tag wasn't changed, just return
return
tag_id = tag + '_id'
try:
# Remap the ID change to ... | python | def _remap_tag_to_tag_id(cls, tag, new_data):
'''Remaps a given changed field from tag to tag_id.'''
try:
value = new_data[tag]
except:
# If tag wasn't changed, just return
return
tag_id = tag + '_id'
try:
# Remap the ID change to ... | [
"def",
"_remap_tag_to_tag_id",
"(",
"cls",
",",
"tag",
",",
"new_data",
")",
":",
"try",
":",
"value",
"=",
"new_data",
"[",
"tag",
"]",
"except",
":",
"# If tag wasn't changed, just return",
"return",
"tag_id",
"=",
"tag",
"+",
"'_id'",
"try",
":",
"# Remap... | Remaps a given changed field from tag to tag_id. | [
"Remaps",
"a",
"given",
"changed",
"field",
"from",
"tag",
"to",
"tag_id",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L198-L219 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Item._add_item_manager | def _add_item_manager(self, key, item_class, **paths):
'''
Add an item manager to this object.
'''
updated_paths = {}
for path_type, path_value in paths.iteritems():
updated_paths[path_type] = path_value.format(**self.__dict__)
manager = Redmine_Items_Manager... | python | def _add_item_manager(self, key, item_class, **paths):
'''
Add an item manager to this object.
'''
updated_paths = {}
for path_type, path_value in paths.iteritems():
updated_paths[path_type] = path_value.format(**self.__dict__)
manager = Redmine_Items_Manager... | [
"def",
"_add_item_manager",
"(",
"self",
",",
"key",
",",
"item_class",
",",
"*",
"*",
"paths",
")",
":",
"updated_paths",
"=",
"{",
"}",
"for",
"path_type",
",",
"path_value",
"in",
"paths",
".",
"iteritems",
"(",
")",
":",
"updated_paths",
"[",
"path_t... | Add an item manager to this object. | [
"Add",
"an",
"item",
"manager",
"to",
"this",
"object",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L221-L231 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Item.save | def save(self):
'''Save all changes on this item (if any) back to Redmine.'''
self._check_custom_fields()
if not self._changes:
return None
for tag in self._remap_to_id:
self._remap_tag_to_tag_id(tag, self._changes)
# Check for custom handlers for tags
... | python | def save(self):
'''Save all changes on this item (if any) back to Redmine.'''
self._check_custom_fields()
if not self._changes:
return None
for tag in self._remap_to_id:
self._remap_tag_to_tag_id(tag, self._changes)
# Check for custom handlers for tags
... | [
"def",
"save",
"(",
"self",
")",
":",
"self",
".",
"_check_custom_fields",
"(",
")",
"if",
"not",
"self",
".",
"_changes",
":",
"return",
"None",
"for",
"tag",
"in",
"self",
".",
"_remap_to_id",
":",
"self",
".",
"_remap_tag_to_tag_id",
"(",
"tag",
",",
... | Save all changes on this item (if any) back to Redmine. | [
"Save",
"all",
"changes",
"on",
"this",
"item",
"(",
"if",
"any",
")",
"back",
"to",
"Redmine",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L233-L271 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Item.refresh | def refresh(self):
'''Refresh this item from data on the server.
Will save any unsaved data first.'''
if not self._item_path:
raise AttributeError('refresh is not available for %s' % self._type)
if not self.id:
raise RedmineError('%s did not come from the Redmine... | python | def refresh(self):
'''Refresh this item from data on the server.
Will save any unsaved data first.'''
if not self._item_path:
raise AttributeError('refresh is not available for %s' % self._type)
if not self.id:
raise RedmineError('%s did not come from the Redmine... | [
"def",
"refresh",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_item_path",
":",
"raise",
"AttributeError",
"(",
"'refresh is not available for %s'",
"%",
"self",
".",
"_type",
")",
"if",
"not",
"self",
".",
"id",
":",
"raise",
"RedmineError",
"(",
"'... | Refresh this item from data on the server.
Will save any unsaved data first. | [
"Refresh",
"this",
"item",
"from",
"data",
"on",
"the",
"server",
".",
"Will",
"save",
"any",
"unsaved",
"data",
"first",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L284-L302 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Custom_Fields._get_changes | def _get_changes(self):
'''Get all changed values.'''
result = dict( (f['id'], f.get('value','')) for f in self._data if f.get('changed', False) )
self._clear_changes
return result | python | def _get_changes(self):
'''Get all changed values.'''
result = dict( (f['id'], f.get('value','')) for f in self._data if f.get('changed', False) )
self._clear_changes
return result | [
"def",
"_get_changes",
"(",
"self",
")",
":",
"result",
"=",
"dict",
"(",
"(",
"f",
"[",
"'id'",
"]",
",",
"f",
".",
"get",
"(",
"'value'",
",",
"''",
")",
")",
"for",
"f",
"in",
"self",
".",
"_data",
"if",
"f",
".",
"get",
"(",
"'changed'",
... | Get all changed values. | [
"Get",
"all",
"changed",
"values",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L335-L339 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Items_Manager.iteritems | def iteritems(self, **options):
'''Return a query interator with (id, object) pairs.'''
iter = self.query(**options)
while True:
obj = iter.next()
yield (obj.id, obj) | python | def iteritems(self, **options):
'''Return a query interator with (id, object) pairs.'''
iter = self.query(**options)
while True:
obj = iter.next()
yield (obj.id, obj) | [
"def",
"iteritems",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"iter",
"=",
"self",
".",
"query",
"(",
"*",
"*",
"options",
")",
"while",
"True",
":",
"obj",
"=",
"iter",
".",
"next",
"(",
")",
"yield",
"(",
"obj",
".",
"id",
",",
"obj",
... | Return a query interator with (id, object) pairs. | [
"Return",
"a",
"query",
"interator",
"with",
"(",
"id",
"object",
")",
"pairs",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L488-L493 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Items_Manager._objectify | def _objectify(self, json_data=None, data={}):
'''Return an object derived from the given json data.'''
if json_data:
# Parse the data
try:
data = json.loads(json_data)
except ValueError:
# If parsing failed, then raise the string which... | python | def _objectify(self, json_data=None, data={}):
'''Return an object derived from the given json data.'''
if json_data:
# Parse the data
try:
data = json.loads(json_data)
except ValueError:
# If parsing failed, then raise the string which... | [
"def",
"_objectify",
"(",
"self",
",",
"json_data",
"=",
"None",
",",
"data",
"=",
"{",
"}",
")",
":",
"if",
"json_data",
":",
"# Parse the data",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"json_data",
")",
"except",
"ValueError",
":",
"# If ... | Return an object derived from the given json data. | [
"Return",
"an",
"object",
"derived",
"from",
"the",
"given",
"json",
"data",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L503-L520 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Items_Manager.new | def new(self, **dict):
'''Create a new item with the provided dict information. Returns the new item.'''
if not self._item_new_path:
raise AttributeError('new is not available for %s' % self._item_name)
# Remap various tag to tag_id
for tag in self._object._remap_to_id:
... | python | def new(self, **dict):
'''Create a new item with the provided dict information. Returns the new item.'''
if not self._item_new_path:
raise AttributeError('new is not available for %s' % self._item_name)
# Remap various tag to tag_id
for tag in self._object._remap_to_id:
... | [
"def",
"new",
"(",
"self",
",",
"*",
"*",
"dict",
")",
":",
"if",
"not",
"self",
".",
"_item_new_path",
":",
"raise",
"AttributeError",
"(",
"'new is not available for %s'",
"%",
"self",
".",
"_item_name",
")",
"# Remap various tag to tag_id",
"for",
"tag",
"i... | Create a new item with the provided dict information. Returns the new item. | [
"Create",
"a",
"new",
"item",
"with",
"the",
"provided",
"dict",
"information",
".",
"Returns",
"the",
"new",
"item",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L522-L536 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Items_Manager.get | def get(self, id, **options):
'''Get a single item with the given ID'''
if not self._item_path:
raise AttributeError('get is not available for %s' % self._item_name)
target = self._item_path % id
json_data = self._redmine.get(target, **options)
data = self._redmine.un... | python | def get(self, id, **options):
'''Get a single item with the given ID'''
if not self._item_path:
raise AttributeError('get is not available for %s' % self._item_name)
target = self._item_path % id
json_data = self._redmine.get(target, **options)
data = self._redmine.un... | [
"def",
"get",
"(",
"self",
",",
"id",
",",
"*",
"*",
"options",
")",
":",
"if",
"not",
"self",
".",
"_item_path",
":",
"raise",
"AttributeError",
"(",
"'get is not available for %s'",
"%",
"self",
".",
"_item_name",
")",
"target",
"=",
"self",
".",
"_ite... | Get a single item with the given ID | [
"Get",
"a",
"single",
"item",
"with",
"the",
"given",
"ID"
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L538-L546 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Items_Manager.update | def update(self, id, **dict):
'''Update a given item with the passed data.'''
if not self._item_path:
raise AttributeError('update is not available for %s' % self._item_name)
target = (self._update_path or self._item_path) % id
payload = json.dumps({self._item_type:dict})
... | python | def update(self, id, **dict):
'''Update a given item with the passed data.'''
if not self._item_path:
raise AttributeError('update is not available for %s' % self._item_name)
target = (self._update_path or self._item_path) % id
payload = json.dumps({self._item_type:dict})
... | [
"def",
"update",
"(",
"self",
",",
"id",
",",
"*",
"*",
"dict",
")",
":",
"if",
"not",
"self",
".",
"_item_path",
":",
"raise",
"AttributeError",
"(",
"'update is not available for %s'",
"%",
"self",
".",
"_item_name",
")",
"target",
"=",
"(",
"self",
".... | Update a given item with the passed data. | [
"Update",
"a",
"given",
"item",
"with",
"the",
"passed",
"data",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L548-L555 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Items_Manager.delete | def delete(self, id):
'''Delete a single item with the given ID'''
if not self._item_path:
raise AttributeError('delete is not available for %s' % self._item_name)
target = self._item_path % id
self._redmine.delete(target)
return None | python | def delete(self, id):
'''Delete a single item with the given ID'''
if not self._item_path:
raise AttributeError('delete is not available for %s' % self._item_name)
target = self._item_path % id
self._redmine.delete(target)
return None | [
"def",
"delete",
"(",
"self",
",",
"id",
")",
":",
"if",
"not",
"self",
".",
"_item_path",
":",
"raise",
"AttributeError",
"(",
"'delete is not available for %s'",
"%",
"self",
".",
"_item_name",
")",
"target",
"=",
"self",
".",
"_item_path",
"%",
"id",
"s... | Delete a single item with the given ID | [
"Delete",
"a",
"single",
"item",
"with",
"the",
"given",
"ID"
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L557-L563 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_Items_Manager.query | def query(self, **options):
'''Return an iterator for the given items.'''
if not self._query_path:
raise AttributeError('query is not available for %s' % self._item_name)
last_item = 0
offset = 0
current_item = None
limit = options.get('limit', 25)
opt... | python | def query(self, **options):
'''Return an iterator for the given items.'''
if not self._query_path:
raise AttributeError('query is not available for %s' % self._item_name)
last_item = 0
offset = 0
current_item = None
limit = options.get('limit', 25)
opt... | [
"def",
"query",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"if",
"not",
"self",
".",
"_query_path",
":",
"raise",
"AttributeError",
"(",
"'query is not available for %s'",
"%",
"self",
".",
"_item_name",
")",
"last_item",
"=",
"0",
"offset",
"=",
"0"... | Return an iterator for the given items. | [
"Return",
"an",
"iterator",
"for",
"the",
"given",
"items",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L565-L602 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_WS._setup_authentication | def _setup_authentication(self, username, password):
'''Create the authentication object with the given credentials.'''
## BUG WORKAROUND
if self.version < 1.1:
# Version 1.0 had a bug when using the key parameter.
# Later versions have the opposite bug (a key in the use... | python | def _setup_authentication(self, username, password):
'''Create the authentication object with the given credentials.'''
## BUG WORKAROUND
if self.version < 1.1:
# Version 1.0 had a bug when using the key parameter.
# Later versions have the opposite bug (a key in the use... | [
"def",
"_setup_authentication",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"## BUG WORKAROUND",
"if",
"self",
".",
"version",
"<",
"1.1",
":",
"# Version 1.0 had a bug when using the key parameter.",
"# Later versions have the opposite bug (a key in the username d... | Create the authentication object with the given credentials. | [
"Create",
"the",
"authentication",
"object",
"with",
"the",
"given",
"credentials",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L631-L661 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_WS.open_raw | def open_raw(self, page, parms=None, payload=None, HTTPrequest=None, payload_type='application/json' ):
'''Opens a page from the server with optional XML. Returns a response file-like object'''
if not parms:
parms={}
# if we're using a key, but it's not going in the header, add it ... | python | def open_raw(self, page, parms=None, payload=None, HTTPrequest=None, payload_type='application/json' ):
'''Opens a page from the server with optional XML. Returns a response file-like object'''
if not parms:
parms={}
# if we're using a key, but it's not going in the header, add it ... | [
"def",
"open_raw",
"(",
"self",
",",
"page",
",",
"parms",
"=",
"None",
",",
"payload",
"=",
"None",
",",
"HTTPrequest",
"=",
"None",
",",
"payload_type",
"=",
"'application/json'",
")",
":",
"if",
"not",
"parms",
":",
"parms",
"=",
"{",
"}",
"# if we'... | Opens a page from the server with optional XML. Returns a response file-like object | [
"Opens",
"a",
"page",
"from",
"the",
"server",
"with",
"optional",
"XML",
".",
"Returns",
"a",
"response",
"file",
"-",
"like",
"object"
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L663-L713 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_WS.open | def open(self, page, parms=None, payload=None, HTTPrequest=None ):
'''Opens a page from the server with optional content. Returns the string response.'''
response = self.open_raw( page, parms, payload, HTTPrequest )
return response.read() | python | def open(self, page, parms=None, payload=None, HTTPrequest=None ):
'''Opens a page from the server with optional content. Returns the string response.'''
response = self.open_raw( page, parms, payload, HTTPrequest )
return response.read() | [
"def",
"open",
"(",
"self",
",",
"page",
",",
"parms",
"=",
"None",
",",
"payload",
"=",
"None",
",",
"HTTPrequest",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"open_raw",
"(",
"page",
",",
"parms",
",",
"payload",
",",
"HTTPrequest",
")",
... | Opens a page from the server with optional content. Returns the string response. | [
"Opens",
"a",
"page",
"from",
"the",
"server",
"with",
"optional",
"content",
".",
"Returns",
"the",
"string",
"response",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L715-L718 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_WS.post | def post(self, page, payload, parms=None ):
'''Posts a string payload to the server - used to make new Redmine items. Returns an JSON string or error.'''
if self.readonlytest:
print 'Redmine read only test: Pretending to create: ' + page
return payload
else:
... | python | def post(self, page, payload, parms=None ):
'''Posts a string payload to the server - used to make new Redmine items. Returns an JSON string or error.'''
if self.readonlytest:
print 'Redmine read only test: Pretending to create: ' + page
return payload
else:
... | [
"def",
"post",
"(",
"self",
",",
"page",
",",
"payload",
",",
"parms",
"=",
"None",
")",
":",
"if",
"self",
".",
"readonlytest",
":",
"print",
"'Redmine read only test: Pretending to create: '",
"+",
"page",
"return",
"payload",
"else",
":",
"return",
"self",
... | Posts a string payload to the server - used to make new Redmine items. Returns an JSON string or error. | [
"Posts",
"a",
"string",
"payload",
"to",
"the",
"server",
"-",
"used",
"to",
"make",
"new",
"Redmine",
"items",
".",
"Returns",
"an",
"JSON",
"string",
"or",
"error",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L725-L731 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_WS.put | def put(self, page, payload, parms=None ):
'''Puts an XML object on the server - used to update Redmine items. Returns nothing useful.'''
if self.readonlytest:
print 'Redmine read only test: Pretending to update: ' + page
else:
return self.open( page, parms, payload, HTT... | python | def put(self, page, payload, parms=None ):
'''Puts an XML object on the server - used to update Redmine items. Returns nothing useful.'''
if self.readonlytest:
print 'Redmine read only test: Pretending to update: ' + page
else:
return self.open( page, parms, payload, HTT... | [
"def",
"put",
"(",
"self",
",",
"page",
",",
"payload",
",",
"parms",
"=",
"None",
")",
":",
"if",
"self",
".",
"readonlytest",
":",
"print",
"'Redmine read only test: Pretending to update: '",
"+",
"page",
"else",
":",
"return",
"self",
".",
"open",
"(",
... | Puts an XML object on the server - used to update Redmine items. Returns nothing useful. | [
"Puts",
"an",
"XML",
"object",
"on",
"the",
"server",
"-",
"used",
"to",
"update",
"Redmine",
"items",
".",
"Returns",
"nothing",
"useful",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L733-L738 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_WS.delete | def delete(self, page ):
'''Deletes a given object on the server - used to remove items from Redmine. Use carefully!'''
if self.readonlytest:
print 'Redmine read only test: Pretending to delete: ' + page
else:
return self.open( page, HTTPrequest=self.DELETE_Request ) | python | def delete(self, page ):
'''Deletes a given object on the server - used to remove items from Redmine. Use carefully!'''
if self.readonlytest:
print 'Redmine read only test: Pretending to delete: ' + page
else:
return self.open( page, HTTPrequest=self.DELETE_Request ) | [
"def",
"delete",
"(",
"self",
",",
"page",
")",
":",
"if",
"self",
".",
"readonlytest",
":",
"print",
"'Redmine read only test: Pretending to delete: '",
"+",
"page",
"else",
":",
"return",
"self",
".",
"open",
"(",
"page",
",",
"HTTPrequest",
"=",
"self",
"... | Deletes a given object on the server - used to remove items from Redmine. Use carefully! | [
"Deletes",
"a",
"given",
"object",
"on",
"the",
"server",
"-",
"used",
"to",
"remove",
"items",
"from",
"Redmine",
".",
"Use",
"carefully!"
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L740-L745 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_WS.unwrap_json | def unwrap_json(self, type, json_data):
'''Decodes a json string, and unwraps any 'type' it finds within.'''
# Parse the data
try:
data = json.loads(json_data)
except ValueError:
# If parsing failed, then raise the string which likely contains an error message ins... | python | def unwrap_json(self, type, json_data):
'''Decodes a json string, and unwraps any 'type' it finds within.'''
# Parse the data
try:
data = json.loads(json_data)
except ValueError:
# If parsing failed, then raise the string which likely contains an error message ins... | [
"def",
"unwrap_json",
"(",
"self",
",",
"type",
",",
"json_data",
")",
":",
"# Parse the data",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"json_data",
")",
"except",
"ValueError",
":",
"# If parsing failed, then raise the string which likely contains an erro... | Decodes a json string, and unwraps any 'type' it finds within. | [
"Decodes",
"a",
"json",
"string",
"and",
"unwraps",
"any",
"type",
"it",
"finds",
"within",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L752-L766 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_WS.find_all_item_classes | def find_all_item_classes(self):
'''Finds and stores a reference to all Redmine_Item subclasses for later use.'''
# This is a circular import, but performed after the class is defined and an object is instatiated.
# We do this in order to get references to any objects definitions in the redmine.... | python | def find_all_item_classes(self):
'''Finds and stores a reference to all Redmine_Item subclasses for later use.'''
# This is a circular import, but performed after the class is defined and an object is instatiated.
# We do this in order to get references to any objects definitions in the redmine.... | [
"def",
"find_all_item_classes",
"(",
"self",
")",
":",
"# This is a circular import, but performed after the class is defined and an object is instatiated.",
"# We do this in order to get references to any objects definitions in the redmine.py file",
"# without requiring anyone editing the file to d... | Finds and stores a reference to all Redmine_Item subclasses for later use. | [
"Finds",
"and",
"stores",
"a",
"reference",
"to",
"all",
"Redmine_Item",
"subclasses",
"for",
"later",
"use",
"."
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L769-L783 | train |
ianepperson/pyredminews | redmine/redmine_rest.py | Redmine_WS.check_cache | def check_cache(self, type, data, obj=None):
'''Returns the updated cached version of the given dict'''
try:
id = data['id']
except:
# Not an identifiable item
#print 'don\'t know this item %r:%r' % (type, data)
return data
# If obj was pa... | python | def check_cache(self, type, data, obj=None):
'''Returns the updated cached version of the given dict'''
try:
id = data['id']
except:
# Not an identifiable item
#print 'don\'t know this item %r:%r' % (type, data)
return data
# If obj was pa... | [
"def",
"check_cache",
"(",
"self",
",",
"type",
",",
"data",
",",
"obj",
"=",
"None",
")",
":",
"try",
":",
"id",
"=",
"data",
"[",
"'id'",
"]",
"except",
":",
"# Not an identifiable item",
"#print 'don\\'t know this item %r:%r' % (type, data)",
"return",
"data"... | Returns the updated cached version of the given dict | [
"Returns",
"the",
"updated",
"cached",
"version",
"of",
"the",
"given",
"dict"
] | b2b0581483632738a3acca3b4e093c181847b813 | https://github.com/ianepperson/pyredminews/blob/b2b0581483632738a3acca3b4e093c181847b813/redmine/redmine_rest.py#L785-L822 | train |
allelos/vectors | vectors/vectors.py | Point.substract | def substract(self, pt):
"""Return a Point instance as the displacement of two points."""
if isinstance(pt, Point):
return Point(pt.x - self.x, pt.y - self.y, pt.z - self.z)
else:
raise TypeError | python | def substract(self, pt):
"""Return a Point instance as the displacement of two points."""
if isinstance(pt, Point):
return Point(pt.x - self.x, pt.y - self.y, pt.z - self.z)
else:
raise TypeError | [
"def",
"substract",
"(",
"self",
",",
"pt",
")",
":",
"if",
"isinstance",
"(",
"pt",
",",
"Point",
")",
":",
"return",
"Point",
"(",
"pt",
".",
"x",
"-",
"self",
".",
"x",
",",
"pt",
".",
"y",
"-",
"self",
".",
"y",
",",
"pt",
".",
"z",
"-"... | Return a Point instance as the displacement of two points. | [
"Return",
"a",
"Point",
"instance",
"as",
"the",
"displacement",
"of",
"two",
"points",
"."
] | 55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee | https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L54-L59 | train |
allelos/vectors | vectors/vectors.py | Point.from_list | def from_list(cls, l):
"""Return a Point instance from a given list"""
if len(l) == 3:
x, y, z = map(float, l)
return cls(x, y, z)
elif len(l) == 2:
x, y = map(float, l)
return cls(x, y)
else:
raise AttributeError | python | def from_list(cls, l):
"""Return a Point instance from a given list"""
if len(l) == 3:
x, y, z = map(float, l)
return cls(x, y, z)
elif len(l) == 2:
x, y = map(float, l)
return cls(x, y)
else:
raise AttributeError | [
"def",
"from_list",
"(",
"cls",
",",
"l",
")",
":",
"if",
"len",
"(",
"l",
")",
"==",
"3",
":",
"x",
",",
"y",
",",
"z",
"=",
"map",
"(",
"float",
",",
"l",
")",
"return",
"cls",
"(",
"x",
",",
"y",
",",
"z",
")",
"elif",
"len",
"(",
"l... | Return a Point instance from a given list | [
"Return",
"a",
"Point",
"instance",
"from",
"a",
"given",
"list"
] | 55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee | https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L62-L71 | train |
allelos/vectors | vectors/vectors.py | Vector.multiply | def multiply(self, number):
"""Return a Vector as the product of the vector and a real number."""
return self.from_list([x * number for x in self.to_list()]) | python | def multiply(self, number):
"""Return a Vector as the product of the vector and a real number."""
return self.from_list([x * number for x in self.to_list()]) | [
"def",
"multiply",
"(",
"self",
",",
"number",
")",
":",
"return",
"self",
".",
"from_list",
"(",
"[",
"x",
"*",
"number",
"for",
"x",
"in",
"self",
".",
"to_list",
"(",
")",
"]",
")"
] | Return a Vector as the product of the vector and a real number. | [
"Return",
"a",
"Vector",
"as",
"the",
"product",
"of",
"the",
"vector",
"and",
"a",
"real",
"number",
"."
] | 55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee | https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L120-L122 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.