body
stringlengths
26
98.2k
body_hash
int64
-9,222,864,604,528,158,000
9,221,803,474B
docstring
stringlengths
1
16.8k
path
stringlengths
5
230
name
stringlengths
1
96
repository_name
stringlengths
7
89
lang
stringclasses
1 value
body_without_docstring
stringlengths
20
98.2k
def get_standard_ids_by_id(self, _id): 'Get chebi_id, pubmed_id, and kegg_id from\n database specific id.\n \n Args:\n _id (:obj:`str`): Database specific ID.\n\n Return:\n (:obj:`dict`): Dictionary containing the information.\n ' if (self.collection_str ...
4,700,694,575,084,467,000
Get chebi_id, pubmed_id, and kegg_id from database specific id. Args: _id (:obj:`str`): Database specific ID. Return: (:obj:`dict`): Dictionary containing the information.
datanator_query_python/query/query_xmdb.py
get_standard_ids_by_id
KarrLab/datanator_query_python
python
def get_standard_ids_by_id(self, _id): 'Get chebi_id, pubmed_id, and kegg_id from\n database specific id.\n \n Args:\n _id (:obj:`str`): Database specific ID.\n\n Return:\n (:obj:`dict`): Dictionary containing the information.\n ' if (self.collection_str ...
@configurable def __init__(self, is_train: bool, *, augmentations: List[Union[(T.Augmentation, T.Transform)]], image_format: str, use_instance_mask: bool=False, use_keypoint: bool=False, instance_mask_format: str='polygon', keypoint_hflip_indices: Optional[np.ndarray]=None, precomputed_proposal_topk: Optional[int]=None...
-208,818,319,591,433,820
NOTE: this interface is experimental. Args: is_train: whether it's used in training or inference augmentations: a list of augmentations or deterministic transforms to apply image_format: an image format supported by :func:`detection_utils.read_image`. use_instance_mask: whether to process instance segm...
detectron2/data/dataset_mapper.py
__init__
Jerrypiglet/detectron2
python
@configurable def __init__(self, is_train: bool, *, augmentations: List[Union[(T.Augmentation, T.Transform)]], image_format: str, use_instance_mask: bool=False, use_keypoint: bool=False, instance_mask_format: str='polygon', keypoint_hflip_indices: Optional[np.ndarray]=None, precomputed_proposal_topk: Optional[int]=None...
def __call__(self, dataset_dict): '\n Args:\n dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.\n\n Returns:\n dict: a format that builtin models in detectron2 accept\n ' dataset_dict = copy.deepcopy(dataset_dict) image = utils.read_image(da...
689,083,837,638,239,400
Args: dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format. Returns: dict: a format that builtin models in detectron2 accept
detectron2/data/dataset_mapper.py
__call__
Jerrypiglet/detectron2
python
def __call__(self, dataset_dict): '\n Args:\n dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.\n\n Returns:\n dict: a format that builtin models in detectron2 accept\n ' dataset_dict = copy.deepcopy(dataset_dict) image = utils.read_image(da...
@contextlib.contextmanager def _open_archive(archive, directory): 'Manages a directory in which an existing SDK is laid out.' if directory: (yield directory) elif archive: temp_dir = tempfile.mkdtemp(prefix='fuchsia-merger') with tarfile.open(archive) as archive_file: arc...
3,065,005,589,519,523,300
Manages a directory in which an existing SDK is laid out.
scripts/sdk/merger/merge.py
_open_archive
allansrc/fuchsia
python
@contextlib.contextmanager def _open_archive(archive, directory): if directory: (yield directory) elif archive: temp_dir = tempfile.mkdtemp(prefix='fuchsia-merger') with tarfile.open(archive) as archive_file: archive_file.extractall(temp_dir) try: (yi...
@contextlib.contextmanager def _open_output(archive, directory): 'Manages the output of this script.' if directory: shutil.rmtree(directory, ignore_errors=True) (yield directory) elif archive: temp_dir = tempfile.mkdtemp(prefix='fuchsia-merger') try: (yield temp_d...
138,120,787,399,427,680
Manages the output of this script.
scripts/sdk/merger/merge.py
_open_output
allansrc/fuchsia
python
@contextlib.contextmanager def _open_output(archive, directory): if directory: shutil.rmtree(directory, ignore_errors=True) (yield directory) elif archive: temp_dir = tempfile.mkdtemp(prefix='fuchsia-merger') try: (yield temp_dir) with tarfile.open(ar...
def _get_manifest(sdk_dir): 'Returns the set of elements in the given SDK.' with open(os.path.join(sdk_dir, 'meta', 'manifest.json'), 'r') as manifest: return json.load(manifest)
-6,938,343,977,296,843,000
Returns the set of elements in the given SDK.
scripts/sdk/merger/merge.py
_get_manifest
allansrc/fuchsia
python
def _get_manifest(sdk_dir): with open(os.path.join(sdk_dir, 'meta', 'manifest.json'), 'r') as manifest: return json.load(manifest)
def _get_meta(element, sdk_dir): "Returns the contents of the given element's manifest in a given SDK." with open(os.path.join(sdk_dir, element), 'r') as meta: return json.load(meta)
-4,476,401,921,661,051,400
Returns the contents of the given element's manifest in a given SDK.
scripts/sdk/merger/merge.py
_get_meta
allansrc/fuchsia
python
def _get_meta(element, sdk_dir): with open(os.path.join(sdk_dir, element), 'r') as meta: return json.load(meta)
def _get_type(element): 'Returns the SDK element type.' if ('schema_id' in element): return element['data']['type'] return element['type']
55,824,938,872,102,580
Returns the SDK element type.
scripts/sdk/merger/merge.py
_get_type
allansrc/fuchsia
python
def _get_type(element): if ('schema_id' in element): return element['data']['type'] return element['type']
def _get_files(element_meta): 'Extracts the files associated with the given element.\n Returns a 2-tuple containing:\n - the set of arch-independent files;\n - the sets of arch-dependent files, indexed by architecture.\n ' type = _get_type(element_meta) common_files = set() arch_files = {}...
7,918,897,328,551,751,000
Extracts the files associated with the given element. Returns a 2-tuple containing: - the set of arch-independent files; - the sets of arch-dependent files, indexed by architecture.
scripts/sdk/merger/merge.py
_get_files
allansrc/fuchsia
python
def _get_files(element_meta): 'Extracts the files associated with the given element.\n Returns a 2-tuple containing:\n - the set of arch-independent files;\n - the sets of arch-dependent files, indexed by architecture.\n ' type = _get_type(element_meta) common_files = set() arch_files = {}...
def _ensure_directory(path): 'Ensures that the directory hierarchy of the given path exists.' target_dir = os.path.dirname(path) try: os.makedirs(target_dir) except OSError as exception: if ((exception.errno == errno.EEXIST) and os.path.isdir(target_dir)): pass else: ...
-2,222,556,865,119,095,600
Ensures that the directory hierarchy of the given path exists.
scripts/sdk/merger/merge.py
_ensure_directory
allansrc/fuchsia
python
def _ensure_directory(path): target_dir = os.path.dirname(path) try: os.makedirs(target_dir) except OSError as exception: if ((exception.errno == errno.EEXIST) and os.path.isdir(target_dir)): pass else: raise
def _copy_file(file, source_dir, dest_dir): 'Copies a file to a given path, taking care of creating directories if\n needed.\n ' source = os.path.join(source_dir, file) destination = os.path.join(dest_dir, file) _ensure_directory(destination) shutil.copy2(source, destination)
-1,162,556,876,817,004,300
Copies a file to a given path, taking care of creating directories if needed.
scripts/sdk/merger/merge.py
_copy_file
allansrc/fuchsia
python
def _copy_file(file, source_dir, dest_dir): 'Copies a file to a given path, taking care of creating directories if\n needed.\n ' source = os.path.join(source_dir, file) destination = os.path.join(dest_dir, file) _ensure_directory(destination) shutil.copy2(source, destination)
def _copy_files(files, source_dir, dest_dir): 'Copies a set of files to a given directory.' for file in files: _copy_file(file, source_dir, dest_dir)
679,370,016,772,844,700
Copies a set of files to a given directory.
scripts/sdk/merger/merge.py
_copy_files
allansrc/fuchsia
python
def _copy_files(files, source_dir, dest_dir): for file in files: _copy_file(file, source_dir, dest_dir)
def _copy_identical_files(set_one, source_dir_one, set_two, source_dir_two, dest_dir): 'Verifies that two sets of files are absolutely identical and then copies\n them to the output directory.\n ' if (set_one != set_two): return False _copy_files(set_one, source_dir_one, dest_dir) return T...
-6,738,155,008,769,796,000
Verifies that two sets of files are absolutely identical and then copies them to the output directory.
scripts/sdk/merger/merge.py
_copy_identical_files
allansrc/fuchsia
python
def _copy_identical_files(set_one, source_dir_one, set_two, source_dir_two, dest_dir): 'Verifies that two sets of files are absolutely identical and then copies\n them to the output directory.\n ' if (set_one != set_two): return False _copy_files(set_one, source_dir_one, dest_dir) return T...
def _copy_element(element, source_dir, dest_dir): 'Copy an entire SDK element to a given directory.' meta = _get_meta(element, source_dir) (common_files, arch_files) = _get_files(meta) files = common_files for more_files in arch_files.values(): files.update(more_files) _copy_files(files,...
8,808,345,156,117,892,000
Copy an entire SDK element to a given directory.
scripts/sdk/merger/merge.py
_copy_element
allansrc/fuchsia
python
def _copy_element(element, source_dir, dest_dir): meta = _get_meta(element, source_dir) (common_files, arch_files) = _get_files(meta) files = common_files for more_files in arch_files.values(): files.update(more_files) _copy_files(files, source_dir, dest_dir) _copy_file(element, sou...
def _write_meta(element, source_dir_one, source_dir_two, dest_dir): 'Writes a meta file for the given element, resulting from the merge of the\n meta files for that element in the two given SDK directories.\n ' meta_one = _get_meta(element, source_dir_one) meta_two = _get_meta(element, source_dir_two)...
4,619,572,242,825,215,000
Writes a meta file for the given element, resulting from the merge of the meta files for that element in the two given SDK directories.
scripts/sdk/merger/merge.py
_write_meta
allansrc/fuchsia
python
def _write_meta(element, source_dir_one, source_dir_two, dest_dir): 'Writes a meta file for the given element, resulting from the merge of the\n meta files for that element in the two given SDK directories.\n ' meta_one = _get_meta(element, source_dir_one) meta_two = _get_meta(element, source_dir_two)...
def _has_host_content(parts): 'Returns true if the given list of SDK parts contains an element with\n content built for a host.\n ' return ('host_tool' in [part.type for part in parts])
8,791,001,200,716,074,000
Returns true if the given list of SDK parts contains an element with content built for a host.
scripts/sdk/merger/merge.py
_has_host_content
allansrc/fuchsia
python
def _has_host_content(parts): 'Returns true if the given list of SDK parts contains an element with\n content built for a host.\n ' return ('host_tool' in [part.type for part in parts])
def _write_manifest(source_dir_one, source_dir_two, dest_dir): 'Writes a manifest file resulting from the merge of the manifest files for\n the two given SDK directories.\n ' manifest_one = _get_manifest(source_dir_one) manifest_two = _get_manifest(source_dir_two) parts_one = set([Part(p) for p in...
6,378,681,545,367,784,000
Writes a manifest file resulting from the merge of the manifest files for the two given SDK directories.
scripts/sdk/merger/merge.py
_write_manifest
allansrc/fuchsia
python
def _write_manifest(source_dir_one, source_dir_two, dest_dir): 'Writes a manifest file resulting from the merge of the manifest files for\n the two given SDK directories.\n ' manifest_one = _get_manifest(source_dir_one) manifest_two = _get_manifest(source_dir_two) parts_one = set([Part(p) for p in...
def testDAGCollectionAllOf(self): 'Test DAGCollectionAllOf' pass
2,568,053,484,597,592,000
Test DAGCollectionAllOf
airflow_client/test/test_dag_collection_all_of.py
testDAGCollectionAllOf
sptsakcg/airflow-client-python
python
def testDAGCollectionAllOf(self): pass
@pytest.mark.usefixtures('init_blockchain') def test_check_script(rpconn, piece_hashes, spool_regtest, transactions): '\n Test :staticmethod:`check_script`.\n\n Args;\n alice (str): bitcoin address of alice, the sender\n bob (str): bitcoin address of bob, the receiver\n rpconn (AuthServic...
7,597,036,693,908,579,000
Test :staticmethod:`check_script`. Args; alice (str): bitcoin address of alice, the sender bob (str): bitcoin address of bob, the receiver rpconn (AuthServiceProxy): JSON-RPC connection (:class:`AuthServiceProxy` instance) to bitcoin regtest transactions (Transactions): :class:`Transactions` in...
tests/test_spoolex.py
test_check_script
ascribe/pyspool
python
@pytest.mark.usefixtures('init_blockchain') def test_check_script(rpconn, piece_hashes, spool_regtest, transactions): '\n Test :staticmethod:`check_script`.\n\n Args;\n alice (str): bitcoin address of alice, the sender\n bob (str): bitcoin address of bob, the receiver\n rpconn (AuthServic...
@pytest.mark.usefixtures('init_blockchain') def test_check_script_with_invalid_tx(eve, wendy, rpconn, transactions): '\n An invalid transaction in this context is one that does not contain a\n ``vout`` for which the ``hex`` is a valid ``Spool`` verb.\n\n Args;\n eve (str): bitcoin address of eve, th...
-3,958,756,659,847,866,000
An invalid transaction in this context is one that does not contain a ``vout`` for which the ``hex`` is a valid ``Spool`` verb. Args; eve (str): bitcoin address of eve, the sender wendy (str): bitcoin address of wendy, the receiver rpconn (AuthServiceProxy): JSON-RPC connection (:class:`AuthService...
tests/test_spoolex.py
test_check_script_with_invalid_tx
ascribe/pyspool
python
@pytest.mark.usefixtures('init_blockchain') def test_check_script_with_invalid_tx(eve, wendy, rpconn, transactions): '\n An invalid transaction in this context is one that does not contain a\n ``vout`` for which the ``hex`` is a valid ``Spool`` verb.\n\n Args;\n eve (str): bitcoin address of eve, th...
@pytest.mark.usefixtures('init_blockchain') def test_get_addresses_with_invalid_tx(eve, wendy, rpconn, transactions): '\n An invalid transaction in this context is one that has inputs from\n different addresses.\n\n Args;\n eve (str): bitcoin address of eve, the sender\n wendy (str): bitcoin ...
-5,346,686,385,827,037,000
An invalid transaction in this context is one that has inputs from different addresses. Args; eve (str): bitcoin address of eve, the sender wendy (str): bitcoin address of wendy, the receiver rpconn (AuthServiceProxy): JSON-RPC connection (:class:`AuthServiceProxy` instance) a local bitcoin regtest...
tests/test_spoolex.py
test_get_addresses_with_invalid_tx
ascribe/pyspool
python
@pytest.mark.usefixtures('init_blockchain') def test_get_addresses_with_invalid_tx(eve, wendy, rpconn, transactions): '\n An invalid transaction in this context is one that has inputs from\n different addresses.\n\n Args;\n eve (str): bitcoin address of eve, the sender\n wendy (str): bitcoin ...
@contextlib.contextmanager def syslog(ctx, config): '\n start syslog / stop syslog on exit.\n ' if (ctx.archive is None): (yield) return log.info('Starting syslog monitoring...') archive_dir = misc.get_archive_dir(ctx) log_dir = '{adir}/syslog'.format(adir=archive_dir) run....
-8,120,165,371,422,887,000
start syslog / stop syslog on exit.
teuthology/task/internal/syslog.py
syslog
dzedro/teuthology
python
@contextlib.contextmanager def syslog(ctx, config): '\n \n ' if (ctx.archive is None): (yield) return log.info('Starting syslog monitoring...') archive_dir = misc.get_archive_dir(ctx) log_dir = '{adir}/syslog'.format(adir=archive_dir) run.wait(ctx.cluster.run(args=['mkdir',...
def define_graph(inputs, labels, is_training, batch_size, replicas_to_aggregate): '\n Define graph for synchronized training.\n ' model = Cifar10Model(resnet_size=20, data_format='channels_last', resnet_version=2, dtype=tf.float32) logits = model(inputs, is_training) loss = softmax_cross_entropy_w...
-1,640,052,700,166,835,500
Define graph for synchronized training.
tensorflow/imagerecognition/openmpi-cifar10-resnet20-all-reduce/main.py
define_graph
mlbench/mlbench-benchmarks
python
def define_graph(inputs, labels, is_training, batch_size, replicas_to_aggregate): '\n \n ' model = Cifar10Model(resnet_size=20, data_format='channels_last', resnet_version=2, dtype=tf.float32) logits = model(inputs, is_training) loss = softmax_cross_entropy_with_logits_v2_l2_regularized(logits=log...
def shift_decoder(decoder, shift_constant): ' Shifts the indices of a decoder by a constant.\n\n Args:\n decoder (iterable): list of BinaryPolynomial; the decoder\n shift_constant (int): the qubit index that corresponds to the offset.\n\n Returns (list): list of BinaryPolynomial shifted decoder\...
1,393,594,874,258,132,700
Shifts the indices of a decoder by a constant. Args: decoder (iterable): list of BinaryPolynomial; the decoder shift_constant (int): the qubit index that corresponds to the offset. Returns (list): list of BinaryPolynomial shifted decoder
src/openfermion/ops/_binary_code.py
shift_decoder
0tt3r/OpenFermion
python
def shift_decoder(decoder, shift_constant): ' Shifts the indices of a decoder by a constant.\n\n Args:\n decoder (iterable): list of BinaryPolynomial; the decoder\n shift_constant (int): the qubit index that corresponds to the offset.\n\n Returns (list): list of BinaryPolynomial shifted decoder\...
def double_decoding(decoder_1, decoder_2): ' Concatenates two decodings\n\n Args:\n decoder_1 (iterable): list of BinaryPolynomial\n decoding of the outer code layer\n decoder_2 (iterable): list of BinaryPolynomial\n decoding of the inner code layer\n\n Returns (list): list...
-7,527,210,314,016,534,000
Concatenates two decodings Args: decoder_1 (iterable): list of BinaryPolynomial decoding of the outer code layer decoder_2 (iterable): list of BinaryPolynomial decoding of the inner code layer Returns (list): list of BinaryPolynomial the decoding defined by w -> decoder_1( decoder_2(w) )
src/openfermion/ops/_binary_code.py
double_decoding
0tt3r/OpenFermion
python
def double_decoding(decoder_1, decoder_2): ' Concatenates two decodings\n\n Args:\n decoder_1 (iterable): list of BinaryPolynomial\n decoding of the outer code layer\n decoder_2 (iterable): list of BinaryPolynomial\n decoding of the inner code layer\n\n Returns (list): list...
def __init__(self, encoding, decoding): ' Initialization of a binary code.\n\n Args:\n encoding (np.ndarray or list): nested lists or binary 2D-array\n decoding (array or list): list of BinaryPolynomial (list or str).\n\n Raises:\n TypeError: non-list, array like encod...
-5,366,171,525,332,897,000
Initialization of a binary code. Args: encoding (np.ndarray or list): nested lists or binary 2D-array decoding (array or list): list of BinaryPolynomial (list or str). Raises: TypeError: non-list, array like encoding or decoding, unsuitable BinaryPolynomial generators, BinaryCodeError: in case...
src/openfermion/ops/_binary_code.py
__init__
0tt3r/OpenFermion
python
def __init__(self, encoding, decoding): ' Initialization of a binary code.\n\n Args:\n encoding (np.ndarray or list): nested lists or binary 2D-array\n decoding (array or list): list of BinaryPolynomial (list or str).\n\n Raises:\n TypeError: non-list, array like encod...
def __iadd__(self, appendix): ' In-place appending a binary code with +=.\n\n Args:\n appendix (BinaryCode): The code to append to the present one.\n\n Returns (BinaryCode): A global binary code with size\n (n_modes1 + n_modes2), (n_qubits1,n_qubits2)\n\n Raises:\n ...
-2,979,734,494,670,934,000
In-place appending a binary code with +=. Args: appendix (BinaryCode): The code to append to the present one. Returns (BinaryCode): A global binary code with size (n_modes1 + n_modes2), (n_qubits1,n_qubits2) Raises: TypeError: Appendix must be a BinaryCode.
src/openfermion/ops/_binary_code.py
__iadd__
0tt3r/OpenFermion
python
def __iadd__(self, appendix): ' In-place appending a binary code with +=.\n\n Args:\n appendix (BinaryCode): The code to append to the present one.\n\n Returns (BinaryCode): A global binary code with size\n (n_modes1 + n_modes2), (n_qubits1,n_qubits2)\n\n Raises:\n ...
def __add__(self, appendix): 'Appends two binary codes via addition +.\n\n Args:\n appendix (BinaryCode): The code to append to the present one.\n\n Returns (BinaryCode): global binary code\n ' twin = copy.deepcopy(self) twin += appendix return twin
6,067,573,203,762,698,000
Appends two binary codes via addition +. Args: appendix (BinaryCode): The code to append to the present one. Returns (BinaryCode): global binary code
src/openfermion/ops/_binary_code.py
__add__
0tt3r/OpenFermion
python
def __add__(self, appendix): 'Appends two binary codes via addition +.\n\n Args:\n appendix (BinaryCode): The code to append to the present one.\n\n Returns (BinaryCode): global binary code\n ' twin = copy.deepcopy(self) twin += appendix return twin
def __imul__(self, factor): 'In-place code concatenation or appendage via *= .\n Multiplication with integer will yield appendage, otherwise\n concatenation.\n\n Args:\n factor (int or BinaryCode): the BinaryCode to concatenate. In case\n of int, it will append the cod...
8,357,015,318,212,129,000
In-place code concatenation or appendage via *= . Multiplication with integer will yield appendage, otherwise concatenation. Args: factor (int or BinaryCode): the BinaryCode to concatenate. In case of int, it will append the code to itself factor times. Returns (BinaryCode): segmented or concatenated code...
src/openfermion/ops/_binary_code.py
__imul__
0tt3r/OpenFermion
python
def __imul__(self, factor): 'In-place code concatenation or appendage via *= .\n Multiplication with integer will yield appendage, otherwise\n concatenation.\n\n Args:\n factor (int or BinaryCode): the BinaryCode to concatenate. In case\n of int, it will append the cod...
def __mul__(self, factor): ' Concatenation of two codes or appendage the same code factor times\n in case of integer factor.\n\n Args:\n factor (int or BinaryCode): the BinaryCode to concatenate. In case\n of int, it will append the code to itself factor times.\n\n Ret...
384,758,140,904,999,740
Concatenation of two codes or appendage the same code factor times in case of integer factor. Args: factor (int or BinaryCode): the BinaryCode to concatenate. In case of int, it will append the code to itself factor times. Returns (BinaryCode): segmented or concatenated code
src/openfermion/ops/_binary_code.py
__mul__
0tt3r/OpenFermion
python
def __mul__(self, factor): ' Concatenation of two codes or appendage the same code factor times\n in case of integer factor.\n\n Args:\n factor (int or BinaryCode): the BinaryCode to concatenate. In case\n of int, it will append the code to itself factor times.\n\n Ret...
def __rmul__(self, factor): ' Appending the same code factor times.\n\n Args:\n factor (int): integer defining number of appendages.\n\n Returns (BinaryCode): Segmented code.\n\n Raises:\n TypeError: factor must be an integer\n ' if isinstance(factor, (numpy.int...
8,989,757,218,044,066,000
Appending the same code factor times. Args: factor (int): integer defining number of appendages. Returns (BinaryCode): Segmented code. Raises: TypeError: factor must be an integer
src/openfermion/ops/_binary_code.py
__rmul__
0tt3r/OpenFermion
python
def __rmul__(self, factor): ' Appending the same code factor times.\n\n Args:\n factor (int): integer defining number of appendages.\n\n Returns (BinaryCode): Segmented code.\n\n Raises:\n TypeError: factor must be an integer\n ' if isinstance(factor, (numpy.int...
def __str__(self): ' Return an easy-to-read string representation.' string_return = [list(map(list, self.encoder.toarray()))] dec_str = '[' for term in self.decoder: dec_str += (term.__str__() + ',') dec_str = dec_str[:(- 1)] string_return.append((dec_str + ']')) return str(string_re...
-746,197,833,112,043,300
Return an easy-to-read string representation.
src/openfermion/ops/_binary_code.py
__str__
0tt3r/OpenFermion
python
def __str__(self): ' ' string_return = [list(map(list, self.encoder.toarray()))] dec_str = '[' for term in self.decoder: dec_str += (term.__str__() + ',') dec_str = dec_str[:(- 1)] string_return.append((dec_str + ']')) return str(string_return)
@app.get('/recommendation') async def recommend(request): '\n Gets recommendations for user\n Expects args in query string form -> user=x&count=n\n Returns json object {posts, unvoted, user, meta}\n ' args = request.raw_args recommender = Recommender(app.predictor, request['accessor'], read_conf...
3,964,531,211,473,154,000
Gets recommendations for user Expects args in query string form -> user=x&count=n Returns json object {posts, unvoted, user, meta}
kiwi-content/kiwi/app.py
recommend
bubblegumsoldier/kiwi
python
@app.get('/recommendation') async def recommend(request): '\n Gets recommendations for user\n Expects args in query string form -> user=x&count=n\n Returns json object {posts, unvoted, user, meta}\n ' args = request.raw_args recommender = Recommender(app.predictor, request['accessor'], read_conf...
@app.post('/feedback') async def feedback(request: Request): 'Stores the feedback for a recommended post. Will return a information object on success and an empty object on failure.\n Think about returning 409-Conflict on failure instead, because the empty object can cause an issue in engine service.' vote =...
-7,407,837,287,500,175,000
Stores the feedback for a recommended post. Will return a information object on success and an empty object on failure. Think about returning 409-Conflict on failure instead, because the empty object can cause an issue in engine service.
kiwi-content/kiwi/app.py
feedback
bubblegumsoldier/kiwi
python
@app.post('/feedback') async def feedback(request: Request): 'Stores the feedback for a recommended post. Will return a information object on success and an empty object on failure.\n Think about returning 409-Conflict on failure instead, because the empty object can cause an issue in engine service.' vote =...
@app.post('/content') async def content(request: Request): '\n Inserts posts into the database. The request needs the format\n { "posts": [{"id": string, "tags": string}]}.\n Returns the amout of inserted items and 200-OK.\n ' filtered_posts = [(post['id'], post['tags']) for post in request.json...
7,956,493,187,145,312,000
Inserts posts into the database. The request needs the format { "posts": [{"id": string, "tags": string}]}. Returns the amout of inserted items and 200-OK.
kiwi-content/kiwi/app.py
content
bubblegumsoldier/kiwi
python
@app.post('/content') async def content(request: Request): '\n Inserts posts into the database. The request needs the format\n { "posts": [{"id": string, "tags": string}]}.\n Returns the amout of inserted items and 200-OK.\n ' filtered_posts = [(post['id'], post['tags']) for post in request.json...
@app.get('/activation') async def activation(request: Request): '\n Returns the activation value for the given set of heuristics\n ' heuristics = request.json['heuristics'] try: utv = (await app.predictor.get_user_taste_vector(heuristics['user'])) except KeyError: utv = None ac...
2,118,346,643,659,316,500
Returns the activation value for the given set of heuristics
kiwi-content/kiwi/app.py
activation
bubblegumsoldier/kiwi
python
@app.get('/activation') async def activation(request: Request): '\n \n ' heuristics = request.json['heuristics'] try: utv = (await app.predictor.get_user_taste_vector(heuristics['user'])) except KeyError: utv = None ac = ActivationCalculator(heuristics, request['accessor']) ...
def allocate_buffers(engine): "Allocates host and device buffer for TRT engine inference.\n\n This function is similair to the one in ../../common.py, but\n converts network outputs (which are np.float32) appropriately\n before writing them to Python buffer. This is needed, since\n TensorRT plugins does...
4,037,928,288,186,843,600
Allocates host and device buffer for TRT engine inference. This function is similair to the one in ../../common.py, but converts network outputs (which are np.float32) appropriately before writing them to Python buffer. This is needed, since TensorRT plugins doesn't support output type description, and in our particul...
samples/python/uff_ssd/utils/engine.py
allocate_buffers
GreyZzzzzzXh/TensorRT
python
def allocate_buffers(engine): "Allocates host and device buffer for TRT engine inference.\n\n This function is similair to the one in ../../common.py, but\n converts network outputs (which are np.float32) appropriately\n before writing them to Python buffer. This is needed, since\n TensorRT plugins does...
def rainbow_to_vector(r, timeformat='h'): " Convert Rainbow object to np.arrays\n Parameters\n ----------\n r : Rainbow object\n chromatic Rainbow object to convert into array format\n timeformat : str\n (optional, default='hours')\n The time format to use (secon...
979,080,137,809,821,700
Convert Rainbow object to np.arrays Parameters ---------- r : Rainbow object chromatic Rainbow object to convert into array format timeformat : str (optional, default='hours') The time format to use (seconds, minutes, hours, days etc.) Returns ---------- rflux : np.array flux...
src/utils.py
rainbow_to_vector
catrionamurray/chromatic_fitting
python
def rainbow_to_vector(r, timeformat='h'): " Convert Rainbow object to np.arrays\n Parameters\n ----------\n r : Rainbow object\n chromatic Rainbow object to convert into array format\n timeformat : str\n (optional, default='hours')\n The time format to use (secon...
def rainbow_to_df(r, timeformat='h'): " Convert Rainbow object to pandas dataframe\n Parameters\n ----------\n r : Rainbow object\n chromatic Rainbow object to convert into pandas df format\n timeformat : str\n (optional, default='hours')\n The time format to use...
43,283,962,878,375,304
Convert Rainbow object to pandas dataframe Parameters ---------- r : Rainbow object chromatic Rainbow object to convert into pandas df format timeformat : str (optional, default='hours') The time format to use (seconds, minutes, hours, days etc.) Returns ---------- pd.DataFrame
src/utils.py
rainbow_to_df
catrionamurray/chromatic_fitting
python
def rainbow_to_df(r, timeformat='h'): " Convert Rainbow object to pandas dataframe\n Parameters\n ----------\n r : Rainbow object\n chromatic Rainbow object to convert into pandas df format\n timeformat : str\n (optional, default='hours')\n The time format to use...
def do_import(self, timestamp): 'Call one key import RPC.' if (self.call == Call.single): if (self.data == Data.address): response = self.try_rpc(self.node.importaddress, self.address['address'], self.label, (self.rescan == Rescan.yes)) elif (self.data == Data.pub): respo...
-4,665,100,780,963,157,000
Call one key import RPC.
test/functional/import-rescan.py
do_import
BlueScionic/vivarium
python
def do_import(self, timestamp): if (self.call == Call.single): if (self.data == Data.address): response = self.try_rpc(self.node.importaddress, self.address['address'], self.label, (self.rescan == Rescan.yes)) elif (self.data == Data.pub): response = self.try_rpc(self.no...
def check(self, txid=None, amount=None, confirmations=None): 'Verify that getbalance/listtransactions return expected values.' balance = self.node.getbalance(self.label, 0, False, True) assert_equal(balance, self.expected_balance) txs = self.node.listtransactions(self.label, 10000, 0, True) assert_e...
226,965,051,230,975,360
Verify that getbalance/listtransactions return expected values.
test/functional/import-rescan.py
check
BlueScionic/vivarium
python
def check(self, txid=None, amount=None, confirmations=None): balance = self.node.getbalance(self.label, 0, False, True) assert_equal(balance, self.expected_balance) txs = self.node.listtransactions(self.label, 10000, 0, True) assert_equal(len(txs), self.expected_txs) if (txid is not None): ...
def filter_func(data, search_notes): ' Return all objects' search_notes.append(('error', 'Unable to parse search expression', 0, len(query_string))) return False
8,760,193,685,689,438,000
Return all objects
sampledb/frontend/objects.py
filter_func
sciapp/sampledb
python
def filter_func(data, search_notes): ' ' search_notes.append(('error', 'Unable to parse search expression', 0, len(query_string))) return False
def elapsed(t0=0.0): 'get elapsed time from the give time\n\n Returns:\n now: the absolute time now\n dt_str: elapsed time in string\n ' now = time() dt = (now - t0) dt_sec = Decimal(str(dt)).quantize(Decimal('.0001'), rounding=ROUND_DOWN) if (dt_sec <= 1): dt_str = (...
3,239,857,340,972,211,000
get elapsed time from the give time Returns: now: the absolute time now dt_str: elapsed time in string
andes/utils/time.py
elapsed
mhdella/andes
python
def elapsed(t0=0.0): 'get elapsed time from the give time\n\n Returns:\n now: the absolute time now\n dt_str: elapsed time in string\n ' now = time() dt = (now - t0) dt_sec = Decimal(str(dt)).quantize(Decimal('.0001'), rounding=ROUND_DOWN) if (dt_sec <= 1): dt_str = (...
def __str__(self): '\n String for representing the Model object (in Admin site etc.)\n ' return self.name
6,625,425,250,428,873,000
String for representing the Model object (in Admin site etc.)
src/locallibrary/catalog/models.py
__str__
zhekazuev/mozilla-django-learning
python
def __str__(self): '\n \n ' return self.name
def __str__(self): '\n String for representing the Model object (in Admin site etc.)\n ' return self.name
6,625,425,250,428,873,000
String for representing the Model object (in Admin site etc.)
src/locallibrary/catalog/models.py
__str__
zhekazuev/mozilla-django-learning
python
def __str__(self): '\n \n ' return self.name
def __str__(self): '\n String for representing the Model object.\n ' return self.title
8,601,006,417,814,906,000
String for representing the Model object.
src/locallibrary/catalog/models.py
__str__
zhekazuev/mozilla-django-learning
python
def __str__(self): '\n \n ' return self.title
def get_absolute_url(self): '\n Returns the url to access a particular book instance.\n ' return reverse('book-detail', args=[str(self.id)])
-9,027,267,842,509,070,000
Returns the url to access a particular book instance.
src/locallibrary/catalog/models.py
get_absolute_url
zhekazuev/mozilla-django-learning
python
def get_absolute_url(self): '\n \n ' return reverse('book-detail', args=[str(self.id)])
def __str__(self): '\n String for representing the Model object\n ' return '{0} ({1})'.format(self.id, self.book.title)
-7,487,876,419,173,492,000
String for representing the Model object
src/locallibrary/catalog/models.py
__str__
zhekazuev/mozilla-django-learning
python
def __str__(self): '\n \n ' return '{0} ({1})'.format(self.id, self.book.title)
def get_absolute_url(self): '\n Returns the url to access a particular author instance.\n ' return reverse('author-detail', args=[str(self.id)])
-894,346,297,409,379,600
Returns the url to access a particular author instance.
src/locallibrary/catalog/models.py
get_absolute_url
zhekazuev/mozilla-django-learning
python
def get_absolute_url(self): '\n \n ' return reverse('author-detail', args=[str(self.id)])
def __str__(self): '\n String for representing the Model object.\n ' return '{0} ({1})'.format(self.last_name, self.first_name)
-6,520,315,775,681,146,000
String for representing the Model object.
src/locallibrary/catalog/models.py
__str__
zhekazuev/mozilla-django-learning
python
def __str__(self): '\n \n ' return '{0} ({1})'.format(self.last_name, self.first_name)
def main(args): 'Main function to parse in Nuclei Dataset from Kaggle and store as HDF5\n\n Parameters\n ----------\n args: ArgumentParser()\n input_dir: str\n directory of the Nuclei data\n output_dir: str\n path to the HDF5 output directory\n ' ...
6,529,766,840,498,225,000
Main function to parse in Nuclei Dataset from Kaggle and store as HDF5 Parameters ---------- args: ArgumentParser() input_dir: str directory of the Nuclei data output_dir: str path to the HDF5 output directory
process_data/nuclei_create_hdf5.py
main
marshuang80/CellSegmentation
python
def main(args): 'Main function to parse in Nuclei Dataset from Kaggle and store as HDF5\n\n Parameters\n ----------\n args: ArgumentParser()\n input_dir: str\n directory of the Nuclei data\n output_dir: str\n path to the HDF5 output directory\n ' ...
def train_step(self, *inputs, **kwargs): 'train_step() API for module wrapped by DistributedDataParallel.\n\n This method is basically the same as\n ``DistributedDataParallel.forward()``, while replacing\n ``self.module.forward()`` with ``self.module.train_step()``.\n It is compatible wi...
-3,869,767,233,722,932,700
train_step() API for module wrapped by DistributedDataParallel. This method is basically the same as ``DistributedDataParallel.forward()``, while replacing ``self.module.forward()`` with ``self.module.train_step()``. It is compatible with PyTorch 1.1 - 1.5.
mmcv/parallel/distributed.py
train_step
BIGWangYuDong/mmcv
python
def train_step(self, *inputs, **kwargs): 'train_step() API for module wrapped by DistributedDataParallel.\n\n This method is basically the same as\n ``DistributedDataParallel.forward()``, while replacing\n ``self.module.forward()`` with ``self.module.train_step()``.\n It is compatible wi...
def val_step(self, *inputs, **kwargs): 'val_step() API for module wrapped by DistributedDataParallel.\n\n This method is basically the same as\n ``DistributedDataParallel.forward()``, while replacing\n ``self.module.forward()`` with ``self.module.val_step()``.\n It is compatible with PyT...
5,817,637,801,054,475,000
val_step() API for module wrapped by DistributedDataParallel. This method is basically the same as ``DistributedDataParallel.forward()``, while replacing ``self.module.forward()`` with ``self.module.val_step()``. It is compatible with PyTorch 1.1 - 1.5.
mmcv/parallel/distributed.py
val_step
BIGWangYuDong/mmcv
python
def val_step(self, *inputs, **kwargs): 'val_step() API for module wrapped by DistributedDataParallel.\n\n This method is basically the same as\n ``DistributedDataParallel.forward()``, while replacing\n ``self.module.forward()`` with ``self.module.val_step()``.\n It is compatible with PyT...
def del_none(d): '\n Delete dict keys with None values, and empty lists, recursively.\n ' for (key, value) in d.items(): if ((value is None) or (isinstance(value, list) and (len(value) == 0))): del d[key] elif isinstance(value, dict): del_none(value) return d
8,142,591,104,627,484,000
Delete dict keys with None values, and empty lists, recursively.
models.py
del_none
cwilso/chromium-dashboard
python
def del_none(d): '\n \n ' for (key, value) in d.items(): if ((value is None) or (isinstance(value, list) and (len(value) == 0))): del d[key] elif isinstance(value, dict): del_none(value) return d
def list_to_chunks(l, n): 'Yield successive n-sized chunk lists from l.' for i in xrange(0, len(l), n): (yield l[i:(i + n)])
-1,047,640,047,794,921,100
Yield successive n-sized chunk lists from l.
models.py
list_to_chunks
cwilso/chromium-dashboard
python
def list_to_chunks(l, n): for i in xrange(0, len(l), n): (yield l[i:(i + n)])
@classmethod def fetch_all_components(self, update_cache=False): 'Returns the list of blink components from live endpoint if unavailable in the cache.' key = ('%s|blinkcomponents' % settings.MEMCACHE_KEY_PREFIX) components = memcache.get(key) if ((components is None) or update_cache): components...
2,615,132,007,290,353,000
Returns the list of blink components from live endpoint if unavailable in the cache.
models.py
fetch_all_components
cwilso/chromium-dashboard
python
@classmethod def fetch_all_components(self, update_cache=False): key = ('%s|blinkcomponents' % settings.MEMCACHE_KEY_PREFIX) components = memcache.get(key) if ((components is None) or update_cache): components = [] result = urlfetch.fetch(self.COMPONENTS_ENDPOINT, deadline=60) i...
@classmethod def fetch_wf_content_for_components(self, update_cache=False): 'Returns the /web content that use each blink component.' key = ('%s|wfcomponents' % settings.MEMCACHE_KEY_PREFIX) components = memcache.get(key) if ((components is None) or update_cache): components = {} result ...
3,755,372,784,358,231,600
Returns the /web content that use each blink component.
models.py
fetch_wf_content_for_components
cwilso/chromium-dashboard
python
@classmethod def fetch_wf_content_for_components(self, update_cache=False): key = ('%s|wfcomponents' % settings.MEMCACHE_KEY_PREFIX) components = memcache.get(key) if ((components is None) or update_cache): components = {} result = urlfetch.fetch(self.WF_CONTENT_ENDPOINT, deadline=60) ...
@classmethod def update_db(self): 'Updates the db with new Blink components from the json endpoint' self.fetch_wf_content_for_components(update_cache=True) new_components = self.fetch_all_components(update_cache=True) existing_comps = self.all().fetch(None) for name in new_components: if (no...
1,520,643,486,992,808,700
Updates the db with new Blink components from the json endpoint
models.py
update_db
cwilso/chromium-dashboard
python
@classmethod def update_db(self): self.fetch_wf_content_for_components(update_cache=True) new_components = self.fetch_all_components(update_cache=True) existing_comps = self.all().fetch(None) for name in new_components: if (not len([x.name for x in existing_comps if (x.name == name)])): ...
@classmethod def get_by_name(self, component_name): 'Fetch blink component with given name.' q = self.all() q.filter('name =', component_name) component = q.fetch(1) if (not component): logging.error(('%s is an unknown BlinkComponent.' % component_name)) return None return compon...
1,578,639,703,039,212,000
Fetch blink component with given name.
models.py
get_by_name
cwilso/chromium-dashboard
python
@classmethod def get_by_name(self, component_name): q = self.all() q.filter('name =', component_name) component = q.fetch(1) if (not component): logging.error(('%s is an unknown BlinkComponent.' % component_name)) return None return component[0]
def __notify_feature_subscribers_of_changes(self, is_update): 'Async notifies subscribers of new features and property changes to features by\n posting to a task queue.' changed_props = [] for (prop_name, prop) in self.properties().iteritems(): new_val = getattr(self, prop_name, None) ...
1,186,048,520,462,652,700
Async notifies subscribers of new features and property changes to features by posting to a task queue.
models.py
__notify_feature_subscribers_of_changes
cwilso/chromium-dashboard
python
def __notify_feature_subscribers_of_changes(self, is_update): 'Async notifies subscribers of new features and property changes to features by\n posting to a task queue.' changed_props = [] for (prop_name, prop) in self.properties().iteritems(): new_val = getattr(self, prop_name, None) ...
def add_to_component_subscribers(self, component_name): 'Adds the user to the list of Blink component subscribers.' c = BlinkComponent.get_by_name(component_name) if c: if (not len(list_with_component(self.blink_components, c))): self.blink_components.append(c.key()) return s...
377,905,915,556,286,800
Adds the user to the list of Blink component subscribers.
models.py
add_to_component_subscribers
cwilso/chromium-dashboard
python
def add_to_component_subscribers(self, component_name): c = BlinkComponent.get_by_name(component_name) if c: if (not len(list_with_component(self.blink_components, c))): self.blink_components.append(c.key()) return self.put() return None
def remove_from_component_subscribers(self, component_name, remove_as_owner=False): 'Removes the user from the list of Blink component subscribers or as the owner\n of the component.' c = BlinkComponent.get_by_name(component_name) if c: if remove_as_owner: self.primary_blink_compon...
-6,766,741,114,973,741,000
Removes the user from the list of Blink component subscribers or as the owner of the component.
models.py
remove_from_component_subscribers
cwilso/chromium-dashboard
python
def remove_from_component_subscribers(self, component_name, remove_as_owner=False): 'Removes the user from the list of Blink component subscribers or as the owner\n of the component.' c = BlinkComponent.get_by_name(component_name) if c: if remove_as_owner: self.primary_blink_compon...
def add_as_component_owner(self, component_name): 'Adds the user as the Blink component owner.' c = BlinkComponent.get_by_name(component_name) if c: self.add_to_component_subscribers(component_name) if (not len(list_with_component(self.primary_blink_components, c))): self.primary...
8,702,347,263,936,550,000
Adds the user as the Blink component owner.
models.py
add_as_component_owner
cwilso/chromium-dashboard
python
def add_as_component_owner(self, component_name): c = BlinkComponent.get_by_name(component_name) if c: self.add_to_component_subscribers(component_name) if (not len(list_with_component(self.primary_blink_components, c))): self.primary_blink_components.append(c.key()) ret...
def get_current_time(format_str: str='%Y-%m-%d %H:%M:%S'): '\n 获取当前时间,默认为 2020-01-01 00:00:00 格式\n :param format_str: 格式\n :return:\n ' return time.strftime(format_str, time.localtime())
2,675,374,514,212,199,400
获取当前时间,默认为 2020-01-01 00:00:00 格式 :param format_str: 格式 :return:
src/sogou_wechat/mongoDB.py
get_current_time
matiastang/selenium-learning
python
def get_current_time(format_str: str='%Y-%m-%d %H:%M:%S'): '\n 获取当前时间,默认为 2020-01-01 00:00:00 格式\n :param format_str: 格式\n :return:\n ' return time.strftime(format_str, time.localtime())
def __init__(self): '初始化\n 初始化 mongo db\n ' mongo_uri = ('mongodb://%s:%s@%s:%s' % (MONGO_CONFIG['user'], MONGO_CONFIG['pwd'], MONGO_CONFIG['host'], MONGO_CONFIG['port'])) self.mongo = MongoClient(mongo_uri) self.sogou_db = self.mongo['sogou_dev'] self.sogou_search_col = self.sogou_db[...
-2,319,926,698,126,357,000
初始化 初始化 mongo db
src/sogou_wechat/mongoDB.py
__init__
matiastang/selenium-learning
python
def __init__(self): '初始化\n 初始化 mongo db\n ' mongo_uri = ('mongodb://%s:%s@%s:%s' % (MONGO_CONFIG['user'], MONGO_CONFIG['pwd'], MONGO_CONFIG['host'], MONGO_CONFIG['port'])) self.mongo = MongoClient(mongo_uri) self.sogou_db = self.mongo['sogou_dev'] self.sogou_search_col = self.sogou_db[...
def update_sogou_login_cookie(self, username, cookie): '\n 更新搜狗微信登录 cookie 信息\n :param username:\n :param cookie:\n :return:\n ' col = self.sogou_db['sogou_login_cookies'] ctime = get_current_time() find_obj = {'nickname': username, 'is_valid': 1} login_item = col....
1,485,805,371,386,330,600
更新搜狗微信登录 cookie 信息 :param username: :param cookie: :return:
src/sogou_wechat/mongoDB.py
update_sogou_login_cookie
matiastang/selenium-learning
python
def update_sogou_login_cookie(self, username, cookie): '\n 更新搜狗微信登录 cookie 信息\n :param username:\n :param cookie:\n :return:\n ' col = self.sogou_db['sogou_login_cookies'] ctime = get_current_time() find_obj = {'nickname': username, 'is_valid': 1} login_item = col....
def insert_sogou_search_result(self, result): '\n 保存搜狗搜索信息\n :param results: 结果数组\n ' ctime = get_current_time() find_obj = {'id': result['id'], 'is_valid': 1} search_item = self.sogou_search_col.find_one(find_obj) print(search_item) new_result = result if (not search_it...
-2,791,544,919,105,490,000
保存搜狗搜索信息 :param results: 结果数组
src/sogou_wechat/mongoDB.py
insert_sogou_search_result
matiastang/selenium-learning
python
def insert_sogou_search_result(self, result): '\n 保存搜狗搜索信息\n :param results: 结果数组\n ' ctime = get_current_time() find_obj = {'id': result['id'], 'is_valid': 1} search_item = self.sogou_search_col.find_one(find_obj) print(search_item) new_result = result if (not search_it...
@utils.classproperty def resource_server(cls) -> Optional[str]: '\n The resource_server name for the API and scopes associated with this client.\n\n This information is pulled from the ``scopes`` attribute of the client class.\n If the client does not have associated scopes, this value will be ...
-8,940,739,177,058,369,000
The resource_server name for the API and scopes associated with this client. This information is pulled from the ``scopes`` attribute of the client class. If the client does not have associated scopes, this value will be ``None``.
src/globus_sdk/client.py
resource_server
rudyardrichter/globus-sdk-python
python
@utils.classproperty def resource_server(cls) -> Optional[str]: '\n The resource_server name for the API and scopes associated with this client.\n\n This information is pulled from the ``scopes`` attribute of the client class.\n If the client does not have associated scopes, this value will be ...
def get(self, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, headers: Optional[Dict[(str, str)]]=None) -> GlobusHTTPResponse: '\n Make a GET request to the specified path.\n\n See :py:meth:`~.BaseClient.request` for details on the various parameters.\n\n :return: :class:`GlobusHTT...
-8,680,274,190,658,656,000
Make a GET request to the specified path. See :py:meth:`~.BaseClient.request` for details on the various parameters. :return: :class:`GlobusHTTPResponse <globus_sdk.response.GlobusHTTPResponse>` object
src/globus_sdk/client.py
get
rudyardrichter/globus-sdk-python
python
def get(self, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, headers: Optional[Dict[(str, str)]]=None) -> GlobusHTTPResponse: '\n Make a GET request to the specified path.\n\n See :py:meth:`~.BaseClient.request` for details on the various parameters.\n\n :return: :class:`GlobusHTT...
def post(self, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, data: Union[(None, Dict[(str, Any)], utils.PayloadWrapper)]=None, headers: Optional[Dict[(str, str)]]=None, encoding: Optional[str]=None) -> GlobusHTTPResponse: '\n Make a POST request to the specified path.\n\n See :py:meth:`...
-6,405,945,534,864,613,000
Make a POST request to the specified path. See :py:meth:`~.BaseClient.request` for details on the various parameters. :return: :class:`GlobusHTTPResponse <globus_sdk.response.GlobusHTTPResponse>` object
src/globus_sdk/client.py
post
rudyardrichter/globus-sdk-python
python
def post(self, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, data: Union[(None, Dict[(str, Any)], utils.PayloadWrapper)]=None, headers: Optional[Dict[(str, str)]]=None, encoding: Optional[str]=None) -> GlobusHTTPResponse: '\n Make a POST request to the specified path.\n\n See :py:meth:`...
def delete(self, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, headers: Optional[Dict[(str, str)]]=None) -> GlobusHTTPResponse: '\n Make a DELETE request to the specified path.\n\n See :py:meth:`~.BaseClient.request` for details on the various parameters.\n\n :return: :class:`Glo...
8,448,269,623,345,632,000
Make a DELETE request to the specified path. See :py:meth:`~.BaseClient.request` for details on the various parameters. :return: :class:`GlobusHTTPResponse <globus_sdk.response.GlobusHTTPResponse>` object
src/globus_sdk/client.py
delete
rudyardrichter/globus-sdk-python
python
def delete(self, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, headers: Optional[Dict[(str, str)]]=None) -> GlobusHTTPResponse: '\n Make a DELETE request to the specified path.\n\n See :py:meth:`~.BaseClient.request` for details on the various parameters.\n\n :return: :class:`Glo...
def put(self, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, data: Union[(None, Dict[(str, Any)], utils.PayloadWrapper)]=None, headers: Optional[Dict[(str, str)]]=None, encoding: Optional[str]=None) -> GlobusHTTPResponse: '\n Make a PUT request to the specified path.\n\n See :py:meth:`~....
-4,209,089,649,074,972,000
Make a PUT request to the specified path. See :py:meth:`~.BaseClient.request` for details on the various parameters. :return: :class:`GlobusHTTPResponse <globus_sdk.response.GlobusHTTPResponse>` object
src/globus_sdk/client.py
put
rudyardrichter/globus-sdk-python
python
def put(self, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, data: Union[(None, Dict[(str, Any)], utils.PayloadWrapper)]=None, headers: Optional[Dict[(str, str)]]=None, encoding: Optional[str]=None) -> GlobusHTTPResponse: '\n Make a PUT request to the specified path.\n\n See :py:meth:`~....
def patch(self, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, data: Union[(None, Dict[(str, Any)], utils.PayloadWrapper)]=None, headers: Optional[Dict[(str, str)]]=None, encoding: Optional[str]=None) -> GlobusHTTPResponse: '\n Make a PATCH request to the specified path.\n\n See :py:meth...
-6,768,478,994,757,211,000
Make a PATCH request to the specified path. See :py:meth:`~.BaseClient.request` for details on the various parameters. :return: :class:`GlobusHTTPResponse <globus_sdk.response.GlobusHTTPResponse>` object
src/globus_sdk/client.py
patch
rudyardrichter/globus-sdk-python
python
def patch(self, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, data: Union[(None, Dict[(str, Any)], utils.PayloadWrapper)]=None, headers: Optional[Dict[(str, str)]]=None, encoding: Optional[str]=None) -> GlobusHTTPResponse: '\n Make a PATCH request to the specified path.\n\n See :py:meth...
def request(self, method: str, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, data: Union[(None, Dict[(str, Any)], utils.PayloadWrapper)]=None, headers: Optional[Dict[(str, str)]]=None, encoding: Optional[str]=None) -> GlobusHTTPResponse: '\n Send an HTTP request\n\n :param method: HTTP ...
-8,669,220,260,102,745,000
Send an HTTP request :param method: HTTP request method, as an all caps string :type method: str :param path: Path for the request, with or without leading slash :type path: str :param query_params: Parameters to be encoded as a query string :type query_params: dict, optional :param headers: HTTP headers to add to the...
src/globus_sdk/client.py
request
rudyardrichter/globus-sdk-python
python
def request(self, method: str, path: str, *, query_params: Optional[Dict[(str, Any)]]=None, data: Union[(None, Dict[(str, Any)], utils.PayloadWrapper)]=None, headers: Optional[Dict[(str, str)]]=None, encoding: Optional[str]=None) -> GlobusHTTPResponse: '\n Send an HTTP request\n\n :param method: HTTP ...
@property def name(self): 'Base name.' return self._name
6,807,634,801,631,736,000
Base name.
robustnessgym/core/identifier.py
name
ANarayan/robustness-gym
python
@property def name(self): return self._name
@property def index(self): 'Index associated with the identifier.' return self._index
1,556,588,699,845,362,400
Index associated with the identifier.
robustnessgym/core/identifier.py
index
ANarayan/robustness-gym
python
@property def index(self): return self._index
@property def parameters(self): 'Additional parameters contained in the identifier.' return self._parameters
7,311,550,149,156,835,000
Additional parameters contained in the identifier.
robustnessgym/core/identifier.py
parameters
ANarayan/robustness-gym
python
@property def parameters(self): return self._parameters
@classmethod def range(cls, n: int, _name: str, **kwargs) -> List[Identifier]: 'Create a list of identifiers, with index varying from 1 to `n`.' if (n > 1): return [cls(_name=_name, _index=i, **kwargs) for i in range(1, (n + 1))] return [cls(_name=_name, **kwargs)]
319,522,355,280,191,170
Create a list of identifiers, with index varying from 1 to `n`.
robustnessgym/core/identifier.py
range
ANarayan/robustness-gym
python
@classmethod def range(cls, n: int, _name: str, **kwargs) -> List[Identifier]: if (n > 1): return [cls(_name=_name, _index=i, **kwargs) for i in range(1, (n + 1))] return [cls(_name=_name, **kwargs)]
def __call__(self, **kwargs): 'Call the identifier with additional parameters to return a new\n identifier.' ident = Identifier.loads(self.dumps()) for (parameter, value) in kwargs.items(): ident.add_parameter(parameter, value) return ident
-3,241,385,535,052,178,400
Call the identifier with additional parameters to return a new identifier.
robustnessgym/core/identifier.py
__call__
ANarayan/robustness-gym
python
def __call__(self, **kwargs): 'Call the identifier with additional parameters to return a new\n identifier.' ident = Identifier.loads(self.dumps()) for (parameter, value) in kwargs.items(): ident.add_parameter(parameter, value) return ident
def dumps(self): 'Dump the identifier to JSON.' return json.dumps(self.__dict__)
9,035,629,313,671,611,000
Dump the identifier to JSON.
robustnessgym/core/identifier.py
dumps
ANarayan/robustness-gym
python
def dumps(self): return json.dumps(self.__dict__)
@staticmethod def _parse_args(s: str): 'https://stackoverflow.com/questions/49723047/parsing-a-string-as-a-\n python-argument-list.' args = 'f({})'.format(s) tree = ast.parse(args) funccall = tree.body[0].value params = {} for arg in funccall.keywords: try: params[arg....
-3,864,303,452,000,702,500
https://stackoverflow.com/questions/49723047/parsing-a-string-as-a- python-argument-list.
robustnessgym/core/identifier.py
_parse_args
ANarayan/robustness-gym
python
@staticmethod def _parse_args(s: str): 'https://stackoverflow.com/questions/49723047/parsing-a-string-as-a-\n python-argument-list.' args = 'f({})'.format(s) tree = ast.parse(args) funccall = tree.body[0].value params = {} for arg in funccall.keywords: try: params[arg....
@classmethod def parse(cls, s: str) -> Identifier: 'Parse in an identifier from string.' if ('(' in s): (name_index, params) = s.split('(') params = params.split(')')[0] else: name_index = s params = None if ('-' in name_index): (name, index) = (name_index.split('...
-3,336,107,861,688,347,000
Parse in an identifier from string.
robustnessgym/core/identifier.py
parse
ANarayan/robustness-gym
python
@classmethod def parse(cls, s: str) -> Identifier: if ('(' in s): (name_index, params) = s.split('(') params = params.split(')')[0] else: name_index = s params = None if ('-' in name_index): (name, index) = (name_index.split('-')[:(- 1)], name_index.split('-')[(-...
def without(self, *params) -> Identifier: 'Returns an identifier without `params`.' return Identifier(self.name, self.index, **{k: v for (k, v) in self.parameters.items() if (k not in set(params))})
-7,226,501,445,548,212,000
Returns an identifier without `params`.
robustnessgym/core/identifier.py
without
ANarayan/robustness-gym
python
def without(self, *params) -> Identifier: return Identifier(self.name, self.index, **{k: v for (k, v) in self.parameters.items() if (k not in set(params))})
@classmethod def loads(cls, s: str): 'Load the identifier from JSON.' identifier = Identifier(_name='') identifier.__dict__ = json.loads(s) return identifier
1,539,369,053,633,276,000
Load the identifier from JSON.
robustnessgym/core/identifier.py
loads
ANarayan/robustness-gym
python
@classmethod def loads(cls, s: str): identifier = Identifier(_name=) identifier.__dict__ = json.loads(s) return identifier
def add_parameter(self, parameter: str, value: Any) -> None: 'Add a parameter to the identifier.' if isinstance(value, Callable): self.parameters[parameter] = '.'.join([str(value.__module__), str(value.__name__)]) else: self.parameters[parameter] = value
7,490,064,917,028,692,000
Add a parameter to the identifier.
robustnessgym/core/identifier.py
add_parameter
ANarayan/robustness-gym
python
def add_parameter(self, parameter: str, value: Any) -> None: if isinstance(value, Callable): self.parameters[parameter] = '.'.join([str(value.__module__), str(value.__name__)]) else: self.parameters[parameter] = value
def get_sinusoid_encoding_table(n_position, d_hid, padding_idx=None): ' Sinusoid position encoding table ' def cal_angle(position, hid_idx): return (position / np.power(10000, ((2 * (hid_idx // 2)) / d_hid))) def get_posi_angle_vec(position): return [cal_angle(position, hid_j) for hid_j in...
6,906,142,374,917,182,000
Sinusoid position encoding table
src/onqg/utils/sinusoid.py
get_sinusoid_encoding_table
MrSchnappi/RL-for-Question-Generation
python
def get_sinusoid_encoding_table(n_position, d_hid, padding_idx=None): ' ' def cal_angle(position, hid_idx): return (position / np.power(10000, ((2 * (hid_idx // 2)) / d_hid))) def get_posi_angle_vec(position): return [cal_angle(position, hid_j) for hid_j in range(d_hid)] sinusoid_tabl...
def learning_rate_schedule(current_epoch, current_batch, steps_per_epoch, batch_size): 'Handles linear scaling rule, gradual warmup, and LR decay.\n\n Scale learning rate at epoch boundaries provided in LR_SCHEDULE by the\n provided scaling factor.\n\n Args:\n current_epoch: integer, current epoch indexed fro...
4,805,554,109,677,772,000
Handles linear scaling rule, gradual warmup, and LR decay. Scale learning rate at epoch boundaries provided in LR_SCHEDULE by the provided scaling factor. Args: current_epoch: integer, current epoch indexed from 0. current_batch: integer, current batch in the current epoch, indexed from 0. steps_per_epoch: inte...
official/vision/image_classification/common.py
learning_rate_schedule
Anku5hk/models
python
def learning_rate_schedule(current_epoch, current_batch, steps_per_epoch, batch_size): 'Handles linear scaling rule, gradual warmup, and LR decay.\n\n Scale learning rate at epoch boundaries provided in LR_SCHEDULE by the\n provided scaling factor.\n\n Args:\n current_epoch: integer, current epoch indexed fro...
def get_optimizer(learning_rate=0.1): 'Returns optimizer to use.' return gradient_descent_v2.SGD(learning_rate=learning_rate, momentum=0.9)
7,685,441,610,714,783,000
Returns optimizer to use.
official/vision/image_classification/common.py
get_optimizer
Anku5hk/models
python
def get_optimizer(learning_rate=0.1): return gradient_descent_v2.SGD(learning_rate=learning_rate, momentum=0.9)
def get_callbacks(steps_per_epoch, learning_rate_schedule_fn=None, pruning_method=None, enable_checkpoint_and_export=False, model_dir=None): 'Returns common callbacks.' time_callback = keras_utils.TimeHistory(FLAGS.batch_size, FLAGS.log_steps) callbacks = [time_callback] if ((not FLAGS.use_tensor_lr) an...
7,434,335,091,102,080,000
Returns common callbacks.
official/vision/image_classification/common.py
get_callbacks
Anku5hk/models
python
def get_callbacks(steps_per_epoch, learning_rate_schedule_fn=None, pruning_method=None, enable_checkpoint_and_export=False, model_dir=None): time_callback = keras_utils.TimeHistory(FLAGS.batch_size, FLAGS.log_steps) callbacks = [time_callback] if ((not FLAGS.use_tensor_lr) and learning_rate_schedule_fn...
def build_stats(history, eval_output, callbacks): 'Normalizes and returns dictionary of stats.\n\n Args:\n history: Results of the training step. Supports both categorical_accuracy\n and sparse_categorical_accuracy.\n eval_output: Output of the eval step. Assumes first value is eval_loss and\n seco...
1,328,152,771,311,647,200
Normalizes and returns dictionary of stats. Args: history: Results of the training step. Supports both categorical_accuracy and sparse_categorical_accuracy. eval_output: Output of the eval step. Assumes first value is eval_loss and second value is accuracy_top_1. callbacks: a list of callbacks which migh...
official/vision/image_classification/common.py
build_stats
Anku5hk/models
python
def build_stats(history, eval_output, callbacks): 'Normalizes and returns dictionary of stats.\n\n Args:\n history: Results of the training step. Supports both categorical_accuracy\n and sparse_categorical_accuracy.\n eval_output: Output of the eval step. Assumes first value is eval_loss and\n seco...
def define_keras_flags(dynamic_loss_scale=True, model=False, optimizer=False, pretrained_filepath=False): 'Define flags for Keras models.' flags_core.define_base(clean=True, num_gpu=True, run_eagerly=True, train_epochs=True, epochs_between_evals=True, distribution_strategy=True) flags_core.define_performanc...
2,800,760,739,962,504,700
Define flags for Keras models.
official/vision/image_classification/common.py
define_keras_flags
Anku5hk/models
python
def define_keras_flags(dynamic_loss_scale=True, model=False, optimizer=False, pretrained_filepath=False): flags_core.define_base(clean=True, num_gpu=True, run_eagerly=True, train_epochs=True, epochs_between_evals=True, distribution_strategy=True) flags_core.define_performance(num_parallel_calls=False, synt...
def get_synth_data(height, width, num_channels, num_classes, dtype): 'Creates a set of synthetic random data.\n\n Args:\n height: Integer height that will be used to create a fake image tensor.\n width: Integer width that will be used to create a fake image tensor.\n num_channels: Integer depth that will ...
4,141,754,423,883,289,000
Creates a set of synthetic random data. Args: height: Integer height that will be used to create a fake image tensor. width: Integer width that will be used to create a fake image tensor. num_channels: Integer depth that will be used to create a fake image tensor. num_classes: Number of classes that should be ...
official/vision/image_classification/common.py
get_synth_data
Anku5hk/models
python
def get_synth_data(height, width, num_channels, num_classes, dtype): 'Creates a set of synthetic random data.\n\n Args:\n height: Integer height that will be used to create a fake image tensor.\n width: Integer width that will be used to create a fake image tensor.\n num_channels: Integer depth that will ...
def define_pruning_flags(): 'Define flags for pruning methods.' flags.DEFINE_string('pruning_method', None, 'Pruning method.None (no pruning) or polynomial_decay.') flags.DEFINE_float('pruning_initial_sparsity', 0.0, 'Initial sparsity for pruning.') flags.DEFINE_float('pruning_final_sparsity', 0.5, 'Fin...
-3,593,318,337,141,748,000
Define flags for pruning methods.
official/vision/image_classification/common.py
define_pruning_flags
Anku5hk/models
python
def define_pruning_flags(): flags.DEFINE_string('pruning_method', None, 'Pruning method.None (no pruning) or polynomial_decay.') flags.DEFINE_float('pruning_initial_sparsity', 0.0, 'Initial sparsity for pruning.') flags.DEFINE_float('pruning_final_sparsity', 0.5, 'Final sparsity for pruning.') flag...
def get_synth_input_fn(height, width, num_channels, num_classes, dtype=tf.float32, drop_remainder=True): 'Returns an input function that returns a dataset with random data.\n\n This input_fn returns a data set that iterates over a set of random data and\n bypasses all preprocessing, e.g. jpeg decode and copy. The...
8,003,751,533,849,318,000
Returns an input function that returns a dataset with random data. This input_fn returns a data set that iterates over a set of random data and bypasses all preprocessing, e.g. jpeg decode and copy. The host to device copy is still included. This used to find the upper throughput bound when tuning the full input pipel...
official/vision/image_classification/common.py
get_synth_input_fn
Anku5hk/models
python
def get_synth_input_fn(height, width, num_channels, num_classes, dtype=tf.float32, drop_remainder=True): 'Returns an input function that returns a dataset with random data.\n\n This input_fn returns a data set that iterates over a set of random data and\n bypasses all preprocessing, e.g. jpeg decode and copy. The...
def set_cudnn_batchnorm_mode(): 'Set CuDNN batchnorm mode for better performance.\n\n Note: Spatial Persistent mode may lead to accuracy losses for certain\n models.\n ' if FLAGS.batchnorm_spatial_persistent: os.environ['TF_USE_CUDNN_BATCHNORM_SPATIAL_PERSISTENT'] = '1' else: os.env...
-4,307,923,414,367,476,000
Set CuDNN batchnorm mode for better performance. Note: Spatial Persistent mode may lead to accuracy losses for certain models.
official/vision/image_classification/common.py
set_cudnn_batchnorm_mode
Anku5hk/models
python
def set_cudnn_batchnorm_mode(): 'Set CuDNN batchnorm mode for better performance.\n\n Note: Spatial Persistent mode may lead to accuracy losses for certain\n models.\n ' if FLAGS.batchnorm_spatial_persistent: os.environ['TF_USE_CUDNN_BATCHNORM_SPATIAL_PERSISTENT'] = '1' else: os.env...
def on_batch_begin(self, batch, logs=None): 'Executes before step begins.' lr = self.schedule(self.epochs, batch, self.steps_per_epoch, self.batch_size) if (not isinstance(lr, (float, np.float32, np.float64))): raise ValueError('The output of the "schedule" function should be float.') if (lr != ...
7,123,145,724,043,767,000
Executes before step begins.
official/vision/image_classification/common.py
on_batch_begin
Anku5hk/models
python
def on_batch_begin(self, batch, logs=None): lr = self.schedule(self.epochs, batch, self.steps_per_epoch, self.batch_size) if (not isinstance(lr, (float, np.float32, np.float64))): raise ValueError('The output of the "schedule" function should be float.') if (lr != self.prev_lr): self.mo...
def _get_learning_rate(self, step): 'Compute learning rate at given step.' with tf.compat.v1.name_scope(self.name, 'PiecewiseConstantDecayWithWarmup', [self.rescaled_lr, self.step_boundaries, self.lr_values, self.warmup_steps, self.compute_lr_on_cpu]): def warmup_lr(step): return (self.resc...
-9,149,486,914,277,548,000
Compute learning rate at given step.
official/vision/image_classification/common.py
_get_learning_rate
Anku5hk/models
python
def _get_learning_rate(self, step): with tf.compat.v1.name_scope(self.name, 'PiecewiseConstantDecayWithWarmup', [self.rescaled_lr, self.step_boundaries, self.lr_values, self.warmup_steps, self.compute_lr_on_cpu]): def warmup_lr(step): return (self.rescaled_lr * (tf.cast(step, tf.float32) /...
def input_fn(is_training, data_dir, batch_size, *args, **kwargs): 'Returns dataset filled with random data.' (inputs, labels) = get_synth_data(height=height, width=width, num_channels=num_channels, num_classes=num_classes, dtype=dtype) labels = tf.cast(labels, dtype=tf.float32) data = tf.data.Dataset.fr...
533,578,729,328,800,500
Returns dataset filled with random data.
official/vision/image_classification/common.py
input_fn
Anku5hk/models
python
def input_fn(is_training, data_dir, batch_size, *args, **kwargs): (inputs, labels) = get_synth_data(height=height, width=width, num_channels=num_channels, num_classes=num_classes, dtype=dtype) labels = tf.cast(labels, dtype=tf.float32) data = tf.data.Dataset.from_tensors((inputs, labels)).repeat() ...
def default_keygen(self, *args, **kwargs) -> Tuple[(Hashable, ...)]: 'Returns all params (args, kwargs, and missing default kwargs) for function as kwargs.' return tuple(self.get_args_as_kwargs(*args, **kwargs).values())
-423,157,303,730,307,500
Returns all params (args, kwargs, and missing default kwargs) for function as kwargs.
atools/_memoize_decorator.py
default_keygen
cevans87/atools
python
def default_keygen(self, *args, **kwargs) -> Tuple[(Hashable, ...)]: return tuple(self.get_args_as_kwargs(*args, **kwargs).values())
def __init__(self, keylist, header=None): '\n Initializes the ConfigList object by tranfsforming\n a list of keywords into a structured list including\n beams descriptions\n\n keylist: list\n List of configuration keys\n header: str\n the header string\n ...
6,519,035,064,426,874,000
Initializes the ConfigList object by tranfsforming a list of keywords into a structured list including beams descriptions keylist: list List of configuration keys header: str the header string
pyaxe/axesrc/configfile.py
__init__
sosey/pyaxe
python
def __init__(self, keylist, header=None): '\n Initializes the ConfigList object by tranfsforming\n a list of keywords into a structured list including\n beams descriptions\n\n keylist: list\n List of configuration keys\n header: str\n the header string\n ...