repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
cloudera/cm_api | python/src/cm_api/endpoints/role_config_groups.py | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/role_config_groups.py#L82-L94 | def get_all_role_config_groups(resource_root, service_name,
cluster_name="default"):
"""
Get all role config groups in the specified service.
@param resource_root: The root Resource object.
@param service_name: Service name.
@param cluster_name: Cluster name.
@return: A list of ApiRoleConfigGroup object... | [
"def",
"get_all_role_config_groups",
"(",
"resource_root",
",",
"service_name",
",",
"cluster_name",
"=",
"\"default\"",
")",
":",
"return",
"call",
"(",
"resource_root",
".",
"get",
",",
"_get_role_config_groups_path",
"(",
"cluster_name",
",",
"service_name",
")",
... | Get all role config groups in the specified service.
@param resource_root: The root Resource object.
@param service_name: Service name.
@param cluster_name: Cluster name.
@return: A list of ApiRoleConfigGroup objects.
@since: API v3 | [
"Get",
"all",
"role",
"config",
"groups",
"in",
"the",
"specified",
"service",
"."
] | python | train |
coremke/django-quill | quill/widgets.py | https://github.com/coremke/django-quill/blob/6c5ace1a96e291f0a8e401f6d61d634dd0cb7c9f/quill/widgets.py#L35-L48 | def render(self, name, value, attrs={}):
"""Render the Quill WYSIWYG."""
if value is None:
value = ''
final_attrs = self.build_attrs(attrs, name=name)
quill_app = apps.get_app_config('quill')
quill_config = getattr(quill_app, self.config)
return mark_safe(ren... | [
"def",
"render",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
"=",
"{",
"}",
")",
":",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"''",
"final_attrs",
"=",
"self",
".",
"build_attrs",
"(",
"attrs",
",",
"name",
"=",
"name",
")",
"qu... | Render the Quill WYSIWYG. | [
"Render",
"the",
"Quill",
"WYSIWYG",
"."
] | python | valid |
alvinwan/TexSoup | TexSoup/utils.py | https://github.com/alvinwan/TexSoup/blob/63323ed71510fd2351102b8c36660a3b7703cead/TexSoup/utils.py#L10-L20 | def to_buffer(f):
"""
Decorator converting all strings and iterators/iterables into Buffers.
"""
@functools.wraps(f)
def wrap(*args, **kwargs):
iterator = kwargs.get('iterator', args[0])
if not isinstance(iterator, Buffer):
iterator = Buffer(iterator)
return f(ite... | [
"def",
"to_buffer",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrap",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"iterator",
"=",
"kwargs",
".",
"get",
"(",
"'iterator'",
",",
"args",
"[",
"0",
"]",
")"... | Decorator converting all strings and iterators/iterables into Buffers. | [
"Decorator",
"converting",
"all",
"strings",
"and",
"iterators",
"/",
"iterables",
"into",
"Buffers",
"."
] | python | train |
raymondEhlers/pachyderm | pachyderm/utils.py | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/utils.py#L97-L115 | def get_array_for_fit(observables: dict, track_pt_bin: int, jet_pt_bin: int) -> histogram.Histogram1D:
""" Get a Histogram1D associated with the selected jet and track pt bins.
This is often used to retrieve data for fitting.
Args:
observables (dict): The observables from which the hist should be ... | [
"def",
"get_array_for_fit",
"(",
"observables",
":",
"dict",
",",
"track_pt_bin",
":",
"int",
",",
"jet_pt_bin",
":",
"int",
")",
"->",
"histogram",
".",
"Histogram1D",
":",
"for",
"name",
",",
"observable",
"in",
"observables",
".",
"items",
"(",
")",
":"... | Get a Histogram1D associated with the selected jet and track pt bins.
This is often used to retrieve data for fitting.
Args:
observables (dict): The observables from which the hist should be retrieved.
track_pt_bin (int): Track pt bin of the desired hist.
jet_ptbin (int): Jet pt bin of... | [
"Get",
"a",
"Histogram1D",
"associated",
"with",
"the",
"selected",
"jet",
"and",
"track",
"pt",
"bins",
"."
] | python | train |
BerkeleyAutomation/autolab_core | autolab_core/learning_analysis.py | https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/learning_analysis.py#L599-L625 | def f1_curve(self, delta_tau=0.01):
""" Computes the relationship between probability threshold
and classification F1 score. """
# compute thresholds based on the sorted probabilities
orig_thresh = self.threshold
sorted_labels, sorted_probs = self.sorted_values
scores = ... | [
"def",
"f1_curve",
"(",
"self",
",",
"delta_tau",
"=",
"0.01",
")",
":",
"# compute thresholds based on the sorted probabilities",
"orig_thresh",
"=",
"self",
".",
"threshold",
"sorted_labels",
",",
"sorted_probs",
"=",
"self",
".",
"sorted_values",
"scores",
"=",
"... | Computes the relationship between probability threshold
and classification F1 score. | [
"Computes",
"the",
"relationship",
"between",
"probability",
"threshold",
"and",
"classification",
"F1",
"score",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/layers/common_image_attention.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_image_attention.py#L639-L672 | def create_output(decoder_output, rows, cols, targets, hparams):
"""Creates output from decoder output and vars.
Args:
decoder_output: Tensor of shape [batch, ...], where ... can be any rank such
that the number of elements is batch * rows * cols * hparams.hidden_size.
rows: Integer representing numb... | [
"def",
"create_output",
"(",
"decoder_output",
",",
"rows",
",",
"cols",
",",
"targets",
",",
"hparams",
")",
":",
"del",
"targets",
"# unused arg",
"decoded_image",
"=",
"postprocess_image",
"(",
"decoder_output",
",",
"rows",
",",
"cols",
",",
"hparams",
")"... | Creates output from decoder output and vars.
Args:
decoder_output: Tensor of shape [batch, ...], where ... can be any rank such
that the number of elements is batch * rows * cols * hparams.hidden_size.
rows: Integer representing number of rows in a 2-D data point.
cols: Integer representing number ... | [
"Creates",
"output",
"from",
"decoder",
"output",
"and",
"vars",
"."
] | python | train |
Azure/azure-uamqp-python | uamqp/__init__.py | https://github.com/Azure/azure-uamqp-python/blob/b67e4fcaf2e8a337636947523570239c10a58ae2/uamqp/__init__.py#L43-L67 | def send_message(target, data, auth=None, debug=False):
"""Send a single message to AMQP endpoint.
:param target: The target AMQP endpoint.
:type target: str, bytes or ~uamqp.address.Target
:param data: The contents of the message to send.
:type data: str, bytes or ~uamqp.message.Message
:param... | [
"def",
"send_message",
"(",
"target",
",",
"data",
",",
"auth",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"message",
"=",
"data",
"if",
"isinstance",
"(",
"data",
",",
"Message",
")",
"else",
"Message",
"(",
"body",
"=",
"data",
")",
"with",... | Send a single message to AMQP endpoint.
:param target: The target AMQP endpoint.
:type target: str, bytes or ~uamqp.address.Target
:param data: The contents of the message to send.
:type data: str, bytes or ~uamqp.message.Message
:param auth: The authentication credentials for the endpoint.
Th... | [
"Send",
"a",
"single",
"message",
"to",
"AMQP",
"endpoint",
"."
] | python | train |
SuperCowPowers/bat | bat/utils/vt_query.py | https://github.com/SuperCowPowers/bat/blob/069e6bc52843dc07760969c531cc442ca7da8e0c/bat/utils/vt_query.py#L43-L56 | def query_file(self, file_sha, verbose=False):
"""Query the VirusTotal Service
Args:
file_sha (str): The file sha1 or sha256 hash
url (str): The domain/url to be queried (default=None)
"""
# Sanity check sha hash input
if len(file_sha) not in [6... | [
"def",
"query_file",
"(",
"self",
",",
"file_sha",
",",
"verbose",
"=",
"False",
")",
":",
"# Sanity check sha hash input",
"if",
"len",
"(",
"file_sha",
")",
"not",
"in",
"[",
"64",
",",
"40",
"]",
":",
"# sha256 and sha1 lengths",
"print",
"(",
"'File sha ... | Query the VirusTotal Service
Args:
file_sha (str): The file sha1 or sha256 hash
url (str): The domain/url to be queried (default=None) | [
"Query",
"the",
"VirusTotal",
"Service",
"Args",
":",
"file_sha",
"(",
"str",
")",
":",
"The",
"file",
"sha1",
"or",
"sha256",
"hash",
"url",
"(",
"str",
")",
":",
"The",
"domain",
"/",
"url",
"to",
"be",
"queried",
"(",
"default",
"=",
"None",
")"
] | python | train |
jslang/responsys | responsys/client.py | https://github.com/jslang/responsys/blob/9b355a444c0c75dff41064502c1e2b76dfd5cb93/responsys/client.py#L352-L367 | def delete_table_records(self, table, query_column, ids_to_delete):
""" Responsys.deleteTableRecords call
Accepts:
InteractObject table
string query_column
possible values: 'RIID'|'EMAIL_ADDRESS'|'CUSTOMER_ID'|'MOBILE_NUMBER'
list ids_to_delete
... | [
"def",
"delete_table_records",
"(",
"self",
",",
"table",
",",
"query_column",
",",
"ids_to_delete",
")",
":",
"table",
"=",
"table",
".",
"get_soap_object",
"(",
"self",
".",
"client",
")",
"result",
"=",
"self",
".",
"call",
"(",
"'deleteTableRecords'",
",... | Responsys.deleteTableRecords call
Accepts:
InteractObject table
string query_column
possible values: 'RIID'|'EMAIL_ADDRESS'|'CUSTOMER_ID'|'MOBILE_NUMBER'
list ids_to_delete
Returns a list of DeleteResult instances | [
"Responsys",
".",
"deleteTableRecords",
"call"
] | python | train |
senaite/senaite.core | bika/lims/content/analysisrequest.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/analysisrequest.py#L1584-L1593 | def getLate(self):
"""Return True if there is at least one late analysis in this Request
"""
for analysis in self.getAnalyses():
if analysis.review_state == "retracted":
continue
analysis_obj = api.get_object(analysis)
if analysis_obj.isLateAna... | [
"def",
"getLate",
"(",
"self",
")",
":",
"for",
"analysis",
"in",
"self",
".",
"getAnalyses",
"(",
")",
":",
"if",
"analysis",
".",
"review_state",
"==",
"\"retracted\"",
":",
"continue",
"analysis_obj",
"=",
"api",
".",
"get_object",
"(",
"analysis",
")",... | Return True if there is at least one late analysis in this Request | [
"Return",
"True",
"if",
"there",
"is",
"at",
"least",
"one",
"late",
"analysis",
"in",
"this",
"Request"
] | python | train |
juju/charm-helpers | charmhelpers/contrib/network/ufw.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/network/ufw.py#L72-L106 | def is_ipv6_ok(soft_fail=False):
"""
Check if IPv6 support is present and ip6tables functional
:param soft_fail: If set to True and IPv6 support is broken, then reports
that the host doesn't have IPv6 support, otherwise a
UFWIPv6Error exception is raised.
:re... | [
"def",
"is_ipv6_ok",
"(",
"soft_fail",
"=",
"False",
")",
":",
"# do we have IPv6 in the machine?",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"'/proc/sys/net/ipv6'",
")",
":",
"# is ip6tables kernel module loaded?",
"if",
"not",
"is_module_loaded",
"(",
"'ip6_tables... | Check if IPv6 support is present and ip6tables functional
:param soft_fail: If set to True and IPv6 support is broken, then reports
that the host doesn't have IPv6 support, otherwise a
UFWIPv6Error exception is raised.
:returns: True if IPv6 is working, False otherwi... | [
"Check",
"if",
"IPv6",
"support",
"is",
"present",
"and",
"ip6tables",
"functional"
] | python | train |
totalgood/pugnlp | src/pugnlp/plots.py | https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/plots.py#L284-L289 | def show(self, block=False):
""" Display the last image drawn """
try:
plt.show(block=block)
except ValueError:
plt.show() | [
"def",
"show",
"(",
"self",
",",
"block",
"=",
"False",
")",
":",
"try",
":",
"plt",
".",
"show",
"(",
"block",
"=",
"block",
")",
"except",
"ValueError",
":",
"plt",
".",
"show",
"(",
")"
] | Display the last image drawn | [
"Display",
"the",
"last",
"image",
"drawn"
] | python | train |
asascience-open/paegan-transport | paegan/transport/models/behaviors/lifestage.py | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/models/behaviors/lifestage.py#L141-L168 | def move(self, particle, u, v, w, modelTimestep, **kwargs):
""" I'm dead, so no behaviors should act on me """
# Kill the particle if it isn't settled and isn't already dead.
if not particle.settled and not particle.dead:
particle.die()
# Still save the temperature and sali... | [
"def",
"move",
"(",
"self",
",",
"particle",
",",
"u",
",",
"v",
",",
"w",
",",
"modelTimestep",
",",
"*",
"*",
"kwargs",
")",
":",
"# Kill the particle if it isn't settled and isn't already dead.",
"if",
"not",
"particle",
".",
"settled",
"and",
"not",
"parti... | I'm dead, so no behaviors should act on me | [
"I",
"m",
"dead",
"so",
"no",
"behaviors",
"should",
"act",
"on",
"me"
] | python | train |
dtmilano/AndroidViewClient | src/com/dtmilano/android/adb/adbclient.py | https://github.com/dtmilano/AndroidViewClient/blob/7e6e83fde63af99e5e4ab959712ecf94f9881aa2/src/com/dtmilano/android/adb/adbclient.py#L1037-L1064 | def percentSame(image1, image2):
'''
Returns the percent of pixels that are equal
@author: catshoes
'''
# If the images differ in size, return 0% same.
size_x1, size_y1 = image1.size
size_x2, size_y2 = image2.size
if (size_x1 != size_x2 or
... | [
"def",
"percentSame",
"(",
"image1",
",",
"image2",
")",
":",
"# If the images differ in size, return 0% same.",
"size_x1",
",",
"size_y1",
"=",
"image1",
".",
"size",
"size_x2",
",",
"size_y2",
"=",
"image2",
".",
"size",
"if",
"(",
"size_x1",
"!=",
"size_x2",
... | Returns the percent of pixels that are equal
@author: catshoes | [
"Returns",
"the",
"percent",
"of",
"pixels",
"that",
"are",
"equal"
] | python | train |
GluuFederation/oxd-python | oxdpython/client.py | https://github.com/GluuFederation/oxd-python/blob/a0448cda03b4384bc50a8c20bd65eacd983bceb8/oxdpython/client.py#L513-L536 | def uma_rp_get_claims_gathering_url(self, ticket):
"""UMA RP function to get the claims gathering URL.
Parameters:
* **ticket (str):** ticket to pass to the auth server. for 90% of the cases, this will be obtained from 'need_info' error of get_rpt
Returns:
**string** sp... | [
"def",
"uma_rp_get_claims_gathering_url",
"(",
"self",
",",
"ticket",
")",
":",
"params",
"=",
"{",
"'oxd_id'",
":",
"self",
".",
"oxd_id",
",",
"'claims_redirect_uri'",
":",
"self",
".",
"config",
".",
"get",
"(",
"'client'",
",",
"'claims_redirect_uri'",
")"... | UMA RP function to get the claims gathering URL.
Parameters:
* **ticket (str):** ticket to pass to the auth server. for 90% of the cases, this will be obtained from 'need_info' error of get_rpt
Returns:
**string** specifying the claims gathering url | [
"UMA",
"RP",
"function",
"to",
"get",
"the",
"claims",
"gathering",
"URL",
"."
] | python | train |
zhmcclient/python-zhmcclient | zhmcclient/_metrics.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_metrics.py#L200-L232 | def create(self, properties):
"""
Create a :term:`Metrics Context` resource in the HMC this client is
connected to.
Parameters:
properties (dict): Initial property values.
Allowable properties are defined in section 'Request body contents'
in section '... | [
"def",
"create",
"(",
"self",
",",
"properties",
")",
":",
"result",
"=",
"self",
".",
"session",
".",
"post",
"(",
"'/api/services/metrics/context'",
",",
"body",
"=",
"properties",
")",
"mc_properties",
"=",
"properties",
".",
"copy",
"(",
")",
"mc_propert... | Create a :term:`Metrics Context` resource in the HMC this client is
connected to.
Parameters:
properties (dict): Initial property values.
Allowable properties are defined in section 'Request body contents'
in section 'Create Metrics Context' in the :term:`HMC API` boo... | [
"Create",
"a",
":",
"term",
":",
"Metrics",
"Context",
"resource",
"in",
"the",
"HMC",
"this",
"client",
"is",
"connected",
"to",
"."
] | python | train |
Contraz/demosys-py | demosys/opengl/vao.py | https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/opengl/vao.py#L246-L294 | def instance(self, program: moderngl.Program) -> moderngl.VertexArray:
"""
Obtain the ``moderngl.VertexArray`` instance for the program.
The instance is only created once and cached internally.
Returns: ``moderngl.VertexArray`` instance
"""
vao = self.vaos.get(program.gl... | [
"def",
"instance",
"(",
"self",
",",
"program",
":",
"moderngl",
".",
"Program",
")",
"->",
"moderngl",
".",
"VertexArray",
":",
"vao",
"=",
"self",
".",
"vaos",
".",
"get",
"(",
"program",
".",
"glo",
")",
"if",
"vao",
":",
"return",
"vao",
"program... | Obtain the ``moderngl.VertexArray`` instance for the program.
The instance is only created once and cached internally.
Returns: ``moderngl.VertexArray`` instance | [
"Obtain",
"the",
"moderngl",
".",
"VertexArray",
"instance",
"for",
"the",
"program",
".",
"The",
"instance",
"is",
"only",
"created",
"once",
"and",
"cached",
"internally",
"."
] | python | valid |
hobson/pug-dj | pug/dj/crawlnmine/management/__init__.py | https://github.com/hobson/pug-dj/blob/55678b08755a55366ce18e7d3b8ea8fa4491ab04/pug/dj/crawlnmine/management/__init__.py#L166-L187 | def fetch_command(self, subcommand):
"""
Tries to fetch the given subcommand, printing a message with the
appropriate command called from the command line (usually
"jira.py") if it can't be found.
"""
# Get commands outside of try block to prevent swallowing exceptions
... | [
"def",
"fetch_command",
"(",
"self",
",",
"subcommand",
")",
":",
"# Get commands outside of try block to prevent swallowing exceptions",
"commands",
"=",
"get_commands",
"(",
")",
"try",
":",
"app_name",
"=",
"commands",
"[",
"subcommand",
"]",
"except",
"KeyError",
... | Tries to fetch the given subcommand, printing a message with the
appropriate command called from the command line (usually
"jira.py") if it can't be found. | [
"Tries",
"to",
"fetch",
"the",
"given",
"subcommand",
"printing",
"a",
"message",
"with",
"the",
"appropriate",
"command",
"called",
"from",
"the",
"command",
"line",
"(",
"usually",
"jira",
".",
"py",
")",
"if",
"it",
"can",
"t",
"be",
"found",
"."
] | python | train |
jjgomera/iapws | iapws/iapws97.py | https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/iapws97.py#L706-L800 | def _Region1(T, P):
"""Basic equation for region 1
Parameters
----------
T : float
Temperature, [K]
P : float
Pressure, [MPa]
Returns
-------
prop : dict
Dict with calculated properties. The available properties are:
* v: Specific volume, [m³/kg]
... | [
"def",
"_Region1",
"(",
"T",
",",
"P",
")",
":",
"if",
"P",
"<",
"0",
":",
"P",
"=",
"Pmin",
"I",
"=",
"[",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1... | Basic equation for region 1
Parameters
----------
T : float
Temperature, [K]
P : float
Pressure, [MPa]
Returns
-------
prop : dict
Dict with calculated properties. The available properties are:
* v: Specific volume, [m³/kg]
* h: Specific ent... | [
"Basic",
"equation",
"for",
"region",
"1"
] | python | train |
Crunch-io/crunch-cube | src/cr/cube/crunch_cube.py | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/crunch_cube.py#L1344-L1350 | def _update_result(self, result, insertions, dimension_index):
"""Insert subtotals into resulting ndarray."""
for j, (ind_insertion, value) in enumerate(insertions):
result = np.insert(
result, ind_insertion + j + 1, value, axis=dimension_index
)
return re... | [
"def",
"_update_result",
"(",
"self",
",",
"result",
",",
"insertions",
",",
"dimension_index",
")",
":",
"for",
"j",
",",
"(",
"ind_insertion",
",",
"value",
")",
"in",
"enumerate",
"(",
"insertions",
")",
":",
"result",
"=",
"np",
".",
"insert",
"(",
... | Insert subtotals into resulting ndarray. | [
"Insert",
"subtotals",
"into",
"resulting",
"ndarray",
"."
] | python | train |
maljovec/topopy | topopy/ContourTree.py | https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/ContourTree.py#L350-L472 | def _process_tree(self, thisTree, thatTree):
""" A function that will process either a split or join tree
with reference to the other tree and store it as part of
this CT instance.
@ In, thisTree, a networkx.Graph instance representing a
merge tree for which w... | [
"def",
"_process_tree",
"(",
"self",
",",
"thisTree",
",",
"thatTree",
")",
":",
"if",
"self",
".",
"debug",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"\"Processing Tree: \"",
")",
"start",
"=",
"time",
".",
"clock",
"(",
")",
"# Get all of the leaf no... | A function that will process either a split or join tree
with reference to the other tree and store it as part of
this CT instance.
@ In, thisTree, a networkx.Graph instance representing a
merge tree for which we will process all of its leaf
nodes into... | [
"A",
"function",
"that",
"will",
"process",
"either",
"a",
"split",
"or",
"join",
"tree",
"with",
"reference",
"to",
"the",
"other",
"tree",
"and",
"store",
"it",
"as",
"part",
"of",
"this",
"CT",
"instance",
"."
] | python | train |
saltstack/salt | salt/modules/napalm_network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_network.py#L2238-L2262 | def cancel_commit(jid):
'''
.. versionadded:: 2019.2.0
Cancel a commit scheduled to be executed via the ``commit_in`` and
``commit_at`` arguments from the
:py:func:`net.load_template <salt.modules.napalm_network.load_template>` or
:py:func:`net.load_config <salt.modules.napalm_network.load_conf... | [
"def",
"cancel_commit",
"(",
"jid",
")",
":",
"job_name",
"=",
"'__napalm_commit_{}'",
".",
"format",
"(",
"jid",
")",
"removed",
"=",
"__salt__",
"[",
"'schedule.delete'",
"]",
"(",
"job_name",
")",
"if",
"removed",
"[",
"'result'",
"]",
":",
"saved",
"="... | .. versionadded:: 2019.2.0
Cancel a commit scheduled to be executed via the ``commit_in`` and
``commit_at`` arguments from the
:py:func:`net.load_template <salt.modules.napalm_network.load_template>` or
:py:func:`net.load_config <salt.modules.napalm_network.load_config>`
execution functions. The co... | [
"..",
"versionadded",
"::",
"2019",
".",
"2",
".",
"0"
] | python | train |
julienr/meshcut | meshcut.py | https://github.com/julienr/meshcut/blob/226c79d8da52b657d904f783940c258093c929a5/meshcut.py#L306-L347 | def merge_close_vertices(verts, faces, close_epsilon=1e-5):
"""
Will merge vertices that are closer than close_epsilon.
Warning, this has a O(n^2) memory usage because we compute the full
vert-to-vert distance matrix. If you have a large mesh, might want
to use some kind of spatial search structure... | [
"def",
"merge_close_vertices",
"(",
"verts",
",",
"faces",
",",
"close_epsilon",
"=",
"1e-5",
")",
":",
"# Pairwise distance between verts",
"if",
"USE_SCIPY",
":",
"D",
"=",
"spdist",
".",
"cdist",
"(",
"verts",
",",
"verts",
")",
"else",
":",
"D",
"=",
"... | Will merge vertices that are closer than close_epsilon.
Warning, this has a O(n^2) memory usage because we compute the full
vert-to-vert distance matrix. If you have a large mesh, might want
to use some kind of spatial search structure like an octree or some fancy
hashing scheme
Returns: new_verts... | [
"Will",
"merge",
"vertices",
"that",
"are",
"closer",
"than",
"close_epsilon",
"."
] | python | train |
GNS3/gns3-server | gns3server/compute/iou/iou_vm.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L188-L214 | def _check_requirements(self):
"""
Checks the IOU image.
"""
if not self._path:
raise IOUError("IOU image is not configured")
if not os.path.isfile(self._path) or not os.path.exists(self._path):
if os.path.islink(self._path):
raise IOUErro... | [
"def",
"_check_requirements",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_path",
":",
"raise",
"IOUError",
"(",
"\"IOU image is not configured\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"_path",
")",
"or",
"not",
"os... | Checks the IOU image. | [
"Checks",
"the",
"IOU",
"image",
"."
] | python | train |
rueckstiess/mtools | mtools/util/profile_collection.py | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/profile_collection.py#L117-L131 | def _calculate_bounds(self):
"""Calculate beginning and end of log events."""
# get start datetime
first = self.coll_handle.find_one(None, sort=[("ts", ASCENDING)])
last = self.coll_handle.find_one(None, sort=[("ts", DESCENDING)])
self._start = first['ts']
if self._start... | [
"def",
"_calculate_bounds",
"(",
"self",
")",
":",
"# get start datetime",
"first",
"=",
"self",
".",
"coll_handle",
".",
"find_one",
"(",
"None",
",",
"sort",
"=",
"[",
"(",
"\"ts\"",
",",
"ASCENDING",
")",
"]",
")",
"last",
"=",
"self",
".",
"coll_hand... | Calculate beginning and end of log events. | [
"Calculate",
"beginning",
"and",
"end",
"of",
"log",
"events",
"."
] | python | train |
waleedka/hiddenlayer | hiddenlayer/utils.py | https://github.com/waleedka/hiddenlayer/blob/294f8732b271cbdd6310c55bdf5ce855cbf61c75/hiddenlayer/utils.py#L17-L35 | def to_data(value):
"""Standardize data types. Converts PyTorch tensors to Numpy arrays,
and Numpy scalars to Python scalars."""
# TODO: Use get_framework() for better detection.
if value.__class__.__module__.startswith("torch"):
import torch
if isinstance(value, torch.nn.parameter.Param... | [
"def",
"to_data",
"(",
"value",
")",
":",
"# TODO: Use get_framework() for better detection.",
"if",
"value",
".",
"__class__",
".",
"__module__",
".",
"startswith",
"(",
"\"torch\"",
")",
":",
"import",
"torch",
"if",
"isinstance",
"(",
"value",
",",
"torch",
"... | Standardize data types. Converts PyTorch tensors to Numpy arrays,
and Numpy scalars to Python scalars. | [
"Standardize",
"data",
"types",
".",
"Converts",
"PyTorch",
"tensors",
"to",
"Numpy",
"arrays",
"and",
"Numpy",
"scalars",
"to",
"Python",
"scalars",
"."
] | python | train |
ga4gh/ga4gh-server | ga4gh/server/datamodel/peers.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/peers.py#L17-L36 | def isUrl(urlString):
"""
Attempts to return whether a given URL string is valid by checking
for the presence of the URL scheme and netloc using the urlparse
module, and then using a regex.
From http://stackoverflow.com/questions/7160737/
"""
parsed = urlparse.urlparse(urlString)
urlpar... | [
"def",
"isUrl",
"(",
"urlString",
")",
":",
"parsed",
"=",
"urlparse",
".",
"urlparse",
"(",
"urlString",
")",
"urlparseValid",
"=",
"parsed",
".",
"netloc",
"!=",
"''",
"and",
"parsed",
".",
"scheme",
"!=",
"''",
"regex",
"=",
"re",
".",
"compile",
"(... | Attempts to return whether a given URL string is valid by checking
for the presence of the URL scheme and netloc using the urlparse
module, and then using a regex.
From http://stackoverflow.com/questions/7160737/ | [
"Attempts",
"to",
"return",
"whether",
"a",
"given",
"URL",
"string",
"is",
"valid",
"by",
"checking",
"for",
"the",
"presence",
"of",
"the",
"URL",
"scheme",
"and",
"netloc",
"using",
"the",
"urlparse",
"module",
"and",
"then",
"using",
"a",
"regex",
"."
... | python | train |
pymc-devs/pymc | pymc/PyMCObjects.py | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/PyMCObjects.py#L63-L86 | def extend_parents(parents):
"""
extend_parents(parents)
Returns a set containing
nearest conditionally stochastic (Stochastic, not Deterministic) ancestors.
"""
new_parents = set()
for parent in parents:
new_parents.add(parent)
if isinstance(parent, DeterministicBase):
... | [
"def",
"extend_parents",
"(",
"parents",
")",
":",
"new_parents",
"=",
"set",
"(",
")",
"for",
"parent",
"in",
"parents",
":",
"new_parents",
".",
"add",
"(",
"parent",
")",
"if",
"isinstance",
"(",
"parent",
",",
"DeterministicBase",
")",
":",
"new_parent... | extend_parents(parents)
Returns a set containing
nearest conditionally stochastic (Stochastic, not Deterministic) ancestors. | [
"extend_parents",
"(",
"parents",
")"
] | python | train |
Xion/taipan | taipan/collections/dicts.py | https://github.com/Xion/taipan/blob/f333f0287c8bd0915182c7d5308e5f05ef0cca78/taipan/collections/dicts.py#L511-L524 | def invert(dict_):
"""Return an inverted dictionary, where former values are keys
and former keys are values.
.. warning::
If more than one key maps to any given value in input dictionary,
it is undefined which one will be chosen for the result.
:param dict_: Dictionary to swap keys a... | [
"def",
"invert",
"(",
"dict_",
")",
":",
"ensure_mapping",
"(",
"dict_",
")",
"return",
"dict_",
".",
"__class__",
"(",
"izip",
"(",
"itervalues",
"(",
"dict_",
")",
",",
"iterkeys",
"(",
"dict_",
")",
")",
")"
] | Return an inverted dictionary, where former values are keys
and former keys are values.
.. warning::
If more than one key maps to any given value in input dictionary,
it is undefined which one will be chosen for the result.
:param dict_: Dictionary to swap keys and values in
:return: ... | [
"Return",
"an",
"inverted",
"dictionary",
"where",
"former",
"values",
"are",
"keys",
"and",
"former",
"keys",
"are",
"values",
"."
] | python | train |
tshlabs/tunic | tunic/core.py | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/core.py#L329-L356 | def get_previous_release(self):
"""Get the release ID of the deployment immediately
before the "current" deployment, ``None`` if no previous
release could be determined.
This method performs two network operations.
:return: The release ID of the release previous to the
... | [
"def",
"get_previous_release",
"(",
"self",
")",
":",
"releases",
"=",
"self",
".",
"get_releases",
"(",
")",
"if",
"not",
"releases",
":",
"return",
"None",
"current",
"=",
"self",
".",
"get_current_release",
"(",
")",
"if",
"not",
"current",
":",
"return... | Get the release ID of the deployment immediately
before the "current" deployment, ``None`` if no previous
release could be determined.
This method performs two network operations.
:return: The release ID of the release previous to the
"current" release.
:rtype: str | [
"Get",
"the",
"release",
"ID",
"of",
"the",
"deployment",
"immediately",
"before",
"the",
"current",
"deployment",
"None",
"if",
"no",
"previous",
"release",
"could",
"be",
"determined",
"."
] | python | train |
inasafe/inasafe | scripts/create_api_docs.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/scripts/create_api_docs.py#L161-L182 | def create_top_level_index(api_docs_path, packages, max_depth=2):
"""Create the top level index page (writing to file)
:param api_docs_path: Path to the api-docs of inasafe documentation.
:type api_docs_path: str
:param packages: List of packages which want to be extracted their api/
:type package... | [
"def",
"create_top_level_index",
"(",
"api_docs_path",
",",
"packages",
",",
"max_depth",
"=",
"2",
")",
":",
"page_text",
"=",
"INDEX_HEADER",
"for",
"package",
"in",
"packages",
":",
"# Write top level index file entries for safe",
"text",
"=",
"create_top_level_index... | Create the top level index page (writing to file)
:param api_docs_path: Path to the api-docs of inasafe documentation.
:type api_docs_path: str
:param packages: List of packages which want to be extracted their api/
:type packages: list
:param max_depth: The maximum depth of tree in the api docs.... | [
"Create",
"the",
"top",
"level",
"index",
"page",
"(",
"writing",
"to",
"file",
")"
] | python | train |
vatlab/SoS | src/sos/step_executor.py | https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/src/sos/step_executor.py#L209-L221 | def expand_depends_files(*args, **kwargs):
'''handle directive depends'''
args = [x.resolve() if isinstance(x, dynamic) else x for x in args]
kwargs = {
x: (y.resolve() if isinstance(y, dynamic) else y)
for x, y in kwargs.items()
}
return sos_targets(
*args,
**kwargs,... | [
"def",
"expand_depends_files",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"[",
"x",
".",
"resolve",
"(",
")",
"if",
"isinstance",
"(",
"x",
",",
"dynamic",
")",
"else",
"x",
"for",
"x",
"in",
"args",
"]",
"kwargs",
"=",
"{"... | handle directive depends | [
"handle",
"directive",
"depends"
] | python | train |
ethpm/py-ethpm | ethpm/utils/ipfs.py | https://github.com/ethpm/py-ethpm/blob/81ed58d7c636fe00c6770edeb0401812b1a5e8fc/ethpm/utils/ipfs.py#L44-L54 | def is_ipfs_uri(value: str) -> bool:
"""
Return a bool indicating whether or not the value is a valid IPFS URI.
"""
parse_result = parse.urlparse(value)
if parse_result.scheme != "ipfs":
return False
if not parse_result.netloc and not parse_result.path:
return False
return T... | [
"def",
"is_ipfs_uri",
"(",
"value",
":",
"str",
")",
"->",
"bool",
":",
"parse_result",
"=",
"parse",
".",
"urlparse",
"(",
"value",
")",
"if",
"parse_result",
".",
"scheme",
"!=",
"\"ipfs\"",
":",
"return",
"False",
"if",
"not",
"parse_result",
".",
"ne... | Return a bool indicating whether or not the value is a valid IPFS URI. | [
"Return",
"a",
"bool",
"indicating",
"whether",
"or",
"not",
"the",
"value",
"is",
"a",
"valid",
"IPFS",
"URI",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/electronic_structure/boltztrap.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/electronic_structure/boltztrap.py#L2013-L2076 | def from_files(path_dir, dos_spin=1):
"""
get a BoltztrapAnalyzer object from a set of files
Args:
path_dir: directory where the boltztrap files are
dos_spin: in DOS mode, set to 1 for spin up and -1 for spin down
Returns:
a BoltztrapAnalyzer object
... | [
"def",
"from_files",
"(",
"path_dir",
",",
"dos_spin",
"=",
"1",
")",
":",
"run_type",
",",
"warning",
",",
"efermi",
",",
"gap",
",",
"doping_levels",
"=",
"BoltztrapAnalyzer",
".",
"parse_outputtrans",
"(",
"path_dir",
")",
"vol",
"=",
"BoltztrapAnalyzer",
... | get a BoltztrapAnalyzer object from a set of files
Args:
path_dir: directory where the boltztrap files are
dos_spin: in DOS mode, set to 1 for spin up and -1 for spin down
Returns:
a BoltztrapAnalyzer object | [
"get",
"a",
"BoltztrapAnalyzer",
"object",
"from",
"a",
"set",
"of",
"files"
] | python | train |
moonso/ped_parser | ped_parser/family.py | https://github.com/moonso/ped_parser/blob/a7393e47139532782ea3c821aabea33d46f94323/ped_parser/family.py#L214-L230 | def get_phenotype(self, individual_id):
"""
Return the phenotype of an individual
If individual does not exist return 0
Arguments:
individual_id (str): Represents the individual id
Returns:
int : Integer that represents the pheno... | [
"def",
"get_phenotype",
"(",
"self",
",",
"individual_id",
")",
":",
"phenotype",
"=",
"0",
"# This is if unknown phenotype",
"if",
"individual_id",
"in",
"self",
".",
"individuals",
":",
"phenotype",
"=",
"self",
".",
"individuals",
"[",
"individual_id",
"]",
"... | Return the phenotype of an individual
If individual does not exist return 0
Arguments:
individual_id (str): Represents the individual id
Returns:
int : Integer that represents the phenotype | [
"Return",
"the",
"phenotype",
"of",
"an",
"individual",
"If",
"individual",
"does",
"not",
"exist",
"return",
"0",
"Arguments",
":",
"individual_id",
"(",
"str",
")",
":",
"Represents",
"the",
"individual",
"id",
"Returns",
":",
"int",
":",
"Integer",
"that"... | python | train |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/thread.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/thread.py#L2005-L2024 | def _add_thread(self, aThread):
"""
Private method to add a thread object to the snapshot.
@type aThread: L{Thread}
@param aThread: Thread object.
"""
## if not isinstance(aThread, Thread):
## if hasattr(aThread, '__class__'):
## typename = aThr... | [
"def",
"_add_thread",
"(",
"self",
",",
"aThread",
")",
":",
"## if not isinstance(aThread, Thread):",
"## if hasattr(aThread, '__class__'):",
"## typename = aThread.__class__.__name__",
"## else:",
"## typename = str(type(aThread))"... | Private method to add a thread object to the snapshot.
@type aThread: L{Thread}
@param aThread: Thread object. | [
"Private",
"method",
"to",
"add",
"a",
"thread",
"object",
"to",
"the",
"snapshot",
"."
] | python | train |
apache/incubator-heron | heronpy/api/stream.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heronpy/api/stream.py#L84-L97 | def is_grouping_sane(cls, gtype):
"""Checks if a given gtype is sane"""
if gtype == cls.SHUFFLE or gtype == cls.ALL or gtype == cls.LOWEST or gtype == cls.NONE:
return True
elif isinstance(gtype, cls.FIELDS):
return gtype.gtype == topology_pb2.Grouping.Value("FIELDS") and \
gtype.fi... | [
"def",
"is_grouping_sane",
"(",
"cls",
",",
"gtype",
")",
":",
"if",
"gtype",
"==",
"cls",
".",
"SHUFFLE",
"or",
"gtype",
"==",
"cls",
".",
"ALL",
"or",
"gtype",
"==",
"cls",
".",
"LOWEST",
"or",
"gtype",
"==",
"cls",
".",
"NONE",
":",
"return",
"T... | Checks if a given gtype is sane | [
"Checks",
"if",
"a",
"given",
"gtype",
"is",
"sane"
] | python | valid |
facebook/pyre-check | sapp/sapp/models.py | https://github.com/facebook/pyre-check/blob/4a9604d943d28ef20238505a51acfb1f666328d7/sapp/sapp/models.py#L87-L94 | def prepare(cls, session, pkgen, items):
"""This is called immediately before the items are written to the
database. pkgen is passed in to allow last-minute resolving of ids.
"""
for item in cls.merge(session, items):
if hasattr(item, "id"):
item.id.resolve(id... | [
"def",
"prepare",
"(",
"cls",
",",
"session",
",",
"pkgen",
",",
"items",
")",
":",
"for",
"item",
"in",
"cls",
".",
"merge",
"(",
"session",
",",
"items",
")",
":",
"if",
"hasattr",
"(",
"item",
",",
"\"id\"",
")",
":",
"item",
".",
"id",
".",
... | This is called immediately before the items are written to the
database. pkgen is passed in to allow last-minute resolving of ids. | [
"This",
"is",
"called",
"immediately",
"before",
"the",
"items",
"are",
"written",
"to",
"the",
"database",
".",
"pkgen",
"is",
"passed",
"in",
"to",
"allow",
"last",
"-",
"minute",
"resolving",
"of",
"ids",
"."
] | python | train |
portfors-lab/sparkle | sparkle/gui/stim/stimulusview.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/stimulusview.py#L381-L393 | def updateSelectionModel(self, components):
"""Creates a new selection model and adds *components* to it
:param components: components in this view to add to the selection
:type components: list<:class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>`
... | [
"def",
"updateSelectionModel",
"(",
"self",
",",
"components",
")",
":",
"# selmodel = self.selectionModel()",
"# selmodel.clearSelection()",
"selmodel",
"=",
"ComponentSelectionModel",
"(",
"self",
".",
"model",
"(",
")",
")",
"self",
".",
"setSelectionModel",
"(",
"... | Creates a new selection model and adds *components* to it
:param components: components in this view to add to the selection
:type components: list<:class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>` | [
"Creates",
"a",
"new",
"selection",
"model",
"and",
"adds",
"*",
"components",
"*",
"to",
"it"
] | python | train |
emillon/mixcloud | mixcloud/__init__.py | https://github.com/emillon/mixcloud/blob/da4c7a70444c7f1712ee13e3a93eb1cd9c3f4ab8/mixcloud/__init__.py#L57-L71 | def exchange_token(self, code):
"""
Exchange the authorization code for an access token.
"""
access_token_url = OAUTH_ROOT + '/access_token'
params = {
'client_id': self.client_id,
'client_secret': self.client_secret,
'redirect_uri': self.redir... | [
"def",
"exchange_token",
"(",
"self",
",",
"code",
")",
":",
"access_token_url",
"=",
"OAUTH_ROOT",
"+",
"'/access_token'",
"params",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'client_secret'",
":",
"self",
".",
"client_secret",
",",
"'redi... | Exchange the authorization code for an access token. | [
"Exchange",
"the",
"authorization",
"code",
"for",
"an",
"access",
"token",
"."
] | python | valid |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/util/bottle3.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/util/bottle3.py#L308-L318 | def match(self, uri):
''' Matches an URL and returns a (handler, target) tuple '''
if uri in self.static:
return self.static[uri], {}
for combined, subroutes in self.dynamic:
match = combined.match(uri)
if not match: continue
target, groups = subro... | [
"def",
"match",
"(",
"self",
",",
"uri",
")",
":",
"if",
"uri",
"in",
"self",
".",
"static",
":",
"return",
"self",
".",
"static",
"[",
"uri",
"]",
",",
"{",
"}",
"for",
"combined",
",",
"subroutes",
"in",
"self",
".",
"dynamic",
":",
"match",
"=... | Matches an URL and returns a (handler, target) tuple | [
"Matches",
"an",
"URL",
"and",
"returns",
"a",
"(",
"handler",
"target",
")",
"tuple"
] | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L7675-L7712 | def check_signature(self, msgbuf, srcSystem, srcComponent):
'''check signature on incoming message'''
if isinstance(msgbuf, array.array):
msgbuf = msgbuf.tostring()
timestamp_buf = msgbuf[-12:-6]
link_id = msgbuf[-13]
(tlow, thigh) = struct.unp... | [
"def",
"check_signature",
"(",
"self",
",",
"msgbuf",
",",
"srcSystem",
",",
"srcComponent",
")",
":",
"if",
"isinstance",
"(",
"msgbuf",
",",
"array",
".",
"array",
")",
":",
"msgbuf",
"=",
"msgbuf",
".",
"tostring",
"(",
")",
"timestamp_buf",
"=",
"msg... | check signature on incoming message | [
"check",
"signature",
"on",
"incoming",
"message"
] | python | train |
marrow/util | marrow/util/object.py | https://github.com/marrow/util/blob/abb8163dbd1fa0692d42a44d129b12ae2b39cdf2/marrow/util/object.py#L253-L308 | def getargspec(obj):
"""An improved inspect.getargspec.
Has a slightly different return value from the default getargspec.
Returns a tuple of:
required, optional, args, kwargs
list, dict, bool, bool
Required is a list of required named arguments.
Optional is a dictionary mapping o... | [
"def",
"getargspec",
"(",
"obj",
")",
":",
"argnames",
",",
"varargs",
",",
"varkw",
",",
"_defaults",
"=",
"None",
",",
"None",
",",
"None",
",",
"None",
"if",
"inspect",
".",
"isfunction",
"(",
"obj",
")",
"or",
"inspect",
".",
"ismethod",
"(",
"ob... | An improved inspect.getargspec.
Has a slightly different return value from the default getargspec.
Returns a tuple of:
required, optional, args, kwargs
list, dict, bool, bool
Required is a list of required named arguments.
Optional is a dictionary mapping optional arguments to default... | [
"An",
"improved",
"inspect",
".",
"getargspec",
"."
] | python | train |
GNS3/gns3-server | gns3server/controller/node.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/node.py#L418-L450 | def _node_data(self, properties=None):
"""
Prepare node data to send to the remote controller
:param properties: If properties is None use actual property otherwise use the parameter
"""
if properties:
data = copy.copy(properties)
else:
data = cop... | [
"def",
"_node_data",
"(",
"self",
",",
"properties",
"=",
"None",
")",
":",
"if",
"properties",
":",
"data",
"=",
"copy",
".",
"copy",
"(",
"properties",
")",
"else",
":",
"data",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"_properties",
")",
"# We ... | Prepare node data to send to the remote controller
:param properties: If properties is None use actual property otherwise use the parameter | [
"Prepare",
"node",
"data",
"to",
"send",
"to",
"the",
"remote",
"controller"
] | python | train |
avelino/bottle-auth | bottle_auth/core/httputil.py | https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L179-L189 | def url_concat(url, args):
"""Concatenate url and argument dictionary regardless of whether
url has existing query parameters.
>>> url_concat("http://example.com/foo?a=b", dict(c="d"))
'http://example.com/foo?a=b&c=d'
"""
if not args: return url
if url[-1] not in ('?', '&'):
url += ... | [
"def",
"url_concat",
"(",
"url",
",",
"args",
")",
":",
"if",
"not",
"args",
":",
"return",
"url",
"if",
"url",
"[",
"-",
"1",
"]",
"not",
"in",
"(",
"'?'",
",",
"'&'",
")",
":",
"url",
"+=",
"'&'",
"if",
"(",
"'?'",
"in",
"url",
")",
"else",... | Concatenate url and argument dictionary regardless of whether
url has existing query parameters.
>>> url_concat("http://example.com/foo?a=b", dict(c="d"))
'http://example.com/foo?a=b&c=d' | [
"Concatenate",
"url",
"and",
"argument",
"dictionary",
"regardless",
"of",
"whether",
"url",
"has",
"existing",
"query",
"parameters",
"."
] | python | test |
alex-sherman/unsync | examples/mixing_methods.py | https://github.com/alex-sherman/unsync/blob/a52a0b04980dcaf6dc2fd734aa9d7be9d8960bbe/examples/mixing_methods.py#L16-L22 | async def result_continuation(task):
"""A preliminary result processor we'll chain on to the original task
This will get executed wherever the source task was executed, in this
case one of the threads in the ThreadPoolExecutor"""
await asyncio.sleep(0.1)
num, res = task.result()
return num... | [
"async",
"def",
"result_continuation",
"(",
"task",
")",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"0.1",
")",
"num",
",",
"res",
"=",
"task",
".",
"result",
"(",
")",
"return",
"num",
",",
"res",
"*",
"2"
] | A preliminary result processor we'll chain on to the original task
This will get executed wherever the source task was executed, in this
case one of the threads in the ThreadPoolExecutor | [
"A",
"preliminary",
"result",
"processor",
"we",
"ll",
"chain",
"on",
"to",
"the",
"original",
"task",
"This",
"will",
"get",
"executed",
"wherever",
"the",
"source",
"task",
"was",
"executed",
"in",
"this",
"case",
"one",
"of",
"the",
"threads",
"in",
"th... | python | train |
rueckstiess/mtools | mtools/util/logevent.py | https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L701-L719 | def _extract_level(self):
"""Extract level and component if available (lazy)."""
if self._level is None:
split_tokens = self.split_tokens
if not split_tokens:
self._level = False
self._component = False
return
x = (sel... | [
"def",
"_extract_level",
"(",
"self",
")",
":",
"if",
"self",
".",
"_level",
"is",
"None",
":",
"split_tokens",
"=",
"self",
".",
"split_tokens",
"if",
"not",
"split_tokens",
":",
"self",
".",
"_level",
"=",
"False",
"self",
".",
"_component",
"=",
"Fals... | Extract level and component if available (lazy). | [
"Extract",
"level",
"and",
"component",
"if",
"available",
"(",
"lazy",
")",
"."
] | python | train |
boakley/robotframework-hub | rfhub/blueprints/doc/__init__.py | https://github.com/boakley/robotframework-hub/blob/f3dc7562fe6218a7b8d7aac7b9ef234e1a573f7c/rfhub/blueprints/doc/__init__.py#L129-L136 | def get_collections(kwdb, libtype="*"):
"""Get list of collections from kwdb, then add urls necessary for hyperlinks"""
collections = kwdb.get_collections(libtype=libtype)
for result in collections:
url = flask.url_for(".doc_for_library", collection_id=result["collection_id"])
result["url"] ... | [
"def",
"get_collections",
"(",
"kwdb",
",",
"libtype",
"=",
"\"*\"",
")",
":",
"collections",
"=",
"kwdb",
".",
"get_collections",
"(",
"libtype",
"=",
"libtype",
")",
"for",
"result",
"in",
"collections",
":",
"url",
"=",
"flask",
".",
"url_for",
"(",
"... | Get list of collections from kwdb, then add urls necessary for hyperlinks | [
"Get",
"list",
"of",
"collections",
"from",
"kwdb",
"then",
"add",
"urls",
"necessary",
"for",
"hyperlinks"
] | python | train |
KE-works/pykechain | pykechain/models/service.py | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/models/service.py#L232-L236 | def service(self):
"""Retrieve the `Service` object to which this execution is associated."""
if not self._service:
self._service = self._client.service(id=self.service_id)
return self._service | [
"def",
"service",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_service",
":",
"self",
".",
"_service",
"=",
"self",
".",
"_client",
".",
"service",
"(",
"id",
"=",
"self",
".",
"service_id",
")",
"return",
"self",
".",
"_service"
] | Retrieve the `Service` object to which this execution is associated. | [
"Retrieve",
"the",
"Service",
"object",
"to",
"which",
"this",
"execution",
"is",
"associated",
"."
] | python | train |
cmap/cmapPy | cmapPy/pandasGEXpress/parse_gctx.py | https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/pandasGEXpress/parse_gctx.py#L371-L391 | def get_row_metadata(gctx_file_path, convert_neg_666=True):
"""
Opens .gctx file and returns only row metadata
Input:
Mandatory:
- gctx_file_path (str): full path to gctx file you want to parse.
Optional:
- convert_neg_666 (bool): whether to convert -666 values to num
... | [
"def",
"get_row_metadata",
"(",
"gctx_file_path",
",",
"convert_neg_666",
"=",
"True",
")",
":",
"full_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"gctx_file_path",
")",
"# open file",
"gctx_file",
"=",
"h5py",
".",
"File",
"(",
"full_path",
",",
... | Opens .gctx file and returns only row metadata
Input:
Mandatory:
- gctx_file_path (str): full path to gctx file you want to parse.
Optional:
- convert_neg_666 (bool): whether to convert -666 values to num
Output:
- row_meta (pandas DataFrame): a DataFrame of all row me... | [
"Opens",
".",
"gctx",
"file",
"and",
"returns",
"only",
"row",
"metadata"
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/utils/diet.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/diet.py#L253-L257 | def _dequantize(q, params):
"""Dequantize q according to params."""
if not params.quantize:
return q
return tf.to_float(tf.bitcast(q, tf.int16)) * params.quantization_scale | [
"def",
"_dequantize",
"(",
"q",
",",
"params",
")",
":",
"if",
"not",
"params",
".",
"quantize",
":",
"return",
"q",
"return",
"tf",
".",
"to_float",
"(",
"tf",
".",
"bitcast",
"(",
"q",
",",
"tf",
".",
"int16",
")",
")",
"*",
"params",
".",
"qua... | Dequantize q according to params. | [
"Dequantize",
"q",
"according",
"to",
"params",
"."
] | python | train |
njsmith/colorspacious | colorspacious/conversion.py | https://github.com/njsmith/colorspacious/blob/59e0226003fb1b894597c5081e8ca5a3aa4fcefd/colorspacious/conversion.py#L222-L232 | def cspace_convert(arr, start, end):
"""Converts the colors in ``arr`` from colorspace ``start`` to colorspace
``end``.
:param arr: An array-like of colors.
:param start, end: Any supported colorspace specifiers. See
:ref:`supported-colorspaces` for details.
"""
converter = cspace_conv... | [
"def",
"cspace_convert",
"(",
"arr",
",",
"start",
",",
"end",
")",
":",
"converter",
"=",
"cspace_converter",
"(",
"start",
",",
"end",
")",
"return",
"converter",
"(",
"arr",
")"
] | Converts the colors in ``arr`` from colorspace ``start`` to colorspace
``end``.
:param arr: An array-like of colors.
:param start, end: Any supported colorspace specifiers. See
:ref:`supported-colorspaces` for details. | [
"Converts",
"the",
"colors",
"in",
"arr",
"from",
"colorspace",
"start",
"to",
"colorspace",
"end",
"."
] | python | train |
hMatoba/Piexif | piexif/_insert.py | https://github.com/hMatoba/Piexif/blob/afd0d232cf05cf530423f4b2a82ab291f150601a/piexif/_insert.py#L9-L60 | def insert(exif, image, new_file=None):
"""
py:function:: piexif.insert(exif_bytes, filename)
Insert exif into JPEG.
:param bytes exif_bytes: Exif as bytes
:param str filename: JPEG
"""
if exif[0:6] != b"\x45\x78\x69\x66\x00\x00":
raise ValueError("Given data is not exif data")
... | [
"def",
"insert",
"(",
"exif",
",",
"image",
",",
"new_file",
"=",
"None",
")",
":",
"if",
"exif",
"[",
"0",
":",
"6",
"]",
"!=",
"b\"\\x45\\x78\\x69\\x66\\x00\\x00\"",
":",
"raise",
"ValueError",
"(",
"\"Given data is not exif data\"",
")",
"output_file",
"=",... | py:function:: piexif.insert(exif_bytes, filename)
Insert exif into JPEG.
:param bytes exif_bytes: Exif as bytes
:param str filename: JPEG | [
"py",
":",
"function",
"::",
"piexif",
".",
"insert",
"(",
"exif_bytes",
"filename",
")"
] | python | train |
Chilipp/psyplot | psyplot/plotter.py | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/plotter.py#L2263-L2302 | def unshare_me(self, keys=None, auto_update=False, draw=None,
update_other=True):
"""
Close the sharing connection of this plotter with others
This method undoes the sharing connections made by the :meth:`share`
method and release this plotter again.
Paramete... | [
"def",
"unshare_me",
"(",
"self",
",",
"keys",
"=",
"None",
",",
"auto_update",
"=",
"False",
",",
"draw",
"=",
"None",
",",
"update_other",
"=",
"True",
")",
":",
"auto_update",
"=",
"auto_update",
"or",
"not",
"self",
".",
"no_auto_update",
"keys",
"="... | Close the sharing connection of this plotter with others
This method undoes the sharing connections made by the :meth:`share`
method and release this plotter again.
Parameters
----------
keys: string or iterable of strings
The formatoptions to unshare, or group name... | [
"Close",
"the",
"sharing",
"connection",
"of",
"this",
"plotter",
"with",
"others"
] | python | train |
quantmind/pulsar | pulsar/async/protocols.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/protocols.py#L353-L360 | async def close(self):
"""Stop serving the :attr:`.Server.sockets` and close all
concurrent connections.
"""
if self._server:
self._server.close()
self._server = None
self.event('stop').fire() | [
"async",
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_server",
":",
"self",
".",
"_server",
".",
"close",
"(",
")",
"self",
".",
"_server",
"=",
"None",
"self",
".",
"event",
"(",
"'stop'",
")",
".",
"fire",
"(",
")"
] | Stop serving the :attr:`.Server.sockets` and close all
concurrent connections. | [
"Stop",
"serving",
"the",
":",
"attr",
":",
".",
"Server",
".",
"sockets",
"and",
"close",
"all",
"concurrent",
"connections",
"."
] | python | train |
Karaage-Cluster/karaage | karaage/people/emails.py | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/emails.py#L86-L100 | def send_confirm_password_email(person):
"""Sends an email to user allowing them to confirm their password."""
url = '%s/profile/login/%s/' % (
settings.REGISTRATION_BASE_URL, person.username)
context = CONTEXT.copy()
context.update({
'url': url,
'receiver': person,
})
... | [
"def",
"send_confirm_password_email",
"(",
"person",
")",
":",
"url",
"=",
"'%s/profile/login/%s/'",
"%",
"(",
"settings",
".",
"REGISTRATION_BASE_URL",
",",
"person",
".",
"username",
")",
"context",
"=",
"CONTEXT",
".",
"copy",
"(",
")",
"context",
".",
"upd... | Sends an email to user allowing them to confirm their password. | [
"Sends",
"an",
"email",
"to",
"user",
"allowing",
"them",
"to",
"confirm",
"their",
"password",
"."
] | python | train |
klmitch/appathy | appathy/response.py | https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/response.py#L135-L155 | def _serialize(self):
"""
Serialize the ResponseObject. Returns a webob `Response`
object.
"""
# Do something appropriate if the response object is unbound
if self._defcode is None:
raise exceptions.UnboundResponse()
# Build the response
res... | [
"def",
"_serialize",
"(",
"self",
")",
":",
"# Do something appropriate if the response object is unbound",
"if",
"self",
".",
"_defcode",
"is",
"None",
":",
"raise",
"exceptions",
".",
"UnboundResponse",
"(",
")",
"# Build the response",
"resp",
"=",
"self",
".",
"... | Serialize the ResponseObject. Returns a webob `Response`
object. | [
"Serialize",
"the",
"ResponseObject",
".",
"Returns",
"a",
"webob",
"Response",
"object",
"."
] | python | train |
edibledinos/pwnypack | pwnypack/shellcode/base.py | https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/shellcode/base.py#L102-L115 | def alloc_buffer(self, length):
"""
Allocate a buffer (a range of uninitialized memory).
Arguments:
length(int): The length of the buffer to allocate.
Returns:
~pwnypack.types.Buffer: The object used to address this buffer.
"""
buf = Buffer(sum(... | [
"def",
"alloc_buffer",
"(",
"self",
",",
"length",
")",
":",
"buf",
"=",
"Buffer",
"(",
"sum",
"(",
"len",
"(",
"v",
")",
"for",
"v",
"in",
"six",
".",
"iterkeys",
"(",
"self",
".",
"data",
")",
")",
"+",
"sum",
"(",
"v",
".",
"length",
"for",
... | Allocate a buffer (a range of uninitialized memory).
Arguments:
length(int): The length of the buffer to allocate.
Returns:
~pwnypack.types.Buffer: The object used to address this buffer. | [
"Allocate",
"a",
"buffer",
"(",
"a",
"range",
"of",
"uninitialized",
"memory",
")",
"."
] | python | train |
markrwilliams/txdarn | txdarn/protocol.py | https://github.com/markrwilliams/txdarn/blob/154d25a1ac78c4e2877c0656e3b9cea4332eda57/txdarn/protocol.py#L129-L133 | def _connectionEstablished(self, transport):
'''Store a reference to our transport and write an open frame.'''
self.transport = transport
self.transport.writeOpen()
self.heartbeater.schedule() | [
"def",
"_connectionEstablished",
"(",
"self",
",",
"transport",
")",
":",
"self",
".",
"transport",
"=",
"transport",
"self",
".",
"transport",
".",
"writeOpen",
"(",
")",
"self",
".",
"heartbeater",
".",
"schedule",
"(",
")"
] | Store a reference to our transport and write an open frame. | [
"Store",
"a",
"reference",
"to",
"our",
"transport",
"and",
"write",
"an",
"open",
"frame",
"."
] | python | train |
CiscoTestAutomation/yang | connector/setup.py | https://github.com/CiscoTestAutomation/yang/blob/c70ec5ac5a91f276c4060009203770ece92e76b4/connector/setup.py#L110-L116 | def find_version(*paths):
'''reads a file and returns the defined __version__ value'''
version_match = re.search(r"^__version__ ?= ?['\"]([^'\"]*)['\"]",
read(*paths), re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version s... | [
"def",
"find_version",
"(",
"*",
"paths",
")",
":",
"version_match",
"=",
"re",
".",
"search",
"(",
"r\"^__version__ ?= ?['\\\"]([^'\\\"]*)['\\\"]\"",
",",
"read",
"(",
"*",
"paths",
")",
",",
"re",
".",
"M",
")",
"if",
"version_match",
":",
"return",
"versi... | reads a file and returns the defined __version__ value | [
"reads",
"a",
"file",
"and",
"returns",
"the",
"defined",
"__version__",
"value"
] | python | train |
soimort/you-get | src/you_get/__main__.py | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/__main__.py#L24-L85 | def main_dev(**kwargs):
"""Main entry point.
you-get-dev
"""
# Get (branch, commit) if running from a git repo.
head = git.get_head(kwargs['repo_path'])
# Get options and arguments.
try:
opts, args = getopt.getopt(sys.argv[1:], _short_options, _options)
except getopt.GetoptErro... | [
"def",
"main_dev",
"(",
"*",
"*",
"kwargs",
")",
":",
"# Get (branch, commit) if running from a git repo.",
"head",
"=",
"git",
".",
"get_head",
"(",
"kwargs",
"[",
"'repo_path'",
"]",
")",
"# Get options and arguments.",
"try",
":",
"opts",
",",
"args",
"=",
"g... | Main entry point.
you-get-dev | [
"Main",
"entry",
"point",
".",
"you",
"-",
"get",
"-",
"dev"
] | python | test |
apache/incubator-mxnet | example/gluon/dc_gan/dcgan.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/dc_gan/dcgan.py#L165-L191 | def get_netG():
"""Get net G"""
# build the generator
netG = nn.Sequential()
with netG.name_scope():
# input is Z, going into a convolution
netG.add(nn.Conv2DTranspose(ngf * 8, 4, 1, 0, use_bias=False))
netG.add(nn.BatchNorm())
netG.add(nn.Activation('relu'))
# st... | [
"def",
"get_netG",
"(",
")",
":",
"# build the generator",
"netG",
"=",
"nn",
".",
"Sequential",
"(",
")",
"with",
"netG",
".",
"name_scope",
"(",
")",
":",
"# input is Z, going into a convolution",
"netG",
".",
"add",
"(",
"nn",
".",
"Conv2DTranspose",
"(",
... | Get net G | [
"Get",
"net",
"G"
] | python | train |
senaite/senaite.core | bika/lims/api/__init__.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/api/__init__.py#L756-L774 | def get_workflow_status_of(brain_or_object, state_var="review_state"):
"""Get the current workflow status of the given brain or context.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param state_var: The name of ... | [
"def",
"get_workflow_status_of",
"(",
"brain_or_object",
",",
"state_var",
"=",
"\"review_state\"",
")",
":",
"# Try to get the state from the catalog brain first",
"if",
"is_brain",
"(",
"brain_or_object",
")",
":",
"if",
"state_var",
"in",
"brain_or_object",
".",
"schem... | Get the current workflow status of the given brain or context.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param state_var: The name of the state variable
:type state_var: string
:returns: Status
:rtype... | [
"Get",
"the",
"current",
"workflow",
"status",
"of",
"the",
"given",
"brain",
"or",
"context",
"."
] | python | train |
etscrivner/nose-perfdump | perfdump/plugin.py | https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/plugin.py#L130-L144 | def report(self, stream):
"""Displays the slowest tests"""
self.db.commit()
stream.writeln()
self.draw_header(stream, "10 SLOWEST SETUPS")
self.display_slowest_setups(stream)
stream.writeln()
self.draw_header(stream, "10 SLOWEST TESTS")
self.display_slow... | [
"def",
"report",
"(",
"self",
",",
"stream",
")",
":",
"self",
".",
"db",
".",
"commit",
"(",
")",
"stream",
".",
"writeln",
"(",
")",
"self",
".",
"draw_header",
"(",
"stream",
",",
"\"10 SLOWEST SETUPS\"",
")",
"self",
".",
"display_slowest_setups",
"(... | Displays the slowest tests | [
"Displays",
"the",
"slowest",
"tests"
] | python | train |
berkeley-cocosci/Wallace | wallace/models.py | https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/models.py#L655-L703 | def vectors(self, direction="all", failed=False):
"""Get vectors that connect at this node.
Direction can be "incoming", "outgoing" or "all" (default).
Failed can be True, False or all
"""
# check direction
if direction not in ["all", "incoming", "outgoing"]:
... | [
"def",
"vectors",
"(",
"self",
",",
"direction",
"=",
"\"all\"",
",",
"failed",
"=",
"False",
")",
":",
"# check direction",
"if",
"direction",
"not",
"in",
"[",
"\"all\"",
",",
"\"incoming\"",
",",
"\"outgoing\"",
"]",
":",
"raise",
"ValueError",
"(",
"\"... | Get vectors that connect at this node.
Direction can be "incoming", "outgoing" or "all" (default).
Failed can be True, False or all | [
"Get",
"vectors",
"that",
"connect",
"at",
"this",
"node",
"."
] | python | train |
senaite/senaite.core | bika/lims/browser/analysisrequest/add2.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/analysisrequest/add2.py#L486-L510 | def get_service_categories(self, restricted=True):
"""Return all service categories in the right order
:param restricted: Client settings restrict categories
:type restricted: bool
:returns: Category catalog results
:rtype: brains
"""
bsc = api.get_tool("bika_set... | [
"def",
"get_service_categories",
"(",
"self",
",",
"restricted",
"=",
"True",
")",
":",
"bsc",
"=",
"api",
".",
"get_tool",
"(",
"\"bika_setup_catalog\"",
")",
"query",
"=",
"{",
"\"portal_type\"",
":",
"\"AnalysisCategory\"",
",",
"\"is_active\"",
":",
"True",
... | Return all service categories in the right order
:param restricted: Client settings restrict categories
:type restricted: bool
:returns: Category catalog results
:rtype: brains | [
"Return",
"all",
"service",
"categories",
"in",
"the",
"right",
"order"
] | python | train |
ContextLab/hypertools | hypertools/tools/cluster.py | https://github.com/ContextLab/hypertools/blob/b76c7ac8061998b560e969ff8e4f4c915088e7a0/hypertools/tools/cluster.py#L28-L100 | def cluster(x, cluster='KMeans', n_clusters=3, ndims=None, format_data=True):
"""
Performs clustering analysis and returns a list of cluster labels
Parameters
----------
x : A Numpy array, Pandas Dataframe or list of arrays/dfs
The data to be clustered. You can pass a single array/df or a ... | [
"def",
"cluster",
"(",
"x",
",",
"cluster",
"=",
"'KMeans'",
",",
"n_clusters",
"=",
"3",
",",
"ndims",
"=",
"None",
",",
"format_data",
"=",
"True",
")",
":",
"if",
"cluster",
"==",
"None",
":",
"return",
"x",
"elif",
"(",
"isinstance",
"(",
"cluste... | Performs clustering analysis and returns a list of cluster labels
Parameters
----------
x : A Numpy array, Pandas Dataframe or list of arrays/dfs
The data to be clustered. You can pass a single array/df or a list.
If a list is passed, the arrays will be stacked and the clustering
w... | [
"Performs",
"clustering",
"analysis",
"and",
"returns",
"a",
"list",
"of",
"cluster",
"labels"
] | python | train |
jedie/django-cms-tools | django_cms_tools/fixture_helper/page_utils.py | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/page_utils.py#L33-L41 | def get_public_cms_page_urls(*, language_code):
"""
:param language_code: e.g.: "en" or "de"
:return: Tuple with all public urls in the given language
"""
pages = Page.objects.public()
urls = [page.get_absolute_url(language=language_code) for page in pages]
urls.sort()
return tuple(urls) | [
"def",
"get_public_cms_page_urls",
"(",
"*",
",",
"language_code",
")",
":",
"pages",
"=",
"Page",
".",
"objects",
".",
"public",
"(",
")",
"urls",
"=",
"[",
"page",
".",
"get_absolute_url",
"(",
"language",
"=",
"language_code",
")",
"for",
"page",
"in",
... | :param language_code: e.g.: "en" or "de"
:return: Tuple with all public urls in the given language | [
":",
"param",
"language_code",
":",
"e",
".",
"g",
".",
":",
"en",
"or",
"de",
":",
"return",
":",
"Tuple",
"with",
"all",
"public",
"urls",
"in",
"the",
"given",
"language"
] | python | train |
LabKey/labkey-api-python | labkey/security.py | https://github.com/LabKey/labkey-api-python/blob/3c8d393384d7cbb2785f8a7f5fe34007b17a76b8/labkey/security.py#L165-L176 | def remove_from_role(server_context, role, user_id=None, email=None, container_path=None):
"""
Remove user/group from security role
:param server_context: A LabKey server context. See utils.create_server_context.
:param role: (from get_roles) to remove user from
:param user_id: to remove permissions... | [
"def",
"remove_from_role",
"(",
"server_context",
",",
"role",
",",
"user_id",
"=",
"None",
",",
"email",
"=",
"None",
",",
"container_path",
"=",
"None",
")",
":",
"return",
"__make_security_role_api_request",
"(",
"server_context",
",",
"'removeAssignment.api'",
... | Remove user/group from security role
:param server_context: A LabKey server context. See utils.create_server_context.
:param role: (from get_roles) to remove user from
:param user_id: to remove permissions from (must supply this or email or both)
:param email: to remove permissions from (must supply thi... | [
"Remove",
"user",
"/",
"group",
"from",
"security",
"role",
":",
"param",
"server_context",
":",
"A",
"LabKey",
"server",
"context",
".",
"See",
"utils",
".",
"create_server_context",
".",
":",
"param",
"role",
":",
"(",
"from",
"get_roles",
")",
"to",
"re... | python | train |
renweizhukov/txt2mobi3 | txt2mobi3/txt2html3.py | https://github.com/renweizhukov/txt2mobi3/blob/db78e5b57595b7ca87570eda2a00f9509b80b4c6/txt2mobi3/txt2html3.py#L240-L250 | def _start_end_of_index(self, book_idx):
"""
根据book_idx计算开始和结束的chapter id
:param book_idx:
:type int:
:return:
:rtype:
"""
start = (book_idx - 1) * self._max_chapters
end = min(book_idx * self._max_chapters, len(self._chapters))
return (sta... | [
"def",
"_start_end_of_index",
"(",
"self",
",",
"book_idx",
")",
":",
"start",
"=",
"(",
"book_idx",
"-",
"1",
")",
"*",
"self",
".",
"_max_chapters",
"end",
"=",
"min",
"(",
"book_idx",
"*",
"self",
".",
"_max_chapters",
",",
"len",
"(",
"self",
".",
... | 根据book_idx计算开始和结束的chapter id
:param book_idx:
:type int:
:return:
:rtype: | [
"根据book_idx计算开始和结束的chapter",
"id",
":",
"param",
"book_idx",
":",
":",
"type",
"int",
":",
":",
"return",
":",
":",
"rtype",
":"
] | python | train |
google/grr | grr/server/grr_response_server/databases/mem_users.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_users.py#L22-L37 | def WriteGRRUser(self,
username,
password=None,
ui_mode=None,
canary_mode=None,
user_type=None):
"""Writes user object for a user with a given name."""
u = self.users.setdefault(username, rdf_objects.GRRUser(username=... | [
"def",
"WriteGRRUser",
"(",
"self",
",",
"username",
",",
"password",
"=",
"None",
",",
"ui_mode",
"=",
"None",
",",
"canary_mode",
"=",
"None",
",",
"user_type",
"=",
"None",
")",
":",
"u",
"=",
"self",
".",
"users",
".",
"setdefault",
"(",
"username"... | Writes user object for a user with a given name. | [
"Writes",
"user",
"object",
"for",
"a",
"user",
"with",
"a",
"given",
"name",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/click/parser.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/parser.py#L25-L73 | def _unpack_args(args, nargs_spec):
"""Given an iterable of arguments and an iterable of nargs specifications,
it returns a tuple with all the unpacked arguments at the first index
and all remaining arguments as the second.
The nargs specification is the number of arguments that should be consumed
... | [
"def",
"_unpack_args",
"(",
"args",
",",
"nargs_spec",
")",
":",
"args",
"=",
"deque",
"(",
"args",
")",
"nargs_spec",
"=",
"deque",
"(",
"nargs_spec",
")",
"rv",
"=",
"[",
"]",
"spos",
"=",
"None",
"def",
"_fetch",
"(",
"c",
")",
":",
"try",
":",
... | Given an iterable of arguments and an iterable of nargs specifications,
it returns a tuple with all the unpacked arguments at the first index
and all remaining arguments as the second.
The nargs specification is the number of arguments that should be consumed
or `-1` to indicate that this position shou... | [
"Given",
"an",
"iterable",
"of",
"arguments",
"and",
"an",
"iterable",
"of",
"nargs",
"specifications",
"it",
"returns",
"a",
"tuple",
"with",
"all",
"the",
"unpacked",
"arguments",
"at",
"the",
"first",
"index",
"and",
"all",
"remaining",
"arguments",
"as",
... | python | train |
watson-developer-cloud/python-sdk | ibm_watson/natural_language_understanding_v1.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/natural_language_understanding_v1.py#L3107-L3114 | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'tokens') and self.tokens is not None:
_dict['tokens'] = self.tokens._to_dict()
if hasattr(self, 'sentences') and self.sentences is not None:
_dict['sentences']... | [
"def",
"_to_dict",
"(",
"self",
")",
":",
"_dict",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"self",
",",
"'tokens'",
")",
"and",
"self",
".",
"tokens",
"is",
"not",
"None",
":",
"_dict",
"[",
"'tokens'",
"]",
"=",
"self",
".",
"tokens",
".",
"_to_dict"... | Return a json dictionary representing this model. | [
"Return",
"a",
"json",
"dictionary",
"representing",
"this",
"model",
"."
] | python | train |
eruvanos/openbrokerapi | openbrokerapi/api.py | https://github.com/eruvanos/openbrokerapi/blob/29d514e5932f2eac27e03995dd41c8cecf40bb10/openbrokerapi/api.py#L49-L317 | def get_blueprint(service_brokers: Union[List[ServiceBroker], ServiceBroker],
broker_credentials: Union[None, List[BrokerCredentials], BrokerCredentials],
logger: logging.Logger) -> Blueprint:
"""
Returns the blueprint with service broker api.
:param service_brokers: Ser... | [
"def",
"get_blueprint",
"(",
"service_brokers",
":",
"Union",
"[",
"List",
"[",
"ServiceBroker",
"]",
",",
"ServiceBroker",
"]",
",",
"broker_credentials",
":",
"Union",
"[",
"None",
",",
"List",
"[",
"BrokerCredentials",
"]",
",",
"BrokerCredentials",
"]",
",... | Returns the blueprint with service broker api.
:param service_brokers: Services that this broker exposes
:param broker_credentials: Optional Usernames and passwords that will be required to communicate with service broker
:param logger: Used for api logs. This will not influence Flasks logging behavior.
... | [
"Returns",
"the",
"blueprint",
"with",
"service",
"broker",
"api",
"."
] | python | train |
hannes-brt/hebel | hebel/pycuda_ops/cublas.py | https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L3350-L3361 | def cublasZtpsv(handle, uplo, trans, diag, n, AP, x, incx):
"""
Solve complex triangular-packed system with one right-hand size.
"""
status = _libcublas.cublasZtpsv_v2(handle,
_CUBLAS_FILL_MODE[uplo],
_CUBLAS_OP[trans]... | [
"def",
"cublasZtpsv",
"(",
"handle",
",",
"uplo",
",",
"trans",
",",
"diag",
",",
"n",
",",
"AP",
",",
"x",
",",
"incx",
")",
":",
"status",
"=",
"_libcublas",
".",
"cublasZtpsv_v2",
"(",
"handle",
",",
"_CUBLAS_FILL_MODE",
"[",
"uplo",
"]",
",",
"_C... | Solve complex triangular-packed system with one right-hand size. | [
"Solve",
"complex",
"triangular",
"-",
"packed",
"system",
"with",
"one",
"right",
"-",
"hand",
"size",
"."
] | python | train |
etalab/cada | cada/commands.py | https://github.com/etalab/cada/blob/36e8b57514445c01ff7cd59a1c965180baf83d5e/cada/commands.py#L147-L175 | def load(patterns, full_reindex):
'''
Load one or more CADA CSV files matching patterns
'''
header('Loading CSV files')
for pattern in patterns:
for filename in iglob(pattern):
echo('Loading {}'.format(white(filename)))
with open(filename) as f:
reader... | [
"def",
"load",
"(",
"patterns",
",",
"full_reindex",
")",
":",
"header",
"(",
"'Loading CSV files'",
")",
"for",
"pattern",
"in",
"patterns",
":",
"for",
"filename",
"in",
"iglob",
"(",
"pattern",
")",
":",
"echo",
"(",
"'Loading {}'",
".",
"format",
"(",
... | Load one or more CADA CSV files matching patterns | [
"Load",
"one",
"or",
"more",
"CADA",
"CSV",
"files",
"matching",
"patterns"
] | python | train |
googleapis/google-cloud-python | bigquery/google/cloud/bigquery/external_config.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/external_config.py#L250-L259 | def columns(self):
"""List[:class:`~.external_config.BigtableColumn`]: Lists of columns
that should be exposed as individual fields.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions.(key).bigtableOptions.columnFamilies.columns
... | [
"def",
"columns",
"(",
"self",
")",
":",
"prop",
"=",
"self",
".",
"_properties",
".",
"get",
"(",
"\"columns\"",
",",
"[",
"]",
")",
"return",
"[",
"BigtableColumn",
".",
"from_api_repr",
"(",
"col",
")",
"for",
"col",
"in",
"prop",
"]"
] | List[:class:`~.external_config.BigtableColumn`]: Lists of columns
that should be exposed as individual fields.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions.(key).bigtableOptions.columnFamilies.columns
https://cloud.google.com/big... | [
"List",
"[",
":",
"class",
":",
"~",
".",
"external_config",
".",
"BigtableColumn",
"]",
":",
"Lists",
"of",
"columns",
"that",
"should",
"be",
"exposed",
"as",
"individual",
"fields",
"."
] | python | train |
juju/charm-helpers | charmhelpers/contrib/openstack/ha/utils.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/ha/utils.py#L130-L186 | def generate_ha_relation_data(service, extra_settings=None):
""" Generate relation data for ha relation
Based on configuration options and unit interfaces, generate a json
encoded dict of relation data items for the hacluster relation,
providing configuration for DNS HA or VIP's + haproxy clone sets.
... | [
"def",
"generate_ha_relation_data",
"(",
"service",
",",
"extra_settings",
"=",
"None",
")",
":",
"_haproxy_res",
"=",
"'res_{}_haproxy'",
".",
"format",
"(",
"service",
")",
"_relation_data",
"=",
"{",
"'resources'",
":",
"{",
"_haproxy_res",
":",
"'lsb:haproxy'"... | Generate relation data for ha relation
Based on configuration options and unit interfaces, generate a json
encoded dict of relation data items for the hacluster relation,
providing configuration for DNS HA or VIP's + haproxy clone sets.
Example of supplying additional settings::
COLO_CONSOLEA... | [
"Generate",
"relation",
"data",
"for",
"ha",
"relation"
] | python | train |
wonambi-python/wonambi | wonambi/ioeeg/egimff.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/ioeeg/egimff.py#L399-L424 | def xml2dict(root):
"""Use functions instead of Class and remove namespace based on:
http://stackoverflow.com/questions/2148119
"""
output = {}
if root.items():
output.update(dict(root.items()))
for element in root:
if element:
if len(element) == 1 or element[0].tag ... | [
"def",
"xml2dict",
"(",
"root",
")",
":",
"output",
"=",
"{",
"}",
"if",
"root",
".",
"items",
"(",
")",
":",
"output",
".",
"update",
"(",
"dict",
"(",
"root",
".",
"items",
"(",
")",
")",
")",
"for",
"element",
"in",
"root",
":",
"if",
"eleme... | Use functions instead of Class and remove namespace based on:
http://stackoverflow.com/questions/2148119 | [
"Use",
"functions",
"instead",
"of",
"Class",
"and",
"remove",
"namespace",
"based",
"on",
":",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"2148119"
] | python | train |
openstack/proliantutils | proliantutils/redfish/redfish.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/redfish.py#L1023-L1040 | def inject_nmi(self):
"""Inject NMI, Non Maskable Interrupt.
Inject NMI (Non Maskable Interrupt) for a node immediately.
:raises: IloError, on an error from iLO
"""
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
if sushy_system.power_state != sushy.SYSTEM_POW... | [
"def",
"inject_nmi",
"(",
"self",
")",
":",
"sushy_system",
"=",
"self",
".",
"_get_sushy_system",
"(",
"PROLIANT_SYSTEM_ID",
")",
"if",
"sushy_system",
".",
"power_state",
"!=",
"sushy",
".",
"SYSTEM_POWER_STATE_ON",
":",
"raise",
"exception",
".",
"IloError",
... | Inject NMI, Non Maskable Interrupt.
Inject NMI (Non Maskable Interrupt) for a node immediately.
:raises: IloError, on an error from iLO | [
"Inject",
"NMI",
"Non",
"Maskable",
"Interrupt",
"."
] | python | train |
yunojuno/elasticsearch-django | elasticsearch_django/index.py | https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L31-L35 | def delete_index(index):
"""Delete index entirely (removes all documents and mapping)."""
logger.info("Deleting search index: '%s'", index)
client = get_client()
return client.indices.delete(index=index) | [
"def",
"delete_index",
"(",
"index",
")",
":",
"logger",
".",
"info",
"(",
"\"Deleting search index: '%s'\"",
",",
"index",
")",
"client",
"=",
"get_client",
"(",
")",
"return",
"client",
".",
"indices",
".",
"delete",
"(",
"index",
"=",
"index",
")"
] | Delete index entirely (removes all documents and mapping). | [
"Delete",
"index",
"entirely",
"(",
"removes",
"all",
"documents",
"and",
"mapping",
")",
"."
] | python | train |
zeromake/aiosqlite3 | aiosqlite3/sa/transaction.py | https://github.com/zeromake/aiosqlite3/blob/1a74a062507e2df8f833a70885e69dca0ab3e7e7/aiosqlite3/sa/transaction.py#L50-L73 | def close(self):
"""
Close this transaction.
If this transaction is the base transaction in a begin/commit
nesting, the transaction will rollback(). Otherwise, the
method returns.
This is used to cancel a Transaction without affecting the scope of
an enclosing ... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_connection",
"or",
"not",
"self",
".",
"_parent",
":",
"return",
"if",
"not",
"self",
".",
"_parent",
".",
"_is_active",
":",
"# pragma: no cover",
"self",
".",
"_connection",
"=",
"None"... | Close this transaction.
If this transaction is the base transaction in a begin/commit
nesting, the transaction will rollback(). Otherwise, the
method returns.
This is used to cancel a Transaction without affecting the scope of
an enclosing transaction. | [
"Close",
"this",
"transaction",
"."
] | python | train |
softlayer/softlayer-python | SoftLayer/managers/firewall.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/firewall.py#L46-L61 | def get_standard_package(self, server_id, is_virt=True):
"""Retrieves the standard firewall package for the virtual server.
:param int server_id: The ID of the server to create the firewall for
:param bool is_virt: True if the ID provided is for a virtual server,
Fa... | [
"def",
"get_standard_package",
"(",
"self",
",",
"server_id",
",",
"is_virt",
"=",
"True",
")",
":",
"firewall_port_speed",
"=",
"self",
".",
"_get_fwl_port_speed",
"(",
"server_id",
",",
"is_virt",
")",
"_value",
"=",
"\"%s%s\"",
"%",
"(",
"firewall_port_speed"... | Retrieves the standard firewall package for the virtual server.
:param int server_id: The ID of the server to create the firewall for
:param bool is_virt: True if the ID provided is for a virtual server,
False for a server
:returns: A dictionary containing the stand... | [
"Retrieves",
"the",
"standard",
"firewall",
"package",
"for",
"the",
"virtual",
"server",
"."
] | python | train |
TC01/calcpkg | calcrepo/repo.py | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/repo.py#L185-L198 | def downloadFileFromUrl(self, url):
"""Given a URL, download the specified file"""
fullurl = self.baseUrl + url
try:
urlobj = urllib2.urlopen(fullurl)
contents = urlobj.read()
except urllib2.HTTPError, e:
self.printd("HTTP error:", e.code, url)
return None
except urllib2.URLError, e:
self.print... | [
"def",
"downloadFileFromUrl",
"(",
"self",
",",
"url",
")",
":",
"fullurl",
"=",
"self",
".",
"baseUrl",
"+",
"url",
"try",
":",
"urlobj",
"=",
"urllib2",
".",
"urlopen",
"(",
"fullurl",
")",
"contents",
"=",
"urlobj",
".",
"read",
"(",
")",
"except",
... | Given a URL, download the specified file | [
"Given",
"a",
"URL",
"download",
"the",
"specified",
"file"
] | python | train |
yvesalexandre/bandicoot | bandicoot/spatial.py | https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/spatial.py#L115-L130 | def frequent_antennas(positions, percentage=0.8):
"""
The number of location that account for 80% of the locations where the user was.
Percentage can be supplied as a decimal (e.g., .8 for default 80%).
"""
location_count = Counter(list(map(str, positions)))
target = math.ceil(sum(location_coun... | [
"def",
"frequent_antennas",
"(",
"positions",
",",
"percentage",
"=",
"0.8",
")",
":",
"location_count",
"=",
"Counter",
"(",
"list",
"(",
"map",
"(",
"str",
",",
"positions",
")",
")",
")",
"target",
"=",
"math",
".",
"ceil",
"(",
"sum",
"(",
"locatio... | The number of location that account for 80% of the locations where the user was.
Percentage can be supplied as a decimal (e.g., .8 for default 80%). | [
"The",
"number",
"of",
"location",
"that",
"account",
"for",
"80%",
"of",
"the",
"locations",
"where",
"the",
"user",
"was",
".",
"Percentage",
"can",
"be",
"supplied",
"as",
"a",
"decimal",
"(",
"e",
".",
"g",
".",
".",
"8",
"for",
"default",
"80%",
... | python | train |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L3337-L3343 | def listGetString(self, doc, inLine):
"""Build the string equivalent to the text contained in the
Node list made of TEXTs and ENTITY_REFs """
if doc is None: doc__o = None
else: doc__o = doc._o
ret = libxml2mod.xmlNodeListGetString(doc__o, self._o, inLine)
return ret | [
"def",
"listGetString",
"(",
"self",
",",
"doc",
",",
"inLine",
")",
":",
"if",
"doc",
"is",
"None",
":",
"doc__o",
"=",
"None",
"else",
":",
"doc__o",
"=",
"doc",
".",
"_o",
"ret",
"=",
"libxml2mod",
".",
"xmlNodeListGetString",
"(",
"doc__o",
",",
... | Build the string equivalent to the text contained in the
Node list made of TEXTs and ENTITY_REFs | [
"Build",
"the",
"string",
"equivalent",
"to",
"the",
"text",
"contained",
"in",
"the",
"Node",
"list",
"made",
"of",
"TEXTs",
"and",
"ENTITY_REFs"
] | python | train |
brocade/pynos | pynos/versions/base/yang/brocade_fcoe.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/yang/brocade_fcoe.py#L131-L144 | def fcoe_fcoe_map_fcoe_map_fabric_map_fcoe_map_fabric_map_name(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
fcoe = ET.SubElement(config, "fcoe", xmlns="urn:brocade.com:mgmt:brocade-fcoe")
fcoe_map = ET.SubElement(fcoe, "fcoe-map")
fcoe_map_nam... | [
"def",
"fcoe_fcoe_map_fcoe_map_fabric_map_fcoe_map_fabric_map_name",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"fcoe",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"fcoe\"",
",",
"xmlns"... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
PyHDI/Pyverilog | pyverilog/vparser/parser.py | https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L1475-L1478 | def p_namedblock(self, p):
'namedblock : BEGIN COLON ID namedblock_statements END'
p[0] = Block(p[4], p[3], lineno=p.lineno(1))
p.set_lineno(0, p.lineno(1)) | [
"def",
"p_namedblock",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Block",
"(",
"p",
"[",
"4",
"]",
",",
"p",
"[",
"3",
"]",
",",
"lineno",
"=",
"p",
".",
"lineno",
"(",
"1",
")",
")",
"p",
".",
"set_lineno",
"(",
"0",
",",... | namedblock : BEGIN COLON ID namedblock_statements END | [
"namedblock",
":",
"BEGIN",
"COLON",
"ID",
"namedblock_statements",
"END"
] | python | train |
bitesofcode/projexui | projexui/widgets/xcolortreewidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcolortreewidget.py#L79-L86 | def setName( self, name ):
"""
Sets the name for this color item to the inputed name.
:param name | <str>
"""
self._name = projex.text.nativestring(name)
self.setText(0, ' '.join(projex.text.words(self._name))) | [
"def",
"setName",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_name",
"=",
"projex",
".",
"text",
".",
"nativestring",
"(",
"name",
")",
"self",
".",
"setText",
"(",
"0",
",",
"' '",
".",
"join",
"(",
"projex",
".",
"text",
".",
"words",
"(... | Sets the name for this color item to the inputed name.
:param name | <str> | [
"Sets",
"the",
"name",
"for",
"this",
"color",
"item",
"to",
"the",
"inputed",
"name",
".",
":",
"param",
"name",
"|",
"<str",
">"
] | python | train |
SylvanasSun/FishFishJump | fish_dashboard/scrapyd/scrapyd_agent.py | https://github.com/SylvanasSun/FishFishJump/blob/696212d242d8d572f3f1b43925f3d8ab8acc6a2d/fish_dashboard/scrapyd/scrapyd_agent.py#L267-L279 | def get_logs(self, project_name, spider_name):
"""
Get urls that scrapyd logs file by project name and spider name
:param project_name: the project name
:param spider_name: the spider name
:return: two list of the logs file name and logs file url
"""
url, method =... | [
"def",
"get_logs",
"(",
"self",
",",
"project_name",
",",
"spider_name",
")",
":",
"url",
",",
"method",
"=",
"self",
".",
"command_set",
"[",
"'logs'",
"]",
"[",
"0",
"]",
"+",
"project_name",
"+",
"'/'",
"+",
"spider_name",
"+",
"'/'",
",",
"self",
... | Get urls that scrapyd logs file by project name and spider name
:param project_name: the project name
:param spider_name: the spider name
:return: two list of the logs file name and logs file url | [
"Get",
"urls",
"that",
"scrapyd",
"logs",
"file",
"by",
"project",
"name",
"and",
"spider",
"name",
":",
"param",
"project_name",
":",
"the",
"project",
"name",
":",
"param",
"spider_name",
":",
"the",
"spider",
"name",
":",
"return",
":",
"two",
"list",
... | python | train |
bkeating/python-payflowpro | payflowpro/classes.py | https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/classes.py#L359-L409 | def parse_parameters(payflowpro_response_data):
"""
Parses a set of Payflow Pro response parameter name and value pairs into
a list of PayflowProObjects, and returns a tuple containing the object
list and a dictionary containing any unconsumed data.
The first item in the object list will alwa... | [
"def",
"parse_parameters",
"(",
"payflowpro_response_data",
")",
":",
"def",
"build_class",
"(",
"klass",
",",
"unconsumed_data",
")",
":",
"known_att_names_set",
"=",
"set",
"(",
"klass",
".",
"base_fields",
".",
"keys",
"(",
")",
")",
"available_atts_set",
"="... | Parses a set of Payflow Pro response parameter name and value pairs into
a list of PayflowProObjects, and returns a tuple containing the object
list and a dictionary containing any unconsumed data.
The first item in the object list will always be the Response object, and
the RecurringPayments obj... | [
"Parses",
"a",
"set",
"of",
"Payflow",
"Pro",
"response",
"parameter",
"name",
"and",
"value",
"pairs",
"into",
"a",
"list",
"of",
"PayflowProObjects",
"and",
"returns",
"a",
"tuple",
"containing",
"the",
"object",
"list",
"and",
"a",
"dictionary",
"containing... | python | train |
upsight/doctor | doctor/docs/base.py | https://github.com/upsight/doctor/blob/2cf1d433f6f1aa1355644b449a757c0660793cdd/doctor/docs/base.py#L642-L664 | def run(self): # pragma: no cover
"""Called by Sphinx to generate documentation for this directive."""
if self.directive_name is None:
raise NotImplementedError('directive_name must be implemented by '
'subclasses of BaseDirective')
env, state =... | [
"def",
"run",
"(",
"self",
")",
":",
"# pragma: no cover",
"if",
"self",
".",
"directive_name",
"is",
"None",
":",
"raise",
"NotImplementedError",
"(",
"'directive_name must be implemented by '",
"'subclasses of BaseDirective'",
")",
"env",
",",
"state",
"=",
"self",
... | Called by Sphinx to generate documentation for this directive. | [
"Called",
"by",
"Sphinx",
"to",
"generate",
"documentation",
"for",
"this",
"directive",
"."
] | python | train |
SHTOOLS/SHTOOLS | pyshtools/shclasses/slepian.py | https://github.com/SHTOOLS/SHTOOLS/blob/9a115cf83002df2ddec6b7f41aeb6be688e285de/pyshtools/shclasses/slepian.py#L444-L521 | def spectra(self, alpha=None, nmax=None, convention='power', unit='per_l',
base=10.):
"""
Return the spectra of one or more Slepian functions.
Usage
-----
spectra = x.spectra([alpha, nmax, convention, unit, base])
Returns
-------
spectra ... | [
"def",
"spectra",
"(",
"self",
",",
"alpha",
"=",
"None",
",",
"nmax",
"=",
"None",
",",
"convention",
"=",
"'power'",
",",
"unit",
"=",
"'per_l'",
",",
"base",
"=",
"10.",
")",
":",
"if",
"alpha",
"is",
"None",
":",
"if",
"nmax",
"is",
"None",
"... | Return the spectra of one or more Slepian functions.
Usage
-----
spectra = x.spectra([alpha, nmax, convention, unit, base])
Returns
-------
spectra : ndarray, shape (lmax+1, nmax)
A matrix with each column containing the spectrum of a Slepian
f... | [
"Return",
"the",
"spectra",
"of",
"one",
"or",
"more",
"Slepian",
"functions",
"."
] | python | train |
lorien/grab | grab/base.py | https://github.com/lorien/grab/blob/8b301db2a08c830245b61c589e58af6234f4db79/grab/base.py#L749-L768 | def detect_request_method(self):
"""
Analyze request config and find which
request method will be used.
Returns request method in upper case
This method needs simetime when `process_config` method
was not called yet.
"""
method = self.config['method']
... | [
"def",
"detect_request_method",
"(",
"self",
")",
":",
"method",
"=",
"self",
".",
"config",
"[",
"'method'",
"]",
"if",
"method",
":",
"method",
"=",
"method",
".",
"upper",
"(",
")",
"else",
":",
"if",
"self",
".",
"config",
"[",
"'post'",
"]",
"or... | Analyze request config and find which
request method will be used.
Returns request method in upper case
This method needs simetime when `process_config` method
was not called yet. | [
"Analyze",
"request",
"config",
"and",
"find",
"which",
"request",
"method",
"will",
"be",
"used",
"."
] | python | train |
skyfielders/python-skyfield | skyfield/positionlib.py | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/positionlib.py#L245-L248 | def galactic_xyz(self):
"""Compute galactic coordinates (x, y, z)"""
vector = _GALACTIC.dot(self.position.au)
return Distance(vector) | [
"def",
"galactic_xyz",
"(",
"self",
")",
":",
"vector",
"=",
"_GALACTIC",
".",
"dot",
"(",
"self",
".",
"position",
".",
"au",
")",
"return",
"Distance",
"(",
"vector",
")"
] | Compute galactic coordinates (x, y, z) | [
"Compute",
"galactic",
"coordinates",
"(",
"x",
"y",
"z",
")"
] | python | train |
decryptus/sonicprobe | sonicprobe/libs/anysql.py | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/anysql.py#L204-L220 | def querymany(self, sql_query, columns, seq_of_parameters):
"""
Same as .query() but eventually call the .executemany() method
of the underlying DBAPI2.0 cursor instead of .execute()
"""
tmp_query = self.__preparequery(sql_query, columns)
if self.__methods[METHOD_MODULE]... | [
"def",
"querymany",
"(",
"self",
",",
"sql_query",
",",
"columns",
",",
"seq_of_parameters",
")",
":",
"tmp_query",
"=",
"self",
".",
"__preparequery",
"(",
"sql_query",
",",
"columns",
")",
"if",
"self",
".",
"__methods",
"[",
"METHOD_MODULE",
"]",
".",
"... | Same as .query() but eventually call the .executemany() method
of the underlying DBAPI2.0 cursor instead of .execute() | [
"Same",
"as",
".",
"query",
"()",
"but",
"eventually",
"call",
"the",
".",
"executemany",
"()",
"method",
"of",
"the",
"underlying",
"DBAPI2",
".",
"0",
"cursor",
"instead",
"of",
".",
"execute",
"()"
] | python | train |
scieloorg/articlemetaapi | articlemeta/client.py | https://github.com/scieloorg/articlemetaapi/blob/7ff87a615951bfdcc6fd535ce7f7c65065f64caa/articlemeta/client.py#L689-L702 | def add_journal(self, data):
"""
This method include new journals to the ArticleMeta.
data: legacy SciELO Documents JSON Type 3.
"""
journal = self.dispatcher(
'add_journal',
data,
self._admintoken
)
return json.loads(journal... | [
"def",
"add_journal",
"(",
"self",
",",
"data",
")",
":",
"journal",
"=",
"self",
".",
"dispatcher",
"(",
"'add_journal'",
",",
"data",
",",
"self",
".",
"_admintoken",
")",
"return",
"json",
".",
"loads",
"(",
"journal",
")"
] | This method include new journals to the ArticleMeta.
data: legacy SciELO Documents JSON Type 3. | [
"This",
"method",
"include",
"new",
"journals",
"to",
"the",
"ArticleMeta",
"."
] | python | train |
tensorflow/probability | tensorflow_probability/python/internal/assert_util.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/assert_util.py#L76-L106 | def assert_rank_at_most(x, rank, data=None, summarize=None, message=None,
name=None):
"""Assert `x` has rank equal to `rank` or smaller.
Example of adding a dependency to an operation:
```python
with tf.control_dependencies([tf.assert_rank_at_most(x, 2)]):
output = tf.reduce_sum(x)... | [
"def",
"assert_rank_at_most",
"(",
"x",
",",
"rank",
",",
"data",
"=",
"None",
",",
"summarize",
"=",
"None",
",",
"message",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v2",
".",
"name_scope",
"(",
"name",
"... | Assert `x` has rank equal to `rank` or smaller.
Example of adding a dependency to an operation:
```python
with tf.control_dependencies([tf.assert_rank_at_most(x, 2)]):
output = tf.reduce_sum(x)
```
Args:
x: Numeric `Tensor`.
rank: Scalar `Tensor`.
data: The tensors to print out if the co... | [
"Assert",
"x",
"has",
"rank",
"equal",
"to",
"rank",
"or",
"smaller",
"."
] | python | test |
luckydonald/pytgbot | code_generation/output/pytgbot/bot.py | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/bot.py#L1469-L1502 | def get_file(self, file_id):
"""
Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<fil... | [
"def",
"get_file",
"(",
"self",
",",
"file_id",
")",
":",
"assert_type_or_raise",
"(",
"file_id",
",",
"unicode_type",
",",
"parameter_name",
"=",
"\"file_id\"",
")",
"result",
"=",
"self",
".",
"do",
"(",
"\"getFile\"",
",",
"file_id",
"=",
"file_id",
")",
... | Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the resp... | [
"Use",
"this",
"method",
"to",
"get",
"basic",
"info",
"about",
"a",
"file",
"and",
"prepare",
"it",
"for",
"downloading",
".",
"For",
"the",
"moment",
"bots",
"can",
"download",
"files",
"of",
"up",
"to",
"20MB",
"in",
"size",
".",
"On",
"success",
"a... | python | train |
sammchardy/python-kucoin | kucoin/client.py | https://github.com/sammchardy/python-kucoin/blob/a4cacde413804784bd313f27a0ad37234888be29/kucoin/client.py#L1769-L1835 | def get_kline_data(self, symbol, kline_type='5min', start=None, end=None):
"""Get kline data
For each query, the system would return at most 1500 pieces of data.
To obtain more data, please page the data by time.
:param symbol: Name of symbol e.g. KCS-BTC
:type symbol: string
... | [
"def",
"get_kline_data",
"(",
"self",
",",
"symbol",
",",
"kline_type",
"=",
"'5min'",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"data",
"=",
"{",
"'symbol'",
":",
"symbol",
"}",
"if",
"kline_type",
"is",
"not",
"None",
":",
"data... | Get kline data
For each query, the system would return at most 1500 pieces of data.
To obtain more data, please page the data by time.
:param symbol: Name of symbol e.g. KCS-BTC
:type symbol: string
:param kline_type: type of symbol, type of candlestick patterns: 1min, 3min, 5m... | [
"Get",
"kline",
"data"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.