_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q39300 | main | train | def main():
"""Main entry-point for oz's cli"""
# Hack to make user code available for import
sys.path.append(".")
# Run the specified action
oz.initialize()
retr = optfn.run(list(oz._actions.values()))
if retr == optfn.ERROR_RETURN_CODE:
sys.exit(-1)
elif retr == None:
... | python | {
"resource": ""
} |
q39301 | build_tree_from_distance_matrix | train | def build_tree_from_distance_matrix(matrix, best_tree=False, params={},\
working_dir='/tmp'):
"""Returns a tree from a distance matrix.
matrix: a square Dict2D object (cogent.util.dict2d)
best_tree: if True (default:False), uses a slower but more accurate
algorithm to build the tree.
params: ... | python | {
"resource": ""
} |
q39302 | _matrix_input_from_dict2d | train | def _matrix_input_from_dict2d(matrix):
"""makes input for running clearcut on a matrix from a dict2D object"""
#clearcut truncates names to 10 char- need to rename before and
#reassign after
#make a dict of env_index:full name
int_keys = dict([('env_' + str(i), k) for i,k in \
enumerate... | python | {
"resource": ""
} |
q39303 | ManifestDownloader._close | train | def _close(self):
'''
Closes aiohttp session and all open file descriptors
'''
if hasattr(self, 'aiohttp'):
if not self.aiohttp.closed:
self.aiohttp.close()
if hasattr(self, 'file_descriptors'):
for fd in self.file_descriptors.values():
... | python | {
"resource": ""
} |
q39304 | _unbytes | train | def _unbytes(bytestr):
"""
Returns a bytestring from the human-friendly string returned by `_bytes`.
>>> _unbytes('123456')
'\x12\x34\x56'
"""
return ''.join(chr(int(bytestr[k:k + 2], 16))
for k in range(0, len(bytestr), 2)) | python | {
"resource": ""
} |
q39305 | _blocking | train | def _blocking(lock, state_dict, event, timeout=None):
"""
A contextmanager that clears `state_dict` and `event`, yields, and waits
for the event to be set. Clearing an yielding are done within `lock`.
Used for blocking request/response semantics on the request side, as in:
with _blocking(lock,... | python | {
"resource": ""
} |
q39306 | Callbacks.register | train | def register(self, event, fn):
"""
Tell the object to run `fn` whenever a message of type `event` is
received.
"""
self._callbacks.setdefault(event, []).append(fn)
return fn | python | {
"resource": ""
} |
q39307 | Callbacks.put | train | def put(self, event, *args, **kwargs):
"""
Schedule a callback for `event`, passing `args` and `kwargs` to each
registered callback handler.
"""
self._queue.put((event, args, kwargs)) | python | {
"resource": ""
} |
q39308 | Lifx._on_gateway | train | def _on_gateway(self, header, payload, rest, addr):
"""
Records a discovered gateway, for connecting to later.
"""
if payload.get('service') == SERVICE_UDP:
self.gateway = Gateway(addr[0], payload['port'], header.gateway)
self.gateway_found_event.set() | python | {
"resource": ""
} |
q39309 | Lifx._on_light_state | train | def _on_light_state(self, header, payload, rest, addr):
"""
Records the light state of bulbs, and forwards to a high-level callback
with human-friendlier arguments.
"""
with self.lock:
label = payload['label'].strip('\x00')
self.bulbs[header.mac] = bulb = ... | python | {
"resource": ""
} |
q39310 | Lifx.send | train | def send(self, packet_type, bulb, packet_fmt, *packet_args):
"""
Builds and sends a packet to one or more bulbs.
"""
packet = build_packet(packet_type, self.gateway.mac, bulb,
packet_fmt, *packet_args)
self.logger('>> %s', _bytes(packet))
sel... | python | {
"resource": ""
} |
q39311 | Lifx.set_power_state | train | def set_power_state(self, is_on, bulb=ALL_BULBS, timeout=None):
"""
Sets the power state of one or more bulbs.
"""
with _blocking(self.lock, self.power_state, self.light_state_event,
timeout):
self.send(REQ_SET_POWER_STATE,
bulb, '... | python | {
"resource": ""
} |
q39312 | Lifx.set_light_state | train | def set_light_state(self, hue, saturation, brightness, kelvin,
bulb=ALL_BULBS, timeout=None):
"""
Sets the light state of one or more bulbs.
Hue is a float from 0 to 360, saturation and brightness are floats from
0 to 1, and kelvin is an integer.
"""
... | python | {
"resource": ""
} |
q39313 | Lifx.on_packet | train | def on_packet(self, packet_type):
"""
Registers a function to be called when packet data is received with a
specific type.
"""
def _wrapper(fn):
return self.callbacks.register(packet_type, fn)
return _wrapper | python | {
"resource": ""
} |
q39314 | Lifx.connect | train | def connect(self, attempts=20, delay=0.5):
"""
Connects to a gateway, blocking until a connection is made and bulbs
are found.
Step 1: send a gateway discovery packet to the broadcast address, wait
until we've received some info about the gateway.
Step 2: connect to a d... | python | {
"resource": ""
} |
q39315 | Lifx.run | train | def run(self):
"""
A context manager starting up threads to send and receive data from a
gateway and handle callbacks. Yields when a connection has been made,
and cleans up connections and threads when it's done.
"""
listener_thr = _spawn(self.receiver.run)
callba... | python | {
"resource": ""
} |
q39316 | BaseWorker.run_multiconvert | train | async def run_multiconvert(self, url_string, to_type):
'''
Enqueues in succession all conversions steps necessary to take the
given URL and convert it to to_type, storing the result in the cache
'''
async def enq_convert(*args):
await self.enqueue(Task.CONVERT, args)
... | python | {
"resource": ""
} |
q39317 | mothur_classify_file | train | def mothur_classify_file(
query_file, ref_fp, tax_fp, cutoff=None, iters=None, ksize=None,
output_fp=None, tmp_dir=None):
"""Classify a set of sequences using Mothur's naive bayes method
Dashes are used in Mothur to provide multiple filenames. A
filepath with a dash typically breaks an oth... | python | {
"resource": ""
} |
q39318 | Mothur._derive_log_path | train | def _derive_log_path(self):
"""Guess logfile path produced by Mothur
This method checks the working directory for log files
generated by Mothur. It will raise an ApplicationError if no
log file can be found.
Mothur generates log files named in a nondeterministic way,
u... | python | {
"resource": ""
} |
q39319 | Mothur._derive_unique_path | train | def _derive_unique_path(self):
"""Guess unique sequences path produced by Mothur"""
base, ext = path.splitext(self._input_filename)
return '%s.unique%s' % (base, ext) | python | {
"resource": ""
} |
q39320 | Mothur.__get_method_abbrev | train | def __get_method_abbrev(self):
"""Abbreviated form of clustering method parameter.
Used to guess output filenames for MOTHUR.
"""
abbrevs = {
'furthest': 'fn',
'nearest': 'nn',
'average': 'an',
}
if self.Parameters['method'].isOn():
... | python | {
"resource": ""
} |
q39321 | Mothur._derive_list_path | train | def _derive_list_path(self):
"""Guess otu list file path produced by Mothur"""
base, ext = path.splitext(self._input_filename)
return '%s.unique.%s.list' % (base, self.__get_method_abbrev()) | python | {
"resource": ""
} |
q39322 | Mothur._derive_rank_abundance_path | train | def _derive_rank_abundance_path(self):
"""Guess rank abundance file path produced by Mothur"""
base, ext = path.splitext(self._input_filename)
return '%s.unique.%s.rabund' % (base, self.__get_method_abbrev()) | python | {
"resource": ""
} |
q39323 | Mothur._derive_species_abundance_path | train | def _derive_species_abundance_path(self):
"""Guess species abundance file path produced by Mothur"""
base, ext = path.splitext(self._input_filename)
return '%s.unique.%s.sabund' % (base, self.__get_method_abbrev()) | python | {
"resource": ""
} |
q39324 | Mothur.getTmpFilename | train | def getTmpFilename(self, tmp_dir=None, prefix='tmp', suffix='.txt'):
"""Returns a temporary filename
Similar interface to tempfile.mktmp()
"""
# Override to change default constructor to str(). FilePath
# objects muck up the Mothur script.
return super(Mothur, self).getT... | python | {
"resource": ""
} |
q39325 | Mothur._input_as_multiline_string | train | def _input_as_multiline_string(self, data):
"""Write multiline string to temp file, return filename
data: a multiline string to be written to a file.
"""
self._input_filename = self.getTmpFilename(
self.WorkingDir, suffix='.fasta')
with open(self._input_filename, 'w'... | python | {
"resource": ""
} |
q39326 | Mothur._input_as_lines | train | def _input_as_lines(self, data):
"""Write sequence of lines to temp file, return filename
data: a sequence to be written to a file, each element of the
sequence will compose a line in the file
* Note: '\n' will be stripped off the end of each sequence
element before wri... | python | {
"resource": ""
} |
q39327 | Mothur._input_as_path | train | def _input_as_path(self, data):
"""Copys the provided file to WorkingDir and returns the new filename
data: path or filename
"""
self._input_filename = self.getTmpFilename(
self.WorkingDir, suffix='.fasta')
copyfile(data, self._input_filename)
return self._in... | python | {
"resource": ""
} |
q39328 | Mothur._set_WorkingDir | train | def _set_WorkingDir(self, path):
"""Sets the working directory
"""
self._curr_working_dir = path
try:
mkdir(self.WorkingDir)
except OSError:
# Directory already exists
pass | python | {
"resource": ""
} |
q39329 | MothurClassifySeqs._format_function_arguments | train | def _format_function_arguments(self, opts):
"""Format a series of function arguments in a Mothur script."""
params = [self.Parameters[x] for x in opts]
return ', '.join(filter(None, map(str, params))) | python | {
"resource": ""
} |
q39330 | Alloy._add_parameter | train | def _add_parameter(self, parameter):
'''
Force adds a `Parameter` object to the instance.
'''
if isinstance(parameter, MethodParameter):
# create a bound instance of the MethodParameter
parameter = parameter.bind(alloy=self)
self._parameters[parameter.name... | python | {
"resource": ""
} |
q39331 | Alloy.get_parameter | train | def get_parameter(self, name, default=None):
'''
Returns the named parameter if present, or the value of `default`,
otherwise.
'''
if hasattr(self, name):
item = getattr(self, name)
if isinstance(item, Parameter):
return item
return... | python | {
"resource": ""
} |
q39332 | Base.set_log_level | train | def set_log_level(self, level: str) -> None:
"""Override the default log level of the class."""
if level == 'info':
to_set = logging.INFO
if level == 'debug':
to_set = logging.DEBUG
if level == 'error':
to_set = logging.ERROR
self.log.setLevel(... | python | {
"resource": ""
} |
q39333 | Base._request_bulk | train | def _request_bulk(self, urls: List[str]) -> List:
"""Batch the requests going out."""
if not urls:
raise Exception("No results were found")
session: FuturesSession = FuturesSession(max_workers=len(urls))
self.log.info("Bulk requesting: %d" % len(urls))
futures = [sess... | python | {
"resource": ""
} |
q39334 | MethodParameter.bind | train | def bind(self, alloy):
'''
Shallow copies this MethodParameter, and binds it to an alloy.
This is required before calling.
'''
param = MethodParameter(self.name, self.method, self.dependencies,
self.units, self.aliases, self._references)
pa... | python | {
"resource": ""
} |
q39335 | PlugIt.doQuery | train | def doQuery(self, url, method='GET', getParmeters=None, postParameters=None, files=None, extraHeaders={}, session={}):
"""Send a request to the server and return the result"""
# Build headers
headers = {}
if not postParameters:
postParameters = {}
for key, value in... | python | {
"resource": ""
} |
q39336 | PlugIt.ping | train | def ping(self):
"""Return true if the server successfully pinged"""
randomToken = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for x in range(32))
r = self.doQuery('ping?data=' + randomToken)
if r.status_code == 200: # Query ok ?
... | python | {
"resource": ""
} |
q39337 | PlugIt.checkVersion | train | def checkVersion(self):
"""Check if the server use the same version of our protocol"""
r = self.doQuery('version')
if r.status_code == 200: # Query ok ?
data = r.json()
if data['result'] == 'Ok' and data['version'] == self.PI_API_VERSION and data['protocol'] == self.P... | python | {
"resource": ""
} |
q39338 | PlugIt.newMail | train | def newMail(self, data, message):
"""Send a mail to a plugit server"""
r = self.doQuery('mail', method='POST', postParameters={'response_id': str(data), 'message': str(message)})
if r.status_code == 200: # Query ok ?
data = r.json()
return data['result'] == 'Ok'
... | python | {
"resource": ""
} |
q39339 | PlugIt.getMedia | train | def getMedia(self, uri):
"""Return a tuple with a media and his content-type. Don't cache anything !"""
r = self.doQuery('media/' + uri)
if r.status_code == 200:
content_type = 'application/octet-stream'
if 'content-type' in r.headers:
content_type = r.... | python | {
"resource": ""
} |
q39340 | PlugIt.getMeta | train | def getMeta(self, uri):
"""Return meta information about an action. Cache the result as specified by the server"""
action = urlparse(uri).path
mediaKey = self.cacheKey + '_meta_' + action
mediaKey = mediaKey.replace(' ', '__')
meta = cache.get(mediaKey, None)
# Nothin... | python | {
"resource": ""
} |
q39341 | PlugIt.getTemplate | train | def getTemplate(self, uri, meta=None):
"""Return the template for an action. Cache the result. Can use an optional meta parameter with meta information"""
if not meta:
metaKey = self.cacheKey + '_templatesmeta_cache_' + uri
meta = cache.get(metaKey, None)
if not m... | python | {
"resource": ""
} |
q39342 | component_offsetvectors | train | def component_offsetvectors(offsetvectors, n):
"""
Given an iterable of offset vectors, return the shortest list of
the unique n-instrument offset vectors from which all the vectors
in the input iterable can be constructed. This can be used to
determine the minimal set of n-instrument coincs required to
construc... | python | {
"resource": ""
} |
q39343 | offsetvector.normalize | train | def normalize(self, **kwargs):
"""
Adjust the offsetvector so that a particular instrument has
the desired offset. All other instruments have their
offsets adjusted so that the relative offsets are
preserved. The instrument to noramlize, and the offset one
wishes it to have, are provided as a key-word arg... | python | {
"resource": ""
} |
q39344 | offsetvector.fromdeltas | train | def fromdeltas(cls, deltas):
"""
Construct an offsetvector from a dictionary of offset
deltas as returned by the .deltas attribute.
Example:
>>> x = offsetvector({"H1": 0, "L1": 10, "V1": 20})
>>> y = offsetvector.fromdeltas(x.deltas)
>>> y
offsetvector({'V1': 20, 'H1': 0, 'L1': 10})
>>> y == x
Tr... | python | {
"resource": ""
} |
q39345 | processGif | train | def processGif(searchStr):
'''
This function returns the url of the gif searched for
with the given search parameters using the Giphy API.
Thanks!
Fails gracefully when it can't find a gif by returning an
appropriate image url with the failure message on it.
'''
# Sanitizing searc... | python | {
"resource": ""
} |
q39346 | HTMLPurifier.__set_whitelist | train | def __set_whitelist(self, whitelist=None):
"""
Update default white list by customer white list
"""
# add tag's names as key and list of enabled attributes as value for defaults
self.whitelist = {}
# tags that removed with contents
self.sanitizelist = ['script', '... | python | {
"resource": ""
} |
q39347 | HTMLPurifier.__attrs_str | train | def __attrs_str(self, tag, attrs):
"""
Build string of attributes list for tag
"""
enabled = self.whitelist.get(tag, ['*'])
all_attrs = '*' in enabled
items = []
for attr in attrs:
key = attr[0]
value = attr[1] or ''
if all_attr... | python | {
"resource": ""
} |
q39348 | hex_from | train | def hex_from(val):
"""Returns hex string representation for a given value.
:param bytes|str|unicode|int|long val:
:rtype: bytes|str
"""
if isinstance(val, integer_types):
hex_str = '%x' % val
if len(hex_str) % 2:
hex_str = '0' + hex_str
return hex_str
return... | python | {
"resource": ""
} |
q39349 | format_hyperlink | train | def format_hyperlink( val, hlx, hxl, xhl ):
"""
Formats an html hyperlink into other forms.
@hlx, hxl, xhl: values returned by set_output_format
"""
if '<a href="' in str(val) and hlx != '<a href="':
val = val.replace('<a href="', hlx).replace('">', hxl, 1).replace('</a>', xhl)
return... | python | {
"resource": ""
} |
q39350 | format_cell | train | def format_cell(val, round_floats = False, decimal_places = 2, format_links = False,
hlx = '', hxl = '', xhl = ''):
"""
Applys smart_round and format_hyperlink to values in a cell if desired.
"""
if round_floats:
val = smart_round(val, decimal_places = decimal_places)
if format_links:
... | python | {
"resource": ""
} |
q39351 | get_row_data | train | def get_row_data(row, column_name, cat_time_ns = True):
"""
Retrieves the requested column's data from the given row.
@cat_time_ns: If the column_name has "_time" in it, will concatenate
the column with any column having the same name but "_time_ns".
"""
column_name_ns = re.sub(r'_time', r... | python | {
"resource": ""
} |
q39352 | SRPContext.generate_random | train | def generate_random(self, bits_len=None):
"""Generates a random value.
:param int bits_len:
:rtype: int
"""
bits_len = bits_len or self._bits_random
return random().getrandbits(bits_len) | python | {
"resource": ""
} |
q39353 | CondorJob.add_checkpoint_file | train | def add_checkpoint_file(self, filename):
"""
Add filename as a checkpoint file for this DAG job.
"""
if filename not in self.__checkpoint_files:
self.__checkpoint_files.append(filename) | python | {
"resource": ""
} |
q39354 | CondorJob.add_file_arg | train | def add_file_arg(self, filename):
"""
Add a file argument to the executable. Arguments are appended after any
options and their order is guaranteed. Also adds the file name to the
list of required input data for this job.
@param filename: file to add as argument.
"""
self.__arguments.append(... | python | {
"resource": ""
} |
q39355 | CondorJob.get_opt | train | def get_opt( self, opt):
"""
Returns the value associated with the given command line option.
Returns None if the option does not exist in the options list.
@param opt: command line option
"""
if self.__options.has_key(opt):
return self.__options[opt]
return None | python | {
"resource": ""
} |
q39356 | CondorJob.add_ini_opts | train | def add_ini_opts(self, cp, section):
"""
Parse command line options from a given section in an ini file and
pass to the executable.
@param cp: ConfigParser object pointing to the ini file.
@param section: section of the ini file to add to the options.
"""
for opt in cp.options(section):
... | python | {
"resource": ""
} |
q39357 | CondorDAGJob.set_grid_site | train | def set_grid_site(self,site):
"""
Set the grid site to run on. If not specified,
will not give hint to Pegasus
"""
self.__grid_site=str(site)
if site != 'local':
self.set_executable_installed(False) | python | {
"resource": ""
} |
q39358 | CondorDAGNode.add_checkpoint_file | train | def add_checkpoint_file(self,filename):
"""
Add filename as a checkpoint file for this DAG node
@param filename: checkpoint filename to add
"""
if filename not in self.__checkpoint_files:
self.__checkpoint_files.append(filename)
if not isinstance(self.job(), CondorDAGManJob):
... | python | {
"resource": ""
} |
q39359 | CondorDAGNode.get_input_files | train | def get_input_files(self):
"""
Return list of input files for this DAG node and its job.
"""
input_files = list(self.__input_files)
if isinstance(self.job(), CondorDAGJob):
input_files = input_files + self.job().get_input_files()
return input_files | python | {
"resource": ""
} |
q39360 | CondorDAGNode.get_output_files | train | def get_output_files(self):
"""
Return list of output files for this DAG node and its job.
"""
output_files = list(self.__output_files)
if isinstance(self.job(), CondorDAGJob):
output_files = output_files + self.job().get_output_files()
return output_files | python | {
"resource": ""
} |
q39361 | CondorDAGNode.get_checkpoint_files | train | def get_checkpoint_files(self):
"""
Return a list of checkpoint files for this DAG node and its job.
"""
checkpoint_files = list(self.__checkpoint_files)
if isinstance(self.job(), CondorDAGJob):
checkpoint_files = checkpoint_files + self.job().get_checkpoint_files()
return checkpoint_fil... | python | {
"resource": ""
} |
q39362 | CondorDAGNode.write_job | train | def write_job(self,fh):
"""
Write the DAG entry for this node's job to the DAG file descriptor.
@param fh: descriptor of open DAG file.
"""
if isinstance(self.job(),CondorDAGManJob):
# create an external subdag from this dag
fh.write( ' '.join(
['SUBDAG EXTERNAL', self.__name, se... | python | {
"resource": ""
} |
q39363 | CondorDAGNode.write_pre_script | train | def write_pre_script(self,fh):
"""
Write the pre script for the job, if there is one
@param fh: descriptor of open DAG file.
"""
if self.__pre_script:
fh.write( 'SCRIPT PRE ' + str(self) + ' ' + self.__pre_script + ' ' +
' '.join(self.__pre_script_args) + '\n' ) | python | {
"resource": ""
} |
q39364 | CondorDAGNode.write_post_script | train | def write_post_script(self,fh):
"""
Write the post script for the job, if there is one
@param fh: descriptor of open DAG file.
"""
if self.__post_script:
fh.write( 'SCRIPT POST ' + str(self) + ' ' + self.__post_script + ' ' +
' '.join(self.__post_script_args) + '\n' ) | python | {
"resource": ""
} |
q39365 | CondorDAGNode.write_input_files | train | def write_input_files(self, fh):
"""
Write as a comment into the DAG file the list of input files
for this DAG node.
@param fh: descriptor of open DAG file.
"""
for f in self.__input_files:
print >>fh, "## Job %s requires input file %s" % (self.__name, f) | python | {
"resource": ""
} |
q39366 | CondorDAGNode.write_output_files | train | def write_output_files(self, fh):
"""
Write as a comment into the DAG file the list of output files
for this DAG node.
@param fh: descriptor of open DAG file.
"""
for f in self.__output_files:
print >>fh, "## Job %s generates output file %s" % (self.__name, f) | python | {
"resource": ""
} |
q39367 | CondorDAGNode.add_parent | train | def add_parent(self,node):
"""
Add a parent to this node. This node will not be executed until the
parent node has run sucessfully.
@param node: CondorDAGNode to add as a parent.
"""
if not isinstance(node, (CondorDAGNode,CondorDAGManNode) ):
raise CondorDAGNodeError, "Parent must be a Con... | python | {
"resource": ""
} |
q39368 | CondorDAGNode.get_cmd_tuple_list | train | def get_cmd_tuple_list(self):
"""
Return a list of tuples containg the command line arguments
"""
# pattern to find DAGman macros
pat = re.compile(r'\$\((.+)\)')
argpat = re.compile(r'\d+')
# first parse the options and replace macros with values
options = self.job().get_opts()
mac... | python | {
"resource": ""
} |
q39369 | CondorDAGNode.get_cmd_line | train | def get_cmd_line(self):
"""
Return the full command line that will be used when this node
is run by DAGman.
"""
cmd = ""
cmd_list = self.get_cmd_tuple_list()
for argument in cmd_list:
cmd += ' '.join(argument) + " "
return cmd | python | {
"resource": ""
} |
q39370 | CondorDAGManNode.add_maxjobs_category | train | def add_maxjobs_category(self,categoryName,maxJobsNum):
"""
Add a category to this DAG called categoryName with a maxjobs of maxJobsNum.
@param node: Add (categoryName,maxJobsNum) tuple to CondorDAG.__maxjobs_categories.
"""
self.__maxjobs_categories.append((str(categoryName),str(maxJobsNum))) | python | {
"resource": ""
} |
q39371 | CondorDAG.add_node | train | def add_node(self,node):
"""
Add a CondorDAGNode to this DAG. The CondorJob that the node uses is
also added to the list of Condor jobs in the DAG so that a list of the
submit files needed by the DAG can be maintained. Each unique CondorJob
will be added once to prevent duplicate submit files being ... | python | {
"resource": ""
} |
q39372 | CondorDAG.write_maxjobs | train | def write_maxjobs(self,fh,category):
"""
Write the DAG entry for this category's maxjobs to the DAG file descriptor.
@param fh: descriptor of open DAG file.
@param category: tuple containing type of jobs to set a maxjobs limit for
and the maximum number of jobs of that type to run at once.
"... | python | {
"resource": ""
} |
q39373 | CondorDAG.write_sub_files | train | def write_sub_files(self):
"""
Write all the submit files used by the dag to disk. Each submit file is
written to the file name set in the CondorJob.
"""
if not self.__nodes_finalized:
for node in self.__nodes:
node.finalize()
if not self.is_dax():
for job in self.__jobs:
... | python | {
"resource": ""
} |
q39374 | CondorDAG.write_concrete_dag | train | def write_concrete_dag(self):
"""
Write all the nodes in the DAG to the DAG file.
"""
if not self.__dag_file_path:
raise CondorDAGError, "No path for DAG file"
try:
dagfile = open( self.__dag_file_path, 'w' )
except:
raise CondorDAGError, "Cannot open file " + self.__dag_file_p... | python | {
"resource": ""
} |
q39375 | CondorDAG.write_dag | train | def write_dag(self):
"""
Write either a dag or a dax.
"""
if not self.__nodes_finalized:
for node in self.__nodes:
node.finalize()
self.write_concrete_dag()
self.write_abstract_dag() | python | {
"resource": ""
} |
q39376 | AnalysisJob.get_config | train | def get_config(self,sec,opt):
"""
Get the configration variable in a particular section of this jobs ini
file.
@param sec: ini file section.
@param opt: option from section sec.
"""
return string.strip(self.__cp.get(sec,opt)) | python | {
"resource": ""
} |
q39377 | AnalysisNode.set_ifo_tag | train | def set_ifo_tag(self,ifo_tag,pass_to_command_line=True):
"""
Set the ifo tag that is passed to the analysis code.
@param ifo_tag: a string to identify one or more IFOs
@bool pass_to_command_line: add ifo-tag as a variable option.
"""
self.__ifo_tag = ifo_tag
if pass_to_command_line:
se... | python | {
"resource": ""
} |
q39378 | AnalysisNode.set_user_tag | train | def set_user_tag(self,usertag,pass_to_command_line=True):
"""
Set the user tag that is passed to the analysis code.
@param user_tag: the user tag to identify the job
@bool pass_to_command_line: add user-tag as a variable option.
"""
self.__user_tag = usertag
if pass_to_command_line:
se... | python | {
"resource": ""
} |
q39379 | AnalysisNode.calibration_cache_path | train | def calibration_cache_path(self):
"""
Determine the path to the correct calibration cache file to use.
"""
if self.__ifo and self.__start > 0:
cal_path = self.job().get_config('calibration','path')
# check if this is S2: split calibration epochs
if ( self.__LHO2k.match(self.__if... | python | {
"resource": ""
} |
q39380 | AnalysisNode.calibration | train | def calibration(self):
"""
Set the path to the calibration cache file for the given IFO.
During S2 the Hanford 2km IFO had two calibration epochs, so
if the start time is during S2, we use the correct cache file.
"""
# figure out the name of the calibration cache files
# as specified in the ... | python | {
"resource": ""
} |
q39381 | ScienceSegment.add_chunk | train | def add_chunk(self,start,end,trig_start=0,trig_end=0):
"""
Add an AnalysisChunk to the list associated with this ScienceSegment.
@param start: GPS start time of chunk.
@param end: GPS end time of chunk.
@param trig_start: GPS start time for triggers from chunk
"""
self.__chunks.append(Analys... | python | {
"resource": ""
} |
q39382 | ScienceData.tama_read | train | def tama_read(self,filename):
"""
Parse the science segments from a tama list of locked segments contained in
file.
@param filename: input text file containing a list of tama segments.
"""
self.__filename = filename
for line in open(filename):
columns = line.split()
i... | python | {
"resource": ""
} |
q39383 | ScienceData.make_chunks | train | def make_chunks(self,length,overlap=0,play=0,sl=0,excl_play=0,pad_data=0):
"""
Divide each ScienceSegment contained in this object into AnalysisChunks.
@param length: length of chunk in seconds.
@param overlap: overlap between segments.
@param play: if true, only generate chunks that overlap with S2... | python | {
"resource": ""
} |
q39384 | ScienceData.make_short_chunks_from_unused | train | def make_short_chunks_from_unused(
self,min_length,overlap=0,play=0,sl=0,excl_play=0):
"""
Create a chunk that uses up the unused data in the science segment
@param min_length: the unused data must be greater than min_length to make a
chunk.
@param overlap: overlap between chunks in seconds.
... | python | {
"resource": ""
} |
q39385 | ScienceData.make_optimised_chunks | train | def make_optimised_chunks(self, min_length, max_length, pad_data=0):
"""
Splits ScienceSegments up into chunks, of a given maximum length.
The length of the last two chunks are chosen so that the data
utilisation is optimised.
@param min_length: minimum chunk length.
@param max_length: maximum c... | python | {
"resource": ""
} |
q39386 | ScienceData.intersection | train | def intersection(self, other):
"""
Replaces the ScienceSegments contained in this instance of ScienceData
with the intersection of those in the instance other. Returns the number
of segments in the intersection.
@param other: ScienceData to use to generate the intersection
"""
# we only dea... | python | {
"resource": ""
} |
q39387 | ScienceData.union | train | def union(self, other):
"""
Replaces the ScienceSegments contained in this instance of ScienceData
with the union of those in the instance other. Returns the number of
ScienceSegments in the union.
@param other: ScienceData to use to generate the intersection
"""
# we only deal with the cas... | python | {
"resource": ""
} |
q39388 | ScienceData.coalesce | train | def coalesce(self):
"""
Coalesces any adjacent ScienceSegments. Returns the number of
ScienceSegments in the coalesced list.
"""
# check for an empty list
if len(self) == 0:
return 0
# sort the list of science segments
self.__sci_segs.sort()
# coalesce the list, checking eac... | python | {
"resource": ""
} |
q39389 | ScienceData.play | train | def play(self):
"""
Keep only times in ScienceSegments which are in the playground
"""
length = len(self)
# initialize list of output segments
ostart = -1
outlist = []
begin_s2 = 729273613
play_space = 6370
play_len = 600
for seg in self:
start = seg.start()
st... | python | {
"resource": ""
} |
q39390 | ScienceData.intersect_3 | train | def intersect_3(self, second, third):
"""
Intersection routine for three inputs. Built out of the intersect,
coalesce and play routines
"""
self.intersection(second)
self.intersection(third)
self.coalesce()
return len(self) | python | {
"resource": ""
} |
q39391 | ScienceData.intersect_4 | train | def intersect_4(self, second, third, fourth):
"""
Intersection routine for four inputs.
"""
self.intersection(second)
self.intersection(third)
self.intersection(fourth)
self.coalesce()
return len(self) | python | {
"resource": ""
} |
q39392 | ScienceData.split | train | def split(self, dt):
"""
Split the segments in the list is subsegments at least as long as dt
"""
outlist=[]
for seg in self:
start = seg.start()
stop = seg.end()
id = seg.id()
while start < stop:
tmpstop = start + dt
if tmpstop > stop:
tmpstop = ... | python | {
"resource": ""
} |
q39393 | LsyncCache.group | train | def group(self, lst, n):
"""
Group an iterable into an n-tuples iterable. Incomplete
tuples are discarded
"""
return itertools.izip(*[itertools.islice(lst, i, None, n) for i in range(n)]) | python | {
"resource": ""
} |
q39394 | LSCDataFindNode.__set_output | train | def __set_output(self):
"""
Private method to set the file to write the cache to. Automaticaly set
once the ifo, start and end times have been set.
"""
if self.__start and self.__end and self.__observatory and self.__type:
self.__output = os.path.join(self.__job.get_cache_dir(), self.__observa... | python | {
"resource": ""
} |
q39395 | LSCDataFindNode.set_start | train | def set_start(self,time,pad = None):
"""
Set the start time of the datafind query.
@param time: GPS start time of query.
"""
if pad:
self.add_var_opt('gps-start-time', int(time)-int(pad))
else:
self.add_var_opt('gps-start-time', int(time))
self.__start = time
self.__set_outpu... | python | {
"resource": ""
} |
q39396 | LSCDataFindNode.set_end | train | def set_end(self,time):
"""
Set the end time of the datafind query.
@param time: GPS end time of query.
"""
self.add_var_opt('gps-end-time', time)
self.__end = time
self.__set_output() | python | {
"resource": ""
} |
q39397 | LSCDataFindNode.set_type | train | def set_type(self,type):
"""
sets the frame type that we are querying
"""
self.add_var_opt('type',str(type))
self.__type = str(type)
self.__set_output() | python | {
"resource": ""
} |
q39398 | LigolwSqliteNode.set_xml_output | train | def set_xml_output(self, xml_file):
"""
Tell ligolw_sqlite to dump the contents of the database to a file.
"""
if self.get_database() is None:
raise ValueError, "no database specified"
self.add_file_opt('extract', xml_file)
self.__xml_output = xml_file | python | {
"resource": ""
} |
q39399 | LigolwSqliteNode.get_output | train | def get_output(self):
"""
Override standard get_output to return xml-file if xml-file is specified.
Otherwise, will return database.
"""
if self.__xml_output:
return self.__xml_output
elif self.get_database():
return self.get_database()
else:
raise ValueError, "no output xm... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.