name stringlengths 1 152 | class_name stringlengths 1 51 | class_bases stringlengths 0 159 ⌀ | is_member bool 2
classes | args stringlengths 0 804 | class_docstr stringlengths 4 8.19k ⌀ | class_docstr_tok stringlengths 2 11.6k ⌀ | docstr stringlengths 0 11.4k ⌀ | docstr_tok stringlengths 2 13.4k ⌀ | returns stringlengths 0 260 ⌀ | code stringlengths 21 52.4k ⌀ | code_tok stringlengths 33 92.8k ⌀ | lstart int64 1 1.75k | lend int64 5 1.75k | raises stringclasses 16
values | filename stringlengths 5 66 | file_path stringlengths 12 161 | imports stringlengths 0 1.77k | total_objects int64 15 15 | num_classes float64 1 7 ⌀ | num_imports int64 0 14 | num_functions int64 0 15 | num_all_bases float64 0 9 ⌀ | num_methods float64 1 14 ⌀ | num_bases float64 1 7 ⌀ | label_desc stringlengths 69 1.05k | label_desc_len int64 69 1.05k | label_id stringclasses 15
values | __index_level_0__ int64 468 2.35M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
_fit_sklearn_model_with_active_run | global | null | false | pandas_df | null | null | null | null | mlflow | def _fit_sklearn_model_with_active_run(pandas_df):
run_id = mlflow.active_run().info.run_id
_fit_sklearn(pandas_df)
return mlflow.get_run(run_id)
| ["def","_fit_sklearn_model_with_active_run","(","pandas_df",")",":","run_id","=","mlflow.active_run","(",")",".info.run_id","_fit_sklearn","(","pandas_df",")","return","mlflow.get_run","(","run_id",")"] | 32 | 35 | null | test_spark_datasource_autologging_crossframework.py | mlflow/tests/spark/autologging/datasource/test_spark_datasource_autologging_crossframework.py | import time
import numpy
import pytest
from sklearn.linear_model import LinearRegression
import mlflow
import mlflow.spark
from tests.spark.autologging.utils import _assert_spark_data_logged | 15 | null | 7 | 8 | null | null | null | Use image node_id 3 for calling a global function with example usage: _fit_sklearn_model_with_active_run(pandas_df) and returns: mlflow | 135 | node_id 3 | 1,357,874 |
test_super | TestGaussianNoise | unittest | true | self | A unittest class for testing the GaussianNoise postprocessor. | ["A","unittest","class","for","testing","the","GaussianNoise","postprocessor","."] | null | null | null | def test_super(self):
gan = GaussianNoise(scale=0.1)
self.assertTrue(gan.is_fitted)
self.assertFalse(gan._apply_fit)
self.assertTrue(gan._apply_predict)
gan.fit(preds=np.array([0.1, 0.2, 0.3]))
| ["def","test_super","(","self",")",":","gan","=","GaussianNoise","(","scale=0.1",")","self.assertTrue","(","gan.is_fitted",")","self.assertFalse","(","gan._apply_fit",")","self.assertTrue","(","gan._apply_predict",")","gan.fit","(","preds=np.array","(","[","0.1",",","0.2",",","0.3","]",")",")"] | 104 | 109 | null | test_gaussian_noise.py | adversarial-robustness-toolbox/tests/defences/test_gaussian_noise.py | import logging
import unittest
import numpy
from art.defences.postprocessor import GaussianNoise
from art.utils import load_dataset
from tests.utils import master_seed, get_image_classifier_kr_tf, get_image_classifier_kr_tf_binary | 15 | 1 | 6 | 0 | 1 | 7 | 1 | Use image node_id 7 for calling the TestGaussianNoise obj's underlying member method code with example usage: obj.test_super() without return types | 147 | node_id 7 | 235,295 |
setUpClass | TestHighConfidence | unittest | true | cls | A unittest class for testing the HighConfidence postprocessor. | ["A","unittest","class","for","testing","the","HighConfidence","postprocessor","."] | null | null | null | def setUpClass(cls):
(x_train, y_train), (x_test, y_test), _, _ = load_dataset("mnist")
cls.mnist = (x_train, y_train), (x_test, y_test)
| ["def","setUpClass","(","cls",")",":","(","x_train",",","y_train",")",",","(","x_test",",","y_test",")",",","_",",","_","=","load_dataset","(","``","mnist","''",")","cls.mnist","=","(","x_train",",","y_train",")",",","(","x_test",",","y_test",")"] | 37 | 39 | null | test_high_confidence.py | adversarial-robustness-toolbox/tests/defences/test_high_confidence.py | import logging
import unittest
import numpy
from art.defences.postprocessor import HighConfidence
from art.utils import load_dataset
from tests.utils import master_seed, get_image_classifier_kr_tf, get_image_classifier_kr_tf_binary | 15 | 1 | 6 | 0 | 1 | 7 | 1 | Use image node_id 1 for calling the TestHighConfidence obj's underlying member method code with example usage: obj.setUpClass(cls) without return types | 151 | node_id 1 | 235,296 |
test_ThompsonSamplerInfeasible | ThompsonSamplerTest | TestCase | true | self | null | null | null | null | null | def test_ThompsonSamplerInfeasible(self) -> None:
generator = ThompsonSampler(min_weight=0.9)
generator.fit(
# pyre-fixme[6]: For 1st param expected `List[List[List[Union[None,
# bool, float, int, str]]]]` but got `List[List[List[int]]]`.
Xs=self.Xs,
# pyre-fixme[6]: For 2nd par... | ["def","test_ThompsonSamplerInfeasible","(","self",")","-",">","None",":","generator","=","ThompsonSampler","(","min_weight=0.9",")","generator.fit","(","#","pyre-fixme","[","6","]",":","For","1st","param","expected","`","List","[","List","[","List","[","Union","[","None",",","#","bool",",","float",",","int",",","str",... | 174 | 198 | null | test_thompson.py | Ax/ax/models/tests/test_thompson.py | import numpy
from ax.exceptions.model import ModelError
from ax.models.discrete.thompson import ThompsonSampler
from ax.utils.common.testutils import TestCase | 15 | 1 | 4 | 0 | 1 | 9 | 1 | Use image node_id 6 for calling the ThompsonSamplerTest obj's underlying member method code with example usage: obj.test_ThompsonSamplerInfeasible() without return types | 169 | node_id 6 | 9,540 |
_maybe_clause | global | null | false | clause | null | null | null | null | unknown | def _maybe_clause(clause: Optional[str]) -> Sequence[str]:
return [clause] if clause is not None else []
| ["def","_maybe_clause","(","clause",":","Optional","[","str","]",")","-",">","Sequence","[","str","]",":","return","[","clause","]","if","clause","is","not","None","else","[","]"] | 40 | 41 | null | store_ext.py | tfx/tfx/orchestration/portable/mlmd/store_ext.py | import collections
import itertools
from typing import Callable, Mapping, Optional, Sequence, Union
from tfx.dsl.compiler import compiler_utils
from tfx.dsl.compiler import constants
from tfx.orchestration.experimental.core import constants
from tfx.orchestration.portable.mlmd import event_lib
from tfx.orchestration.po... | 15 | null | 9 | 6 | null | null | null | Use image node_id 2 for calling a global function with example usage: _maybe_clause(clause) and returns: unknown | 112 | node_id 2 | 2,198,856 |
__init__ | EventSievesConfiguration | SievesConfiguration | true | self | null | null | null | null | EventSievesConfiguration | def __init__(self):
super(EventSievesConfiguration, self).__init__()
self.run_evaluation = True
self.sieves_order = [
(RelationType.SAME_HEAD_LEMMA, 1.0),
(RelationType.EXACT_STRING, 1.0),
(RelationType.WIKIPEDIA_DISAMBIGUATION, 0.1),
(RelationType.WORD_EMBEDDING_MATCH, 0.7... | ["def","__init__","(","self",")",":","super","(","EventSievesConfiguration",",","self",")",".__init__","(",")","self.run_evaluation","=","True","self.sieves_order","=","[","(","RelationType.SAME_HEAD_LEMMA",",","1.0",")",",","(","RelationType.EXACT_STRING",",","1.0",")",",","(","RelationType.WIKIPEDIA_DISAMBIGUATION","... | 59 | 78 | null | sieves_config.py | nlp-architect/nlp_architect/models/cross_doc_coref/sieves_config.py | from typing import List, Tuple
from nlp_architect.data.cdc_resources.relations.relation_types_enums import RelationType | 15 | 3 | 2 | 0 | 3 | 1 | 1 | Use image node_id 1 to create a new EventSievesConfiguration object from inherited base classes: SievesConfiguration with example: obj = EventSievesConfiguration() | 163 | node_id 1 | 1,443,098 |
simple_segmentation_example | global | null | false | null | null | null | null | null | def simple_segmentation_example():
"Perfect results!"
parameters = legion_parameters()
parameters.eps = 0.02
parameters.alpha = 0.005
parameters.betta = 0.1
parameters.gamma = 7.0
parameters.teta = 0.9
parameters.lamda = 0.1
parameters.teta_x = -0.5
parameters.teta_p = 7.0
pa... | ["def","simple_segmentation_example","(",")",":","``","Perfect","results","!","''","parameters","=","legion_parameters","(",")","parameters.eps","=","0.02","parameters.alpha","=","0.005","parameters.betta","=","0.1","parameters.gamma","=","7.0","parameters.teta","=","0.9","parameters.lamda","=","0.1","parameters.teta_x... | 94 | 126 | null | legion_examples.py | pyclustering/pyclustering/nnet/examples/legion_examples.py | from pyclustering.utils import draw_dynamics
from pyclustering.nnet.legion import legion_network, legion_parameters
from pyclustering.nnet import * | 15 | null | 3 | 12 | null | null | null | Use image node_id 12 for calling a global function with example usage: simple_segmentation_example() without return types | 121 | node_id 12 | 1,634,375 | |
forward | ConstantGate | torch.nn | true | self,inp | null | null | null | null | idx, score | def forward(self, inp):
idx = torch.zeros(
(inp.shape[0], self.top_k),
dtype=torch.int64,
device=inp.device,
)
score = (
torch.ones((inp.shape[0], 1, self.top_k), device=inp.device)
/ 2
)
return idx, score
| ["def","forward","(","self",",","inp",")",":","idx","=","torch.zeros","(","(","inp.shape","[","0","]",",","self.top_k",")",",","dtype=torch.int64",",","device=inp.device",",",")","score","=","(","torch.ones","(","(","inp.shape","[","0","]",",","1",",","self.top_k",")",",","device=inp.device",")","\/","2",")","return","... | 16 | 20 | null | test_zero.py | thu-pacman-faster-moe/tests/test_zero.py | import os
import sys
import json
import torch
from fmoe.layers import _fmoe_general_global_forward
from fmoe import FMoETransformerMLP
from test_ddp import _run_distributed | 15 | 1 | 7 | 4 | 1 | 2 | 1 | Use image node_id 2 for calling the ConstantGate obj's underlying member method code with example usage: obj.forward(inp) and returns: idx, score | 146 | node_id 2 | 2,201,994 |
__init__ | ConstantGate | torch.nn | true | self,d_model,num_expert,world_size,top_k | null | null | null | null | ConstantGate | def __init__(self, d_model, num_expert, world_size, top_k=1):
super().__init__()
self.top_k = top_k
| ["def","__init__","(","self",",","d_model",",","num_expert",",","world_size",",","top_k=1",")",":","super","(",")",".__init__","(",")","self.top_k","=","top_k"] | 12 | 14 | null | test_zero.py | thu-pacman-faster-moe/tests/test_zero.py | import os
import sys
import json
import torch
from fmoe.layers import _fmoe_general_global_forward
from fmoe import FMoETransformerMLP
from test_ddp import _run_distributed | 15 | 1 | 7 | 4 | 1 | 2 | 1 | Use image node_id 1 to create a new ConstantGate object from inherited base classes: torch.nn with example: obj = ConstantGate(d_model, num_expert, world_size, top_k) | 166 | node_id 1 | 2,201,993 |
test_GetLastPoint | RandomModelTest | TestCase | true | self | null | null | null | null | null | def test_GetLastPoint(self) -> None:
generated_points = np.array([[1, 2, 3], [4, 5, 6]])
RandomModelWithPoints = RandomModel(
generated_points=generated_points
)
result = RandomModelWithPoints._get_last_point()
expected = torch.tensor([[4], [5], [6]])
comparison = result == expected
... | ["def","test_GetLastPoint","(","self",")","-",">","None",":","generated_points","=","np.array","(","[","[","1",",","2",",","3","]",",","[","4",",","5",",","6","]","]",")","RandomModelWithPoints","=","RandomModel","(","generated_points=generated_points",")","result","=","RandomModelWithPoints._get_last_point","(",")","e... | 74 | 81 | null | test_random.py | Ax/ax/models/tests/test_random.py | import numpy
import torch
from ax.models.random.base import RandomModel
from ax.utils.common.testutils import TestCase
from ax.utils.common.typeutils import not_none | 15 | 1 | 5 | 0 | 1 | 8 | 1 | Use image node_id 8 for calling the RandomModelTest obj's underlying member method code with example usage: obj.test_GetLastPoint() without return types | 152 | node_id 8 | 9,517 |
get_config | global | null | false | null | null | null | null | config, args | def get_config():
parser = argparse.ArgumentParser(
"Global Config Argument Parser", allow_abbrev=False
)
parser.add_argument(
"--config_yaml",
required=True,
type=str,
help="the configuration file for this experiment.",
)
parser.add_argument(
"--resum... | ["def","get_config","(",")",":","parser","=","argparse.ArgumentParser","(","``","Global","Config","Argument","Parser","''",",","allow_abbrev=False",")","parser.add_argument","(","``","--","config_yaml","''",",","required=True",",","type=str",",","help=","''","the","configuration","file","for","this","experiment",".","`... | 123 | 138 | null | config.py | OpenPrompt/openprompt/config.py | import argparse
from yacs.config import CfgNode
import sys
from openprompt.utils.utils import check_config_conflicts
from .default_config import get_default_config
from openprompt.utils.logging import logger
import os | 15 | null | 7 | 8 | null | null | null | Use image node_id 8 for calling a global function with example usage: get_config() and returns: config, args | 109 | node_id 8 | 152,524 | |
save_config_to_yaml | global | null | false | config | null | null | null | null | null | def save_config_to_yaml(config):
from contextlib import redirect_stdout
saved_yaml_path = os.path.join(config.logging.path, "config.yaml")
with open(saved_yaml_path, "w") as f:
with redirect_stdout(f):
print(config.dump())
logger.info("Config saved as {}".format(saved_yaml_path))
| ["def","save_config_to_yaml","(","config",")",":","from","contextlib","import","redirect_stdout","saved_yaml_path","=","os.path.join","(","config.logging.path",",","``","config.yaml","''",")","with","open","(","saved_yaml_path",",","``","w","''",")","as","f",":","with","redirect_stdout","(","f",")",":","print","(","con... | 116 | 121 | null | config.py | OpenPrompt/openprompt/config.py | import argparse
from yacs.config import CfgNode
import sys
from openprompt.utils.utils import check_config_conflicts
from .default_config import get_default_config
from openprompt.utils.logging import logger
import os | 15 | null | 7 | 8 | null | null | null | Use image node_id 7 for calling a global function with example usage: save_config_to_yaml(config) without return types | 118 | node_id 7 | 152,523 |
update_cfg_with_argparser | global | null | false | cfg,args,prefix | null | null | null | null | null | def update_cfg_with_argparser(cfg, args, prefix=None):
r"""To support update cfg with command line"""
for key in cfg:
value = cfg[key]
full_key_name = (
prefix + "." + key if prefix is not None else key
)
if isinstance(value, CfgNode):
update_cfg_with_argp... | ["def","update_cfg_with_argparser","(","cfg",",","args",",","prefix=None",")",":","r","''","''","''","To","support","update","cfg","with","command","line","''","''","''","for","key","in","cfg",":","value","=","cfg","[","key","]","full_key_name","=","(","prefix","+","``",".","''","+","key","if","prefix","is","not","None... | 99 | 113 | null | config.py | OpenPrompt/openprompt/config.py | import argparse
from yacs.config import CfgNode
import sys
from openprompt.utils.utils import check_config_conflicts
from .default_config import get_default_config
from openprompt.utils.logging import logger
import os | 15 | null | 7 | 8 | null | null | null | Use image node_id 6 for calling a global function with example usage: update_cfg_with_argparser(cfg, args, prefix) without return types | 135 | node_id 6 | 152,522 |
test_ConvertBounds | RandomModelTest | TestCase | true | self | null | null | null | null | null | def test_ConvertBounds(self) -> None:
bounds = [(1.0, 2.0), (3.0, 4.0), (5.0, 6.0)]
bounds_result = self.random_model._convert_bounds(bounds)
bounds_expected = torch.tensor(
[[1, 3, 5], [2, 4, 6]], dtype=torch.double
)
bounds_comparison = bounds_result == bounds_expected
# pyre-fixme[16]... | ["def","test_ConvertBounds","(","self",")","-",">","None",":","bounds","=","[","(","1.0",",","2.0",")",",","(","3.0",",","4.0",")",",","(","5.0",",","6.0",")","]","bounds_result","=","self.random_model._convert_bounds","(","bounds",")","bounds_expected","=","torch.tensor","(","[","[","1",",","3",",","5","]",",","[","2"... | 63 | 72 | null | test_random.py | Ax/ax/models/tests/test_random.py | import numpy
import torch
from ax.models.random.base import RandomModel
from ax.utils.common.testutils import TestCase
from ax.utils.common.typeutils import not_none | 15 | 1 | 5 | 0 | 1 | 8 | 1 | Use image node_id 7 for calling the RandomModelTest obj's underlying member method code with example usage: obj.test_ConvertBounds() without return types | 153 | node_id 7 | 9,516 |
test_ConvertInequalityConstraints | RandomModelTest | TestCase | true | self | null | null | null | null | null | def test_ConvertInequalityConstraints(self) -> None:
A = np.array([[1, 2], [3, 4]])
b = np.array([[5], [6]])
A_result, b_result = not_none(
self.random_model._convert_inequality_constraints((A, b))
)
A_expected = torch.tensor([[1, 2], [3, 4]], dtype=torch.double)
b_expected = torch.tenso... | ["def","test_ConvertInequalityConstraints","(","self",")","-",">","None",":","A","=","np.array","(","[","[","1",",","2","]",",","[","3",",","4","]","]",")","b","=","np.array","(","[","[","5","]",",","[","6","]","]",")","A_result",",","b_result","=","not_none","(","self.random_model._convert_inequality_constraints","(",... | 49 | 61 | null | test_random.py | Ax/ax/models/tests/test_random.py | import numpy
import torch
from ax.models.random.base import RandomModel
from ax.utils.common.testutils import TestCase
from ax.utils.common.typeutils import not_none | 15 | 1 | 5 | 0 | 1 | 8 | 1 | Use image node_id 6 for calling the RandomModelTest obj's underlying member method code with example usage: obj.test_ConvertInequalityConstraints() without return types | 168 | node_id 6 | 9,515 |
test_ConvertEqualityConstraints | RandomModelTest | TestCase | true | self | null | null | null | null | null | def test_ConvertEqualityConstraints(self) -> None:
fixed_features = {3: 0.7, 1: 0.5}
d = 4
C, c = not_none(
self.random_model._convert_equality_constraints(
d, fixed_features
)
)
c_expected = torch.tensor([[0.5], [0.7]], dtype=torch.double)
C_expected = torch.tensor(
... | ["def","test_ConvertEqualityConstraints","(","self",")","-",">","None",":","fixed_features","=","{","3",":","0.7",",","1",":","0.5","}","d","=","4","C",",","c","=","not_none","(","self.random_model._convert_equality_constraints","(","d",",","fixed_features",")",")","c_expected","=","torch.tensor","(","[","[","0.5","]",... | 35 | 47 | null | test_random.py | Ax/ax/models/tests/test_random.py | import numpy
import torch
from ax.models.random.base import RandomModel
from ax.utils.common.testutils import TestCase
from ax.utils.common.typeutils import not_none | 15 | 1 | 5 | 0 | 1 | 8 | 1 | Use image node_id 5 for calling the RandomModelTest obj's underlying member method code with example usage: obj.test_ConvertEqualityConstraints() without return types | 166 | node_id 5 | 9,514 |
add_cfg_to_argparser | global | null | false | cfg,parser,prefix | null | null | null | null | null | def add_cfg_to_argparser(cfg, parser, prefix=None):
r"""To support argument parser style in addition to yaml style"""
for key in cfg:
value = cfg[key]
full_key_name = (
prefix + "." + key if prefix is not None else key
)
if isinstance(value, CfgNode):
add_... | ["def","add_cfg_to_argparser","(","cfg",",","parser",",","prefix=None",")",":","r","''","''","''","To","support","argument","parser","style","in","addition","to","yaml","style","''","''","''","for","key","in","cfg",":","value","=","cfg","[","key","]","full_key_name","=","(","prefix","+","``",".","''","+","key","if","pr... | 78 | 96 | null | config.py | OpenPrompt/openprompt/config.py | import argparse
from yacs.config import CfgNode
import sys
from openprompt.utils.utils import check_config_conflicts
from .default_config import get_default_config
from openprompt.utils.logging import logger
import os | 15 | null | 7 | 8 | null | null | null | Use image node_id 5 for calling a global function with example usage: add_cfg_to_argparser(cfg, parser, prefix) without return types | 132 | node_id 5 | 152,521 |
_get_node_live_artifacts | global | null | false | store | null | null | null | null | store | def _get_node_live_artifacts(
store: mlmd.MetadataStore,
*,
pipeline_id: str,
node_id: str,
pipeline_run_id: Optional[str] = None,
) -> Sequence[mlmd.proto.Artifact]:
"""Gets all LIVE node artifacts.
Args:
store: A MetadataStore object.
pipeline_id: The pipeline ID.
node_i... | ["def","_get_node_live_artifacts","(","store",":","mlmd.MetadataStore",",","*",",","pipeline_id",":","str",",","node_id",":","str",",","pipeline_run_id",":","Optional","[","str","]","=","None",",",")","-",">","Sequence","[","mlmd.proto.Artifact","]",":","``","''","''","Gets","all","LIVE","node","artifacts",".","Args","... | 44 | 87 | null | store_ext.py | tfx/tfx/orchestration/portable/mlmd/store_ext.py | import collections
import itertools
from typing import Callable, Mapping, Optional, Sequence, Union
from tfx.dsl.compiler import compiler_utils
from tfx.dsl.compiler import constants
from tfx.orchestration.experimental.core import constants
from tfx.orchestration.portable.mlmd import event_lib
from tfx.orchestration.po... | 15 | null | 9 | 6 | null | null | null | Use image node_id 3 for calling a global function with example usage: _get_node_live_artifacts(store) and returns: store | 120 | node_id 3 | 2,198,857 |
get_node_executions | global | null | false | store | null | null | null | null | store | def get_node_executions(
store: mlmd.MetadataStore,
*,
pipeline_id: str,
node_id: str,
pipeline_run_id: Optional[str] = None,
order_by: mlmd.OrderByField = mlmd.OrderByField.ID,
is_asc: bool = True,
execution_states: Optional[
Sequence["mlmd.proto.Execution.State"]
] = None,
... | ["def","get_node_executions","(","store",":","mlmd.MetadataStore",",","*",",","pipeline_id",":","str",",","node_id",":","str",",","pipeline_run_id",":","Optional","[","str","]","=","None",",","order_by",":","mlmd.OrderByField","=","mlmd.OrderByField.ID",",","is_asc",":","bool","=","True",",","execution_states",":","Opt... | 90 | 154 | null | store_ext.py | tfx/tfx/orchestration/portable/mlmd/store_ext.py | import collections
import itertools
from typing import Callable, Mapping, Optional, Sequence, Union
from tfx.dsl.compiler import compiler_utils
from tfx.dsl.compiler import constants
from tfx.orchestration.experimental.core import constants
from tfx.orchestration.portable.mlmd import event_lib
from tfx.orchestration.po... | 15 | null | 9 | 6 | null | null | null | Use image node_id 4 for calling a global function with example usage: get_node_executions(store) and returns: store | 115 | node_id 4 | 2,198,858 |
__init__ | Distribution | object | true | self,generator | Sampling distribution for mystic optimizers
| ["Sampling","distribution","for","mystic","optimizers"] | generate a sampling distribution with interface dist(size=None)
input::
- generator: a 'distribution' method from scipy.stats or numpy.random
- rng: a mystic.random_state object [default: random_state('numpy.random')]
- args: positional arguments for the distribtution object
- kwds: keyword arguments f... | ["generate","a","sampling","distribution","with","interface","dist","(","size=None",")","input",":",":","-","generator",":","a","'distribution","'","method","from","scipy.stats","or","numpy.random","-","rng",":","a","mystic.random_state","object","[","default",":","random_state","(","'numpy.random","'",")","]","-","arg... | Distribution | def __init__(self, generator=None, *args, **kwds):
"""
generate a sampling distribution with interface dist(size=None)
input::
- generator: a 'distribution' method from scipy.stats or numpy.random
- rng: a mystic.random_state object [default: random_state('numpy.random')]
- args: po... | ["def","__init__","(","self",",","generator=None",",","*","args",",","*","*","kwds",")",":","``","''","''","generate","a","sampling","distribution","with","interface","dist","(","size=None",")","input",":",":","-","generator",":","a","'distribution","'","method","from","scipy.stats","or","numpy.random","-","rng",":","a... | 55 | 144 | null | __init__.py | mystic/mystic/math/__init__.py | from .poly import polyeval, poly1d
from .grid import gridpts, samplepts, fillpts
from .approx import almostEqual, tolerance
from .approx import approx_equal
from .None import discrete
from .None import distance | 15 | 1 | 6 | 0 | 1 | 7 | 1 | Use image node_id 1 to create a new Distribution object from inherited base classes: object with example: obj = Distribution(generator) | 135 | node_id 1 | 1,406,721 |
__call__ | Distribution | object | true | self,size | Sampling distribution for mystic optimizers
| ["Sampling","distribution","for","mystic","optimizers"] | generate a sample of given size (tuple) from the distribution | ["generate","a","sample","of","given","size","(","tuple",")","from","the","distribution"] | unknown | def __call__(self, size=None):
"""generate a sample of given size (tuple) from the distribution"""
return self.norm * self.rvs(size)
| ["def","__call__","(","self",",","size=None",")",":","``","''","''","generate","a","sample","of","given","size","(","tuple",")","from","the","distribution","''","''","''","return","self.norm","*","self.rvs","(","size",")"] | 145 | 147 | null | __init__.py | mystic/mystic/math/__init__.py | from .poly import polyeval, poly1d
from .grid import gridpts, samplepts, fillpts
from .approx import almostEqual, tolerance
from .approx import approx_equal
from .None import discrete
from .None import distance | 15 | 1 | 6 | 0 | 1 | 7 | 1 | Use image node_id 2 for calling the Distribution obj's underlying member method code with example usage: obj.__call__(size) and returns: unknown | 144 | node_id 2 | 1,406,722 |
__repr__ | Distribution | object | true | self | Sampling distribution for mystic optimizers
| ["Sampling","distribution","for","mystic","optimizers"] | null | null | self | def __repr__(self):
return self.repr(self.__class__.__name__, self.norm)
| ["def","__repr__","(","self",")",":","return","self.repr","(","self.__class__.__name__",",","self.norm",")"] | 148 | 149 | null | __init__.py | mystic/mystic/math/__init__.py | from .poly import polyeval, poly1d
from .grid import gridpts, samplepts, fillpts
from .approx import almostEqual, tolerance
from .approx import approx_equal
from .None import discrete
from .None import distance | 15 | 1 | 6 | 0 | 1 | 7 | 1 | Use image node_id 3 for calling the Distribution obj's underlying member method code with example usage: obj.__repr__() and returns: self | 137 | node_id 3 | 1,406,723 |
__add__ | Distribution | object | true | self,dist | Sampling distribution for mystic optimizers
| ["Sampling","distribution","for","mystic","optimizers"] | null | null | new | def __add__(self, dist):
if not isinstance(dist, Distribution):
msg = "unsupported operand type(s) for +: '{0}' and '{1}'".format(
self.__class__.__name__, type(dist)
)
raise TypeError(msg)
# add data from multiple distributions
new = Distribution()
first = "{0}".form... | ["def","__add__","(","self",",","dist",")",":","if","not","isinstance","(","dist",",","Distribution",")",":","msg","=","``","unsupported","operand","type","(","s",")","for","+",":","'","{","0","}","'","and","'","{","1","}","'","''",".format","(","self.__class__.__name__",",","type","(","dist",")",")","raise","TypeError... | 150 | 164 | null | __init__.py | mystic/mystic/math/__init__.py | from .poly import polyeval, poly1d
from .grid import gridpts, samplepts, fillpts
from .approx import almostEqual, tolerance
from .approx import approx_equal
from .None import discrete
from .None import distance | 15 | 1 | 6 | 0 | 1 | 7 | 1 | Use image node_id 4 for calling the Distribution obj's underlying member method code with example usage: obj.__add__(dist) and returns: new | 139 | node_id 4 | 1,406,724 |
convert_cfg_to_dict | global | null | false | cfg_node,key_list | null | null | null | null | cfg_node,cfg_dict | def convert_cfg_to_dict(cfg_node, key_list=[]):
"""Convert a config node to dictionary"""
if not isinstance(cfg_node, CfgNode):
if type(cfg_node) not in _VALID_TYPES:
print(
"Key {} with value {} is not a valid type; valid types: {}".format(
".".join(key_l... | ["def","convert_cfg_to_dict","(","cfg_node",",","key_list=","[","]",")",":","``","''","''","Convert","a","config","node","to","dictionary","''","''","''","if","not","isinstance","(","cfg_node",",","CfgNode",")",":","if","type","(","cfg_node",")","not","in","_VALID_TYPES",":","print","(","``","Key","{","}","with","value... | 65 | 76 | null | config.py | OpenPrompt/openprompt/config.py | import argparse
from yacs.config import CfgNode
import sys
from openprompt.utils.utils import check_config_conflicts
from .default_config import get_default_config
from openprompt.utils.logging import logger
import os | 15 | null | 7 | 8 | null | null | null | Use image node_id 4 for calling a global function with example usage: convert_cfg_to_dict(cfg_node, key_list) and returns: cfg_node, cfg_dict | 141 | node_id 4 | 152,520 |
get_live_output_artifacts_of_node_by_output_key | global | null | false | store | null | null | null | null | output_artifacts_by_output_key,dict,dict | def get_live_output_artifacts_of_node_by_output_key(
store: mlmd.MetadataStore,
*,
pipeline_id: str,
node_id: str,
pipeline_run_id: Optional[str] = None,
execution_states: Optional[
Sequence["mlmd.proto.Execution.State"]
] = None,
) -> Mapping[str, Sequence[Sequence[mlmd.proto.Artifa... | ["def","get_live_output_artifacts_of_node_by_output_key","(","store",":","mlmd.MetadataStore",",","*",",","pipeline_id",":","str",",","node_id",":","str",",","pipeline_run_id",":","Optional","[","str","]","=","None",",","execution_states",":","Optional","[","Sequence","[","``","mlmd.proto.Execution.State","''","]","]",... | 157 | 273 | null | store_ext.py | tfx/tfx/orchestration/portable/mlmd/store_ext.py | import collections
import itertools
from typing import Callable, Mapping, Optional, Sequence, Union
from tfx.dsl.compiler import compiler_utils
from tfx.dsl.compiler import constants
from tfx.orchestration.experimental.core import constants
from tfx.orchestration.portable.mlmd import event_lib
from tfx.orchestration.po... | 15 | null | 9 | 6 | null | null | null | Use image node_id 5 for calling a global function with example usage: get_live_output_artifacts_of_node_by_output_key(store) and returns: output_artifacts_by_output_key, dict, dict | 180 | node_id 5 | 2,198,859 |
test_zero_fwd | global | null | false | num_expert,batch_size,d_hidden,world_size | null | null | null | null | null | def test_zero_fwd(
num_expert=2, batch_size=4, d_hidden=8, world_size=1
):
_run_distributed(
"_test_zero_fwd",
1,
{
"num_expert": num_expert,
"batch_size": batch_size,
"d_hidden": d_hidden,
},
script=__file__,
)
| ["def","test_zero_fwd","(","num_expert=2",",","batch_size=4",",","d_hidden=8",",","world_size=1",")",":","_run_distributed","(","``","_test_zero_fwd","''",",","1",",","{","``","num_expert","''",":","num_expert",",","``","batch_size","''",":","batch_size",",","``","d_hidden","''",":","d_hidden",",","}",",","script=__fil... | 23 | 32 | null | test_zero.py | thu-pacman-faster-moe/tests/test_zero.py | import os
import sys
import json
import torch
from fmoe.layers import _fmoe_general_global_forward
from fmoe import FMoETransformerMLP
from test_ddp import _run_distributed | 15 | null | 7 | 4 | null | null | null | Use image node_id 1 for calling a global function with example usage: test_zero_fwd(num_expert, batch_size, d_hidden, world_size) without return types | 150 | node_id 1 | 2,201,995 |
_test_zero_fwd | global | null | false | num_expert,batch_size,d_hidden,world_size | null | null | null | null | null | def _test_zero_fwd(
num_expert=2, batch_size=4, d_hidden=8, world_size=1
):
inp = torch.rand(batch_size, d_hidden).cuda()
gate = torch.zeros(batch_size, dtype=torch.int64).cuda()
x = _fmoe_general_global_forward(
inp, gate, lambda x, y: x, num_expert, world_size
)
| ["def","_test_zero_fwd","(","num_expert=2",",","batch_size=4",",","d_hidden=8",",","world_size=1",")",":","inp","=","torch.rand","(","batch_size",",","d_hidden",")",".cuda","(",")","gate","=","torch.zeros","(","batch_size",",","dtype=torch.int64",")",".cuda","(",")","x","=","_fmoe_general_global_forward","(","inp",",",... | 34 | 38 | null | test_zero.py | thu-pacman-faster-moe/tests/test_zero.py | import os
import sys
import json
import torch
from fmoe.layers import _fmoe_general_global_forward
from fmoe import FMoETransformerMLP
from test_ddp import _run_distributed | 15 | null | 7 | 4 | null | null | null | Use image node_id 2 for calling a global function with example usage: _test_zero_fwd(num_expert, batch_size, d_hidden, world_size) without return types | 151 | node_id 2 | 2,201,996 |
test_zero_transformer | global | null | false | num_expert,batch_size,d_hidden,world_size | null | null | null | null | null | def test_zero_transformer(
num_expert=2, batch_size=4, d_hidden=8, world_size=1
):
_run_distributed(
"_test_zero_transformer",
1,
{
"num_expert": num_expert,
"batch_size": batch_size,
"d_hidden": d_hidden,
},
script=__file__,
)
| ["def","test_zero_transformer","(","num_expert=2",",","batch_size=4",",","d_hidden=8",",","world_size=1",")",":","_run_distributed","(","``","_test_zero_transformer","''",",","1",",","{","``","num_expert","''",":","num_expert",",","``","batch_size","''",":","batch_size",",","``","d_hidden","''",":","d_hidden",",","}","... | 41 | 50 | null | test_zero.py | thu-pacman-faster-moe/tests/test_zero.py | import os
import sys
import json
import torch
from fmoe.layers import _fmoe_general_global_forward
from fmoe import FMoETransformerMLP
from test_ddp import _run_distributed | 15 | null | 7 | 4 | null | null | null | Use image node_id 3 for calling a global function with example usage: test_zero_transformer(num_expert, batch_size, d_hidden, world_size) without return types | 158 | node_id 3 | 2,201,997 |
_test_zero_transformer | global | null | false | num_expert,batch_size,d_hidden,world_size | null | null | null | null | null | def _test_zero_transformer(
num_expert=2, batch_size=4, d_hidden=8, world_size=1
):
inp = torch.rand(batch_size, d_hidden).cuda()
mask = torch.zeros(inp.shape[0], dtype=torch.long)
mask[1] = 1
mask_dict = {1: torch.zeros(d_hidden).cuda()}
model = FMoETransformerMLP(
num_expert,
d... | ["def","_test_zero_transformer","(","num_expert=2",",","batch_size=4",",","d_hidden=8",",","world_size=1",")",":","inp","=","torch.rand","(","batch_size",",","d_hidden",")",".cuda","(",")","mask","=","torch.zeros","(","inp.shape","[","0","]",",","dtype=torch.long",")","mask","[","1","]","=","1","mask_dict","=","{","1",... | 52 | 61 | null | test_zero.py | thu-pacman-faster-moe/tests/test_zero.py | import os
import sys
import json
import torch
from fmoe.layers import _fmoe_general_global_forward
from fmoe import FMoETransformerMLP
from test_ddp import _run_distributed | 15 | null | 7 | 4 | null | null | null | Use image node_id 4 for calling a global function with example usage: _test_zero_transformer(num_expert, batch_size, d_hidden, world_size) without return types | 159 | node_id 4 | 2,201,998 |
setUp | TestHighConfidence | unittest | true | self | A unittest class for testing the HighConfidence postprocessor. | ["A","unittest","class","for","testing","the","HighConfidence","postprocessor","."] | null | null | null | def setUp(self):
master_seed(seed=1234)
| ["def","setUp","(","self",")",":","master_seed","(","seed=1234",")"] | 41 | 42 | null | test_high_confidence.py | adversarial-robustness-toolbox/tests/defences/test_high_confidence.py | import logging
import unittest
import numpy
from art.defences.postprocessor import HighConfidence
from art.utils import load_dataset
from tests.utils import master_seed, get_image_classifier_kr_tf, get_image_classifier_kr_tf_binary | 15 | 1 | 6 | 0 | 1 | 7 | 1 | Use image node_id 2 for calling the TestHighConfidence obj's underlying member method code with example usage: obj.setUp() without return types | 143 | node_id 2 | 235,297 |
test_difference | TestIntervalIndex | null | true | self,closed,sort | null | null | null | null | null | def test_difference(self, closed, sort):
index = IntervalIndex.from_arrays(
[1, 0, 3, 2], [1, 2, 3, 4], closed=closed
)
result = index.difference(index[:1], sort=sort)
expected = index[1:]
if sort is None:
expected = expected.sort_values()
tm.assert_index_equal(result, expected)
... | ["def","test_difference","(","self",",","closed",",","sort",")",":","index","=","IntervalIndex.from_arrays","(","[","1",",","0",",","3",",","2","]",",","[","1",",","2",",","3",",","4","]",",","closed=closed",")","result","=","index.difference","(","index","[",":1","]",",","sort=sort",")","expected","=","index","[","1",... | 131 | 149 | null | test_setops.py | pandas/pandas/tests/indexes/interval/test_setops.py | import numpy
import pytest
from pandas import Index, IntervalIndex, Timestamp, interval_range
import pandas._testing | 15 | 1 | 4 | 2 | 0 | 8 | null | Use image node_id 6 for calling the TestIntervalIndex obj's underlying member method code with example usage: obj.test_difference(closed, sort) without return types | 164 | node_id 6 | 1,514,638 |
test_ThompsonSamplerUniformWeights | ThompsonSamplerTest | TestCase | true | self | null | null | null | null | null | def test_ThompsonSamplerUniformWeights(self) -> None:
generator = ThompsonSampler(min_weight=0.0, uniform_weights=True)
generator.fit(
# pyre-fixme[6]: For 1st param expected `List[List[List[Union[None,
# bool, float, int, str]]]]` but got `List[List[List[int]]]`.
Xs=self.Xs,
# ... | ["def","test_ThompsonSamplerUniformWeights","(","self",")","-",">","None",":","generator","=","ThompsonSampler","(","min_weight=0.0",",","uniform_weights=True",")","generator.fit","(","#","pyre-fixme","[","6","]",":","For","1st","param","expected","`","List","[","List","[","List","[","Union","[","None",",","#","bool","... | 146 | 172 | null | test_thompson.py | Ax/ax/models/tests/test_thompson.py | import numpy
from ax.exceptions.model import ModelError
from ax.models.discrete.thompson import ThompsonSampler
from ax.utils.common.testutils import TestCase | 15 | 1 | 4 | 0 | 1 | 9 | 1 | Use image node_id 5 for calling the ThompsonSamplerTest obj's underlying member method code with example usage: obj.test_ThompsonSamplerUniformWeights() without return types | 173 | node_id 5 | 9,539 |
test_ThompsonSamplerMinWeight | ThompsonSamplerTest | TestCase | true | self | null | null | null | null | null | def test_ThompsonSamplerMinWeight(self) -> None:
generator = ThompsonSampler(min_weight=0.01)
generator.fit(
# pyre-fixme[6]: For 1st param expected `List[List[List[Union[None,
# bool, float, int, str]]]]` but got `List[List[List[int]]]`.
Xs=self.Xs,
# pyre-fixme[6]: For 2nd par... | ["def","test_ThompsonSamplerMinWeight","(","self",")","-",">","None",":","generator","=","ThompsonSampler","(","min_weight=0.01",")","generator.fit","(","#","pyre-fixme","[","6","]",":","For","1st","param","expected","`","List","[","List","[","List","[","Union","[","None",",","#","bool",",","float",",","int",",","str",... | 116 | 144 | null | test_thompson.py | Ax/ax/models/tests/test_thompson.py | import numpy
from ax.exceptions.model import ModelError
from ax.models.discrete.thompson import ThompsonSampler
from ax.utils.common.testutils import TestCase | 15 | 1 | 4 | 0 | 1 | 9 | 1 | Use image node_id 4 for calling the ThompsonSamplerTest obj's underlying member method code with example usage: obj.test_ThompsonSamplerMinWeight() without return types | 168 | node_id 4 | 9,538 |
test_ThompsonSamplerValidation | ThompsonSamplerTest | TestCase | true | self | null | null | null | null | null | def test_ThompsonSamplerValidation(self) -> None:
generator = ThompsonSampler(min_weight=0.01)
# all Xs are not the same
with self.assertRaises(ValueError):
generator.fit(
Xs=[
[[1, 1], [2, 2], [3, 3], [4, 4]],
[[1, 1], [2, 2], [4, 4]],
],
... | ["def","test_ThompsonSamplerValidation","(","self",")","-",">","None",":","generator","=","ThompsonSampler","(","min_weight=0.01",")","#","all","Xs","are","not","the","same","with","self.assertRaises","(","ValueError",")",":","generator.fit","(","Xs=","[","[","[","1",",","1","]",",","[","2",",","2","]",",","[","3",",",... | 60 | 114 | null | test_thompson.py | Ax/ax/models/tests/test_thompson.py | import numpy
from ax.exceptions.model import ModelError
from ax.models.discrete.thompson import ThompsonSampler
from ax.utils.common.testutils import TestCase | 15 | 1 | 4 | 0 | 1 | 9 | 1 | Use image node_id 3 for calling the ThompsonSamplerTest obj's underlying member method code with example usage: obj.test_ThompsonSamplerValidation() without return types | 169 | node_id 3 | 9,537 |
test_ThompsonSampler | ThompsonSamplerTest | TestCase | true | self | null | null | null | null | null | def test_ThompsonSampler(self) -> None:
generator = ThompsonSampler(min_weight=0.0)
generator.fit(
# pyre-fixme[6]: For 1st param expected `List[List[List[Union[None,
# bool, float, int, str]]]]` but got `List[List[List[int]]]`.
Xs=self.Xs,
# pyre-fixme[6]: For 2nd param expecte... | ["def","test_ThompsonSampler","(","self",")","-",">","None",":","generator","=","ThompsonSampler","(","min_weight=0.0",")","generator.fit","(","#","pyre-fixme","[","6","]",":","For","1st","param","expected","`","List","[","List","[","List","[","Union","[","None",",","#","bool",",","float",",","int",",","str","]","]","]... | 29 | 58 | null | test_thompson.py | Ax/ax/models/tests/test_thompson.py | import numpy
from ax.exceptions.model import ModelError
from ax.models.discrete.thompson import ThompsonSampler
from ax.utils.common.testutils import TestCase | 15 | 1 | 4 | 0 | 1 | 9 | 1 | Use image node_id 2 for calling the ThompsonSamplerTest obj's underlying member method code with example usage: obj.test_ThompsonSampler() without return types | 159 | node_id 2 | 9,536 |
setUp | ThompsonSamplerTest | TestCase | true | self | null | null | null | null | null | def setUp(self) -> None:
self.Xs = [
[[1, 1], [2, 2], [3, 3], [4, 4]]
] # 4 arms, each of dimensionality 2
self.Ys = [[1, 2, 3, 4]]
self.Yvars = [[1, 1, 1, 1]]
self.parameter_values = [[1, 2, 3, 4], [1, 2, 3, 4]]
self.outcome_names = ["x", "y"] # not used for regular TS
self.multi... | ["def","setUp","(","self",")","-",">","None",":","self.Xs","=","[","[","[","1",",","1","]",",","[","2",",","2","]",",","[","3",",","3","]",",","[","4",",","4","]","]","]","#","4","arms",",","each","of","dimensionality","2","self.Ys","=","[","[","1",",","2",",","3",",","4","]","]","self.Yvars","=","[","[","1",",","1",",... | 15 | 27 | null | test_thompson.py | Ax/ax/models/tests/test_thompson.py | import numpy
from ax.exceptions.model import ModelError
from ax.models.discrete.thompson import ThompsonSampler
from ax.utils.common.testutils import TestCase | 15 | 1 | 4 | 0 | 1 | 9 | 1 | Use image node_id 1 for calling the ThompsonSamplerTest obj's underlying member method code with example usage: obj.setUp() without return types | 144 | node_id 1 | 9,535 |
test_decimals_0_1 | TestHighConfidence | unittest | true | self | A unittest class for testing the HighConfidence postprocessor. | ["A","unittest","class","for","testing","the","HighConfidence","postprocessor","."] | Test with cutoff of 0.1. | ["Test","with","cutoff","of","0.1","."] | null | def test_decimals_0_1(self):
"""
Test with cutoff of 0.1.
"""
(_, _), (x_test, _) = self.mnist
classifier = get_image_classifier_kr_tf()
preds = classifier.predict(x_test[0:1])
postprocessor = HighConfidence(cutoff=0.1)
post_preds = postprocessor(preds=preds)
classifier_prediction_e... | ["def","test_decimals_0_1","(","self",")",":","``","''","''","Test","with","cutoff","of","0.1.","``","''","''","(","_",",","_",")",",","(","x_test",",","_",")","=","self.mnist","classifier","=","get_image_classifier_kr_tf","(",")","preds","=","classifier.predict","(","x_test","[","0:1","]",")","postprocessor","=","High... | 44 | 76 | null | test_high_confidence.py | adversarial-robustness-toolbox/tests/defences/test_high_confidence.py | import logging
import unittest
import numpy
from art.defences.postprocessor import HighConfidence
from art.utils import load_dataset
from tests.utils import master_seed, get_image_classifier_kr_tf, get_image_classifier_kr_tf_binary | 15 | 1 | 6 | 0 | 1 | 7 | 1 | Use image node_id 3 for calling the TestHighConfidence obj's underlying member method code with example usage: obj.test_decimals_0_1() without return types | 155 | node_id 3 | 235,298 |
test_decimals_0_2 | TestHighConfidence | unittest | true | self | A unittest class for testing the HighConfidence postprocessor. | ["A","unittest","class","for","testing","the","HighConfidence","postprocessor","."] | Test with cutoff of 0.2. | ["Test","with","cutoff","of","0.2","."] | null | def test_decimals_0_2(self):
"""
Test with cutoff of 0.2.
"""
(_, _), (x_test, _) = self.mnist
classifier = get_image_classifier_kr_tf()
preds = classifier.predict(x_test[0:1])
postprocessor = HighConfidence(cutoff=0.2)
post_preds = postprocessor(preds=preds)
classifier_prediction_e... | ["def","test_decimals_0_2","(","self",")",":","``","''","''","Test","with","cutoff","of","0.2.","``","''","''","(","_",",","_",")",",","(","x_test",",","_",")","=","self.mnist","classifier","=","get_image_classifier_kr_tf","(",")","preds","=","classifier.predict","(","x_test","[","0:1","]",")","postprocessor","=","High... | 78 | 110 | null | test_high_confidence.py | adversarial-robustness-toolbox/tests/defences/test_high_confidence.py | import logging
import unittest
import numpy
from art.defences.postprocessor import HighConfidence
from art.utils import load_dataset
from tests.utils import master_seed, get_image_classifier_kr_tf, get_image_classifier_kr_tf_binary | 15 | 1 | 6 | 0 | 1 | 7 | 1 | Use image node_id 4 for calling the TestHighConfidence obj's underlying member method code with example usage: obj.test_decimals_0_2() without return types | 155 | node_id 4 | 235,299 |
test_binary_decimals_0_5 | TestHighConfidence | unittest | true | self | A unittest class for testing the HighConfidence postprocessor. | ["A","unittest","class","for","testing","the","HighConfidence","postprocessor","."] | Test with cutoff of 0.5 for binary classifier. | ["Test","with","cutoff","of","0.5","for","binary","classifier","."] | null | def test_binary_decimals_0_5(self):
"""
Test with cutoff of 0.5 for binary classifier.
"""
(_, _), (x_test, _) = self.mnist
classifier = get_image_classifier_kr_tf_binary()
preds = classifier.predict(x_test[0:1])
postprocessor = HighConfidence(cutoff=0.5)
post_preds = postprocessor(preds... | ["def","test_binary_decimals_0_5","(","self",")",":","``","''","''","Test","with","cutoff","of","0.5","for","binary","classifier.","``","''","''","(","_",",","_",")",",","(","x_test",",","_",")","=","self.mnist","classifier","=","get_image_classifier_kr_tf_binary","(",")","preds","=","classifier.predict","(","x_test","... | 112 | 126 | null | test_high_confidence.py | adversarial-robustness-toolbox/tests/defences/test_high_confidence.py | import logging
import unittest
import numpy
from art.defences.postprocessor import HighConfidence
from art.utils import load_dataset
from tests.utils import master_seed, get_image_classifier_kr_tf, get_image_classifier_kr_tf_binary | 15 | 1 | 6 | 0 | 1 | 7 | 1 | Use image node_id 5 for calling the TestHighConfidence obj's underlying member method code with example usage: obj.test_binary_decimals_0_5() without return types | 162 | node_id 5 | 235,300 |
test_RandomModelGenSamples | RandomModelTest | TestCase | true | self | null | null | null | null | null | def test_RandomModelGenSamples(self) -> None:
with self.assertRaises(NotImplementedError):
self.random_model._gen_samples(n=1, tunable_d=1)
| ["def","test_RandomModelGenSamples","(","self",")","-",">","None",":","with","self.assertRaises","(","NotImplementedError",")",":","self.random_model._gen_samples","(","n=1",",","tunable_d=1",")"] | 25 | 27 | null | test_random.py | Ax/ax/models/tests/test_random.py | import numpy
import torch
from ax.models.random.base import RandomModel
from ax.utils.common.testutils import TestCase
from ax.utils.common.typeutils import not_none | 15 | 1 | 5 | 0 | 1 | 8 | 1 | Use image node_id 3 for calling the RandomModelTest obj's underlying member method code with example usage: obj.test_RandomModelGenSamples() without return types | 161 | node_id 3 | 9,512 |
test_binary_decimals_0_6 | TestHighConfidence | unittest | true | self | A unittest class for testing the HighConfidence postprocessor. | ["A","unittest","class","for","testing","the","HighConfidence","postprocessor","."] | Test with cutoff of 0.6 for binary classifier. | ["Test","with","cutoff","of","0.6","for","binary","classifier","."] | null | def test_binary_decimals_0_6(self):
"""
Test with cutoff of 0.6 for binary classifier.
"""
(_, _), (x_test, _) = self.mnist
classifier = get_image_classifier_kr_tf_binary()
preds = classifier.predict(x_test[0:1])
postprocessor = HighConfidence(cutoff=0.6)
post_preds = postprocessor(preds... | ["def","test_binary_decimals_0_6","(","self",")",":","``","''","''","Test","with","cutoff","of","0.6","for","binary","classifier.","``","''","''","(","_",",","_",")",",","(","x_test",",","_",")","=","self.mnist","classifier","=","get_image_classifier_kr_tf_binary","(",")","preds","=","classifier.predict","(","x_test","... | 128 | 142 | null | test_high_confidence.py | adversarial-robustness-toolbox/tests/defences/test_high_confidence.py | import logging
import unittest
import numpy
from art.defences.postprocessor import HighConfidence
from art.utils import load_dataset
from tests.utils import master_seed, get_image_classifier_kr_tf, get_image_classifier_kr_tf_binary | 15 | 1 | 6 | 0 | 1 | 7 | 1 | Use image node_id 6 for calling the TestHighConfidence obj's underlying member method code with example usage: obj.test_binary_decimals_0_6() without return types | 162 | node_id 6 | 235,301 |
convert | Converter | ImageConverter | true | self,_from,_to | null | null | Converts the image from SVG to PDF using chrome. | ["Converts","the","image","from","SVG","to","PDF","using","chrome","."] | True | def convert(self, _from: str, _to: str) -> bool:
"""Converts the image from SVG to PDF using chrome."""
with open(_from, "r") as f:
svg = f.read()
HTML = (
"<html><head><style>body {margin: 0; }</style><script>function init() {const element = document.querySelector('svg');const positionInfo... | ["def","convert","(","self",",","_from",":","str",",","_to",":","str",")","-",">","bool",":","``","''","''","Converts","the","image","from","SVG","to","PDF","using","chrome",".","''","''","''","with","open","(","_from",",","``","r","''",")","as","f",":","svg","=","f.read","(",")","HTML","=","(","``","<","html",">","<",... | 71 | 89 | null | convert-svg-to-pdf.py | sympy/doc/ext/convert-svg-to-pdf.py | from __future__ import annotations
from sphinx.transforms.post_transforms.images import ImageConverter
from sphinx.util import logging
import os
import platform
from typing import Any
from sphinx.application import Sphinx | 15 | 1 | 7 | 1 | 1 | 5 | 1 | Use image node_id 5 for calling the Converter obj's underlying member method code with example usage: obj.convert(_from, _to) and returns: True | 143 | node_id 5 | 2,029,278 |
_setup | RunnerTrafficMetricsMiddleware | null | true | self,metrics_client | null | null | null | null | null | def _setup(
self,
metrics_client: "PrometheusClient" = Provide[
BentoMLContainer.metrics_client
],
):
self.metrics_client = metrics_client
self.metrics_request_duration = metrics_client.Histogram(
namespace=self.namespace,
name="request_duration_seconds",
documentati... | ["def","_setup","(","self",",","metrics_client",":","``","PrometheusClient","''","=","Provide","[","BentoMLContainer.metrics_client","]",",",")",":","self.metrics_client","=","metrics_client","self.metrics_request_duration","=","metrics_client.Histogram","(","namespace=self.namespace",",","name=","''","request_duration... | 150 | 187 | null | instruments.py | BentoML/src/bentoml/_internal/server/http/instruments.py | from __future__ import annotations
import contextvars
import logging
from timeit import default_timer
from typing import TYPE_CHECKING
from simple_di import Provide
from simple_di import inject
from ...configuration.containers import BentoMLContainer
from ...context import component_context | 15 | 2 | 9 | 0 | 0 | 2 | null | Use image node_id 2 for calling the RunnerTrafficMetricsMiddleware obj's underlying member method code with example usage: obj._setup(metrics_client) without return types | 170 | node_id 2 | 14,515 |
command_runner | Converter | ImageConverter | true | self,chrome,_to,temp_name | null | null | null | null | os,int | def command_runner(
self, chrome: str | None, _to: str, temp_name: str
) -> int:
if not chrome:
return 1
command = f"{chrome} --headless --disable-gpu --disable-software-rasterizer --print-to-pdf={_to} {temp_name}"
logger.error(command)
return os.system(command)
| ["def","command_runner","(","self",",","chrome",":","str","|","None",",","_to",":","str",",","temp_name",":","str",")","-",">","int",":","if","not","chrome",":","return","1","command","=","f","''","{","chrome","}","--","headless","--","disable-gpu","--","disable-software-rasterizer","--","print-to-pdf=","{","_to","}","... | 64 | 69 | null | convert-svg-to-pdf.py | sympy/doc/ext/convert-svg-to-pdf.py | from __future__ import annotations
from sphinx.transforms.post_transforms.images import ImageConverter
from sphinx.util import logging
import os
import platform
from typing import Any
from sphinx.application import Sphinx | 15 | 1 | 7 | 1 | 1 | 5 | 1 | Use image node_id 4 for calling the Converter obj's underlying member method code with example usage: obj.command_runner(chrome, _to, temp_name) and returns: os, int | 165 | node_id 4 | 2,029,277 |
chromium_command | Converter | ImageConverter | true | self | null | null | null | null | None,None,str,str,str+path+str,path,str | def chromium_command(self) -> str | None:
if platform.win32_ver()[0]:
if os.system("where chromium") == 0:
return "chromium"
path = os.path.join(
os.environ["PROGRAMW6432"],
"Chromium\\Application\\chrome.exe",
)
if os.path.exists(path):
... | ["def","chromium_command","(","self",")","-",">","str","|","None",":","if","platform.win32_ver","(",")","[","0","]",":","if","os.system","(","``","where","chromium","''",")","==","0",":","return","``","chromium","''","path","=","os.path.join","(","os.environ","[","``","PROGRAMW6432","''","]",",","``","Chromium\\\\Appli... | 44 | 61 | null | convert-svg-to-pdf.py | sympy/doc/ext/convert-svg-to-pdf.py | from __future__ import annotations
from sphinx.transforms.post_transforms.images import ImageConverter
from sphinx.util import logging
import os
import platform
from typing import Any
from sphinx.application import Sphinx | 15 | 1 | 7 | 1 | 1 | 5 | 1 | Use image node_id 3 for calling the Converter obj's underlying member method code with example usage: obj.chromium_command() and returns: None, None, str, str, str, path, str, path, str | 185 | node_id 3 | 2,029,276 |
_test_texture_as_input | TestShapeShifter | TestBase | true | self,sign_gradients,use_spectral,soft_clip | null | null | null | null | background, image_frame, y_,current_image | def _test_texture_as_input(
self, sign_gradients, use_spectral, soft_clip
):
# We must start a new graph
tf.reset_default_graph()
# Only import if object detection module is available
from art.estimators.object_detection.tensorflow_faster_rcnn import (
TensorFlowFasterRCNN,
)
from a... | ["def","_test_texture_as_input","(","self",",","sign_gradients",",","use_spectral",",","soft_clip",")",":","#","We","must","start","a","new","graph","tf.reset_default_graph","(",")","#","Only","import","if","object","detection","module","is","available","from","art.estimators.object_detection.tensorflow_faster_rcnn","i... | 139 | 235 | null | test_shapeshifter.py | adversarial-robustness-toolbox/tests/attacks/test_shapeshifter.py | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import unittest
import importlib
import tensorflow
import numpy
from tests.utils import TestBase, master_seed | 15 | 1 | 7 | 0 | 1 | 6 | 1 | Use image node_id 5 for calling the TestShapeShifter obj's underlying member method code with example usage: obj._test_texture_as_input(sign_gradients, use_spectral, soft_clip) and returns: background, image_frame, y_, current_image | 234 | node_id 5 | 234,965 |
test_check_params | TestShapeShifter | TestBase | true | self | null | null | null | null | null | def test_check_params(self):
from art.estimators.object_detection import TensorFlowFasterRCNN
from art.attacks.evasion import ShapeShifter
images = tf.Variable(
initial_value=np.zeros([1, 28, 28, 1]), dtype=tf.float32
)
obj_dec = TensorFlowFasterRCNN(images=images)
with self.assertRais... | ["def","test_check_params","(","self",")",":","from","art.estimators.object_detection","import","TensorFlowFasterRCNN","from","art.attacks.evasion","import","ShapeShifter","images","=","tf.Variable","(","initial_value=np.zeros","(","[","1",",","28",",","28",",","1","]",")",",","dtype=tf.float32",")","obj_dec","=","Tens... | 237 | 380 | null | test_shapeshifter.py | adversarial-robustness-toolbox/tests/attacks/test_shapeshifter.py | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import unittest
import importlib
import tensorflow
import numpy
from tests.utils import TestBase, master_seed | 15 | 1 | 7 | 0 | 1 | 6 | 1 | Use image node_id 6 for calling the TestShapeShifter obj's underlying member method code with example usage: obj.test_check_params() without return types | 153 | node_id 6 | 234,966 |
do_measure | global | null | false | opts | null | null | null | null | null | def do_measure(opts):
name = opts["-d"]
_log.info("reading data %s", name)
test = pd.read_parquet(f"data/{name}-test.parquet")
recs = pd.read_parquet(f"data/{name}-recs.parquet")
_log.info("setting up analysis")
rla = RecListAnalysis()
rla.add_metric(ndcg)
rla.add_metric(recip_rank)
... | ["def","do_measure","(","opts",")",":","name","=","opts","[","``","-d","''","]","_log.info","(","``","reading","data","%","s","''",",","name",")","test","=","pd.read_parquet","(","f","''","data\/","{","name","}","-test.parquet","''",")","recs","=","pd.read_parquet","(","f","''","data\/","{","name","}","-recs.parquet","... | 65 | 86 | null | rla-perf.py | lkpy/utils/rla-perf.py | import sys
import logging
import tqdm
from docopt import docopt
import pandas
from lenskit.datasets import MovieLens
from lenskit.util import Stopwatch
from lenskit.batch import recommend
from lenskit.crossfold import sample_users, SampleN
from lenskit.algorithms.basic import Popular
from lenskit.algorithms import Reco... | 15 | null | 13 | 2 | null | null | null | Use image node_id 2 for calling a global function with example usage: do_measure(opts) without return types | 107 | node_id 2 | 1,270,200 |
__init__ | EntitySievesConfiguration | SievesConfiguration | true | self | null | null | null | null | EntitySievesConfiguration | def __init__(self):
super(EntitySievesConfiguration, self).__init__()
self.run_evaluation = True
self.sieves_order = [
(RelationType.SAME_HEAD_LEMMA, 1.0),
(RelationType.EXACT_STRING, 1.0),
(RelationType.FUZZY_FIT, 1.0),
(RelationType.WIKIPEDIA_REDIRECT_LINK, 0.1),
... | ["def","__init__","(","self",")",":","super","(","EntitySievesConfiguration",",","self",")",".__init__","(",")","self.run_evaluation","=","True","self.sieves_order","=","[","(","RelationType.SAME_HEAD_LEMMA",",","1.0",")",",","(","RelationType.EXACT_STRING",",","1.0",")",",","(","RelationType.FUZZY_FIT",",","1.0",")","... | 82 | 102 | null | sieves_config.py | nlp-architect/nlp_architect/models/cross_doc_coref/sieves_config.py | from typing import List, Tuple
from nlp_architect.data.cdc_resources.relations.relation_types_enums import RelationType | 15 | 3 | 2 | 0 | 3 | 1 | 1 | Use image node_id 1 to create a new EntitySievesConfiguration object from inherited base classes: SievesConfiguration with example: obj = EntitySievesConfiguration() | 165 | node_id 1 | 1,443,099 |
get_boutiques_output_from_inp | global | null | false | inputs,inp_spec,inp_name | null | null | null | null | output | def get_boutiques_output_from_inp(inputs, inp_spec, inp_name):
"""
Takes a Nipype input representing an output file and generates a
Boutiques output for it
"""
output = {}
output["name"] = inp_name.replace("_", " ").capitalize()
output["id"] = inp_name
output["optional"] = True
outpu... | ["def","get_boutiques_output_from_inp","(","inputs",",","inp_spec",",","inp_name",")",":","``","''","''","Takes","a","Nipype","input","representing","an","output","file","and","generates","a","Boutiques","output","for","it","``","''","''","output","=","{","}","output","[","``","name","''","]","=","inp_name.replace","("... | 637 | 666 | null | nipype2boutiques.py | nipype/nipype/utils/nipype2boutiques.py | import os
import sys
import simplejson
from ..scripts.instance import import_module | 15 | null | 4 | 11 | null | null | null | Use image node_id 11 for calling a global function with example usage: get_boutiques_output_from_inp(inputs, inp_spec, inp_name) and returns: output | 148 | node_id 11 | 1,442,053 |
_ids | global | null | false | values | null | null | null | null | unknown | def _ids(values: Sequence[_Metadata]) -> Sequence[int]:
return [v.id for v in values]
| ["def","_ids","(","values",":","Sequence","[","_Metadata","]",")","-",">","Sequence","[","int","]",":","return","[","v.id","for","v","in","values","]"] | 36 | 37 | null | store_ext.py | tfx/tfx/orchestration/portable/mlmd/store_ext.py | import collections
import itertools
from typing import Callable, Mapping, Optional, Sequence, Union
from tfx.dsl.compiler import compiler_utils
from tfx.dsl.compiler import constants
from tfx.orchestration.experimental.core import constants
from tfx.orchestration.portable.mlmd import event_lib
from tfx.orchestration.po... | 15 | null | 9 | 6 | null | null | null | Use image node_id 1 for calling a global function with example usage: _ids(values) and returns: unknown | 103 | node_id 1 | 2,198,855 |
setup | global | null | false | app | null | null | null | null | dict | def setup(app: Sphinx) -> dict[str, Any]:
app.add_post_transform(Converter)
return {
"version": "builtin",
"parallel_read_safe": True,
"parallel_write_safe": True,
}
| ["def","setup","(","app",":","Sphinx",")","-",">","dict","[","str",",","Any","]",":","app.add_post_transform","(","Converter",")","return","{","``","version","''",":","``","builtin","''",",","``","parallel_read_safe","''",":","True",",","``","parallel_write_safe","''",":","True",",","}"] | 92 | 99 | null | convert-svg-to-pdf.py | sympy/doc/ext/convert-svg-to-pdf.py | from __future__ import annotations
from sphinx.transforms.post_transforms.images import ImageConverter
from sphinx.util import logging
import os
import platform
from typing import Any
from sphinx.application import Sphinx | 15 | null | 7 | 1 | null | null | null | Use image node_id 1 for calling a global function with example usage: setup(app) and returns: dict | 98 | node_id 1 | 2,029,279 |
__init__ | SearchSpaceToChoice | Transform | true | self,search_space,observations,modelbridge,config | Replaces the search space with a single choice parameter, whose values
are the signatures of the arms observed in the data.
This transform is meant to be used with ThompsonSampler.
Choice parameter will be unordered unless config["use_ordered"] specifies
otherwise.
Transform is done in-place. | ["Replaces","the","search","space","with","a","single","choice","parameter",",","whose","values","are","the","signatures","of","the","arms","observed","in","the","data",".","This","transform","is","meant","to","be","used","with","ThompsonSampler",".","Choice","parameter","will","be","unordered","unless","config","[","`... | null | null | SearchSpaceToChoice | def __init__(
self,
search_space: Optional[SearchSpace] = None,
observations: Optional[List[Observation]] = None,
modelbridge: Optional[
"modelbridge_module.base.ModelBridge"
] = None,
config: Optional[TConfig] = None,
) -> None:
assert (
search_space is not None
), "Sear... | ["def","__init__","(","self",",","search_space",":","Optional","[","SearchSpace","]","=","None",",","observations",":","Optional","[","List","[","Observation","]","]","=","None",",","modelbridge",":","Optional","[","``","modelbridge_module.base.ModelBridge","''","]","=","None",",","config",":","Optional","[","TConfig",... | 35 | 63 | null | search_space_to_choice.py | Ax/ax/modelbridge/transforms/search_space_to_choice.py | from typing import List, Optional, TYPE_CHECKING
from ax.core.arm import Arm
from ax.core.observation import Observation, ObservationFeatures
from ax.core.parameter import ChoiceParameter, FixedParameter, ParameterType
from ax.core.search_space import RobustSearchSpace, SearchSpace
from ax.exceptions.core import Unsupp... | 15 | 1 | 9 | 0 | 1 | 4 | 1 | Use image node_id 1 to create a new SearchSpaceToChoice object from inherited base classes: Transform with example: obj = SearchSpaceToChoice(search_space, observations, modelbridge, config) | 190 | node_id 1 | 9,096 |
cs_diff | global | null | false | x,a,b,period,_cache | null | null | null | null | convolve,unknown,int,unknown | def cs_diff(x, a, b, period=None, _cache=_cache):
"""
Return (a,b)-cosh/sinh pseudo-derivative of a periodic sequence.
If ``x_j`` and ``y_j`` are Fourier coefficients of periodic functions x
and y, respectively, then::
y_j = -sqrt(-1)*cosh(j*a*2*pi/period)/sinh(j*b*2*pi/period) * x_j
y_0 =... | ["def","cs_diff","(","x",",","a",",","b",",","period=None",",","_cache=_cache",")",":","``","''","''","Return","(","a",",","b",")","-cosh\/sinh","pseudo-derivative","of","a","periodic","sequence",".","If","``","x_j","``","and","``","y_j","``","are","Fourier","coefficients","of","periodic","functions","x","and","y",",",... | 282 | 333 | null | pseudo_diffs.py | catboost/contrib/python/scipy/py2/scipy/fftpack/pseudo_diffs.py | from __future__ import division, print_function, absolute_import
from numpy import pi, asarray, sin, cos, sinh, cosh, tanh, iscomplexobj
from .None import convolve
from scipy.fftpack.basic import _datacopied
import atexit | 15 | null | 5 | 10 | null | null | null | Use image node_id 6 for calling a global function with example usage: cs_diff(x, a, b, period, _cache) and returns: convolve, unknown, int, unknown | 147 | node_id 6 | 523,402 |
hilbert | global | null | false | x,_cache | null | null | null | null | convolve,unknown,int,int,unknown | def hilbert(x, _cache=_cache):
"""
Return Hilbert transform of a periodic sequence x.
If x_j and y_j are Fourier coefficients of periodic functions x
and y, respectively, then::
y_j = sqrt(-1)*sign(j) * x_j
y_0 = 0
Parameters
----------
x : array_like
The input array, ... | ["def","hilbert","(","x",",","_cache=_cache",")",":","``","''","''","Return","Hilbert","transform","of","a","periodic","sequence","x",".","If","x_j","and","y_j","are","Fourier","coefficients","of","periodic","functions","x","and","y",",","respectively",",","then",":",":","y_j","=","sqrt","(","-1",")","*","sign","(","j"... | 201 | 259 | null | pseudo_diffs.py | catboost/contrib/python/scipy/py2/scipy/fftpack/pseudo_diffs.py | from __future__ import division, print_function, absolute_import
from numpy import pi, asarray, sin, cos, sinh, cosh, tanh, iscomplexobj
from .None import convolve
from scipy.fftpack.basic import _datacopied
import atexit | 15 | null | 5 | 10 | null | null | null | Use image node_id 4 for calling a global function with example usage: hilbert(x, _cache) and returns: convolve, unknown, int, int, unknown | 138 | node_id 4 | 523,400 |
price | InterestRateSwap | null | true | self,valuation_date,market,model,pricing_context,name | Represents a batch of Interest Rate Swaps (IRS).
An Interest rate swap (IRS) is a contract between two counterparties for an
exchange of a series of payments over a period of time. The payments are made
periodically (for example quarterly or semi-annually) where the last payment
is made at the maturity (or termination... | ["Represents","a","batch","of","Interest","Rate","Swaps","(","IRS",")",".","An","Interest","rate","swap","(","IRS",")","is","a","contract","between","two","counterparties","for","an","exchange","of","a","series","of","payments","over","a","period","of","time",".","The","payments","are","made","periodically","(","for","... | Returns the present value of the instrument on the valuation date.
Args:
valuation_date: A scalar `DateTensor` specifying the date on which
valuation is being desired.
market: A namedtuple of type `InterestRateMarket` which contains the
necessary information for pricing the interest rate swap.
model: Res... | ["Returns","the","present","value","of","the","instrument","on","the","valuation","date",".","Args",":","valuation_date",":","A","scalar","`","DateTensor","`","specifying","the","date","on","which","valuation","is","being","desired",".","market",":","A","namedtuple","of","type","`","InterestRateMarket","`","which","con... | unknown | def price(
self,
valuation_date,
market,
model=None,
pricing_context=None,
name=None,
):
"""Returns the present value of the instrument on the valuation date.
Args:
valuation_date: A scalar `DateTensor` specifying the date on which
valuation is being desired.
market:... | ["def","price","(","self",",","valuation_date",",","market",",","model=None",",","pricing_context=None",",","name=None",",",")",":","``","''","''","Returns","the","present","value","of","the","instrument","on","the","valuation","date",".","Args",":","valuation_date",":","A","scalar","`","DateTensor","`","specifying","t... | 213 | 239 | null | interest_rate_swap.py | tf-quant-finance/tf_quant_finance/experimental/instruments/interest_rate_swap.py | import tensorflow.compat.v2
from tf_quant_finance import datetime
from tf_quant_finance.experimental.instruments import cashflow_stream
from tf_quant_finance.experimental.instruments import rates_common | 15 | 1 | 4 | 0 | 0 | 10 | null | Use image node_id 2 for calling the InterestRateSwap obj's underlying member method code with example usage: obj.price(valuation_date, market, model, pricing_context, name) and returns: unknown | 193 | node_id 2 | 2,191,435 |
create_attn | global | null | false | attn_type,channels | null | null | null | null | None,module_cls | def create_attn(attn_type, channels, **kwargs):
module_cls = get_attn(attn_type)
if module_cls is not None:
# NOTE: it's expected the first (positional) argument of all attention layers is the # input channels
return module_cls(channels, **kwargs)
return None
| ["def","create_attn","(","attn_type",",","channels",",","*","*","kwargs",")",":","module_cls","=","get_attn","(","attn_type",")","if","module_cls","is","not","None",":","#","NOTE",":","it","'s","expected","the","first","(","positional",")","argument","of","all","attention","layers","is","the","#","input","channels","re... | 84 | 89 | null | create_attn.py | pytorch-image-models/timm/layers/create_attn.py | import torch
from functools import partial
from .bottleneck_attn import BottleneckAttn
from .cbam import CbamModule, LightCbamModule
from .eca import EcaModule, CecaModule
from .gather_excite import GatherExcite
from .global_context import GlobalContext
from .halo_attn import HaloAttn
from .lambda_layer import LambdaLa... | 15 | null | 13 | 2 | null | null | null | Use image node_id 2 for calling a global function with example usage: create_attn(attn_type, channels) and returns: None, module_cls | 132 | node_id 2 | 1,692,280 |
test_unstructured | TestRetrieveUtils | null | true | self | null | null | null | null | null | def test_unstructured(self):
pdf_file_path = os.path.join(test_dir, "example.pdf")
txt_file_path = os.path.join(test_dir, "example.txt")
word_file_path = os.path.join(test_dir, "example.docx")
chunks = split_files_to_chunks(
[pdf_file_path, txt_file_path, word_file_path]
)
assert all(
... | ["def","test_unstructured","(","self",")",":","pdf_file_path","=","os.path.join","(","test_dir",",","``","example.pdf","''",")","txt_file_path","=","os.path.join","(","test_dir",",","``","example.txt","''",")","word_file_path","=","os.path.join","(","test_dir",",","``","example.docx","''",")","chunks","=","split_files_... | 226 | 234 | null | test_retrieve_utils.py | autogen/test/test_retrieve_utils.py | import pytest
import os | 15 | 1 | 2 | 0 | 0 | 12 | null | Use image node_id 12 for calling the TestRetrieveUtils obj's underlying member method code with example usage: obj.test_unstructured() without return types | 155 | node_id 12 | 319,457 |
on | TextLogger | NullLogger | true | self | null | null | null | null | True | def on(self):
return True
| ["def","on","(","self",")",":","return","True"] | 45 | 46 | null | logger.py | turicreate/src/external/boost/boost_1_68_0/tools/build/src/util/logger.py | import sys | 15 | 2 | 1 | 0 | 1 | 4 | 1 | Use image node_id 4 for calling the TextLogger obj's underlying member method code with example usage: obj.on() and returns: True | 129 | node_id 4 | 2,276,657 |
normalize | ImageGPTFeatureExtractor | FeatureExtractionMixin,ImageFeatureExtractionMixin | true | self,image | Constructs an ImageGPT feature extractor. This feature extractor can be used to resize images to a smaller
resolution (such as 32x32 or 64x64), normalize them and finally color quantize them to obtain sequences of "pixel
values" (color clusters).
This feature extractor inherits from [`FeatureExtractionMixin`] which co... | ["Constructs","an","ImageGPT","feature","extractor",".","This","feature","extractor","can","be","used","to","resize","images","to","a","smaller","resolution","(","such","as","32x32","or","64x64",")",",","normalize","them","and","finally","color","quantize","them","to","obtain","sequences","of","``","pixel","values","''... | Normalizes `image` into the range -1 to +1.
Args:
image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
The image to normalize.
Returns:
`np.ndarray`: The normalized image. | ["Normalizes","`","image","`","into","the","range","-1","to","+1",".","Args",":","image","(","`","PIL.Image.Image","`","or","`","np.ndarray","`","or","`","torch.Tensor","`",")",":","The","image","to","normalize",".","Returns",":","`","np.ndarray","`",":","The","normalized","image","."] | unknown | def normalize(self, image):
"""
Normalizes `image` into the range -1 to +1.
Args:
image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
The image to normalize.
Returns:
`np.ndarray`: The normalized image.
"""
image = self.to_numpy_array(
image, rescal... | ["def","normalize","(","self",",","image",")",":","``","''","''","Normalizes","`","image","`","into","the","range","-1","to","+1",".","Args",":","image","(","`","PIL.Image.Image","`","or","`","np.ndarray","`","or","`","torch.Tensor","`",")",":","The","image","to","normalize",".","Returns",":","`","np.ndarray","`",":","... | 86 | 99 | null | feature_extraction_imagegpt.py | H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/models/imagegpt/feature_extraction_imagegpt.py | from typing import List, Optional, Union
import numpy
from PIL import Image
from transformers.image_utils import PILImageResampling
from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin
from ...image_utils import ImageFeatureExtractionMixin, is_torch_tensor
from ...utils import TensorType, loggin... | 15 | 1 | 7 | 2 | 2 | 3 | 2 | Use image node_id 2 for calling the ImageGPTFeatureExtractor obj's underlying member method code with example usage: obj.normalize(image) and returns: unknown | 158 | node_id 2 | 95,363 |
test_retrieve_utils | TestRetrieveUtils | null | true | self | null | null | null | null | null | def test_retrieve_utils(self):
client = chromadb.PersistentClient(path="/tmp/chromadb")
create_vector_db_from_dir(
dir_path="./website/docs",
client=client,
collection_name="autogen-docs",
custom_text_types=["txt", "md", "rtf", "rst"],
get_or_create=True,
)
result... | ["def","test_retrieve_utils","(","self",")",":","client","=","chromadb.PersistentClient","(","path=","''","\/tmp\/chromadb","''",")","create_vector_db_from_dir","(","dir_path=","''",".\/website\/docs","''",",","client=client",",","collection_name=","''","autogen-docs","''",",","custom_text_types=","[","``","txt","''","... | 201 | 220 | null | test_retrieve_utils.py | autogen/test/test_retrieve_utils.py | import pytest
import os | 15 | 1 | 2 | 0 | 0 | 12 | null | Use image node_id 11 for calling the TestRetrieveUtils obj's underlying member method code with example usage: obj.test_retrieve_utils() without return types | 157 | node_id 11 | 319,456 |
_maximum_given_samples | global | null | false | f,pts,map | null | null | null | null | max | def _maximum_given_samples(f, pts, map=None):
"""
use given sample pts to calculate maximum for function f
Inputs:
f -- a function that returns a single value, given a list of inputs
pts -- a list of sample points
map -- the mapping function [Default is builtins.map]"""
if map i... | ["def","_maximum_given_samples","(","f",",","pts",",","map=None",")",":","``","''","''","use","given","sample","pts","to","calculate","maximum","for","function","f","Inputs",":","f","--","a","function","that","returns","a","single","value",",","given","a","list","of","inputs","pts","--","a","list","of","sample","points... | 226 | 238 | null | samples.py | mystic/mystic/math/samples.py | 15 | null | 0 | 15 | null | null | null | Use image node_id 11 for calling a global function with example usage: _maximum_given_samples(f, pts, map) and returns: max | 123 | node_id 11 | 1,407,031 | |
test_custom_text_split_function | TestRetrieveUtils | null | true | self | null | null | null | null | list | def test_custom_text_split_function(self):
def custom_text_split_function(text):
return [text[: len(text) // 2], text[len(text) // 2 :]]
db_path = "/tmp/test_retrieve_utils_chromadb.db"
client = chromadb.PersistentClient(path=db_path)
create_vector_db_from_dir(
os.path.join(test_dir, "e... | ["def","test_custom_text_split_function","(","self",")",":","def","custom_text_split_function","(","text",")",":","return","[","text","[",":","len","(","text",")","\/\/","2","]",",","text","[","len","(","text",")","\/\/","2",":","]","]","db_path","=","``","\/tmp\/test_retrieve_utils_chromadb.db","''","client","=","chro... | 181 | 199 | null | test_retrieve_utils.py | autogen/test/test_retrieve_utils.py | import pytest
import os | 15 | 1 | 2 | 0 | 0 | 12 | null | Use image node_id 10 for calling the TestRetrieveUtils obj's underlying member method code with example usage: obj.test_custom_text_split_function() and returns: list | 166 | node_id 10 | 319,455 |
_ptp_given_samples | global | null | false | f,pts,map | null | null | null | null | ptp | def _ptp_given_samples(f, pts, map=None):
"""
use given sample pts to calculate spread for function f
Inputs:
f -- a function that returns a single value, given a list of inputs
pts -- a list of sample points
map -- the mapping function [Default is builtins.map]"""
if map is Non... | ["def","_ptp_given_samples","(","f",",","pts",",","map=None",")",":","``","''","''","use","given","sample","pts","to","calculate","spread","for","function","f","Inputs",":","f","--","a","function","that","returns","a","single","value",",","given","a","list","of","inputs","pts","--","a","list","of","sample","points","ma... | 241 | 253 | null | samples.py | mystic/mystic/math/samples.py | 15 | null | 0 | 15 | null | null | null | Use image node_id 12 for calling a global function with example usage: _ptp_given_samples(f, pts, map) and returns: ptp | 119 | node_id 12 | 1,407,032 | |
test_custom_vector_db | TestRetrieveUtils | null | true | self | null | null | null | null | dict | def test_custom_vector_db(self):
try:
import lancedb
except ImportError:
return
from autogen.agentchat.contrib.retrieve_user_proxy_agent import (
RetrieveUserProxyAgent,
)
db_path = "/tmp/lancedb"
def create_lancedb():
db = lancedb.connect(db_path)
data ... | ["def","test_custom_vector_db","(","self",")",":","try",":","import","lancedb","except","ImportError",":","return","from","autogen.agentchat.contrib.retrieve_user_proxy_agent","import","(","RetrieveUserProxyAgent",",",")","db_path","=","``","\/tmp\/lancedb","''","def","create_lancedb","(",")",":","db","=","lancedb.conn... | 117 | 179 | null | test_retrieve_utils.py | autogen/test/test_retrieve_utils.py | import pytest
import os | 15 | 1 | 2 | 0 | 0 | 12 | null | Use image node_id 9 for calling the TestRetrieveUtils obj's underlying member method code with example usage: obj.test_custom_vector_db() and returns: dict | 155 | node_id 9 | 319,454 |
test_query_vector_db | TestRetrieveUtils | null | true | self | null | null | null | null | null | def test_query_vector_db(self):
db_path = "/tmp/test_retrieve_utils_chromadb.db"
if os.path.exists(db_path):
client = chromadb.PersistentClient(path=db_path)
else: # If the database does not exist, create it first
client = chromadb.PersistentClient(path=db_path)
create_vector_db_fro... | ["def","test_query_vector_db","(","self",")",":","db_path","=","``","\/tmp\/test_retrieve_utils_chromadb.db","''","if","os.path.exists","(","db_path",")",":","client","=","chromadb.PersistentClient","(","path=db_path",")","else",":","#","If","the","database","does","not","exist",",","create","it","first","client","=","... | 106 | 115 | null | test_retrieve_utils.py | autogen/test/test_retrieve_utils.py | import pytest
import os | 15 | 1 | 2 | 0 | 0 | 12 | null | Use image node_id 8 for calling the TestRetrieveUtils obj's underlying member method code with example usage: obj.test_query_vector_db() without return types | 157 | node_id 8 | 319,453 |
get_boxes | global | null | false | model,val_set,num_images,image_dir,score_threshold | null | null | null | null | all_boxes, all_gt_boxes | def get_boxes(
model, val_set, num_images=0, image_dir=None, score_threshold=0.6
):
n = 0
all_boxes = []
all_gt_boxes = []
with tqdm(total=val_set.ndata) as pbar: # progress bar
for img, (
gt_boxes,
gt_classes,
num_gt_boxes,
difficult,
... | ["def","get_boxes","(","model",",","val_set",",","num_images=0",",","image_dir=None",",","score_threshold=0.6",")",":","n","=","0","all_boxes","=","[","]","all_gt_boxes","=","[","]","with","tqdm","(","total=val_set.ndata",")","as","pbar",":","#","progress","bar","for","img",",","(","gt_boxes",",","gt_classes",",","num_... | 41 | 83 | null | inference.py | neon/examples/ssd/inference.py | from neon.backends import gen_backend
from neon.util.argparser import NeonArgparser
from neon.models.model import Model
import numpy
from ssd_container import SSD
from util.voc_eval import voc_eval
from tqdm import tqdm
import json
from ssd_dataloader import build_dataloader
import pickle
import os
from sys import exit... | 15 | null | 14 | 1 | null | null | null | Use image node_id 1 for calling a global function with example usage: get_boxes(model, val_set, num_images, image_dir, score_threshold) and returns: all_boxes, all_gt_boxes | 173 | node_id 1 | 1,411,035 |
test_create_vector_db_from_dir | TestRetrieveUtils | null | true | self | null | null | null | null | null | def test_create_vector_db_from_dir(self):
db_path = "/tmp/test_retrieve_utils_chromadb.db"
if os.path.exists(db_path):
client = chromadb.PersistentClient(path=db_path)
else:
client = chromadb.PersistentClient(path=db_path)
create_vector_db_from_dir(test_dir, client=client)
asser... | ["def","test_create_vector_db_from_dir","(","self",")",":","db_path","=","``","\/tmp\/test_retrieve_utils_chromadb.db","''","if","os.path.exists","(","db_path",")",":","client","=","chromadb.PersistentClient","(","path=db_path",")","else",":","client","=","chromadb.PersistentClient","(","path=db_path",")","create_vecto... | 96 | 104 | null | test_retrieve_utils.py | autogen/test/test_retrieve_utils.py | import pytest
import os | 15 | 1 | 2 | 0 | 0 | 12 | null | Use image node_id 7 for calling the TestRetrieveUtils obj's underlying member method code with example usage: obj.test_create_vector_db_from_dir() without return types | 167 | node_id 7 | 319,452 |
test_is_url | TestRetrieveUtils | null | true | self | null | null | null | null | null | def test_is_url(self):
assert is_url("https://www.example.com")
assert not is_url("not_a_url")
| ["def","test_is_url","(","self",")",":","assert","is_url","(","``","https",":","\/\/www.example.com","''",")","assert","not","is_url","(","``","not_a_url","''",")"] | 92 | 94 | null | test_retrieve_utils.py | autogen/test/test_retrieve_utils.py | import pytest
import os | 15 | 1 | 2 | 0 | 0 | 12 | null | Use image node_id 6 for calling the TestRetrieveUtils obj's underlying member method code with example usage: obj.test_is_url() without return types | 148 | node_id 6 | 319,451 |
test_download_all | TestDatasets | null | true | self | null | null | null | null | null | def test_download_all(self):
# This fixture requires INTERNET CONNECTION
# test_setup phase
download_all()
yield
| ["def","test_download_all","(","self",")",":","#","This","fixture","requires","INTERNET","CONNECTION","#","test_setup","phase","download_all","(",")","yield"] | 30 | 36 | null | test_data.py | scipy/scipy/datasets/tests/test_data.py | from scipy.datasets._registry import registry
from scipy.datasets._fetchers import data_fetcher
from scipy.datasets._utils import _clear_cache
from scipy.datasets import ascent, face, electrocardiogram, download_all
from numpy.testing import assert_equal, assert_almost_equal
import os
import pytest | 15 | 1 | 7 | 2 | 0 | 5 | null | Use image node_id 1 for calling the TestDatasets obj's underlying member method code with example usage: obj.test_download_all() without return types | 149 | node_id 1 | 1,884,887 |
difference | global | null | false | ctx,s,n | null | null | null | null | d | def difference(ctx, s, n):
r"""
Given a sequence `(s_k)` containing at least `n+1` items, returns the
`n`-th forward difference,
.. math ::
\Delta^n = \sum_{k=0}^{\infty} (-1)^{k+n} {n \choose k} s_k.
"""
n = int(n)
d = ctx.zero
b = (-1) ** (n & 1)
for k in xrange(n + 1):
... | ["def","difference","(","ctx",",","s",",","n",")",":","r","''","''","''","Given","a","sequence","`","(","s_k",")","`","containing","at","least","`","n+1","`","items",",","returns","the","`","n","`","-th","forward","difference",",","..","math",":",":","\\Delta^n","=","\\sum_","{","k=0","}","^","{","\\infty","}","(","-1"... | 14 | 29 | null | differentiation.py | catboost/contrib/python/mpmath/py3/mpmath/calculus/differentiation.py | from ..libmp.backend import xrange
from .calculus import defun | 15 | null | 2 | 13 | null | null | null | Use image node_id 1 for calling a global function with example usage: difference(ctx, s, n) and returns: d | 106 | node_id 1 | 407,212 |
test_existence_all | TestDatasets | null | true | self | null | null | null | null | null | def test_existence_all(self):
assert len(os.listdir(data_dir)) >= len(registry)
| ["def","test_existence_all","(","self",")",":","assert","len","(","os.listdir","(","data_dir",")",")",">","=","len","(","registry",")"] | 38 | 39 | null | test_data.py | scipy/scipy/datasets/tests/test_data.py | from scipy.datasets._registry import registry
from scipy.datasets._fetchers import data_fetcher
from scipy.datasets._utils import _clear_cache
from scipy.datasets import ascent, face, electrocardiogram, download_all
from numpy.testing import assert_equal, assert_almost_equal
import os
import pytest | 15 | 1 | 7 | 2 | 0 | 5 | null | Use image node_id 2 for calling the TestDatasets obj's underlying member method code with example usage: obj.test_existence_all() without return types | 150 | node_id 2 | 1,884,888 |
hsteps | global | null | false | ctx,f,x,n,prec | null | null | null | null | values, norm, workprec | def hsteps(ctx, f, x, n, prec, **options):
singular = options.get("singular")
addprec = options.get("addprec", 10)
direction = options.get("direction", 0)
workprec = (prec + 2 * addprec) * (n + 1)
orig = ctx.prec
try:
ctx.prec = workprec
h = options.get("h")
if h is None:... | ["def","hsteps","(","ctx",",","f",",","x",",","n",",","prec",",","*","*","options",")",":","singular","=","options.get","(","``","singular","''",")","addprec","=","options.get","(","``","addprec","''",",","10",")","direction","=","options.get","(","``","direction","''",",","0",")","workprec","=","(","prec","+","2","*",... | 31 | 64 | null | differentiation.py | catboost/contrib/python/mpmath/py3/mpmath/calculus/differentiation.py | from ..libmp.backend import xrange
from .calculus import defun | 15 | null | 2 | 13 | null | null | null | Use image node_id 2 for calling a global function with example usage: hsteps(ctx, f, x, n, prec) and returns: values, norm, workprec | 134 | node_id 2 | 407,213 |
diff | global | null | false | ctx,f,x,n | null | null | null | null | unknown,_partial_diff,f,unknown | def diff(ctx, f, x, n=1, **options):
r"""
Numerically computes the derivative of `f`, `f'(x)`, or generally for
an integer `n \ge 0`, the `n`-th derivative `f^{(n)}(x)`.
A few basic examples are::
>>> from mpmath import *
>>> mp.dps = 15; mp.pretty = True
>>> diff(lambda x: x**2... | ["def","diff","(","ctx",",","f",",","x",",","n=1",",","*","*","options",")",":","r","''","''","''","Numerically","computes","the","derivative","of","`","f","`",",","`","f","'","(","x",")","`",",","or","generally","for","an","integer","`","n","\\ge","0","`",",","the","`","n","`","-th","derivative","`","f^","{","(","n","... | 68 | 204 | null | differentiation.py | catboost/contrib/python/mpmath/py3/mpmath/calculus/differentiation.py | from ..libmp.backend import xrange
from .calculus import defun | 15 | null | 2 | 13 | null | null | null | Use image node_id 3 for calling a global function with example usage: diff(ctx, f, x, n) and returns: unknown, _partial_diff, f, unknown | 136 | node_id 3 | 407,214 |
test_extra_tags_paddle_autolog | global | null | false | null | null | null | null | null | def test_extra_tags_paddle_autolog():
mlflow.paddle.autolog(extra_tags={"test_tag": "paddle_autolog"})
train_model()
run = mlflow.last_active_run()
assert run.data.tags["test_tag"] == "paddle_autolog"
assert (
run.data.tags[mlflow.utils.mlflow_tags.MLFLOW_AUTOLOGGING]
== "paddle"
... | ["def","test_extra_tags_paddle_autolog","(",")",":","mlflow.paddle.autolog","(","extra_tags=","{","``","test_tag","''",":","``","paddle_autolog","''","}",")","train_model","(",")","run","=","mlflow.last_active_run","(",")","assert","run.data.tags","[","``","test_tag","''","]","==","``","paddle_autolog","''","assert","(... | 107 | 113 | null | test_paddle_autolog.py | mlflow/tests/paddle/test_paddle_autolog.py | import paddle
import pytest
import mlflow
from mlflow import MlflowClient | 15 | null | 4 | 7 | null | null | null | Use image node_id 7 for calling a global function with example usage: test_extra_tags_paddle_autolog() without return types | 123 | node_id 7 | 1,356,432 | |
_partial_diff | global | null | false | ctx,f,xs,orders,options | null | null | null | null | _partial_diff,f,f,ctx,f | def _partial_diff(ctx, f, xs, orders, options):
if not orders:
return f()
if not sum(orders):
return f(*xs)
i = 0
for i in range(len(orders)):
if orders[i]:
break
order = orders[i]
def fdiff_inner(*f_args):
def inner(t):
return f(*(f_args[... | ["def","_partial_diff","(","ctx",",","f",",","xs",",","orders",",","options",")",":","if","not","orders",":","return","f","(",")","if","not","sum","(","orders",")",":","return","f","(","*","xs",")","i","=","0","for","i","in","range","(","len","(","orders",")",")",":","if","orders","[","i","]",":","break","order","=","o... | 206 | 221 | null | differentiation.py | catboost/contrib/python/mpmath/py3/mpmath/calculus/differentiation.py | from ..libmp.backend import xrange
from .calculus import defun | 15 | null | 2 | 13 | null | null | null | Use image node_id 4 for calling a global function with example usage: _partial_diff(ctx, f, xs, orders, options) and returns: _partial_diff, f, f, ctx, f | 153 | node_id 4 | 407,215 |
__init__ | AudioInput | null | true | self,channels_first,channels,sample_rate,batch_size | Create audio batch. | ["Create","audio","batch","."] | null | null | AudioInput | def __init__(
self, channels_first, channels, sample_rate=44100, batch_size=2
):
self.channels_first = channels_first
self.channels = channels
self.sample_rate = sample_rate
self.batch_size = batch_size
| ["def","__init__","(","self",",","channels_first",",","channels",",","sample_rate=44100",",","batch_size=2",")",":","self.channels_first","=","channels_first","self.channels","=","channels","self.sample_rate","=","sample_rate","self.batch_size","=","batch_size"] | 38 | 42 | null | test_mp3_compression_pytorch.py | adversarial-robustness-toolbox/tests/defences/preprocessor/test_mp3_compression_pytorch.py | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import numpy
import pytest
from numpy.testing import assert_array_equal
from art.defences.preprocessor import Mp3CompressionPyTorch
from tests.utils import ARTTestException | 15 | 1 | 7 | 5 | 0 | 2 | null | Use image node_id 1 to create a new AudioInput object with example: obj = AudioInput(channels_first, channels, sample_rate, batch_size) | 136 | node_id 1 | 235,203 |
test_autolog_registering_model | global | null | false | null | null | null | null | null | def test_autolog_registering_model():
registered_model_name = "test_autolog_registered_model"
mlflow.paddle.autolog(registered_model_name=registered_model_name)
with mlflow.start_run():
train_model()
registered_model = MlflowClient().get_registered_model(
registered_model_name
... | ["def","test_autolog_registering_model","(",")",":","registered_model_name","=","``","test_autolog_registered_model","''","mlflow.paddle.autolog","(","registered_model_name=registered_model_name",")","with","mlflow.start_run","(",")",":","train_model","(",")","registered_model","=","MlflowClient","(",")",".get_register... | 96 | 104 | null | test_paddle_autolog.py | mlflow/tests/paddle/test_paddle_autolog.py | import paddle
import pytest
import mlflow
from mlflow import MlflowClient | 15 | null | 4 | 7 | null | null | null | Use image node_id 6 for calling a global function with example usage: test_autolog_registering_model() without return types | 123 | node_id 6 | 1,356,431 | |
get_data | AudioInput | null | true | self | Create audio batch. | ["Create","audio","batch","."] | null | null | np | def get_data(self):
if self.channels_first:
shape = (self.batch_size, self.channels, self.sample_rate)
else:
shape = (self.batch_size, self.sample_rate, self.channels)
return np.zeros(shape, dtype=np.int16)
| ["def","get_data","(","self",")",":","if","self.channels_first",":","shape","=","(","self.batch_size",",","self.channels",",","self.sample_rate",")","else",":","shape","=","(","self.batch_size",",","self.sample_rate",",","self.channels",")","return","np.zeros","(","shape",",","dtype=np.int16",")"] | 44 | 49 | null | test_mp3_compression_pytorch.py | adversarial-robustness-toolbox/tests/defences/preprocessor/test_mp3_compression_pytorch.py | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import numpy
import pytest
from numpy.testing import assert_array_equal
from art.defences.preprocessor import Mp3CompressionPyTorch
from tests.utils import ARTTestException | 15 | 1 | 7 | 5 | 0 | 2 | null | Use image node_id 2 for calling the AudioInput obj's underlying member method code with example usage: obj.get_data() and returns: np | 133 | node_id 2 | 235,204 |
audio_batch | global | null | false | request,channels_first | null | null | null | null | test_input, test_output, audio_input | def audio_batch(request, channels_first):
"""
Audio fixtures of shape `(batch_size, channels, samples)` or `(batch_size, samples, channels)`.
"""
channels = request.param
audio_input = AudioInput(channels_first, channels)
test_input = audio_input.get_data()
test_output = test_input.copy()
... | ["def","audio_batch","(","request",",","channels_first",")",":","``","''","''","Audio","fixtures","of","shape","`","(","batch_size",",","channels",",","samples",")","`","or","`","(","batch_size",",","samples",",","channels",")","`",".","``","''","''","channels","=","request.param","audio_input","=","AudioInput","(","ch... | 53 | 61 | null | test_mp3_compression_pytorch.py | adversarial-robustness-toolbox/tests/defences/preprocessor/test_mp3_compression_pytorch.py | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import numpy
import pytest
from numpy.testing import assert_array_equal
from art.defences.preprocessor import Mp3CompressionPyTorch
from tests.utils import ARTTestException | 15 | null | 7 | 5 | null | null | null | Use image node_id 1 for calling a global function with example usage: audio_batch(request, channels_first) and returns: test_input, test_output, audio_input | 158 | node_id 1 | 235,205 |
log | NullLogger | null | true | self,source_name | null | null | null | null | null | def log(self, source_name, *args):
if self.on() and self.interesting(source_name):
self.do_log(self.indent_)
for i in args:
self.do_log(i)
self.do_log("\n")
| ["def","log","(","self",",","source_name",",","*","args",")",":","if","self.on","(",")","and","self.interesting","(","source_name",")",":","self.do_log","(","self.indent_",")","for","i","in","args",":","self.do_log","(","i",")","self.do_log","(","``","\\n","''",")"] | 11 | 16 | null | logger.py | turicreate/src/external/boost/boost_1_68_0/tools/build/src/util/logger.py | import sys | 15 | 2 | 1 | 0 | 1 | 7 | null | Use image node_id 2 for calling the NullLogger obj's underlying member method code with example usage: obj.log(source_name) without return types | 144 | node_id 2 | 2,276,648 |
increase_indent | NullLogger | null | true | self | null | null | null | null | null | def increase_indent(self):
if self.on():
self.indent_ += " "
| ["def","increase_indent","(","self",")",":","if","self.on","(",")",":","self.indent_","+=","``","``"] | 18 | 20 | null | logger.py | turicreate/src/external/boost/boost_1_68_0/tools/build/src/util/logger.py | import sys | 15 | 2 | 1 | 0 | 1 | 7 | null | Use image node_id 3 for calling the NullLogger obj's underlying member method code with example usage: obj.increase_indent() without return types | 145 | node_id 3 | 2,276,649 |
_pof_given_samples | global | null | false | f,pts,map | null | null | null | null | pof | def _pof_given_samples(f, pts, map=None):
"""
use given sample pts to calculate probability of failure for function f
Inputs:
f -- a function that returns True for 'success' and False for 'failure'
pts -- a list of sample points
map -- the mapping function [Default is builtins.map]"... | ["def","_pof_given_samples","(","f",",","pts",",","map=None",")",":","``","''","''","use","given","sample","pts","to","calculate","probability","of","failure","for","function","f","Inputs",":","f","--","a","function","that","returns","True","for","'success","'","and","False","for","'failure'","pts","--","a","list","of"... | 164 | 178 | null | samples.py | mystic/mystic/math/samples.py | 15 | null | 0 | 15 | null | null | null | Use image node_id 7 for calling a global function with example usage: _pof_given_samples(f, pts, map) and returns: pof | 118 | node_id 7 | 1,407,027 | |
_minimum_given_samples | global | null | false | f,pts,map | null | null | null | null | min | def _minimum_given_samples(f, pts, map=None):
"""
use given sample pts to calculate minimum for function f
Inputs:
f -- a function that returns a single value, given a list of inputs
pts -- a list of sample points
map -- the mapping function [Default is builtins.map]"""
if map i... | ["def","_minimum_given_samples","(","f",",","pts",",","map=None",")",":","``","''","''","use","given","sample","pts","to","calculate","minimum","for","function","f","Inputs",":","f","--","a","function","that","returns","a","single","value",",","given","a","list","of","inputs","pts","--","a","list","of","sample","points... | 181 | 193 | null | samples.py | mystic/mystic/math/samples.py | 15 | null | 0 | 15 | null | null | null | Use image node_id 8 for calling a global function with example usage: _minimum_given_samples(f, pts, map) and returns: min | 122 | node_id 8 | 1,407,028 | |
to_json_file | Config | null | true | self,json_file | Hold some config params to control generation and report procedure. | ["Hold","some","config","params","to","control","generation","and","report","procedure","."] | Serializes this instance to a JSON file. | ["Serializes","this","instance","to","a","JSON","file","."] | null | def to_json_file(self, json_file):
r"""
Serializes this instance to a JSON file.
"""
with open(json_file, "w+", encoding="utf-8") as writer:
json.dump(
self.to_dict(), writer, indent=2, ensure_ascii=False
)
| ["def","to_json_file","(","self",",","json_file",")",":","r","''","''","''","Serializes","this","instance","to","a","JSON","file.","``","''","''","with","open","(","json_file",",","``","w+","''",",","encoding=","''","utf-8","''",")","as","writer",":","json.dump","(","self.to_dict","(",")",",","writer",",","indent=2",",... | 233 | 244 | null | config.py | textflint/textflint/input/config/config.py | import os
import six
import json
import copy
from ...common.utils.logger import logger
from ...common.settings import NLP_TASK_MAP, ALLOWED_TRANSFORMATIONS, TRANSFORM_FIELDS, ALLOWED_SUBPOPULATIONS, ALLOWED_VALIDATORS, ALLOWED_cn_TRANSFORMATIONS | 15 | 1 | 6 | 0 | 0 | 8 | null | Use image node_id 8 for calling the Config obj's underlying member method code with example usage: obj.to_json_file(json_file) without return types | 147 | node_id 8 | 2,188,355 |
_expectation_given_samples | global | null | false | f,pts,map | null | null | null | null | mean | def _expectation_given_samples(f, pts, map=None):
"""
use given sample pts to calculate expected value for function f
Inputs:
f -- a function that returns a single value, given a list of inputs
pts -- a list of sample points
map -- the mapping function [Default is builtins.map]"""
... | ["def","_expectation_given_samples","(","f",",","pts",",","map=None",")",":","``","''","''","use","given","sample","pts","to","calculate","expected","value","for","function","f","Inputs",":","f","--","a","function","that","returns","a","single","value",",","given","a","list","of","inputs","pts","--","a","list","of","sa... | 196 | 208 | null | samples.py | mystic/mystic/math/samples.py | 15 | null | 0 | 15 | null | null | null | Use image node_id 9 for calling a global function with example usage: _expectation_given_samples(f, pts, map) and returns: mean | 127 | node_id 9 | 1,407,029 | |
test_import_vispy | global | null | false | null | null | null | null | null | def test_import_vispy():
"""Importing vispy should only pull in other vispy.util submodule."""
modnames = loaded_vispy_modules("vispy", 2)
assert_equal(modnames, set(_min_modules))
| ["def","test_import_vispy","(",")",":","``","''","''","Importing","vispy","should","only","pull","in","other","vispy.util","submodule",".","''","''","''","modnames","=","loaded_vispy_modules","(","``","vispy","''",",","2",")","assert_equal","(","modnames",",","set","(","_min_modules",")",")"] | 58 | 61 | null | test_import.py | vispy/vispy/util/tests/test_import.py | import sys
import os
from vispy.testing import assert_in, assert_not_in, requires_pyopengl, run_tests_if_main, assert_equal
from vispy.util import run_subprocess
import vispy | 15 | null | 5 | 10 | null | null | null | Use image node_id 3 for calling a global function with example usage: test_import_vispy() without return types | 110 | node_id 3 | 2,320,261 | |
test_import_vispy_util | global | null | false | null | null | null | null | null | def test_import_vispy_util():
"""Importing vispy.util should not pull in other vispy submodules."""
modnames = loaded_vispy_modules("vispy.util", 2)
assert_equal(modnames, set(_min_modules))
| ["def","test_import_vispy_util","(",")",":","``","''","''","Importing","vispy.util","should","not","pull","in","other","vispy","submodules",".","''","''","''","modnames","=","loaded_vispy_modules","(","``","vispy.util","''",",","2",")","assert_equal","(","modnames",",","set","(","_min_modules",")",")"] | 64 | 67 | null | test_import.py | vispy/vispy/util/tests/test_import.py | import sys
import os
from vispy.testing import assert_in, assert_not_in, requires_pyopengl, run_tests_if_main, assert_equal
from vispy.util import run_subprocess
import vispy | 15 | null | 5 | 10 | null | null | null | Use image node_id 4 for calling a global function with example usage: test_import_vispy_util() without return types | 115 | node_id 4 | 2,320,262 | |
_variance_given_samples | global | null | false | f,pts,map | null | null | null | null | var | def _variance_given_samples(f, pts, map=None):
"""
use given sample pts to calculate expected variance for function f
Inputs:
f -- a function that returns a single value, given a list of inputs
pts -- a list of sample points
map -- the mapping function [Default is builtins.map]"""
... | ["def","_variance_given_samples","(","f",",","pts",",","map=None",")",":","``","''","''","use","given","sample","pts","to","calculate","expected","variance","for","function","f","Inputs",":","f","--","a","function","that","returns","a","single","value",",","given","a","list","of","inputs","pts","--","a","list","of","sa... | 211 | 223 | null | samples.py | mystic/mystic/math/samples.py | 15 | null | 0 | 15 | null | null | null | Use image node_id 10 for calling a global function with example usage: _variance_given_samples(f, pts, map) and returns: var | 124 | node_id 10 | 1,407,030 | |
__init__ | InterestRateSwap | null | true | self,start_date,maturity_date,pay_leg,receive_leg,holiday_calendar,dtype,name | Represents a batch of Interest Rate Swaps (IRS).
An Interest rate swap (IRS) is a contract between two counterparties for an
exchange of a series of payments over a period of time. The payments are made
periodically (for example quarterly or semi-annually) where the last payment
is made at the maturity (or termination... | ["Represents","a","batch","of","Interest","Rate","Swaps","(","IRS",")",".","An","Interest","rate","swap","(","IRS",")","is","a","contract","between","two","counterparties","for","an","exchange","of","a","series","of","payments","over","a","period","of","time",".","The","payments","are","made","periodically","(","for","... | Initialize a batch of IRS contracts.
Args:
start_date: A rank 1 `DateTensor` specifying the dates for the inception
(start of the accrual) of the swap contracts. The shape of the input
correspond to the number of instruments being created.
maturity_date: A rank 1 `DateTensor` specifying the maturity dates ... | ["Initialize","a","batch","of","IRS","contracts",".","Args",":","start_date",":","A","rank","1","`","DateTensor","`","specifying","the","dates","for","the","inception","(","start","of","the","accrual",")","of","the","swap","contracts",".","The","shape","of","the","input","correspond","to","the","number","of","instrumen... | InterestRateSwap | def __init__(
self,
start_date,
maturity_date,
pay_leg,
receive_leg,
holiday_calendar=None,
dtype=None,
name=None,
):
"""Initialize a batch of IRS contracts.
Args:
start_date: A rank 1 `DateTensor` specifying the dates for the inception
(start of the accrual) of th... | ["def","__init__","(","self",",","start_date",",","maturity_date",",","pay_leg",",","receive_leg",",","holiday_calendar=None",",","dtype=None",",","name=None",",",")",":","``","''","''","Initialize","a","batch","of","IRS","contracts",".","Args",":","start_date",":","A","rank","1","`","DateTensor","`","specifying","the"... | 156 | 211 | null | interest_rate_swap.py | tf-quant-finance/tf_quant_finance/experimental/instruments/interest_rate_swap.py | import tensorflow.compat.v2
from tf_quant_finance import datetime
from tf_quant_finance.experimental.instruments import cashflow_stream
from tf_quant_finance.experimental.instruments import rates_common | 15 | 1 | 4 | 0 | 0 | 10 | null | Use image node_id 1 to create a new InterestRateSwap object with example: obj = InterestRateSwap(start_date, maturity_date, pay_leg, receive_leg, holiday_calendar, dtype, name) | 177 | node_id 1 | 2,191,434 |
__call__ | ImageGPTFeatureExtractor | FeatureExtractionMixin,ImageFeatureExtractionMixin | true | self,images,return_tensors | Constructs an ImageGPT feature extractor. This feature extractor can be used to resize images to a smaller
resolution (such as 32x32 or 64x64), normalize them and finally color quantize them to obtain sequences of "pixel
values" (color clusters).
This feature extractor inherits from [`FeatureExtractionMixin`] which co... | ["Constructs","an","ImageGPT","feature","extractor",".","This","feature","extractor","can","be","used","to","resize","images","to","a","smaller","resolution","(","such","as","32x32","or","64x64",")",",","normalize","them","and","finally","color","quantize","them","to","obtain","sequences","of","``","pixel","values","''... | Main method to prepare for the model one or several image(s).
<Tip warning={true}>
NumPy arrays and PyTorch tensors are converted to PIL images when resizing, so the most efficient is to pass
PIL images.
</Tip>
Args:
images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndar... | ["Main","method","to","prepare","for","the","model","one","or","several","image","(","s",")",".","<","Tip","warning=","{","true","}",">","NumPy","arrays","and","PyTorch","tensors","are","converted","to","PIL","images","when","resizing",",","so","the","most","efficient","is","to","pass","PIL","images",".","<","\/Tip",">... | encoded_inputs | def __call__(
self,
images: Union[
Image.Image,
np.ndarray,
"torch.Tensor",
List[Image.Image],
List[np.ndarray],
List["torch.Tensor"], # noqa
],
return_tensors: Optional[Union[str, TensorType]] = None,
**kwargs,
) -> BatchFeature:
"""
Main met... | ["def","__call__","(","self",",","images",":","Union","[","Image.Image",",","np.ndarray",",","``","torch.Tensor","''",",","List","[","Image.Image","]",",","List","[","np.ndarray","]",",","List","[","``","torch.Tensor","''","]",",","#","noqa","]",",","return_tensors",":","Optional","[","Union","[","str",",","TensorType"... | 101 | 181 | null | feature_extraction_imagegpt.py | H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/models/imagegpt/feature_extraction_imagegpt.py | from typing import List, Optional, Union
import numpy
from PIL import Image
from transformers.image_utils import PILImageResampling
from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin
from ...image_utils import ImageFeatureExtractionMixin, is_torch_tensor
from ...utils import TensorType, loggin... | 15 | 1 | 7 | 2 | 2 | 3 | 2 | Use image node_id 3 for calling the ImageGPTFeatureExtractor obj's underlying member method code with example usage: obj.__call__(images, return_tensors) and returns: encoded_inputs | 181 | node_id 3 | 95,364 |
test_sample_rate_error | global | null | false | art_warning | null | null | null | null | null | def test_sample_rate_error(art_warning):
try:
exc_msg = "Sample rate be must a positive integer."
with pytest.raises(ValueError, match=exc_msg):
Mp3CompressionPyTorch(sample_rate=0)
except ARTTestException as e:
art_warning(e)
| ["def","test_sample_rate_error","(","art_warning",")",":","try",":","exc_msg","=","``","Sample","rate","be","must","a","positive","integer",".","''","with","pytest.raises","(","ValueError",",","match=exc_msg",")",":","Mp3CompressionPyTorch","(","sample_rate=0",")","except","ARTTestException","as","e",":","art_warning",... | 65 | 71 | null | test_mp3_compression_pytorch.py | adversarial-robustness-toolbox/tests/defences/preprocessor/test_mp3_compression_pytorch.py | from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import numpy
import pytest
from numpy.testing import assert_array_equal
from art.defences.preprocessor import Mp3CompressionPyTorch
from tests.utils import ARTTestException | 15 | null | 7 | 5 | null | null | null | Use image node_id 2 for calling a global function with example usage: test_sample_rate_error(art_warning) without return types | 126 | node_id 2 | 235,206 |
_mean_square_error | global | null | false | y,y_pred,w | null | null | null | null | np | def _mean_square_error(y, y_pred, w):
"""Calculate the mean square error."""
return np.average(((y_pred - y) ** 2), weights=w)
| ["def","_mean_square_error","(","y",",","y_pred",",","w",")",":","``","''","''","Calculate","the","mean","square","error",".","''","''","''","return","np.average","(","(","(","y_pred","-","y",")","*","*","2",")",",","weights=w",")"] | 130 | 132 | null | fitness.py | gplearn/gplearn/fitness.py | import numbers
import numpy
from joblib import wrap_non_picklable_objects
from scipy.stats import rankdata | 15 | null | 4 | 7 | null | null | null | Use image node_id 5 for calling a global function with example usage: _mean_square_error(y, y_pred, w) and returns: np | 118 | node_id 5 | 1,106,034 |
_root_mean_square_error | global | null | false | y,y_pred,w | null | null | null | null | np | def _root_mean_square_error(y, y_pred, w):
"""Calculate the root mean square error."""
return np.sqrt(np.average(((y_pred - y) ** 2), weights=w))
| ["def","_root_mean_square_error","(","y",",","y_pred",",","w",")",":","``","''","''","Calculate","the","root","mean","square","error",".","''","''","''","return","np.sqrt","(","np.average","(","(","(","y_pred","-","y",")","*","*","2",")",",","weights=w",")",")"] | 135 | 137 | null | fitness.py | gplearn/gplearn/fitness.py | import numbers
import numpy
from joblib import wrap_non_picklable_objects
from scipy.stats import rankdata | 15 | null | 4 | 7 | null | null | null | Use image node_id 6 for calling a global function with example usage: _root_mean_square_error(y, y_pred, w) and returns: np | 123 | node_id 6 | 1,106,035 |
decrease_indent | NullLogger | null | true | self | null | null | null | null | null | def decrease_indent(self):
if self.on() and len(self.indent_) > 4:
self.indent_ = self.indent_[-4:]
| ["def","decrease_indent","(","self",")",":","if","self.on","(",")","and","len","(","self.indent_",")",">","4",":","self.indent_","=","self.indent_","[","-4",":","]"] | 22 | 24 | null | logger.py | turicreate/src/external/boost/boost_1_68_0/tools/build/src/util/logger.py | import sys | 15 | 2 | 1 | 0 | 1 | 7 | null | Use image node_id 4 for calling the NullLogger obj's underlying member method code with example usage: obj.decrease_indent() without return types | 145 | node_id 4 | 2,276,650 |
do_log | NullLogger | null | true | self | null | null | null | null | null | def do_log(self, *args):
pass
| ["def","do_log","(","self",",","*","args",")",":","pass"] | 26 | 27 | null | logger.py | turicreate/src/external/boost/boost_1_68_0/tools/build/src/util/logger.py | import sys | 15 | 2 | 1 | 0 | 1 | 7 | null | Use image node_id 5 for calling the NullLogger obj's underlying member method code with example usage: obj.do_log() without return types | 136 | node_id 5 | 2,276,651 |
_log_loss | global | null | false | y,y_pred,w | null | null | null | null | np | def _log_loss(y, y_pred, w):
"""Calculate the log loss."""
eps = 1e-15
inv_y_pred = np.clip(1 - y_pred, eps, 1 - eps)
y_pred = np.clip(y_pred, eps, 1 - eps)
score = y * np.log(y_pred) + (1 - y) * np.log(inv_y_pred)
return np.average(-score, weights=w)
| ["def","_log_loss","(","y",",","y_pred",",","w",")",":","``","''","''","Calculate","the","log","loss",".","''","''","''","eps","=","1e-15","inv_y_pred","=","np.clip","(","1","-","y_pred",",","eps",",","1","-","eps",")","y_pred","=","np.clip","(","y_pred",",","eps",",","1","-","eps",")","score","=","y","*","np.log","(",... | 140 | 146 | null | fitness.py | gplearn/gplearn/fitness.py | import numbers
import numpy
from joblib import wrap_non_picklable_objects
from scipy.stats import rankdata | 15 | null | 4 | 7 | null | null | null | Use image node_id 7 for calling a global function with example usage: _log_loss(y, y_pred, w) and returns: np | 109 | node_id 7 | 1,106,036 |
interesting | NullLogger | null | true | self,source_name | null | null | null | null | False | def interesting(self, source_name):
return False
| ["def","interesting","(","self",",","source_name",")",":","return","False"] | 29 | 30 | null | logger.py | turicreate/src/external/boost/boost_1_68_0/tools/build/src/util/logger.py | import sys | 15 | 2 | 1 | 0 | 1 | 7 | null | Use image node_id 6 for calling the NullLogger obj's underlying member method code with example usage: obj.interesting(source_name) and returns: False | 150 | node_id 6 | 2,276,652 |
on | NullLogger | null | true | self | null | null | null | null | True | def on(self):
return True
| ["def","on","(","self",")",":","return","True"] | 32 | 33 | null | logger.py | turicreate/src/external/boost/boost_1_68_0/tools/build/src/util/logger.py | import sys | 15 | 2 | 1 | 0 | 1 | 7 | null | Use image node_id 7 for calling the NullLogger obj's underlying member method code with example usage: obj.on() and returns: True | 129 | node_id 7 | 2,276,653 |
__init__ | TextLogger | NullLogger | true | self | null | null | null | null | TextLogger | def __init__(self):
NullLogger.__init__(self)
| ["def","__init__","(","self",")",":","NullLogger.__init__","(","self",")"] | 36 | 37 | null | logger.py | turicreate/src/external/boost/boost_1_68_0/tools/build/src/util/logger.py | import sys | 15 | 2 | 1 | 0 | 1 | 4 | 1 | Use image node_id 1 to create a new TextLogger object from inherited base classes: NullLogger with example: obj = TextLogger() | 126 | node_id 1 | 2,276,654 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.