repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
nion-software/nionswift | nion/swift/HistogramPanel.py | ColorMapCanvasItem._repaint | def _repaint(self, drawing_context: DrawingContext.DrawingContext):
"""Repaint the canvas item. This will occur on a thread."""
# canvas size
canvas_width = self.canvas_size.width
canvas_height = self.canvas_size.height
with drawing_context.saver():
if self.__color_... | python | def _repaint(self, drawing_context: DrawingContext.DrawingContext):
"""Repaint the canvas item. This will occur on a thread."""
# canvas size
canvas_width = self.canvas_size.width
canvas_height = self.canvas_size.height
with drawing_context.saver():
if self.__color_... | [
"def",
"_repaint",
"(",
"self",
",",
"drawing_context",
":",
"DrawingContext",
".",
"DrawingContext",
")",
":",
"# canvas size",
"canvas_width",
"=",
"self",
".",
"canvas_size",
".",
"width",
"canvas_height",
"=",
"self",
".",
"canvas_size",
".",
"height",
"with... | Repaint the canvas item. This will occur on a thread. | [
"Repaint",
"the",
"canvas",
"item",
".",
"This",
"will",
"occur",
"on",
"a",
"thread",
"."
] | d43693eaf057b8683b9638e575000f055fede452 | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/HistogramPanel.py#L179-L191 | train |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.get_params | def get_params(self):
"Parameters used to initialize the class"
import inspect
a = inspect.getargspec(self.__init__)[0]
out = dict()
for key in a[1:]:
value = getattr(self, "_%s" % key, None)
out[key] = value
return out | python | def get_params(self):
"Parameters used to initialize the class"
import inspect
a = inspect.getargspec(self.__init__)[0]
out = dict()
for key in a[1:]:
value = getattr(self, "_%s" % key, None)
out[key] = value
return out | [
"def",
"get_params",
"(",
"self",
")",
":",
"import",
"inspect",
"a",
"=",
"inspect",
".",
"getargspec",
"(",
"self",
".",
"__init__",
")",
"[",
"0",
"]",
"out",
"=",
"dict",
"(",
")",
"for",
"key",
"in",
"a",
"[",
"1",
":",
"]",
":",
"value",
... | Parameters used to initialize the class | [
"Parameters",
"used",
"to",
"initialize",
"the",
"class"
] | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L137-L145 | train |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.signature | def signature(self):
"Instance file name"
kw = self.get_params()
keys = sorted(kw.keys())
l = []
for k in keys:
n = k[0] + k[-1]
v = kw[k]
if k == 'function_set':
v = "_".join([x.__name__[0] +
x.__n... | python | def signature(self):
"Instance file name"
kw = self.get_params()
keys = sorted(kw.keys())
l = []
for k in keys:
n = k[0] + k[-1]
v = kw[k]
if k == 'function_set':
v = "_".join([x.__name__[0] +
x.__n... | [
"def",
"signature",
"(",
"self",
")",
":",
"kw",
"=",
"self",
".",
"get_params",
"(",
")",
"keys",
"=",
"sorted",
"(",
"kw",
".",
"keys",
"(",
")",
")",
"l",
"=",
"[",
"]",
"for",
"k",
"in",
"keys",
":",
"n",
"=",
"k",
"[",
"0",
"]",
"+",
... | Instance file name | [
"Instance",
"file",
"name"
] | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L157-L174 | train |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.population | def population(self):
"Class containing the population and all the individuals generated"
try:
return self._p
except AttributeError:
self._p = self._population_class(base=self,
tournament_size=self._tournament_size,
... | python | def population(self):
"Class containing the population and all the individuals generated"
try:
return self._p
except AttributeError:
self._p = self._population_class(base=self,
tournament_size=self._tournament_size,
... | [
"def",
"population",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_p",
"except",
"AttributeError",
":",
"self",
".",
"_p",
"=",
"self",
".",
"_population_class",
"(",
"base",
"=",
"self",
",",
"tournament_size",
"=",
"self",
".",
"_tourname... | Class containing the population and all the individuals generated | [
"Class",
"containing",
"the",
"population",
"and",
"all",
"the",
"individuals",
"generated"
] | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L262-L275 | train |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.random_leaf | def random_leaf(self):
"Returns a random variable with the associated weight"
for i in range(self._number_tries_feasible_ind):
var = np.random.randint(self.nvar)
v = self._random_leaf(var)
if v is None:
continue
return v
raise Runti... | python | def random_leaf(self):
"Returns a random variable with the associated weight"
for i in range(self._number_tries_feasible_ind):
var = np.random.randint(self.nvar)
v = self._random_leaf(var)
if v is None:
continue
return v
raise Runti... | [
"def",
"random_leaf",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_number_tries_feasible_ind",
")",
":",
"var",
"=",
"np",
".",
"random",
".",
"randint",
"(",
"self",
".",
"nvar",
")",
"v",
"=",
"self",
".",
"_random_leaf",
"... | Returns a random variable with the associated weight | [
"Returns",
"a",
"random",
"variable",
"with",
"the",
"associated",
"weight"
] | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L300-L308 | train |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.random_offspring | def random_offspring(self):
"Returns an offspring with the associated weight(s)"
function_set = self.function_set
function_selection = self._function_selection_ins
function_selection.density = self.population.density
function_selection.unfeasible_functions.clear()
for i i... | python | def random_offspring(self):
"Returns an offspring with the associated weight(s)"
function_set = self.function_set
function_selection = self._function_selection_ins
function_selection.density = self.population.density
function_selection.unfeasible_functions.clear()
for i i... | [
"def",
"random_offspring",
"(",
"self",
")",
":",
"function_set",
"=",
"self",
".",
"function_set",
"function_selection",
"=",
"self",
".",
"_function_selection_ins",
"function_selection",
".",
"density",
"=",
"self",
".",
"population",
".",
"density",
"function_sel... | Returns an offspring with the associated weight(s) | [
"Returns",
"an",
"offspring",
"with",
"the",
"associated",
"weight",
"(",
"s",
")"
] | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L454-L476 | train |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.stopping_criteria | def stopping_criteria(self):
"Test whether the stopping criteria has been achieved."
if self.stopping_criteria_tl():
return True
if self.generations < np.inf:
inds = self.popsize * self.generations
flag = inds <= len(self.population.hist)
else:
... | python | def stopping_criteria(self):
"Test whether the stopping criteria has been achieved."
if self.stopping_criteria_tl():
return True
if self.generations < np.inf:
inds = self.popsize * self.generations
flag = inds <= len(self.population.hist)
else:
... | [
"def",
"stopping_criteria",
"(",
"self",
")",
":",
"if",
"self",
".",
"stopping_criteria_tl",
"(",
")",
":",
"return",
"True",
"if",
"self",
".",
"generations",
"<",
"np",
".",
"inf",
":",
"inds",
"=",
"self",
".",
"popsize",
"*",
"self",
".",
"generat... | Test whether the stopping criteria has been achieved. | [
"Test",
"whether",
"the",
"stopping",
"criteria",
"has",
"been",
"achieved",
"."
] | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L488-L511 | train |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.nclasses | def nclasses(self, v):
"Number of classes of v, also sets the labes"
if not self.classifier:
return 0
if isinstance(v, list):
self._labels = np.arange(len(v))
return
if not isinstance(v, np.ndarray):
v = tonparray(v)
self._labels = ... | python | def nclasses(self, v):
"Number of classes of v, also sets the labes"
if not self.classifier:
return 0
if isinstance(v, list):
self._labels = np.arange(len(v))
return
if not isinstance(v, np.ndarray):
v = tonparray(v)
self._labels = ... | [
"def",
"nclasses",
"(",
"self",
",",
"v",
")",
":",
"if",
"not",
"self",
".",
"classifier",
":",
"return",
"0",
"if",
"isinstance",
"(",
"v",
",",
"list",
")",
":",
"self",
".",
"_labels",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"v",
")",
")... | Number of classes of v, also sets the labes | [
"Number",
"of",
"classes",
"of",
"v",
"also",
"sets",
"the",
"labes"
] | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L513-L523 | train |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.fit | def fit(self, X, y, test_set=None):
"""Evolutive process"""
self._init_time = time.time()
self.X = X
if self._popsize == "nvar":
self._popsize = self.nvar + len(self._input_functions)
if isinstance(test_set, str) and test_set == 'shuffle':
test_set = self.... | python | def fit(self, X, y, test_set=None):
"""Evolutive process"""
self._init_time = time.time()
self.X = X
if self._popsize == "nvar":
self._popsize = self.nvar + len(self._input_functions)
if isinstance(test_set, str) and test_set == 'shuffle':
test_set = self.... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
",",
"test_set",
"=",
"None",
")",
":",
"self",
".",
"_init_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"X",
"=",
"X",
"if",
"self",
".",
"_popsize",
"==",
"\"nvar\"",
":",
"self",
".",... | Evolutive process | [
"Evolutive",
"process"
] | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L537-L583 | train |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.decision_function | def decision_function(self, v=None, X=None):
"Decision function i.e. the raw data of the prediction"
m = self.model(v=v)
return m.decision_function(X) | python | def decision_function(self, v=None, X=None):
"Decision function i.e. the raw data of the prediction"
m = self.model(v=v)
return m.decision_function(X) | [
"def",
"decision_function",
"(",
"self",
",",
"v",
"=",
"None",
",",
"X",
"=",
"None",
")",
":",
"m",
"=",
"self",
".",
"model",
"(",
"v",
"=",
"v",
")",
"return",
"m",
".",
"decision_function",
"(",
"X",
")"
] | Decision function i.e. the raw data of the prediction | [
"Decision",
"function",
"i",
".",
"e",
".",
"the",
"raw",
"data",
"of",
"the",
"prediction"
] | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L593-L596 | train |
mgraffg/EvoDAG | EvoDAG/base.py | EvoDAG.predict | def predict(self, v=None, X=None):
"""In classification this returns the classes, in
regression it is equivalent to the decision function"""
if X is None:
X = v
v = None
m = self.model(v=v)
return m.predict(X) | python | def predict(self, v=None, X=None):
"""In classification this returns the classes, in
regression it is equivalent to the decision function"""
if X is None:
X = v
v = None
m = self.model(v=v)
return m.predict(X) | [
"def",
"predict",
"(",
"self",
",",
"v",
"=",
"None",
",",
"X",
"=",
"None",
")",
":",
"if",
"X",
"is",
"None",
":",
"X",
"=",
"v",
"v",
"=",
"None",
"m",
"=",
"self",
".",
"model",
"(",
"v",
"=",
"v",
")",
"return",
"m",
".",
"predict",
... | In classification this returns the classes, in
regression it is equivalent to the decision function | [
"In",
"classification",
"this",
"returns",
"the",
"classes",
"in",
"regression",
"it",
"is",
"equivalent",
"to",
"the",
"decision",
"function"
] | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L598-L605 | train |
marrow/WebCore | web/server/gevent_.py | serve | def serve(application, host='127.0.0.1', port=8080):
"""Gevent-based WSGI-HTTP server."""
# Instantiate the server with a host/port configuration and our application.
WSGIServer((host, int(port)), application).serve_forever() | python | def serve(application, host='127.0.0.1', port=8080):
"""Gevent-based WSGI-HTTP server."""
# Instantiate the server with a host/port configuration and our application.
WSGIServer((host, int(port)), application).serve_forever() | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Instantiate the server with a host/port configuration and our application.",
"WSGIServer",
"(",
"(",
"host",
",",
"int",
"(",
"port",
")",
")",
",",
"applic... | Gevent-based WSGI-HTTP server. | [
"Gevent",
"-",
"based",
"WSGI",
"-",
"HTTP",
"server",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/gevent_.py#L14-L18 | train |
bitlabstudio/django-subscribe | subscribe/templatetags/subscribe_tags.py | get_subscribers | def get_subscribers(obj):
"""
Returns the subscribers for a given object.
:param obj: Any object.
"""
ctype = ContentType.objects.get_for_model(obj)
return Subscription.objects.filter(content_type=ctype, object_id=obj.pk) | python | def get_subscribers(obj):
"""
Returns the subscribers for a given object.
:param obj: Any object.
"""
ctype = ContentType.objects.get_for_model(obj)
return Subscription.objects.filter(content_type=ctype, object_id=obj.pk) | [
"def",
"get_subscribers",
"(",
"obj",
")",
":",
"ctype",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"obj",
")",
"return",
"Subscription",
".",
"objects",
".",
"filter",
"(",
"content_type",
"=",
"ctype",
",",
"object_id",
"=",
"obj",
".... | Returns the subscribers for a given object.
:param obj: Any object. | [
"Returns",
"the",
"subscribers",
"for",
"a",
"given",
"object",
"."
] | 313de63fb4acda172e88b65c3327c793f98e8aa9 | https://github.com/bitlabstudio/django-subscribe/blob/313de63fb4acda172e88b65c3327c793f98e8aa9/subscribe/templatetags/subscribe_tags.py#L23-L31 | train |
bitlabstudio/django-subscribe | subscribe/templatetags/subscribe_tags.py | is_subscribed | def is_subscribed(user, obj):
"""
Returns ``True`` if the user is subscribed to the given object.
:param user: A ``User`` instance.
:param obj: Any object.
"""
if not user.is_authenticated():
return False
ctype = ContentType.objects.get_for_model(obj)
try:
Subscriptio... | python | def is_subscribed(user, obj):
"""
Returns ``True`` if the user is subscribed to the given object.
:param user: A ``User`` instance.
:param obj: Any object.
"""
if not user.is_authenticated():
return False
ctype = ContentType.objects.get_for_model(obj)
try:
Subscriptio... | [
"def",
"is_subscribed",
"(",
"user",
",",
"obj",
")",
":",
"if",
"not",
"user",
".",
"is_authenticated",
"(",
")",
":",
"return",
"False",
"ctype",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"obj",
")",
"try",
":",
"Subscription",
"."... | Returns ``True`` if the user is subscribed to the given object.
:param user: A ``User`` instance.
:param obj: Any object. | [
"Returns",
"True",
"if",
"the",
"user",
"is",
"subscribed",
"to",
"the",
"given",
"object",
"."
] | 313de63fb4acda172e88b65c3327c793f98e8aa9 | https://github.com/bitlabstudio/django-subscribe/blob/313de63fb4acda172e88b65c3327c793f98e8aa9/subscribe/templatetags/subscribe_tags.py#L35-L54 | train |
marrow/WebCore | web/core/context.py | Context._promote | def _promote(self, name, instantiate=True):
"""Create a new subclass of Context which incorporates instance attributes and new descriptors.
This promotes an instance and its instance attributes up to being a class with class attributes, then
returns an instance of that class.
"""
metaclass = type(self._... | python | def _promote(self, name, instantiate=True):
"""Create a new subclass of Context which incorporates instance attributes and new descriptors.
This promotes an instance and its instance attributes up to being a class with class attributes, then
returns an instance of that class.
"""
metaclass = type(self._... | [
"def",
"_promote",
"(",
"self",
",",
"name",
",",
"instantiate",
"=",
"True",
")",
":",
"metaclass",
"=",
"type",
"(",
"self",
".",
"__class__",
")",
"contents",
"=",
"self",
".",
"__dict__",
".",
"copy",
"(",
")",
"cls",
"=",
"metaclass",
"(",
"str"... | Create a new subclass of Context which incorporates instance attributes and new descriptors.
This promotes an instance and its instance attributes up to being a class with class attributes, then
returns an instance of that class. | [
"Create",
"a",
"new",
"subclass",
"of",
"Context",
"which",
"incorporates",
"instance",
"attributes",
"and",
"new",
"descriptors",
".",
"This",
"promotes",
"an",
"instance",
"and",
"its",
"instance",
"attributes",
"up",
"to",
"being",
"a",
"class",
"with",
"cl... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/context.py#L23-L37 | train |
NeuroML/pyNeuroML | pyneuroml/tune/NeuroMLController.py | run_individual | def run_individual(sim_var,
reference,
neuroml_file,
nml_doc,
still_included,
generate_dir,
target,
sim_time,
dt,
simulator,
cl... | python | def run_individual(sim_var,
reference,
neuroml_file,
nml_doc,
still_included,
generate_dir,
target,
sim_time,
dt,
simulator,
cl... | [
"def",
"run_individual",
"(",
"sim_var",
",",
"reference",
",",
"neuroml_file",
",",
"nml_doc",
",",
"still_included",
",",
"generate_dir",
",",
"target",
",",
"sim_time",
",",
"dt",
",",
"simulator",
",",
"cleanup",
"=",
"True",
",",
"show",
"=",
"False",
... | Run an individual simulation.
The candidate data has been flattened into the sim_var dict. The
sim_var dict contains parameter:value key value pairs, which are
applied to the model before it is simulated. | [
"Run",
"an",
"individual",
"simulation",
"."
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/tune/NeuroMLController.py#L154-L323 | train |
NeuroML/pyNeuroML | pyneuroml/tune/NeuroMLController.py | NeuroMLController.run | def run(self,candidates,parameters):
"""
Run simulation for each candidate
This run method will loop through each candidate and run the simulation
corresponding to its parameter values. It will populate an array called
traces with the resulting voltage traces for the sim... | python | def run(self,candidates,parameters):
"""
Run simulation for each candidate
This run method will loop through each candidate and run the simulation
corresponding to its parameter values. It will populate an array called
traces with the resulting voltage traces for the sim... | [
"def",
"run",
"(",
"self",
",",
"candidates",
",",
"parameters",
")",
":",
"traces",
"=",
"[",
"]",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"if",
"self",
".",
"num_parallel_evaluations",
"==",
"1",
":",
"for",
"candidate_i",
"in",
"range",
"(... | Run simulation for each candidate
This run method will loop through each candidate and run the simulation
corresponding to its parameter values. It will populate an array called
traces with the resulting voltage traces for the simulation and return it. | [
"Run",
"simulation",
"for",
"each",
"candidate",
"This",
"run",
"method",
"will",
"loop",
"through",
"each",
"candidate",
"and",
"run",
"the",
"simulation",
"corresponding",
"to",
"its",
"parameter",
"values",
".",
"It",
"will",
"populate",
"an",
"array",
"cal... | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/tune/NeuroMLController.py#L64-L135 | train |
marrow/WebCore | web/ext/local.py | ThreadLocalExtension.prepare | def prepare(self, context):
"""Executed prior to processing a request."""
if __debug__:
log.debug("Assigning thread local request context.")
self.local.context = context | python | def prepare(self, context):
"""Executed prior to processing a request."""
if __debug__:
log.debug("Assigning thread local request context.")
self.local.context = context | [
"def",
"prepare",
"(",
"self",
",",
"context",
")",
":",
"if",
"__debug__",
":",
"log",
".",
"debug",
"(",
"\"Assigning thread local request context.\"",
")",
"self",
".",
"local",
".",
"context",
"=",
"context"
] | Executed prior to processing a request. | [
"Executed",
"prior",
"to",
"processing",
"a",
"request",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/local.py#L79-L84 | train |
marrow/WebCore | web/core/view.py | WebViews.register | def register(self, kind, handler):
"""Register a handler for a given type, class, interface, or abstract base class.
View registration should happen within the `start` callback of an extension. For example, to register the
previous `json` view example:
class JSONExtension:
def start(self, context):
... | python | def register(self, kind, handler):
"""Register a handler for a given type, class, interface, or abstract base class.
View registration should happen within the `start` callback of an extension. For example, to register the
previous `json` view example:
class JSONExtension:
def start(self, context):
... | [
"def",
"register",
"(",
"self",
",",
"kind",
",",
"handler",
")",
":",
"if",
"__debug__",
":",
"# In production this logging is completely skipped, regardless of logging level.",
"if",
"py3",
"and",
"not",
"pypy",
":",
"# Where possible, we shorten things to just the cannonic... | Register a handler for a given type, class, interface, or abstract base class.
View registration should happen within the `start` callback of an extension. For example, to register the
previous `json` view example:
class JSONExtension:
def start(self, context):
context.view.register(tuple, json)
... | [
"Register",
"a",
"handler",
"for",
"a",
"given",
"type",
"class",
"interface",
"or",
"abstract",
"base",
"class",
".",
"View",
"registration",
"should",
"happen",
"within",
"the",
"start",
"callback",
"of",
"an",
"extension",
".",
"For",
"example",
"to",
"re... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/view.py#L112-L144 | train |
marrow/WebCore | web/app/static.py | static | def static(base, mapping=None, far=('js', 'css', 'gif', 'jpg', 'jpeg', 'png', 'ttf', 'woff')):
"""Serve files from disk.
This utility endpoint factory is meant primarily for use in development environments; in production environments
it is better (more efficient, secure, etc.) to serve your static content using a ... | python | def static(base, mapping=None, far=('js', 'css', 'gif', 'jpg', 'jpeg', 'png', 'ttf', 'woff')):
"""Serve files from disk.
This utility endpoint factory is meant primarily for use in development environments; in production environments
it is better (more efficient, secure, etc.) to serve your static content using a ... | [
"def",
"static",
"(",
"base",
",",
"mapping",
"=",
"None",
",",
"far",
"=",
"(",
"'js'",
",",
"'css'",
",",
"'gif'",
",",
"'jpg'",
",",
"'jpeg'",
",",
"'png'",
",",
"'ttf'",
",",
"'woff'",
")",
")",
":",
"base",
"=",
"abspath",
"(",
"base",
")",
... | Serve files from disk.
This utility endpoint factory is meant primarily for use in development environments; in production environments
it is better (more efficient, secure, etc.) to serve your static content using a front end load balancer such as
Nginx.
The first argument, `base`, represents the base path to ... | [
"Serve",
"files",
"from",
"disk",
".",
"This",
"utility",
"endpoint",
"factory",
"is",
"meant",
"primarily",
"for",
"use",
"in",
"development",
"environments",
";",
"in",
"production",
"environments",
"it",
"is",
"better",
"(",
"more",
"efficient",
"secure",
"... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/app/static.py#L21-L76 | train |
marrow/WebCore | web/server/diesel_.py | serve | def serve(application, host='127.0.0.1', port=8080):
"""Diesel-based (greenlet) WSGI-HTTP server.
As a minor note, this is crazy. Diesel includes Flask, too.
"""
# Instantiate the server with a host/port configuration and our application.
WSGIApplication(application, port=int(port), iface=host).run() | python | def serve(application, host='127.0.0.1', port=8080):
"""Diesel-based (greenlet) WSGI-HTTP server.
As a minor note, this is crazy. Diesel includes Flask, too.
"""
# Instantiate the server with a host/port configuration and our application.
WSGIApplication(application, port=int(port), iface=host).run() | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Instantiate the server with a host/port configuration and our application.",
"WSGIApplication",
"(",
"application",
",",
"port",
"=",
"int",
"(",
"port",
")",
... | Diesel-based (greenlet) WSGI-HTTP server.
As a minor note, this is crazy. Diesel includes Flask, too. | [
"Diesel",
"-",
"based",
"(",
"greenlet",
")",
"WSGI",
"-",
"HTTP",
"server",
".",
"As",
"a",
"minor",
"note",
"this",
"is",
"crazy",
".",
"Diesel",
"includes",
"Flask",
"too",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/diesel_.py#L14-L21 | train |
NeuroML/pyNeuroML | pyneuroml/plot/PlotSpikes.py | process_args | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A script for plotting files containing spike time data")
parser.add_argument('spiketimeFiles',
type=str,
metavar='<spiketime file>',
... | python | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A script for plotting files containing spike time data")
parser.add_argument('spiketimeFiles',
type=str,
metavar='<spiketime file>',
... | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"A script for plotting files containing spike time data\"",
")",
"parser",
".",
"add_argument",
"(",
"'spiketimeFiles'",
",",
"type",
"=",
"str",
",",
... | Parse command-line arguments. | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/plot/PlotSpikes.py#L56-L105 | train |
marrow/WebCore | web/server/stdlib.py | simple | def simple(application, host='127.0.0.1', port=8080):
"""Python-standard WSGI-HTTP server for testing purposes.
The additional work performed here is to match the default startup output of "waitress".
This is not a production quality interface and will be have badly under load.
"""
# Try to be handy as many ... | python | def simple(application, host='127.0.0.1', port=8080):
"""Python-standard WSGI-HTTP server for testing purposes.
The additional work performed here is to match the default startup output of "waitress".
This is not a production quality interface and will be have badly under load.
"""
# Try to be handy as many ... | [
"def",
"simple",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Try to be handy as many terminals allow clicking links.",
"print",
"(",
"\"serving on http://{0}:{1}\"",
".",
"format",
"(",
"host",
",",
"port",
")",
")",
... | Python-standard WSGI-HTTP server for testing purposes.
The additional work performed here is to match the default startup output of "waitress".
This is not a production quality interface and will be have badly under load. | [
"Python",
"-",
"standard",
"WSGI",
"-",
"HTTP",
"server",
"for",
"testing",
"purposes",
".",
"The",
"additional",
"work",
"performed",
"here",
"is",
"to",
"match",
"the",
"default",
"startup",
"output",
"of",
"waitress",
".",
"This",
"is",
"not",
"a",
"pro... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/stdlib.py#L23-L35 | train |
marrow/WebCore | web/server/stdlib.py | iiscgi | def iiscgi(application):
"""A specialized version of the reference WSGI-CGI server to adapt to Microsoft IIS quirks.
This is not a production quality interface and will behave badly under load.
"""
try:
from wsgiref.handlers import IISCGIHandler
except ImportError:
print("Python 3.2 or newer is required.")
... | python | def iiscgi(application):
"""A specialized version of the reference WSGI-CGI server to adapt to Microsoft IIS quirks.
This is not a production quality interface and will behave badly under load.
"""
try:
from wsgiref.handlers import IISCGIHandler
except ImportError:
print("Python 3.2 or newer is required.")
... | [
"def",
"iiscgi",
"(",
"application",
")",
":",
"try",
":",
"from",
"wsgiref",
".",
"handlers",
"import",
"IISCGIHandler",
"except",
"ImportError",
":",
"print",
"(",
"\"Python 3.2 or newer is required.\"",
")",
"if",
"not",
"__debug__",
":",
"warnings",
".",
"wa... | A specialized version of the reference WSGI-CGI server to adapt to Microsoft IIS quirks.
This is not a production quality interface and will behave badly under load. | [
"A",
"specialized",
"version",
"of",
"the",
"reference",
"WSGI",
"-",
"CGI",
"server",
"to",
"adapt",
"to",
"Microsoft",
"IIS",
"quirks",
".",
"This",
"is",
"not",
"a",
"production",
"quality",
"interface",
"and",
"will",
"behave",
"badly",
"under",
"load",
... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/stdlib.py#L53-L66 | train |
marrow/WebCore | web/server/fcgi.py | serve | def serve(application, host='127.0.0.1', port=8080, socket=None, **options):
"""Basic FastCGI support via flup.
This web server has many, many options. Please see the Flup project documentation for details.
"""
# Allow either on-disk socket (recommended) or TCP/IP socket use.
if not socket:
bindAddress = (ho... | python | def serve(application, host='127.0.0.1', port=8080, socket=None, **options):
"""Basic FastCGI support via flup.
This web server has many, many options. Please see the Flup project documentation for details.
"""
# Allow either on-disk socket (recommended) or TCP/IP socket use.
if not socket:
bindAddress = (ho... | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"socket",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"# Allow either on-disk socket (recommended) or TCP/IP socket use.",
"if",
"not",
"socket",
":",
"bindA... | Basic FastCGI support via flup.
This web server has many, many options. Please see the Flup project documentation for details. | [
"Basic",
"FastCGI",
"support",
"via",
"flup",
".",
"This",
"web",
"server",
"has",
"many",
"many",
"options",
".",
"Please",
"see",
"the",
"Flup",
"project",
"documentation",
"for",
"details",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/fcgi.py#L18-L31 | train |
bitlabstudio/django-subscribe | subscribe/forms.py | SubscriptionCreateForm._get_method_kwargs | def _get_method_kwargs(self):
"""
Helper method. Returns kwargs needed to filter the correct object.
Can also be used to create the correct object.
"""
method_kwargs = {
'user': self.user,
'content_type': self.ctype,
'object_id': self.content... | python | def _get_method_kwargs(self):
"""
Helper method. Returns kwargs needed to filter the correct object.
Can also be used to create the correct object.
"""
method_kwargs = {
'user': self.user,
'content_type': self.ctype,
'object_id': self.content... | [
"def",
"_get_method_kwargs",
"(",
"self",
")",
":",
"method_kwargs",
"=",
"{",
"'user'",
":",
"self",
".",
"user",
",",
"'content_type'",
":",
"self",
".",
"ctype",
",",
"'object_id'",
":",
"self",
".",
"content_object",
".",
"pk",
",",
"}",
"return",
"m... | Helper method. Returns kwargs needed to filter the correct object.
Can also be used to create the correct object. | [
"Helper",
"method",
".",
"Returns",
"kwargs",
"needed",
"to",
"filter",
"the",
"correct",
"object",
"."
] | 313de63fb4acda172e88b65c3327c793f98e8aa9 | https://github.com/bitlabstudio/django-subscribe/blob/313de63fb4acda172e88b65c3327c793f98e8aa9/subscribe/forms.py#L15-L27 | train |
bitlabstudio/django-subscribe | subscribe/forms.py | SubscriptionCreateForm.save | def save(self, *args, **kwargs):
"""Adds a subscription for the given user to the given object."""
method_kwargs = self._get_method_kwargs()
try:
subscription = Subscription.objects.get(**method_kwargs)
except Subscription.DoesNotExist:
subscription = Subscription... | python | def save(self, *args, **kwargs):
"""Adds a subscription for the given user to the given object."""
method_kwargs = self._get_method_kwargs()
try:
subscription = Subscription.objects.get(**method_kwargs)
except Subscription.DoesNotExist:
subscription = Subscription... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"method_kwargs",
"=",
"self",
".",
"_get_method_kwargs",
"(",
")",
"try",
":",
"subscription",
"=",
"Subscription",
".",
"objects",
".",
"get",
"(",
"*",
"*",
"method_kwar... | Adds a subscription for the given user to the given object. | [
"Adds",
"a",
"subscription",
"for",
"the",
"given",
"user",
"to",
"the",
"given",
"object",
"."
] | 313de63fb4acda172e88b65c3327c793f98e8aa9 | https://github.com/bitlabstudio/django-subscribe/blob/313de63fb4acda172e88b65c3327c793f98e8aa9/subscribe/forms.py#L29-L36 | train |
marrow/WebCore | web/ext/base.py | BaseExtension.prepare | def prepare(self, context):
"""Add the usual suspects to the context.
This adds `request`, `response`, and `path` to the `RequestContext` instance.
"""
if __debug__:
log.debug("Preparing request context.", extra=dict(request=id(context)))
# Bridge in WebOb `Request` and `Response` objects.
# Ext... | python | def prepare(self, context):
"""Add the usual suspects to the context.
This adds `request`, `response`, and `path` to the `RequestContext` instance.
"""
if __debug__:
log.debug("Preparing request context.", extra=dict(request=id(context)))
# Bridge in WebOb `Request` and `Response` objects.
# Ext... | [
"def",
"prepare",
"(",
"self",
",",
"context",
")",
":",
"if",
"__debug__",
":",
"log",
".",
"debug",
"(",
"\"Preparing request context.\"",
",",
"extra",
"=",
"dict",
"(",
"request",
"=",
"id",
"(",
"context",
")",
")",
")",
"# Bridge in WebOb `Request` and... | Add the usual suspects to the context.
This adds `request`, `response`, and `path` to the `RequestContext` instance. | [
"Add",
"the",
"usual",
"suspects",
"to",
"the",
"context",
".",
"This",
"adds",
"request",
"response",
"and",
"path",
"to",
"the",
"RequestContext",
"instance",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L83-L106 | train |
marrow/WebCore | web/ext/base.py | BaseExtension.dispatch | def dispatch(self, context, consumed, handler, is_endpoint):
"""Called as dispatch descends into a tier.
The base extension uses this to maintain the "current url".
"""
request = context.request
if __debug__:
log.debug("Handling dispatch event.", extra=dict(
request = id(context),
consum... | python | def dispatch(self, context, consumed, handler, is_endpoint):
"""Called as dispatch descends into a tier.
The base extension uses this to maintain the "current url".
"""
request = context.request
if __debug__:
log.debug("Handling dispatch event.", extra=dict(
request = id(context),
consum... | [
"def",
"dispatch",
"(",
"self",
",",
"context",
",",
"consumed",
",",
"handler",
",",
"is_endpoint",
")",
":",
"request",
"=",
"context",
".",
"request",
"if",
"__debug__",
":",
"log",
".",
"debug",
"(",
"\"Handling dispatch event.\"",
",",
"extra",
"=",
"... | Called as dispatch descends into a tier.
The base extension uses this to maintain the "current url". | [
"Called",
"as",
"dispatch",
"descends",
"into",
"a",
"tier",
".",
"The",
"base",
"extension",
"uses",
"this",
"to",
"maintain",
"the",
"current",
"url",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L108-L145 | train |
marrow/WebCore | web/ext/base.py | BaseExtension.render_none | def render_none(self, context, result):
"""Render empty responses."""
context.response.body = b''
del context.response.content_length
return True | python | def render_none(self, context, result):
"""Render empty responses."""
context.response.body = b''
del context.response.content_length
return True | [
"def",
"render_none",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"context",
".",
"response",
".",
"body",
"=",
"b''",
"del",
"context",
".",
"response",
".",
"content_length",
"return",
"True"
] | Render empty responses. | [
"Render",
"empty",
"responses",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L149-L153 | train |
marrow/WebCore | web/ext/base.py | BaseExtension.render_binary | def render_binary(self, context, result):
"""Return binary responses unmodified."""
context.response.app_iter = iter((result, )) # This wraps the binary string in a WSGI body iterable.
return True | python | def render_binary(self, context, result):
"""Return binary responses unmodified."""
context.response.app_iter = iter((result, )) # This wraps the binary string in a WSGI body iterable.
return True | [
"def",
"render_binary",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"context",
".",
"response",
".",
"app_iter",
"=",
"iter",
"(",
"(",
"result",
",",
")",
")",
"# This wraps the binary string in a WSGI body iterable.",
"return",
"True"
] | Return binary responses unmodified. | [
"Return",
"binary",
"responses",
"unmodified",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L160-L163 | train |
marrow/WebCore | web/ext/base.py | BaseExtension.render_file | def render_file(self, context, result):
"""Perform appropriate metadata wrangling for returned open file handles."""
if __debug__:
log.debug("Processing file-like object.", extra=dict(request=id(context), result=repr(result)))
response = context.response
response.conditional_response = True
modified ... | python | def render_file(self, context, result):
"""Perform appropriate metadata wrangling for returned open file handles."""
if __debug__:
log.debug("Processing file-like object.", extra=dict(request=id(context), result=repr(result)))
response = context.response
response.conditional_response = True
modified ... | [
"def",
"render_file",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"if",
"__debug__",
":",
"log",
".",
"debug",
"(",
"\"Processing file-like object.\"",
",",
"extra",
"=",
"dict",
"(",
"request",
"=",
"id",
"(",
"context",
")",
",",
"result",
"=... | Perform appropriate metadata wrangling for returned open file handles. | [
"Perform",
"appropriate",
"metadata",
"wrangling",
"for",
"returned",
"open",
"file",
"handles",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L170-L192 | train |
marrow/WebCore | web/ext/base.py | BaseExtension.render_generator | def render_generator(self, context, result):
"""Attempt to serve generator responses through stream encoding.
This allows for direct use of cinje template functions, which are generators, as returned views.
"""
context.response.encoding = 'utf8'
context.response.app_iter = (
(i.encode('utf8') if isinst... | python | def render_generator(self, context, result):
"""Attempt to serve generator responses through stream encoding.
This allows for direct use of cinje template functions, which are generators, as returned views.
"""
context.response.encoding = 'utf8'
context.response.app_iter = (
(i.encode('utf8') if isinst... | [
"def",
"render_generator",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"context",
".",
"response",
".",
"encoding",
"=",
"'utf8'",
"context",
".",
"response",
".",
"app_iter",
"=",
"(",
"(",
"i",
".",
"encode",
"(",
"'utf8'",
")",
"if",
"isin... | Attempt to serve generator responses through stream encoding.
This allows for direct use of cinje template functions, which are generators, as returned views. | [
"Attempt",
"to",
"serve",
"generator",
"responses",
"through",
"stream",
"encoding",
".",
"This",
"allows",
"for",
"direct",
"use",
"of",
"cinje",
"template",
"functions",
"which",
"are",
"generators",
"as",
"returned",
"views",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/base.py#L194-L204 | train |
marrow/WebCore | web/server/cherrypy_.py | serve | def serve(application, host='127.0.0.1', port=8080):
"""CherryPy-based WSGI-HTTP server."""
# Instantiate the server with our configuration and application.
server = CherryPyWSGIServer((host, int(port)), application, server_name=host)
# Try to be handy as many terminals allow clicking links.
print("serving on ... | python | def serve(application, host='127.0.0.1', port=8080):
"""CherryPy-based WSGI-HTTP server."""
# Instantiate the server with our configuration and application.
server = CherryPyWSGIServer((host, int(port)), application, server_name=host)
# Try to be handy as many terminals allow clicking links.
print("serving on ... | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Instantiate the server with our configuration and application.",
"server",
"=",
"CherryPyWSGIServer",
"(",
"(",
"host",
",",
"int",
"(",
"port",
")",
")",
... | CherryPy-based WSGI-HTTP server. | [
"CherryPy",
"-",
"based",
"WSGI",
"-",
"HTTP",
"server",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/cherrypy_.py#L14-L27 | train |
broadinstitute/xtermcolor | xtermcolor/ColorMap.py | TerminalColorMap.colorize | def colorize(self, string, rgb=None, ansi=None, bg=None, ansi_bg=None):
'''Returns the colored string'''
if not isinstance(string, str):
string = str(string)
if rgb is None and ansi is None:
raise TerminalColorMapException(
'colorize: must specify one name... | python | def colorize(self, string, rgb=None, ansi=None, bg=None, ansi_bg=None):
'''Returns the colored string'''
if not isinstance(string, str):
string = str(string)
if rgb is None and ansi is None:
raise TerminalColorMapException(
'colorize: must specify one name... | [
"def",
"colorize",
"(",
"self",
",",
"string",
",",
"rgb",
"=",
"None",
",",
"ansi",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"ansi_bg",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"string",
",",
"str",
")",
":",
"string",
"=",
"str",... | Returns the colored string | [
"Returns",
"the",
"colored",
"string"
] | 2615100979eb59744597c9d01e6fd1b711b311e1 | https://github.com/broadinstitute/xtermcolor/blob/2615100979eb59744597c9d01e6fd1b711b311e1/xtermcolor/ColorMap.py#L27-L54 | train |
marrow/WebCore | web/ext/serialize.py | SerializationExtension.render_serialization | def render_serialization(self, context, result):
"""Render serialized responses."""
resp = context.response
serial = context.serialize
match = context.request.accept.best_match(serial.types, default_match=self.default)
result = serial[match](result)
if isinstance(result, str):
result = result.decod... | python | def render_serialization(self, context, result):
"""Render serialized responses."""
resp = context.response
serial = context.serialize
match = context.request.accept.best_match(serial.types, default_match=self.default)
result = serial[match](result)
if isinstance(result, str):
result = result.decod... | [
"def",
"render_serialization",
"(",
"self",
",",
"context",
",",
"result",
")",
":",
"resp",
"=",
"context",
".",
"response",
"serial",
"=",
"context",
".",
"serialize",
"match",
"=",
"context",
".",
"request",
".",
"accept",
".",
"best_match",
"(",
"seria... | Render serialized responses. | [
"Render",
"serialized",
"responses",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/serialize.py#L91-L106 | train |
marrow/WebCore | web/server/eventlet_.py | serve | def serve(application, host='127.0.0.1', port=8080):
"""Eventlet-based WSGI-HTTP server.
For a more fully-featured Eventlet-capable interface, see also [Spawning](http://pypi.python.org/pypi/Spawning/).
"""
# Instantiate the server with a bound port and with our application.
server(listen(host, int(port)), app... | python | def serve(application, host='127.0.0.1', port=8080):
"""Eventlet-based WSGI-HTTP server.
For a more fully-featured Eventlet-capable interface, see also [Spawning](http://pypi.python.org/pypi/Spawning/).
"""
# Instantiate the server with a bound port and with our application.
server(listen(host, int(port)), app... | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
")",
":",
"# Instantiate the server with a bound port and with our application.",
"server",
"(",
"listen",
"(",
"host",
",",
"int",
"(",
"port",
")",
")",
",",
"applic... | Eventlet-based WSGI-HTTP server.
For a more fully-featured Eventlet-capable interface, see also [Spawning](http://pypi.python.org/pypi/Spawning/). | [
"Eventlet",
"-",
"based",
"WSGI",
"-",
"HTTP",
"server",
".",
"For",
"a",
"more",
"fully",
"-",
"featured",
"Eventlet",
"-",
"capable",
"interface",
"see",
"also",
"[",
"Spawning",
"]",
"(",
"http",
":",
"//",
"pypi",
".",
"python",
".",
"org",
"/",
... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/eventlet_.py#L15-L22 | train |
NeuroML/pyNeuroML | examples/component_evaluation.py | main | def main(args=None):
"""Main"""
vs = [(v-100)*0.001 for v in range(200)]
for f in ['IM.channel.nml','Kd.channel.nml']:
nml_doc = pynml.read_neuroml2_file(f)
for ct in nml_doc.ComponentType:
ys = []
for v in vs:
req_variables = {'v':'%sV'%v,... | python | def main(args=None):
"""Main"""
vs = [(v-100)*0.001 for v in range(200)]
for f in ['IM.channel.nml','Kd.channel.nml']:
nml_doc = pynml.read_neuroml2_file(f)
for ct in nml_doc.ComponentType:
ys = []
for v in vs:
req_variables = {'v':'%sV'%v,... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"vs",
"=",
"[",
"(",
"v",
"-",
"100",
")",
"*",
"0.001",
"for",
"v",
"in",
"range",
"(",
"200",
")",
"]",
"for",
"f",
"in",
"[",
"'IM.channel.nml'",
",",
"'Kd.channel.nml'",
"]",
":",
"nml_doc",
... | Main | [
"Main"
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/examples/component_evaluation.py#L5-L33 | train |
NeuroML/pyNeuroML | pyneuroml/analysis/NML2ChannelAnalysis.py | process_args | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to generate a LEMS "
"file to analyse the behaviour of channels in "
"NeuroML 2"))
parser.ad... | python | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to generate a LEMS "
"file to analyse the behaviour of channels in "
"NeuroML 2"))
parser.ad... | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"\"A script which can be run to generate a LEMS \"",
"\"file to analyse the behaviour of channels in \"",
"\"NeuroML 2\"",
")",
")",
"parser",
".",
"add_arg... | Parse command-line arguments. | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/analysis/NML2ChannelAnalysis.py#L58-L185 | train |
NeuroML/pyNeuroML | pyneuroml/analysis/NML2ChannelAnalysis.py | plot_iv_curve | def plot_iv_curve(a, hold_v, i, *plt_args, **plt_kwargs):
"""A single IV curve"""
grid = plt_kwargs.pop('grid',True)
same_fig = plt_kwargs.pop('same_fig',False)
if not len(plt_args):
plt_args = ('ko-',)
if 'label' not in plt_kwargs:
plt_kwargs['label'] = 'Current'
if not sa... | python | def plot_iv_curve(a, hold_v, i, *plt_args, **plt_kwargs):
"""A single IV curve"""
grid = plt_kwargs.pop('grid',True)
same_fig = plt_kwargs.pop('same_fig',False)
if not len(plt_args):
plt_args = ('ko-',)
if 'label' not in plt_kwargs:
plt_kwargs['label'] = 'Current'
if not sa... | [
"def",
"plot_iv_curve",
"(",
"a",
",",
"hold_v",
",",
"i",
",",
"*",
"plt_args",
",",
"*",
"*",
"plt_kwargs",
")",
":",
"grid",
"=",
"plt_kwargs",
".",
"pop",
"(",
"'grid'",
",",
"True",
")",
"same_fig",
"=",
"plt_kwargs",
".",
"pop",
"(",
"'same_fig... | A single IV curve | [
"A",
"single",
"IV",
"curve"
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/analysis/NML2ChannelAnalysis.py#L581-L594 | train |
marrow/WebCore | example/stream.py | root | def root(context):
"""Multipart AJAX request example.
See: http://test.getify.com/mpAjax/description.html
"""
response = context.response
parts = []
for i in range(12):
for j in range(12):
parts.append(executor.submit(mul, i, j))
def stream(parts, timeout=None):
try:
for future in as_complete... | python | def root(context):
"""Multipart AJAX request example.
See: http://test.getify.com/mpAjax/description.html
"""
response = context.response
parts = []
for i in range(12):
for j in range(12):
parts.append(executor.submit(mul, i, j))
def stream(parts, timeout=None):
try:
for future in as_complete... | [
"def",
"root",
"(",
"context",
")",
":",
"response",
"=",
"context",
".",
"response",
"parts",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"12",
")",
":",
"for",
"j",
"in",
"range",
"(",
"12",
")",
":",
"parts",
".",
"append",
"(",
"executor",... | Multipart AJAX request example.
See: http://test.getify.com/mpAjax/description.html | [
"Multipart",
"AJAX",
"request",
"example",
".",
"See",
":",
"http",
":",
"//",
"test",
".",
"getify",
".",
"com",
"/",
"mpAjax",
"/",
"description",
".",
"html"
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/example/stream.py#L16-L49 | train |
contraslash/django-crud-generator | django_crud_generator/django_crud_generator.py | render_template_with_args_in_file | def render_template_with_args_in_file(file, template_file_name, **kwargs):
"""
Get a file and render the content of the template_file_name with kwargs in a file
:param file: A File Stream to write
:param template_file_name: path to route with template name
:param **kwargs: Args to be rendered in tem... | python | def render_template_with_args_in_file(file, template_file_name, **kwargs):
"""
Get a file and render the content of the template_file_name with kwargs in a file
:param file: A File Stream to write
:param template_file_name: path to route with template name
:param **kwargs: Args to be rendered in tem... | [
"def",
"render_template_with_args_in_file",
"(",
"file",
",",
"template_file_name",
",",
"*",
"*",
"kwargs",
")",
":",
"template_file_content",
"=",
"\"\"",
".",
"join",
"(",
"codecs",
".",
"open",
"(",
"template_file_name",
",",
"encoding",
"=",
"'UTF-8'",
")",... | Get a file and render the content of the template_file_name with kwargs in a file
:param file: A File Stream to write
:param template_file_name: path to route with template name
:param **kwargs: Args to be rendered in template | [
"Get",
"a",
"file",
"and",
"render",
"the",
"content",
"of",
"the",
"template_file_name",
"with",
"kwargs",
"in",
"a",
"file",
":",
"param",
"file",
":",
"A",
"File",
"Stream",
"to",
"write",
":",
"param",
"template_file_name",
":",
"path",
"to",
"route",
... | 9080a227291a36cf0d93b49d20601e55a616da1e | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L20-L34 | train |
contraslash/django-crud-generator | django_crud_generator/django_crud_generator.py | create_or_open | def create_or_open(file_name, initial_template_file_name, args):
"""
Creates a file or open the file with file_name name
:param file_name: String with a filename
:param initial_template_file_name: String with path to initial template
:param args: from console to determine path to save the files
... | python | def create_or_open(file_name, initial_template_file_name, args):
"""
Creates a file or open the file with file_name name
:param file_name: String with a filename
:param initial_template_file_name: String with path to initial template
:param args: from console to determine path to save the files
... | [
"def",
"create_or_open",
"(",
"file_name",
",",
"initial_template_file_name",
",",
"args",
")",
":",
"file",
"=",
"None",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"args",
"[",
"'django_application_folder'",
"... | Creates a file or open the file with file_name name
:param file_name: String with a filename
:param initial_template_file_name: String with path to initial template
:param args: from console to determine path to save the files | [
"Creates",
"a",
"file",
"or",
"open",
"the",
"file",
"with",
"file_name",
"name",
":",
"param",
"file_name",
":",
"String",
"with",
"a",
"filename",
":",
"param",
"initial_template_file_name",
":",
"String",
"with",
"path",
"to",
"initial",
"template",
":",
... | 9080a227291a36cf0d93b49d20601e55a616da1e | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L37-L74 | train |
contraslash/django-crud-generator | django_crud_generator/django_crud_generator.py | generic_insert_module | def generic_insert_module(module_name, args, **kwargs):
"""
In general we have a initial template and then insert new data, so we dont repeat the schema for each module
:param module_name: String with module name
:paran **kwargs: Args to be rendered in template
"""
file = create_or_open(
... | python | def generic_insert_module(module_name, args, **kwargs):
"""
In general we have a initial template and then insert new data, so we dont repeat the schema for each module
:param module_name: String with module name
:paran **kwargs: Args to be rendered in template
"""
file = create_or_open(
... | [
"def",
"generic_insert_module",
"(",
"module_name",
",",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"file",
"=",
"create_or_open",
"(",
"'{}.py'",
".",
"format",
"(",
"module_name",
")",
",",
"os",
".",
"path",
".",
"join",
"(",
"BASE_TEMPLATES_DIR",
",",
... | In general we have a initial template and then insert new data, so we dont repeat the schema for each module
:param module_name: String with module name
:paran **kwargs: Args to be rendered in template | [
"In",
"general",
"we",
"have",
"a",
"initial",
"template",
"and",
"then",
"insert",
"new",
"data",
"so",
"we",
"dont",
"repeat",
"the",
"schema",
"for",
"each",
"module",
":",
"param",
"module_name",
":",
"String",
"with",
"module",
"name",
":",
"paran",
... | 9080a227291a36cf0d93b49d20601e55a616da1e | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L77-L100 | train |
contraslash/django-crud-generator | django_crud_generator/django_crud_generator.py | sanity_check | def sanity_check(args):
"""
Verify if the work folder is a django app.
A valid django app always must have a models.py file
:return: None
"""
if not os.path.isfile(
os.path.join(
args['django_application_folder'],
'models.py'
)
):
print("django... | python | def sanity_check(args):
"""
Verify if the work folder is a django app.
A valid django app always must have a models.py file
:return: None
"""
if not os.path.isfile(
os.path.join(
args['django_application_folder'],
'models.py'
)
):
print("django... | [
"def",
"sanity_check",
"(",
"args",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"args",
"[",
"'django_application_folder'",
"]",
",",
"'models.py'",
")",
")",
":",
"print",
"(",
"\"django_application... | Verify if the work folder is a django app.
A valid django app always must have a models.py file
:return: None | [
"Verify",
"if",
"the",
"work",
"folder",
"is",
"a",
"django",
"app",
".",
"A",
"valid",
"django",
"app",
"always",
"must",
"have",
"a",
"models",
".",
"py",
"file",
":",
"return",
":",
"None"
] | 9080a227291a36cf0d93b49d20601e55a616da1e | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L103-L116 | train |
contraslash/django-crud-generator | django_crud_generator/django_crud_generator.py | generic_insert_with_folder | def generic_insert_with_folder(folder_name, file_name, template_name, args):
"""
In general if we need to put a file on a folder, we use this method
"""
# First we make sure views are a package instead a file
if not os.path.isdir(
os.path.join(
args['django_application_folder'],
... | python | def generic_insert_with_folder(folder_name, file_name, template_name, args):
"""
In general if we need to put a file on a folder, we use this method
"""
# First we make sure views are a package instead a file
if not os.path.isdir(
os.path.join(
args['django_application_folder'],
... | [
"def",
"generic_insert_with_folder",
"(",
"folder_name",
",",
"file_name",
",",
"template_name",
",",
"args",
")",
":",
"# First we make sure views are a package instead a file",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"join",
"(... | In general if we need to put a file on a folder, we use this method | [
"In",
"general",
"if",
"we",
"need",
"to",
"put",
"a",
"file",
"on",
"a",
"folder",
"we",
"use",
"this",
"method"
] | 9080a227291a36cf0d93b49d20601e55a616da1e | https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L119-L160 | train |
marrow/WebCore | web/server/waitress_.py | serve | def serve(application, host='127.0.0.1', port=8080, threads=4, **kw):
"""The recommended development HTTP server.
Note that this server performs additional buffering and will not honour chunked encoding breaks.
"""
# Bind and start the server; this is a blocking process.
serve_(application, host=host, port=int... | python | def serve(application, host='127.0.0.1', port=8080, threads=4, **kw):
"""The recommended development HTTP server.
Note that this server performs additional buffering and will not honour chunked encoding breaks.
"""
# Bind and start the server; this is a blocking process.
serve_(application, host=host, port=int... | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"threads",
"=",
"4",
",",
"*",
"*",
"kw",
")",
":",
"# Bind and start the server; this is a blocking process.",
"serve_",
"(",
"application",
",",
"host",
"=",
... | The recommended development HTTP server.
Note that this server performs additional buffering and will not honour chunked encoding breaks. | [
"The",
"recommended",
"development",
"HTTP",
"server",
".",
"Note",
"that",
"this",
"server",
"performs",
"additional",
"buffering",
"and",
"will",
"not",
"honour",
"chunked",
"encoding",
"breaks",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/waitress_.py#L18-L25 | train |
NeuroML/pyNeuroML | pyneuroml/tune/NeuroMLSimulation.py | NeuroMLSimulation.show | def show(self):
"""
Plot the result of the simulation once it's been intialized
"""
from matplotlib import pyplot as plt
if self.already_run:
for ref in self.volts.keys():
plt.plot(self.t, self.volts[ref], label=ref)
plt... | python | def show(self):
"""
Plot the result of the simulation once it's been intialized
"""
from matplotlib import pyplot as plt
if self.already_run:
for ref in self.volts.keys():
plt.plot(self.t, self.volts[ref], label=ref)
plt... | [
"def",
"show",
"(",
"self",
")",
":",
"from",
"matplotlib",
"import",
"pyplot",
"as",
"plt",
"if",
"self",
".",
"already_run",
":",
"for",
"ref",
"in",
"self",
".",
"volts",
".",
"keys",
"(",
")",
":",
"plt",
".",
"plot",
"(",
"self",
".",
"t",
"... | Plot the result of the simulation once it's been intialized | [
"Plot",
"the",
"result",
"of",
"the",
"simulation",
"once",
"it",
"s",
"been",
"intialized"
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/tune/NeuroMLSimulation.py#L58-L77 | train |
marrow/WebCore | example/annotation.py | Root.mul | def mul(self, a: int = None, b: int = None) -> 'json':
"""Multiply two values together and return the result via JSON.
Python 3 function annotations are used to ensure that the arguments are integers. This requires the
functionality of `web.ext.annotation:AnnotationExtension`.
There are several ways to ex... | python | def mul(self, a: int = None, b: int = None) -> 'json':
"""Multiply two values together and return the result via JSON.
Python 3 function annotations are used to ensure that the arguments are integers. This requires the
functionality of `web.ext.annotation:AnnotationExtension`.
There are several ways to ex... | [
"def",
"mul",
"(",
"self",
",",
"a",
":",
"int",
"=",
"None",
",",
"b",
":",
"int",
"=",
"None",
")",
"->",
"'json'",
":",
"if",
"not",
"a",
"or",
"not",
"b",
":",
"return",
"dict",
"(",
"message",
"=",
"\"Pass arguments a and b to multiply them togeth... | Multiply two values together and return the result via JSON.
Python 3 function annotations are used to ensure that the arguments are integers. This requires the
functionality of `web.ext.annotation:AnnotationExtension`.
There are several ways to execute this method:
* POST http://localhost:8080/mul
*... | [
"Multiply",
"two",
"values",
"together",
"and",
"return",
"the",
"result",
"via",
"JSON",
".",
"Python",
"3",
"function",
"annotations",
"are",
"used",
"to",
"ensure",
"that",
"the",
"arguments",
"are",
"integers",
".",
"This",
"requires",
"the",
"functionalit... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/example/annotation.py#L15-L42 | train |
broadinstitute/xtermcolor | xtermcolor/__init__.py | colorize | def colorize(string, rgb=None, ansi=None, bg=None, ansi_bg=None, fd=1):
'''Returns the colored string to print on the terminal.
This function detects the terminal type and if it is supported and the
output is not going to a pipe or a file, then it will return the colored
string, otherwise it will retur... | python | def colorize(string, rgb=None, ansi=None, bg=None, ansi_bg=None, fd=1):
'''Returns the colored string to print on the terminal.
This function detects the terminal type and if it is supported and the
output is not going to a pipe or a file, then it will return the colored
string, otherwise it will retur... | [
"def",
"colorize",
"(",
"string",
",",
"rgb",
"=",
"None",
",",
"ansi",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"ansi_bg",
"=",
"None",
",",
"fd",
"=",
"1",
")",
":",
"#Reinitializes if fd used is different",
"if",
"colorize",
".",
"fd",
"!=",
"fd",
... | Returns the colored string to print on the terminal.
This function detects the terminal type and if it is supported and the
output is not going to a pipe or a file, then it will return the colored
string, otherwise it will return the string without modifications.
string = the string to print. Only acc... | [
"Returns",
"the",
"colored",
"string",
"to",
"print",
"on",
"the",
"terminal",
"."
] | 2615100979eb59744597c9d01e6fd1b711b311e1 | https://github.com/broadinstitute/xtermcolor/blob/2615100979eb59744597c9d01e6fd1b711b311e1/xtermcolor/__init__.py#L6-L45 | train |
marrow/WebCore | web/ext/annotation.py | AnnotationExtension.mutate | def mutate(self, context, handler, args, kw):
"""Inspect and potentially mutate the given handler's arguments.
The args list and kw dictionary may be freely modified, though invalid arguments to the handler will fail.
"""
def cast(arg, val):
if arg not in annotations:
return
cast = annotations[... | python | def mutate(self, context, handler, args, kw):
"""Inspect and potentially mutate the given handler's arguments.
The args list and kw dictionary may be freely modified, though invalid arguments to the handler will fail.
"""
def cast(arg, val):
if arg not in annotations:
return
cast = annotations[... | [
"def",
"mutate",
"(",
"self",
",",
"context",
",",
"handler",
",",
"args",
",",
"kw",
")",
":",
"def",
"cast",
"(",
"arg",
",",
"val",
")",
":",
"if",
"arg",
"not",
"in",
"annotations",
":",
"return",
"cast",
"=",
"annotations",
"[",
"key",
"]",
... | Inspect and potentially mutate the given handler's arguments.
The args list and kw dictionary may be freely modified, though invalid arguments to the handler will fail. | [
"Inspect",
"and",
"potentially",
"mutate",
"the",
"given",
"handler",
"s",
"arguments",
".",
"The",
"args",
"list",
"and",
"kw",
"dictionary",
"may",
"be",
"freely",
"modified",
"though",
"invalid",
"arguments",
"to",
"the",
"handler",
"will",
"fail",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/annotation.py#L48-L87 | train |
marrow/WebCore | web/ext/annotation.py | AnnotationExtension.transform | def transform(self, context, handler, result):
"""Transform the value returned by the controller endpoint.
This extension transforms returned values if the endpoint has a return type annotation.
"""
handler = handler.__func__ if hasattr(handler, '__func__') else handler
annotation = getattr(handler, '__ann... | python | def transform(self, context, handler, result):
"""Transform the value returned by the controller endpoint.
This extension transforms returned values if the endpoint has a return type annotation.
"""
handler = handler.__func__ if hasattr(handler, '__func__') else handler
annotation = getattr(handler, '__ann... | [
"def",
"transform",
"(",
"self",
",",
"context",
",",
"handler",
",",
"result",
")",
":",
"handler",
"=",
"handler",
".",
"__func__",
"if",
"hasattr",
"(",
"handler",
",",
"'__func__'",
")",
"else",
"handler",
"annotation",
"=",
"getattr",
"(",
"handler",
... | Transform the value returned by the controller endpoint.
This extension transforms returned values if the endpoint has a return type annotation. | [
"Transform",
"the",
"value",
"returned",
"by",
"the",
"controller",
"endpoint",
".",
"This",
"extension",
"transforms",
"returned",
"values",
"if",
"the",
"endpoint",
"has",
"a",
"return",
"type",
"annotation",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/annotation.py#L89-L100 | train |
NeuroML/pyNeuroML | pyneuroml/tune/NeuroMLTuner.py | process_args | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to tune a NeuroML 2 model against a number of target properties. Work in progress!"))
parser.add_argument('prefix',
... | python | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(
description=("A script which can be run to tune a NeuroML 2 model against a number of target properties. Work in progress!"))
parser.add_argument('prefix',
... | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"\"A script which can be run to tune a NeuroML 2 model against a number of target properties. Work in progress!\"",
")",
")",
"parser",
".",
"add_argument",
"... | Parse command-line arguments. | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/tune/NeuroMLTuner.py#L52-L209 | train |
NeuroML/pyNeuroML | pyneuroml/povray/MakeMovie.py | process_args | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for overlaying POVRay files generated from NeuroML by NeuroML1ToPOVRay.py with cell activity (e.g. as generated from a neuroConstruct simulation)")
parser.add_argument('prefix',
... | python | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for overlaying POVRay files generated from NeuroML by NeuroML1ToPOVRay.py with cell activity (e.g. as generated from a neuroConstruct simulation)")
parser.add_argument('prefix',
... | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"A file for overlaying POVRay files generated from NeuroML by NeuroML1ToPOVRay.py with cell activity (e.g. as generated from a neuroConstruct simulation)\"",
")",
"parser"... | Parse command-line arguments. | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/povray/MakeMovie.py#L27-L92 | train |
marrow/WebCore | web/server/tornado_.py | serve | def serve(application, host='127.0.0.1', port=8080, **options):
"""Tornado's HTTPServer.
This is a high quality asynchronous server with many options. For details, please visit:
http://www.tornadoweb.org/en/stable/httpserver.html#http-server
"""
# Wrap our our WSGI application (potentially stack) in a Torn... | python | def serve(application, host='127.0.0.1', port=8080, **options):
"""Tornado's HTTPServer.
This is a high quality asynchronous server with many options. For details, please visit:
http://www.tornadoweb.org/en/stable/httpserver.html#http-server
"""
# Wrap our our WSGI application (potentially stack) in a Torn... | [
"def",
"serve",
"(",
"application",
",",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"8080",
",",
"*",
"*",
"options",
")",
":",
"# Wrap our our WSGI application (potentially stack) in a Tornado adapter.",
"container",
"=",
"tornado",
".",
"wsgi",
".",
"WSGIContai... | Tornado's HTTPServer.
This is a high quality asynchronous server with many options. For details, please visit:
http://www.tornadoweb.org/en/stable/httpserver.html#http-server | [
"Tornado",
"s",
"HTTPServer",
".",
"This",
"is",
"a",
"high",
"quality",
"asynchronous",
"server",
"with",
"many",
"options",
".",
"For",
"details",
"please",
"visit",
":",
"http",
":",
"//",
"www",
".",
"tornadoweb",
".",
"org",
"/",
"en",
"/",
"stable"... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/server/tornado_.py#L18-L34 | train |
NeuroML/pyNeuroML | pyneuroml/pynml.py | parse_arguments | def parse_arguments():
"""Parse command line arguments"""
import argparse
parser = argparse.ArgumentParser(
description=('pyNeuroML v%s: Python utilities for NeuroML2' % __version__
+ "\n libNeuroML v%s"%(neuroml.__version__)
+ "\n jNe... | python | def parse_arguments():
"""Parse command line arguments"""
import argparse
parser = argparse.ArgumentParser(
description=('pyNeuroML v%s: Python utilities for NeuroML2' % __version__
+ "\n libNeuroML v%s"%(neuroml.__version__)
+ "\n jNe... | [
"def",
"parse_arguments",
"(",
")",
":",
"import",
"argparse",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"'pyNeuroML v%s: Python utilities for NeuroML2'",
"%",
"__version__",
"+",
"\"\\n libNeuroML v%s\"",
"%",
"(",
"neuroml",
... | Parse command line arguments | [
"Parse",
"command",
"line",
"arguments"
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L43-L245 | train |
NeuroML/pyNeuroML | pyneuroml/pynml.py | quick_summary | def quick_summary(nml2_doc):
'''
Or better just use nml2_doc.summary(show_includes=False)
'''
info = 'Contents of NeuroML 2 document: %s\n'%nml2_doc.id
membs = inspect.getmembers(nml2_doc)
for memb in membs:
if isinstance(memb[1], list) and len(memb[1])>0 \
and not... | python | def quick_summary(nml2_doc):
'''
Or better just use nml2_doc.summary(show_includes=False)
'''
info = 'Contents of NeuroML 2 document: %s\n'%nml2_doc.id
membs = inspect.getmembers(nml2_doc)
for memb in membs:
if isinstance(memb[1], list) and len(memb[1])>0 \
and not... | [
"def",
"quick_summary",
"(",
"nml2_doc",
")",
":",
"info",
"=",
"'Contents of NeuroML 2 document: %s\\n'",
"%",
"nml2_doc",
".",
"id",
"membs",
"=",
"inspect",
".",
"getmembers",
"(",
"nml2_doc",
")",
"for",
"memb",
"in",
"membs",
":",
"if",
"isinstance",
"(",... | Or better just use nml2_doc.summary(show_includes=False) | [
"Or",
"better",
"just",
"use",
"nml2_doc",
".",
"summary",
"(",
"show_includes",
"=",
"False",
")"
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L419-L441 | train |
NeuroML/pyNeuroML | pyneuroml/pynml.py | execute_command_in_dir | def execute_command_in_dir(command, directory, verbose=DEFAULTS['v'],
prefix="Output: ", env=None):
"""Execute a command in specific working directory"""
if os.name == 'nt':
directory = os.path.normpath(directory)
print_comment("Executing: (%s) in direc... | python | def execute_command_in_dir(command, directory, verbose=DEFAULTS['v'],
prefix="Output: ", env=None):
"""Execute a command in specific working directory"""
if os.name == 'nt':
directory = os.path.normpath(directory)
print_comment("Executing: (%s) in direc... | [
"def",
"execute_command_in_dir",
"(",
"command",
",",
"directory",
",",
"verbose",
"=",
"DEFAULTS",
"[",
"'v'",
"]",
",",
"prefix",
"=",
"\"Output: \"",
",",
"env",
"=",
"None",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"directory",
"=",
"o... | Execute a command in specific working directory | [
"Execute",
"a",
"command",
"in",
"specific",
"working",
"directory"
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L1181-L1239 | train |
NeuroML/pyNeuroML | pyneuroml/pynml.py | evaluate_component | def evaluate_component(comp_type, req_variables={}, parameter_values={}):
print_comment('Evaluating %s with req:%s; params:%s'%(comp_type.name,req_variables,parameter_values))
exec_str = ''
return_vals = {}
from math import exp
for p in parameter_values:
exec_str+='%s = %s\n'%(p, get_va... | python | def evaluate_component(comp_type, req_variables={}, parameter_values={}):
print_comment('Evaluating %s with req:%s; params:%s'%(comp_type.name,req_variables,parameter_values))
exec_str = ''
return_vals = {}
from math import exp
for p in parameter_values:
exec_str+='%s = %s\n'%(p, get_va... | [
"def",
"evaluate_component",
"(",
"comp_type",
",",
"req_variables",
"=",
"{",
"}",
",",
"parameter_values",
"=",
"{",
"}",
")",
":",
"print_comment",
"(",
"'Evaluating %s with req:%s; params:%s'",
"%",
"(",
"comp_type",
".",
"name",
",",
"req_variables",
",",
"... | print_comment_v(exec_str) | [
"print_comment_v",
"(",
"exec_str",
")"
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/pynml.py#L1431-L1462 | train |
marrow/WebCore | web/ext/analytics.py | AnalyticsExtension.after | def after(self, context, exc=None):
"""Executed after dispatch has returned and the response populated, prior to anything being sent to the client."""
duration = context._duration = round((time.time() - context._start_time) * 1000) # Convert to ms.
delta = unicode(duration)
# Default response augmentatio... | python | def after(self, context, exc=None):
"""Executed after dispatch has returned and the response populated, prior to anything being sent to the client."""
duration = context._duration = round((time.time() - context._start_time) * 1000) # Convert to ms.
delta = unicode(duration)
# Default response augmentatio... | [
"def",
"after",
"(",
"self",
",",
"context",
",",
"exc",
"=",
"None",
")",
":",
"duration",
"=",
"context",
".",
"_duration",
"=",
"round",
"(",
"(",
"time",
".",
"time",
"(",
")",
"-",
"context",
".",
"_start_time",
")",
"*",
"1000",
")",
"# Conve... | Executed after dispatch has returned and the response populated, prior to anything being sent to the client. | [
"Executed",
"after",
"dispatch",
"has",
"returned",
"and",
"the",
"response",
"populated",
"prior",
"to",
"anything",
"being",
"sent",
"to",
"the",
"client",
"."
] | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/analytics.py#L55-L69 | train |
marrow/WebCore | web/ext/args.py | ArgumentExtension._process_flat_kwargs | def _process_flat_kwargs(source, kwargs):
"""Apply a flat namespace transformation to recreate (in some respects) a rich structure.
This applies several transformations, which may be nested:
`foo` (singular): define a simple value named `foo`
`foo` (repeated): define a simple value for placement in an arr... | python | def _process_flat_kwargs(source, kwargs):
"""Apply a flat namespace transformation to recreate (in some respects) a rich structure.
This applies several transformations, which may be nested:
`foo` (singular): define a simple value named `foo`
`foo` (repeated): define a simple value for placement in an arr... | [
"def",
"_process_flat_kwargs",
"(",
"source",
",",
"kwargs",
")",
":",
"ordered_arrays",
"=",
"[",
"]",
"# Process arguments one at a time and apply them to the kwargs passed in.",
"for",
"name",
",",
"value",
"in",
"source",
".",
"items",
"(",
")",
":",
"container",
... | Apply a flat namespace transformation to recreate (in some respects) a rich structure.
This applies several transformations, which may be nested:
`foo` (singular): define a simple value named `foo`
`foo` (repeated): define a simple value for placement in an array named `foo`
`foo[]`: define a simple value... | [
"Apply",
"a",
"flat",
"namespace",
"transformation",
"to",
"recreate",
"(",
"in",
"some",
"respects",
")",
"a",
"rich",
"structure",
".",
"This",
"applies",
"several",
"transformations",
"which",
"may",
"be",
"nested",
":",
"foo",
"(",
"singular",
")",
":",
... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/ext/args.py#L22-L87 | train |
NeuroML/pyNeuroML | pyneuroml/povray/NeuroML2ToPOVRay.py | process_args | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for converting NeuroML v2 files into POVRay files for 3D rendering")
parser.add_argument('neuroml_file', type=str, metavar='<NeuroML file>',
help='NeuroML ... | python | def process_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description="A file for converting NeuroML v2 files into POVRay files for 3D rendering")
parser.add_argument('neuroml_file', type=str, metavar='<NeuroML file>',
help='NeuroML ... | [
"def",
"process_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"A file for converting NeuroML v2 files into POVRay files for 3D rendering\"",
")",
"parser",
".",
"add_argument",
"(",
"'neuroml_file'",
",",
"type",
"=",
... | Parse command-line arguments. | [
"Parse",
"command",
"-",
"line",
"arguments",
"."
] | aeba2e3040b360bb26556f643cccbfb3dac3b8fb | https://github.com/NeuroML/pyNeuroML/blob/aeba2e3040b360bb26556f643cccbfb3dac3b8fb/pyneuroml/povray/NeuroML2ToPOVRay.py#L27-L143 | train |
marrow/WebCore | web/core/application.py | Application._configure | def _configure(self, config):
"""Prepare the incoming configuration and ensure certain expected values are present.
For example, this ensures BaseExtension is included in the extension list, and populates the logging config.
"""
config = config or dict()
# We really need this to be there.
if 'extensio... | python | def _configure(self, config):
"""Prepare the incoming configuration and ensure certain expected values are present.
For example, this ensures BaseExtension is included in the extension list, and populates the logging config.
"""
config = config or dict()
# We really need this to be there.
if 'extensio... | [
"def",
"_configure",
"(",
"self",
",",
"config",
")",
":",
"config",
"=",
"config",
"or",
"dict",
"(",
")",
"# We really need this to be there.",
"if",
"'extensions'",
"not",
"in",
"config",
":",
"config",
"[",
"'extensions'",
"]",
"=",
"list",
"(",
")",
"... | Prepare the incoming configuration and ensure certain expected values are present.
For example, this ensures BaseExtension is included in the extension list, and populates the logging config. | [
"Prepare",
"the",
"incoming",
"configuration",
"and",
"ensure",
"certain",
"expected",
"values",
"are",
"present",
".",
"For",
"example",
"this",
"ensures",
"BaseExtension",
"is",
"included",
"in",
"the",
"extension",
"list",
"and",
"populates",
"the",
"logging",
... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/application.py#L108-L147 | train |
marrow/WebCore | web/core/application.py | Application.serve | def serve(self, service='auto', **options): # pragma: no cover
"""Initiate a web server service to serve this application.
You can always use the Application instance as a bare WSGI application, of course. This method is provided as
a convienence.
Pass in the name of the service you wish to use, and any... | python | def serve(self, service='auto', **options): # pragma: no cover
"""Initiate a web server service to serve this application.
You can always use the Application instance as a bare WSGI application, of course. This method is provided as
a convienence.
Pass in the name of the service you wish to use, and any... | [
"def",
"serve",
"(",
"self",
",",
"service",
"=",
"'auto'",
",",
"*",
"*",
"options",
")",
":",
"# pragma: no cover",
"service",
"=",
"load",
"(",
"service",
",",
"'web.server'",
")",
"# We don't bother with a full registry for these one-time lookups.",
"try",
":",
... | Initiate a web server service to serve this application.
You can always use the Application instance as a bare WSGI application, of course. This method is provided as
a convienence.
Pass in the name of the service you wish to use, and any additional configuration options appropriate for that
service. Al... | [
"Initiate",
"a",
"web",
"server",
"service",
"to",
"serve",
"this",
"application",
".",
"You",
"can",
"always",
"use",
"the",
"Application",
"instance",
"as",
"a",
"bare",
"WSGI",
"application",
"of",
"course",
".",
"This",
"method",
"is",
"provided",
"as",
... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/application.py#L151-L170 | train |
marrow/WebCore | web/core/application.py | Application.application | def application(self, environ, start_response):
"""Process a single WSGI request/response cycle.
This is the WSGI handler for WebCore. Depending on the presence of extensions providing WSGI middleware,
the `__call__` attribute of the Application instance will either become this, or become the outermost
midd... | python | def application(self, environ, start_response):
"""Process a single WSGI request/response cycle.
This is the WSGI handler for WebCore. Depending on the presence of extensions providing WSGI middleware,
the `__call__` attribute of the Application instance will either become this, or become the outermost
midd... | [
"def",
"application",
"(",
"self",
",",
"environ",
",",
"start_response",
")",
":",
"context",
"=",
"environ",
"[",
"'wc.context'",
"]",
"=",
"self",
".",
"RequestContext",
"(",
"environ",
"=",
"environ",
")",
"signals",
"=",
"context",
".",
"extension",
"... | Process a single WSGI request/response cycle.
This is the WSGI handler for WebCore. Depending on the presence of extensions providing WSGI middleware,
the `__call__` attribute of the Application instance will either become this, or become the outermost
middleware callable.
Most apps won't utilize middlew... | [
"Process",
"a",
"single",
"WSGI",
"request",
"/",
"response",
"cycle",
".",
"This",
"is",
"the",
"WSGI",
"handler",
"for",
"WebCore",
".",
"Depending",
"on",
"the",
"presence",
"of",
"extensions",
"providing",
"WSGI",
"middleware",
"the",
"__call__",
"attribut... | 38d50f8022ca62976a1e5ff23f7714bd647b6532 | https://github.com/marrow/WebCore/blob/38d50f8022ca62976a1e5ff23f7714bd647b6532/web/core/application.py#L217-L280 | train |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment._swap | def _swap(self):
'''Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed'''
self.ref_start, self.qry_start = self.qry_start, self.ref_start
self.ref_end, self.qry_end = self.qry_end, self.ref_end
self.hit... | python | def _swap(self):
'''Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed'''
self.ref_start, self.qry_start = self.qry_start, self.ref_start
self.ref_end, self.qry_end = self.qry_end, self.ref_end
self.hit... | [
"def",
"_swap",
"(",
"self",
")",
":",
"self",
".",
"ref_start",
",",
"self",
".",
"qry_start",
"=",
"self",
".",
"qry_start",
",",
"self",
".",
"ref_start",
"self",
".",
"ref_end",
",",
"self",
".",
"qry_end",
"=",
"self",
".",
"qry_end",
",",
"self... | Swaps the alignment so that the reference becomes the query and vice-versa. Swaps their names, coordinates etc. The frame is not changed | [
"Swaps",
"the",
"alignment",
"so",
"that",
"the",
"reference",
"becomes",
"the",
"query",
"and",
"vice",
"-",
"versa",
".",
"Swaps",
"their",
"names",
"coordinates",
"etc",
".",
"The",
"frame",
"is",
"not",
"changed"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L52-L58 | train |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.qry_coords | def qry_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the query sequence'''
return pyfastaq.intervals.Interval(min(self.qry_start, self.qry_end), max(self.qry_start, self.qry_end)) | python | def qry_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the query sequence'''
return pyfastaq.intervals.Interval(min(self.qry_start, self.qry_end), max(self.qry_start, self.qry_end)) | [
"def",
"qry_coords",
"(",
"self",
")",
":",
"return",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"(",
"min",
"(",
"self",
".",
"qry_start",
",",
"self",
".",
"qry_end",
")",
",",
"max",
"(",
"self",
".",
"qry_start",
",",
"self",
".",
"qry_end",
... | Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the query sequence | [
"Returns",
"a",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"object",
"of",
"the",
"start",
"and",
"end",
"coordinates",
"in",
"the",
"query",
"sequence"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L61-L63 | train |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.ref_coords | def ref_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the reference sequence'''
return pyfastaq.intervals.Interval(min(self.ref_start, self.ref_end), max(self.ref_start, self.ref_end)) | python | def ref_coords(self):
'''Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the reference sequence'''
return pyfastaq.intervals.Interval(min(self.ref_start, self.ref_end), max(self.ref_start, self.ref_end)) | [
"def",
"ref_coords",
"(",
"self",
")",
":",
"return",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"(",
"min",
"(",
"self",
".",
"ref_start",
",",
"self",
".",
"ref_end",
")",
",",
"max",
"(",
"self",
".",
"ref_start",
",",
"self",
".",
"ref_end",
... | Returns a pyfastaq.intervals.Interval object of the start and end coordinates in the reference sequence | [
"Returns",
"a",
"pyfastaq",
".",
"intervals",
".",
"Interval",
"object",
"of",
"the",
"start",
"and",
"end",
"coordinates",
"in",
"the",
"reference",
"sequence"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L66-L68 | train |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.on_same_strand | def on_same_strand(self):
'''Returns true iff the direction of the alignment is the same in the reference and the query'''
return (self.ref_start < self.ref_end) == (self.qry_start < self.qry_end) | python | def on_same_strand(self):
'''Returns true iff the direction of the alignment is the same in the reference and the query'''
return (self.ref_start < self.ref_end) == (self.qry_start < self.qry_end) | [
"def",
"on_same_strand",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"ref_start",
"<",
"self",
".",
"ref_end",
")",
"==",
"(",
"self",
".",
"qry_start",
"<",
"self",
".",
"qry_end",
")"
] | Returns true iff the direction of the alignment is the same in the reference and the query | [
"Returns",
"true",
"iff",
"the",
"direction",
"of",
"the",
"alignment",
"is",
"the",
"same",
"in",
"the",
"reference",
"and",
"the",
"query"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L71-L73 | train |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.is_self_hit | def is_self_hit(self):
'''Returns true iff the alignment is of a sequence to itself: names and all coordinates are the same and 100 percent identity'''
return self.ref_name == self.qry_name \
and self.ref_start == self.qry_start \
and self.ref_end == self.qry_end \
... | python | def is_self_hit(self):
'''Returns true iff the alignment is of a sequence to itself: names and all coordinates are the same and 100 percent identity'''
return self.ref_name == self.qry_name \
and self.ref_start == self.qry_start \
and self.ref_end == self.qry_end \
... | [
"def",
"is_self_hit",
"(",
"self",
")",
":",
"return",
"self",
".",
"ref_name",
"==",
"self",
".",
"qry_name",
"and",
"self",
".",
"ref_start",
"==",
"self",
".",
"qry_start",
"and",
"self",
".",
"ref_end",
"==",
"self",
".",
"qry_end",
"and",
"self",
... | Returns true iff the alignment is of a sequence to itself: names and all coordinates are the same and 100 percent identity | [
"Returns",
"true",
"iff",
"the",
"alignment",
"is",
"of",
"a",
"sequence",
"to",
"itself",
":",
"names",
"and",
"all",
"coordinates",
"are",
"the",
"same",
"and",
"100",
"percent",
"identity"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L76-L81 | train |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.reverse_query | def reverse_query(self):
'''Changes the coordinates as if the query sequence has been reverse complemented'''
self.qry_start = self.qry_length - self.qry_start - 1
self.qry_end = self.qry_length - self.qry_end - 1 | python | def reverse_query(self):
'''Changes the coordinates as if the query sequence has been reverse complemented'''
self.qry_start = self.qry_length - self.qry_start - 1
self.qry_end = self.qry_length - self.qry_end - 1 | [
"def",
"reverse_query",
"(",
"self",
")",
":",
"self",
".",
"qry_start",
"=",
"self",
".",
"qry_length",
"-",
"self",
".",
"qry_start",
"-",
"1",
"self",
".",
"qry_end",
"=",
"self",
".",
"qry_length",
"-",
"self",
".",
"qry_end",
"-",
"1"
] | Changes the coordinates as if the query sequence has been reverse complemented | [
"Changes",
"the",
"coordinates",
"as",
"if",
"the",
"query",
"sequence",
"has",
"been",
"reverse",
"complemented"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L84-L87 | train |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.reverse_reference | def reverse_reference(self):
'''Changes the coordinates as if the reference sequence has been reverse complemented'''
self.ref_start = self.ref_length - self.ref_start - 1
self.ref_end = self.ref_length - self.ref_end - 1 | python | def reverse_reference(self):
'''Changes the coordinates as if the reference sequence has been reverse complemented'''
self.ref_start = self.ref_length - self.ref_start - 1
self.ref_end = self.ref_length - self.ref_end - 1 | [
"def",
"reverse_reference",
"(",
"self",
")",
":",
"self",
".",
"ref_start",
"=",
"self",
".",
"ref_length",
"-",
"self",
".",
"ref_start",
"-",
"1",
"self",
".",
"ref_end",
"=",
"self",
".",
"ref_length",
"-",
"self",
".",
"ref_end",
"-",
"1"
] | Changes the coordinates as if the reference sequence has been reverse complemented | [
"Changes",
"the",
"coordinates",
"as",
"if",
"the",
"reference",
"sequence",
"has",
"been",
"reverse",
"complemented"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L90-L93 | train |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.to_msp_crunch | def to_msp_crunch(self):
'''Returns the alignment as a line in MSPcrunch format. The columns are space-separated and are:
1. score
2. percent identity
3. match start in the query sequence
4. match end in the query sequence
5. query sequence name
... | python | def to_msp_crunch(self):
'''Returns the alignment as a line in MSPcrunch format. The columns are space-separated and are:
1. score
2. percent identity
3. match start in the query sequence
4. match end in the query sequence
5. query sequence name
... | [
"def",
"to_msp_crunch",
"(",
"self",
")",
":",
"# we don't know the alignment score. Estimate it. This approximates 1 for a match.",
"aln_score",
"=",
"int",
"(",
"self",
".",
"percent_identity",
"*",
"0.005",
"*",
"(",
"self",
".",
"hit_length_ref",
"+",
"self",
".",
... | Returns the alignment as a line in MSPcrunch format. The columns are space-separated and are:
1. score
2. percent identity
3. match start in the query sequence
4. match end in the query sequence
5. query sequence name
6. subject sequence start
... | [
"Returns",
"the",
"alignment",
"as",
"a",
"line",
"in",
"MSPcrunch",
"format",
".",
"The",
"columns",
"are",
"space",
"-",
"separated",
"and",
"are",
":",
"1",
".",
"score",
"2",
".",
"percent",
"identity",
"3",
".",
"match",
"start",
"in",
"the",
"que... | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L113-L136 | train |
sanger-pathogens/pymummer | pymummer/alignment.py | Alignment.qry_coords_from_ref_coord | def qry_coords_from_ref_coord(self, ref_coord, variant_list):
'''Given a reference position and a list of variants ([variant.Variant]),
works out the position in the query sequence, accounting for indels.
Returns a tuple: (position, True|False), where second element is whether
o... | python | def qry_coords_from_ref_coord(self, ref_coord, variant_list):
'''Given a reference position and a list of variants ([variant.Variant]),
works out the position in the query sequence, accounting for indels.
Returns a tuple: (position, True|False), where second element is whether
o... | [
"def",
"qry_coords_from_ref_coord",
"(",
"self",
",",
"ref_coord",
",",
"variant_list",
")",
":",
"if",
"self",
".",
"ref_coords",
"(",
")",
".",
"distance_to_point",
"(",
"ref_coord",
")",
">",
"0",
":",
"raise",
"Error",
"(",
"'Cannot get query coord in qry_co... | Given a reference position and a list of variants ([variant.Variant]),
works out the position in the query sequence, accounting for indels.
Returns a tuple: (position, True|False), where second element is whether
or not the ref_coord lies in an indel. If it is, then
returns t... | [
"Given",
"a",
"reference",
"position",
"and",
"a",
"list",
"of",
"variants",
"(",
"[",
"variant",
".",
"Variant",
"]",
")",
"works",
"out",
"the",
"position",
"in",
"the",
"query",
"sequence",
"accounting",
"for",
"indels",
".",
"Returns",
"a",
"tuple",
... | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/alignment.py#L147-L181 | train |
sanger-pathogens/pymummer | pymummer/nucmer.py | Runner._nucmer_command | def _nucmer_command(self, ref, qry, outprefix):
'''Construct the nucmer command'''
if self.use_promer:
command = 'promer'
else:
command = 'nucmer'
command += ' -p ' + outprefix
if self.breaklen is not None:
command += ' -b ' + str(self.breakl... | python | def _nucmer_command(self, ref, qry, outprefix):
'''Construct the nucmer command'''
if self.use_promer:
command = 'promer'
else:
command = 'nucmer'
command += ' -p ' + outprefix
if self.breaklen is not None:
command += ' -b ' + str(self.breakl... | [
"def",
"_nucmer_command",
"(",
"self",
",",
"ref",
",",
"qry",
",",
"outprefix",
")",
":",
"if",
"self",
".",
"use_promer",
":",
"command",
"=",
"'promer'",
"else",
":",
"command",
"=",
"'nucmer'",
"command",
"+=",
"' -p '",
"+",
"outprefix",
"if",
"self... | Construct the nucmer command | [
"Construct",
"the",
"nucmer",
"command"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L53-L83 | train |
sanger-pathogens/pymummer | pymummer/nucmer.py | Runner._delta_filter_command | def _delta_filter_command(self, infile, outfile):
'''Construct delta-filter command'''
command = 'delta-filter'
if self.min_id is not None:
command += ' -i ' + str(self.min_id)
if self.min_length is not None:
command += ' -l ' + str(self.min_length)
ret... | python | def _delta_filter_command(self, infile, outfile):
'''Construct delta-filter command'''
command = 'delta-filter'
if self.min_id is not None:
command += ' -i ' + str(self.min_id)
if self.min_length is not None:
command += ' -l ' + str(self.min_length)
ret... | [
"def",
"_delta_filter_command",
"(",
"self",
",",
"infile",
",",
"outfile",
")",
":",
"command",
"=",
"'delta-filter'",
"if",
"self",
".",
"min_id",
"is",
"not",
"None",
":",
"command",
"+=",
"' -i '",
"+",
"str",
"(",
"self",
".",
"min_id",
")",
"if",
... | Construct delta-filter command | [
"Construct",
"delta",
"-",
"filter",
"command"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L86-L96 | train |
sanger-pathogens/pymummer | pymummer/nucmer.py | Runner._show_coords_command | def _show_coords_command(self, infile, outfile):
'''Construct show-coords command'''
command = 'show-coords -dTlro'
if not self.coords_header:
command += ' -H'
return command + ' ' + infile + ' > ' + outfile | python | def _show_coords_command(self, infile, outfile):
'''Construct show-coords command'''
command = 'show-coords -dTlro'
if not self.coords_header:
command += ' -H'
return command + ' ' + infile + ' > ' + outfile | [
"def",
"_show_coords_command",
"(",
"self",
",",
"infile",
",",
"outfile",
")",
":",
"command",
"=",
"'show-coords -dTlro'",
"if",
"not",
"self",
".",
"coords_header",
":",
"command",
"+=",
"' -H'",
"return",
"command",
"+",
"' '",
"+",
"infile",
"+",
"' > '... | Construct show-coords command | [
"Construct",
"show",
"-",
"coords",
"command"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L99-L106 | train |
sanger-pathogens/pymummer | pymummer/nucmer.py | Runner._write_script | def _write_script(self, script_name, ref, qry, outfile):
'''Write commands into a bash script'''
f = pyfastaq.utils.open_file_write(script_name)
print(self._nucmer_command(ref, qry, 'p'), file=f)
print(self._delta_filter_command('p.delta', 'p.delta.filter'), file=f)
print(self._s... | python | def _write_script(self, script_name, ref, qry, outfile):
'''Write commands into a bash script'''
f = pyfastaq.utils.open_file_write(script_name)
print(self._nucmer_command(ref, qry, 'p'), file=f)
print(self._delta_filter_command('p.delta', 'p.delta.filter'), file=f)
print(self._s... | [
"def",
"_write_script",
"(",
"self",
",",
"script_name",
",",
"ref",
",",
"qry",
",",
"outfile",
")",
":",
"f",
"=",
"pyfastaq",
".",
"utils",
".",
"open_file_write",
"(",
"script_name",
")",
"print",
"(",
"self",
".",
"_nucmer_command",
"(",
"ref",
",",... | Write commands into a bash script | [
"Write",
"commands",
"into",
"a",
"bash",
"script"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L118-L126 | train |
sanger-pathogens/pymummer | pymummer/nucmer.py | Runner.run | def run(self):
'''
Change to a temp directory
Run bash script containing commands
Place results in specified output file
Clean up temp directory
'''
qry = os.path.abspath(self.qry)
ref = os.path.abspath(self.ref)
outfile = os.path.abspath(self.outf... | python | def run(self):
'''
Change to a temp directory
Run bash script containing commands
Place results in specified output file
Clean up temp directory
'''
qry = os.path.abspath(self.qry)
ref = os.path.abspath(self.ref)
outfile = os.path.abspath(self.outf... | [
"def",
"run",
"(",
"self",
")",
":",
"qry",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"qry",
")",
"ref",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"ref",
")",
"outfile",
"=",
"os",
".",
"path",
".",
"abspath",
... | Change to a temp directory
Run bash script containing commands
Place results in specified output file
Clean up temp directory | [
"Change",
"to",
"a",
"temp",
"directory",
"Run",
"bash",
"script",
"containing",
"commands",
"Place",
"results",
"in",
"specified",
"output",
"file",
"Clean",
"up",
"temp",
"directory"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/nucmer.py#L129-L146 | train |
sanger-pathogens/pymummer | pymummer/variant.py | Variant.update_indel | def update_indel(self, nucmer_snp):
'''Indels are reported over multiple lines, 1 base insertion or deletion per line. This method extends the current variant by 1 base if it's an indel and adjacent to the new SNP and returns True. If the current variant is a SNP, does nothing and returns False'''
new_v... | python | def update_indel(self, nucmer_snp):
'''Indels are reported over multiple lines, 1 base insertion or deletion per line. This method extends the current variant by 1 base if it's an indel and adjacent to the new SNP and returns True. If the current variant is a SNP, does nothing and returns False'''
new_v... | [
"def",
"update_indel",
"(",
"self",
",",
"nucmer_snp",
")",
":",
"new_variant",
"=",
"Variant",
"(",
"nucmer_snp",
")",
"if",
"self",
".",
"var_type",
"not",
"in",
"[",
"INS",
",",
"DEL",
"]",
"or",
"self",
".",
"var_type",
"!=",
"new_variant",
".",
"v... | Indels are reported over multiple lines, 1 base insertion or deletion per line. This method extends the current variant by 1 base if it's an indel and adjacent to the new SNP and returns True. If the current variant is a SNP, does nothing and returns False | [
"Indels",
"are",
"reported",
"over",
"multiple",
"lines",
"1",
"base",
"insertion",
"or",
"deletion",
"per",
"line",
".",
"This",
"method",
"extends",
"the",
"current",
"variant",
"by",
"1",
"base",
"if",
"it",
"s",
"an",
"indel",
"and",
"adjacent",
"to",
... | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/variant.py#L62-L84 | train |
sanger-pathogens/pymummer | pymummer/coords_file.py | reader | def reader(fname):
'''Helper function to open the results file (coords file) and create alignment objects with the values in it'''
f = pyfastaq.utils.open_file_read(fname)
for line in f:
if line.startswith('[') or (not '\t' in line):
continue
yield alignment.Alignment(line)
... | python | def reader(fname):
'''Helper function to open the results file (coords file) and create alignment objects with the values in it'''
f = pyfastaq.utils.open_file_read(fname)
for line in f:
if line.startswith('[') or (not '\t' in line):
continue
yield alignment.Alignment(line)
... | [
"def",
"reader",
"(",
"fname",
")",
":",
"f",
"=",
"pyfastaq",
".",
"utils",
".",
"open_file_read",
"(",
"fname",
")",
"for",
"line",
"in",
"f",
":",
"if",
"line",
".",
"startswith",
"(",
"'['",
")",
"or",
"(",
"not",
"'\\t'",
"in",
"line",
")",
... | Helper function to open the results file (coords file) and create alignment objects with the values in it | [
"Helper",
"function",
"to",
"open",
"the",
"results",
"file",
"(",
"coords",
"file",
")",
"and",
"create",
"alignment",
"objects",
"with",
"the",
"values",
"in",
"it"
] | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/coords_file.py#L6-L16 | train |
sanger-pathogens/pymummer | pymummer/coords_file.py | convert_to_msp_crunch | def convert_to_msp_crunch(infile, outfile, ref_fai=None, qry_fai=None):
'''Converts a coords file to a file in MSPcrunch format (for use with ACT, most likely).
ACT ignores sequence names in the crunch file, and just looks at the numbers.
To make a compatible file, the coords all must be shifted appro... | python | def convert_to_msp_crunch(infile, outfile, ref_fai=None, qry_fai=None):
'''Converts a coords file to a file in MSPcrunch format (for use with ACT, most likely).
ACT ignores sequence names in the crunch file, and just looks at the numbers.
To make a compatible file, the coords all must be shifted appro... | [
"def",
"convert_to_msp_crunch",
"(",
"infile",
",",
"outfile",
",",
"ref_fai",
"=",
"None",
",",
"qry_fai",
"=",
"None",
")",
":",
"fai_files",
"=",
"{",
"ref_fai",
",",
"qry_fai",
"}",
"if",
"None",
"in",
"fai_files",
"and",
"len",
"(",
"fai_files",
")"... | Converts a coords file to a file in MSPcrunch format (for use with ACT, most likely).
ACT ignores sequence names in the crunch file, and just looks at the numbers.
To make a compatible file, the coords all must be shifted appropriately, which
can be done by providing both the ref_fai and qry_fai op... | [
"Converts",
"a",
"coords",
"file",
"to",
"a",
"file",
"in",
"MSPcrunch",
"format",
"(",
"for",
"use",
"with",
"ACT",
"most",
"likely",
")",
".",
"ACT",
"ignores",
"sequence",
"names",
"in",
"the",
"crunch",
"file",
"and",
"just",
"looks",
"at",
"the",
... | fd97bccfbae62719a7247473d73dd6733d4fa903 | https://github.com/sanger-pathogens/pymummer/blob/fd97bccfbae62719a7247473d73dd6733d4fa903/pymummer/coords_file.py#L19-L47 | train |
anandtiwarics/python-burp-rest-api | PyBurprestapi/burpscanner.py | BurpApi._request | def _request(self, method, url, params=None, headers=None, data=None):
"""Common handler for all the HTTP requests."""
if not params:
params = {}
# set default headers
if not headers:
headers = {
'accept': '*/*'
}
if method... | python | def _request(self, method, url, params=None, headers=None, data=None):
"""Common handler for all the HTTP requests."""
if not params:
params = {}
# set default headers
if not headers:
headers = {
'accept': '*/*'
}
if method... | [
"def",
"_request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"if",
"not",
"params",
":",
"params",
"=",
"{",
"}",
"# set default headers",
"if",
"not",
"header... | Common handler for all the HTTP requests. | [
"Common",
"handler",
"for",
"all",
"the",
"HTTP",
"requests",
"."
] | 1b3fb263ef1d006e181b838ea017ac2abbd68a30 | https://github.com/anandtiwarics/python-burp-rest-api/blob/1b3fb263ef1d006e181b838ea017ac2abbd68a30/PyBurprestapi/burpscanner.py#L55-L98 | train |
sloria/sphinx-issues | sphinx_issues.py | user_role | def user_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a user profile. Defaults to linking to
Github profiles, but the profile URIS can be configured via the
``issues_user_uri`` config value.
Examples: ::
:user:`sloria`
Anchor text a... | python | def user_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a user profile. Defaults to linking to
Github profiles, but the profile URIS can be configured via the
``issues_user_uri`` config value.
Examples: ::
:user:`sloria`
Anchor text a... | [
"def",
"user_role",
"(",
"name",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"None",
",",
"content",
"=",
"None",
")",
":",
"options",
"=",
"options",
"or",
"{",
"}",
"content",
"=",
"content",
"or",
"[",
"]",
"... | Sphinx role for linking to a user profile. Defaults to linking to
Github profiles, but the profile URIS can be configured via the
``issues_user_uri`` config value.
Examples: ::
:user:`sloria`
Anchor text also works: ::
:user:`Steven Loria <sloria>` | [
"Sphinx",
"role",
"for",
"linking",
"to",
"a",
"user",
"profile",
".",
"Defaults",
"to",
"linking",
"to",
"Github",
"profiles",
"but",
"the",
"profile",
"URIS",
"can",
"be",
"configured",
"via",
"the",
"issues_user_uri",
"config",
"value",
"."
] | 0a9597472645dc728c2aef12e0653aabfdb68ab2 | https://github.com/sloria/sphinx-issues/blob/0a9597472645dc728c2aef12e0653aabfdb68ab2/sphinx_issues.py#L13-L43 | train |
sloria/sphinx-issues | sphinx_issues.py | cve_role | def cve_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a CVE on https://cve.mitre.org.
Examples: ::
:cve:`CVE-2018-17175`
"""
options = options or {}
content = content or []
has_explicit_title, title, target = split_explicit_title... | python | def cve_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a CVE on https://cve.mitre.org.
Examples: ::
:cve:`CVE-2018-17175`
"""
options = options or {}
content = content or []
has_explicit_title, title, target = split_explicit_title... | [
"def",
"cve_role",
"(",
"name",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"None",
",",
"content",
"=",
"None",
")",
":",
"options",
"=",
"options",
"or",
"{",
"}",
"content",
"=",
"content",
"or",
"[",
"]",
"h... | Sphinx role for linking to a CVE on https://cve.mitre.org.
Examples: ::
:cve:`CVE-2018-17175` | [
"Sphinx",
"role",
"for",
"linking",
"to",
"a",
"CVE",
"on",
"https",
":",
"//",
"cve",
".",
"mitre",
".",
"org",
"."
] | 0a9597472645dc728c2aef12e0653aabfdb68ab2 | https://github.com/sloria/sphinx-issues/blob/0a9597472645dc728c2aef12e0653aabfdb68ab2/sphinx_issues.py#L46-L63 | train |
adamnovak/tsv | tsv.py | TsvWriter.list_line | def list_line(self, line):
"""
Write the given iterable of values (line) to the file as items on the
same line. Any argument that stringifies to a string legal as a TSV data
item can be written.
Does not copy the line or build a big string in memory.
"""
... | python | def list_line(self, line):
"""
Write the given iterable of values (line) to the file as items on the
same line. Any argument that stringifies to a string legal as a TSV data
item can be written.
Does not copy the line or build a big string in memory.
"""
... | [
"def",
"list_line",
"(",
"self",
",",
"line",
")",
":",
"if",
"len",
"(",
"line",
")",
"==",
"0",
":",
"return",
"self",
".",
"stream",
".",
"write",
"(",
"str",
"(",
"line",
"[",
"0",
"]",
")",
")",
"for",
"item",
"in",
"line",
"[",
"1",
":"... | Write the given iterable of values (line) to the file as items on the
same line. Any argument that stringifies to a string legal as a TSV data
item can be written.
Does not copy the line or build a big string in memory. | [
"Write",
"the",
"given",
"iterable",
"of",
"values",
"(",
"line",
")",
"to",
"the",
"file",
"as",
"items",
"on",
"the",
"same",
"line",
".",
"Any",
"argument",
"that",
"stringifies",
"to",
"a",
"string",
"legal",
"as",
"a",
"TSV",
"data",
"item",
"can"... | 379189e9da4c1b65d0587bb32f3b51e6a7c936c8 | https://github.com/adamnovak/tsv/blob/379189e9da4c1b65d0587bb32f3b51e6a7c936c8/tsv.py#L42-L60 | train |
michaelstepner/pandoc-mustache | pandoc_mustache/pandoc_mustache.py | prepare | def prepare(doc):
""" Parse metadata to obtain list of mustache templates,
then load those templates.
"""
doc.mustache_files = doc.get_metadata('mustache')
if isinstance(doc.mustache_files, basestring): # process single YAML value stored as string
if not doc.mustache_files:
... | python | def prepare(doc):
""" Parse metadata to obtain list of mustache templates,
then load those templates.
"""
doc.mustache_files = doc.get_metadata('mustache')
if isinstance(doc.mustache_files, basestring): # process single YAML value stored as string
if not doc.mustache_files:
... | [
"def",
"prepare",
"(",
"doc",
")",
":",
"doc",
".",
"mustache_files",
"=",
"doc",
".",
"get_metadata",
"(",
"'mustache'",
")",
"if",
"isinstance",
"(",
"doc",
".",
"mustache_files",
",",
"basestring",
")",
":",
"# process single YAML value stored as string",
"if... | Parse metadata to obtain list of mustache templates,
then load those templates. | [
"Parse",
"metadata",
"to",
"obtain",
"list",
"of",
"mustache",
"templates",
"then",
"load",
"those",
"templates",
"."
] | 52d71190d134964596e7f8e109564452e916b3fc | https://github.com/michaelstepner/pandoc-mustache/blob/52d71190d134964596e7f8e109564452e916b3fc/pandoc_mustache/pandoc_mustache.py#L8-L26 | train |
michaelstepner/pandoc-mustache | pandoc_mustache/pandoc_mustache.py | action | def action(elem, doc):
""" Apply combined mustache template to all strings in document.
"""
if type(elem) == Str and doc.mhash is not None:
elem.text = doc.mrenderer.render(elem.text, doc.mhash)
return elem | python | def action(elem, doc):
""" Apply combined mustache template to all strings in document.
"""
if type(elem) == Str and doc.mhash is not None:
elem.text = doc.mrenderer.render(elem.text, doc.mhash)
return elem | [
"def",
"action",
"(",
"elem",
",",
"doc",
")",
":",
"if",
"type",
"(",
"elem",
")",
"==",
"Str",
"and",
"doc",
".",
"mhash",
"is",
"not",
"None",
":",
"elem",
".",
"text",
"=",
"doc",
".",
"mrenderer",
".",
"render",
"(",
"elem",
".",
"text",
"... | Apply combined mustache template to all strings in document. | [
"Apply",
"combined",
"mustache",
"template",
"to",
"all",
"strings",
"in",
"document",
"."
] | 52d71190d134964596e7f8e109564452e916b3fc | https://github.com/michaelstepner/pandoc-mustache/blob/52d71190d134964596e7f8e109564452e916b3fc/pandoc_mustache/pandoc_mustache.py#L28-L33 | train |
jpadilla/django-rest-framework-jsonp | rest_framework_jsonp/renderers.py | JSONPRenderer.get_callback | def get_callback(self, renderer_context):
"""
Determine the name of the callback to wrap around the json output.
"""
request = renderer_context.get('request', None)
params = request and get_query_params(request) or {}
return params.get(self.callback_parameter, self.defaul... | python | def get_callback(self, renderer_context):
"""
Determine the name of the callback to wrap around the json output.
"""
request = renderer_context.get('request', None)
params = request and get_query_params(request) or {}
return params.get(self.callback_parameter, self.defaul... | [
"def",
"get_callback",
"(",
"self",
",",
"renderer_context",
")",
":",
"request",
"=",
"renderer_context",
".",
"get",
"(",
"'request'",
",",
"None",
")",
"params",
"=",
"request",
"and",
"get_query_params",
"(",
"request",
")",
"or",
"{",
"}",
"return",
"... | Determine the name of the callback to wrap around the json output. | [
"Determine",
"the",
"name",
"of",
"the",
"callback",
"to",
"wrap",
"around",
"the",
"json",
"output",
"."
] | 64e91d451206a815b98d4b4a4e27e705104ad06e | https://github.com/jpadilla/django-rest-framework-jsonp/blob/64e91d451206a815b98d4b4a4e27e705104ad06e/rest_framework_jsonp/renderers.py#L23-L29 | train |
jpadilla/django-rest-framework-jsonp | rest_framework_jsonp/renderers.py | JSONPRenderer.render | def render(self, data, accepted_media_type=None, renderer_context=None):
"""
Renders into jsonp, wrapping the json output in a callback function.
Clients may set the callback function name using a query parameter
on the URL, for example: ?callback=exampleCallbackName
"""
... | python | def render(self, data, accepted_media_type=None, renderer_context=None):
"""
Renders into jsonp, wrapping the json output in a callback function.
Clients may set the callback function name using a query parameter
on the URL, for example: ?callback=exampleCallbackName
"""
... | [
"def",
"render",
"(",
"self",
",",
"data",
",",
"accepted_media_type",
"=",
"None",
",",
"renderer_context",
"=",
"None",
")",
":",
"renderer_context",
"=",
"renderer_context",
"or",
"{",
"}",
"callback",
"=",
"self",
".",
"get_callback",
"(",
"renderer_contex... | Renders into jsonp, wrapping the json output in a callback function.
Clients may set the callback function name using a query parameter
on the URL, for example: ?callback=exampleCallbackName | [
"Renders",
"into",
"jsonp",
"wrapping",
"the",
"json",
"output",
"in",
"a",
"callback",
"function",
"."
] | 64e91d451206a815b98d4b4a4e27e705104ad06e | https://github.com/jpadilla/django-rest-framework-jsonp/blob/64e91d451206a815b98d4b4a4e27e705104ad06e/rest_framework_jsonp/renderers.py#L31-L42 | train |
3ll3d00d/vibe | backend/src/analyser/resources/timeseries.py | TimeSeries.get | def get(self, measurementId):
"""
Analyses the measurement with the given parameters
:param measurementId:
:return:
"""
logger.info('Loading raw data for ' + measurementId)
measurement = self._measurementController.getMeasurement(measurementId, MeasurementStatus.C... | python | def get(self, measurementId):
"""
Analyses the measurement with the given parameters
:param measurementId:
:return:
"""
logger.info('Loading raw data for ' + measurementId)
measurement = self._measurementController.getMeasurement(measurementId, MeasurementStatus.C... | [
"def",
"get",
"(",
"self",
",",
"measurementId",
")",
":",
"logger",
".",
"info",
"(",
"'Loading raw data for '",
"+",
"measurementId",
")",
"measurement",
"=",
"self",
".",
"_measurementController",
".",
"getMeasurement",
"(",
"measurementId",
",",
"MeasurementSt... | Analyses the measurement with the given parameters
:param measurementId:
:return: | [
"Analyses",
"the",
"measurement",
"with",
"the",
"given",
"parameters",
":",
"param",
"measurementId",
":",
":",
"return",
":"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/timeseries.py#L13-L47 | train |
fitnr/convertdate | convertdate/iso.py | to_jd | def to_jd(year, week, day):
'''Return Julian day count of given ISO year, week, and day'''
return day + n_weeks(SUN, gregorian.to_jd(year - 1, 12, 28), week) | python | def to_jd(year, week, day):
'''Return Julian day count of given ISO year, week, and day'''
return day + n_weeks(SUN, gregorian.to_jd(year - 1, 12, 28), week) | [
"def",
"to_jd",
"(",
"year",
",",
"week",
",",
"day",
")",
":",
"return",
"day",
"+",
"n_weeks",
"(",
"SUN",
",",
"gregorian",
".",
"to_jd",
"(",
"year",
"-",
"1",
",",
"12",
",",
"28",
")",
",",
"week",
")"
] | Return Julian day count of given ISO year, week, and day | [
"Return",
"Julian",
"day",
"count",
"of",
"given",
"ISO",
"year",
"week",
"and",
"day"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/iso.py#L24-L26 | train |
fitnr/convertdate | convertdate/iso.py | from_jd | def from_jd(jd):
'''Return tuple of ISO (year, week, day) for Julian day'''
year = gregorian.from_jd(jd)[0]
day = jwday(jd) + 1
dayofyear = ordinal.from_jd(jd)[1]
week = trunc((dayofyear - day + 10) / 7)
# Reset year
if week < 1:
week = weeks_per_year(year - 1)
year = year ... | python | def from_jd(jd):
'''Return tuple of ISO (year, week, day) for Julian day'''
year = gregorian.from_jd(jd)[0]
day = jwday(jd) + 1
dayofyear = ordinal.from_jd(jd)[1]
week = trunc((dayofyear - day + 10) / 7)
# Reset year
if week < 1:
week = weeks_per_year(year - 1)
year = year ... | [
"def",
"from_jd",
"(",
"jd",
")",
":",
"year",
"=",
"gregorian",
".",
"from_jd",
"(",
"jd",
")",
"[",
"0",
"]",
"day",
"=",
"jwday",
"(",
"jd",
")",
"+",
"1",
"dayofyear",
"=",
"ordinal",
".",
"from_jd",
"(",
"jd",
")",
"[",
"1",
"]",
"week",
... | Return tuple of ISO (year, week, day) for Julian day | [
"Return",
"tuple",
"of",
"ISO",
"(",
"year",
"week",
"day",
")",
"for",
"Julian",
"day"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/iso.py#L29-L47 | train |
fitnr/convertdate | convertdate/iso.py | weeks_per_year | def weeks_per_year(year):
'''Number of ISO weeks in a year'''
# 53 weeks: any year starting on Thursday and any leap year starting on Wednesday
jan1 = jwday(gregorian.to_jd(year, 1, 1))
if jan1 == THU or (jan1 == WED and isleap(year)):
return 53
else:
return 52 | python | def weeks_per_year(year):
'''Number of ISO weeks in a year'''
# 53 weeks: any year starting on Thursday and any leap year starting on Wednesday
jan1 = jwday(gregorian.to_jd(year, 1, 1))
if jan1 == THU or (jan1 == WED and isleap(year)):
return 53
else:
return 52 | [
"def",
"weeks_per_year",
"(",
"year",
")",
":",
"# 53 weeks: any year starting on Thursday and any leap year starting on Wednesday",
"jan1",
"=",
"jwday",
"(",
"gregorian",
".",
"to_jd",
"(",
"year",
",",
"1",
",",
"1",
")",
")",
"if",
"jan1",
"==",
"THU",
"or",
... | Number of ISO weeks in a year | [
"Number",
"of",
"ISO",
"weeks",
"in",
"a",
"year"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/iso.py#L50-L58 | train |
spacetelescope/stsci.tools | lib/stsci/tools/readgeis.py | stsci | def stsci(hdulist):
"""For STScI GEIS files, need to do extra steps."""
instrument = hdulist[0].header.get('INSTRUME', '')
# Update extension header keywords
if instrument in ("WFPC2", "FOC"):
rootname = hdulist[0].header.get('ROOTNAME', '')
filetype = hdulist[0].header.get('FILETYPE',... | python | def stsci(hdulist):
"""For STScI GEIS files, need to do extra steps."""
instrument = hdulist[0].header.get('INSTRUME', '')
# Update extension header keywords
if instrument in ("WFPC2", "FOC"):
rootname = hdulist[0].header.get('ROOTNAME', '')
filetype = hdulist[0].header.get('FILETYPE',... | [
"def",
"stsci",
"(",
"hdulist",
")",
":",
"instrument",
"=",
"hdulist",
"[",
"0",
"]",
".",
"header",
".",
"get",
"(",
"'INSTRUME'",
",",
"''",
")",
"# Update extension header keywords",
"if",
"instrument",
"in",
"(",
"\"WFPC2\"",
",",
"\"FOC\"",
")",
":",... | For STScI GEIS files, need to do extra steps. | [
"For",
"STScI",
"GEIS",
"files",
"need",
"to",
"do",
"extra",
"steps",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/readgeis.py#L79-L97 | train |
spacetelescope/stsci.tools | lib/stsci/tools/readgeis.py | stsci2 | def stsci2(hdulist, filename):
"""For STScI GEIS files, need to do extra steps."""
# Write output file name to the primary header
instrument = hdulist[0].header.get('INSTRUME', '')
if instrument in ("WFPC2", "FOC"):
hdulist[0].header['FILENAME'] = filename | python | def stsci2(hdulist, filename):
"""For STScI GEIS files, need to do extra steps."""
# Write output file name to the primary header
instrument = hdulist[0].header.get('INSTRUME', '')
if instrument in ("WFPC2", "FOC"):
hdulist[0].header['FILENAME'] = filename | [
"def",
"stsci2",
"(",
"hdulist",
",",
"filename",
")",
":",
"# Write output file name to the primary header",
"instrument",
"=",
"hdulist",
"[",
"0",
"]",
".",
"header",
".",
"get",
"(",
"'INSTRUME'",
",",
"''",
")",
"if",
"instrument",
"in",
"(",
"\"WFPC2\"",... | For STScI GEIS files, need to do extra steps. | [
"For",
"STScI",
"GEIS",
"files",
"need",
"to",
"do",
"extra",
"steps",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/readgeis.py#L100-L106 | train |
spacetelescope/stsci.tools | lib/stsci/tools/readgeis.py | readgeis | def readgeis(input):
"""Input GEIS files "input" will be read and a HDUList object will
be returned.
The user can use the writeto method to write the HDUList object to
a FITS file.
"""
global dat
cardLen = fits.Card.length
# input file(s) must be of the form *.??h and *.??d
... | python | def readgeis(input):
"""Input GEIS files "input" will be read and a HDUList object will
be returned.
The user can use the writeto method to write the HDUList object to
a FITS file.
"""
global dat
cardLen = fits.Card.length
# input file(s) must be of the form *.??h and *.??d
... | [
"def",
"readgeis",
"(",
"input",
")",
":",
"global",
"dat",
"cardLen",
"=",
"fits",
".",
"Card",
".",
"length",
"# input file(s) must be of the form *.??h and *.??d",
"if",
"input",
"[",
"-",
"1",
"]",
"!=",
"'h'",
"or",
"input",
"[",
"-",
"4",
"]",
"!=",
... | Input GEIS files "input" will be read and a HDUList object will
be returned.
The user can use the writeto method to write the HDUList object to
a FITS file. | [
"Input",
"GEIS",
"files",
"input",
"will",
"be",
"read",
"and",
"a",
"HDUList",
"object",
"will",
"be",
"returned",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/readgeis.py#L109-L320 | train |
spacetelescope/stsci.tools | lib/stsci/tools/readgeis.py | parse_path | def parse_path(f1, f2):
"""Parse two input arguments and return two lists of file names"""
import glob
# if second argument is missing or is a wild card, point it
# to the current directory
f2 = f2.strip()
if f2 == '' or f2 == '*':
f2 = './'
# if the first argument is a directory... | python | def parse_path(f1, f2):
"""Parse two input arguments and return two lists of file names"""
import glob
# if second argument is missing or is a wild card, point it
# to the current directory
f2 = f2.strip()
if f2 == '' or f2 == '*':
f2 = './'
# if the first argument is a directory... | [
"def",
"parse_path",
"(",
"f1",
",",
"f2",
")",
":",
"import",
"glob",
"# if second argument is missing or is a wild card, point it",
"# to the current directory",
"f2",
"=",
"f2",
".",
"strip",
"(",
")",
"if",
"f2",
"==",
"''",
"or",
"f2",
"==",
"'*'",
":",
"... | Parse two input arguments and return two lists of file names | [
"Parse",
"two",
"input",
"arguments",
"and",
"return",
"two",
"lists",
"of",
"file",
"names"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/readgeis.py#L322-L363 | train |
spacetelescope/stsci.tools | lib/stsci/tools/parseinput.py | parseinput | def parseinput(inputlist,outputname=None, atfile=None):
"""
Recursively parse user input based upon the irafglob
program and construct a list of files that need to be processed.
This program addresses the following deficiencies of the irafglob program::
parseinput can extract filenames from asso... | python | def parseinput(inputlist,outputname=None, atfile=None):
"""
Recursively parse user input based upon the irafglob
program and construct a list of files that need to be processed.
This program addresses the following deficiencies of the irafglob program::
parseinput can extract filenames from asso... | [
"def",
"parseinput",
"(",
"inputlist",
",",
"outputname",
"=",
"None",
",",
"atfile",
"=",
"None",
")",
":",
"# Initalize some variables",
"files",
"=",
"[",
"]",
"# list used to store names of input files",
"newoutputname",
"=",
"outputname",
"# Outputname returned to ... | Recursively parse user input based upon the irafglob
program and construct a list of files that need to be processed.
This program addresses the following deficiencies of the irafglob program::
parseinput can extract filenames from association tables
Returns
-------
This program will return... | [
"Recursively",
"parse",
"user",
"input",
"based",
"upon",
"the",
"irafglob",
"program",
"and",
"construct",
"a",
"list",
"of",
"files",
"that",
"need",
"to",
"be",
"processed",
".",
"This",
"program",
"addresses",
"the",
"following",
"deficiencies",
"of",
"the... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/parseinput.py#L31-L134 | train |
spacetelescope/stsci.tools | lib/stsci/tools/parseinput.py | checkASN | def checkASN(filename):
"""
Determine if the filename provided to the function belongs to
an association.
Parameters
----------
filename: string
Returns
-------
validASN : boolean value
"""
# Extract the file extn type:
extnType = filename[filename.rfind('_')+1:filena... | python | def checkASN(filename):
"""
Determine if the filename provided to the function belongs to
an association.
Parameters
----------
filename: string
Returns
-------
validASN : boolean value
"""
# Extract the file extn type:
extnType = filename[filename.rfind('_')+1:filena... | [
"def",
"checkASN",
"(",
"filename",
")",
":",
"# Extract the file extn type:",
"extnType",
"=",
"filename",
"[",
"filename",
".",
"rfind",
"(",
"'_'",
")",
"+",
"1",
":",
"filename",
".",
"rfind",
"(",
"'.'",
")",
"]",
"# Determine if this extn name is valid for... | Determine if the filename provided to the function belongs to
an association.
Parameters
----------
filename: string
Returns
-------
validASN : boolean value | [
"Determine",
"if",
"the",
"filename",
"provided",
"to",
"the",
"function",
"belongs",
"to",
"an",
"association",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/parseinput.py#L137-L158 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.