partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | WCSObject.print_archive | Prints out archived WCS keywords. | lib/stsci/tools/wcsutil.py | def print_archive(self,format=True):
""" Prints out archived WCS keywords."""
if len(list(self.orig_wcs.keys())) > 0:
block = 'Original WCS keywords for ' + self.rootname+ '\n'
block += ' backed up on '+repr(self.orig_wcs['WCSCDATE'])+'\n'
if not format:
... | def print_archive(self,format=True):
""" Prints out archived WCS keywords."""
if len(list(self.orig_wcs.keys())) > 0:
block = 'Original WCS keywords for ' + self.rootname+ '\n'
block += ' backed up on '+repr(self.orig_wcs['WCSCDATE'])+'\n'
if not format:
... | [
"Prints",
"out",
"archived",
"WCS",
"keywords",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L420-L439 | [
"def",
"print_archive",
"(",
"self",
",",
"format",
"=",
"True",
")",
":",
"if",
"len",
"(",
"list",
"(",
"self",
".",
"orig_wcs",
".",
"keys",
"(",
")",
")",
")",
">",
"0",
":",
"block",
"=",
"'Original WCS keywords for '",
"+",
"self",
".",
"rootna... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.set_pscale | Compute the pixel scale based on active WCS values. | lib/stsci/tools/wcsutil.py | def set_pscale(self):
""" Compute the pixel scale based on active WCS values. """
if self.new:
self.pscale = 1.0
else:
self.pscale = self.compute_pscale(self.cd11,self.cd21) | def set_pscale(self):
""" Compute the pixel scale based on active WCS values. """
if self.new:
self.pscale = 1.0
else:
self.pscale = self.compute_pscale(self.cd11,self.cd21) | [
"Compute",
"the",
"pixel",
"scale",
"based",
"on",
"active",
"WCS",
"values",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L445-L450 | [
"def",
"set_pscale",
"(",
"self",
")",
":",
"if",
"self",
".",
"new",
":",
"self",
".",
"pscale",
"=",
"1.0",
"else",
":",
"self",
".",
"pscale",
"=",
"self",
".",
"compute_pscale",
"(",
"self",
".",
"cd11",
",",
"self",
".",
"cd21",
")"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.compute_pscale | Compute the pixel scale based on active WCS values. | lib/stsci/tools/wcsutil.py | def compute_pscale(self,cd11,cd21):
""" Compute the pixel scale based on active WCS values. """
return N.sqrt(N.power(cd11,2)+N.power(cd21,2)) * 3600. | def compute_pscale(self,cd11,cd21):
""" Compute the pixel scale based on active WCS values. """
return N.sqrt(N.power(cd11,2)+N.power(cd21,2)) * 3600. | [
"Compute",
"the",
"pixel",
"scale",
"based",
"on",
"active",
"WCS",
"values",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L452-L454 | [
"def",
"compute_pscale",
"(",
"self",
",",
"cd11",
",",
"cd21",
")",
":",
"return",
"N",
".",
"sqrt",
"(",
"N",
".",
"power",
"(",
"cd11",
",",
"2",
")",
"+",
"N",
".",
"power",
"(",
"cd21",
",",
"2",
")",
")",
"*",
"3600."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.set_orient | Return the computed orientation based on CD matrix. | lib/stsci/tools/wcsutil.py | def set_orient(self):
""" Return the computed orientation based on CD matrix. """
self.orient = RADTODEG(N.arctan2(self.cd12,self.cd22)) | def set_orient(self):
""" Return the computed orientation based on CD matrix. """
self.orient = RADTODEG(N.arctan2(self.cd12,self.cd22)) | [
"Return",
"the",
"computed",
"orientation",
"based",
"on",
"CD",
"matrix",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L460-L462 | [
"def",
"set_orient",
"(",
"self",
")",
":",
"self",
".",
"orient",
"=",
"RADTODEG",
"(",
"N",
".",
"arctan2",
"(",
"self",
".",
"cd12",
",",
"self",
".",
"cd22",
")",
")"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.updateWCS | Create a new CD Matrix from the absolute pixel scale
and reference image orientation. | lib/stsci/tools/wcsutil.py | def updateWCS(self, pixel_scale=None, orient=None,refpos=None,refval=None,size=None):
"""
Create a new CD Matrix from the absolute pixel scale
and reference image orientation.
"""
# Set up parameters necessary for updating WCS
# Check to see if new value is provided,
... | def updateWCS(self, pixel_scale=None, orient=None,refpos=None,refval=None,size=None):
"""
Create a new CD Matrix from the absolute pixel scale
and reference image orientation.
"""
# Set up parameters necessary for updating WCS
# Check to see if new value is provided,
... | [
"Create",
"a",
"new",
"CD",
"Matrix",
"from",
"the",
"absolute",
"pixel",
"scale",
"and",
"reference",
"image",
"orientation",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L469-L540 | [
"def",
"updateWCS",
"(",
"self",
",",
"pixel_scale",
"=",
"None",
",",
"orient",
"=",
"None",
",",
"refpos",
"=",
"None",
",",
"refval",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"# Set up parameters necessary for updating WCS",
"# Check to see if new val... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.scale_WCS | Scale the WCS to a new pixel_scale. The 'retain' parameter
[default value: True] controls whether or not to retain the original
distortion solution in the CD matrix. | lib/stsci/tools/wcsutil.py | def scale_WCS(self,pixel_scale,retain=True):
''' Scale the WCS to a new pixel_scale. The 'retain' parameter
[default value: True] controls whether or not to retain the original
distortion solution in the CD matrix.
'''
_ratio = pixel_scale / self.pscale
# Correct the siz... | def scale_WCS(self,pixel_scale,retain=True):
''' Scale the WCS to a new pixel_scale. The 'retain' parameter
[default value: True] controls whether or not to retain the original
distortion solution in the CD matrix.
'''
_ratio = pixel_scale / self.pscale
# Correct the siz... | [
"Scale",
"the",
"WCS",
"to",
"a",
"new",
"pixel_scale",
".",
"The",
"retain",
"parameter",
"[",
"default",
"value",
":",
"True",
"]",
"controls",
"whether",
"or",
"not",
"to",
"retain",
"the",
"original",
"distortion",
"solution",
"in",
"the",
"CD",
"matri... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L542-L570 | [
"def",
"scale_WCS",
"(",
"self",
",",
"pixel_scale",
",",
"retain",
"=",
"True",
")",
":",
"_ratio",
"=",
"pixel_scale",
"/",
"self",
".",
"pscale",
"# Correct the size of the image and CRPIX values for scaled WCS",
"self",
".",
"naxis1",
"/=",
"_ratio",
"self",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.xy2rd | This method would apply the WCS keywords to a position to
generate a new sky position.
The algorithm comes directly from 'imgtools.xy2rd'
translate (x,y) to (ra, dec) | lib/stsci/tools/wcsutil.py | def xy2rd(self,pos):
"""
This method would apply the WCS keywords to a position to
generate a new sky position.
The algorithm comes directly from 'imgtools.xy2rd'
translate (x,y) to (ra, dec)
"""
if self.ctype1.find('TAN') < 0 or self.ctype2.find('TAN') < 0:
... | def xy2rd(self,pos):
"""
This method would apply the WCS keywords to a position to
generate a new sky position.
The algorithm comes directly from 'imgtools.xy2rd'
translate (x,y) to (ra, dec)
"""
if self.ctype1.find('TAN') < 0 or self.ctype2.find('TAN') < 0:
... | [
"This",
"method",
"would",
"apply",
"the",
"WCS",
"keywords",
"to",
"a",
"position",
"to",
"generate",
"a",
"new",
"sky",
"position",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L572-L612 | [
"def",
"xy2rd",
"(",
"self",
",",
"pos",
")",
":",
"if",
"self",
".",
"ctype1",
".",
"find",
"(",
"'TAN'",
")",
"<",
"0",
"or",
"self",
".",
"ctype2",
".",
"find",
"(",
"'TAN'",
")",
"<",
"0",
":",
"print",
"(",
"'XY2RD only supported for TAN project... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.rd2xy | This method would use the WCS keywords to compute the XY position
from a given RA/Dec tuple (in deg).
NOTE: Investigate how to let this function accept arrays as well
as single positions. WJH 27Mar03 | lib/stsci/tools/wcsutil.py | def rd2xy(self,skypos,hour=no):
"""
This method would use the WCS keywords to compute the XY position
from a given RA/Dec tuple (in deg).
NOTE: Investigate how to let this function accept arrays as well
as single positions. WJH 27Mar03
"""
if self.ctype1.find('T... | def rd2xy(self,skypos,hour=no):
"""
This method would use the WCS keywords to compute the XY position
from a given RA/Dec tuple (in deg).
NOTE: Investigate how to let this function accept arrays as well
as single positions. WJH 27Mar03
"""
if self.ctype1.find('T... | [
"This",
"method",
"would",
"use",
"the",
"WCS",
"keywords",
"to",
"compute",
"the",
"XY",
"position",
"from",
"a",
"given",
"RA",
"/",
"Dec",
"tuple",
"(",
"in",
"deg",
")",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L615-L657 | [
"def",
"rd2xy",
"(",
"self",
",",
"skypos",
",",
"hour",
"=",
"no",
")",
":",
"if",
"self",
".",
"ctype1",
".",
"find",
"(",
"'TAN'",
")",
"<",
"0",
"or",
"self",
".",
"ctype2",
".",
"find",
"(",
"'TAN'",
")",
"<",
"0",
":",
"print",
"(",
"'R... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.rotateCD | Rotates WCS CD matrix to new orientation given by 'orient' | lib/stsci/tools/wcsutil.py | def rotateCD(self,orient):
""" Rotates WCS CD matrix to new orientation given by 'orient'
"""
# Determine where member CRVAL position falls in ref frame
# Find out whether this needs to be rotated to align with
# reference frame.
_delta = self.get_orient() - orient
... | def rotateCD(self,orient):
""" Rotates WCS CD matrix to new orientation given by 'orient'
"""
# Determine where member CRVAL position falls in ref frame
# Find out whether this needs to be rotated to align with
# reference frame.
_delta = self.get_orient() - orient
... | [
"Rotates",
"WCS",
"CD",
"matrix",
"to",
"new",
"orientation",
"given",
"by",
"orient"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L659-L679 | [
"def",
"rotateCD",
"(",
"self",
",",
"orient",
")",
":",
"# Determine where member CRVAL position falls in ref frame",
"# Find out whether this needs to be rotated to align with",
"# reference frame.",
"_delta",
"=",
"self",
".",
"get_orient",
"(",
")",
"-",
"orient",
"if",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.write | Write out the values of the WCS keywords to the
specified image.
If it is a GEIS image and 'fitsname' has been provided,
it will automatically make a multi-extension
FITS copy of the GEIS and update that file. Otherwise, it
throw an Exception if the user attempts to directly upd... | lib/stsci/tools/wcsutil.py | def write(self,fitsname=None,wcs=None,archive=True,overwrite=False,quiet=True):
"""
Write out the values of the WCS keywords to the
specified image.
If it is a GEIS image and 'fitsname' has been provided,
it will automatically make a multi-extension
FITS copy of the GEIS... | def write(self,fitsname=None,wcs=None,archive=True,overwrite=False,quiet=True):
"""
Write out the values of the WCS keywords to the
specified image.
If it is a GEIS image and 'fitsname' has been provided,
it will automatically make a multi-extension
FITS copy of the GEIS... | [
"Write",
"out",
"the",
"values",
"of",
"the",
"WCS",
"keywords",
"to",
"the",
"specified",
"image",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L756-L809 | [
"def",
"write",
"(",
"self",
",",
"fitsname",
"=",
"None",
",",
"wcs",
"=",
"None",
",",
"archive",
"=",
"True",
",",
"overwrite",
"=",
"False",
",",
"quiet",
"=",
"True",
")",
":",
"## Start by making sure all derived values are in sync with CD matrix",
"self",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.restore | Reset the active WCS keywords to values stored in the
backup keywords. | lib/stsci/tools/wcsutil.py | def restore(self):
""" Reset the active WCS keywords to values stored in the
backup keywords.
"""
# If there are no backup keys, do nothing...
if len(list(self.backup.keys())) == 0:
return
for key in self.backup.keys():
if key != 'WCSCDATE':
... | def restore(self):
""" Reset the active WCS keywords to values stored in the
backup keywords.
"""
# If there are no backup keys, do nothing...
if len(list(self.backup.keys())) == 0:
return
for key in self.backup.keys():
if key != 'WCSCDATE':
... | [
"Reset",
"the",
"active",
"WCS",
"keywords",
"to",
"values",
"stored",
"in",
"the",
"backup",
"keywords",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L811-L822 | [
"def",
"restore",
"(",
"self",
")",
":",
"# If there are no backup keys, do nothing...",
"if",
"len",
"(",
"list",
"(",
"self",
".",
"backup",
".",
"keys",
"(",
")",
")",
")",
"==",
"0",
":",
"return",
"for",
"key",
"in",
"self",
".",
"backup",
".",
"k... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.archive | Create backup copies of the WCS keywords with the given prepended
string.
If backup keywords are already present, only update them if
'overwrite' is set to 'yes', otherwise, do warn the user and do nothing.
Set the WCSDATE at this time as well. | lib/stsci/tools/wcsutil.py | def archive(self,prepend=None,overwrite=no,quiet=yes):
""" Create backup copies of the WCS keywords with the given prepended
string.
If backup keywords are already present, only update them if
'overwrite' is set to 'yes', otherwise, do warn the user and do nothing.
... | def archive(self,prepend=None,overwrite=no,quiet=yes):
""" Create backup copies of the WCS keywords with the given prepended
string.
If backup keywords are already present, only update them if
'overwrite' is set to 'yes', otherwise, do warn the user and do nothing.
... | [
"Create",
"backup",
"copies",
"of",
"the",
"WCS",
"keywords",
"with",
"the",
"given",
"prepended",
"string",
".",
"If",
"backup",
"keywords",
"are",
"already",
"present",
"only",
"update",
"them",
"if",
"overwrite",
"is",
"set",
"to",
"yes",
"otherwise",
"do... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L824-L864 | [
"def",
"archive",
"(",
"self",
",",
"prepend",
"=",
"None",
",",
"overwrite",
"=",
"no",
",",
"quiet",
"=",
"yes",
")",
":",
"# Verify that existing backup values are not overwritten accidentally.",
"if",
"len",
"(",
"list",
"(",
"self",
".",
"backup",
".",
"k... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.read_archive | Extract a copy of WCS keywords from an open file header,
if they have already been created and remember the prefix
used for those keywords. Otherwise, setup the current WCS
keywords as the archive values. | lib/stsci/tools/wcsutil.py | def read_archive(self,header,prepend=None):
""" Extract a copy of WCS keywords from an open file header,
if they have already been created and remember the prefix
used for those keywords. Otherwise, setup the current WCS
keywords as the archive values.
"""
# S... | def read_archive(self,header,prepend=None):
""" Extract a copy of WCS keywords from an open file header,
if they have already been created and remember the prefix
used for those keywords. Otherwise, setup the current WCS
keywords as the archive values.
"""
# S... | [
"Extract",
"a",
"copy",
"of",
"WCS",
"keywords",
"from",
"an",
"open",
"file",
"header",
"if",
"they",
"have",
"already",
"been",
"created",
"and",
"remember",
"the",
"prefix",
"used",
"for",
"those",
"keywords",
".",
"Otherwise",
"setup",
"the",
"current",
... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L866-L920 | [
"def",
"read_archive",
"(",
"self",
",",
"header",
",",
"prepend",
"=",
"None",
")",
":",
"# Start by looking for the any backup WCS keywords to",
"# determine whether archived values are present and to set",
"# the prefix used.",
"_prefix",
"=",
"None",
"_archive",
"=",
"Fal... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.write_archive | Saves a copy of the WCS keywords from the image header
as new keywords with the user-supplied 'prepend'
character(s) prepended to the old keyword names.
If the file is a GEIS image and 'fitsname' is not None, create
a FITS copy and update that version; otherwise, raise
... | lib/stsci/tools/wcsutil.py | def write_archive(self,fitsname=None,overwrite=no,quiet=yes):
""" Saves a copy of the WCS keywords from the image header
as new keywords with the user-supplied 'prepend'
character(s) prepended to the old keyword names.
If the file is a GEIS image and 'fitsname' is not None, ... | def write_archive(self,fitsname=None,overwrite=no,quiet=yes):
""" Saves a copy of the WCS keywords from the image header
as new keywords with the user-supplied 'prepend'
character(s) prepended to the old keyword names.
If the file is a GEIS image and 'fitsname' is not None, ... | [
"Saves",
"a",
"copy",
"of",
"the",
"WCS",
"keywords",
"from",
"the",
"image",
"header",
"as",
"new",
"keywords",
"with",
"the",
"user",
"-",
"supplied",
"prepend",
"character",
"(",
"s",
")",
"prepended",
"to",
"the",
"old",
"keyword",
"names",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L922-L981 | [
"def",
"write_archive",
"(",
"self",
",",
"fitsname",
"=",
"None",
",",
"overwrite",
"=",
"no",
",",
"quiet",
"=",
"yes",
")",
":",
"_fitsname",
"=",
"fitsname",
"# Open image in update mode",
"# Copying of GEIS images handled by 'openImage'.",
"fimg",
"=",
"file... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.restoreWCS | Resets the WCS values to the original values stored in
the backup keywords recorded in self.backup. | lib/stsci/tools/wcsutil.py | def restoreWCS(self,prepend=None):
""" Resets the WCS values to the original values stored in
the backup keywords recorded in self.backup.
"""
# Open header for image
image = self.rootname
if prepend: _prepend = prepend
elif self.prepend: _prepend = self.prep... | def restoreWCS(self,prepend=None):
""" Resets the WCS values to the original values stored in
the backup keywords recorded in self.backup.
"""
# Open header for image
image = self.rootname
if prepend: _prepend = prepend
elif self.prepend: _prepend = self.prep... | [
"Resets",
"the",
"WCS",
"values",
"to",
"the",
"original",
"values",
"stored",
"in",
"the",
"backup",
"keywords",
"recorded",
"in",
"self",
".",
"backup",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L983-L1023 | [
"def",
"restoreWCS",
"(",
"self",
",",
"prepend",
"=",
"None",
")",
":",
"# Open header for image",
"image",
"=",
"self",
".",
"rootname",
"if",
"prepend",
":",
"_prepend",
"=",
"prepend",
"elif",
"self",
".",
"prepend",
":",
"_prepend",
"=",
"self",
".",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.createReferenceWCS | Write out the values of the WCS keywords to the NEW
specified image 'fitsname'. | lib/stsci/tools/wcsutil.py | def createReferenceWCS(self,refname,overwrite=yes):
""" Write out the values of the WCS keywords to the NEW
specified image 'fitsname'.
"""
hdu = self.createWcsHDU()
# If refname already exists, delete it to make way for new file
if os.path.exists(refname):
... | def createReferenceWCS(self,refname,overwrite=yes):
""" Write out the values of the WCS keywords to the NEW
specified image 'fitsname'.
"""
hdu = self.createWcsHDU()
# If refname already exists, delete it to make way for new file
if os.path.exists(refname):
... | [
"Write",
"out",
"the",
"values",
"of",
"the",
"WCS",
"keywords",
"to",
"the",
"NEW",
"specified",
"image",
"fitsname",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L1025-L1053 | [
"def",
"createReferenceWCS",
"(",
"self",
",",
"refname",
",",
"overwrite",
"=",
"yes",
")",
":",
"hdu",
"=",
"self",
".",
"createWcsHDU",
"(",
")",
"# If refname already exists, delete it to make way for new file",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | WCSObject.createWcsHDU | Generate a WCS header object that can be used to
populate a reference WCS HDU. | lib/stsci/tools/wcsutil.py | def createWcsHDU(self):
""" Generate a WCS header object that can be used to
populate a reference WCS HDU.
"""
hdu = fits.ImageHDU()
hdu.header['EXTNAME'] = 'WCS'
hdu.header['EXTVER'] = 1
# Now, update original image size information
hdu.header['WCSAXE... | def createWcsHDU(self):
""" Generate a WCS header object that can be used to
populate a reference WCS HDU.
"""
hdu = fits.ImageHDU()
hdu.header['EXTNAME'] = 'WCS'
hdu.header['EXTVER'] = 1
# Now, update original image size information
hdu.header['WCSAXE... | [
"Generate",
"a",
"WCS",
"header",
"object",
"that",
"can",
"be",
"used",
"to",
"populate",
"a",
"reference",
"WCS",
"HDU",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/wcsutil.py#L1055-L1076 | [
"def",
"createWcsHDU",
"(",
"self",
")",
":",
"hdu",
"=",
"fits",
".",
"ImageHDU",
"(",
")",
"hdu",
".",
"header",
"[",
"'EXTNAME'",
"]",
"=",
"'WCS'",
"hdu",
".",
"header",
"[",
"'EXTVER'",
"]",
"=",
"1",
"# Now, update original image size information",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | main | The main routine. | backend/src/analyser/app.py | def main(args=None):
""" The main routine. """
logger = cfg.configureLogger()
for root, dirs, files in os.walk(cfg.dataDir):
for dir in dirs:
newDir = os.path.join(root, dir)
try:
os.removedirs(newDir)
logger.info("Deleted empty dir " + str(new... | def main(args=None):
""" The main routine. """
logger = cfg.configureLogger()
for root, dirs, files in os.walk(cfg.dataDir):
for dir in dirs:
newDir = os.path.join(root, dir)
try:
os.removedirs(newDir)
logger.info("Deleted empty dir " + str(new... | [
"The",
"main",
"routine",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/app.py#L120-L219 | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"logger",
"=",
"cfg",
".",
"configureLogger",
"(",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"cfg",
".",
"dataDir",
")",
":",
"for",
"dir",
"in",
"dirs",
":",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | leap | Determine if this is a leap year in the FR calendar using one of three methods: 4, 100, 128
(every 4th years, every 4th or 400th but not 100th, every 4th but not 128th) | convertdate/french_republican.py | def leap(year, method=None):
'''
Determine if this is a leap year in the FR calendar using one of three methods: 4, 100, 128
(every 4th years, every 4th or 400th but not 100th, every 4th but not 128th)
'''
method = method or 'equinox'
if year in (3, 7, 11):
return True
elif year < ... | def leap(year, method=None):
'''
Determine if this is a leap year in the FR calendar using one of three methods: 4, 100, 128
(every 4th years, every 4th or 400th but not 100th, every 4th but not 128th)
'''
method = method or 'equinox'
if year in (3, 7, 11):
return True
elif year < ... | [
"Determine",
"if",
"this",
"is",
"a",
"leap",
"year",
"in",
"the",
"FR",
"calendar",
"using",
"one",
"of",
"three",
"methods",
":",
"4",
"100",
"128",
"(",
"every",
"4th",
"years",
"every",
"4th",
"or",
"400th",
"but",
"not",
"100th",
"every",
"4th",
... | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L48-L78 | [
"def",
"leap",
"(",
"year",
",",
"method",
"=",
"None",
")",
":",
"method",
"=",
"method",
"or",
"'equinox'",
"if",
"year",
"in",
"(",
"3",
",",
"7",
",",
"11",
")",
":",
"return",
"True",
"elif",
"year",
"<",
"15",
":",
"return",
"False",
"if",
... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | premier_da_la_annee | Determine the year in the French revolutionary calendar in which a given Julian day falls.
Returns Julian day number containing fall equinox (first day of the FR year) | convertdate/french_republican.py | def premier_da_la_annee(jd):
'''Determine the year in the French revolutionary calendar in which a given Julian day falls.
Returns Julian day number containing fall equinox (first day of the FR year)'''
p = ephem.previous_fall_equinox(dublin.from_jd(jd))
previous = trunc(dublin.to_jd(p) - 0.5) + 0.5
... | def premier_da_la_annee(jd):
'''Determine the year in the French revolutionary calendar in which a given Julian day falls.
Returns Julian day number containing fall equinox (first day of the FR year)'''
p = ephem.previous_fall_equinox(dublin.from_jd(jd))
previous = trunc(dublin.to_jd(p) - 0.5) + 0.5
... | [
"Determine",
"the",
"year",
"in",
"the",
"French",
"revolutionary",
"calendar",
"in",
"which",
"a",
"given",
"Julian",
"day",
"falls",
".",
"Returns",
"Julian",
"day",
"number",
"containing",
"fall",
"equinox",
"(",
"first",
"day",
"of",
"the",
"FR",
"year",... | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L81-L95 | [
"def",
"premier_da_la_annee",
"(",
"jd",
")",
":",
"p",
"=",
"ephem",
".",
"previous_fall_equinox",
"(",
"dublin",
".",
"from_jd",
"(",
"jd",
")",
")",
"previous",
"=",
"trunc",
"(",
"dublin",
".",
"to_jd",
"(",
"p",
")",
"-",
"0.5",
")",
"+",
"0.5",... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | to_jd | Obtain Julian day from a given French Revolutionary calendar date. | convertdate/french_republican.py | def to_jd(year, month, day, method=None):
'''Obtain Julian day from a given French Revolutionary calendar date.'''
method = method or 'equinox'
if day < 1 or day > 30:
raise ValueError("Invalid day for this calendar")
if month > 13:
raise ValueError("Invalid month for this calendar")
... | def to_jd(year, month, day, method=None):
'''Obtain Julian day from a given French Revolutionary calendar date.'''
method = method or 'equinox'
if day < 1 or day > 30:
raise ValueError("Invalid day for this calendar")
if month > 13:
raise ValueError("Invalid month for this calendar")
... | [
"Obtain",
"Julian",
"day",
"from",
"a",
"given",
"French",
"Revolutionary",
"calendar",
"date",
"."
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L98-L115 | [
"def",
"to_jd",
"(",
"year",
",",
"month",
",",
"day",
",",
"method",
"=",
"None",
")",
":",
"method",
"=",
"method",
"or",
"'equinox'",
"if",
"day",
"<",
"1",
"or",
"day",
">",
"30",
":",
"raise",
"ValueError",
"(",
"\"Invalid day for this calendar\"",
... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | _to_jd_schematic | Calculate JD using various leap-year calculation methods | convertdate/french_republican.py | def _to_jd_schematic(year, month, day, method):
'''Calculate JD using various leap-year calculation methods'''
y0, y1, y2, y3, y4, y5 = 0, 0, 0, 0, 0, 0
intercal_cycle_yrs, over_cycle_yrs, leap_suppression_yrs = None, None, None
# Use the every-four-years method below year 16 (madler) or below 15 (ro... | def _to_jd_schematic(year, month, day, method):
'''Calculate JD using various leap-year calculation methods'''
y0, y1, y2, y3, y4, y5 = 0, 0, 0, 0, 0, 0
intercal_cycle_yrs, over_cycle_yrs, leap_suppression_yrs = None, None, None
# Use the every-four-years method below year 16 (madler) or below 15 (ro... | [
"Calculate",
"JD",
"using",
"various",
"leap",
"-",
"year",
"calculation",
"methods"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L118-L181 | [
"def",
"_to_jd_schematic",
"(",
"year",
",",
"month",
",",
"day",
",",
"method",
")",
":",
"y0",
",",
"y1",
",",
"y2",
",",
"y3",
",",
"y4",
",",
"y5",
"=",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
"intercal_cycle_yrs",
",",
"ov... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | from_jd | Calculate date in the French Revolutionary
calendar from Julian day. The five or six
"sansculottides" are considered a thirteenth
month in the results of this function. | convertdate/french_republican.py | def from_jd(jd, method=None):
'''Calculate date in the French Revolutionary
calendar from Julian day. The five or six
"sansculottides" are considered a thirteenth
month in the results of this function.'''
method = method or 'equinox'
if method == 'equinox':
return _from_jd_equinox(jd)
... | def from_jd(jd, method=None):
'''Calculate date in the French Revolutionary
calendar from Julian day. The five or six
"sansculottides" are considered a thirteenth
month in the results of this function.'''
method = method or 'equinox'
if method == 'equinox':
return _from_jd_equinox(jd)
... | [
"Calculate",
"date",
"in",
"the",
"French",
"Revolutionary",
"calendar",
"from",
"Julian",
"day",
".",
"The",
"five",
"or",
"six",
"sansculottides",
"are",
"considered",
"a",
"thirteenth",
"month",
"in",
"the",
"results",
"of",
"this",
"function",
"."
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L190-L201 | [
"def",
"from_jd",
"(",
"jd",
",",
"method",
"=",
"None",
")",
":",
"method",
"=",
"method",
"or",
"'equinox'",
"if",
"method",
"==",
"'equinox'",
":",
"return",
"_from_jd_equinox",
"(",
"jd",
")",
"else",
":",
"return",
"_from_jd_schematic",
"(",
"jd",
"... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | _from_jd_schematic | Convert from JD using various leap-year calculation methods | convertdate/french_republican.py | def _from_jd_schematic(jd, method):
'''Convert from JD using various leap-year calculation methods'''
if jd < EPOCH:
raise ValueError("Can't convert days before the French Revolution")
# days since Epoch
J = trunc(jd) + 0.5 - EPOCH
y0, y1, y2, y3, y4, y5 = 0, 0, 0, 0, 0, 0
intercal_cyc... | def _from_jd_schematic(jd, method):
'''Convert from JD using various leap-year calculation methods'''
if jd < EPOCH:
raise ValueError("Can't convert days before the French Revolution")
# days since Epoch
J = trunc(jd) + 0.5 - EPOCH
y0, y1, y2, y3, y4, y5 = 0, 0, 0, 0, 0, 0
intercal_cyc... | [
"Convert",
"from",
"JD",
"using",
"various",
"leap",
"-",
"year",
"calculation",
"methods"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L204-L288 | [
"def",
"_from_jd_schematic",
"(",
"jd",
",",
"method",
")",
":",
"if",
"jd",
"<",
"EPOCH",
":",
"raise",
"ValueError",
"(",
"\"Can't convert days before the French Revolution\"",
")",
"# days since Epoch",
"J",
"=",
"trunc",
"(",
"jd",
")",
"+",
"0.5",
"-",
"E... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | _from_jd_equinox | Calculate the FR day using the equinox as day 1 | convertdate/french_republican.py | def _from_jd_equinox(jd):
'''Calculate the FR day using the equinox as day 1'''
jd = trunc(jd) + 0.5
equinoxe = premier_da_la_annee(jd)
an = gregorian.from_jd(equinoxe)[0] - YEAR_EPOCH
mois = trunc((jd - equinoxe) / 30.) + 1
jour = int((jd - equinoxe) % 30) + 1
return (an, mois, jour) | def _from_jd_equinox(jd):
'''Calculate the FR day using the equinox as day 1'''
jd = trunc(jd) + 0.5
equinoxe = premier_da_la_annee(jd)
an = gregorian.from_jd(equinoxe)[0] - YEAR_EPOCH
mois = trunc((jd - equinoxe) / 30.) + 1
jour = int((jd - equinoxe) % 30) + 1
return (an, mois, jour) | [
"Calculate",
"the",
"FR",
"day",
"using",
"the",
"equinox",
"as",
"day",
"1"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/french_republican.py#L291-L300 | [
"def",
"_from_jd_equinox",
"(",
"jd",
")",
":",
"jd",
"=",
"trunc",
"(",
"jd",
")",
"+",
"0.5",
"equinoxe",
"=",
"premier_da_la_annee",
"(",
"jd",
")",
"an",
"=",
"gregorian",
".",
"from_jd",
"(",
"equinoxe",
")",
"[",
"0",
"]",
"-",
"YEAR_EPOCH",
"m... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | to_jd | Obtain Julian day for Indian Civil date | convertdate/indian_civil.py | def to_jd(year, month, day):
'''Obtain Julian day for Indian Civil date'''
gyear = year + 78
leap = isleap(gyear)
# // Is this a leap year ?
# 22 - leap = 21 if leap, 22 non-leap
start = gregorian.to_jd(gyear, 3, 22 - leap)
if leap:
Caitra = 31
else:
Caitra = 30
if... | def to_jd(year, month, day):
'''Obtain Julian day for Indian Civil date'''
gyear = year + 78
leap = isleap(gyear)
# // Is this a leap year ?
# 22 - leap = 21 if leap, 22 non-leap
start = gregorian.to_jd(gyear, 3, 22 - leap)
if leap:
Caitra = 31
else:
Caitra = 30
if... | [
"Obtain",
"Julian",
"day",
"for",
"Indian",
"Civil",
"date"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/indian_civil.py#L47-L74 | [
"def",
"to_jd",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"gyear",
"=",
"year",
"+",
"78",
"leap",
"=",
"isleap",
"(",
"gyear",
")",
"# // Is this a leap year ?",
"# 22 - leap = 21 if leap, 22 non-leap",
"start",
"=",
"gregorian",
".",
"to_jd",
"(",
"... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | from_jd | Calculate Indian Civil date from Julian day
Offset in years from Saka era to Gregorian epoch | convertdate/indian_civil.py | def from_jd(jd):
'''Calculate Indian Civil date from Julian day
Offset in years from Saka era to Gregorian epoch'''
start = 80
# Day offset between Saka and Gregorian
jd = trunc(jd) + 0.5
greg = gregorian.from_jd(jd) # Gregorian date for Julian day
leap = isleap(greg[0]) # Is this a leap... | def from_jd(jd):
'''Calculate Indian Civil date from Julian day
Offset in years from Saka era to Gregorian epoch'''
start = 80
# Day offset between Saka and Gregorian
jd = trunc(jd) + 0.5
greg = gregorian.from_jd(jd) # Gregorian date for Julian day
leap = isleap(greg[0]) # Is this a leap... | [
"Calculate",
"Indian",
"Civil",
"date",
"from",
"Julian",
"day",
"Offset",
"in",
"years",
"from",
"Saka",
"era",
"to",
"Gregorian",
"epoch"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/indian_civil.py#L77-L117 | [
"def",
"from_jd",
"(",
"jd",
")",
":",
"start",
"=",
"80",
"# Day offset between Saka and Gregorian",
"jd",
"=",
"trunc",
"(",
"jd",
")",
"+",
"0.5",
"greg",
"=",
"gregorian",
".",
"from_jd",
"(",
"jd",
")",
"# Gregorian date for Julian day",
"leap",
"=",
"i... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | format_stack | Returns a one-line string with the current callstack. | src/aspectlib/debug.py | def format_stack(skip=0, length=6, _sep=os.path.sep):
"""
Returns a one-line string with the current callstack.
"""
return ' < '.join("%s:%s:%s" % (
'/'.join(f.f_code.co_filename.split(_sep)[-2:]),
f.f_lineno,
f.f_code.co_name
) for f in islice(frame_iterator(sys._getframe(1 ... | def format_stack(skip=0, length=6, _sep=os.path.sep):
"""
Returns a one-line string with the current callstack.
"""
return ' < '.join("%s:%s:%s" % (
'/'.join(f.f_code.co_filename.split(_sep)[-2:]),
f.f_lineno,
f.f_code.co_name
) for f in islice(frame_iterator(sys._getframe(1 ... | [
"Returns",
"a",
"one",
"-",
"line",
"string",
"with",
"the",
"current",
"callstack",
"."
] | ionelmc/python-aspectlib | python | https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/debug.py#L27-L35 | [
"def",
"format_stack",
"(",
"skip",
"=",
"0",
",",
"length",
"=",
"6",
",",
"_sep",
"=",
"os",
".",
"path",
".",
"sep",
")",
":",
"return",
"' < '",
".",
"join",
"(",
"\"%s:%s:%s\"",
"%",
"(",
"'/'",
".",
"join",
"(",
"f",
".",
"f_code",
".",
"... | 7dba7651ab76160b9ce66c9c11e770f7844e95ec |
train | log | Decorates `func` to have logging.
Args
func (function):
Function to decorate. If missing log returns a partial which you can use as a decorator.
stacktrace (int):
Number of frames to show.
stacktrace_align (int):
Column to align the framelist to.
... | src/aspectlib/debug.py | def log(func=None,
stacktrace=10,
stacktrace_align=60,
attributes=(),
module=True,
call=True,
call_args=True,
call_args_repr=repr,
result=True,
exception=True,
exception_repr=repr,
result_repr=strip_non_ascii,
use_logging='C... | def log(func=None,
stacktrace=10,
stacktrace_align=60,
attributes=(),
module=True,
call=True,
call_args=True,
call_args_repr=repr,
result=True,
exception=True,
exception_repr=repr,
result_repr=strip_non_ascii,
use_logging='C... | [
"Decorates",
"func",
"to",
"have",
"logging",
"."
] | ionelmc/python-aspectlib | python | https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/debug.py#L48-L233 | [
"def",
"log",
"(",
"func",
"=",
"None",
",",
"stacktrace",
"=",
"10",
",",
"stacktrace_align",
"=",
"60",
",",
"attributes",
"=",
"(",
")",
",",
"module",
"=",
"True",
",",
"call",
"=",
"True",
",",
"call_args",
"=",
"True",
",",
"call_args_repr",
"=... | 7dba7651ab76160b9ce66c9c11e770f7844e95ec |
train | wireHandlers | If the device is configured to run against a remote server, ping that device on a scheduled basis with our current
state.
:param cfg: the config object.
:return: | backend/src/recorder/app.py | def wireHandlers(cfg):
"""
If the device is configured to run against a remote server, ping that device on a scheduled basis with our current
state.
:param cfg: the config object.
:return:
"""
logger = logging.getLogger('recorder')
httpPoster = cfg.handlers.get('remote')
csvLogger = ... | def wireHandlers(cfg):
"""
If the device is configured to run against a remote server, ping that device on a scheduled basis with our current
state.
:param cfg: the config object.
:return:
"""
logger = logging.getLogger('recorder')
httpPoster = cfg.handlers.get('remote')
csvLogger = ... | [
"If",
"the",
"device",
"is",
"configured",
"to",
"run",
"against",
"a",
"remote",
"server",
"ping",
"that",
"device",
"on",
"a",
"scheduled",
"basis",
"with",
"our",
"current",
"state",
".",
":",
"param",
"cfg",
":",
"the",
"config",
"object",
".",
":",
... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/app.py#L55-L83 | [
"def",
"wireHandlers",
"(",
"cfg",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'recorder'",
")",
"httpPoster",
"=",
"cfg",
".",
"handlers",
".",
"get",
"(",
"'remote'",
")",
"csvLogger",
"=",
"cfg",
".",
"handlers",
".",
"get",
"(",
"'l... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | main | The main routine. | backend/src/recorder/app.py | def main(args=None):
""" The main routine. """
cfg.configureLogger()
wireHandlers(cfg)
# get config from a flask standard place not our config yml
app.run(debug=cfg.runInDebug(), host='0.0.0.0', port=cfg.getPort()) | def main(args=None):
""" The main routine. """
cfg.configureLogger()
wireHandlers(cfg)
# get config from a flask standard place not our config yml
app.run(debug=cfg.runInDebug(), host='0.0.0.0', port=cfg.getPort()) | [
"The",
"main",
"routine",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/app.py#L86-L91 | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"cfg",
".",
"configureLogger",
"(",
")",
"wireHandlers",
"(",
"cfg",
")",
"# get config from a flask standard place not our config yml",
"app",
".",
"run",
"(",
"debug",
"=",
"cfg",
".",
"runInDebug",
"(",
")"... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Measurements.get | lists all known active measurements. | backend/src/recorder/resources/measurements.py | def get(self, deviceId):
"""
lists all known active measurements.
"""
measurementsByName = self.measurements.get(deviceId)
if measurementsByName is None:
return []
else:
return list(measurementsByName.values()) | def get(self, deviceId):
"""
lists all known active measurements.
"""
measurementsByName = self.measurements.get(deviceId)
if measurementsByName is None:
return []
else:
return list(measurementsByName.values()) | [
"lists",
"all",
"known",
"active",
"measurements",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L25-L33 | [
"def",
"get",
"(",
"self",
",",
"deviceId",
")",
":",
"measurementsByName",
"=",
"self",
".",
"measurements",
".",
"get",
"(",
"deviceId",
")",
"if",
"measurementsByName",
"is",
"None",
":",
"return",
"[",
"]",
"else",
":",
"return",
"list",
"(",
"measur... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Measurement.get | details the specific measurement. | backend/src/recorder/resources/measurements.py | def get(self, deviceId, measurementId):
"""
details the specific measurement.
"""
record = self.measurements.get(deviceId)
if record is not None:
return record.get(measurementId)
return None | def get(self, deviceId, measurementId):
"""
details the specific measurement.
"""
record = self.measurements.get(deviceId)
if record is not None:
return record.get(measurementId)
return None | [
"details",
"the",
"specific",
"measurement",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L42-L49 | [
"def",
"get",
"(",
"self",
",",
"deviceId",
",",
"measurementId",
")",
":",
"record",
"=",
"self",
".",
"measurements",
".",
"get",
"(",
"deviceId",
")",
"if",
"record",
"is",
"not",
"None",
":",
"return",
"record",
".",
"get",
"(",
"measurementId",
")... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Measurement.put | Schedules a new measurement at the specified time.
:param deviceId: the device to measure.
:param measurementId: the name of the measurement.
:return: 200 if it was scheduled, 400 if the device is busy, 500 if the device is bad. | backend/src/recorder/resources/measurements.py | def put(self, deviceId, measurementId):
"""
Schedules a new measurement at the specified time.
:param deviceId: the device to measure.
:param measurementId: the name of the measurement.
:return: 200 if it was scheduled, 400 if the device is busy, 500 if the device is bad.
... | def put(self, deviceId, measurementId):
"""
Schedules a new measurement at the specified time.
:param deviceId: the device to measure.
:param measurementId: the name of the measurement.
:return: 200 if it was scheduled, 400 if the device is busy, 500 if the device is bad.
... | [
"Schedules",
"a",
"new",
"measurement",
"at",
"the",
"specified",
"time",
".",
":",
"param",
"deviceId",
":",
"the",
"device",
"to",
"measure",
".",
":",
"param",
"measurementId",
":",
"the",
"name",
"of",
"the",
"measurement",
".",
":",
"return",
":",
"... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L52-L81 | [
"def",
"put",
"(",
"self",
",",
"deviceId",
",",
"measurementId",
")",
":",
"record",
"=",
"self",
".",
"measurements",
".",
"get",
"(",
"deviceId",
")",
"if",
"record",
"is",
"not",
"None",
":",
"measurement",
"=",
"record",
".",
"get",
"(",
"measurem... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Measurement.delete | Deletes a stored measurement.
:param deviceId: the device to measure.
:param measurementId: the name of the measurement.
:return: 200 if it was deleted, 400 if no such measurement (or device). | backend/src/recorder/resources/measurements.py | def delete(self, deviceId, measurementId):
"""
Deletes a stored measurement.
:param deviceId: the device to measure.
:param measurementId: the name of the measurement.
:return: 200 if it was deleted, 400 if no such measurement (or device).
"""
record = self.measur... | def delete(self, deviceId, measurementId):
"""
Deletes a stored measurement.
:param deviceId: the device to measure.
:param measurementId: the name of the measurement.
:return: 200 if it was deleted, 400 if no such measurement (or device).
"""
record = self.measur... | [
"Deletes",
"a",
"stored",
"measurement",
".",
":",
"param",
"deviceId",
":",
"the",
"device",
"to",
"measure",
".",
":",
"param",
"measurementId",
":",
"the",
"name",
"of",
"the",
"measurement",
".",
":",
"return",
":",
"200",
"if",
"it",
"was",
"deleted... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L84-L95 | [
"def",
"delete",
"(",
"self",
",",
"deviceId",
",",
"measurementId",
")",
":",
"record",
"=",
"self",
".",
"measurements",
".",
"get",
"(",
"deviceId",
")",
"if",
"record",
"is",
"not",
"None",
":",
"popped",
"=",
"record",
".",
"pop",
"(",
"measuremen... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | AbortMeasurement.get | signals a stop for the given measurement.
:param deviceId: the device to measure.
:param measurementId: the name of the measurement.
:return: 200 if stop is signalled, 400 if it doesn't exist or is not running. | backend/src/recorder/resources/measurements.py | def get(self, deviceId, measurementId):
"""
signals a stop for the given measurement.
:param deviceId: the device to measure.
:param measurementId: the name of the measurement.
:return: 200 if stop is signalled, 400 if it doesn't exist or is not running.
"""
recor... | def get(self, deviceId, measurementId):
"""
signals a stop for the given measurement.
:param deviceId: the device to measure.
:param measurementId: the name of the measurement.
:return: 200 if stop is signalled, 400 if it doesn't exist or is not running.
"""
recor... | [
"signals",
"a",
"stop",
"for",
"the",
"given",
"measurement",
".",
":",
"param",
"deviceId",
":",
"the",
"device",
"to",
"measure",
".",
":",
"param",
"measurementId",
":",
"the",
"name",
"of",
"the",
"measurement",
".",
":",
"return",
":",
"200",
"if",
... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L104-L120 | [
"def",
"get",
"(",
"self",
",",
"deviceId",
",",
"measurementId",
")",
":",
"record",
"=",
"self",
".",
"measurements",
".",
"get",
"(",
"deviceId",
")",
"if",
"record",
"is",
"not",
"None",
":",
"measurement",
"=",
"record",
".",
"get",
"(",
"measurem... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | ScheduledMeasurement.schedule | schedules the measurement (to execute asynchronously).
:param duration: how long to run for.
:param at: the time to start at.
:param delay: the time to wait til starting (use at or delay).
:param callback: a callback.
:return: nothing. | backend/src/recorder/resources/measurements.py | def schedule(self, duration, at=None, delay=None, callback=None):
"""
schedules the measurement (to execute asynchronously).
:param duration: how long to run for.
:param at: the time to start at.
:param delay: the time to wait til starting (use at or delay).
:param callba... | def schedule(self, duration, at=None, delay=None, callback=None):
"""
schedules the measurement (to execute asynchronously).
:param duration: how long to run for.
:param at: the time to start at.
:param delay: the time to wait til starting (use at or delay).
:param callba... | [
"schedules",
"the",
"measurement",
"(",
"to",
"execute",
"asynchronously",
")",
".",
":",
"param",
"duration",
":",
"how",
"long",
"to",
"run",
"for",
".",
":",
"param",
"at",
":",
"the",
"time",
"to",
"start",
"at",
".",
":",
"param",
"delay",
":",
... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L148-L161 | [
"def",
"schedule",
"(",
"self",
",",
"duration",
",",
"at",
"=",
"None",
",",
"delay",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"delay",
"=",
"self",
".",
"calculateDelay",
"(",
"at",
",",
"delay",
")",
"self",
".",
"callback",
"=",
"ca... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | ScheduledMeasurement.execute | Executes the measurement, recording the event status.
:param duration: the time to run for.
:return: nothing. | backend/src/recorder/resources/measurements.py | def execute(self, duration):
"""
Executes the measurement, recording the event status.
:param duration: the time to run for.
:return: nothing.
"""
self.statuses.append({'name': ScheduledMeasurementStatus.RUNNING.name, 'time': datetime.utcnow()})
try:
s... | def execute(self, duration):
"""
Executes the measurement, recording the event status.
:param duration: the time to run for.
:return: nothing.
"""
self.statuses.append({'name': ScheduledMeasurementStatus.RUNNING.name, 'time': datetime.utcnow()})
try:
s... | [
"Executes",
"the",
"measurement",
"recording",
"the",
"event",
"status",
".",
":",
"param",
"duration",
":",
"the",
"time",
"to",
"run",
"for",
".",
":",
"return",
":",
"nothing",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L163-L183 | [
"def",
"execute",
"(",
"self",
",",
"duration",
")",
":",
"self",
".",
"statuses",
".",
"append",
"(",
"{",
"'name'",
":",
"ScheduledMeasurementStatus",
".",
"RUNNING",
".",
"name",
",",
"'time'",
":",
"datetime",
".",
"utcnow",
"(",
")",
"}",
")",
"tr... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | ScheduledMeasurement.calculateDelay | Creates the delay from now til the specified start time, uses "at" if available.
:param at: the start time in %a %b %d %H:%M:%S %Y format.
:param delay: the delay from now til start.
:return: the delay. | backend/src/recorder/resources/measurements.py | def calculateDelay(self, at, delay):
"""
Creates the delay from now til the specified start time, uses "at" if available.
:param at: the start time in %a %b %d %H:%M:%S %Y format.
:param delay: the delay from now til start.
:return: the delay.
"""
if at is not Non... | def calculateDelay(self, at, delay):
"""
Creates the delay from now til the specified start time, uses "at" if available.
:param at: the start time in %a %b %d %H:%M:%S %Y format.
:param delay: the delay from now til start.
:return: the delay.
"""
if at is not Non... | [
"Creates",
"the",
"delay",
"from",
"now",
"til",
"the",
"specified",
"start",
"time",
"uses",
"at",
"if",
"available",
".",
":",
"param",
"at",
":",
"the",
"start",
"time",
"in",
"%a",
"%b",
"%d",
"%H",
":",
"%M",
":",
"%S",
"%Y",
"format",
".",
":... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/resources/measurements.py#L185-L197 | [
"def",
"calculateDelay",
"(",
"self",
",",
"at",
",",
"delay",
")",
":",
"if",
"at",
"is",
"not",
"None",
":",
"return",
"max",
"(",
"(",
"datetime",
".",
"strptime",
"(",
"at",
",",
"DATETIME_FORMAT",
")",
"-",
"datetime",
".",
"utcnow",
"(",
")",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | launch_and_wait | Given a list of multiprocessing.Process objects which have not yet
been started, this function launches them and blocks until the last
finishes. This makes sure that only <pool_size> processes are ever
working at any one time (this number does not include the main process
which called this function, si... | lib/stsci/tools/mputil.py | def launch_and_wait(mp_proc_list, pool_size):
""" Given a list of multiprocessing.Process objects which have not yet
been started, this function launches them and blocks until the last
finishes. This makes sure that only <pool_size> processes are ever
working at any one time (this number does not inclu... | def launch_and_wait(mp_proc_list, pool_size):
""" Given a list of multiprocessing.Process objects which have not yet
been started, this function launches them and blocks until the last
finishes. This makes sure that only <pool_size> processes are ever
working at any one time (this number does not inclu... | [
"Given",
"a",
"list",
"of",
"multiprocessing",
".",
"Process",
"objects",
"which",
"have",
"not",
"yet",
"been",
"started",
"this",
"function",
"launches",
"them",
"and",
"blocks",
"until",
"the",
"last",
"finishes",
".",
"This",
"makes",
"sure",
"that",
"on... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/mputil.py#L36-L103 | [
"def",
"launch_and_wait",
"(",
"mp_proc_list",
",",
"pool_size",
")",
":",
"# Sanity check",
"if",
"len",
"(",
"mp_proc_list",
")",
"<",
"1",
":",
"return",
"# Create or own list with easy state watching",
"procs",
"=",
"[",
"]",
"for",
"p",
"in",
"mp_proc_list",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | best_tile_layout | Determine and return the best layout of "tiles" for fastest
overall parallel processing of a rectangular image broken up into N
smaller equally-sized rectangular tiles, given as input the number
of processes/chunks which can be run/worked at the same time (pool_size).
This attempts to return a layout w... | lib/stsci/tools/mputil.py | def best_tile_layout(pool_size):
""" Determine and return the best layout of "tiles" for fastest
overall parallel processing of a rectangular image broken up into N
smaller equally-sized rectangular tiles, given as input the number
of processes/chunks which can be run/worked at the same time (pool_size)... | def best_tile_layout(pool_size):
""" Determine and return the best layout of "tiles" for fastest
overall parallel processing of a rectangular image broken up into N
smaller equally-sized rectangular tiles, given as input the number
of processes/chunks which can be run/worked at the same time (pool_size)... | [
"Determine",
"and",
"return",
"the",
"best",
"layout",
"of",
"tiles",
"for",
"fastest",
"overall",
"parallel",
"processing",
"of",
"a",
"rectangular",
"image",
"broken",
"up",
"into",
"N",
"smaller",
"equally",
"-",
"sized",
"rectangular",
"tiles",
"given",
"a... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/mputil.py#L107-L160 | [
"def",
"best_tile_layout",
"(",
"pool_size",
")",
":",
"# Easy answer sanity-checks",
"if",
"pool_size",
"<",
"2",
":",
"return",
"(",
"1",
",",
"1",
")",
"# Next, use a small mapping of hard-coded results. While we agree",
"# that many of these are unlikely pool_size values, ... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | Reactor._accept | Work loop runs forever (or until running is False)
:return: | backend/src/core/reactor.py | def _accept(self):
"""
Work loop runs forever (or until running is False)
:return:
"""
logger.warning("Reactor " + self._name + " is starting")
while self.running:
try:
self._completeTask()
except:
logger.exception("... | def _accept(self):
"""
Work loop runs forever (or until running is False)
:return:
"""
logger.warning("Reactor " + self._name + " is starting")
while self.running:
try:
self._completeTask()
except:
logger.exception("... | [
"Work",
"loop",
"runs",
"forever",
"(",
"or",
"until",
"running",
"is",
"False",
")",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/reactor.py#L23-L34 | [
"def",
"_accept",
"(",
"self",
")",
":",
"logger",
".",
"warning",
"(",
"\"Reactor \"",
"+",
"self",
".",
"_name",
"+",
"\" is starting\"",
")",
"while",
"self",
".",
"running",
":",
"try",
":",
"self",
".",
"_completeTask",
"(",
")",
"except",
":",
"l... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | Reactor.offer | public interface to the reactor.
:param requestType:
:param args:
:return: | backend/src/core/reactor.py | def offer(self, requestType, *args):
"""
public interface to the reactor.
:param requestType:
:param args:
:return:
"""
if self._funcsByRequest.get(requestType) is not None:
self._workQueue.put((requestType, list(*args)))
else:
logg... | def offer(self, requestType, *args):
"""
public interface to the reactor.
:param requestType:
:param args:
:return:
"""
if self._funcsByRequest.get(requestType) is not None:
self._workQueue.put((requestType, list(*args)))
else:
logg... | [
"public",
"interface",
"to",
"the",
"reactor",
".",
":",
"param",
"requestType",
":",
":",
"param",
"args",
":",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/reactor.py#L58-L68 | [
"def",
"offer",
"(",
"self",
",",
"requestType",
",",
"*",
"args",
")",
":",
"if",
"self",
".",
"_funcsByRequest",
".",
"get",
"(",
"requestType",
")",
"is",
"not",
"None",
":",
"self",
".",
"_workQueue",
".",
"put",
"(",
"(",
"requestType",
",",
"li... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | TealActionParButton.clicked | Called when this button is clicked. Execute code from .cfgspc | lib/stsci/tools/teal_bttn.py | def clicked(self):
""" Called when this button is clicked. Execute code from .cfgspc """
try:
from . import teal
except:
teal = None
try:
# start drilling down into the tpo to get the code
tealGui = self._mainGuiObj
tealGui.show... | def clicked(self):
""" Called when this button is clicked. Execute code from .cfgspc """
try:
from . import teal
except:
teal = None
try:
# start drilling down into the tpo to get the code
tealGui = self._mainGuiObj
tealGui.show... | [
"Called",
"when",
"this",
"button",
"is",
"clicked",
".",
"Execute",
"code",
"from",
".",
"cfgspc"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal_bttn.py#L31-L70 | [
"def",
"clicked",
"(",
"self",
")",
":",
"try",
":",
"from",
".",
"import",
"teal",
"except",
":",
"teal",
"=",
"None",
"try",
":",
"# start drilling down into the tpo to get the code",
"tealGui",
"=",
"self",
".",
"_mainGuiObj",
"tealGui",
".",
"showStatus",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | ndarr2str | This is used to ensure that the return value of arr.tostring()
is actually a string. This will prevent lots of if-checks in calling
code. As of numpy v1.6.1 (in Python 3.2.3), the tostring() function
still returns type 'bytes', not 'str' as it advertises. | lib/stsci/tools/for2to3.py | def ndarr2str(arr, encoding='ascii'):
""" This is used to ensure that the return value of arr.tostring()
is actually a string. This will prevent lots of if-checks in calling
code. As of numpy v1.6.1 (in Python 3.2.3), the tostring() function
still returns type 'bytes', not 'str' as it advertises. """
... | def ndarr2str(arr, encoding='ascii'):
""" This is used to ensure that the return value of arr.tostring()
is actually a string. This will prevent lots of if-checks in calling
code. As of numpy v1.6.1 (in Python 3.2.3), the tostring() function
still returns type 'bytes', not 'str' as it advertises. """
... | [
"This",
"is",
"used",
"to",
"ensure",
"that",
"the",
"return",
"value",
"of",
"arr",
".",
"tostring",
"()",
"is",
"actually",
"a",
"string",
".",
"This",
"will",
"prevent",
"lots",
"of",
"if",
"-",
"checks",
"in",
"calling",
"code",
".",
"As",
"of",
... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/for2to3.py#L15-L28 | [
"def",
"ndarr2str",
"(",
"arr",
",",
"encoding",
"=",
"'ascii'",
")",
":",
"# be fast, don't check - just assume 'arr' is a numpy array - the tostring",
"# call will fail anyway if not",
"retval",
"=",
"arr",
".",
"tostring",
"(",
")",
"# would rather check \"if isinstance(retv... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | ndarr2bytes | This is used to ensure that the return value of arr.tostring()
is actually a *bytes* array in PY3K. See notes in ndarr2str above. Even
though we consider it a bug that numpy's tostring() function returns
a bytes array in PY3K, there are actually many instances where that is what
we want - bytes, not u... | lib/stsci/tools/for2to3.py | def ndarr2bytes(arr, encoding='ascii'):
""" This is used to ensure that the return value of arr.tostring()
is actually a *bytes* array in PY3K. See notes in ndarr2str above. Even
though we consider it a bug that numpy's tostring() function returns
a bytes array in PY3K, there are actually many instanc... | def ndarr2bytes(arr, encoding='ascii'):
""" This is used to ensure that the return value of arr.tostring()
is actually a *bytes* array in PY3K. See notes in ndarr2str above. Even
though we consider it a bug that numpy's tostring() function returns
a bytes array in PY3K, there are actually many instanc... | [
"This",
"is",
"used",
"to",
"ensure",
"that",
"the",
"return",
"value",
"of",
"arr",
".",
"tostring",
"()",
"is",
"actually",
"a",
"*",
"bytes",
"*",
"array",
"in",
"PY3K",
".",
"See",
"notes",
"in",
"ndarr2str",
"above",
".",
"Even",
"though",
"we",
... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/for2to3.py#L31-L50 | [
"def",
"ndarr2bytes",
"(",
"arr",
",",
"encoding",
"=",
"'ascii'",
")",
":",
"# be fast, don't check - just assume 'arr' is a numpy array - the tostring",
"# call will fail anyway if not",
"retval",
"=",
"arr",
".",
"tostring",
"(",
")",
"# would rather check \"if not isinstanc... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | tobytes | Convert string s to the 'bytes' type, in all Pythons, even
back before Python 2.6. What 'str' means varies by PY3K or not.
In Pythons before 3.0, this is technically the same as the str type
in terms of the character data in memory. | lib/stsci/tools/for2to3.py | def tobytes(s, encoding='ascii'):
""" Convert string s to the 'bytes' type, in all Pythons, even
back before Python 2.6. What 'str' means varies by PY3K or not.
In Pythons before 3.0, this is technically the same as the str type
in terms of the character data in memory. """
# NOTE: after we abandon... | def tobytes(s, encoding='ascii'):
""" Convert string s to the 'bytes' type, in all Pythons, even
back before Python 2.6. What 'str' means varies by PY3K or not.
In Pythons before 3.0, this is technically the same as the str type
in terms of the character data in memory. """
# NOTE: after we abandon... | [
"Convert",
"string",
"s",
"to",
"the",
"bytes",
"type",
"in",
"all",
"Pythons",
"even",
"back",
"before",
"Python",
"2",
".",
"6",
".",
"What",
"str",
"means",
"varies",
"by",
"PY3K",
"or",
"not",
".",
"In",
"Pythons",
"before",
"3",
".",
"0",
"this"... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/for2to3.py#L53-L71 | [
"def",
"tobytes",
"(",
"s",
",",
"encoding",
"=",
"'ascii'",
")",
":",
"# NOTE: after we abandon 2.5, we might simply instead use \"bytes(s)\"",
"# NOTE: after we abandon all 2.*, del this and prepend byte strings with 'b'",
"if",
"PY3K",
":",
"if",
"isinstance",
"(",
"s",
",",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | tostr | Convert string-like-thing s to the 'str' type, in all Pythons, even
back before Python 2.6. What 'str' means varies by PY3K or not.
In Pythons before 3.0, str and bytes are the same type.
In Python 3+, this may require a decoding step. | lib/stsci/tools/for2to3.py | def tostr(s, encoding='ascii'):
""" Convert string-like-thing s to the 'str' type, in all Pythons, even
back before Python 2.6. What 'str' means varies by PY3K or not.
In Pythons before 3.0, str and bytes are the same type.
In Python 3+, this may require a decoding step. """
if PY3K:
if isi... | def tostr(s, encoding='ascii'):
""" Convert string-like-thing s to the 'str' type, in all Pythons, even
back before Python 2.6. What 'str' means varies by PY3K or not.
In Pythons before 3.0, str and bytes are the same type.
In Python 3+, this may require a decoding step. """
if PY3K:
if isi... | [
"Convert",
"string",
"-",
"like",
"-",
"thing",
"s",
"to",
"the",
"str",
"type",
"in",
"all",
"Pythons",
"even",
"back",
"before",
"Python",
"2",
".",
"6",
".",
"What",
"str",
"means",
"varies",
"by",
"PY3K",
"or",
"not",
".",
"In",
"Pythons",
"befor... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/for2to3.py#L73-L89 | [
"def",
"tostr",
"(",
"s",
",",
"encoding",
"=",
"'ascii'",
")",
":",
"if",
"PY3K",
":",
"if",
"isinstance",
"(",
"s",
",",
"str",
")",
":",
"# str == unicode in PY3K",
"return",
"s",
"else",
":",
"# s is type bytes",
"return",
"s",
".",
"decode",
"(",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | retry | Decorator that retries the call ``retries`` times if ``func`` raises ``exceptions``. Can use a ``backoff`` function
to sleep till next retry.
Example::
>>> should_fail = lambda foo=[1,2,3]: foo and foo.pop()
>>> @retry
... def flaky_func():
... if should_fail():
...... | src/aspectlib/contrib.py | def retry(func=None, retries=5, backoff=None, exceptions=(IOError, OSError, EOFError), cleanup=None, sleep=time.sleep):
"""
Decorator that retries the call ``retries`` times if ``func`` raises ``exceptions``. Can use a ``backoff`` function
to sleep till next retry.
Example::
>>> should_fail = ... | def retry(func=None, retries=5, backoff=None, exceptions=(IOError, OSError, EOFError), cleanup=None, sleep=time.sleep):
"""
Decorator that retries the call ``retries`` times if ``func`` raises ``exceptions``. Can use a ``backoff`` function
to sleep till next retry.
Example::
>>> should_fail = ... | [
"Decorator",
"that",
"retries",
"the",
"call",
"retries",
"times",
"if",
"func",
"raises",
"exceptions",
".",
"Can",
"use",
"a",
"backoff",
"function",
"to",
"sleep",
"till",
"next",
"retry",
"."
] | ionelmc/python-aspectlib | python | https://github.com/ionelmc/python-aspectlib/blob/7dba7651ab76160b9ce66c9c11e770f7844e95ec/src/aspectlib/contrib.py#L9-L60 | [
"def",
"retry",
"(",
"func",
"=",
"None",
",",
"retries",
"=",
"5",
",",
"backoff",
"=",
"None",
",",
"exceptions",
"=",
"(",
"IOError",
",",
"OSError",
",",
"EOFError",
")",
",",
"cleanup",
"=",
"None",
",",
"sleep",
"=",
"time",
".",
"sleep",
")"... | 7dba7651ab76160b9ce66c9c11e770f7844e95ec |
train | UploadController.loadSignal | Loads the named entry from the upload cache as a signal.
:param name: the name.
:param start: the time to start from in HH:mm:ss.SSS format
:param end: the time to end at in HH:mm:ss.SSS format.
:return: the signal if the named upload exists. | backend/src/analyser/common/uploadcontroller.py | def loadSignal(self, name, start=None, end=None):
"""
Loads the named entry from the upload cache as a signal.
:param name: the name.
:param start: the time to start from in HH:mm:ss.SSS format
:param end: the time to end at in HH:mm:ss.SSS format.
:return: the signal if ... | def loadSignal(self, name, start=None, end=None):
"""
Loads the named entry from the upload cache as a signal.
:param name: the name.
:param start: the time to start from in HH:mm:ss.SSS format
:param end: the time to end at in HH:mm:ss.SSS format.
:return: the signal if ... | [
"Loads",
"the",
"named",
"entry",
"from",
"the",
"upload",
"cache",
"as",
"a",
"signal",
".",
":",
"param",
"name",
":",
"the",
"name",
".",
":",
"param",
"start",
":",
"the",
"time",
"to",
"start",
"from",
"in",
"HH",
":",
"mm",
":",
"ss",
".",
... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L41-L54 | [
"def",
"loadSignal",
"(",
"self",
",",
"name",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"entry",
"=",
"self",
".",
"_getCacheEntry",
"(",
"name",
")",
"if",
"entry",
"is",
"not",
"None",
":",
"from",
"analyser",
".",
"common",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | UploadController._getCacheEntry | :param name: the name of the cache entry.
:return: the entry or none. | backend/src/analyser/common/uploadcontroller.py | def _getCacheEntry(self, name):
"""
:param name: the name of the cache entry.
:return: the entry or none.
"""
return next((x for x in self._uploadCache if x['name'] == name), None) | def _getCacheEntry(self, name):
"""
:param name: the name of the cache entry.
:return: the entry or none.
"""
return next((x for x in self._uploadCache if x['name'] == name), None) | [
":",
"param",
"name",
":",
"the",
"name",
"of",
"the",
"cache",
"entry",
".",
":",
"return",
":",
"the",
"entry",
"or",
"none",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L56-L61 | [
"def",
"_getCacheEntry",
"(",
"self",
",",
"name",
")",
":",
"return",
"next",
"(",
"(",
"x",
"for",
"x",
"in",
"self",
".",
"_uploadCache",
"if",
"x",
"[",
"'name'",
"]",
"==",
"name",
")",
",",
"None",
")"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | UploadController._convertTmp | Moves a tmp file to the upload dir, resampling it if necessary, and then deleting the tmp entries.
:param tmpCacheEntry: the cache entry.
:return: | backend/src/analyser/common/uploadcontroller.py | def _convertTmp(self, tmpCacheEntry):
"""
Moves a tmp file to the upload dir, resampling it if necessary, and then deleting the tmp entries.
:param tmpCacheEntry: the cache entry.
:return:
"""
from analyser.common.signal import loadSignalFromWav
tmpCacheEntry['sta... | def _convertTmp(self, tmpCacheEntry):
"""
Moves a tmp file to the upload dir, resampling it if necessary, and then deleting the tmp entries.
:param tmpCacheEntry: the cache entry.
:return:
"""
from analyser.common.signal import loadSignalFromWav
tmpCacheEntry['sta... | [
"Moves",
"a",
"tmp",
"file",
"to",
"the",
"upload",
"dir",
"resampling",
"it",
"if",
"necessary",
"and",
"then",
"deleting",
"the",
"tmp",
"entries",
".",
":",
"param",
"tmpCacheEntry",
":",
"the",
"cache",
"entry",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L94-L121 | [
"def",
"_convertTmp",
"(",
"self",
",",
"tmpCacheEntry",
")",
":",
"from",
"analyser",
".",
"common",
".",
"signal",
"import",
"loadSignalFromWav",
"tmpCacheEntry",
"[",
"'status'",
"]",
"=",
"'converting'",
"logger",
".",
"info",
"(",
"\"Loading \"",
"+",
"tm... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | UploadController.writeChunk | Streams an uploaded chunk to a file.
:param stream: the binary stream that contains the file.
:param filename: the name of the file.
:param chunkIdx: optional chunk index (for writing to a tmp dir)
:return: no of bytes written or -1 if there was an error. | backend/src/analyser/common/uploadcontroller.py | def writeChunk(self, stream, filename, chunkIdx=None):
"""
Streams an uploaded chunk to a file.
:param stream: the binary stream that contains the file.
:param filename: the name of the file.
:param chunkIdx: optional chunk index (for writing to a tmp dir)
:return: no of... | def writeChunk(self, stream, filename, chunkIdx=None):
"""
Streams an uploaded chunk to a file.
:param stream: the binary stream that contains the file.
:param filename: the name of the file.
:param chunkIdx: optional chunk index (for writing to a tmp dir)
:return: no of... | [
"Streams",
"an",
"uploaded",
"chunk",
"to",
"a",
"file",
".",
":",
"param",
"stream",
":",
"the",
"binary",
"stream",
"that",
"contains",
"the",
"file",
".",
":",
"param",
"filename",
":",
"the",
"name",
"of",
"the",
"file",
".",
":",
"param",
"chunkId... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L126-L153 | [
"def",
"writeChunk",
"(",
"self",
",",
"stream",
",",
"filename",
",",
"chunkIdx",
"=",
"None",
")",
":",
"import",
"io",
"more",
"=",
"True",
"outputFileName",
"=",
"filename",
"if",
"chunkIdx",
"is",
"None",
"else",
"filename",
"+",
"'.'",
"+",
"str",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | UploadController.finalise | Completes the upload which means converting to a single 1kHz sample rate file output file.
:param filename:
:param totalChunks:
:param status:
:return: | backend/src/analyser/common/uploadcontroller.py | def finalise(self, filename, totalChunks, status):
"""
Completes the upload which means converting to a single 1kHz sample rate file output file.
:param filename:
:param totalChunks:
:param status:
:return:
"""
def getChunkIdx(x):
try:
... | def finalise(self, filename, totalChunks, status):
"""
Completes the upload which means converting to a single 1kHz sample rate file output file.
:param filename:
:param totalChunks:
:param status:
:return:
"""
def getChunkIdx(x):
try:
... | [
"Completes",
"the",
"upload",
"which",
"means",
"converting",
"to",
"a",
"single",
"1kHz",
"sample",
"rate",
"file",
"output",
"file",
".",
":",
"param",
"filename",
":",
":",
"param",
"totalChunks",
":",
":",
"param",
"status",
":",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L155-L183 | [
"def",
"finalise",
"(",
"self",
",",
"filename",
",",
"totalChunks",
",",
"status",
")",
":",
"def",
"getChunkIdx",
"(",
"x",
")",
":",
"try",
":",
"return",
"int",
"(",
"x",
".",
"suffix",
"[",
"1",
":",
"]",
")",
"except",
"ValueError",
":",
"ret... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | UploadController.writeOutput | Resamples the signal to the targetFs and writes it to filename.
:param filename: the filename.
:param signal: the signal to resample.
:param targetFs: the target fs.
:return: None | backend/src/analyser/common/uploadcontroller.py | def writeOutput(self, filename, samples, srcFs, targetFs):
"""
Resamples the signal to the targetFs and writes it to filename.
:param filename: the filename.
:param signal: the signal to resample.
:param targetFs: the target fs.
:return: None
"""
import li... | def writeOutput(self, filename, samples, srcFs, targetFs):
"""
Resamples the signal to the targetFs and writes it to filename.
:param filename: the filename.
:param signal: the signal to resample.
:param targetFs: the target fs.
:return: None
"""
import li... | [
"Resamples",
"the",
"signal",
"to",
"the",
"targetFs",
"and",
"writes",
"it",
"to",
"filename",
".",
":",
"param",
"filename",
":",
"the",
"filename",
".",
":",
"param",
"signal",
":",
"the",
"signal",
"to",
"resample",
".",
":",
"param",
"targetFs",
":"... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L194-L219 | [
"def",
"writeOutput",
"(",
"self",
",",
"filename",
",",
"samples",
",",
"srcFs",
",",
"targetFs",
")",
":",
"import",
"librosa",
"inputLength",
"=",
"samples",
".",
"shape",
"[",
"-",
"1",
"]",
"if",
"srcFs",
"!=",
"targetFs",
":",
"if",
"inputLength",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | UploadController.delete | Deletes the named entry.
:param name: the entry.
:return: the deleted entry. | backend/src/analyser/common/uploadcontroller.py | def delete(self, name):
"""
Deletes the named entry.
:param name: the entry.
:return: the deleted entry.
"""
i, entry = next(((i, x) for i, x in enumerate(self._uploadCache) if x['name'] == name), (None, None))
if entry is not None:
logger.info("Deleti... | def delete(self, name):
"""
Deletes the named entry.
:param name: the entry.
:return: the deleted entry.
"""
i, entry = next(((i, x) for i, x in enumerate(self._uploadCache) if x['name'] == name), (None, None))
if entry is not None:
logger.info("Deleti... | [
"Deletes",
"the",
"named",
"entry",
".",
":",
"param",
"name",
":",
"the",
"entry",
".",
":",
"return",
":",
"the",
"deleted",
"entry",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/uploadcontroller.py#L221-L235 | [
"def",
"delete",
"(",
"self",
",",
"name",
")",
":",
"i",
",",
"entry",
"=",
"next",
"(",
"(",
"(",
"i",
",",
"x",
")",
"for",
"i",
",",
"x",
"in",
"enumerate",
"(",
"self",
".",
"_uploadCache",
")",
"if",
"x",
"[",
"'name'",
"]",
"==",
"name... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | eparOptionFactory | Return EparOption item of appropriate type for the parameter param | lib/stsci/tools/eparoption.py | def eparOptionFactory(master, statusBar, param, defaultParam,
doScroll, fieldWidths,
plugIn=None, editedCallbackObj=None,
helpCallbackObj=None, mainGuiObj=None,
defaultsVerb="Default", bg=None, indent=False,
fl... | def eparOptionFactory(master, statusBar, param, defaultParam,
doScroll, fieldWidths,
plugIn=None, editedCallbackObj=None,
helpCallbackObj=None, mainGuiObj=None,
defaultsVerb="Default", bg=None, indent=False,
fl... | [
"Return",
"EparOption",
"item",
"of",
"appropriate",
"type",
"for",
"the",
"parameter",
"param"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L910-L940 | [
"def",
"eparOptionFactory",
"(",
"master",
",",
"statusBar",
",",
"param",
",",
"defaultParam",
",",
"doScroll",
",",
"fieldWidths",
",",
"plugIn",
"=",
"None",
",",
"editedCallbackObj",
"=",
"None",
",",
"helpCallbackObj",
"=",
"None",
",",
"mainGuiObj",
"=",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.extraBindingsForSelectableText | Collect in 1 place the bindings needed for watchTextSelection() | lib/stsci/tools/eparoption.py | def extraBindingsForSelectableText(self):
""" Collect in 1 place the bindings needed for watchTextSelection() """
# See notes in watchTextSelection
self.entry.bind('<FocusIn>', self.watchTextSelection, "+")
self.entry.bind('<ButtonRelease-1>', self.watchTextSelection, "+")
self.e... | def extraBindingsForSelectableText(self):
""" Collect in 1 place the bindings needed for watchTextSelection() """
# See notes in watchTextSelection
self.entry.bind('<FocusIn>', self.watchTextSelection, "+")
self.entry.bind('<ButtonRelease-1>', self.watchTextSelection, "+")
self.e... | [
"Collect",
"in",
"1",
"place",
"the",
"bindings",
"needed",
"for",
"watchTextSelection",
"()"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L243-L251 | [
"def",
"extraBindingsForSelectableText",
"(",
"self",
")",
":",
"# See notes in watchTextSelection",
"self",
".",
"entry",
".",
"bind",
"(",
"'<FocusIn>'",
",",
"self",
".",
"watchTextSelection",
",",
"\"+\"",
")",
"self",
".",
"entry",
".",
"bind",
"(",
"'<Butt... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.focusOut | Clear selection (if text is selected in this widget) | lib/stsci/tools/eparoption.py | def focusOut(self, event=None):
"""Clear selection (if text is selected in this widget)"""
# do nothing if this isn't a text-enabled widget
if not self.isSelectable:
return
if self.entryCheck(event) is None:
# Entry value is OK
# Save the last selectio... | def focusOut(self, event=None):
"""Clear selection (if text is selected in this widget)"""
# do nothing if this isn't a text-enabled widget
if not self.isSelectable:
return
if self.entryCheck(event) is None:
# Entry value is OK
# Save the last selectio... | [
"Clear",
"selection",
"(",
"if",
"text",
"is",
"selected",
"in",
"this",
"widget",
")"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L257-L281 | [
"def",
"focusOut",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"# do nothing if this isn't a text-enabled widget",
"if",
"not",
"self",
".",
"isSelectable",
":",
"return",
"if",
"self",
".",
"entryCheck",
"(",
"event",
")",
"is",
"None",
":",
"# Entry va... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.watchTextSelection | Callback used to see if there is a new text selection. In certain
cases we manually add the text to the clipboard (though on most
platforms the correct behavior happens automatically). | lib/stsci/tools/eparoption.py | def watchTextSelection(self, event=None):
""" Callback used to see if there is a new text selection. In certain
cases we manually add the text to the clipboard (though on most
platforms the correct behavior happens automatically). """
# Note that this isn't perfect - it is a key click be... | def watchTextSelection(self, event=None):
""" Callback used to see if there is a new text selection. In certain
cases we manually add the text to the clipboard (though on most
platforms the correct behavior happens automatically). """
# Note that this isn't perfect - it is a key click be... | [
"Callback",
"used",
"to",
"see",
"if",
"there",
"is",
"a",
"new",
"text",
"selection",
".",
"In",
"certain",
"cases",
"we",
"manually",
"add",
"the",
"text",
"to",
"the",
"clipboard",
"(",
"though",
"on",
"most",
"platforms",
"the",
"correct",
"behavior",
... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L283-L296 | [
"def",
"watchTextSelection",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"# Note that this isn't perfect - it is a key click behind when",
"# selections are made via shift-arrow. If this becomes important, it",
"# can likely be fixed with after().",
"if",
"self",
".",
"entry",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.focusIn | Select all text (if applicable) on taking focus | lib/stsci/tools/eparoption.py | def focusIn(self, event=None):
"""Select all text (if applicable) on taking focus"""
try:
# doScroll returns false if the call was ignored because the
# last call also came from this widget. That avoids unwanted
# scrolls and text selection when the focus moves in an... | def focusIn(self, event=None):
"""Select all text (if applicable) on taking focus"""
try:
# doScroll returns false if the call was ignored because the
# last call also came from this widget. That avoids unwanted
# scrolls and text selection when the focus moves in an... | [
"Select",
"all",
"text",
"(",
"if",
"applicable",
")",
"on",
"taking",
"focus"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L302-L316 | [
"def",
"focusIn",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"try",
":",
"# doScroll returns false if the call was ignored because the",
"# last call also came from this widget. That avoids unwanted",
"# scrolls and text selection when the focus moves in and out",
"# of the win... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.widgetEdited | A general method for firing any applicable triggers when
a value has been set. This is meant to be easily callable from any
part of this class (or its subclasses), so that it can be called
as soon as need be (immed. on click?). This is smart enough to
be called multiple... | lib/stsci/tools/eparoption.py | def widgetEdited(self, event=None, val=None, action='entry', skipDups=True):
""" A general method for firing any applicable triggers when
a value has been set. This is meant to be easily callable from any
part of this class (or its subclasses), so that it can be called
as so... | def widgetEdited(self, event=None, val=None, action='entry', skipDups=True):
""" A general method for firing any applicable triggers when
a value has been set. This is meant to be easily callable from any
part of this class (or its subclasses), so that it can be called
as so... | [
"A",
"general",
"method",
"for",
"firing",
"any",
"applicable",
"triggers",
"when",
"a",
"value",
"has",
"been",
"set",
".",
"This",
"is",
"meant",
"to",
"be",
"easily",
"callable",
"from",
"any",
"part",
"of",
"this",
"class",
"(",
"or",
"its",
"subclas... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L347-L380 | [
"def",
"widgetEdited",
"(",
"self",
",",
"event",
"=",
"None",
",",
"val",
"=",
"None",
",",
"action",
"=",
"'entry'",
",",
"skipDups",
"=",
"True",
")",
":",
"# be as lightweight as possible if obj doesn't care about this stuff",
"if",
"not",
"self",
".",
"_edi... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.popupChoices | Popup right-click menu of special parameter operations
Relies on browserEnabled, clearEnabled, unlearnEnabled, helpEnabled
instance attributes to determine which items are available. | lib/stsci/tools/eparoption.py | def popupChoices(self, event=None):
"""Popup right-click menu of special parameter operations
Relies on browserEnabled, clearEnabled, unlearnEnabled, helpEnabled
instance attributes to determine which items are available.
"""
# don't bother if all items are disabled
if N... | def popupChoices(self, event=None):
"""Popup right-click menu of special parameter operations
Relies on browserEnabled, clearEnabled, unlearnEnabled, helpEnabled
instance attributes to determine which items are available.
"""
# don't bother if all items are disabled
if N... | [
"Popup",
"right",
"-",
"click",
"menu",
"of",
"special",
"parameter",
"operations"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L392-L436 | [
"def",
"popupChoices",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"# don't bother if all items are disabled",
"if",
"NORMAL",
"not",
"in",
"(",
"self",
".",
"browserEnabled",
",",
"self",
".",
"clearEnabled",
",",
"self",
".",
"unlearnEnabled",
",",
"se... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.fileBrowser | Invoke a tkinter file dialog | lib/stsci/tools/eparoption.py | def fileBrowser(self):
"""Invoke a tkinter file dialog"""
if capable.OF_TKFD_IN_EPAR:
fname = askopenfilename(parent=self.entry, title="Select File")
else:
from . import filedlg
self.fd = filedlg.PersistLoadFileDialog(self.entry,
"... | def fileBrowser(self):
"""Invoke a tkinter file dialog"""
if capable.OF_TKFD_IN_EPAR:
fname = askopenfilename(parent=self.entry, title="Select File")
else:
from . import filedlg
self.fd = filedlg.PersistLoadFileDialog(self.entry,
"... | [
"Invoke",
"a",
"tkinter",
"file",
"dialog"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L438-L456 | [
"def",
"fileBrowser",
"(",
"self",
")",
":",
"if",
"capable",
".",
"OF_TKFD_IN_EPAR",
":",
"fname",
"=",
"askopenfilename",
"(",
"parent",
"=",
"self",
".",
"entry",
",",
"title",
"=",
"\"Select File\"",
")",
"else",
":",
"from",
".",
"import",
"filedlg",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.dirBrowser | Invoke a tkinter directory dialog | lib/stsci/tools/eparoption.py | def dirBrowser(self):
"""Invoke a tkinter directory dialog"""
if capable.OF_TKFD_IN_EPAR:
fname = askdirectory(parent=self.entry, title="Select Directory")
else:
raise NotImplementedError('Fix popupChoices() logic.')
if not fname:
return # canceled
... | def dirBrowser(self):
"""Invoke a tkinter directory dialog"""
if capable.OF_TKFD_IN_EPAR:
fname = askdirectory(parent=self.entry, title="Select Directory")
else:
raise NotImplementedError('Fix popupChoices() logic.')
if not fname:
return # canceled
... | [
"Invoke",
"a",
"tkinter",
"directory",
"dialog"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L458-L471 | [
"def",
"dirBrowser",
"(",
"self",
")",
":",
"if",
"capable",
".",
"OF_TKFD_IN_EPAR",
":",
"fname",
"=",
"askdirectory",
"(",
"parent",
"=",
"self",
".",
"entry",
",",
"title",
"=",
"\"Select Directory\"",
")",
"else",
":",
"raise",
"NotImplementedError",
"("... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.forceValue | Force-set a parameter entry to the given value | lib/stsci/tools/eparoption.py | def forceValue(self, newVal, noteEdited=False):
"""Force-set a parameter entry to the given value"""
if newVal is None:
newVal = ""
self.choice.set(newVal)
if noteEdited:
self.widgetEdited(val=newVal, skipDups=False) | def forceValue(self, newVal, noteEdited=False):
"""Force-set a parameter entry to the given value"""
if newVal is None:
newVal = ""
self.choice.set(newVal)
if noteEdited:
self.widgetEdited(val=newVal, skipDups=False) | [
"Force",
"-",
"set",
"a",
"parameter",
"entry",
"to",
"the",
"given",
"value"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L477-L483 | [
"def",
"forceValue",
"(",
"self",
",",
"newVal",
",",
"noteEdited",
"=",
"False",
")",
":",
"if",
"newVal",
"is",
"None",
":",
"newVal",
"=",
"\"\"",
"self",
".",
"choice",
".",
"set",
"(",
"newVal",
")",
"if",
"noteEdited",
":",
"self",
".",
"widget... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.unlearnValue | Unlearn a parameter value by setting it back to its default | lib/stsci/tools/eparoption.py | def unlearnValue(self):
"""Unlearn a parameter value by setting it back to its default"""
defaultValue = self.defaultParamInfo.get(field = "p_filename",
native = 0, prompt = 0)
self.choice.set(defaultValue) | def unlearnValue(self):
"""Unlearn a parameter value by setting it back to its default"""
defaultValue = self.defaultParamInfo.get(field = "p_filename",
native = 0, prompt = 0)
self.choice.set(defaultValue) | [
"Unlearn",
"a",
"parameter",
"value",
"by",
"setting",
"it",
"back",
"to",
"its",
"default"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L491-L495 | [
"def",
"unlearnValue",
"(",
"self",
")",
":",
"defaultValue",
"=",
"self",
".",
"defaultParamInfo",
".",
"get",
"(",
"field",
"=",
"\"p_filename\"",
",",
"native",
"=",
"0",
",",
"prompt",
"=",
"0",
")",
"self",
".",
"choice",
".",
"set",
"(",
"default... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.setActiveState | Use this to enable or disable (grey out) a parameter. | lib/stsci/tools/eparoption.py | def setActiveState(self, active):
""" Use this to enable or disable (grey out) a parameter. """
st = DISABLED
if active: st = NORMAL
self.entry.configure(state=st)
self.inputLabel.configure(state=st)
self.promptLabel.configure(state=st) | def setActiveState(self, active):
""" Use this to enable or disable (grey out) a parameter. """
st = DISABLED
if active: st = NORMAL
self.entry.configure(state=st)
self.inputLabel.configure(state=st)
self.promptLabel.configure(state=st) | [
"Use",
"this",
"to",
"enable",
"or",
"disable",
"(",
"grey",
"out",
")",
"a",
"parameter",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L508-L514 | [
"def",
"setActiveState",
"(",
"self",
",",
"active",
")",
":",
"st",
"=",
"DISABLED",
"if",
"active",
":",
"st",
"=",
"NORMAL",
"self",
".",
"entry",
".",
"configure",
"(",
"state",
"=",
"st",
")",
"self",
".",
"inputLabel",
".",
"configure",
"(",
"s... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EparOption.flagThisPar | If this par's value is different from the default value, it is here
that we flag it somehow as such. This basic version simply makes the
surrounding text red (or returns it to normal). May be overridden.
Leave force at False if you want to allow this mehtod to make smart
time-saving dec... | lib/stsci/tools/eparoption.py | def flagThisPar(self, currentVal, force):
""" If this par's value is different from the default value, it is here
that we flag it somehow as such. This basic version simply makes the
surrounding text red (or returns it to normal). May be overridden.
Leave force at False if you want to a... | def flagThisPar(self, currentVal, force):
""" If this par's value is different from the default value, it is here
that we flag it somehow as such. This basic version simply makes the
surrounding text red (or returns it to normal). May be overridden.
Leave force at False if you want to a... | [
"If",
"this",
"par",
"s",
"value",
"is",
"different",
"from",
"the",
"default",
"value",
"it",
"is",
"here",
"that",
"we",
"flag",
"it",
"somehow",
"as",
"such",
".",
"This",
"basic",
"version",
"simply",
"makes",
"the",
"surrounding",
"text",
"red",
"("... | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L516-L547 | [
"def",
"flagThisPar",
"(",
"self",
",",
"currentVal",
",",
"force",
")",
":",
"# Get out ASAP if we can",
"if",
"(",
"not",
"force",
")",
"and",
"(",
"not",
"self",
".",
"_flagNonDefaultVals",
")",
":",
"return",
"# handle simple case before comparing values (quick ... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EnumEparOption.keypress | Allow keys typed in widget to select items | lib/stsci/tools/eparoption.py | def keypress(self, event):
"""Allow keys typed in widget to select items"""
try:
self.choice.set(self.shortcuts[event.keysym])
except KeyError:
# key not found (probably a bug, since we intend to catch
# only events from shortcut keys, but ignore it anyway)
... | def keypress(self, event):
"""Allow keys typed in widget to select items"""
try:
self.choice.set(self.shortcuts[event.keysym])
except KeyError:
# key not found (probably a bug, since we intend to catch
# only events from shortcut keys, but ignore it anyway)
... | [
"Allow",
"keys",
"typed",
"in",
"widget",
"to",
"select",
"items"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L641-L648 | [
"def",
"keypress",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"self",
".",
"choice",
".",
"set",
"(",
"self",
".",
"shortcuts",
"[",
"event",
".",
"keysym",
"]",
")",
"except",
"KeyError",
":",
"# key not found (probably a bug, since we intend to catch",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | EnumEparOption.postcmd | Make sure proper entry is activated when menu is posted | lib/stsci/tools/eparoption.py | def postcmd(self):
"""Make sure proper entry is activated when menu is posted"""
value = self.choice.get()
try:
index = self.paramInfo.choice.index(value)
self.entry.menu.activate(index)
except ValueError:
# initial null value may not be in list
... | def postcmd(self):
"""Make sure proper entry is activated when menu is posted"""
value = self.choice.get()
try:
index = self.paramInfo.choice.index(value)
self.entry.menu.activate(index)
except ValueError:
# initial null value may not be in list
... | [
"Make",
"sure",
"proper",
"entry",
"is",
"activated",
"when",
"menu",
"is",
"posted"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L650-L658 | [
"def",
"postcmd",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"choice",
".",
"get",
"(",
")",
"try",
":",
"index",
"=",
"self",
".",
"paramInfo",
".",
"choice",
".",
"index",
"(",
"value",
")",
"self",
".",
"entry",
".",
"menu",
".",
"activ... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | BooleanEparOption.convertToNative | Convert to native bool; interpret certain strings. | lib/stsci/tools/eparoption.py | def convertToNative(self, aVal):
""" Convert to native bool; interpret certain strings. """
if aVal is None:
return None
if isinstance(aVal, bool): return aVal
# otherwise interpret strings
return str(aVal).lower() in ('1','on','yes','true') | def convertToNative(self, aVal):
""" Convert to native bool; interpret certain strings. """
if aVal is None:
return None
if isinstance(aVal, bool): return aVal
# otherwise interpret strings
return str(aVal).lower() in ('1','on','yes','true') | [
"Convert",
"to",
"native",
"bool",
";",
"interpret",
"certain",
"strings",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L674-L680 | [
"def",
"convertToNative",
"(",
"self",
",",
"aVal",
")",
":",
"if",
"aVal",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"aVal",
",",
"bool",
")",
":",
"return",
"aVal",
"# otherwise interpret strings",
"return",
"str",
"(",
"aVal",
")",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | BooleanEparOption.toggle | Toggle value between Yes and No | lib/stsci/tools/eparoption.py | def toggle(self, event=None):
"""Toggle value between Yes and No"""
if self.choice.get() == "yes":
self.rbno.select()
else:
self.rbyes.select()
self.widgetEdited() | def toggle(self, event=None):
"""Toggle value between Yes and No"""
if self.choice.get() == "yes":
self.rbno.select()
else:
self.rbyes.select()
self.widgetEdited() | [
"Toggle",
"value",
"between",
"Yes",
"and",
"No"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L780-L786 | [
"def",
"toggle",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"if",
"self",
".",
"choice",
".",
"get",
"(",
")",
"==",
"\"yes\"",
":",
"self",
".",
"rbno",
".",
"select",
"(",
")",
"else",
":",
"self",
".",
"rbyes",
".",
"select",
"(",
")"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | NumberEparOption.entryCheck | Ensure any INDEF entry is uppercase, before base class behavior | lib/stsci/tools/eparoption.py | def entryCheck(self, event = None, repair = True):
""" Ensure any INDEF entry is uppercase, before base class behavior """
valupr = self.choice.get().upper()
if valupr.strip() == 'INDEF':
self.choice.set(valupr)
return EparOption.entryCheck(self, event, repair = repair) | def entryCheck(self, event = None, repair = True):
""" Ensure any INDEF entry is uppercase, before base class behavior """
valupr = self.choice.get().upper()
if valupr.strip() == 'INDEF':
self.choice.set(valupr)
return EparOption.entryCheck(self, event, repair = repair) | [
"Ensure",
"any",
"INDEF",
"entry",
"is",
"uppercase",
"before",
"base",
"class",
"behavior"
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/eparoption.py#L881-L886 | [
"def",
"entryCheck",
"(",
"self",
",",
"event",
"=",
"None",
",",
"repair",
"=",
"True",
")",
":",
"valupr",
"=",
"self",
".",
"choice",
".",
"get",
"(",
")",
".",
"upper",
"(",
")",
"if",
"valupr",
".",
"strip",
"(",
")",
"==",
"'INDEF'",
":",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | xyinterp | :Purpose: Interpolates y based on the given xval.
x and y are a pair of independent/dependent variable arrays that must
be the same length. The x array must also be sorted.
xval is a user-specified value. This routine looks
up xval in the x array and uses that information to properly interpolate
th... | lib/stsci/tools/xyinterp.py | def xyinterp(x,y,xval):
"""
:Purpose: Interpolates y based on the given xval.
x and y are a pair of independent/dependent variable arrays that must
be the same length. The x array must also be sorted.
xval is a user-specified value. This routine looks
up xval in the x array and uses that ... | def xyinterp(x,y,xval):
"""
:Purpose: Interpolates y based on the given xval.
x and y are a pair of independent/dependent variable arrays that must
be the same length. The x array must also be sorted.
xval is a user-specified value. This routine looks
up xval in the x array and uses that ... | [
":",
"Purpose",
":",
"Interpolates",
"y",
"based",
"on",
"the",
"given",
"xval",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/xyinterp.py#L28-L102 | [
"def",
"xyinterp",
"(",
"x",
",",
"y",
",",
"xval",
")",
":",
"#Enforce conditions on x, y, and xval:",
"#x and y must correspond",
"if",
"len",
"(",
"x",
")",
"!=",
"len",
"(",
"y",
")",
":",
"raise",
"ValueError",
"(",
"\"Input arrays must be equal lengths\"",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | mpu6050._setSampleSizeBytes | updates the current record of the packet size per sample and the relationship between this and the fifo reads. | backend/src/recorder/common/mpu6050.py | def _setSampleSizeBytes(self):
"""
updates the current record of the packet size per sample and the relationship between this and the fifo reads.
"""
self.sampleSizeBytes = self.getPacketSize()
if self.sampleSizeBytes > 0:
self.maxBytesPerFifoRead = (32 // self.sampl... | def _setSampleSizeBytes(self):
"""
updates the current record of the packet size per sample and the relationship between this and the fifo reads.
"""
self.sampleSizeBytes = self.getPacketSize()
if self.sampleSizeBytes > 0:
self.maxBytesPerFifoRead = (32 // self.sampl... | [
"updates",
"the",
"current",
"record",
"of",
"the",
"packet",
"size",
"per",
"sample",
"and",
"the",
"relationship",
"between",
"this",
"and",
"the",
"fifo",
"reads",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L265-L271 | [
"def",
"_setSampleSizeBytes",
"(",
"self",
")",
":",
"self",
".",
"sampleSizeBytes",
"=",
"self",
".",
"getPacketSize",
"(",
")",
"if",
"self",
".",
"sampleSizeBytes",
">",
"0",
":",
"self",
".",
"maxBytesPerFifoRead",
"=",
"(",
"32",
"//",
"self",
".",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.getPacketSize | the current packet size.
:return: the current packet size based on the enabled registers. | backend/src/recorder/common/mpu6050.py | def getPacketSize(self):
"""
the current packet size.
:return: the current packet size based on the enabled registers.
"""
size = 0
if self.isAccelerometerEnabled():
size += 6
if self.isGyroEnabled():
size += 6
if self.isTemperature... | def getPacketSize(self):
"""
the current packet size.
:return: the current packet size based on the enabled registers.
"""
size = 0
if self.isAccelerometerEnabled():
size += 6
if self.isGyroEnabled():
size += 6
if self.isTemperature... | [
"the",
"current",
"packet",
"size",
".",
":",
"return",
":",
"the",
"current",
"packet",
"size",
"based",
"on",
"the",
"enabled",
"registers",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L273-L285 | [
"def",
"getPacketSize",
"(",
"self",
")",
":",
"size",
"=",
"0",
"if",
"self",
".",
"isAccelerometerEnabled",
"(",
")",
":",
"size",
"+=",
"6",
"if",
"self",
".",
"isGyroEnabled",
"(",
")",
":",
"size",
"+=",
"6",
"if",
"self",
".",
"isTemperatureEnabl... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.initialiseDevice | performs initialisation of the device
:param batchSize: the no of samples that each provideData call should yield
:return: | backend/src/recorder/common/mpu6050.py | def initialiseDevice(self):
"""
performs initialisation of the device
:param batchSize: the no of samples that each provideData call should yield
:return:
"""
logger.debug("Initialising device")
self.getInterruptStatus()
self.setAccelerometerSensitivity(se... | def initialiseDevice(self):
"""
performs initialisation of the device
:param batchSize: the no of samples that each provideData call should yield
:return:
"""
logger.debug("Initialising device")
self.getInterruptStatus()
self.setAccelerometerSensitivity(se... | [
"performs",
"initialisation",
"of",
"the",
"device",
":",
"param",
"batchSize",
":",
"the",
"no",
"of",
"samples",
"that",
"each",
"provideData",
"call",
"should",
"yield",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L287-L308 | [
"def",
"initialiseDevice",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Initialising device\"",
")",
"self",
".",
"getInterruptStatus",
"(",
")",
"self",
".",
"setAccelerometerSensitivity",
"(",
"self",
".",
"_accelerationFactor",
"*",
"32768.0",
")",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.enableAccelerometer | Specifies the device should write acceleration values to the FIFO, is not applied until enableFIFO is called.
:return: | backend/src/recorder/common/mpu6050.py | def enableAccelerometer(self):
"""
Specifies the device should write acceleration values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling acceleration sensor")
self.fifoSensorMask |= self.enableAccelerometerMask
self._acc... | def enableAccelerometer(self):
"""
Specifies the device should write acceleration values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling acceleration sensor")
self.fifoSensorMask |= self.enableAccelerometerMask
self._acc... | [
"Specifies",
"the",
"device",
"should",
"write",
"acceleration",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L317-L325 | [
"def",
"enableAccelerometer",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Enabling acceleration sensor\"",
")",
"self",
".",
"fifoSensorMask",
"|=",
"self",
".",
"enableAccelerometerMask",
"self",
".",
"_accelEnabled",
"=",
"True",
"self",
".",
"_setSam... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.disableAccelerometer | Specifies the device should NOT write acceleration values to the FIFO, is not applied until enableFIFO is
called.
:return: | backend/src/recorder/common/mpu6050.py | def disableAccelerometer(self):
"""
Specifies the device should NOT write acceleration values to the FIFO, is not applied until enableFIFO is
called.
:return:
"""
logger.debug("Disabling acceleration sensor")
self.fifoSensorMask &= ~self.enableAccelerometerMask
... | def disableAccelerometer(self):
"""
Specifies the device should NOT write acceleration values to the FIFO, is not applied until enableFIFO is
called.
:return:
"""
logger.debug("Disabling acceleration sensor")
self.fifoSensorMask &= ~self.enableAccelerometerMask
... | [
"Specifies",
"the",
"device",
"should",
"NOT",
"write",
"acceleration",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L327-L336 | [
"def",
"disableAccelerometer",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Disabling acceleration sensor\"",
")",
"self",
".",
"fifoSensorMask",
"&=",
"~",
"self",
".",
"enableAccelerometerMask",
"self",
".",
"_accelEnabled",
"=",
"False",
"self",
".",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.enableGyro | Specifies the device should write gyro values to the FIFO, is not applied until enableFIFO is called.
:return: | backend/src/recorder/common/mpu6050.py | def enableGyro(self):
"""
Specifies the device should write gyro values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling gyro sensor")
self.fifoSensorMask |= self.enableGyroMask
self._gyroEnabled = True
self._set... | def enableGyro(self):
"""
Specifies the device should write gyro values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling gyro sensor")
self.fifoSensorMask |= self.enableGyroMask
self._gyroEnabled = True
self._set... | [
"Specifies",
"the",
"device",
"should",
"write",
"gyro",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L345-L353 | [
"def",
"enableGyro",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Enabling gyro sensor\"",
")",
"self",
".",
"fifoSensorMask",
"|=",
"self",
".",
"enableGyroMask",
"self",
".",
"_gyroEnabled",
"=",
"True",
"self",
".",
"_setSampleSizeBytes",
"(",
")"... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.disableGyro | Specifies the device should NOT write gyro values to the FIFO, is not applied until enableFIFO is called.
:return: | backend/src/recorder/common/mpu6050.py | def disableGyro(self):
"""
Specifies the device should NOT write gyro values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Disabling gyro sensor")
self.fifoSensorMask &= ~self.enableGyroMask
self._gyroEnabled = False
s... | def disableGyro(self):
"""
Specifies the device should NOT write gyro values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Disabling gyro sensor")
self.fifoSensorMask &= ~self.enableGyroMask
self._gyroEnabled = False
s... | [
"Specifies",
"the",
"device",
"should",
"NOT",
"write",
"gyro",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L355-L363 | [
"def",
"disableGyro",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Disabling gyro sensor\"",
")",
"self",
".",
"fifoSensorMask",
"&=",
"~",
"self",
".",
"enableGyroMask",
"self",
".",
"_gyroEnabled",
"=",
"False",
"self",
".",
"_setSampleSizeBytes",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.enableTemperature | Specifies the device should write temperature values to the FIFO, is not applied until enableFIFO is called.
:return: | backend/src/recorder/common/mpu6050.py | def enableTemperature(self):
"""
Specifies the device should write temperature values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling temperature sensor")
self.fifoSensorMask |= self.enableTemperatureMask
self._setSampl... | def enableTemperature(self):
"""
Specifies the device should write temperature values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Enabling temperature sensor")
self.fifoSensorMask |= self.enableTemperatureMask
self._setSampl... | [
"Specifies",
"the",
"device",
"should",
"write",
"temperature",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L372-L379 | [
"def",
"enableTemperature",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Enabling temperature sensor\"",
")",
"self",
".",
"fifoSensorMask",
"|=",
"self",
".",
"enableTemperatureMask",
"self",
".",
"_setSampleSizeBytes",
"(",
")"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.disableTemperature | Specifies the device should NOT write temperature values to the FIFO, is not applied until enableFIFO is called.
:return: | backend/src/recorder/common/mpu6050.py | def disableTemperature(self):
"""
Specifies the device should NOT write temperature values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Disabling temperature sensor")
self.fifoSensorMask &= ~self.enableTemperatureMask
self._s... | def disableTemperature(self):
"""
Specifies the device should NOT write temperature values to the FIFO, is not applied until enableFIFO is called.
:return:
"""
logger.debug("Disabling temperature sensor")
self.fifoSensorMask &= ~self.enableTemperatureMask
self._s... | [
"Specifies",
"the",
"device",
"should",
"NOT",
"write",
"temperature",
"values",
"to",
"the",
"FIFO",
"is",
"not",
"applied",
"until",
"enableFIFO",
"is",
"called",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L381-L388 | [
"def",
"disableTemperature",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Disabling temperature sensor\"",
")",
"self",
".",
"fifoSensorMask",
"&=",
"~",
"self",
".",
"enableTemperatureMask",
"self",
".",
"_setSampleSizeBytes",
"(",
")"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.setGyroSensitivity | Sets the gyro sensitivity to 250, 500, 1000 or 2000 according to the given value (and implicitly disables the
self
tests)
:param value: the target sensitivity. | backend/src/recorder/common/mpu6050.py | def setGyroSensitivity(self, value):
"""
Sets the gyro sensitivity to 250, 500, 1000 or 2000 according to the given value (and implicitly disables the
self
tests)
:param value: the target sensitivity.
"""
try:
self.i2c_io.write(self.MPU6050_ADDRESS, se... | def setGyroSensitivity(self, value):
"""
Sets the gyro sensitivity to 250, 500, 1000 or 2000 according to the given value (and implicitly disables the
self
tests)
:param value: the target sensitivity.
"""
try:
self.i2c_io.write(self.MPU6050_ADDRESS, se... | [
"Sets",
"the",
"gyro",
"sensitivity",
"to",
"250",
"500",
"1000",
"or",
"2000",
"according",
"to",
"the",
"given",
"value",
"(",
"and",
"implicitly",
"disables",
"the",
"self",
"tests",
")",
":",
"param",
"value",
":",
"the",
"target",
"sensitivity",
"."
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L390-L404 | [
"def",
"setGyroSensitivity",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"self",
".",
"i2c_io",
".",
"write",
"(",
"self",
".",
"MPU6050_ADDRESS",
",",
"self",
".",
"MPU6050_RA_GYRO_CONFIG",
",",
"{",
"250",
":",
"0",
",",
"500",
":",
"8",
",",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.setAccelerometerSensitivity | Sets the accelerometer sensitivity to 2, 4, 8 or 16 according to the given value. Throws an ArgumentError if
the value provided is not valid.
:param value: the target sensitivity. | backend/src/recorder/common/mpu6050.py | def setAccelerometerSensitivity(self, value):
"""
Sets the accelerometer sensitivity to 2, 4, 8 or 16 according to the given value. Throws an ArgumentError if
the value provided is not valid.
:param value: the target sensitivity.
"""
# note that this implicitly disables t... | def setAccelerometerSensitivity(self, value):
"""
Sets the accelerometer sensitivity to 2, 4, 8 or 16 according to the given value. Throws an ArgumentError if
the value provided is not valid.
:param value: the target sensitivity.
"""
# note that this implicitly disables t... | [
"Sets",
"the",
"accelerometer",
"sensitivity",
"to",
"2",
"4",
"8",
"or",
"16",
"according",
"to",
"the",
"given",
"value",
".",
"Throws",
"an",
"ArgumentError",
"if",
"the",
"value",
"provided",
"is",
"not",
"valid",
".",
":",
"param",
"value",
":",
"th... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L406-L426 | [
"def",
"setAccelerometerSensitivity",
"(",
"self",
",",
"value",
")",
":",
"# note that this implicitly disables the self tests on each axis",
"# i.e. the full byte is actually 000[accel]000 where the 1st 3 are the accelerometer self tests, the next two",
"# values are the actual sensitivity and... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.setSampleRate | Sets the internal sample rate of the MPU-6050, this requires writing a value to the device to set the sample
rate as Gyroscope Output Rate / (1 + SMPLRT_DIV) where the gryoscope outputs at 8kHz and the peak sampling rate
is 1kHz. The target sample rate is therefore capped at 1kHz.
:param target... | backend/src/recorder/common/mpu6050.py | def setSampleRate(self, targetSampleRate):
"""
Sets the internal sample rate of the MPU-6050, this requires writing a value to the device to set the sample
rate as Gyroscope Output Rate / (1 + SMPLRT_DIV) where the gryoscope outputs at 8kHz and the peak sampling rate
is 1kHz. The target... | def setSampleRate(self, targetSampleRate):
"""
Sets the internal sample rate of the MPU-6050, this requires writing a value to the device to set the sample
rate as Gyroscope Output Rate / (1 + SMPLRT_DIV) where the gryoscope outputs at 8kHz and the peak sampling rate
is 1kHz. The target... | [
"Sets",
"the",
"internal",
"sample",
"rate",
"of",
"the",
"MPU",
"-",
"6050",
"this",
"requires",
"writing",
"a",
"value",
"to",
"the",
"device",
"to",
"set",
"the",
"sample",
"rate",
"as",
"Gyroscope",
"Output",
"Rate",
"/",
"(",
"1",
"+",
"SMPLRT_DIV",... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L428-L439 | [
"def",
"setSampleRate",
"(",
"self",
",",
"targetSampleRate",
")",
":",
"sampleRateDenominator",
"=",
"int",
"(",
"(",
"8000",
"/",
"min",
"(",
"targetSampleRate",
",",
"1000",
")",
")",
"-",
"1",
")",
"self",
".",
"i2c_io",
".",
"write",
"(",
"self",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.resetFifo | Resets the FIFO by first disabling the FIFO then sending a FIFO_RESET and then re-enabling the FIFO.
:return: | backend/src/recorder/common/mpu6050.py | def resetFifo(self):
"""
Resets the FIFO by first disabling the FIFO then sending a FIFO_RESET and then re-enabling the FIFO.
:return:
"""
logger.debug("Resetting FIFO")
self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_USER_CTRL, 0b00000000)
pass
se... | def resetFifo(self):
"""
Resets the FIFO by first disabling the FIFO then sending a FIFO_RESET and then re-enabling the FIFO.
:return:
"""
logger.debug("Resetting FIFO")
self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_USER_CTRL, 0b00000000)
pass
se... | [
"Resets",
"the",
"FIFO",
"by",
"first",
"disabling",
"the",
"FIFO",
"then",
"sending",
"a",
"FIFO_RESET",
"and",
"then",
"re",
"-",
"enabling",
"the",
"FIFO",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L441-L452 | [
"def",
"resetFifo",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Resetting FIFO\"",
")",
"self",
".",
"i2c_io",
".",
"write",
"(",
"self",
".",
"MPU6050_ADDRESS",
",",
"self",
".",
"MPU6050_RA_USER_CTRL",
",",
"0b00000000",
")",
"pass",
"self",
"... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.enableFifo | Enables the FIFO, resets it and then sets which values should be written to the FIFO.
:return: | backend/src/recorder/common/mpu6050.py | def enableFifo(self):
"""
Enables the FIFO, resets it and then sets which values should be written to the FIFO.
:return:
"""
logger.debug("Enabling FIFO")
self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_FIFO_EN, 0)
self.resetFifo()
self.i2c_io.writ... | def enableFifo(self):
"""
Enables the FIFO, resets it and then sets which values should be written to the FIFO.
:return:
"""
logger.debug("Enabling FIFO")
self.i2c_io.write(self.MPU6050_ADDRESS, self.MPU6050_RA_FIFO_EN, 0)
self.resetFifo()
self.i2c_io.writ... | [
"Enables",
"the",
"FIFO",
"resets",
"it",
"and",
"then",
"sets",
"which",
"values",
"should",
"be",
"written",
"to",
"the",
"FIFO",
".",
":",
"return",
":"
] | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L454-L463 | [
"def",
"enableFifo",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Enabling FIFO\"",
")",
"self",
".",
"i2c_io",
".",
"write",
"(",
"self",
".",
"MPU6050_ADDRESS",
",",
"self",
".",
"MPU6050_RA_FIFO_EN",
",",
"0",
")",
"self",
".",
"resetFifo",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.getFifoCount | gets the amount of data available on the FIFO right now.
:return: the number of bytes available on the FIFO which will be proportional to the number of samples available
based on the values the device is configured to sample. | backend/src/recorder/common/mpu6050.py | def getFifoCount(self):
"""
gets the amount of data available on the FIFO right now.
:return: the number of bytes available on the FIFO which will be proportional to the number of samples available
based on the values the device is configured to sample.
"""
bytes = self.i... | def getFifoCount(self):
"""
gets the amount of data available on the FIFO right now.
:return: the number of bytes available on the FIFO which will be proportional to the number of samples available
based on the values the device is configured to sample.
"""
bytes = self.i... | [
"gets",
"the",
"amount",
"of",
"data",
"available",
"on",
"the",
"FIFO",
"right",
"now",
".",
":",
"return",
":",
"the",
"number",
"of",
"bytes",
"available",
"on",
"the",
"FIFO",
"which",
"will",
"be",
"proportional",
"to",
"the",
"number",
"of",
"sampl... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L474-L483 | [
"def",
"getFifoCount",
"(",
"self",
")",
":",
"bytes",
"=",
"self",
".",
"i2c_io",
".",
"readBlock",
"(",
"self",
".",
"MPU6050_ADDRESS",
",",
"self",
".",
"MPU6050_RA_FIFO_COUNTH",
",",
"2",
")",
"count",
"=",
"(",
"bytes",
"[",
"0",
"]",
"<<",
"8",
... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.getDataFromFIFO | reads the specified number of bytes from the FIFO, should be called after a call to getFifoCount to ensure there
is new data available (to avoid reading duplicate data).
:param bytesToRead: the number of bytes to read.
:return: the bytes read. | backend/src/recorder/common/mpu6050.py | def getDataFromFIFO(self, bytesToRead):
"""
reads the specified number of bytes from the FIFO, should be called after a call to getFifoCount to ensure there
is new data available (to avoid reading duplicate data).
:param bytesToRead: the number of bytes to read.
:return: the byte... | def getDataFromFIFO(self, bytesToRead):
"""
reads the specified number of bytes from the FIFO, should be called after a call to getFifoCount to ensure there
is new data available (to avoid reading duplicate data).
:param bytesToRead: the number of bytes to read.
:return: the byte... | [
"reads",
"the",
"specified",
"number",
"of",
"bytes",
"from",
"the",
"FIFO",
"should",
"be",
"called",
"after",
"a",
"call",
"to",
"getFifoCount",
"to",
"ensure",
"there",
"is",
"new",
"data",
"available",
"(",
"to",
"avoid",
"reading",
"duplicate",
"data",
... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L485-L492 | [
"def",
"getDataFromFIFO",
"(",
"self",
",",
"bytesToRead",
")",
":",
"return",
"self",
".",
"i2c_io",
".",
"readBlock",
"(",
"self",
".",
"MPU6050_ADDRESS",
",",
"self",
".",
"MPU6050_RA_FIFO_R_W",
",",
"bytesToRead",
")"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.provideData | reads a batchSize batch of data from the FIFO while attempting to optimise the number of times we have to read
from the device itself.
:return: a list of data where each item is a single sample of data converted into real values and stored as a
dict. | backend/src/recorder/common/mpu6050.py | def provideData(self):
"""
reads a batchSize batch of data from the FIFO while attempting to optimise the number of times we have to read
from the device itself.
:return: a list of data where each item is a single sample of data converted into real values and stored as a
dict.
... | def provideData(self):
"""
reads a batchSize batch of data from the FIFO while attempting to optimise the number of times we have to read
from the device itself.
:return: a list of data where each item is a single sample of data converted into real values and stored as a
dict.
... | [
"reads",
"a",
"batchSize",
"batch",
"of",
"data",
"from",
"the",
"FIFO",
"while",
"attempting",
"to",
"optimise",
"the",
"number",
"of",
"times",
"we",
"have",
"to",
"read",
"from",
"the",
"device",
"itself",
".",
":",
"return",
":",
"a",
"list",
"of",
... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L494-L564 | [
"def",
"provideData",
"(",
"self",
")",
":",
"samples",
"=",
"[",
"]",
"fifoBytesAvailable",
"=",
"0",
"fifoWasReset",
"=",
"False",
"logger",
".",
"debug",
"(",
"\">> provideData target %d samples\"",
",",
"self",
".",
"samplesPerBatch",
")",
"iterations",
"=",... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | mpu6050.unpackSample | unpacks a single sample of data (where sample length is based on the currently enabled sensors).
:param rawData: the data to convert
:return: a converted data set. | backend/src/recorder/common/mpu6050.py | def unpackSample(self, rawData):
"""
unpacks a single sample of data (where sample length is based on the currently enabled sensors).
:param rawData: the data to convert
:return: a converted data set.
"""
length = len(rawData)
# TODO error if not multiple of 2
... | def unpackSample(self, rawData):
"""
unpacks a single sample of data (where sample length is based on the currently enabled sensors).
:param rawData: the data to convert
:return: a converted data set.
"""
length = len(rawData)
# TODO error if not multiple of 2
... | [
"unpacks",
"a",
"single",
"sample",
"of",
"data",
"(",
"where",
"sample",
"length",
"is",
"based",
"on",
"the",
"currently",
"enabled",
"sensors",
")",
".",
":",
"param",
"rawData",
":",
"the",
"data",
"to",
"convert",
":",
"return",
":",
"a",
"converted... | 3ll3d00d/vibe | python | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/mpu6050.py#L566-L603 | [
"def",
"unpackSample",
"(",
"self",
",",
"rawData",
")",
":",
"length",
"=",
"len",
"(",
"rawData",
")",
"# TODO error if not multiple of 2",
"# logger.debug(\">> unpacking sample %d length %d\", self._sampleIdx, length)",
"unpacked",
"=",
"struct",
".",
"unpack",
"(",
"\... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 |
train | wrap | Like :func:`textwrap.wrap` but preserves existing newlines which
:func:`textwrap.wrap` does not otherwise handle well.
See Also
--------
:func:`textwrap.wrap` | lib/stsci/tools/textutil.py | def wrap(text, width, *args, **kwargs):
"""
Like :func:`textwrap.wrap` but preserves existing newlines which
:func:`textwrap.wrap` does not otherwise handle well.
See Also
--------
:func:`textwrap.wrap`
"""
return sum([textwrap.wrap(line, width, *args, **kwargs)
if line... | def wrap(text, width, *args, **kwargs):
"""
Like :func:`textwrap.wrap` but preserves existing newlines which
:func:`textwrap.wrap` does not otherwise handle well.
See Also
--------
:func:`textwrap.wrap`
"""
return sum([textwrap.wrap(line, width, *args, **kwargs)
if line... | [
"Like",
":",
"func",
":",
"textwrap",
".",
"wrap",
"but",
"preserves",
"existing",
"newlines",
"which",
":",
"func",
":",
"textwrap",
".",
"wrap",
"does",
"not",
"otherwise",
"handle",
"well",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/textutil.py#L7-L18 | [
"def",
"wrap",
"(",
"text",
",",
"width",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"sum",
"(",
"[",
"textwrap",
".",
"wrap",
"(",
"line",
",",
"width",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"line",
"else",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | textbox | Outputs line-wrapped text wrapped in a box drawn with a repeated (usually
ASCII) character.
For example:
>>> print(textbox('Text to wrap', width=16))
################
# #
# Text to wrap #
# #
################
Parameters
-------... | lib/stsci/tools/textutil.py | def textbox(text, width=78, boxchar='#', indent=0):
"""
Outputs line-wrapped text wrapped in a box drawn with a repeated (usually
ASCII) character.
For example:
>>> print(textbox('Text to wrap', width=16))
################
# #
# Text to wrap #
# ... | def textbox(text, width=78, boxchar='#', indent=0):
"""
Outputs line-wrapped text wrapped in a box drawn with a repeated (usually
ASCII) character.
For example:
>>> print(textbox('Text to wrap', width=16))
################
# #
# Text to wrap #
# ... | [
"Outputs",
"line",
"-",
"wrapped",
"text",
"wrapped",
"in",
"a",
"box",
"drawn",
"with",
"a",
"repeated",
"(",
"usually",
"ASCII",
")",
"character",
"."
] | spacetelescope/stsci.tools | python | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/textutil.py#L21-L72 | [
"def",
"textbox",
"(",
"text",
",",
"width",
"=",
"78",
",",
"boxchar",
"=",
"'#'",
",",
"indent",
"=",
"0",
")",
":",
"min_width",
"=",
"len",
"(",
"boxchar",
")",
"*",
"2",
"+",
"3",
"width",
"=",
"max",
"(",
"width",
"-",
"indent",
",",
"min... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 |
train | main | Entrypoint function. | pyhydroquebec/__main__.py | def main():
"""Entrypoint function."""
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--username',
help='Hydro Quebec username')
parser.add_argument('-p', '--password',
help='Password')
parser.add_argument('-j', '--json', action='store_t... | def main():
"""Entrypoint function."""
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--username',
help='Hydro Quebec username')
parser.add_argument('-p', '--password',
help='Password')
parser.add_argument('-j', '--json', action='store_t... | [
"Entrypoint",
"function",
"."
] | titilambert/pyhydroquebec | python | https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/__main__.py#L14-L89 | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'-u'",
",",
"'--username'",
",",
"help",
"=",
"'Hydro Quebec username'",
")",
"parser",
".",
"add_argument",
"(",
"'-p'",
",",
"'... | 4ea1374a63944413889c147d91961eda0605d4fd |
train | easter | Calculate western easter | convertdate/holidays.py | def easter(year):
'''Calculate western easter'''
# formula taken from http://aa.usno.navy.mil/faq/docs/easter.html
c = trunc(year / 100)
n = year - 19 * trunc(year / 19)
k = trunc((c - 17) / 25)
i = c - trunc(c / 4) - trunc((c - k) / 3) + (19 * n) + 15
i = i - 30 * trunc(i / 30)
i = i ... | def easter(year):
'''Calculate western easter'''
# formula taken from http://aa.usno.navy.mil/faq/docs/easter.html
c = trunc(year / 100)
n = year - 19 * trunc(year / 19)
k = trunc((c - 17) / 25)
i = c - trunc(c / 4) - trunc((c - k) / 3) + (19 * n) + 15
i = i - 30 * trunc(i / 30)
i = i ... | [
"Calculate",
"western",
"easter"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L75-L95 | [
"def",
"easter",
"(",
"year",
")",
":",
"# formula taken from http://aa.usno.navy.mil/faq/docs/easter.html",
"c",
"=",
"trunc",
"(",
"year",
"/",
"100",
")",
"n",
"=",
"year",
"-",
"19",
"*",
"trunc",
"(",
"year",
"/",
"19",
")",
"k",
"=",
"trunc",
"(",
... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | independence_day | July 4th | convertdate/holidays.py | def independence_day(year, observed=None):
'''July 4th'''
day = 4
if observed:
if calendar.weekday(year, JUL, 4) == SAT:
day = 3
if calendar.weekday(year, JUL, 4) == SUN:
day = 5
return (year, JUL, day) | def independence_day(year, observed=None):
'''July 4th'''
day = 4
if observed:
if calendar.weekday(year, JUL, 4) == SAT:
day = 3
if calendar.weekday(year, JUL, 4) == SUN:
day = 5
return (year, JUL, day) | [
"July",
"4th"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L122-L133 | [
"def",
"independence_day",
"(",
"year",
",",
"observed",
"=",
"None",
")",
":",
"day",
"=",
"4",
"if",
"observed",
":",
"if",
"calendar",
".",
"weekday",
"(",
"year",
",",
"JUL",
",",
"4",
")",
"==",
"SAT",
":",
"day",
"=",
"3",
"if",
"calendar",
... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | columbus_day | in USA: 2nd Monday in Oct
Elsewhere: Oct 12 | convertdate/holidays.py | def columbus_day(year, country='usa'):
'''in USA: 2nd Monday in Oct
Elsewhere: Oct 12'''
if country == 'usa':
return nth_day_of_month(2, MON, OCT, year)
else:
return (year, OCT, 12) | def columbus_day(year, country='usa'):
'''in USA: 2nd Monday in Oct
Elsewhere: Oct 12'''
if country == 'usa':
return nth_day_of_month(2, MON, OCT, year)
else:
return (year, OCT, 12) | [
"in",
"USA",
":",
"2nd",
"Monday",
"in",
"Oct",
"Elsewhere",
":",
"Oct",
"12"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L141-L147 | [
"def",
"columbus_day",
"(",
"year",
",",
"country",
"=",
"'usa'",
")",
":",
"if",
"country",
"==",
"'usa'",
":",
"return",
"nth_day_of_month",
"(",
"2",
",",
"MON",
",",
"OCT",
",",
"year",
")",
"else",
":",
"return",
"(",
"year",
",",
"OCT",
",",
... | e920f168a87f99183b0aa7290d6c3af222582d43 |
train | thanksgiving | USA: last Thurs. of November, Canada: 2nd Mon. of October | convertdate/holidays.py | def thanksgiving(year, country='usa'):
'''USA: last Thurs. of November, Canada: 2nd Mon. of October'''
if country == 'usa':
if year in [1940, 1941]:
return nth_day_of_month(3, THU, NOV, year)
elif year == 1939:
return nth_day_of_month(4, THU, NOV, year)
else:
... | def thanksgiving(year, country='usa'):
'''USA: last Thurs. of November, Canada: 2nd Mon. of October'''
if country == 'usa':
if year in [1940, 1941]:
return nth_day_of_month(3, THU, NOV, year)
elif year == 1939:
return nth_day_of_month(4, THU, NOV, year)
else:
... | [
"USA",
":",
"last",
"Thurs",
".",
"of",
"November",
"Canada",
":",
"2nd",
"Mon",
".",
"of",
"October"
] | fitnr/convertdate | python | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L173-L184 | [
"def",
"thanksgiving",
"(",
"year",
",",
"country",
"=",
"'usa'",
")",
":",
"if",
"country",
"==",
"'usa'",
":",
"if",
"year",
"in",
"[",
"1940",
",",
"1941",
"]",
":",
"return",
"nth_day_of_month",
"(",
"3",
",",
"THU",
",",
"NOV",
",",
"year",
")... | e920f168a87f99183b0aa7290d6c3af222582d43 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.