code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def _fixpath(root, base):
return os.path.abspath(os.path.normpath(os.path.join(root, base))) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_fixpath'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'roo... | Return absolute, normalized, joined paths |
def dotted(self):
v = str(self.geoid.tract).zfill(6)
return v[0:4] + '.' + v[4:] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dotted'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | Return just the tract number, excluding the state and county, in the dotted format |
def uridecode(uristring, encoding='utf-8', errors='strict'):
if not isinstance(uristring, bytes):
uristring = uristring.encode(encoding or 'ascii', errors)
parts = uristring.split(b'%')
result = [parts[0]]
append = result.append
decode = _decoded.get
for s in parts[1:]:
append(de... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'uridecode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Decode a URI string or string component. |
def _resolve_file_name(source, destination):
number = 1
if os.path.exists(os.path.join(destination, os.path.basename(source) + '.zip')):
while True:
zip_filename = os.path.join(destination, os.path.basename(source) + '_' + str(number) + '.zip')
if not os.path.... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_resolve_file_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Create a filename for the destination zip file. |
def ruleName(self):
return _('%s at %s' % (self.room.name, self.room.location.name)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ruleName'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | overrides from parent class |
def check_cache(cache):
if isinstance(cache, BaseCache):
return cache
elif cache is False:
return DictCache()
elif cache is None:
return DummyCache()
else:
raise ValueError('Provided cache must implement BaseCache') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_cache'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cache... | check if a cache fits esipy needs or not |
def validate(self):
super(OutputContextVertex, self).validate()
if self.location.field is not None:
raise ValueError(u'Expected location at a vertex, but got: {}'.format(self.location)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Validate that the OutputContextVertex is correctly representable. |
def variablename(var):
s=[tpl[0] for tpl in itertools.ifilter(lambda x: var is x[1], globals().items())]
s=s[0].upper()
return s | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'variablename'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'var'... | Returns the string of a variable name. |
def legacy_events_view(request):
events = TeacherEvent.objects.all()
event_count = events.count()
paginator = Paginator(events, 100)
page = request.GET.get('page')
try:
events = paginator.page(page)
except PageNotAnInteger:
events = paginator.page(1)
except EmptyPage:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'legacy_events_view'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | View to see legacy events. |
def marshal(self, o, use_value_list=False):
if o is None:
return
elif isinstance(o, dict):
if use_value_list:
for k, v in o.items():
o[k] = [v]
return o
elif isinstance(o, six.string_types):
if use_value_list:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'marshal'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Packages the return from a parser for easy use in a rule. |
def _init_count_terms(self, annots):
gonotindag = set()
gocnts = self.gocnts
go2obj = self.go2obj
for terms in annots.values():
allterms = set()
for go_id in terms:
goobj = go2obj.get(go_id, None)
if goobj is not None:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_count_terms'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Fills in the counts and overall aspect counts. |
def suffix(self):
name = self.name
i = name.rfind('.')
if 0 < i < len(name) - 1:
return name[i:]
else:
return '' | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'suffix'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | The final component's last suffix, if any. |
def _GenerateFleetspeakConfig(self, template_dir, rpm_build_dir):
source_config = os.path.join(
template_dir, "fleetspeak",
os.path.basename(
config.CONFIG.Get(
"ClientBuilder.fleetspeak_config_path", context=self.context)))
fleetspeak_service_dir = config.CONFIG.Get(... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_GenerateFleetspeakConfig'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childr... | Generates a Fleetspeak config for GRR. |
def start(self):
self._prepare()
self._disconnector = tornado.ioloop.PeriodicCallback(self._disconnect_hanging_devices, 1000, self._loop)
self._disconnector.start() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Start this gateway agent. |
def config_parser_to_dict(config_parser):
response = {}
for section in config_parser.sections():
for option in config_parser.options(section):
response.setdefault(section, {})[option] = config_parser.get(section, option)
return response | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'config_parser_to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Convert a ConfigParser to a dictionary. |
def __load(self):
if self._text is not None: return
body = self._session.get(self.url).content
root = html.fromstring(body)
self._text = "\n".join((
p_tag.text_content()
for p_tag in root.findall('.//p[@class="ArticleContent"]')
if 'justify' in... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__load'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | Loads text and photos if they are not cached. |
def interface_direct_csvpath(csvpath):
with open(csvpath) as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
data_class = row.pop('amaasclass', '')
return interface_direct_class(data_class) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'interface_direct_csvpath'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | help to direct to the correct interface interacting with DB by csvfile path |
def _get_intf_rb_id(rbridge_id):
intf_rb_id = ET.Element(
'get-ip-interface',
xmlns="urn:brocade.com:mgmt:brocade-interface-ext"
)
if rbridge_id is not None:
rbridge_el = ET.SubElement(intf_rb_id, "rbridge-id")
rbridge_el.text = rbridge_id
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_intf_rb_id'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'r... | Creates a new Netconf request based on the rbridge_id specifed |
def target(self, project_module):
assert isinstance(project_module, basestring)
if project_module not in self.module2target:
self.module2target[project_module] = \
b2.build.targets.ProjectTarget(project_module, project_module,
self.attribute(proj... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'target'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Returns the project target corresponding to the 'project-module'. |
def _parse_var_int_components(buf, signed):
value = 0
sign = 1
while True:
ch = buf.read(1)
if ch == '':
raise IonException('Variable integer under-run')
octet = ord(ch)
if signed:
if octet & _VAR_INT_SIGN_MASK:
sign = -1
va... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_var_int_components'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ... | Parses a ``VarInt`` or ``VarUInt`` field from a file-like object. |
def cli(env, columns, sortby, volume_id):
file_storage_manager = SoftLayer.FileStorageManager(env.client)
legal_volumes = file_storage_manager.get_replication_partners(
volume_id
)
if not legal_volumes:
click.echo("There are no replication partners for the given volume.")
else:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | List existing replicant volumes for a file volume. |
def includeme(config):
settings = config.registry.settings
root_package_name = config.root_package.__name__
config.registry.webpack = {
'DEFAULT': WebpackState(settings, root_package_name)
}
for extra_config in aslist(settings.get('webpack.configs', [])):
state = WebpackState(setting... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'includeme'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'config'... | Add pyramid_webpack methods and config to the app |
def show(self, ax:plt.Axes=None, figsize:tuple=(3,3), title:Optional[str]=None, hide_axis:bool=True,
cmap:str='tab20', alpha:float=0.5, **kwargs):
"Show the `ImageSegment` on `ax`."
ax = show_image(self, ax=ax, hide_axis=hide_axis, cmap=cmap, figsize=figsize,
interpolatio... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '45']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '12', '19', '28', '33', '38', '43']}; {'id': '4', 'type': 'identifie... | Show the `ImageSegment` on `ax`. |
def aggregate(self, search):
for f, facet in self.facets.items():
agg = facet.get_aggregation()
if isinstance(agg, Bucket):
search.aggs.bucket(f, agg)
elif isinstance(agg, Pipeline):
search.aggs.pipeline(f, agg)
else:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'aggregate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Add aggregations representing the facets selected |
def zSaveFile(self, fileName):
cmd = "SaveFile,{}".format(fileName)
reply = self._sendDDEcommand(cmd)
return int(float(reply.rstrip())) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zSaveFile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Saves the lens currently loaded in the server to a Zemax file |
def feed_interval_get(feed_id, parameters):
'Get adaptive interval between checks for a feed.'
val = cache.get(getkey( T_INTERVAL,
key=feed_interval_key(feed_id, parameters) ))
return val if isinstance(val, tuple) else (val, None) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'feed_interval_get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Get adaptive interval between checks for a feed. |
def tryload_cache(dpath, fname, cfgstr, verbose=None):
try:
return load_cache(dpath, fname, cfgstr, verbose=verbose)
except IOError:
return None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tryload_cache'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [... | returns None if cache cannot be loaded |
async def resume(self):
self.logger.debug("resume command")
if not self.state == 'ready':
return
if self.streamer is None:
return
try:
if not self.streamer.is_playing():
play_state = "Streaming" if self.is_live else "Playing"
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resume'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | Resumes playback if paused |
def open(self):
if not os.path.exists(self.path):
raise IOError("No such path: {0}".format(self.path))
with open(self.path, "rb") as f:
msg = f.read()
result = chardet.detect(msg)
self.buffer = codecs.open(self.path, "rb", encoding=result['encoding'])
self... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'open'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Open the data file. |
def load_definitions(self):
self.data = dict(json.load(open(self.data_fp))['data'])
self.all_faces = set(self.data.pop("__all__"))
self.locations = set(self.data.keys()) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_definitions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Load mapping of country names to face ids |
def round_robin(self, x, y, n_keep):
vals = y.unique()
scores = {}
for cls in vals:
scores[cls] = self.rank(x, np.equal(cls, y).astype('Int64'))
scores[cls].reverse()
keepers = set()
while len(keepers) < n_keep:
for cls in vals:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'round_robin'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Ensures all classes get representative features, not just those with strong features |
def remove_intersecting(self, division, symm=True):
IntersectRelationship.objects.filter(
from_division=self, to_division=division
).delete()
if symm:
division.remove_intersecting(self, False) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_intersecting'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [... | Removes paired relationships between intersecting divisions |
def _auto(direction, name, value, source='auto', convert_to_human=True):
if direction not in ['to', 'from']:
return value
props = property_data_zpool()
if source == 'zfs':
props = property_data_zfs()
elif source == 'auto':
props.update(property_data_zfs())
value_type = props[... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_auto'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [],... | Internal magic for from_auto and to_auto |
def open(self, encoding=None):
try:
if IS_GZIPPED_FILE.search(self._filename):
_file = gzip.open(self._filename, 'rb')
else:
if encoding:
_file = io.open(self._filename, 'r', encoding=encoding, errors='replace')
elif sel... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'open'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Opens the file with the appropriate call |
def _bsecurate_cli_compare_basis_files(args):
ret = curate.compare_basis_files(args.file1, args.file2, args.readfmt1, args.readfmt2, args.uncontract_general)
if ret:
return "No difference found"
else:
return "DIFFERENCES FOUND. SEE ABOVE" | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_bsecurate_cli_compare_basis_files'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'childre... | Handles compare-basis-files subcommand |
def flatten(*args):
for arg in args:
if isinstance(arg, collections.Iterable) and not isinstance(arg, (str, bytes)):
yield from flatten(*arg)
else:
yield arg | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flatten'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': ... | Generator that recursively flattens embedded lists, tuples, etc. |
def time_to_number(self, time):
if not isinstance(time, datetime.time):
raise TypeError(time)
return ((time.second / 60.0 + time.minute) / 60.0 + time.hour) / 24.0 | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'time_to_number'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Converts a time instance to a corresponding float value. |
def _fill_vao(self):
with self.vao:
self.vbos = []
for loc, verts in enumerate(self.arrays):
vbo = VBO(verts)
self.vbos.append(vbo)
self.vao.assign_vertex_attrib_location(vbo, loc) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_fill_vao'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Put array location in VAO for shader in same order as arrays given to Mesh. |
def validate_config(config, schema=CLUSTER_CONFIG_SCHEMA):
if not isinstance(config, dict):
raise ValueError("Config {} is not a dictionary".format(config))
check_required(config, schema)
check_extraneous(config, schema) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Required Dicts indicate that no extra fields can be introduced. |
def _delete_dir(self):
if not self.auto and os.path.isdir(self.meta.build_path + self.prgnam):
shutil.rmtree(self.meta.build_path + self.prgnam) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_delete_dir'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Delete old folder if exists before start build |
def on_replace_scene(self, event: events.ReplaceScene, signal):
self.stop_scene()
self.start_scene(event.new_scene, event.kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_replace_scene'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '11']}; {'id': '4', 'type': 'identifier', 'children': []... | Replace the running scene with a new one. |
def draw_markers(self):
self._canvas_markers.clear()
for marker in self._markers.values():
self.create_marker(marker["category"], marker["start"], marker["finish"], marker) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'draw_markers'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Draw all created markers on the TimeLine Canvas |
def _load_project(self, project):
try:
project['md5sum'] = utils.md5string(project['script'])
ret = self.build_module(project, self.env)
self.projects[project['name']] = ret
except Exception as e:
logger.exception("load project %s error", project.get('name... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_project'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Load project into self.projects from project info dict |
def getBlocks(self):
try:
conn = self.dbi.connection()
result = self.buflistblks.execute(conn)
return result
finally:
if conn:
conn.close() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getBlocks'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Get the blocks that need to be migrated |
def delete(self, count=1):
if self.cursor_position < len(self.text):
deleted = self.document.text_after_cursor[:count]
self.text = self.text[:self.cursor_position] + \
self.text[self.cursor_position + len(deleted):]
return deleted
else:
ret... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Delete specified number of characters and Return the deleted text. |
def node_val_dump(self):
self._flush_node_val()
for (
graph, node, key, branch, turn, tick, value
) in self.sql('node_val_dump'):
yield (
self.unpack(graph),
self.unpack(node),
self.unpack(key),
branch,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'node_val_dump'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Yield the entire contents of the node_val table. |
def space(self):
arg_spaces = [o.space for o in self.matrix.ravel()
if hasattr(o, 'space')]
if len(arg_spaces) == 0:
return TrivialSpace
else:
return ProductSpace.create(*arg_spaces) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'space'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | Combined Hilbert space of all matrix elements. |
def minion_config(opts, vm_):
minion = {
'master': 'salt',
'log_level': 'info',
'hash_type': 'sha256',
}
minion['id'] = vm_['name']
master_finger = salt.config.get_cloud_config_value('master_finger', vm_, opts)
if master_finger is not None:
minion['master_finger'] = m... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'minion_config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Return a minion's configuration for the provided options and VM |
async def create_turn_endpoint(protocol_factory, server_addr, username, password,
lifetime=600, ssl=False, transport='udp'):
loop = asyncio.get_event_loop()
if transport == 'tcp':
_, inner_protocol = await loop.create_connection(
lambda: TurnClientTcpProtocol(s... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_turn_endpoint'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '14']}; {'id': '4', 'type': 'id... | Create datagram connection relayed over TURN. |
def _remove_keys_from_dict_with_nonunique_values(self, d, log_fh=None, log_outprefix=None):
value_counts = collections.Counter(d.values())
new_d = {}
writing_log_file = None not in [log_fh, log_outprefix]
for key in d:
if value_counts[d[key]] == 1:
new_d[key] ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_remove_keys_from_dict_with_nonunique_values'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'typ... | Returns a new dictionary, with keys from input dict removed if their value was not unique |
def resp_set_wififirmware(self, resp):
if resp:
self.wifi_firmware_version = float(str(str(resp.version >> 16) + "." + str(resp.version & 0xff)))
self.wifi_firmware_build_timestamp = resp.build | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resp_set_wififirmware'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Default callback for get_wififirmware |
def _put_text(irods_path, text):
with tempfile.NamedTemporaryFile() as fh:
fpath = fh.name
try:
text = unicode(text, "utf-8")
except (NameError, TypeError):
pass
fh.write(text.encode("utf-8"))
fh.flush()
cmd = CommandWrapper([
"iput... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_put_text'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ir... | Put raw text into iRODS. |
def angle(x, y):
return arccos(dot(x, y)/(norm(x)*norm(y)))*180./pi | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'angle'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'}; {... | Return the angle between vectors a and b in degrees. |
def do_upload(post_data, callback=None):
encoder = MultipartEncoder(post_data)
monitor = MultipartEncoderMonitor(encoder, callback)
headers = {'User-Agent': USER_AGENT, 'Content-Type': monitor.content_type}
response = post(API_URL, data=monitor, headers=headers)
check_response(response)
return r... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_upload'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'po... | does the actual upload also sets and generates the user agent string |
def _c0(self):
"the logarithm of normalizing constant in pdf"
h_df = self.df / 2
p, S = self._p, self.S
return h_df * (logdet(S) + p * logtwo) + lpgamma(p, h_df) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_c0'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'... | the logarithm of normalizing constant in pdf |
def _J(self):
pd = self.particle_distribution(self._Ep * u.GeV)
return pd.to("1/GeV").value | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_J'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id':... | Particles per unit proton energy in particles per GeV |
def qs_delete(self, *keys):
query = self.query.copy()
for key in set(keys):
try:
del query[key]
except KeyError:
pass
return self._copy(query=query) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'qs_delete'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Delete value from QuerySet MultiDict |
def select_ip_version(host, port):
if ':' in host and hasattr(socket, 'AF_INET6'):
return socket.AF_INET6
return socket.AF_INET | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'select_ip_version'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Returns AF_INET4 or AF_INET6 depending on where to connect to. |
def _set_tick_lines_visibility(ax, visible=True):
for i, thisAxis in enumerate((ax.get_xaxis(), ax.get_yaxis())):
for thisItem in thisAxis.get_ticklines():
if isinstance(visible, list):
thisItem.set_visible(visible[i])
else:
thisItem.set_visible(visibl... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_tick_lines_visibility'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':... | Set the visibility of the tick lines of the requested axis. |
def _raise_on_unsupported_token(self, request):
if (request.token_type_hint and
request.token_type_hint in self.valid_token_types and
request.token_type_hint not in self.supported_token_types):
raise UnsupportedTokenTypeError(request=request) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_raise_on_unsupported_token'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children'... | Raise on unsupported tokens. |
def id_unique(dict_id, name, lineno):
if dict_id in name_dict:
global error_occurred
error_occurred = True
print(
"ERROR - {0:s} definition {1:s} at line {2:d} conflicts with {3:s}"
.format(name, dict_id, lineno, name_dict[dict_id]))
return False
else:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'id_unique'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Returns True if dict_id not already used. Otherwise, invokes error |
def function(fname):
def _f(func):
class WrapFunction(Function):
name = fname
def __call__(self, *args, **kwargs):
return func(*args, **kwargs)
return WrapFunction
return _f | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'function'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fname'};... | Make a function to Function class |
def _create_application(self):
return Application(
input=self.input,
output=self.output,
layout=self.ptpython_layout.layout,
key_bindings=merge_key_bindings([
load_python_bindings(self),
load_auto_suggest_bindings(),
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_application'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Create an `Application` instance. |
def ScheduleSystemCronJobs(names=None):
errors = []
disabled_classes = config.CONFIG["Cron.disabled_cron_jobs"]
for name in disabled_classes:
try:
cls = registry.SystemCronJobRegistry.CronJobClassByName(name)
except ValueError:
errors.append("Cron job not found: %s." % name)
continue
i... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ScheduleSystemCronJobs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': [... | Schedules all system cron jobs. |
def rect(self):
if self._w3c:
return self._execute(Command.GET_ELEMENT_RECT)['value']
else:
rect = self.size.copy()
rect.update(self.location)
return rect | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | A dictionary with the size and location of the element. |
def hashVariantAnnotation(cls, gaVariant, gaVariantAnnotation):
treffs = [treff.id for treff in gaVariantAnnotation.transcript_effects]
return hashlib.md5(
"{}\t{}\t{}\t".format(
gaVariant.reference_bases, tuple(gaVariant.alternate_bases),
treffs)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hashVariantAnnotation'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children':... | Produces an MD5 hash of the gaVariant and gaVariantAnnotation objects |
def goForward(self):
if self._slideshow.currentIndex() == self._slideshow.count() - 1:
self.finished.emit()
else:
self._slideshow.slideInNext() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'goForward'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Moves to the next slide or finishes the walkthrough. |
def sweFixedStar(star, jd):
sweList = swisseph.fixstar_ut(star, jd)
mag = swisseph.fixstar_mag(star)
return {
'id': star,
'mag': mag,
'lon': sweList[0],
'lat': sweList[1]
} | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sweFixedStar'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Returns a fixed star from the Ephemeris. |
def lgdistplot(self,dict_to_use,orientation):
data = dict()
for s_name in dict_to_use:
try:
data[s_name] = {int(d): int (dict_to_use[s_name][d]) for d in dict_to_use[s_name]}
except KeyError:
pass
if len(data) == 0:
log.debug('N... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lgdistplot'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Generate a read length distribution plot |
def shell(cmd, **kwargs):
logger.debug("$ %s", cmd)
return subprocess.check_output(cmd, shell=True, **kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'shell'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cmd'};... | Execute cmd, check exit code, return stdout |
def hidden_cursor():
if sys.stdout.isatty():
_LOGGER.debug('Hiding cursor.')
print('\x1B[?25l', end='')
sys.stdout.flush()
try:
yield
finally:
if sys.stdout.isatty():
_LOGGER.debug('Showing cursor.')
print('\n\x1B[?25h', end='')
sys... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hidden_cursor'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '37']}; {'id': '5',... | Temporarily hide the terminal cursor. |
def name(self):
self.open()
name = lvm_lv_get_name(self.__lvh)
self.close()
return name | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'name'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Returns the logical volume name. |
def create (netParams=None, simConfig=None, output=False):
from .. import sim
import __main__ as top
if not netParams: netParams = top.netParams
if not simConfig: simConfig = top.simConfig
sim.initialize(netParams, simConfig)
pops = sim.net.createPops()
cells = sim.net.createCells()
conn... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children': ['5',... | Sequence of commands to create network |
def exec_file(filename, return_locals=False, is_deploy_code=False):
if filename not in PYTHON_CODES:
with open(filename, 'r') as f:
code = f.read()
code = compile(code, filename, 'exec')
PYTHON_CODES[filename] = code
data = {
'__file__': filename,
'state': pse... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exec_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Execute a Python file and optionally return it's attributes as a dict. |
def css_text(self, path, default=NULL, smart=False, normalize_space=True):
try:
return get_node_text(self.css_one(path), smart=smart,
normalize_space=normalize_space)
except IndexError:
if default is NULL:
raise
else:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'css_text'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': ... | Get normalized text of node which matches the css path. |
def sentence_iterator(self, file_path: str) -> Iterator[OntonotesSentence]:
for document in self.dataset_document_iterator(file_path):
for sentence in document:
yield sentence | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sentence_iterator'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | An iterator over the sentences in an individual CONLL formatted file. |
def _py_ctype(parameter):
ctype = parameter.ctype
if ctype is None:
raise ValueError("Can't bind ctypes py_parameter for parameter"
" {}".format(parameter.definition()))
return ctype.lower() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_py_ctype'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'paramet... | Returns the ctypes type name for the specified fortran parameter. |
def add_device_override(self, addr, cat, subcat, firmware=None):
self.plm.devices.add_override(addr, 'cat', cat)
self.plm.devices.add_override(addr, 'subcat', subcat)
if firmware:
self.plm.devices.add_override(addr, 'firmware', firmware) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_device_override'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'c... | Add a device override to the PLM. |
async def states(self, country: str) -> list:
data = await self._request(
'get', 'states', params={'country': country})
return [d['state'] for d in data['data']] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'states'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Return a list of supported states in a country. |
def assert_is_not_substring(substring, subject, message=None, extra=None):
assert (
(subject is not None)
and (substring is not None)
and (subject.find(substring) == -1)
), _assert_fail_message(message, substring, subject, "is in", extra) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'assert_is_not_substring'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'ch... | Raises an AssertionError if substring is a substring of subject. |
def put_on_top(self, request, queryset):
queryset.update(publication_date=timezone.now())
self.ping_directories(request, queryset, messages=False)
self.message_user(request, _(
'The selected entries are now set at the current date.')) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'put_on_top'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Put the selected entries on top at the current date. |
def merge_range_pairs(prs):
new_prs = []
sprs = [sorted(p) for p in prs]
sprs = sorted(sprs)
merged = False
x = 0
while x < len(sprs):
newx = x + 1
new_pair = list(sprs[x])
for y in range(x + 1, len(sprs)):
if new_pair[0] <= sprs[y][0] - 1 <= new_pair[1]:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_range_pairs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Takes in a list of pairs specifying ranges and returns a sorted list of merged, sorted ranges. |
def parse_jellyfish_data(self, f):
histogram = {}
occurence = 0
for line in f['f']:
line = line.rstrip('\n')
occurence = int(line.split(" ")[0])
count = int(line.split(" ")[1])
histogram[occurence] = occurence*count
del histogram[occurence]... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_jellyfish_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Go through the hist file and memorise it |
def sort_snps(snps):
sorted_list = sorted(snps["chrom"].unique(), key=_natural_sort_key)
if "PAR" in sorted_list:
sorted_list.remove("PAR")
sorted_list.append("PAR")
if "MT" in sorted_list:
sorted_list.remove("MT")
sorted_list.append("MT")
snps["chrom"] = snps["chrom"].as... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_snps'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'snps'};... | Sort SNPs based on ordered chromosome list and position. |
def LogMsg(msg):
global headerlogged
if headerlogged == 0:
print("{0:<8} {1:<90} {2}".format(
"Time",
"MainThread",
"UpdateSNMPObjsThread"
))
print("{0:-^120}".format("-"))
headerlogged = 1
threadname = threading.currentThread().name
funcname = sys._getframe(1).f_code.co_name
if funcname == "<modu... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'LogMsg'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'i... | Writes a formatted log message with a timestamp to stdout. |
def create_admin(app, appbuilder, username, firstname, lastname, email, password):
auth_type = {
c.AUTH_DB: "Database Authentications",
c.AUTH_OID: "OpenID Authentication",
c.AUTH_LDAP: "LDAP Authentication",
c.AUTH_REMOTE_USER: "WebServer REMOTE_USER Authentication",
c.AUTH_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_admin'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': 'identifier'... | Creates an admin user |
def segments_to_numpy(segments):
segments = numpy.array(segments, dtype=SEGMENT_DATATYPE, ndmin=2)
segments = segments if SEGMENTS_DIRECTION == 0 else numpy.transpose(segments)
return segments | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'segments_to_numpy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | given a list of 4-element tuples, transforms it into a numpy array |
def print_recipe(recipe):
print(colors.yellow("\n{0}".format(recipe['name'])))
print " description: {0}".format(recipe['description'])
print " version: {0}".format(recipe['version'])
print " dependencies: {0}".format(", ".join(recipe['dependencies']))
print " attributes: {0}".format(", "... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_recipe'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'reci... | Pretty prints the given recipe |
def deviator_stress(self):
if not self.is_symmetric:
raise warnings.warn("The stress tensor is not symmetric, "
"so deviator stress will not be either")
return self - self.mean_stress*np.eye(3) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'deviator_stress'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | returns the deviatoric component of the stress |
def _welch_anova(self, dv=None, between=None, export_filename=None):
aov = welch_anova(data=self, dv=dv, between=between,
export_filename=export_filename)
return aov | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_welch_anova'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [... | Return one-way Welch ANOVA. |
def upd_doc(self, doc, index_update=True, label_guesser_update=True):
if not self.index_writer and index_update:
self.index_writer = self.index.writer()
if not self.label_guesser_updater and label_guesser_update:
self.label_guesser_updater = self.label_guesser.get_updater()
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'upd_doc'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Update a document in the index |
def _get_dopants(substitutions, num_dopants, match_oxi_sign):
n_type = [pred for pred in substitutions
if pred['dopant_species'].oxi_state >
pred['original_species'].oxi_state
and (not match_oxi_sign or
np.sign(pred['dopant_species'].oxi_state) ==
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_dopants'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Utility method to get n- and p-type dopants from a list of substitutions. |
def parse(self, output):
output = self._get_lines_with_stems(output)
words = self._make_unique(output)
return self._parse_for_simple_stems(words) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Find stems for a given text. |
def api_url(self):
return pathjoin(Bin.path, self.name, url=self.service.url) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'api_url'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | return the api url of self |
def save(self):
if self.parent.buffered:
query =
query = query % (self.identifier.n3(),
self.graph.serialize(format='nt'))
self.parent.graph.update(query)
self.flush()
else:
self.meta.generate() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id... | Transfer the statements in this context over to the main store. |
def _load_view(self, template_engine_name, template_dir):
file_name = template_engine_name.lower()
class_name = "{}View".format(template_engine_name.title())
try:
view_module = import_module("rails.views.{}".format(file_name))
except ImportError:
raise Exception("... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_view'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Load view by name and return an instance. |
def active_tcp():
ret = {}
for statf in ['/proc/net/tcp', '/proc/net/tcp6']:
if os.path.isfile(statf):
with salt.utils.files.fopen(statf, 'rb') as fp_:
for line in fp_:
line = salt.utils.stringutils.to_unicode(line)
if line.strip().star... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'active_tcp'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '116']}; {'id': '... | Return a dict describing all active tcp connections as quickly as possible |
def add_update_callback(self, callback, device):
self._update_callbacks.append([callback, device])
_LOGGER.debug('Added update callback to %s on %s', callback, device) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_update_callback'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [... | Register as callback for when a matching device changes. |
def collapse_umi(in_file):
keep = defaultdict(dict)
with open_fastq(in_file) as handle:
for line in handle:
if line.startswith("@"):
m = re.search('UMI_([ATGC]*)', line.strip())
umis = m.group(0)
seq = handle.next().strip()
hand... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'collapse_umi'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'in_f... | collapse reads using UMI tags |
def env(self):
from copy import copy
env = copy(self.doc.env)
assert env is not None, 'Got a null execution context'
env.update(self._envvar_env)
env.update(self.all_props)
return env | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'env'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'... | The execution context for rowprocessors and row-generating notebooks and functions. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.