repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
datamachine/twx | twx/twx.py | TWXBotApi.send_location | def send_location(self, peer: Peer, latitude: float, longitude: float, reply: int=None,
on_success: callable=None, reply_markup: botapi.ReplyMarkup=None):
"""
Send location to peer.
:param peer: Peer to send message to.
:param latitude: Latitude of the location.
... | python | def send_location(self, peer: Peer, latitude: float, longitude: float, reply: int=None,
on_success: callable=None, reply_markup: botapi.ReplyMarkup=None):
"""
Send location to peer.
:param peer: Peer to send message to.
:param latitude: Latitude of the location.
... | [
"def",
"send_location",
"(",
"self",
",",
"peer",
":",
"Peer",
",",
"latitude",
":",
"float",
",",
"longitude",
":",
"float",
",",
"reply",
":",
"int",
"=",
"None",
",",
"on_success",
":",
"callable",
"=",
"None",
",",
"reply_markup",
":",
"botapi",
".... | Send location to peer.
:param peer: Peer to send message to.
:param latitude: Latitude of the location.
:param longitude: Longitude of the location.
:param reply: Message object or message_id to reply to.
:param on_success: Callback to call when call is complete.
:type r... | [
"Send",
"location",
"to",
"peer",
".",
":",
"param",
"peer",
":",
"Peer",
"to",
"send",
"message",
"to",
".",
":",
"param",
"latitude",
":",
"Latitude",
"of",
"the",
"location",
".",
":",
"param",
"longitude",
":",
"Longitude",
"of",
"the",
"location",
... | d9633f12f3647b1e54ba87b70b39df3b7e02b4eb | https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/twx.py#L698-L715 | train | Send location to peer. |
datamachine/twx | twx/twx.py | TWXBotApi.send_chat_action | def send_chat_action(self, peer: Peer, action: botapi.ChatAction, on_success: callable=None):
"""
Send status to peer.
:param peer: Peer to send status to.
:param action: Type of action to send to peer.
:param on_success: Callback to call when call is complete.
"""
... | python | def send_chat_action(self, peer: Peer, action: botapi.ChatAction, on_success: callable=None):
"""
Send status to peer.
:param peer: Peer to send status to.
:param action: Type of action to send to peer.
:param on_success: Callback to call when call is complete.
"""
... | [
"def",
"send_chat_action",
"(",
"self",
",",
"peer",
":",
"Peer",
",",
"action",
":",
"botapi",
".",
"ChatAction",
",",
"on_success",
":",
"callable",
"=",
"None",
")",
":",
"botapi",
".",
"send_chat_action",
"(",
"chat_id",
"=",
"peer",
".",
"id",
",",
... | Send status to peer.
:param peer: Peer to send status to.
:param action: Type of action to send to peer.
:param on_success: Callback to call when call is complete. | [
"Send",
"status",
"to",
"peer",
".",
":",
"param",
"peer",
":",
"Peer",
"to",
"send",
"status",
"to",
".",
":",
"param",
"action",
":",
"Type",
"of",
"action",
"to",
"send",
"to",
"peer",
".",
":",
"param",
"on_success",
":",
"Callback",
"to",
"call"... | d9633f12f3647b1e54ba87b70b39df3b7e02b4eb | https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/twx.py#L717-L725 | train | Send chat action to peer. |
datamachine/twx | twx/twx.py | TWXBotApi.message_search | def message_search(self, text, on_success, peer=None, min_date=None, max_date=None, max_id=None, offset=0, limit=255):
"""
Unsupported in the Bot API
"""
raise TWXUnsupportedMethod() | python | def message_search(self, text, on_success, peer=None, min_date=None, max_date=None, max_id=None, offset=0, limit=255):
"""
Unsupported in the Bot API
"""
raise TWXUnsupportedMethod() | [
"def",
"message_search",
"(",
"self",
",",
"text",
",",
"on_success",
",",
"peer",
"=",
"None",
",",
"min_date",
"=",
"None",
",",
"max_date",
"=",
"None",
",",
"max_id",
"=",
"None",
",",
"offset",
"=",
"0",
",",
"limit",
"=",
"255",
")",
":",
"ra... | Unsupported in the Bot API | [
"Unsupported",
"in",
"the",
"Bot",
"API"
] | d9633f12f3647b1e54ba87b70b39df3b7e02b4eb | https://github.com/datamachine/twx/blob/d9633f12f3647b1e54ba87b70b39df3b7e02b4eb/twx/twx.py#L758-L762 | train | Search for messages in the local cache. |
johnnoone/json-spec | src/jsonspec/operations/bases.py | Target.check | def check(self, pointer, expected, raise_onerror=False):
"""Check if value exists into object.
:param pointer: the path to search in
:param expected: the expected value
:param raise_onerror: should raise on error?
:return: boolean
"""
obj = self.document
... | python | def check(self, pointer, expected, raise_onerror=False):
"""Check if value exists into object.
:param pointer: the path to search in
:param expected: the expected value
:param raise_onerror: should raise on error?
:return: boolean
"""
obj = self.document
... | [
"def",
"check",
"(",
"self",
",",
"pointer",
",",
"expected",
",",
"raise_onerror",
"=",
"False",
")",
":",
"obj",
"=",
"self",
".",
"document",
"for",
"token",
"in",
"Pointer",
"(",
"pointer",
")",
":",
"try",
":",
"obj",
"=",
"token",
".",
"extract... | Check if value exists into object.
:param pointer: the path to search in
:param expected: the expected value
:param raise_onerror: should raise on error?
:return: boolean | [
"Check",
"if",
"value",
"exists",
"into",
"object",
"."
] | f91981724cea0c366bd42a6670eb07bbe31c0e0c | https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/operations/bases.py#L28-L45 | train | Check if value exists into object. |
johnnoone/json-spec | src/jsonspec/operations/bases.py | Target.remove | def remove(self, pointer):
"""Remove element from sequence, member from mapping.
:param pointer: the path to search in
:return: resolved document
:rtype: Target
"""
doc = deepcopy(self.document)
parent, obj = None, doc
try:
# fetching
... | python | def remove(self, pointer):
"""Remove element from sequence, member from mapping.
:param pointer: the path to search in
:return: resolved document
:rtype: Target
"""
doc = deepcopy(self.document)
parent, obj = None, doc
try:
# fetching
... | [
"def",
"remove",
"(",
"self",
",",
"pointer",
")",
":",
"doc",
"=",
"deepcopy",
"(",
"self",
".",
"document",
")",
"parent",
",",
"obj",
"=",
"None",
",",
"doc",
"try",
":",
"# fetching",
"for",
"token",
"in",
"Pointer",
"(",
"pointer",
")",
":",
"... | Remove element from sequence, member from mapping.
:param pointer: the path to search in
:return: resolved document
:rtype: Target | [
"Remove",
"element",
"from",
"sequence",
"member",
"from",
"mapping",
"."
] | f91981724cea0c366bd42a6670eb07bbe31c0e0c | https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/operations/bases.py#L47-L70 | train | Removes element from sequence member from mapping. |
johnnoone/json-spec | src/jsonspec/operations/bases.py | Target.add | def add(self, pointer, value):
"""Add element to sequence, member to mapping.
:param pointer: the path to add in it
:param value: the new value
:return: resolved document
:rtype: Target
The pointer must reference one of:
- The root of the target document - w... | python | def add(self, pointer, value):
"""Add element to sequence, member to mapping.
:param pointer: the path to add in it
:param value: the new value
:return: resolved document
:rtype: Target
The pointer must reference one of:
- The root of the target document - w... | [
"def",
"add",
"(",
"self",
",",
"pointer",
",",
"value",
")",
":",
"doc",
"=",
"deepcopy",
"(",
"self",
".",
"document",
")",
"parent",
",",
"obj",
"=",
"None",
",",
"doc",
"try",
":",
"for",
"token",
"in",
"Pointer",
"(",
"pointer",
")",
":",
"p... | Add element to sequence, member to mapping.
:param pointer: the path to add in it
:param value: the new value
:return: resolved document
:rtype: Target
The pointer must reference one of:
- The root of the target document - whereupon the specified value
b... | [
"Add",
"element",
"to",
"sequence",
"member",
"to",
"mapping",
"."
] | f91981724cea0c366bd42a6670eb07bbe31c0e0c | https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/operations/bases.py#L72-L122 | train | Adds a new value to the sequence at the specified location. |
johnnoone/json-spec | src/jsonspec/operations/bases.py | Target.move | def move(self, dest, src):
"""Move element from sequence, member from mapping.
:param dest: the destination
:type dest: Pointer
:param src: the source
:type src: Pointer
:return: resolved document
:rtype: Target
.. note::
This operation is f... | python | def move(self, dest, src):
"""Move element from sequence, member from mapping.
:param dest: the destination
:type dest: Pointer
:param src: the source
:type src: Pointer
:return: resolved document
:rtype: Target
.. note::
This operation is f... | [
"def",
"move",
"(",
"self",
",",
"dest",
",",
"src",
")",
":",
"doc",
"=",
"deepcopy",
"(",
"self",
".",
"document",
")",
"# delete",
"parent",
",",
"fragment",
"=",
"None",
",",
"doc",
"for",
"token",
"in",
"Pointer",
"(",
"src",
")",
":",
"parent... | Move element from sequence, member from mapping.
:param dest: the destination
:type dest: Pointer
:param src: the source
:type src: Pointer
:return: resolved document
:rtype: Target
.. note::
This operation is functionally identical to a "remove" op... | [
"Move",
"element",
"from",
"sequence",
"member",
"from",
"mapping",
"."
] | f91981724cea0c366bd42a6670eb07bbe31c0e0c | https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/operations/bases.py#L151-L187 | train | Move element from sequence member from mapping. |
johnnoone/json-spec | src/jsonspec/operations/bases.py | Target.copy | def copy(self, dest, src):
"""Copy element from sequence, member from mapping.
:param dest: the destination
:type dest: Pointer
:param src: the source
:type src: Pointer
:return: resolved document
:rtype: Target
"""
doc = fragment = deepcopy(self.... | python | def copy(self, dest, src):
"""Copy element from sequence, member from mapping.
:param dest: the destination
:type dest: Pointer
:param src: the source
:type src: Pointer
:return: resolved document
:rtype: Target
"""
doc = fragment = deepcopy(self.... | [
"def",
"copy",
"(",
"self",
",",
"dest",
",",
"src",
")",
":",
"doc",
"=",
"fragment",
"=",
"deepcopy",
"(",
"self",
".",
"document",
")",
"for",
"token",
"in",
"Pointer",
"(",
"src",
")",
":",
"fragment",
"=",
"token",
".",
"extract",
"(",
"fragme... | Copy element from sequence, member from mapping.
:param dest: the destination
:type dest: Pointer
:param src: the source
:type src: Pointer
:return: resolved document
:rtype: Target | [
"Copy",
"element",
"from",
"sequence",
"member",
"from",
"mapping",
"."
] | f91981724cea0c366bd42a6670eb07bbe31c0e0c | https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/operations/bases.py#L189-L203 | train | Copy element from sequence member from mapping. |
PeerAssets/pypeerassets | pypeerassets/provider/common.py | Provider._netname | def _netname(name: str) -> dict:
'''resolute network name,
required because some providers use shortnames and other use longnames.'''
try:
long = net_query(name).name
short = net_query(name).shortname
except AttributeError:
raise UnsupportedNetwork(''... | python | def _netname(name: str) -> dict:
'''resolute network name,
required because some providers use shortnames and other use longnames.'''
try:
long = net_query(name).name
short = net_query(name).shortname
except AttributeError:
raise UnsupportedNetwork(''... | [
"def",
"_netname",
"(",
"name",
":",
"str",
")",
"->",
"dict",
":",
"try",
":",
"long",
"=",
"net_query",
"(",
"name",
")",
".",
"name",
"short",
"=",
"net_query",
"(",
"name",
")",
".",
"shortname",
"except",
"AttributeError",
":",
"raise",
"Unsupport... | resolute network name,
required because some providers use shortnames and other use longnames. | [
"resolute",
"network",
"name",
"required",
"because",
"some",
"providers",
"use",
"shortnames",
"and",
"other",
"use",
"longnames",
"."
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/provider/common.py#L21-L32 | train | resolute network name and return its components. |
PeerAssets/pypeerassets | pypeerassets/provider/common.py | Provider.sendrawtransaction | def sendrawtransaction(cls, rawtxn: str) -> str:
'''sendrawtransaction remote API'''
if cls.is_testnet:
url = 'https://testnet-explorer.peercoin.net/api/sendrawtransaction?hex={0}'.format(rawtxn)
else:
url = 'https://explorer.peercoin.net/api/sendrawtransaction?hex={0}'.... | python | def sendrawtransaction(cls, rawtxn: str) -> str:
'''sendrawtransaction remote API'''
if cls.is_testnet:
url = 'https://testnet-explorer.peercoin.net/api/sendrawtransaction?hex={0}'.format(rawtxn)
else:
url = 'https://explorer.peercoin.net/api/sendrawtransaction?hex={0}'.... | [
"def",
"sendrawtransaction",
"(",
"cls",
",",
"rawtxn",
":",
"str",
")",
"->",
"str",
":",
"if",
"cls",
".",
"is_testnet",
":",
"url",
"=",
"'https://testnet-explorer.peercoin.net/api/sendrawtransaction?hex={0}'",
".",
"format",
"(",
"rawtxn",
")",
"else",
":",
... | sendrawtransaction remote API | [
"sendrawtransaction",
"remote",
"API"
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/provider/common.py#L62-L71 | train | sendrawtransaction remote API |
PeerAssets/pypeerassets | pypeerassets/provider/common.py | Provider.validateaddress | def validateaddress(self, address: str) -> bool:
"Returns True if the passed address is valid, False otherwise."
try:
Address.from_string(address, self.network_properties)
except InvalidAddress:
return False
return True | python | def validateaddress(self, address: str) -> bool:
"Returns True if the passed address is valid, False otherwise."
try:
Address.from_string(address, self.network_properties)
except InvalidAddress:
return False
return True | [
"def",
"validateaddress",
"(",
"self",
",",
"address",
":",
"str",
")",
"->",
"bool",
":",
"try",
":",
"Address",
".",
"from_string",
"(",
"address",
",",
"self",
".",
"network_properties",
")",
"except",
"InvalidAddress",
":",
"return",
"False",
"return",
... | Returns True if the passed address is valid, False otherwise. | [
"Returns",
"True",
"if",
"the",
"passed",
"address",
"is",
"valid",
"False",
"otherwise",
"."
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/provider/common.py#L116-L124 | train | Returns True if the passed address is valid False otherwise. |
zero-os/zerotier_client | zerotier/Error.py | Error.create | def create(data=None, id=None, message=None):
"""
:type data: dict
:type id: int
:type message: str
:rtype: Error
"""
return Error(
data=data,
id=id,
message=message,
) | python | def create(data=None, id=None, message=None):
"""
:type data: dict
:type id: int
:type message: str
:rtype: Error
"""
return Error(
data=data,
id=id,
message=message,
) | [
"def",
"create",
"(",
"data",
"=",
"None",
",",
"id",
"=",
"None",
",",
"message",
"=",
"None",
")",
":",
"return",
"Error",
"(",
"data",
"=",
"data",
",",
"id",
"=",
"id",
",",
"message",
"=",
"message",
",",
")"
] | :type data: dict
:type id: int
:type message: str
:rtype: Error | [
":",
"type",
"data",
":",
"dict",
":",
"type",
"id",
":",
"int",
":",
"type",
"message",
":",
"str",
":",
"rtype",
":",
"Error"
] | 03993da11e69d837a0308a2f41ae7b378692fd82 | https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/Error.py#L14-L26 | train | Create an error object from data id and message. |
dirkcuys/s3-backup-rotate | dcu/active_memory/__init__.py | upload_rotate | def upload_rotate(file_path, s3_bucket, s3_key_prefix, aws_key=None, aws_secret=None):
'''
Upload file_path to s3 bucket with prefix
Ex. upload_rotate('/tmp/file-2015-01-01.tar.bz2', 'backups', 'foo.net/')
would upload file to bucket backups with key=foo.net/file-2015-01-01.tar.bz2
and then rotate a... | python | def upload_rotate(file_path, s3_bucket, s3_key_prefix, aws_key=None, aws_secret=None):
'''
Upload file_path to s3 bucket with prefix
Ex. upload_rotate('/tmp/file-2015-01-01.tar.bz2', 'backups', 'foo.net/')
would upload file to bucket backups with key=foo.net/file-2015-01-01.tar.bz2
and then rotate a... | [
"def",
"upload_rotate",
"(",
"file_path",
",",
"s3_bucket",
",",
"s3_key_prefix",
",",
"aws_key",
"=",
"None",
",",
"aws_secret",
"=",
"None",
")",
":",
"key",
"=",
"''",
".",
"join",
"(",
"[",
"s3_key_prefix",
",",
"os",
".",
"path",
".",
"basename",
... | Upload file_path to s3 bucket with prefix
Ex. upload_rotate('/tmp/file-2015-01-01.tar.bz2', 'backups', 'foo.net/')
would upload file to bucket backups with key=foo.net/file-2015-01-01.tar.bz2
and then rotate all files starting with foo.net/file and with extension .tar.bz2
Timestamps need to be present b... | [
"Upload",
"file_path",
"to",
"s3",
"bucket",
"with",
"prefix",
"Ex",
".",
"upload_rotate",
"(",
"/",
"tmp",
"/",
"file",
"-",
"2015",
"-",
"01",
"-",
"01",
".",
"tar",
".",
"bz2",
"backups",
"foo",
".",
"net",
"/",
")",
"would",
"upload",
"file",
"... | ab226c7b636550823a9c91e3ebd81776d255f204 | https://github.com/dirkcuys/s3-backup-rotate/blob/ab226c7b636550823a9c91e3ebd81776d255f204/dcu/active_memory/__init__.py#L12-L33 | train | Upload a file to S3 bucket with specified prefix and then rotate all files starting with the file root and extension. |
bennylope/smartystreets.py | smartystreets/async.py | chunker | def chunker(l, n):
"""
Generates n-sized chunks from the list l
"""
for i in ranger(0, len(l), n):
yield l[i:i + n] | python | def chunker(l, n):
"""
Generates n-sized chunks from the list l
"""
for i in ranger(0, len(l), n):
yield l[i:i + n] | [
"def",
"chunker",
"(",
"l",
",",
"n",
")",
":",
"for",
"i",
"in",
"ranger",
"(",
"0",
",",
"len",
"(",
"l",
")",
",",
"n",
")",
":",
"yield",
"l",
"[",
"i",
":",
"i",
"+",
"n",
"]"
] | Generates n-sized chunks from the list l | [
"Generates",
"n",
"-",
"sized",
"chunks",
"from",
"the",
"list",
"l"
] | f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69 | https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/async.py#L24-L29 | train | Generates n - sized chunks from the list l |
bennylope/smartystreets.py | smartystreets/async.py | AsyncClient.post | def post(self, endpoint, data, parallelism=5):
"""
Executes most of the request.
The parallelism parameter is useful to avoid swamping the API service with calls. Thus
the entire set of requests won't be all made at once, but in chunked groups.
:param endpoint: string indicatin... | python | def post(self, endpoint, data, parallelism=5):
"""
Executes most of the request.
The parallelism parameter is useful to avoid swamping the API service with calls. Thus
the entire set of requests won't be all made at once, but in chunked groups.
:param endpoint: string indicatin... | [
"def",
"post",
"(",
"self",
",",
"endpoint",
",",
"data",
",",
"parallelism",
"=",
"5",
")",
":",
"headers",
"=",
"{",
"\"Content-Type\"",
":",
"\"application/json\"",
",",
"\"Accept\"",
":",
"\"application/json\"",
",",
"\"x-standardize-only\"",
":",
"\"true\""... | Executes most of the request.
The parallelism parameter is useful to avoid swamping the API service with calls. Thus
the entire set of requests won't be all made at once, but in chunked groups.
:param endpoint: string indicating the URL component to call
:param data: the JSON ready dat... | [
"Executes",
"most",
"of",
"the",
"request",
"."
] | f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69 | https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/async.py#L52-L120 | train | Executes the POST request for the given endpoint. |
lreis2415/PyGeoC | examples/ex01_begin_with_pygeoc.py | main | def main():
"""Read GeoTiff raster data and print statistics.
The output will be::
rows: 130, cols: 100
LLCornerX: 755145.28, LLCornerY: 654294.06
cell size: 10.0
mean: 203.92, max: 284.07, min: 139.11
std: 32.32, sum: 2650967.00
"""
input_tif = "../tests/data/J... | python | def main():
"""Read GeoTiff raster data and print statistics.
The output will be::
rows: 130, cols: 100
LLCornerX: 755145.28, LLCornerY: 654294.06
cell size: 10.0
mean: 203.92, max: 284.07, min: 139.11
std: 32.32, sum: 2650967.00
"""
input_tif = "../tests/data/J... | [
"def",
"main",
"(",
")",
":",
"input_tif",
"=",
"\"../tests/data/Jamaica_dem.tif\"",
"rst",
"=",
"RasterUtilClass",
".",
"read_raster",
"(",
"input_tif",
")",
"# metadata information",
"print",
"(",
"\"rows: %d, cols: %d\"",
"%",
"(",
"rst",
".",
"nRows",
",",
"rs... | Read GeoTiff raster data and print statistics.
The output will be::
rows: 130, cols: 100
LLCornerX: 755145.28, LLCornerY: 654294.06
cell size: 10.0
mean: 203.92, max: 284.07, min: 139.11
std: 32.32, sum: 2650967.00 | [
"Read",
"GeoTiff",
"raster",
"data",
"and",
"print",
"statistics",
".",
"The",
"output",
"will",
"be",
"::"
] | 9a92d1a229bb74298e3c57f27c97079980b5f729 | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/examples/ex01_begin_with_pygeoc.py#L8-L27 | train | Read GeoTiff raster data and print statistics. |
idlesign/django-siteblocks | siteblocks/siteblocksapp.py | SiteBlocks._cache_init | def _cache_init(self):
"""Initializes local cache from Django cache."""
cache_ = cache.get(self.CACHE_KEY)
if cache_ is None:
cache_ = defaultdict(dict)
self._cache = cache_ | python | def _cache_init(self):
"""Initializes local cache from Django cache."""
cache_ = cache.get(self.CACHE_KEY)
if cache_ is None:
cache_ = defaultdict(dict)
self._cache = cache_ | [
"def",
"_cache_init",
"(",
"self",
")",
":",
"cache_",
"=",
"cache",
".",
"get",
"(",
"self",
".",
"CACHE_KEY",
")",
"if",
"cache_",
"is",
"None",
":",
"cache_",
"=",
"defaultdict",
"(",
"dict",
")",
"self",
".",
"_cache",
"=",
"cache_"
] | Initializes local cache from Django cache. | [
"Initializes",
"local",
"cache",
"from",
"Django",
"cache",
"."
] | 7fdb3800f7330dd4143d55416393d83d01a09f73 | https://github.com/idlesign/django-siteblocks/blob/7fdb3800f7330dd4143d55416393d83d01a09f73/siteblocks/siteblocksapp.py#L92-L97 | train | Initializes local cache from Django cache. |
idlesign/django-siteblocks | siteblocks/siteblocksapp.py | SiteBlocks.get_contents_static | def get_contents_static(self, block_alias, context):
"""Returns contents of a static block."""
if 'request' not in context:
# No use in further actions as we won't ever know current URL.
return ''
current_url = context['request'].path
# Resolve current view nam... | python | def get_contents_static(self, block_alias, context):
"""Returns contents of a static block."""
if 'request' not in context:
# No use in further actions as we won't ever know current URL.
return ''
current_url = context['request'].path
# Resolve current view nam... | [
"def",
"get_contents_static",
"(",
"self",
",",
"block_alias",
",",
"context",
")",
":",
"if",
"'request'",
"not",
"in",
"context",
":",
"# No use in further actions as we won't ever know current URL.",
"return",
"''",
"current_url",
"=",
"context",
"[",
"'request'",
... | Returns contents of a static block. | [
"Returns",
"contents",
"of",
"a",
"static",
"block",
"."
] | 7fdb3800f7330dd4143d55416393d83d01a09f73 | https://github.com/idlesign/django-siteblocks/blob/7fdb3800f7330dd4143d55416393d83d01a09f73/siteblocks/siteblocksapp.py#L114-L188 | train | Returns the contents of a static block. |
idlesign/django-siteblocks | siteblocks/siteblocksapp.py | SiteBlocks.get_contents_dynamic | def get_contents_dynamic(self, block_alias, context):
"""Returns contents of a dynamic block."""
dynamic_block = get_dynamic_blocks().get(block_alias, [])
if not dynamic_block:
return ''
dynamic_block = choice(dynamic_block)
return dynamic_block(block_alias=block_ali... | python | def get_contents_dynamic(self, block_alias, context):
"""Returns contents of a dynamic block."""
dynamic_block = get_dynamic_blocks().get(block_alias, [])
if not dynamic_block:
return ''
dynamic_block = choice(dynamic_block)
return dynamic_block(block_alias=block_ali... | [
"def",
"get_contents_dynamic",
"(",
"self",
",",
"block_alias",
",",
"context",
")",
":",
"dynamic_block",
"=",
"get_dynamic_blocks",
"(",
")",
".",
"get",
"(",
"block_alias",
",",
"[",
"]",
")",
"if",
"not",
"dynamic_block",
":",
"return",
"''",
"dynamic_bl... | Returns contents of a dynamic block. | [
"Returns",
"contents",
"of",
"a",
"dynamic",
"block",
"."
] | 7fdb3800f7330dd4143d55416393d83d01a09f73 | https://github.com/idlesign/django-siteblocks/blob/7fdb3800f7330dd4143d55416393d83d01a09f73/siteblocks/siteblocksapp.py#L190-L197 | train | Returns the contents of a dynamic block. |
idlesign/django-siteblocks | siteblocks/siteblocksapp.py | SiteBlocks.get | def get(self, block_alias, context):
"""Main method returning block contents (static or dynamic)."""
contents = []
dynamic_block_contents = self.get_contents_dynamic(block_alias, context)
if dynamic_block_contents:
contents.append(dynamic_block_contents)
static_bloc... | python | def get(self, block_alias, context):
"""Main method returning block contents (static or dynamic)."""
contents = []
dynamic_block_contents = self.get_contents_dynamic(block_alias, context)
if dynamic_block_contents:
contents.append(dynamic_block_contents)
static_bloc... | [
"def",
"get",
"(",
"self",
",",
"block_alias",
",",
"context",
")",
":",
"contents",
"=",
"[",
"]",
"dynamic_block_contents",
"=",
"self",
".",
"get_contents_dynamic",
"(",
"block_alias",
",",
"context",
")",
"if",
"dynamic_block_contents",
":",
"contents",
".... | Main method returning block contents (static or dynamic). | [
"Main",
"method",
"returning",
"block",
"contents",
"(",
"static",
"or",
"dynamic",
")",
"."
] | 7fdb3800f7330dd4143d55416393d83d01a09f73 | https://github.com/idlesign/django-siteblocks/blob/7fdb3800f7330dd4143d55416393d83d01a09f73/siteblocks/siteblocksapp.py#L199-L214 | train | Main method returning block contents. |
hyperledger-archives/indy-ledger | ledger/tree_hasher.py | TreeHasher._hash_full | def _hash_full(self, leaves, l_idx, r_idx):
"""Hash the leaves between (l_idx, r_idx) as a valid entire tree.
Note that this is only valid for certain combinations of indexes,
depending on where the leaves are meant to be located in a parent tree.
Returns:
(root_hash, hashe... | python | def _hash_full(self, leaves, l_idx, r_idx):
"""Hash the leaves between (l_idx, r_idx) as a valid entire tree.
Note that this is only valid for certain combinations of indexes,
depending on where the leaves are meant to be located in a parent tree.
Returns:
(root_hash, hashe... | [
"def",
"_hash_full",
"(",
"self",
",",
"leaves",
",",
"l_idx",
",",
"r_idx",
")",
":",
"width",
"=",
"r_idx",
"-",
"l_idx",
"if",
"width",
"<",
"0",
"or",
"l_idx",
"<",
"0",
"or",
"r_idx",
">",
"len",
"(",
"leaves",
")",
":",
"raise",
"IndexError",... | Hash the leaves between (l_idx, r_idx) as a valid entire tree.
Note that this is only valid for certain combinations of indexes,
depending on where the leaves are meant to be located in a parent tree.
Returns:
(root_hash, hashes): where root_hash is that of the entire tree,
... | [
"Hash",
"the",
"leaves",
"between",
"(",
"l_idx",
"r_idx",
")",
"as",
"a",
"valid",
"entire",
"tree",
"."
] | 7210c3b288e07f940eddad09b1dfc6a56be846df | https://github.com/hyperledger-archives/indy-ledger/blob/7210c3b288e07f940eddad09b1dfc6a56be846df/ledger/tree_hasher.py#L32-L61 | train | Hash the leaves between l_idx and r_idx. |
hyperledger-archives/indy-ledger | ledger/tree_hasher.py | TreeHasher.hash_full_tree | def hash_full_tree(self, leaves):
"""Hash a set of leaves representing a valid full tree."""
root_hash, hashes = self._hash_full(leaves, 0, len(leaves))
assert len(hashes) == count_bits_set(len(leaves))
assert (self._hash_fold(hashes) == root_hash if hashes else
root_hash... | python | def hash_full_tree(self, leaves):
"""Hash a set of leaves representing a valid full tree."""
root_hash, hashes = self._hash_full(leaves, 0, len(leaves))
assert len(hashes) == count_bits_set(len(leaves))
assert (self._hash_fold(hashes) == root_hash if hashes else
root_hash... | [
"def",
"hash_full_tree",
"(",
"self",
",",
"leaves",
")",
":",
"root_hash",
",",
"hashes",
"=",
"self",
".",
"_hash_full",
"(",
"leaves",
",",
"0",
",",
"len",
"(",
"leaves",
")",
")",
"assert",
"len",
"(",
"hashes",
")",
"==",
"count_bits_set",
"(",
... | Hash a set of leaves representing a valid full tree. | [
"Hash",
"a",
"set",
"of",
"leaves",
"representing",
"a",
"valid",
"full",
"tree",
"."
] | 7210c3b288e07f940eddad09b1dfc6a56be846df | https://github.com/hyperledger-archives/indy-ledger/blob/7210c3b288e07f940eddad09b1dfc6a56be846df/ledger/tree_hasher.py#L63-L69 | train | Hash a set of leaves representing a valid full tree. |
johnnoone/json-spec | src/jsonspec/validators/draft03.py | compile | def compile(schema, pointer, context, scope=None):
"""
Compiles schema with `JSON Schema`_ draft-03.
:param schema: obj to compile
:type schema: Mapping
:param pointer: uri of the schema
:type pointer: Pointer, str
:param context: context of this schema
:type context: Context
.. _`... | python | def compile(schema, pointer, context, scope=None):
"""
Compiles schema with `JSON Schema`_ draft-03.
:param schema: obj to compile
:type schema: Mapping
:param pointer: uri of the schema
:type pointer: Pointer, str
:param context: context of this schema
:type context: Context
.. _`... | [
"def",
"compile",
"(",
"schema",
",",
"pointer",
",",
"context",
",",
"scope",
"=",
"None",
")",
":",
"schm",
"=",
"deepcopy",
"(",
"schema",
")",
"scope",
"=",
"urljoin",
"(",
"scope",
"or",
"str",
"(",
"pointer",
")",
",",
"schm",
".",
"pop",
"("... | Compiles schema with `JSON Schema`_ draft-03.
:param schema: obj to compile
:type schema: Mapping
:param pointer: uri of the schema
:type pointer: Pointer, str
:param context: context of this schema
:type context: Context
.. _`JSON Schema`: http://json-schema.org | [
"Compiles",
"schema",
"with",
"JSON",
"Schema",
"_",
"draft",
"-",
"03",
"."
] | f91981724cea0c366bd42a6670eb07bbe31c0e0c | https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/validators/draft03.py#L32-L247 | train | Compile a JSON schema with JSON Schema_ draft - 03. |
johnnoone/json-spec | src/jsonspec/validators/draft03.py | Draft03Validator.validate | def validate(self, obj, pointer=None):
"""
Validate object against validator
:param obj: the object to validate
"""
pointer = pointer or '#'
validator = deepcopy(self)
validator.errors = []
validator.fail_fast = False
obj = deepcopy(obj)
... | python | def validate(self, obj, pointer=None):
"""
Validate object against validator
:param obj: the object to validate
"""
pointer = pointer or '#'
validator = deepcopy(self)
validator.errors = []
validator.fail_fast = False
obj = deepcopy(obj)
... | [
"def",
"validate",
"(",
"self",
",",
"obj",
",",
"pointer",
"=",
"None",
")",
":",
"pointer",
"=",
"pointer",
"or",
"'#'",
"validator",
"=",
"deepcopy",
"(",
"self",
")",
"validator",
".",
"errors",
"=",
"[",
"]",
"validator",
".",
"fail_fast",
"=",
... | Validate object against validator
:param obj: the object to validate | [
"Validate",
"object",
"against",
"validator"
] | f91981724cea0c366bd42a6670eb07bbe31c0e0c | https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/validators/draft03.py#L301-L346 | train | Validate object against the validator |
johnnoone/json-spec | src/jsonspec/validators/draft03.py | Draft03Validator.validate_format | def validate_format(self, obj, pointer=None):
"""
================= ============
Expected draft03 Alias of
----------------- ------------
color css.color
date-time utc.datetime
date utc.date
time utc.time
... | python | def validate_format(self, obj, pointer=None):
"""
================= ============
Expected draft03 Alias of
----------------- ------------
color css.color
date-time utc.datetime
date utc.date
time utc.time
... | [
"def",
"validate_format",
"(",
"self",
",",
"obj",
",",
"pointer",
"=",
"None",
")",
":",
"if",
"'format'",
"in",
"self",
".",
"attrs",
":",
"substituted",
"=",
"{",
"'color'",
":",
"'css.color'",
",",
"'date-time'",
":",
"'utc.datetime'",
",",
"'date'",
... | ================= ============
Expected draft03 Alias of
----------------- ------------
color css.color
date-time utc.datetime
date utc.date
time utc.time
utc-millisec utc.millisec
regex regex... | [
"=================",
"============",
"Expected",
"draft03",
"Alias",
"of",
"-----------------",
"------------",
"color",
"css",
".",
"color",
"date",
"-",
"time",
"utc",
".",
"datetime",
"date",
"utc",
".",
"date",
"time",
"utc",
".",
"time",
"utc",
"-",
"mill... | f91981724cea0c366bd42a6670eb07bbe31c0e0c | https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/validators/draft03.py#L424-L464 | train | Validate the format attribute of the object. |
lreis2415/PyGeoC | examples/ex06_model_performace_index.py | cal_model_performance | def cal_model_performance(obsl, siml):
"""Calculate model performance indexes."""
nse = MathClass.nashcoef(obsl, siml)
r2 = MathClass.rsquare(obsl, siml)
rmse = MathClass.rmse(obsl, siml)
pbias = MathClass.pbias(obsl, siml)
rsr = MathClass.rsr(obsl, siml)
print('NSE: %.2f, R-square: %... | python | def cal_model_performance(obsl, siml):
"""Calculate model performance indexes."""
nse = MathClass.nashcoef(obsl, siml)
r2 = MathClass.rsquare(obsl, siml)
rmse = MathClass.rmse(obsl, siml)
pbias = MathClass.pbias(obsl, siml)
rsr = MathClass.rsr(obsl, siml)
print('NSE: %.2f, R-square: %... | [
"def",
"cal_model_performance",
"(",
"obsl",
",",
"siml",
")",
":",
"nse",
"=",
"MathClass",
".",
"nashcoef",
"(",
"obsl",
",",
"siml",
")",
"r2",
"=",
"MathClass",
".",
"rsquare",
"(",
"obsl",
",",
"siml",
")",
"rmse",
"=",
"MathClass",
".",
"rmse",
... | Calculate model performance indexes. | [
"Calculate",
"model",
"performance",
"indexes",
"."
] | 9a92d1a229bb74298e3c57f27c97079980b5f729 | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/examples/ex06_model_performace_index.py#L7-L15 | train | Calculate model performance indexes. |
nmdp-bioinformatics/SeqAnn | seqann/gfe.py | GFE.load_features | def load_features(self):
"""
Loads all the known features from the feature service
"""
# Loading all loci that
# are in self.loci variable defined
# when the pyGFE object is created
for loc in self.loci:
if self.verbose:
self.logger.inf... | python | def load_features(self):
"""
Loads all the known features from the feature service
"""
# Loading all loci that
# are in self.loci variable defined
# when the pyGFE object is created
for loc in self.loci:
if self.verbose:
self.logger.inf... | [
"def",
"load_features",
"(",
"self",
")",
":",
"# Loading all loci that",
"# are in self.loci variable defined",
"# when the pyGFE object is created",
"for",
"loc",
"in",
"self",
".",
"loci",
":",
"if",
"self",
".",
"verbose",
":",
"self",
".",
"logger",
".",
"info"... | Loads all the known features from the feature service | [
"Loads",
"all",
"the",
"known",
"features",
"from",
"the",
"feature",
"service"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/gfe.py#L100-L119 | train | Loads all the known features from the feature service |
nmdp-bioinformatics/SeqAnn | seqann/gfe.py | GFE.locus_features | def locus_features(self, locus):
"""
Returns all features associated with a locus
:param locus: string containing HLA locus.
:type locus: ``str``
:rtype: ``dict``
"""
features = self.api.list_features(locus=locus)
feat_dict = {":".join([a.locus, str(a.ran... | python | def locus_features(self, locus):
"""
Returns all features associated with a locus
:param locus: string containing HLA locus.
:type locus: ``str``
:rtype: ``dict``
"""
features = self.api.list_features(locus=locus)
feat_dict = {":".join([a.locus, str(a.ran... | [
"def",
"locus_features",
"(",
"self",
",",
"locus",
")",
":",
"features",
"=",
"self",
".",
"api",
".",
"list_features",
"(",
"locus",
"=",
"locus",
")",
"feat_dict",
"=",
"{",
"\":\"",
".",
"join",
"(",
"[",
"a",
".",
"locus",
",",
"str",
"(",
"a"... | Returns all features associated with a locus
:param locus: string containing HLA locus.
:type locus: ``str``
:rtype: ``dict`` | [
"Returns",
"all",
"features",
"associated",
"with",
"a",
"locus"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/gfe.py#L121-L131 | train | Returns all features associated with a locus. |
nmdp-bioinformatics/SeqAnn | seqann/gfe.py | GFE.get_gfe | def get_gfe(self, annotation, locus):
"""
creates GFE from a sequence annotation
:param locus: The gene locus
:type locus: ``str``
:param annotation: An sequence annotation object
:type annotation: ``List``
:rtype: ``List``
Returns:
The GFE ... | python | def get_gfe(self, annotation, locus):
"""
creates GFE from a sequence annotation
:param locus: The gene locus
:type locus: ``str``
:param annotation: An sequence annotation object
:type annotation: ``List``
:rtype: ``List``
Returns:
The GFE ... | [
"def",
"get_gfe",
"(",
"self",
",",
"annotation",
",",
"locus",
")",
":",
"features",
"=",
"[",
"]",
"accessions",
"=",
"{",
"}",
"for",
"feat",
"in",
"annotation",
".",
"annotation",
":",
"if",
"isinstance",
"(",
"annotation",
".",
"annotation",
"[",
... | creates GFE from a sequence annotation
:param locus: The gene locus
:type locus: ``str``
:param annotation: An sequence annotation object
:type annotation: ``List``
:rtype: ``List``
Returns:
The GFE notation and the associated features in an array | [
"creates",
"GFE",
"from",
"a",
"sequence",
"annotation"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/gfe.py#L133-L272 | train | Creates GFE from a sequence annotation object and returns the GFE notation and the associated features in an array. |
nmdp-bioinformatics/SeqAnn | seqann/gfe.py | GFE._seq | def _seq(self, locus, term, rank, accession):
"""
creates GFE from HLA sequence and locus
:param locus: string containing HLA locus.
:param sequence: string containing sequence data.
:return: GFEobject.
"""
try:
feature = self.api.get_feature_by_path... | python | def _seq(self, locus, term, rank, accession):
"""
creates GFE from HLA sequence and locus
:param locus: string containing HLA locus.
:param sequence: string containing sequence data.
:return: GFEobject.
"""
try:
feature = self.api.get_feature_by_path... | [
"def",
"_seq",
"(",
"self",
",",
"locus",
",",
"term",
",",
"rank",
",",
"accession",
")",
":",
"try",
":",
"feature",
"=",
"self",
".",
"api",
".",
"get_feature_by_path",
"(",
"locus",
",",
"term",
",",
"rank",
",",
"accession",
")",
"return",
"feat... | creates GFE from HLA sequence and locus
:param locus: string containing HLA locus.
:param sequence: string containing sequence data.
:return: GFEobject. | [
"creates",
"GFE",
"from",
"HLA",
"sequence",
"and",
"locus"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/gfe.py#L274-L291 | train | creates GFE from HLA sequence and locus |
nmdp-bioinformatics/SeqAnn | seqann/gfe.py | GFE._breakup_gfe | def _breakup_gfe(self, gfe):
"""
creates GFE from HLA sequence and locus
:param locus: string containing HLA locus.
:param sequence: string containing sequence data.
:return: GFEobject.
"""
[locus, feature_accessions] = gfe.split("w")
accessions = featur... | python | def _breakup_gfe(self, gfe):
"""
creates GFE from HLA sequence and locus
:param locus: string containing HLA locus.
:param sequence: string containing sequence data.
:return: GFEobject.
"""
[locus, feature_accessions] = gfe.split("w")
accessions = featur... | [
"def",
"_breakup_gfe",
"(",
"self",
",",
"gfe",
")",
":",
"[",
"locus",
",",
"feature_accessions",
"]",
"=",
"gfe",
".",
"split",
"(",
"\"w\"",
")",
"accessions",
"=",
"feature_accessions",
".",
"split",
"(",
"\"-\"",
")",
"i",
"=",
"0",
"features",
"=... | creates GFE from HLA sequence and locus
:param locus: string containing HLA locus.
:param sequence: string containing sequence data.
:return: GFEobject. | [
"creates",
"GFE",
"from",
"HLA",
"sequence",
"and",
"locus"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/gfe.py#L293-L311 | train | This function creates GFE object from HLA sequence and locus and locus. |
nmdp-bioinformatics/SeqAnn | seqann/gfe.py | GFE._make_gfe | def _make_gfe(self, features, locus):
"""
creates GFE from HLA sequence and locus
:param locus: string containing HLA locus.
:param sequence: string containing sequence data.
:return: GFEobject.
"""
gfe_list = []
for feat in sorted(self.structures[locus]... | python | def _make_gfe(self, features, locus):
"""
creates GFE from HLA sequence and locus
:param locus: string containing HLA locus.
:param sequence: string containing sequence data.
:return: GFEobject.
"""
gfe_list = []
for feat in sorted(self.structures[locus]... | [
"def",
"_make_gfe",
"(",
"self",
",",
"features",
",",
"locus",
")",
":",
"gfe_list",
"=",
"[",
"]",
"for",
"feat",
"in",
"sorted",
"(",
"self",
".",
"structures",
"[",
"locus",
"]",
",",
"key",
"=",
"lambda",
"k",
":",
"self",
".",
"structures",
"... | creates GFE from HLA sequence and locus
:param locus: string containing HLA locus.
:param sequence: string containing sequence data.
:return: GFEobject. | [
"creates",
"GFE",
"from",
"HLA",
"sequence",
"and",
"locus"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/gfe.py#L313-L331 | train | Creates GFE from HLA sequence and locus. |
LISE-B26/pylabcontrol | pylabcontrol/scripts/select_points.py | SelectPoints.toggle_NV | def toggle_NV(self, pt):
'''
If there is not currently a selected NV within self.settings[patch_size] of pt, adds it to the selected list. If
there is, removes that point from the selected list.
Args:
pt: the point to add or remove from the selected list
Poststate: up... | python | def toggle_NV(self, pt):
'''
If there is not currently a selected NV within self.settings[patch_size] of pt, adds it to the selected list. If
there is, removes that point from the selected list.
Args:
pt: the point to add or remove from the selected list
Poststate: up... | [
"def",
"toggle_NV",
"(",
"self",
",",
"pt",
")",
":",
"if",
"not",
"self",
".",
"data",
"[",
"'nv_locations'",
"]",
":",
"#if self.data is empty so this is the first point",
"self",
".",
"data",
"[",
"'nv_locations'",
"]",
".",
"append",
"(",
"pt",
")",
"sel... | If there is not currently a selected NV within self.settings[patch_size] of pt, adds it to the selected list. If
there is, removes that point from the selected list.
Args:
pt: the point to add or remove from the selected list
Poststate: updates selected list | [
"If",
"there",
"is",
"not",
"currently",
"a",
"selected",
"NV",
"within",
"self",
".",
"settings",
"[",
"patch_size",
"]",
"of",
"pt",
"adds",
"it",
"to",
"the",
"selected",
"list",
".",
"If",
"there",
"is",
"removes",
"that",
"point",
"from",
"the",
"... | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/pylabcontrol/scripts/select_points.py#L120-L253 | train | toggle_NV - Toggles the NV of a specific point in the selected list |
CitrineInformatics/pif-dft | dfttopif/drivers.py | tarfile_to_pif | def tarfile_to_pif(filename, temp_root_dir='', verbose=0):
"""
Process a tar file that contains DFT data.
Input:
filename - String, Path to the file to process.
temp_root_dir - String, Directory in which to save temporary files. Defaults to working directory.
verbose - int, How much... | python | def tarfile_to_pif(filename, temp_root_dir='', verbose=0):
"""
Process a tar file that contains DFT data.
Input:
filename - String, Path to the file to process.
temp_root_dir - String, Directory in which to save temporary files. Defaults to working directory.
verbose - int, How much... | [
"def",
"tarfile_to_pif",
"(",
"filename",
",",
"temp_root_dir",
"=",
"''",
",",
"verbose",
"=",
"0",
")",
":",
"temp_dir",
"=",
"temp_root_dir",
"+",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"os",
".",
"makedirs",
"(",
"temp_dir",
")",
"try",
... | Process a tar file that contains DFT data.
Input:
filename - String, Path to the file to process.
temp_root_dir - String, Directory in which to save temporary files. Defaults to working directory.
verbose - int, How much status messages to print
Output:
pif - ChemicalSystem, Re... | [
"Process",
"a",
"tar",
"file",
"that",
"contains",
"DFT",
"data",
"."
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/drivers.py#L59-L84 | train | Process a tar file that contains DFT data and return a PIF file. |
CitrineInformatics/pif-dft | dfttopif/drivers.py | archive_to_pif | def archive_to_pif(filename, verbose=0):
"""
Given a archive file that contains output from a DFT calculation, parse the data and return a PIF object.
Input:
filename - String, Path to the file to process.
verbose - int, How much status messages to print
Output:
pif - ChemicalS... | python | def archive_to_pif(filename, verbose=0):
"""
Given a archive file that contains output from a DFT calculation, parse the data and return a PIF object.
Input:
filename - String, Path to the file to process.
verbose - int, How much status messages to print
Output:
pif - ChemicalS... | [
"def",
"archive_to_pif",
"(",
"filename",
",",
"verbose",
"=",
"0",
")",
":",
"if",
"tarfile",
".",
"is_tarfile",
"(",
"filename",
")",
":",
"return",
"tarfile_to_pif",
"(",
"filename",
",",
"verbose",
")",
"raise",
"Exception",
"(",
"'Cannot process file type... | Given a archive file that contains output from a DFT calculation, parse the data and return a PIF object.
Input:
filename - String, Path to the file to process.
verbose - int, How much status messages to print
Output:
pif - ChemicalSystem, Results and settings of
the DFT ca... | [
"Given",
"a",
"archive",
"file",
"that",
"contains",
"output",
"from",
"a",
"DFT",
"calculation",
"parse",
"the",
"data",
"and",
"return",
"a",
"PIF",
"object",
"."
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/drivers.py#L87-L101 | train | Given a file that contains output from a DFT calculation parse the data and return a PIF object. |
CitrineInformatics/pif-dft | dfttopif/drivers.py | files_to_pif | def files_to_pif(files, verbose=0, quality_report=True, inline=True):
'''Given a directory that contains output from
a DFT calculation, parse the data and return
a pif object
Input:
files - [str] list of files from which the parser is allowed to read.
verbose - int, How much status mess... | python | def files_to_pif(files, verbose=0, quality_report=True, inline=True):
'''Given a directory that contains output from
a DFT calculation, parse the data and return
a pif object
Input:
files - [str] list of files from which the parser is allowed to read.
verbose - int, How much status mess... | [
"def",
"files_to_pif",
"(",
"files",
",",
"verbose",
"=",
"0",
",",
"quality_report",
"=",
"True",
",",
"inline",
"=",
"True",
")",
":",
"# Look for the first parser compatible with the directory",
"found_parser",
"=",
"False",
"for",
"possible_parser",
"in",
"[",
... | Given a directory that contains output from
a DFT calculation, parse the data and return
a pif object
Input:
files - [str] list of files from which the parser is allowed to read.
verbose - int, How much status messages to print
Output:
pif - ChemicalSystem, Results and settings... | [
"Given",
"a",
"directory",
"that",
"contains",
"output",
"from",
"a",
"DFT",
"calculation",
"parse",
"the",
"data",
"and",
"return",
"a",
"pif",
"object"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/drivers.py#L104-L197 | train | Given a list of files in a directory that contains output from a DFT calculation parse the data and return a pif object. |
CitrineInformatics/pif-dft | dfttopif/drivers.py | directory_to_pif | def directory_to_pif(directory, **kwargs):
"""
Convert a directory to a pif
:param directory: Directory to convert to a pif
:param kwargs: any additional keyword arguments. (See `files_to_pif`)
:return: the created pif
"""
# Get the files
files = [os.path.join(directory, f) for f in os.... | python | def directory_to_pif(directory, **kwargs):
"""
Convert a directory to a pif
:param directory: Directory to convert to a pif
:param kwargs: any additional keyword arguments. (See `files_to_pif`)
:return: the created pif
"""
# Get the files
files = [os.path.join(directory, f) for f in os.... | [
"def",
"directory_to_pif",
"(",
"directory",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get the files",
"files",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"f",
")",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
"if"... | Convert a directory to a pif
:param directory: Directory to convert to a pif
:param kwargs: any additional keyword arguments. (See `files_to_pif`)
:return: the created pif | [
"Convert",
"a",
"directory",
"to",
"a",
"pif",
":",
"param",
"directory",
":",
"Directory",
"to",
"convert",
"to",
"a",
"pif",
":",
"param",
"kwargs",
":",
"any",
"additional",
"keyword",
"arguments",
".",
"(",
"See",
"files_to_pif",
")",
":",
"return",
... | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/drivers.py#L200-L213 | train | Convert a directory to a pif
|
CitrineInformatics/pif-dft | dfttopif/drivers.py | convert | def convert(files, **kwargs):
"""
Wrap directory to pif as a dice extension
:param files: a list of files, which must be non-empty
:param kwargs: any additional keyword arguments
:return: the created pif
"""
if len(files) < 1:
raise ValueError("Files needs to be a non-empty list")
... | python | def convert(files, **kwargs):
"""
Wrap directory to pif as a dice extension
:param files: a list of files, which must be non-empty
:param kwargs: any additional keyword arguments
:return: the created pif
"""
if len(files) < 1:
raise ValueError("Files needs to be a non-empty list")
... | [
"def",
"convert",
"(",
"files",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"files",
")",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"Files needs to be a non-empty list\"",
")",
"if",
"len",
"(",
"files",
")",
"==",
"1",
":",
"if",
"os",
"... | Wrap directory to pif as a dice extension
:param files: a list of files, which must be non-empty
:param kwargs: any additional keyword arguments
:return: the created pif | [
"Wrap",
"directory",
"to",
"pif",
"as",
"a",
"dice",
"extension",
":",
"param",
"files",
":",
"a",
"list",
"of",
"files",
"which",
"must",
"be",
"non",
"-",
"empty",
":",
"param",
"kwargs",
":",
"any",
"additional",
"keyword",
"arguments",
":",
"return",... | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/drivers.py#L216-L233 | train | Wrap a directory to pif |
PeerAssets/pypeerassets | examples/once_issue_mode_example.py | wait_for_confirmation | def wait_for_confirmation(provider, transaction_id):
'Sleep on a loop until we see a confirmation of the transaction.'
while(True):
transaction = provider.gettransaction(transaction_id)
if transaction["confirmations"] > 0:
break
time.sleep(10) | python | def wait_for_confirmation(provider, transaction_id):
'Sleep on a loop until we see a confirmation of the transaction.'
while(True):
transaction = provider.gettransaction(transaction_id)
if transaction["confirmations"] > 0:
break
time.sleep(10) | [
"def",
"wait_for_confirmation",
"(",
"provider",
",",
"transaction_id",
")",
":",
"while",
"(",
"True",
")",
":",
"transaction",
"=",
"provider",
".",
"gettransaction",
"(",
"transaction_id",
")",
"if",
"transaction",
"[",
"\"confirmations\"",
"]",
">",
"0",
"... | Sleep on a loop until we see a confirmation of the transaction. | [
"Sleep",
"on",
"a",
"loop",
"until",
"we",
"see",
"a",
"confirmation",
"of",
"the",
"transaction",
"."
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/examples/once_issue_mode_example.py#L51-L57 | train | Sleep on a loop until we see a confirmation of the transaction. |
PeerAssets/pypeerassets | pypeerassets/protocol.py | validate_card_issue_modes | def validate_card_issue_modes(issue_mode: int, cards: list) -> list:
"""validate cards against deck_issue modes"""
supported_mask = 63 # sum of all issue_mode values
if not bool(issue_mode & supported_mask):
return [] # return empty list
for i in [1 << x for x in range(len(IssueMode))]:
... | python | def validate_card_issue_modes(issue_mode: int, cards: list) -> list:
"""validate cards against deck_issue modes"""
supported_mask = 63 # sum of all issue_mode values
if not bool(issue_mode & supported_mask):
return [] # return empty list
for i in [1 << x for x in range(len(IssueMode))]:
... | [
"def",
"validate_card_issue_modes",
"(",
"issue_mode",
":",
"int",
",",
"cards",
":",
"list",
")",
"->",
"list",
":",
"supported_mask",
"=",
"63",
"# sum of all issue_mode values",
"if",
"not",
"bool",
"(",
"issue_mode",
"&",
"supported_mask",
")",
":",
"return"... | validate cards against deck_issue modes | [
"validate",
"cards",
"against",
"deck_issue",
"modes"
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L365-L389 | train | validate cards against deck_issue modes |
PeerAssets/pypeerassets | pypeerassets/protocol.py | Deck.p2th_address | def p2th_address(self) -> Optional[str]:
'''P2TH address of this deck'''
if self.id:
return Kutil(network=self.network,
privkey=bytearray.fromhex(self.id)).address
else:
return None | python | def p2th_address(self) -> Optional[str]:
'''P2TH address of this deck'''
if self.id:
return Kutil(network=self.network,
privkey=bytearray.fromhex(self.id)).address
else:
return None | [
"def",
"p2th_address",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"self",
".",
"id",
":",
"return",
"Kutil",
"(",
"network",
"=",
"self",
".",
"network",
",",
"privkey",
"=",
"bytearray",
".",
"fromhex",
"(",
"self",
".",
"id",
... | P2TH address of this deck | [
"P2TH",
"address",
"of",
"this",
"deck"
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L89-L96 | train | P2TH address of this deck |
PeerAssets/pypeerassets | pypeerassets/protocol.py | Deck.p2th_wif | def p2th_wif(self) -> Optional[str]:
'''P2TH privkey in WIF format'''
if self.id:
return Kutil(network=self.network,
privkey=bytearray.fromhex(self.id)).wif
else:
return None | python | def p2th_wif(self) -> Optional[str]:
'''P2TH privkey in WIF format'''
if self.id:
return Kutil(network=self.network,
privkey=bytearray.fromhex(self.id)).wif
else:
return None | [
"def",
"p2th_wif",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"self",
".",
"id",
":",
"return",
"Kutil",
"(",
"network",
"=",
"self",
".",
"network",
",",
"privkey",
"=",
"bytearray",
".",
"fromhex",
"(",
"self",
".",
"id",
")"... | P2TH privkey in WIF format | [
"P2TH",
"privkey",
"in",
"WIF",
"format"
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L99-L106 | train | P2TH privkey in WIF format? |
PeerAssets/pypeerassets | pypeerassets/protocol.py | Deck.metainfo_to_protobuf | def metainfo_to_protobuf(self) -> bytes:
'''encode deck into protobuf'''
deck = deckspawnproto()
deck.version = self.version
deck.name = self.name
deck.number_of_decimals = self.number_of_decimals
deck.issue_mode = self.issue_mode
if self.asset_specific_data:
... | python | def metainfo_to_protobuf(self) -> bytes:
'''encode deck into protobuf'''
deck = deckspawnproto()
deck.version = self.version
deck.name = self.name
deck.number_of_decimals = self.number_of_decimals
deck.issue_mode = self.issue_mode
if self.asset_specific_data:
... | [
"def",
"metainfo_to_protobuf",
"(",
"self",
")",
"->",
"bytes",
":",
"deck",
"=",
"deckspawnproto",
"(",
")",
"deck",
".",
"version",
"=",
"self",
".",
"version",
"deck",
".",
"name",
"=",
"self",
".",
"name",
"deck",
".",
"number_of_decimals",
"=",
"sel... | encode deck into protobuf | [
"encode",
"deck",
"into",
"protobuf"
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L109-L129 | train | encode deck into protobuf |
PeerAssets/pypeerassets | pypeerassets/protocol.py | Deck.metainfo_to_dict | def metainfo_to_dict(self) -> dict:
'''encode deck into dictionary'''
r = {
"version": self.version,
"name": self.name,
"number_of_decimals": self.number_of_decimals,
"issue_mode": self.issue_mode
}
if self.asset_specific_data:
... | python | def metainfo_to_dict(self) -> dict:
'''encode deck into dictionary'''
r = {
"version": self.version,
"name": self.name,
"number_of_decimals": self.number_of_decimals,
"issue_mode": self.issue_mode
}
if self.asset_specific_data:
... | [
"def",
"metainfo_to_dict",
"(",
"self",
")",
"->",
"dict",
":",
"r",
"=",
"{",
"\"version\"",
":",
"self",
".",
"version",
",",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"number_of_decimals\"",
":",
"self",
".",
"number_of_decimals",
",",
"\"issue_mode\""... | encode deck into dictionary | [
"encode",
"deck",
"into",
"dictionary"
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L132-L145 | train | encode deck into dictionary |
PeerAssets/pypeerassets | pypeerassets/protocol.py | Deck.to_json | def to_json(self) -> dict:
'''export the Deck object to json-ready format'''
d = self.__dict__
d['p2th_wif'] = self.p2th_wif
return d | python | def to_json(self) -> dict:
'''export the Deck object to json-ready format'''
d = self.__dict__
d['p2th_wif'] = self.p2th_wif
return d | [
"def",
"to_json",
"(",
"self",
")",
"->",
"dict",
":",
"d",
"=",
"self",
".",
"__dict__",
"d",
"[",
"'p2th_wif'",
"]",
"=",
"self",
".",
"p2th_wif",
"return",
"d"
] | export the Deck object to json-ready format | [
"export",
"the",
"Deck",
"object",
"to",
"json",
"-",
"ready",
"format"
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L147-L152 | train | export the Deck object to json - ready format |
PeerAssets/pypeerassets | pypeerassets/protocol.py | CardTransfer.metainfo_to_protobuf | def metainfo_to_protobuf(self) -> bytes:
'''encode card_transfer info to protobuf'''
card = cardtransferproto()
card.version = self.version
card.amount.extend(self.amount)
card.number_of_decimals = self.number_of_decimals
if self.asset_specific_data:
if not i... | python | def metainfo_to_protobuf(self) -> bytes:
'''encode card_transfer info to protobuf'''
card = cardtransferproto()
card.version = self.version
card.amount.extend(self.amount)
card.number_of_decimals = self.number_of_decimals
if self.asset_specific_data:
if not i... | [
"def",
"metainfo_to_protobuf",
"(",
"self",
")",
"->",
"bytes",
":",
"card",
"=",
"cardtransferproto",
"(",
")",
"card",
".",
"version",
"=",
"self",
".",
"version",
"card",
".",
"amount",
".",
"extend",
"(",
"self",
".",
"amount",
")",
"card",
".",
"n... | encode card_transfer info to protobuf | [
"encode",
"card_transfer",
"info",
"to",
"protobuf"
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L309-L328 | train | encode card_transfer info to protobuf |
PeerAssets/pypeerassets | pypeerassets/protocol.py | CardTransfer.metainfo_to_dict | def metainfo_to_dict(self) -> dict:
'''encode card into dictionary'''
r = {
"version": self.version,
"amount": self.amount,
"number_of_decimals": self.number_of_decimals
}
if self.asset_specific_data:
r.update({'asset_specific_data': self... | python | def metainfo_to_dict(self) -> dict:
'''encode card into dictionary'''
r = {
"version": self.version,
"amount": self.amount,
"number_of_decimals": self.number_of_decimals
}
if self.asset_specific_data:
r.update({'asset_specific_data': self... | [
"def",
"metainfo_to_dict",
"(",
"self",
")",
"->",
"dict",
":",
"r",
"=",
"{",
"\"version\"",
":",
"self",
".",
"version",
",",
"\"amount\"",
":",
"self",
".",
"amount",
",",
"\"number_of_decimals\"",
":",
"self",
".",
"number_of_decimals",
"}",
"if",
"sel... | encode card into dictionary | [
"encode",
"card",
"into",
"dictionary"
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L331-L343 | train | encode card into dictionary |
PeerAssets/pypeerassets | pypeerassets/protocol.py | DeckState._sort_cards | def _sort_cards(self, cards: Generator) -> list:
'''sort cards by blocknum and blockseq'''
return sorted([card.__dict__ for card in cards],
key=itemgetter('blocknum', 'blockseq', 'cardseq')) | python | def _sort_cards(self, cards: Generator) -> list:
'''sort cards by blocknum and blockseq'''
return sorted([card.__dict__ for card in cards],
key=itemgetter('blocknum', 'blockseq', 'cardseq')) | [
"def",
"_sort_cards",
"(",
"self",
",",
"cards",
":",
"Generator",
")",
"->",
"list",
":",
"return",
"sorted",
"(",
"[",
"card",
".",
"__dict__",
"for",
"card",
"in",
"cards",
"]",
",",
"key",
"=",
"itemgetter",
"(",
"'blocknum'",
",",
"'blockseq'",
",... | sort cards by blocknum and blockseq | [
"sort",
"cards",
"by",
"blocknum",
"and",
"blockseq"
] | 8927b4a686887f44fe2cd9de777e2c827c948987 | https://github.com/PeerAssets/pypeerassets/blob/8927b4a686887f44fe2cd9de777e2c827c948987/pypeerassets/protocol.py#L439-L443 | train | sort cards by blocknum and blockseq |
lreis2415/PyGeoC | examples/ex07_handling_raster_with_numpy.py | main | def main():
"""Read GeoTiff raster data and perform log transformation.
"""
input_tif = "../tests/data/Jamaica_dem.tif"
output_tif = "../tests/data/tmp_results/log_dem.tif"
rst = RasterUtilClass.read_raster(input_tif)
# raster data (with noDataValue as numpy.nan) as numpy array
rst_valid = r... | python | def main():
"""Read GeoTiff raster data and perform log transformation.
"""
input_tif = "../tests/data/Jamaica_dem.tif"
output_tif = "../tests/data/tmp_results/log_dem.tif"
rst = RasterUtilClass.read_raster(input_tif)
# raster data (with noDataValue as numpy.nan) as numpy array
rst_valid = r... | [
"def",
"main",
"(",
")",
":",
"input_tif",
"=",
"\"../tests/data/Jamaica_dem.tif\"",
"output_tif",
"=",
"\"../tests/data/tmp_results/log_dem.tif\"",
"rst",
"=",
"RasterUtilClass",
".",
"read_raster",
"(",
"input_tif",
")",
"# raster data (with noDataValue as numpy.nan) as numpy... | Read GeoTiff raster data and perform log transformation. | [
"Read",
"GeoTiff",
"raster",
"data",
"and",
"perform",
"log",
"transformation",
"."
] | 9a92d1a229bb74298e3c57f27c97079980b5f729 | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/examples/ex07_handling_raster_with_numpy.py#L10-L21 | train | Read GeoTiff raster data and perform log transformation.
|
zero-os/zerotier_client | zerotier/client_support.py | val_factory | def val_factory(val, datatypes):
"""
return an instance of `val` that is of type `datatype`.
keep track of exceptions so we can produce meaningful error messages.
"""
exceptions = []
for dt in datatypes:
try:
if isinstance(val, dt):
return val
retu... | python | def val_factory(val, datatypes):
"""
return an instance of `val` that is of type `datatype`.
keep track of exceptions so we can produce meaningful error messages.
"""
exceptions = []
for dt in datatypes:
try:
if isinstance(val, dt):
return val
retu... | [
"def",
"val_factory",
"(",
"val",
",",
"datatypes",
")",
":",
"exceptions",
"=",
"[",
"]",
"for",
"dt",
"in",
"datatypes",
":",
"try",
":",
"if",
"isinstance",
"(",
"val",
",",
"dt",
")",
":",
"return",
"val",
"return",
"type_handler_object",
"(",
"val... | return an instance of `val` that is of type `datatype`.
keep track of exceptions so we can produce meaningful error messages. | [
"return",
"an",
"instance",
"of",
"val",
"that",
"is",
"of",
"type",
"datatype",
".",
"keep",
"track",
"of",
"exceptions",
"so",
"we",
"can",
"produce",
"meaningful",
"error",
"messages",
"."
] | 03993da11e69d837a0308a2f41ae7b378692fd82 | https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/client_support.py#L75-L90 | train | Factory function for creating a new object from a list of datatypes. |
zero-os/zerotier_client | zerotier/client_support.py | to_dict | def to_dict(cls, convert_datetime=True):
"""
return a dict representation of the Event and its sub-objects
`convert_datetime` controls whether datetime objects are converted to strings or not
:rtype: dict
"""
def todict(obj):
"""
recurse the objects and represent as a dict
... | python | def to_dict(cls, convert_datetime=True):
"""
return a dict representation of the Event and its sub-objects
`convert_datetime` controls whether datetime objects are converted to strings or not
:rtype: dict
"""
def todict(obj):
"""
recurse the objects and represent as a dict
... | [
"def",
"to_dict",
"(",
"cls",
",",
"convert_datetime",
"=",
"True",
")",
":",
"def",
"todict",
"(",
"obj",
")",
":",
"\"\"\"\n recurse the objects and represent as a dict\n use the registered handlers if possible\n \"\"\"",
"data",
"=",
"{",
"}",
"if",
... | return a dict representation of the Event and its sub-objects
`convert_datetime` controls whether datetime objects are converted to strings or not
:rtype: dict | [
"return",
"a",
"dict",
"representation",
"of",
"the",
"Event",
"and",
"its",
"sub",
"-",
"objects",
"convert_datetime",
"controls",
"whether",
"datetime",
"objects",
"are",
"converted",
"to",
"strings",
"or",
"not",
":",
"rtype",
":",
"dict"
] | 03993da11e69d837a0308a2f41ae7b378692fd82 | https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/client_support.py#L102-L132 | train | Returns a dict representation of the Event and its sub - objects
. convert_datetime controls whether datetime objects are converted to strings or not
|
zero-os/zerotier_client | zerotier/client_support.py | handler_for | def handler_for(obj):
"""return the handler for the object type"""
for handler_type in handlers:
if isinstance(obj, handler_type):
return handlers[handler_type]
try:
for handler_type in handlers:
if issubclass(obj, handler_type):
return handlers[handl... | python | def handler_for(obj):
"""return the handler for the object type"""
for handler_type in handlers:
if isinstance(obj, handler_type):
return handlers[handler_type]
try:
for handler_type in handlers:
if issubclass(obj, handler_type):
return handlers[handl... | [
"def",
"handler_for",
"(",
"obj",
")",
":",
"for",
"handler_type",
"in",
"handlers",
":",
"if",
"isinstance",
"(",
"obj",
",",
"handler_type",
")",
":",
"return",
"handlers",
"[",
"handler_type",
"]",
"try",
":",
"for",
"handler_type",
"in",
"handlers",
":... | return the handler for the object type | [
"return",
"the",
"handler",
"for",
"the",
"object",
"type"
] | 03993da11e69d837a0308a2f41ae7b378692fd82 | https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/client_support.py#L189-L201 | train | return the handler for the object type |
zero-os/zerotier_client | zerotier/client_support.py | type_handler_object | def type_handler_object(val, objtype):
"""
return the deserialized (restored) value from the registered handler for the type
"""
handler = handlers.get(objtype)
if handler:
return handler().restore(val)
else:
return objtype(val) | python | def type_handler_object(val, objtype):
"""
return the deserialized (restored) value from the registered handler for the type
"""
handler = handlers.get(objtype)
if handler:
return handler().restore(val)
else:
return objtype(val) | [
"def",
"type_handler_object",
"(",
"val",
",",
"objtype",
")",
":",
"handler",
"=",
"handlers",
".",
"get",
"(",
"objtype",
")",
"if",
"handler",
":",
"return",
"handler",
"(",
")",
".",
"restore",
"(",
"val",
")",
"else",
":",
"return",
"objtype",
"("... | return the deserialized (restored) value from the registered handler for the type | [
"return",
"the",
"deserialized",
"(",
"restored",
")",
"value",
"from",
"the",
"registered",
"handler",
"for",
"the",
"type"
] | 03993da11e69d837a0308a2f41ae7b378692fd82 | https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/client_support.py#L213-L221 | train | Return the deserialized value from the registered type
|
lreis2415/PyGeoC | pygeoc/postTauDEM.py | main | def main():
"""Test code"""
import os
# wp = r'C:\z_code\subrepos\PyGeoC\tests\data\tmp_results\wtsd_delineation'
wp = r'C:\z_data_m\SEIMS2018\zhongtianshe_100m\taudem_delineated'
dinfflowang = wp + os.sep + 'flowDirDinfTau.tif'
compdinffile = wp + os.sep + 'dirCodeDinfTau.tif'
weightfile = ... | python | def main():
"""Test code"""
import os
# wp = r'C:\z_code\subrepos\PyGeoC\tests\data\tmp_results\wtsd_delineation'
wp = r'C:\z_data_m\SEIMS2018\zhongtianshe_100m\taudem_delineated'
dinfflowang = wp + os.sep + 'flowDirDinfTau.tif'
compdinffile = wp + os.sep + 'dirCodeDinfTau.tif'
weightfile = ... | [
"def",
"main",
"(",
")",
":",
"import",
"os",
"# wp = r'C:\\z_code\\subrepos\\PyGeoC\\tests\\data\\tmp_results\\wtsd_delineation'",
"wp",
"=",
"r'C:\\z_data_m\\SEIMS2018\\zhongtianshe_100m\\taudem_delineated'",
"dinfflowang",
"=",
"wp",
"+",
"os",
".",
"sep",
"+",
"'flowDirDinf... | Test code | [
"Test",
"code"
] | 9a92d1a229bb74298e3c57f27c97079980b5f729 | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/postTauDEM.py#L290-L298 | train | Test code for Dinf Tau test |
lreis2415/PyGeoC | pygeoc/postTauDEM.py | DinfUtil.compress_dinf | def compress_dinf(angle, nodata):
"""Compress dinf flow direction to D8 direction with weight follows ArcGIS D8 codes.
Args:
angle: D-inf flow direction angle
nodata: NoData value
Returns:
1. Updated Dinf values
2. Compressed flow direction follow... | python | def compress_dinf(angle, nodata):
"""Compress dinf flow direction to D8 direction with weight follows ArcGIS D8 codes.
Args:
angle: D-inf flow direction angle
nodata: NoData value
Returns:
1. Updated Dinf values
2. Compressed flow direction follow... | [
"def",
"compress_dinf",
"(",
"angle",
",",
"nodata",
")",
":",
"if",
"MathClass",
".",
"floatequal",
"(",
"angle",
",",
"nodata",
")",
":",
"return",
"DEFAULT_NODATA",
",",
"DEFAULT_NODATA",
",",
"DEFAULT_NODATA",
"taud",
",",
"d",
"=",
"DinfUtil",
".",
"c... | Compress dinf flow direction to D8 direction with weight follows ArcGIS D8 codes.
Args:
angle: D-inf flow direction angle
nodata: NoData value
Returns:
1. Updated Dinf values
2. Compressed flow direction follows ArcGIS D8 codes rule
3. Weight ... | [
"Compress",
"dinf",
"flow",
"direction",
"to",
"D8",
"direction",
"with",
"weight",
"follows",
"ArcGIS",
"D8",
"codes",
".",
"Args",
":",
"angle",
":",
"D",
"-",
"inf",
"flow",
"direction",
"angle",
"nodata",
":",
"NoData",
"value"
] | 9a92d1a229bb74298e3c57f27c97079980b5f729 | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/postTauDEM.py#L68-L108 | train | Compress dinf flow direction to D8 direction with weight follows ArcGIS D8 codes rule |
lreis2415/PyGeoC | pygeoc/postTauDEM.py | DinfUtil.output_compressed_dinf | def output_compressed_dinf(dinfflowang, compdinffile, weightfile):
"""Output compressed Dinf flow direction and weight to raster file
Args:
dinfflowang: Dinf flow direction raster file
compdinffile: Compressed D8 flow code
weightfile: The correspond weight
"""... | python | def output_compressed_dinf(dinfflowang, compdinffile, weightfile):
"""Output compressed Dinf flow direction and weight to raster file
Args:
dinfflowang: Dinf flow direction raster file
compdinffile: Compressed D8 flow code
weightfile: The correspond weight
"""... | [
"def",
"output_compressed_dinf",
"(",
"dinfflowang",
",",
"compdinffile",
",",
"weightfile",
")",
":",
"dinf_r",
"=",
"RasterUtilClass",
".",
"read_raster",
"(",
"dinfflowang",
")",
"data",
"=",
"dinf_r",
".",
"data",
"xsize",
"=",
"dinf_r",
".",
"nCols",
"ysi... | Output compressed Dinf flow direction and weight to raster file
Args:
dinfflowang: Dinf flow direction raster file
compdinffile: Compressed D8 flow code
weightfile: The correspond weight | [
"Output",
"compressed",
"Dinf",
"flow",
"direction",
"and",
"weight",
"to",
"raster",
"file",
"Args",
":",
"dinfflowang",
":",
"Dinf",
"flow",
"direction",
"raster",
"file",
"compdinffile",
":",
"Compressed",
"D8",
"flow",
"code",
"weightfile",
":",
"The",
"co... | 9a92d1a229bb74298e3c57f27c97079980b5f729 | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/postTauDEM.py#L111-L132 | train | This function will output the compressed Dinf flow direction raster file and weight to the raster file. |
lreis2415/PyGeoC | pygeoc/postTauDEM.py | DinfUtil.dinf_downslope_direction | def dinf_downslope_direction(a):
"""Get the downslope directions of an dinf direction value
Args:
a: Dinf value
Returns:
downslope directions
"""
taud, d = DinfUtil.check_orthogonal(a)
if d != -1:
down = [d]
return down
... | python | def dinf_downslope_direction(a):
"""Get the downslope directions of an dinf direction value
Args:
a: Dinf value
Returns:
downslope directions
"""
taud, d = DinfUtil.check_orthogonal(a)
if d != -1:
down = [d]
return down
... | [
"def",
"dinf_downslope_direction",
"(",
"a",
")",
":",
"taud",
",",
"d",
"=",
"DinfUtil",
".",
"check_orthogonal",
"(",
"a",
")",
"if",
"d",
"!=",
"-",
"1",
":",
"down",
"=",
"[",
"d",
"]",
"return",
"down",
"else",
":",
"if",
"a",
"<",
"FlowModelC... | Get the downslope directions of an dinf direction value
Args:
a: Dinf value
Returns:
downslope directions | [
"Get",
"the",
"downslope",
"directions",
"of",
"an",
"dinf",
"direction",
"value",
"Args",
":",
"a",
":",
"Dinf",
"value"
] | 9a92d1a229bb74298e3c57f27c97079980b5f729 | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/postTauDEM.py#L135-L164 | train | Get the downslope directions of an dinf value. |
lreis2415/PyGeoC | pygeoc/postTauDEM.py | DinfUtil.downstream_index_dinf | def downstream_index_dinf(dinfdir_value, i, j):
"""find downslope coordinate for Dinf of TauDEM
Args:
dinfdir_value: dinf direction value
i: current row
j: current col
Returns:
downstream (row, col)s
"""
down_dirs = DinfUtil.dinf_d... | python | def downstream_index_dinf(dinfdir_value, i, j):
"""find downslope coordinate for Dinf of TauDEM
Args:
dinfdir_value: dinf direction value
i: current row
j: current col
Returns:
downstream (row, col)s
"""
down_dirs = DinfUtil.dinf_d... | [
"def",
"downstream_index_dinf",
"(",
"dinfdir_value",
",",
"i",
",",
"j",
")",
":",
"down_dirs",
"=",
"DinfUtil",
".",
"dinf_downslope_direction",
"(",
"dinfdir_value",
")",
"down_coors",
"=",
"[",
"]",
"for",
"dir_code",
"in",
"down_dirs",
":",
"row",
",",
... | find downslope coordinate for Dinf of TauDEM
Args:
dinfdir_value: dinf direction value
i: current row
j: current col
Returns:
downstream (row, col)s | [
"find",
"downslope",
"coordinate",
"for",
"Dinf",
"of",
"TauDEM",
"Args",
":",
"dinfdir_value",
":",
"dinf",
"direction",
"value",
"i",
":",
"current",
"row",
"j",
":",
"current",
"col"
] | 9a92d1a229bb74298e3c57f27c97079980b5f729 | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/postTauDEM.py#L167-L182 | train | find downslope coordinate for Dinf of TauDEM ArcGIS |
lreis2415/PyGeoC | pygeoc/postTauDEM.py | StreamnetUtil.serialize_streamnet | def serialize_streamnet(streamnet_file, output_reach_file):
"""Eliminate reach with zero length and return the reach ID map.
Args:
streamnet_file: original stream net ESRI shapefile
output_reach_file: serialized stream net, ESRI shapefile
Returns:
id pairs {o... | python | def serialize_streamnet(streamnet_file, output_reach_file):
"""Eliminate reach with zero length and return the reach ID map.
Args:
streamnet_file: original stream net ESRI shapefile
output_reach_file: serialized stream net, ESRI shapefile
Returns:
id pairs {o... | [
"def",
"serialize_streamnet",
"(",
"streamnet_file",
",",
"output_reach_file",
")",
":",
"FileClass",
".",
"copy_files",
"(",
"streamnet_file",
",",
"output_reach_file",
")",
"ds_reach",
"=",
"ogr_Open",
"(",
"output_reach_file",
",",
"update",
"=",
"True",
")",
"... | Eliminate reach with zero length and return the reach ID map.
Args:
streamnet_file: original stream net ESRI shapefile
output_reach_file: serialized stream net, ESRI shapefile
Returns:
id pairs {origin: newly assigned} | [
"Eliminate",
"reach",
"with",
"zero",
"length",
"and",
"return",
"the",
"reach",
"ID",
"map",
".",
"Args",
":",
"streamnet_file",
":",
"original",
"stream",
"net",
"ESRI",
"shapefile",
"output_reach_file",
":",
"serialized",
"stream",
"net",
"ESRI",
"shapefile"
... | 9a92d1a229bb74298e3c57f27c97079980b5f729 | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/postTauDEM.py#L199-L266 | train | This function takes a streamnet file and returns a dict of all the reach ID pairs. |
lreis2415/PyGeoC | pygeoc/postTauDEM.py | StreamnetUtil.assign_stream_id_raster | def assign_stream_id_raster(stream_file, subbasin_file, out_stream_file):
"""Assign stream link ID according to subbasin ID.
Args:
stream_file: input stream raster file
subbasin_file: subbasin raster file
out_stream_file: output stream raster file
"""
... | python | def assign_stream_id_raster(stream_file, subbasin_file, out_stream_file):
"""Assign stream link ID according to subbasin ID.
Args:
stream_file: input stream raster file
subbasin_file: subbasin raster file
out_stream_file: output stream raster file
"""
... | [
"def",
"assign_stream_id_raster",
"(",
"stream_file",
",",
"subbasin_file",
",",
"out_stream_file",
")",
":",
"stream_raster",
"=",
"RasterUtilClass",
".",
"read_raster",
"(",
"stream_file",
")",
"stream_data",
"=",
"stream_raster",
".",
"data",
"nrows",
"=",
"strea... | Assign stream link ID according to subbasin ID.
Args:
stream_file: input stream raster file
subbasin_file: subbasin raster file
out_stream_file: output stream raster file | [
"Assign",
"stream",
"link",
"ID",
"according",
"to",
"subbasin",
"ID",
".",
"Args",
":",
"stream_file",
":",
"input",
"stream",
"raster",
"file",
"subbasin_file",
":",
"subbasin",
"raster",
"file",
"out_stream_file",
":",
"output",
"stream",
"raster",
"file"
] | 9a92d1a229bb74298e3c57f27c97079980b5f729 | https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/postTauDEM.py#L269-L287 | train | Assign stream link ID according to subbasin ID. |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/instruments/instrument_dummy.py | DummyInstrument.update | def update(self, settings):
'''
updates the internal dictionary and sends changed values to instrument
Args:
settings: parameters to be set
# mabe in the future:
# Returns: boolean that is true if update successful
'''
Instrument.update(self, settings... | python | def update(self, settings):
'''
updates the internal dictionary and sends changed values to instrument
Args:
settings: parameters to be set
# mabe in the future:
# Returns: boolean that is true if update successful
'''
Instrument.update(self, settings... | [
"def",
"update",
"(",
"self",
",",
"settings",
")",
":",
"Instrument",
".",
"update",
"(",
"self",
",",
"settings",
")",
"for",
"key",
",",
"value",
"in",
"settings",
".",
"items",
"(",
")",
":",
"if",
"key",
"==",
"'test1'",
":",
"self",
".",
"_in... | updates the internal dictionary and sends changed values to instrument
Args:
settings: parameters to be set
# mabe in the future:
# Returns: boolean that is true if update successful | [
"updates",
"the",
"internal",
"dictionary",
"and",
"sends",
"changed",
"values",
"to",
"instrument",
"Args",
":",
"settings",
":",
"parameters",
"to",
"be",
"set",
"#",
"mabe",
"in",
"the",
"future",
":",
"#",
"Returns",
":",
"boolean",
"that",
"is",
"true... | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/instruments/instrument_dummy.py#L52-L65 | train | Updates the internal dictionary and sends changed values to instrument
|
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/instruments/instrument_dummy.py | DummyInstrument.read_probes | def read_probes(self, key):
"""
requestes value from the instrument and returns it
Args:
key: name of requested value
Returns: reads values from instrument
"""
assert key in list(self._PROBES.keys())
import random
if key == 'value1':
... | python | def read_probes(self, key):
"""
requestes value from the instrument and returns it
Args:
key: name of requested value
Returns: reads values from instrument
"""
assert key in list(self._PROBES.keys())
import random
if key == 'value1':
... | [
"def",
"read_probes",
"(",
"self",
",",
"key",
")",
":",
"assert",
"key",
"in",
"list",
"(",
"self",
".",
"_PROBES",
".",
"keys",
"(",
")",
")",
"import",
"random",
"if",
"key",
"==",
"'value1'",
":",
"value",
"=",
"random",
".",
"random",
"(",
")"... | requestes value from the instrument and returns it
Args:
key: name of requested value
Returns: reads values from instrument | [
"requestes",
"value",
"from",
"the",
"instrument",
"and",
"returns",
"it",
"Args",
":",
"key",
":",
"name",
"of",
"requested",
"value"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/instruments/instrument_dummy.py#L69-L90 | train | reads the value of the requested probe from the instrument and returns it |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/instruments/instrument_dummy.py | Plant.start | def start(self, *args, **kwargs):
"""
start the instrument thread
"""
self._stop = False
super(Plant, self).start(*args, **kwargs) | python | def start(self, *args, **kwargs):
"""
start the instrument thread
"""
self._stop = False
super(Plant, self).start(*args, **kwargs) | [
"def",
"start",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_stop",
"=",
"False",
"super",
"(",
"Plant",
",",
"self",
")",
".",
"start",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | start the instrument thread | [
"start",
"the",
"instrument",
"thread"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/instruments/instrument_dummy.py#L121-L127 | train | start the instrument thread
|
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/instruments/instrument_dummy.py | Plant.quit | def quit(self, *args, **kwargs): # real signature unknown
"""
quit the instrument thread
"""
self.stop()
self._stop = True
self.msleep(2* int(1e3 / self.settings['update frequency']))
super(Plant, self).quit(*args, **kwargs) | python | def quit(self, *args, **kwargs): # real signature unknown
"""
quit the instrument thread
"""
self.stop()
self._stop = True
self.msleep(2* int(1e3 / self.settings['update frequency']))
super(Plant, self).quit(*args, **kwargs) | [
"def",
"quit",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# real signature unknown",
"self",
".",
"stop",
"(",
")",
"self",
".",
"_stop",
"=",
"True",
"self",
".",
"msleep",
"(",
"2",
"*",
"int",
"(",
"1e3",
"/",
"self",
"... | quit the instrument thread | [
"quit",
"the",
"instrument",
"thread"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/instruments/instrument_dummy.py#L130-L137 | train | quit the instrument thread
|
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/instruments/instrument_dummy.py | Plant.run | def run(self):
"""
this is the actual execution of the instrument thread: continuously read values from the probes
"""
eta = self.settings['noise_strength']
gamma = 2 * np.pi * self.settings['noise_bandwidth']
dt = 1. / self.settings['update frequency']
control =... | python | def run(self):
"""
this is the actual execution of the instrument thread: continuously read values from the probes
"""
eta = self.settings['noise_strength']
gamma = 2 * np.pi * self.settings['noise_bandwidth']
dt = 1. / self.settings['update frequency']
control =... | [
"def",
"run",
"(",
"self",
")",
":",
"eta",
"=",
"self",
".",
"settings",
"[",
"'noise_strength'",
"]",
"gamma",
"=",
"2",
"*",
"np",
".",
"pi",
"*",
"self",
".",
"settings",
"[",
"'noise_bandwidth'",
"]",
"dt",
"=",
"1.",
"/",
"self",
".",
"settin... | this is the actual execution of the instrument thread: continuously read values from the probes | [
"this",
"is",
"the",
"actual",
"execution",
"of",
"the",
"instrument",
"thread",
":",
"continuously",
"read",
"values",
"from",
"the",
"probes"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/instruments/instrument_dummy.py#L139-L159 | train | This method is called by the instrument thread to run the state machine. |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/instruments/instrument_dummy.py | Plant.read_probes | def read_probes(self, key):
"""
requestes value from the instrument and returns it
Args:
key: name of requested value
Returns: reads values from instrument
"""
assert key in list(self._PROBES.keys())
if key == 'output':
value = self._out... | python | def read_probes(self, key):
"""
requestes value from the instrument and returns it
Args:
key: name of requested value
Returns: reads values from instrument
"""
assert key in list(self._PROBES.keys())
if key == 'output':
value = self._out... | [
"def",
"read_probes",
"(",
"self",
",",
"key",
")",
":",
"assert",
"key",
"in",
"list",
"(",
"self",
".",
"_PROBES",
".",
"keys",
"(",
")",
")",
"if",
"key",
"==",
"'output'",
":",
"value",
"=",
"self",
".",
"_output",
"return",
"value"
] | requestes value from the instrument and returns it
Args:
key: name of requested value
Returns: reads values from instrument | [
"requestes",
"value",
"from",
"the",
"instrument",
"and",
"returns",
"it",
"Args",
":",
"key",
":",
"name",
"of",
"requested",
"value"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/instruments/instrument_dummy.py#L163-L177 | train | Reads the value of a specific key from the instrument and returns it. |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/instruments/instrument_dummy.py | PIControler.controler_output | def controler_output(self, current_value):
"""
Calculate PI output value for given reference input and feedback
"""
set_point = self.settings['set_point']
Kp = self.settings['gains']['proportional']
Ki = self.settings['gains']['integral']
output_range = self.sett... | python | def controler_output(self, current_value):
"""
Calculate PI output value for given reference input and feedback
"""
set_point = self.settings['set_point']
Kp = self.settings['gains']['proportional']
Ki = self.settings['gains']['integral']
output_range = self.sett... | [
"def",
"controler_output",
"(",
"self",
",",
"current_value",
")",
":",
"set_point",
"=",
"self",
".",
"settings",
"[",
"'set_point'",
"]",
"Kp",
"=",
"self",
".",
"settings",
"[",
"'gains'",
"]",
"[",
"'proportional'",
"]",
"Ki",
"=",
"self",
".",
"sett... | Calculate PI output value for given reference input and feedback | [
"Calculate",
"PI",
"output",
"value",
"for",
"given",
"reference",
"input",
"and",
"feedback"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/instruments/instrument_dummy.py#L226-L259 | train | Calculate PI output value for given reference input and feedback |
rosshamish/catan-py | catan/boardbuilder.py | get_opts | def get_opts(opts):
"""
Validate options and apply defaults for options not supplied.
:param opts: dictionary mapping str->str.
:return: dictionary mapping str->Opt. All possible keys are present.
"""
defaults = {
'board': None,
'terrain': Opt.random,
'numbers': Opt.pres... | python | def get_opts(opts):
"""
Validate options and apply defaults for options not supplied.
:param opts: dictionary mapping str->str.
:return: dictionary mapping str->Opt. All possible keys are present.
"""
defaults = {
'board': None,
'terrain': Opt.random,
'numbers': Opt.pres... | [
"def",
"get_opts",
"(",
"opts",
")",
":",
"defaults",
"=",
"{",
"'board'",
":",
"None",
",",
"'terrain'",
":",
"Opt",
".",
"random",
",",
"'numbers'",
":",
"Opt",
".",
"preset",
",",
"'ports'",
":",
"Opt",
".",
"preset",
",",
"'pieces'",
":",
"Opt",
... | Validate options and apply defaults for options not supplied.
:param opts: dictionary mapping str->str.
:return: dictionary mapping str->Opt. All possible keys are present. | [
"Validate",
"options",
"and",
"apply",
"defaults",
"for",
"options",
"not",
"supplied",
"."
] | 120438a8f16e39c13322c5d5930e1064e1d3f4be | https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/boardbuilder.py#L40-L72 | train | Validate options and apply defaults for options not supplied. |
rosshamish/catan-py | catan/boardbuilder.py | build | def build(opts=None):
"""
Build a new board using the given options.
:param opts: dictionary mapping str->Opt
:return: the new board, Board
"""
board = catan.board.Board()
modify(board, opts)
return board | python | def build(opts=None):
"""
Build a new board using the given options.
:param opts: dictionary mapping str->Opt
:return: the new board, Board
"""
board = catan.board.Board()
modify(board, opts)
return board | [
"def",
"build",
"(",
"opts",
"=",
"None",
")",
":",
"board",
"=",
"catan",
".",
"board",
".",
"Board",
"(",
")",
"modify",
"(",
"board",
",",
"opts",
")",
"return",
"board"
] | Build a new board using the given options.
:param opts: dictionary mapping str->Opt
:return: the new board, Board | [
"Build",
"a",
"new",
"board",
"using",
"the",
"given",
"options",
".",
":",
"param",
"opts",
":",
"dictionary",
"mapping",
"str",
"-",
">",
"Opt",
":",
"return",
":",
"the",
"new",
"board",
"Board"
] | 120438a8f16e39c13322c5d5930e1064e1d3f4be | https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/boardbuilder.py#L75-L83 | train | Build a new board using the given options. |
rosshamish/catan-py | catan/boardbuilder.py | modify | def modify(board, opts=None):
"""
Reset an existing board using the given options.
:param board: the board to reset
:param opts: dictionary mapping str->Opt
:return: None
"""
opts = get_opts(opts)
if opts['board'] is not None:
board.tiles = _read_tiles_from_string(opts['board'])
... | python | def modify(board, opts=None):
"""
Reset an existing board using the given options.
:param board: the board to reset
:param opts: dictionary mapping str->Opt
:return: None
"""
opts = get_opts(opts)
if opts['board'] is not None:
board.tiles = _read_tiles_from_string(opts['board'])
... | [
"def",
"modify",
"(",
"board",
",",
"opts",
"=",
"None",
")",
":",
"opts",
"=",
"get_opts",
"(",
"opts",
")",
"if",
"opts",
"[",
"'board'",
"]",
"is",
"not",
"None",
":",
"board",
".",
"tiles",
"=",
"_read_tiles_from_string",
"(",
"opts",
"[",
"'boar... | Reset an existing board using the given options.
:param board: the board to reset
:param opts: dictionary mapping str->Opt
:return: None | [
"Reset",
"an",
"existing",
"board",
"using",
"the",
"given",
"options",
".",
":",
"param",
"board",
":",
"the",
"board",
"to",
"reset",
":",
"param",
"opts",
":",
"dictionary",
"mapping",
"str",
"-",
">",
"Opt",
":",
"return",
":",
"None"
] | 120438a8f16e39c13322c5d5930e1064e1d3f4be | https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/boardbuilder.py#L94-L109 | train | Reset an existing board using the given options. |
rosshamish/catan-py | catan/boardbuilder.py | _get_tiles | def _get_tiles(board=None, terrain=None, numbers=None):
"""
Generate a list of tiles using the given terrain and numbers options.
terrain options supported:
- Opt.empty -> all tiles are desert
- Opt.random -> tiles are randomized
- Opt.preset ->
- Opt.debug -> alias for Opt.random
numb... | python | def _get_tiles(board=None, terrain=None, numbers=None):
"""
Generate a list of tiles using the given terrain and numbers options.
terrain options supported:
- Opt.empty -> all tiles are desert
- Opt.random -> tiles are randomized
- Opt.preset ->
- Opt.debug -> alias for Opt.random
numb... | [
"def",
"_get_tiles",
"(",
"board",
"=",
"None",
",",
"terrain",
"=",
"None",
",",
"numbers",
"=",
"None",
")",
":",
"if",
"board",
"is",
"not",
"None",
":",
"# we have a board given, ignore the terrain and numbers opts and log warnings",
"# if they were supplied",
"ti... | Generate a list of tiles using the given terrain and numbers options.
terrain options supported:
- Opt.empty -> all tiles are desert
- Opt.random -> tiles are randomized
- Opt.preset ->
- Opt.debug -> alias for Opt.random
numbers options supported:
- Opt.empty -> no tiles have numbers
... | [
"Generate",
"a",
"list",
"of",
"tiles",
"using",
"the",
"given",
"terrain",
"and",
"numbers",
"options",
"."
] | 120438a8f16e39c13322c5d5930e1064e1d3f4be | https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/boardbuilder.py#L112-L140 | train | Generate a list of tiles using the given terrain and numbers options. |
rosshamish/catan-py | catan/boardbuilder.py | _get_ports | def _get_ports(port_opts):
"""
Generate a list of ports using the given options.
port options supported:
- Opt.empty ->
- Opt.random ->
- Opt.preset -> ports are in default locations
- Opt.debug -> alias for Opt.preset
:param port_opts: Opt
:return: list(Port)
"""
if port_o... | python | def _get_ports(port_opts):
"""
Generate a list of ports using the given options.
port options supported:
- Opt.empty ->
- Opt.random ->
- Opt.preset -> ports are in default locations
- Opt.debug -> alias for Opt.preset
:param port_opts: Opt
:return: list(Port)
"""
if port_o... | [
"def",
"_get_ports",
"(",
"port_opts",
")",
":",
"if",
"port_opts",
"in",
"[",
"Opt",
".",
"preset",
",",
"Opt",
".",
"debug",
"]",
":",
"_preset_ports",
"=",
"[",
"(",
"1",
",",
"'NW'",
",",
"catan",
".",
"board",
".",
"PortType",
".",
"any3",
")"... | Generate a list of ports using the given options.
port options supported:
- Opt.empty ->
- Opt.random ->
- Opt.preset -> ports are in default locations
- Opt.debug -> alias for Opt.preset
:param port_opts: Opt
:return: list(Port) | [
"Generate",
"a",
"list",
"of",
"ports",
"using",
"the",
"given",
"options",
"."
] | 120438a8f16e39c13322c5d5930e1064e1d3f4be | https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/boardbuilder.py#L231-L258 | train | Generate a list of ports using the given options. |
rosshamish/catan-py | catan/boardbuilder.py | _get_pieces | def _get_pieces(tiles, ports, players_opts, pieces_opts):
"""
Generate a dictionary of pieces using the given options.
pieces options supported:
- Opt.empty -> no locations have pieces
- Opt.random ->
- Opt.preset -> robber is placed on the first desert found
- Opt.debug -> a variety of pie... | python | def _get_pieces(tiles, ports, players_opts, pieces_opts):
"""
Generate a dictionary of pieces using the given options.
pieces options supported:
- Opt.empty -> no locations have pieces
- Opt.random ->
- Opt.preset -> robber is placed on the first desert found
- Opt.debug -> a variety of pie... | [
"def",
"_get_pieces",
"(",
"tiles",
",",
"ports",
",",
"players_opts",
",",
"pieces_opts",
")",
":",
"if",
"pieces_opts",
"==",
"Opt",
".",
"empty",
":",
"return",
"dict",
"(",
")",
"elif",
"pieces_opts",
"==",
"Opt",
".",
"debug",
":",
"players",
"=",
... | Generate a dictionary of pieces using the given options.
pieces options supported:
- Opt.empty -> no locations have pieces
- Opt.random ->
- Opt.preset -> robber is placed on the first desert found
- Opt.debug -> a variety of pieces are placed around the board
:param tiles: list of tiles from ... | [
"Generate",
"a",
"dictionary",
"of",
"pieces",
"using",
"the",
"given",
"options",
"."
] | 120438a8f16e39c13322c5d5930e1064e1d3f4be | https://github.com/rosshamish/catan-py/blob/120438a8f16e39c13322c5d5930e1064e1d3f4be/catan/boardbuilder.py#L261-L298 | train | Generate a dictionary of pieces based on the given options. |
nmdp-bioinformatics/SeqAnn | seqann/feature_client/apis/features_api.py | FeaturesApi.create_feature | def create_feature(self, **kwargs):
"""
Create an enumerated sequence feature
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def ca... | python | def create_feature(self, **kwargs):
"""
Create an enumerated sequence feature
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def ca... | [
"def",
"create_feature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"create_feature_with_http_info",
"(",
"*",
... | Create an enumerated sequence feature
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(respon... | [
"Create",
"an",
"enumerated",
"sequence",
"feature"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/feature_client/apis/features_api.py#L53-L78 | train | Create an enumerated sequence feature with the specified attributes. |
nmdp-bioinformatics/SeqAnn | seqann/feature_client/apis/features_api.py | FeaturesApi.get_feature_by_path | def get_feature_by_path(self, locus, term, rank, accession, **kwargs):
"""
Retrieve an enumerated sequence feature
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when recei... | python | def get_feature_by_path(self, locus, term, rank, accession, **kwargs):
"""
Retrieve an enumerated sequence feature
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when recei... | [
"def",
"get_feature_by_path",
"(",
"self",
",",
"locus",
",",
"term",
",",
"rank",
",",
"accession",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
... | Retrieve an enumerated sequence feature
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(resp... | [
"Retrieve",
"an",
"enumerated",
"sequence",
"feature"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/feature_client/apis/features_api.py#L154-L182 | train | Retrieve an enumerated sequence feature by path |
nmdp-bioinformatics/SeqAnn | seqann/feature_client/apis/features_api.py | FeaturesApi.get_feature_by_query | def get_feature_by_query(self, **kwargs):
"""
Retrieve an enumerated sequence feature
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>... | python | def get_feature_by_query(self, **kwargs):
"""
Retrieve an enumerated sequence feature
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>... | [
"def",
"get_feature_by_query",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"get_feature_by_query_with_http_info",
"... | Retrieve an enumerated sequence feature
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(resp... | [
"Retrieve",
"an",
"enumerated",
"sequence",
"feature"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/feature_client/apis/features_api.py#L279-L307 | train | Retrieve an enumerated sequence feature by query |
nmdp-bioinformatics/SeqAnn | seqann/feature_client/apis/features_api.py | FeaturesApi.list_features | def list_features(self, locus, **kwargs):
"""
List the enumerated sequence features at a locus
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
... | python | def list_features(self, locus, **kwargs):
"""
List the enumerated sequence features at a locus
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
... | [
"def",
"list_features",
"(",
"self",
",",
"locus",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"list_features_with_http_info",... | List the enumerated sequence features at a locus
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pp... | [
"List",
"the",
"enumerated",
"sequence",
"features",
"at",
"a",
"locus"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/feature_client/apis/features_api.py#L392-L417 | train | List the enumerated sequence features at a locus. |
nmdp-bioinformatics/SeqAnn | seqann/feature_client/apis/features_api.py | FeaturesApi.list_features_0 | def list_features_0(self, locus, term, **kwargs):
"""
List the enumerated sequence features matching a term at a locus
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when r... | python | def list_features_0(self, locus, term, **kwargs):
"""
List the enumerated sequence features matching a term at a locus
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when r... | [
"def",
"list_features_0",
"(",
"self",
",",
"locus",
",",
"term",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"list_featur... | List the enumerated sequence features matching a term at a locus
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
... | [
"List",
"the",
"enumerated",
"sequence",
"features",
"matching",
"a",
"term",
"at",
"a",
"locus"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/feature_client/apis/features_api.py#L496-L522 | train | List the enumerated sequence features matching a term at a locus. |
nmdp-bioinformatics/SeqAnn | seqann/feature_client/apis/features_api.py | FeaturesApi.list_features_1 | def list_features_1(self, locus, term, rank, **kwargs):
"""
List the enumerated sequence features matching a term and rank at a locus
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be... | python | def list_features_1(self, locus, term, rank, **kwargs):
"""
List the enumerated sequence features matching a term and rank at a locus
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be... | [
"def",
"list_features_1",
"(",
"self",
",",
"locus",
",",
"term",
",",
"rank",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".... | List the enumerated sequence features matching a term and rank at a locus
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(resp... | [
"List",
"the",
"enumerated",
"sequence",
"features",
"matching",
"a",
"term",
"and",
"rank",
"at",
"a",
"locus"
] | 5ce91559b0a4fbe4fb7758e034eb258202632463 | https://github.com/nmdp-bioinformatics/SeqAnn/blob/5ce91559b0a4fbe4fb7758e034eb258202632463/seqann/feature_client/apis/features_api.py#L607-L634 | train | List the enumerated sequence features matching a term and rank at a locus. |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/gui/qt_b26_widgets.py | B26QTreeItem.setData | def setData(self, column, role, value):
"""
if value is valid sets the data to value
Args:
column: column of item
role: role of item (see Qt doc)
value: value to be set
"""
assert isinstance(column, int)
assert isinstance(role, int)
... | python | def setData(self, column, role, value):
"""
if value is valid sets the data to value
Args:
column: column of item
role: role of item (see Qt doc)
value: value to be set
"""
assert isinstance(column, int)
assert isinstance(role, int)
... | [
"def",
"setData",
"(",
"self",
",",
"column",
",",
"role",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"column",
",",
"int",
")",
"assert",
"isinstance",
"(",
"role",
",",
"int",
")",
"# make sure that the right row is selected, this is not always the cas... | if value is valid sets the data to value
Args:
column: column of item
role: role of item (see Qt doc)
value: value to be set | [
"if",
"value",
"is",
"valid",
"sets",
"the",
"data",
"to",
"value",
"Args",
":",
"column",
":",
"column",
"of",
"item",
"role",
":",
"role",
"of",
"item",
"(",
"see",
"Qt",
"doc",
")",
"value",
":",
"value",
"to",
"be",
"set"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/qt_b26_widgets.py#L183-L230 | train | Set the data for the item in the tree structure |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/gui/qt_b26_widgets.py | B26QTreeItem.cast_type | def cast_type(self, var, cast_type=None):
"""
cast the value into the type typ
if type is not provided it is set to self.valid_values
Args:
var: variable to be cast
type: target type
Returns: the variable var csat into type typ
"""
if ca... | python | def cast_type(self, var, cast_type=None):
"""
cast the value into the type typ
if type is not provided it is set to self.valid_values
Args:
var: variable to be cast
type: target type
Returns: the variable var csat into type typ
"""
if ca... | [
"def",
"cast_type",
"(",
"self",
",",
"var",
",",
"cast_type",
"=",
"None",
")",
":",
"if",
"cast_type",
"is",
"None",
":",
"cast_type",
"=",
"self",
".",
"valid_values",
"try",
":",
"if",
"cast_type",
"==",
"int",
":",
"return",
"int",
"(",
"var",
"... | cast the value into the type typ
if type is not provided it is set to self.valid_values
Args:
var: variable to be cast
type: target type
Returns: the variable var csat into type typ | [
"cast",
"the",
"value",
"into",
"the",
"type",
"typ",
"if",
"type",
"is",
"not",
"provided",
"it",
"is",
"set",
"to",
"self",
".",
"valid_values",
"Args",
":",
"var",
":",
"variable",
"to",
"be",
"cast",
"type",
":",
"target",
"type"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/qt_b26_widgets.py#L232-L262 | train | cast the value into the type typ
|
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/gui/qt_b26_widgets.py | B26QTreeItem.get_instrument | def get_instrument(self):
"""
Returns: the instrument and the path to the instrument to which this item belongs
"""
if isinstance(self.value, Instrument):
instrument = self.value
path_to_instrument = []
else:
instrument = None
pare... | python | def get_instrument(self):
"""
Returns: the instrument and the path to the instrument to which this item belongs
"""
if isinstance(self.value, Instrument):
instrument = self.value
path_to_instrument = []
else:
instrument = None
pare... | [
"def",
"get_instrument",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"value",
",",
"Instrument",
")",
":",
"instrument",
"=",
"self",
".",
"value",
"path_to_instrument",
"=",
"[",
"]",
"else",
":",
"instrument",
"=",
"None",
"parent",
"=... | Returns: the instrument and the path to the instrument to which this item belongs | [
"Returns",
":",
"the",
"instrument",
"and",
"the",
"path",
"to",
"the",
"instrument",
"to",
"which",
"this",
"item",
"belongs"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/qt_b26_widgets.py#L264-L284 | train | Returns the instrument and the path to the instrument to which this item belongs. |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/gui/qt_b26_widgets.py | B26QTreeItem.get_subscript | def get_subscript(self, sub_script_name):
"""
finds the item that contains the sub_script with name sub_script_name
Args:
sub_script_name: name of subscript
Returns: B26QTreeItem in QTreeWidget which is a script
"""
# get tree of item
tree = self.tre... | python | def get_subscript(self, sub_script_name):
"""
finds the item that contains the sub_script with name sub_script_name
Args:
sub_script_name: name of subscript
Returns: B26QTreeItem in QTreeWidget which is a script
"""
# get tree of item
tree = self.tre... | [
"def",
"get_subscript",
"(",
"self",
",",
"sub_script_name",
")",
":",
"# get tree of item",
"tree",
"=",
"self",
".",
"treeWidget",
"(",
")",
"items",
"=",
"tree",
".",
"findItems",
"(",
"sub_script_name",
",",
"QtCore",
".",
"Qt",
".",
"MatchExactly",
"|",... | finds the item that contains the sub_script with name sub_script_name
Args:
sub_script_name: name of subscript
Returns: B26QTreeItem in QTreeWidget which is a script | [
"finds",
"the",
"item",
"that",
"contains",
"the",
"sub_script",
"with",
"name",
"sub_script_name",
"Args",
":",
"sub_script_name",
":",
"name",
"of",
"subscript",
"Returns",
":",
"B26QTreeItem",
"in",
"QTreeWidget",
"which",
"is",
"a",
"script"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/qt_b26_widgets.py#L313-L337 | train | returns the item that contains the sub_script with name sub_script_name |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/gui/qt_b26_widgets.py | B26QTreeItem.is_point | def is_point(self):
"""
figures out if item is a point, that is if it has two subelements of type float
Args:
self:
Returns: if item is a point (True) or not (False)
"""
if self.childCount() == 2:
if self.child(0).valid_values == float and s... | python | def is_point(self):
"""
figures out if item is a point, that is if it has two subelements of type float
Args:
self:
Returns: if item is a point (True) or not (False)
"""
if self.childCount() == 2:
if self.child(0).valid_values == float and s... | [
"def",
"is_point",
"(",
"self",
")",
":",
"if",
"self",
".",
"childCount",
"(",
")",
"==",
"2",
":",
"if",
"self",
".",
"child",
"(",
"0",
")",
".",
"valid_values",
"==",
"float",
"and",
"self",
".",
"child",
"(",
"1",
")",
".",
"valid_values",
"... | figures out if item is a point, that is if it has two subelements of type float
Args:
self:
Returns: if item is a point (True) or not (False) | [
"figures",
"out",
"if",
"item",
"is",
"a",
"point",
"that",
"is",
"if",
"it",
"has",
"two",
"subelements",
"of",
"type",
"float",
"Args",
":",
"self",
":"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/qt_b26_widgets.py#L339-L353 | train | Figure out if the item is a point |
tryfer/tryfer | tryfer/http.py | TracingAgent.request | def request(self, method, uri, headers=None, bodyProducer=None):
"""
Send a client request following HTTP redirects.
@see: L{Agent.request}.
"""
if self._parent_trace is None:
trace = Trace(method)
else:
trace = self._parent_trace.child(method)
... | python | def request(self, method, uri, headers=None, bodyProducer=None):
"""
Send a client request following HTTP redirects.
@see: L{Agent.request}.
"""
if self._parent_trace is None:
trace = Trace(method)
else:
trace = self._parent_trace.child(method)
... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"uri",
",",
"headers",
"=",
"None",
",",
"bodyProducer",
"=",
"None",
")",
":",
"if",
"self",
".",
"_parent_trace",
"is",
"None",
":",
"trace",
"=",
"Trace",
"(",
"method",
")",
"else",
":",
"trace",... | Send a client request following HTTP redirects.
@see: L{Agent.request}. | [
"Send",
"a",
"client",
"request",
"following",
"HTTP",
"redirects",
"."
] | d4aa45b39eab5ce4b06d6343344afb05a0bf8582 | https://github.com/tryfer/tryfer/blob/d4aa45b39eab5ce4b06d6343344afb05a0bf8582/tryfer/http.py#L42-L92 | train | Send a client request following HTTP redirects. |
bennylope/smartystreets.py | smartystreets/client.py | validate_args | def validate_args(f):
"""
Ensures that *args consist of a consistent type
:param f: any client method with *args parameter
:return: function f
"""
def wrapper(self, args):
arg_types = set([type(arg) for arg in args])
if len(arg_types) > 1:
raise TypeError("Mixed inp... | python | def validate_args(f):
"""
Ensures that *args consist of a consistent type
:param f: any client method with *args parameter
:return: function f
"""
def wrapper(self, args):
arg_types = set([type(arg) for arg in args])
if len(arg_types) > 1:
raise TypeError("Mixed inp... | [
"def",
"validate_args",
"(",
"f",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"args",
")",
":",
"arg_types",
"=",
"set",
"(",
"[",
"type",
"(",
"arg",
")",
"for",
"arg",
"in",
"args",
"]",
")",
"if",
"len",
"(",
"arg_types",
")",
">",
"1",
":... | Ensures that *args consist of a consistent type
:param f: any client method with *args parameter
:return: function f | [
"Ensures",
"that",
"*",
"args",
"consist",
"of",
"a",
"consistent",
"type"
] | f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69 | https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/client.py#L16-L34 | train | Decorator that the function f accepts the args parameter
|
bennylope/smartystreets.py | smartystreets/client.py | truncate_args | def truncate_args(f):
"""
Ensures that *args do not exceed a set limit or are truncated to meet that limit
:param f: any Client method with *args parameter
:return: function f
"""
def wrapper(self, args):
if len(args) > 100:
if self.truncate_addresses:
args ... | python | def truncate_args(f):
"""
Ensures that *args do not exceed a set limit or are truncated to meet that limit
:param f: any Client method with *args parameter
:return: function f
"""
def wrapper(self, args):
if len(args) > 100:
if self.truncate_addresses:
args ... | [
"def",
"truncate_args",
"(",
"f",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"100",
":",
"if",
"self",
".",
"truncate_addresses",
":",
"args",
"=",
"args",
"[",
":",
"100",
"]",
"else",
":"... | Ensures that *args do not exceed a set limit or are truncated to meet that limit
:param f: any Client method with *args parameter
:return: function f | [
"Ensures",
"that",
"*",
"args",
"do",
"not",
"exceed",
"a",
"set",
"limit",
"or",
"are",
"truncated",
"to",
"meet",
"that",
"limit"
] | f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69 | https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/client.py#L37-L56 | train | Decorator that ensures that the given list of arguments is not exceeding 100 address at a time SmartyStreets limit. |
bennylope/smartystreets.py | smartystreets/client.py | stringify | def stringify(data):
"""
Ensure all values in the dictionary are strings, except for the value for `candidate` which
should just be an integer.
:param data: a list of addresses in dictionary format
:return: the same list with all values except for `candidate` count as a string
"""
def seri... | python | def stringify(data):
"""
Ensure all values in the dictionary are strings, except for the value for `candidate` which
should just be an integer.
:param data: a list of addresses in dictionary format
:return: the same list with all values except for `candidate` count as a string
"""
def seri... | [
"def",
"stringify",
"(",
"data",
")",
":",
"def",
"serialize",
"(",
"k",
",",
"v",
")",
":",
"if",
"k",
"==",
"\"candidates\"",
":",
"return",
"int",
"(",
"v",
")",
"if",
"isinstance",
"(",
"v",
",",
"numbers",
".",
"Number",
")",
":",
"if",
"k",... | Ensure all values in the dictionary are strings, except for the value for `candidate` which
should just be an integer.
:param data: a list of addresses in dictionary format
:return: the same list with all values except for `candidate` count as a string | [
"Ensure",
"all",
"values",
"in",
"the",
"dictionary",
"are",
"strings",
"except",
"for",
"the",
"value",
"for",
"candidate",
"which",
"should",
"just",
"be",
"an",
"integer",
"."
] | f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69 | https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/client.py#L59-L82 | train | Convert all values in the dictionary to strings except for the value for candidate which
should just be an integer. |
bennylope/smartystreets.py | smartystreets/client.py | Client.post | def post(self, endpoint, data):
"""
Executes the HTTP POST request
:param endpoint: string indicating the URL component to call
:param data: the data to submit
:return: the dumped JSON response content
"""
headers = {
"Content-Type": "application/json... | python | def post(self, endpoint, data):
"""
Executes the HTTP POST request
:param endpoint: string indicating the URL component to call
:param data: the data to submit
:return: the dumped JSON response content
"""
headers = {
"Content-Type": "application/json... | [
"def",
"post",
"(",
"self",
",",
"endpoint",
",",
"data",
")",
":",
"headers",
"=",
"{",
"\"Content-Type\"",
":",
"\"application/json\"",
",",
"\"Accept\"",
":",
"\"application/json\"",
",",
"\"x-standardize-only\"",
":",
"\"true\"",
"if",
"self",
".",
"standard... | Executes the HTTP POST request
:param endpoint: string indicating the URL component to call
:param data: the data to submit
:return: the dumped JSON response content | [
"Executes",
"the",
"HTTP",
"POST",
"request"
] | f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69 | https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/client.py#L128-L158 | train | Executes the HTTP POST request to the specified endpoint and returns the JSON response. |
bennylope/smartystreets.py | smartystreets/client.py | Client.street_addresses | def street_addresses(self, addresses):
"""
API method for verifying street address and geolocating
Returns an AddressCollection always for consistency. In common usage it'd be simple and
sane to return an Address when only one address was searched, however this makes
populating ... | python | def street_addresses(self, addresses):
"""
API method for verifying street address and geolocating
Returns an AddressCollection always for consistency. In common usage it'd be simple and
sane to return an Address when only one address was searched, however this makes
populating ... | [
"def",
"street_addresses",
"(",
"self",
",",
"addresses",
")",
":",
"# While it's okay in theory to accept freeform addresses they do need to be submitted in",
"# a dictionary format.",
"if",
"type",
"(",
"addresses",
"[",
"0",
"]",
")",
"!=",
"dict",
":",
"addresses",
"=... | API method for verifying street address and geolocating
Returns an AddressCollection always for consistency. In common usage it'd be simple and
sane to return an Address when only one address was searched, however this makes
populating search addresses from lists of unknown length problematic. ... | [
"API",
"method",
"for",
"verifying",
"street",
"address",
"and",
"geolocating"
] | f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69 | https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/client.py#L162-L184 | train | This method is used to verify that a list of street addresses is returned. |
bennylope/smartystreets.py | smartystreets/client.py | Client.street_address | def street_address(self, address):
"""
Geocode one and only address, get a single Address object back
>>> client.street_address("100 Main St, Anywhere, USA")
>>> client.street_address({"street": "100 Main St, anywhere USA"})
:param address: string or dictionary with street addr... | python | def street_address(self, address):
"""
Geocode one and only address, get a single Address object back
>>> client.street_address("100 Main St, Anywhere, USA")
>>> client.street_address({"street": "100 Main St, anywhere USA"})
:param address: string or dictionary with street addr... | [
"def",
"street_address",
"(",
"self",
",",
"address",
")",
":",
"address",
"=",
"self",
".",
"street_addresses",
"(",
"[",
"address",
"]",
")",
"if",
"not",
"len",
"(",
"address",
")",
":",
"return",
"None",
"return",
"Address",
"(",
"address",
"[",
"0... | Geocode one and only address, get a single Address object back
>>> client.street_address("100 Main St, Anywhere, USA")
>>> client.street_address({"street": "100 Main St, anywhere USA"})
:param address: string or dictionary with street address information
:return: an Address object or N... | [
"Geocode",
"one",
"and",
"only",
"address",
"get",
"a",
"single",
"Address",
"object",
"back"
] | f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69 | https://github.com/bennylope/smartystreets.py/blob/f45e37dd52ea7cec8ed43ce2b64724beb6dbbb69/smartystreets/client.py#L186-L200 | train | Geocode one and only address get a single Address object |
LISE-B26/pylabcontrol | build/lib/tools/scan_serial_ports.py | scan | def scan():
"""
scan for available ports. return a list of tuples (num, name)
Returns:
"""
available = []
for i in range(256):
try:
s = serial.Serial('COM'+str(i))
available.append((i, s.portstr))
s.close()
except serial.SerialException:
... | python | def scan():
"""
scan for available ports. return a list of tuples (num, name)
Returns:
"""
available = []
for i in range(256):
try:
s = serial.Serial('COM'+str(i))
available.append((i, s.portstr))
s.close()
except serial.SerialException:
... | [
"def",
"scan",
"(",
")",
":",
"available",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"256",
")",
":",
"try",
":",
"s",
"=",
"serial",
".",
"Serial",
"(",
"'COM'",
"+",
"str",
"(",
"i",
")",
")",
"available",
".",
"append",
"(",
"(",
"i",... | scan for available ports. return a list of tuples (num, name)
Returns: | [
"scan",
"for",
"available",
"ports",
".",
"return",
"a",
"list",
"of",
"tuples",
"(",
"num",
"name",
")",
"Returns",
":"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/tools/scan_serial_ports.py#L24-L38 | train | scan for available ports. return a list of tuples ( num name ) |
johnnoone/json-spec | src/jsonspec/validators/__init__.py | load | def load(schema, uri=None, spec=None, provider=None):
"""Scaffold a validator against a schema.
:param schema: the schema to compile into a Validator
:type schema: Mapping
:param uri: the uri of the schema.
it may be ignored in case of not cross
referencing.
:type ur... | python | def load(schema, uri=None, spec=None, provider=None):
"""Scaffold a validator against a schema.
:param schema: the schema to compile into a Validator
:type schema: Mapping
:param uri: the uri of the schema.
it may be ignored in case of not cross
referencing.
:type ur... | [
"def",
"load",
"(",
"schema",
",",
"uri",
"=",
"None",
",",
"spec",
"=",
"None",
",",
"provider",
"=",
"None",
")",
":",
"factory",
"=",
"Factory",
"(",
"provider",
",",
"spec",
")",
"return",
"factory",
"(",
"schema",
",",
"uri",
"or",
"'#'",
")"
... | Scaffold a validator against a schema.
:param schema: the schema to compile into a Validator
:type schema: Mapping
:param uri: the uri of the schema.
it may be ignored in case of not cross
referencing.
:type uri: Pointer, str
:param spec: fallback to this spec if the... | [
"Scaffold",
"a",
"validator",
"against",
"a",
"schema",
"."
] | f91981724cea0c366bd42a6670eb07bbe31c0e0c | https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/validators/__init__.py#L21-L37 | train | Creates a Validator that can be used to validate a schema against another schema. |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/gui/windows_and_widgets/widgets.py | MatplotlibWidget.sizeHint | def sizeHint(self):
"""
gives qt a starting point for widget size during window resizing
"""
w, h = self.get_width_height()
return QtCore.QSize(w, h) | python | def sizeHint(self):
"""
gives qt a starting point for widget size during window resizing
"""
w, h = self.get_width_height()
return QtCore.QSize(w, h) | [
"def",
"sizeHint",
"(",
"self",
")",
":",
"w",
",",
"h",
"=",
"self",
".",
"get_width_height",
"(",
")",
"return",
"QtCore",
".",
"QSize",
"(",
"w",
",",
"h",
")"
] | gives qt a starting point for widget size during window resizing | [
"gives",
"qt",
"a",
"starting",
"point",
"for",
"widget",
"size",
"during",
"window",
"resizing"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/gui/windows_and_widgets/widgets.py#L416-L421 | train | returns the size hint for this widget |
johnnoone/json-spec | src/jsonspec/pointer/stages.py | stage | def stage(obj, parent=None, member=None):
"""
Prepare obj to be staged.
This is almost used for relative JSON Pointers.
"""
obj = Staged(obj, parent, member)
if isinstance(obj, Mapping):
for key, value in obj.items():
stage(value, obj, key)
elif isinstance(obj, Sequence... | python | def stage(obj, parent=None, member=None):
"""
Prepare obj to be staged.
This is almost used for relative JSON Pointers.
"""
obj = Staged(obj, parent, member)
if isinstance(obj, Mapping):
for key, value in obj.items():
stage(value, obj, key)
elif isinstance(obj, Sequence... | [
"def",
"stage",
"(",
"obj",
",",
"parent",
"=",
"None",
",",
"member",
"=",
"None",
")",
":",
"obj",
"=",
"Staged",
"(",
"obj",
",",
"parent",
",",
"member",
")",
"if",
"isinstance",
"(",
"obj",
",",
"Mapping",
")",
":",
"for",
"key",
",",
"value... | Prepare obj to be staged.
This is almost used for relative JSON Pointers. | [
"Prepare",
"obj",
"to",
"be",
"staged",
"."
] | f91981724cea0c366bd42a6670eb07bbe31c0e0c | https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/pointer/stages.py#L50-L68 | train | Prepare obj to be staged. |
dirkcuys/s3-backup-rotate | dcu/active_memory/rotate.py | rotate | def rotate(key_prefix, key_ext, bucket_name, daily_backups=7, weekly_backups=4, aws_key=None, aws_secret=None):
""" Delete old files we've uploaded to S3 according to grandfather, father, sun strategy """
session = boto3.Session(
aws_access_key_id=aws_key,
aws_secret_access_key=aws_secret
)... | python | def rotate(key_prefix, key_ext, bucket_name, daily_backups=7, weekly_backups=4, aws_key=None, aws_secret=None):
""" Delete old files we've uploaded to S3 according to grandfather, father, sun strategy """
session = boto3.Session(
aws_access_key_id=aws_key,
aws_secret_access_key=aws_secret
)... | [
"def",
"rotate",
"(",
"key_prefix",
",",
"key_ext",
",",
"bucket_name",
",",
"daily_backups",
"=",
"7",
",",
"weekly_backups",
"=",
"4",
",",
"aws_key",
"=",
"None",
",",
"aws_secret",
"=",
"None",
")",
":",
"session",
"=",
"boto3",
".",
"Session",
"(",
... | Delete old files we've uploaded to S3 according to grandfather, father, sun strategy | [
"Delete",
"old",
"files",
"we",
"ve",
"uploaded",
"to",
"S3",
"according",
"to",
"grandfather",
"father",
"sun",
"strategy"
] | ab226c7b636550823a9c91e3ebd81776d255f204 | https://github.com/dirkcuys/s3-backup-rotate/blob/ab226c7b636550823a9c91e3ebd81776d255f204/dcu/active_memory/rotate.py#L10-L46 | train | Delete old files we ve uploaded to S3 according to grandfather father sun strategy |
dirkcuys/s3-backup-rotate | dcu/active_memory/rotate.py | splitext | def splitext( filename ):
""" Return the filename and extension according to the first dot in the filename.
This helps date stamping .tar.bz2 or .ext.gz files properly.
"""
index = filename.find('.')
if index == 0:
index = 1+filename[1:].find('.')
if index == -1:
return filen... | python | def splitext( filename ):
""" Return the filename and extension according to the first dot in the filename.
This helps date stamping .tar.bz2 or .ext.gz files properly.
"""
index = filename.find('.')
if index == 0:
index = 1+filename[1:].find('.')
if index == -1:
return filen... | [
"def",
"splitext",
"(",
"filename",
")",
":",
"index",
"=",
"filename",
".",
"find",
"(",
"'.'",
")",
"if",
"index",
"==",
"0",
":",
"index",
"=",
"1",
"+",
"filename",
"[",
"1",
":",
"]",
".",
"find",
"(",
"'.'",
")",
"if",
"index",
"==",
"-",... | Return the filename and extension according to the first dot in the filename.
This helps date stamping .tar.bz2 or .ext.gz files properly. | [
"Return",
"the",
"filename",
"and",
"extension",
"according",
"to",
"the",
"first",
"dot",
"in",
"the",
"filename",
".",
"This",
"helps",
"date",
"stamping",
".",
"tar",
".",
"bz2",
"or",
".",
"ext",
".",
"gz",
"files",
"properly",
"."
] | ab226c7b636550823a9c91e3ebd81776d255f204 | https://github.com/dirkcuys/s3-backup-rotate/blob/ab226c7b636550823a9c91e3ebd81776d255f204/dcu/active_memory/rotate.py#L49-L59 | train | Return the filename and extension according to the first dot in the filename. |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/gui/manual_fitting.py | FittingWindow.plot_clicked | def plot_clicked(self, mouse_event):
"""
When a click is registered on the plot, appends the click location to self.peak_vals and plots a red dot in the
click location
:param mouse_event: a mouse event object for the click
"""
if type(self.peak_vals) is list:
... | python | def plot_clicked(self, mouse_event):
"""
When a click is registered on the plot, appends the click location to self.peak_vals and plots a red dot in the
click location
:param mouse_event: a mouse event object for the click
"""
if type(self.peak_vals) is list:
... | [
"def",
"plot_clicked",
"(",
"self",
",",
"mouse_event",
")",
":",
"if",
"type",
"(",
"self",
".",
"peak_vals",
")",
"is",
"list",
":",
"self",
".",
"peak_vals",
".",
"append",
"(",
"[",
"mouse_event",
".",
"xdata",
",",
"mouse_event",
".",
"ydata",
"]"... | When a click is registered on the plot, appends the click location to self.peak_vals and plots a red dot in the
click location
:param mouse_event: a mouse event object for the click | [
"When",
"a",
"click",
"is",
"registered",
"on",
"the",
"plot",
"appends",
"the",
"click",
"location",
"to",
"self",
".",
"peak_vals",
"and",
"plots",
"a",
"red",
"dot",
"in",
"the",
"click",
"location",
":",
"param",
"mouse_event",
":",
"a",
"mouse",
"ev... | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/manual_fitting.py#L92-L110 | train | This method is called when a mouse button is clicked on the plot. |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/gui/manual_fitting.py | FittingWindow.start_fitting | def start_fitting(self):
"""
Launches the fitting routine on another thread
"""
self.queue = queue.Queue()
self.peak_vals = []
self.fit_thread = QThread() #must be assigned as an instance variable, not local, as otherwise thread is garbage
... | python | def start_fitting(self):
"""
Launches the fitting routine on another thread
"""
self.queue = queue.Queue()
self.peak_vals = []
self.fit_thread = QThread() #must be assigned as an instance variable, not local, as otherwise thread is garbage
... | [
"def",
"start_fitting",
"(",
"self",
")",
":",
"self",
".",
"queue",
"=",
"queue",
".",
"Queue",
"(",
")",
"self",
".",
"peak_vals",
"=",
"[",
"]",
"self",
".",
"fit_thread",
"=",
"QThread",
"(",
")",
"#must be assigned as an instance variable, not local, as o... | Launches the fitting routine on another thread | [
"Launches",
"the",
"fitting",
"routine",
"on",
"another",
"thread"
] | 67482e5157fcd1c40705e5c2cacfb93564703ed0 | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/gui/manual_fitting.py#L326-L339 | train | Launches the fitting routine on another thread |
CitrineInformatics/pif-dft | dfttopif/parsers/vasp.py | VaspParser._get_bandgap_from_bands | def _get_bandgap_from_bands(energies, nelec):
"""Compute difference in conduction band min and valence band max"""
nelec = int(nelec)
valence = [x[nelec-1] for x in energies]
conduction = [x[nelec] for x in energies]
return max(min(conduction) - max(valence), 0.0) | python | def _get_bandgap_from_bands(energies, nelec):
"""Compute difference in conduction band min and valence band max"""
nelec = int(nelec)
valence = [x[nelec-1] for x in energies]
conduction = [x[nelec] for x in energies]
return max(min(conduction) - max(valence), 0.0) | [
"def",
"_get_bandgap_from_bands",
"(",
"energies",
",",
"nelec",
")",
":",
"nelec",
"=",
"int",
"(",
"nelec",
")",
"valence",
"=",
"[",
"x",
"[",
"nelec",
"-",
"1",
"]",
"for",
"x",
"in",
"energies",
"]",
"conduction",
"=",
"[",
"x",
"[",
"nelec",
... | Compute difference in conduction band min and valence band max | [
"Compute",
"difference",
"in",
"conduction",
"band",
"min",
"and",
"valence",
"band",
"max"
] | d5411dc1f6c6e8d454b132977ca7ab3bb8131a80 | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/vasp.py#L331-L336 | train | Compute the difference in conduction band min and valence band max |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.