query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Sets the max_players of this CoreActivitySettings. The maximum number of players the game can hold | def max_players(self, max_players):
self._max_players = max_players | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_players(self):\n return self._max_players",
"def set_max_participants(self, max_part):\n self.max_participants = max_part",
"def setMaxValue(self, max_value):\r\n\t\tself.MaxValue = max_value",
"def setMaxValue(self, max_value):\r\n\t\tself.MaxValue = max_value",
"def set_max(self, va... | [
"0.73955363",
"0.6657424",
"0.63540506",
"0.63540506",
"0.6187427",
"0.6185521",
"0.61810195",
"0.6165908",
"0.61564755",
"0.61423624",
"0.609049",
"0.60222536",
"0.602141",
"0.6001057",
"0.6001057",
"0.6001057",
"0.59969234",
"0.59969234",
"0.5963012",
"0.5957278",
"0.595727... | 0.86082315 | 0 |
Gets the min_players of this CoreActivitySettings. The minimum number of players the game can hold | def min_players(self):
return self._min_players | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_players(self):\n return 2",
"def min_players(self, min_players):\n\n self._min_players = min_players",
"def get_min_id(self):\r\n min_id = None\r\n for pid in self.players:\r\n if min_id is None or pid < min_id:\r\n min_id = pid\r\n return mi... | [
"0.76113",
"0.6851282",
"0.68278474",
"0.643859",
"0.640651",
"0.63727874",
"0.63515544",
"0.6343842",
"0.62926227",
"0.62926227",
"0.6239794",
"0.62332374",
"0.62070435",
"0.6170405",
"0.61378324",
"0.60647947",
"0.6036875",
"0.60143083",
"0.5976273",
"0.5976273",
"0.5976273... | 0.8670473 | 0 |
Sets the min_players of this CoreActivitySettings. The minimum number of players the game can hold | def min_players(self, min_players):
self._min_players = min_players | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_players(self):\n return self._min_players",
"def min_players(self):\n return 2",
"def set_min_participants(self, min_part):\n self.min_participants = min_part",
"def xp_per_min(self, xp_per_min):\n\n self._xp_per_min = xp_per_min",
"def __init__(self, min_player_count):\... | [
"0.7563934",
"0.71112365",
"0.65346396",
"0.6465872",
"0.6395651",
"0.6234409",
"0.6109531",
"0.600785",
"0.5916709",
"0.5916709",
"0.58952904",
"0.5881943",
"0.58510995",
"0.58152056",
"0.58152056",
"0.57964677",
"0.57964677",
"0.57964677",
"0.57834744",
"0.57834744",
"0.577... | 0.8662863 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, CoreActivitySettings):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.80885184",
"0.80885184",
"0.805514",
"0.7983044",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
"0.7966715",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Add a word in the trie structure | def add(root, word):
node = root
for char in word:
found_in_child = False
# Search for the character in the children of the present `node`
for child in node.children:
if child.char == char:
# We found it, increase the counter by 1 to keep track that another
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addWord(self, word):\n ptr = self.root\n for k in word:\n if k in ptr.child:\n ptr = ptr.child[k]\n else:\n ptr.child[k] = TrieNode()\n ptr = ptr.child[k]\n ptr.isEnd = True",
"def addWord(self, word): \n\n # make trie for new word\n self.root.makeTrie(... | [
"0.89895463",
"0.8933609",
"0.8932145",
"0.8932144",
"0.88926435",
"0.88826823",
"0.8866427",
"0.8830613",
"0.88140225",
"0.87661743",
"0.8742865",
"0.8725088",
"0.8568811",
"0.851034",
"0.850462",
"0.84927154",
"0.84809357",
"0.8477725",
"0.84429365",
"0.841936",
"0.83847225... | 0.8136192 | 41 |
NHWC [1x1xd] [5x5xd] + (1) [1x1x4d] (N)(H//stride)(W//stride)(4d) | def _bottleneck(self, inputs, stride=1, outputs_collections=None, scope=None):
with tf.variable_scope(scope, 'bottleneck_v2', [inputs]) as sc:
if self.use_batch_norm:
preact = slim.batch_norm(inputs, activation_fn=tf.nn.relu, scope='preact')
else:
preact =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nw(n):\n return 4*n*n + 1",
"def conv_output_shape(\n h_w: Tuple[int, int],\n kernel_size: int = 1,\n stride: int = 1,\n pad: int = 0,\n dilation: int = 1,\n ):\n h = floor(\n ((h_w[0] + (2 * pad) - (dilation * (kernel_size - 1)) - 1) / stride) + 1\n )\n w = floor(\n ((h... | [
"0.604739",
"0.5929892",
"0.5908317",
"0.58959913",
"0.5829011",
"0.5730633",
"0.5728713",
"0.57135063",
"0.5692593",
"0.5662185",
"0.5637902",
"0.5634279",
"0.5588223",
"0.55839044",
"0.55359906",
"0.54808956",
"0.539002",
"0.5380176",
"0.5344539",
"0.5321963",
"0.5321041",
... | 0.0 | -1 |
Op for generating training labels for RPN proposals. This is used when training RPN jointly with Fast/Mask RCNN (as in endtoend Faster RCNN training). | def forward(self, rpn_rois, roidb, im_info):
im_scales = im_info.data.numpy()[:, 2]
# get_fast_rcnn_blob_names()
output_blob_names = ['rois',
'labels_int32', 'bbox_targets', 'bbox_inside_weights', 'bbox_outside_weights',
'mask_rois', 'roi_has_mask_in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_labels(n_samples):\n return np.ones([n_samples, 1]), np.zeros([n_samples, 1])",
"def label_generator(self):\r\n if self.label_mode == 'separate':\r\n return self.generate_separate_labels()\r\n elif self.label_mode == 'joint':\r\n return self.generate_joint_labe... | [
"0.57406735",
"0.5732566",
"0.568096",
"0.5674445",
"0.567086",
"0.5649215",
"0.5618738",
"0.5617878",
"0.55908847",
"0.559006",
"0.5570181",
"0.55655843",
"0.55563813",
"0.5551461",
"0.5535618",
"0.552033",
"0.55115414",
"0.55050284",
"0.5502784",
"0.5494684",
"0.5493915",
... | 0.0 | -1 |
Only keep boxes with both sides >= min_size and center within the image. | def _filter_boxes(self, boxes, min_size, im_info):
# Scale min_size to match image scale
min_size *= im_info[2]
ws = boxes[:, 2] - boxes[:, 0] + 1
hs = boxes[:, 3] - boxes[:, 1] + 1
x_ctr = boxes[:, 0] + ws / 2.
y_ctr = boxes[:, 1] + hs / 2.
keep = np.where((ws >=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filter_boxes(boxes, min_size):\n ws = boxes[:, 2] - boxes[:, 0] + 1\n hs = boxes[:, 3] - boxes[:, 1] + 1\n keep = np.where((ws >= min_size) & (hs >= min_size))[0]\n return keep",
"def _filter_boxes(boxes, min_size):\n ws = boxes[:, 2] - boxes[:, 0] + 1\n hs = boxes[:, 3] - ... | [
"0.7619617",
"0.7603541",
"0.7603541",
"0.75886637",
"0.7537951",
"0.7290434",
"0.7057679",
"0.6964894",
"0.66949075",
"0.66687864",
"0.6575996",
"0.6575996",
"0.64715207",
"0.6446642",
"0.640746",
"0.6312547",
"0.62918854",
"0.6291512",
"0.62779146",
"0.62597907",
"0.6259790... | 0.80861914 | 0 |
Clip boxes to image boundaries. im_shape is [height, width] and boxes has shape (N, 4 num_tiled_boxes). | def _clip_tiled_boxes(self, boxes, im_shape):
assert boxes.shape[1] % 4 == 0, \
'boxes.shape[1] is {:d}, but must be divisible by 4.'.format(
boxes.shape[1]
)
# x1 >= 0
boxes[:, 0::4] = np.maximum(np.minimum(boxes[:, 0::4], im_shape[1] - 1), 0)
# y1 >= 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clip_boxes(self, boxes, im_shape):\n if boxes.shape[0] == 0:\n return boxes\n\n # x1 >= 0\n boxes[:, 0::4] = np.maximum(np.minimum(boxes[:, 0::4], im_shape[1] - 1), 0)\n # y1 >= 0\n boxes[:, 1::4] = np.maximum(np.minimum(boxes[:, 1::4], im_shape[0] - 1), 0)\n ... | [
"0.83247554",
"0.8321995",
"0.82934266",
"0.82399404",
"0.82399404",
"0.8150131",
"0.8150131",
"0.8148732",
"0.81025916",
"0.7851256",
"0.7478519",
"0.7408463",
"0.7223331",
"0.7004812",
"0.68646723",
"0.6505796",
"0.64668024",
"0.6355265",
"0.6335578",
"0.6248439",
"0.624530... | 0.8381895 | 0 |
Return whether we expect / require regression weights; Right now that is all models except ESM1v | def _has_regression_weights(model_name):
return not ("esm1v" in model_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_weights(obj):\n # TODO(b/110718070): Replace with isinstance(obj, base_layer.Layer).\n has_weight = (hasattr(type(obj), \"trainable_weights\")\n and hasattr(type(obj), \"non_trainable_weights\"))\n\n return has_weight and not isinstance(obj, type)",
"def need_ovo(model_name):\n retur... | [
"0.6592943",
"0.64028656",
"0.63032",
"0.61123866",
"0.61022455",
"0.6061834",
"0.6035603",
"0.6005666",
"0.60020566",
"0.59139276",
"0.59011495",
"0.58188635",
"0.5811774",
"0.578876",
"0.5733348",
"0.5707055",
"0.5675799",
"0.56562686",
"0.56400377",
"0.5626857",
"0.5626857... | 0.86441183 | 0 |
Return bpmfln function with numba. | def bpmfln(k, n, p):
bnm = np.empty_like(n, dtype=np.float64)
logp = math.log(p)
one_logp = math.log(1 - p)
for i in range(len(k)):
bnm[i] = math.exp(combinln(n[i], k[i]) + k[i] *
logp + (n[i] - k[i]) * one_logp)
return bnm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def njit(func):\n return func",
"def bpmfln(k, n, p):\n return np.exp(combinln(n, k) + k * np.log(p) + (n - k) * np.log(1 - p))",
"def applymap_nb(a, map_func_nb, *args):\n out = np.full_like(a, np.nan, dtype=np.float_)\n\n for col in range(out.shape[1]):\n idxs = np.flatnonzero(~np.... | [
"0.64635795",
"0.6398811",
"0.6019388",
"0.59986913",
"0.595082",
"0.5919305",
"0.58751404",
"0.58368987",
"0.5836305",
"0.5802148",
"0.5730889",
"0.57168716",
"0.56329316",
"0.561414",
"0.55734676",
"0.5545763",
"0.5542114",
"0.552053",
"0.55117244",
"0.5509722",
"0.550114",... | 0.6489538 | 0 |
Return bpmfln function wuth numpy. | def bpmfln(k, n, p):
return np.exp(combinln(n, k) + k * np.log(p) + (n - k) * np.log(1 - p)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f_np(phi, lambd):\n f = 1. / (np.absolute(1. - sft(phi, lambd)) ** 2)\n return f",
"def bpmfln(k, n, p):\n bnm = np.empty_like(n, dtype=np.float64)\n logp = math.log(p)\n one_logp = math.log(1 - p)\n for i in range(len(k)):\n bnm[i] = math.exp(combinln(n[i], k[i])... | [
"0.6960087",
"0.67491955",
"0.6103096",
"0.6037518",
"0.6031193",
"0.60158575",
"0.59856194",
"0.5959925",
"0.59296924",
"0.5914411",
"0.58878785",
"0.5784712",
"0.57818717",
"0.5740454",
"0.5704756",
"0.5702907",
"0.5682225",
"0.56217027",
"0.56202936",
"0.55736226",
"0.5573... | 0.6645829 | 2 |
Saves parameters to json file | def save(self, json_path):
with open(json_path, 'w') as f:
json.dump(self.__dict__, f, indent=4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_json(self, path=None):\n if path is None:\n path = self.parampath\n\n params = {str(key): str(value) for key, value in self.__dict__.items()}\n # with open(f'{path}/params_{self.mode}.json', 'w') as f:\n with open(os.path.join(path, f'params_{self.mode}.json'), 'w') ... | [
"0.82312053",
"0.8181947",
"0.8057166",
"0.7808885",
"0.77812463",
"0.775106",
"0.7710382",
"0.7706769",
"0.76148814",
"0.75990826",
"0.7574917",
"0.75643057",
"0.7448175",
"0.7373087",
"0.7341731",
"0.7261098",
"0.719621",
"0.7154501",
"0.714766",
"0.7143015",
"0.71297264",
... | 0.6701761 | 63 |
Sets the logger to log info in terminal and file `log_path`. In general, it is useful to have a logger so that every output to the terminal is saved in a permanent file. Here we save it to `model_dir/train.log`. | def set_logger(log_path):
logger = logging.getLogger()
logger.setLevel(logging.INFO)
if not logger.handlers:
# Logging to a file
file_handler = logging.FileHandler(log_path, mode='w')
file_handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s: %(message)s'))
logg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_log_dir(self, model_path=None):\n # Set date and epoch counter as if starting a new model\n self.epoch = 0\n now = datetime.datetime.now()\n\n # If we have a model path with date and epochs use them\n if model_path:\n # Continue from we left of. Get epoch and d... | [
"0.7125661",
"0.7017231",
"0.6963836",
"0.68003154",
"0.65923315",
"0.6566201",
"0.654351",
"0.6436083",
"0.63942605",
"0.6256997",
"0.62283105",
"0.6212779",
"0.6182543",
"0.6181041",
"0.6157524",
"0.61547387",
"0.6153127",
"0.6081566",
"0.60556686",
"0.59869903",
"0.5946518... | 0.62806326 | 9 |
Returns the active ``SparkContext`` if there is one and it's not stopped, otherwise returns None | def get_active_spark_context() -> Optional[SparkContext]:
if is_spark_context_stopped():
return None
return SparkContext._active_spark_context | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_active_spark_session() -> Optional[SparkSession]:\n if is_spark_context_stopped():\n return None\n return SparkSession.getActiveSession()",
"def get_spark_context(conf=None):\n if hasattr(SparkContext, \"getOrCreate\"):\n with SparkContext._lock:\n if SparkContext._activ... | [
"0.830488",
"0.72235626",
"0.6739669",
"0.6606784",
"0.62115747",
"0.61983407",
"0.6195099",
"0.6171946",
"0.6101583",
"0.6029224",
"0.6022193",
"0.5772433",
"0.5705983",
"0.5705983",
"0.5705983",
"0.56983453",
"0.5648026",
"0.56366515",
"0.56271595",
"0.5457026",
"0.53808236... | 0.9050855 | 0 |
Get a SparkSession object with some of the default/boilerplate config needed for THIS project preset Providing no arguments will work, and give a plainvanilla SparkSession wrapping a plain vanilla SparkContext with all the default spark configurations set (or set with any filebased configs that have been established in... | def configure_spark_session(
java_gateway: JavaGateway = None,
spark_context: Union[SparkContext, SparkSession] = None,
master=None,
app_name="Spark App",
log_level: int = None,
log_spark_config_vals: bool = False,
log_hadoop_config_vals: bool = False,
enable_hive_support: bool = False,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_spark_session(name='not provided', **kwargs):\n try:\n from pyspark.sql import SparkSession\n except ImportError:\n import findspark\n findspark.init(spark_home=kwargs.get('spark_home'),\n python_path=kwargs.get('python_path'))\n from pyspark.sql i... | [
"0.6867688",
"0.6605679",
"0.6398324",
"0.6377082",
"0.63403815",
"0.63389045",
"0.63049394",
"0.6284391",
"0.62388784",
"0.6158866",
"0.61490256",
"0.6146191",
"0.61113846",
"0.6102277",
"0.6082016",
"0.6082016",
"0.6082016",
"0.6082016",
"0.6082016",
"0.6082016",
"0.6082016... | 0.5931455 | 34 |
Converts the passedin Postgres DB connection URI to a JDBCcompliant Postgres DB connection string | def get_jdbc_url_from_pg_uri(pg_uri: str) -> str:
url_parts, user, password = parse_pg_uri(pg_uri)
if user is None or password is None:
raise ValueError("pg_uri provided must have username and password with host or in query string")
# JDBC URLs only support postgresql://
pg_uri = f"postgresql://... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_usas_jdbc_url():\n if not CONFIG.DATABASE_URL:\n raise ValueError(\"DATABASE_URL config val must provided\")\n\n return get_jdbc_url_from_pg_uri(CONFIG.DATABASE_URL)",
"def connection_string(self):\n return \"postgresql+psycopg2://%s:%s@%s:%s/%s\" % \\\n (os.environ['DB_... | [
"0.7377357",
"0.71319085",
"0.70621395",
"0.70545214",
"0.70001876",
"0.67105854",
"0.66121274",
"0.65854883",
"0.6511685",
"0.6505907",
"0.64583147",
"0.6398349",
"0.6380881",
"0.63494456",
"0.63442296",
"0.63309294",
"0.63192916",
"0.6281735",
"0.62536454",
"0.6243578",
"0.... | 0.79532456 | 0 |
Return age with currentmeters. | def transform(self, X):
transformed = np.ones(X.shape)
transformed[:, 0] = pd.to_datetime(X[:, 1]).year - X[:, 0]
transformed[:, 1] = X[:, 2]
return transformed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_age(self):\n age = CURRENT_YEAR - self.year\n return age",
"def get_age(self):\n return CURRENT_YEAR - self.year",
"def get_age(self):\n return CURRENT_YEAR - self.year",
"def get_age(self):\n\t\treturn self.age",
"def get_age(self):\n return Guitar.CURRENT_YEAR -... | [
"0.8072585",
"0.8005624",
"0.8005624",
"0.7801879",
"0.7717726",
"0.7699239",
"0.764645",
"0.7630905",
"0.7611926",
"0.760829",
"0.7606074",
"0.7575031",
"0.7575031",
"0.7575031",
"0.7557475",
"0.7545636",
"0.75398916",
"0.7531413",
"0.7441121",
"0.73864776",
"0.73414785",
... | 0.0 | -1 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(ManipTaskResult, self).__init__(*args, **kwds)
# message fields cannot be None, assign default values for those that are
if self.manip_return_code is None:
self.manip_return_code = 0
if self.object_grabber_return_code is None:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.cmd is None:\n ... | [
"0.7794164",
"0.7721611",
"0.7721611",
"0.7687804",
"0.7626575",
"0.7565245",
"0.74406534",
"0.74182206",
"0.73521465",
"0.73088044",
"0.72807634",
"0.7238138",
"0.7227902",
"0.72254795",
"0.72254795",
"0.7219563",
"0.7212849",
"0.7212849",
"0.7212849",
"0.7212849",
"0.721284... | 0.0 | -1 |
Checks vowel count, double letter, forbidden strings and returns whether or not sit satisfies conditions | def naughty_nice_check(string: str) -> bool:
vowels = 0
double_letters = 0
forbidden_string = False
last_letter = ''
for i, letter in enumerate(string):
vowels += 1 if letter in 'aeiou' else 0
double_letters += 1 if letter == last_letter else 0
if last_letter + letter in FORB... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def property_1(string):\n vowels = ['a', 'e', 'i', 'o', 'u']\n occurances = 0\n for vowel in vowels:\n if vowel in string:\n occurances += string.count(vowel)\n if occurances > 2:\n return True\n return False",
"def does_it_have_3_vowels(word):\n vowel_c... | [
"0.6971542",
"0.68248385",
"0.6652647",
"0.6635341",
"0.66008973",
"0.65079343",
"0.6453528",
"0.6429756",
"0.6311973",
"0.6279592",
"0.6236954",
"0.6218705",
"0.6200517",
"0.6192769",
"0.61464816",
"0.61139685",
"0.6113959",
"0.61121494",
"0.6094367",
"0.6056389",
"0.6040775... | 0.7464414 | 0 |
Returns True if user is a candidate. Costs one database query. | def is_candidate(self, user):
return self.candidates.filter(pk=user.pk).exists() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def q_is_candidate(cls, user_obj):\n return Q(candidates__student=user_obj)",
"def q_is_candidate(cls, user_obj):\n return Q(candidates__relatedstudent__user=user_obj)",
"def authorizes(self, user):\n return self.owner == user or self.workers.filter(pk=user.id).exists()",
"def get_is_por... | [
"0.7259935",
"0.70674884",
"0.6730719",
"0.65276784",
"0.64876944",
"0.6464249",
"0.6393419",
"0.6359417",
"0.63493454",
"0.63210964",
"0.6306662",
"0.63002443",
"0.6246956",
"0.6205753",
"0.6179037",
"0.6172021",
"0.617082",
"0.61521536",
"0.6092689",
"0.6083653",
"0.6074239... | 0.86393374 | 0 |
Returns the normal queryset. In the background we join and prefetch all related models. | def get_prefetched_queryset(self, *args, **kwargs):
return (
super()
.get_prefetched_queryset(*args, **kwargs)
.select_related("user", "poll")
.prefetch_related("votes")
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prefetch(self, queryset: models.QuerySet) -> models.QuerySet:\n subquery = self.model.objects.all()\n \n if self.filters:\n q = reduce(operator.and_, [f.get() for f in self.filters])\n subquery = subquery.filter(q)\n \n if self.sort:\n subquer... | [
"0.78477097",
"0.7259695",
"0.7037126",
"0.6867757",
"0.6819712",
"0.6778886",
"0.67473936",
"0.6565618",
"0.65518004",
"0.6402129",
"0.6383351",
"0.6238297",
"0.62120056",
"0.6191736",
"0.61817664",
"0.61370593",
"0.60924804",
"0.607053",
"0.60594714",
"0.59891963",
"0.59883... | 0.6771962 | 6 |
Returns the normal queryset with all assignment polls. In the background we join and prefetch all related models. | def get_prefetched_queryset(self, *args, **kwargs):
return (
super()
.get_prefetched_queryset(*args, **kwargs)
.select_related("assignment")
.prefetch_related(
"options", "options__user", "options__votes", "voted", "groups"
)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_prefetched_queryset(self, *args, **kwargs):\n\n return (\n super()\n .get_prefetched_queryset(*args, **kwargs)\n .prefetch_related(\n \"assignment_related_users\",\n \"agenda_items\",\n \"lists_of_speakers\",\n ... | [
"0.7630337",
"0.7000979",
"0.65076745",
"0.6365199",
"0.6278897",
"0.5972492",
"0.5930554",
"0.58636695",
"0.58182603",
"0.5696804",
"0.5686963",
"0.55791265",
"0.55791265",
"0.5462735",
"0.5455535",
"0.5449296",
"0.5441646",
"0.5434988",
"0.54224044",
"0.5422243",
"0.5383985... | 0.7449777 | 1 |
Returns the number of days since start day | def days_since_start():
initial = initial_time('time_stamp.txt')
actual = time.localtime(time.time())
if initial[0] == actual[0]:
return actual[7] - initial[7]
else:
if calendar.isleap(initial[0]):
return (366 - initial[7]) + actual[7]
else:
return (365 - ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_days(start: date, end: date) -> int:\n delta = end - start\n return delta.days + 1",
"def get_number_days(self):\r\n return 1",
"def compute_total_days(start, end):\n # Use the datetime module to subtract the dates (+1 if inclusive)\n return (end - start).days + 1",
"def DAYS(e... | [
"0.7662911",
"0.7637556",
"0.75184983",
"0.7363291",
"0.7343233",
"0.7288119",
"0.71636724",
"0.71007746",
"0.70899326",
"0.7084582",
"0.7071234",
"0.7056898",
"0.70462847",
"0.70361936",
"0.69083375",
"0.6835536",
"0.67967796",
"0.67846334",
"0.67846334",
"0.67706615",
"0.67... | 0.78667194 | 0 |
Convert a string (bytestring in `encoding` or unicode), to unicode. | def to_unicode(text, encoding='utf8', errors='strict'):
if isinstance(text, unicode):
return text
return unicode(text, encoding, errors=errors) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_unicode(string):\n\n if isinstance(string, str):\n return string.decode('utf-8')\n else:\n return unicode(string)",
"def to_unicode(s, encoding=\"utf-8\"):\n if isinstance(s, six.text_type):\n return s\n elif isinstance(s, bytes):\n return s.decode(encoding)\n # ... | [
"0.85251766",
"0.8524837",
"0.83010745",
"0.81882405",
"0.81632316",
"0.8149855",
"0.8114386",
"0.8092626",
"0.8046262",
"0.7950895",
"0.7921842",
"0.7917224",
"0.78339505",
"0.78276324",
"0.7822083",
"0.780238",
"0.77633584",
"0.77592474",
"0.7722087",
"0.7688505",
"0.768850... | 0.7469589 | 26 |
Instantiate an NlpEngine with a spaCy model | def create_nlp_engine_with_spacy(
model_path: str,
) -> Tuple[NlpEngine, RecognizerRegistry]:
registry = RecognizerRegistry()
registry.load_predefined_recognizers()
if not spacy.util.is_package(model_path):
spacy.cli.download(model_path)
nlp_configuration = {
"nlp_engine_name": "sp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, nlp_model):\n\n self.__nlp_model: spacy = nlp_model\n self.__pipe_mode = False\n self.__documents = None\n self.__nlp_model.tokenizer = custom_tokenizer(self.__nlp_model.vocab)",
"def main(model=None, output_dir=None, n_iter=20):\n if model is not None:\n ... | [
"0.66777116",
"0.6516763",
"0.6497612",
"0.6494125",
"0.64900994",
"0.6478523",
"0.64034444",
"0.6387191",
"0.6293386",
"0.61844265",
"0.61250937",
"0.6083482",
"0.6042071",
"0.6016586",
"0.60078216",
"0.5979568",
"0.59571797",
"0.595414",
"0.5954043",
"0.5875853",
"0.5862723... | 0.71796453 | 0 |
Instantiate an NlpEngine with a TransformersRecognizer and a small spaCy model. The TransformersRecognizer would return results from Transformers models, the spaCy model would return NlpArtifacts such as POS and lemmas. | def create_nlp_engine_with_transformers(
model_path: str,
) -> Tuple[NlpEngine, RecognizerRegistry]:
from transformers_rec import (
STANFORD_COFIGURATION,
BERT_DEID_CONFIGURATION,
TransformersRecognizer,
)
registry = RecognizerRegistry()
registry.load_predefined_recognizers... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_nlp_engine_with_spacy(\n model_path: str,\n) -> Tuple[NlpEngine, RecognizerRegistry]:\n registry = RecognizerRegistry()\n registry.load_predefined_recognizers()\n\n if not spacy.util.is_package(model_path):\n spacy.cli.download(model_path)\n\n nlp_configuration = {\n \"nlp_e... | [
"0.6309258",
"0.59957725",
"0.5848229",
"0.5831569",
"0.5831549",
"0.56891596",
"0.566701",
"0.5644719",
"0.55836546",
"0.54984206",
"0.5488743",
"0.5468071",
"0.54487264",
"0.5393884",
"0.53751194",
"0.53609306",
"0.53496253",
"0.5299719",
"0.5288677",
"0.5271717",
"0.525315... | 0.7412707 | 0 |
Instantiate an NlpEngine with a TextAnalyticsWrapper and a small spaCy model. The TextAnalyticsWrapper would return results from calling Azure Text Analytics PII, the spaCy model would return NlpArtifacts such as POS and lemmas. | def create_nlp_engine_with_azure_text_analytics(ta_key: str, ta_endpoint: str):
from text_analytics_wrapper import TextAnalyticsWrapper
if not ta_key or not ta_endpoint:
raise RuntimeError("Please fill in the Text Analytics endpoint details")
registry = RecognizerRegistry()
registry.load_prede... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_nlp_engine_with_spacy(\n model_path: str,\n) -> Tuple[NlpEngine, RecognizerRegistry]:\n registry = RecognizerRegistry()\n registry.load_predefined_recognizers()\n\n if not spacy.util.is_package(model_path):\n spacy.cli.download(model_path)\n\n nlp_configuration = {\n \"nlp_e... | [
"0.6329537",
"0.6134199",
"0.59808147",
"0.57942176",
"0.5723757",
"0.55372757",
"0.5435132",
"0.540155",
"0.5391157",
"0.53365564",
"0.53069323",
"0.5287742",
"0.52663356",
"0.522313",
"0.5202655",
"0.51811576",
"0.5176938",
"0.51603085",
"0.5157487",
"0.5080522",
"0.5060003... | 0.74815893 | 0 |
Get current average value. | def get_value(
self
) -> float:
return self.average | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAvg(self):\r\n\t\treturn self.data['avg']",
"def average(self):\n return (self.current + self.last) / 2.0",
"def average(self):\n return self.properties.get('average')",
"def current_mean(self):\r\n values = self._timings\r\n return np.mean(values)",
"def getAvg(self):\r\... | [
"0.82754064",
"0.8273873",
"0.80291945",
"0.7965683",
"0.79476863",
"0.79342854",
"0.791237",
"0.7849167",
"0.77748686",
"0.7761742",
"0.77044845",
"0.77001125",
"0.77001125",
"0.7685076",
"0.76703435",
"0.76491344",
"0.7638778",
"0.7489224",
"0.7471779",
"0.7393287",
"0.7391... | 0.84638816 | 0 |
Get argument parser for a class. | def get_argument_parser(
fully_qualified_class_name
) -> ArgumentParser:
parser = None
try:
loaded_class = load_class(fully_qualified_class_name)
parser = loaded_class.get_argument_parser()
except Exception:
pass
return parser | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_parser():\n\n parser = parser.ArgumentParser()\n return parser",
"def parser(self):\n return self.arg_parser",
"def get_parser():\n parser = ArgumentParser(\n description=__doc__, formatter_class=ArgumentDefaultsHelpFormatter\n )\n parser.add_argument(\n \"-s... | [
"0.7529748",
"0.7425545",
"0.7014187",
"0.6880837",
"0.6880837",
"0.68285406",
"0.6810964",
"0.68031895",
"0.67766315",
"0.67219365",
"0.6719253",
"0.6712278",
"0.6645676",
"0.656488",
"0.65113723",
"0.650896",
"0.6489204",
"0.64720553",
"0.6465023",
"0.6456307",
"0.64529526"... | 0.8027745 | 0 |
Returns a tree with the same structure as `x` but with each leaf replaced by a `_ValueRepresentation` object. | def _represent_tree(x):
return jax.tree_util.tree_map(
_get_value_representation,
x,
is_leaf=lambda x: x is None or isinstance(x, meta.Partitioned),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _treeify(values):\n if len(values) == 1: # this case causes problems later\n return values\n tree = np.empty_like(values)\n # Tree indices work as follows:\n # 0 is the root\n # 2n+1 is the left child of n\n # 2n+2 is the right child of n\n # So we n... | [
"0.61983526",
"0.61905545",
"0.58174485",
"0.58076596",
"0.58076596",
"0.56117356",
"0.5321016",
"0.5302137",
"0.5276118",
"0.522799",
"0.5219278",
"0.52188027",
"0.521051",
"0.5197067",
"0.51930845",
"0.5176564",
"0.51745635",
"0.5167721",
"0.5167721",
"0.5164249",
"0.514700... | 0.7618141 | 0 |
Return list of message_ids of messages that have not yet been sent out | def get_unsent_messages():
unsent_messages = Message.query.filter(Message.sent == False).all()
# SELECT message_id FROM messages WHERE sent = False
return unsent_messages | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_seen_messages(self, messages):\n seen_uids = set()\n for uid in messages:\n key = \"%s_%s_%s\" % (self.opt_pop3_server,\n self.opt_global_account[\"username\"], uid.split()[1])\n if self.helper.get_check_point(key) is not None:\n ... | [
"0.6564373",
"0.64003205",
"0.6358967",
"0.6358967",
"0.62269306",
"0.61844486",
"0.6127037",
"0.6124186",
"0.6118156",
"0.60941833",
"0.59998477",
"0.5987276",
"0.5964109",
"0.58986986",
"0.58953977",
"0.5858326",
"0.58520764",
"0.5820744",
"0.5820744",
"0.5800344",
"0.57960... | 0.75613105 | 0 |
Converts a number to a number with decimal point. | def clean(amount):
# Return empty input immediately.
if not amount:
return amount
if re.search(r'[\. ][0-9]{3},[0-9]{1,2}$', amount):
# Assume amount is in 1.123,12 or 1 123,12 format (Dutch).
return amount.replace('.', '').replace(' ', '').replace(',', '.')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num(value):\n value = Decimal(value)\n return value",
"def decimalize(n):\n return '{:.2f}'.format(n)",
"def __round(num):\n return float(round(decimal.Decimal(num), DataGen.precision))",
"def decimalformat(value):\n getcontext().prec = 8\n v = str(value)\n return Decimal(v)/Deci... | [
"0.7077795",
"0.69462895",
"0.64070225",
"0.6384231",
"0.6351873",
"0.6304567",
"0.627297",
"0.6259637",
"0.6251034",
"0.62466913",
"0.61581266",
"0.60988283",
"0.6085649",
"0.603252",
"0.6031842",
"0.59968853",
"0.5969206",
"0.59469354",
"0.5913636",
"0.59094125",
"0.5906922... | 0.0 | -1 |
Try to extract the expiration date from the given data. | def __extract_it(self):
for regex in self.expiration_patterns:
expiration_date = helpers.Regex(regex).match(
self.data, return_match=True, rematch=True, group=0
)
if not expiration_date:
continue
expiration_date = expiration_date... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_expiry():\n\n return get_or_append_details('expiry', \"Please enter your expiry date, two digits for the month and two digits for the year\")",
"def _check_expiration(self, url, data):\n if data.expires_after < time.time():\n del self.data[url]\n data = None\n retur... | [
"0.6765368",
"0.6507341",
"0.6214671",
"0.60990363",
"0.60603565",
"0.6003449",
"0.59971756",
"0.59558797",
"0.59003645",
"0.5898838",
"0.5890946",
"0.58480436",
"0.58217484",
"0.57251346",
"0.5687422",
"0.5601885",
"0.5599184",
"0.5589525",
"0.5566101",
"0.5559045",
"0.55521... | 0.69955814 | 0 |
Set default value for defined field. | def set_default_value(self, field):
if field._default is not None:
if callable(field._default):
default = field._default()
else:
default = field._default
self.defaults[field.name] = default | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default(self, default):\n\n self._set_field(\"value\", default)",
"def set_value_to_default(self):\n self.setValue(self.default_value)",
"def default_value(self, val):\n self.set_property(\"DefaultValue\", val)",
"def default_value(self, default_value):\n\n self._default_value... | [
"0.793816",
"0.7418267",
"0.7380837",
"0.7185621",
"0.7185621",
"0.7185621",
"0.7148132",
"0.7125401",
"0.7056688",
"0.69887215",
"0.6982201",
"0.68796945",
"0.6876141",
"0.68555295",
"0.6811182",
"0.6807332",
"0.6784424",
"0.6783037",
"0.6779412",
"0.6771425",
"0.6703667",
... | 0.86775917 | 0 |
Get Model object or if it is not found then create one. | def get_or_create(cls, defaults=None, **kwargs):
try:
instance = cls.get(**kwargs)
except NoDataException:
if isinstance(defaults, dict):
kwargs.update(defaults)
instance = cls.create(**kwargs)
return instance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_or_initialize_model(self, payload):\n try:\n model = self.get_model(payload)\n except DoesNotExistException:\n model = self.initialize_model()\n\n model.id = payload.get('local_id', model.id)\n return model",
"def get_or_create_model(self) -> Model:\n ... | [
"0.76848316",
"0.7673591",
"0.7368167",
"0.7238984",
"0.72070044",
"0.7024778",
"0.69812745",
"0.6980114",
"0.6961938",
"0.6949769",
"0.69435483",
"0.69435483",
"0.6887673",
"0.6851559",
"0.6830831",
"0.68263364",
"0.6759251",
"0.67446715",
"0.674362",
"0.672204",
"0.6690674"... | 0.611056 | 83 |
Join a different chat channel on Twitch. Note, this function returns immediately, but the switch might take a moment | def join_channel(self, channel):
self._send('JOIN #%s\r\n' % channel) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def joinChat(self,ctx):\n await ctx.send('Joining the chat kiddo')",
"async def join(ctx):\r\n channel = ctx.message.author.voice.channel\r\n if ctx.voice_client is not None:\r\n return await ctx.voice_client.move_to(channel)\r\n\r\n await channel.connect()",
"async def join(self, ... | [
"0.7036636",
"0.6902702",
"0.66494554",
"0.6646213",
"0.66429573",
"0.65229636",
"0.6522512",
"0.64485794",
"0.6419035",
"0.641416",
"0.6394776",
"0.6377304",
"0.63673985",
"0.6365609",
"0.630374",
"0.62790704",
"0.62551767",
"0.6253805",
"0.62377506",
"0.62025845",
"0.619748... | 0.6114248 | 25 |
Setup test fixture for all model tests. | def setup():
load_app()
setup_db() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUpFixture(self):\n pass",
"def _fixture_setup(self):\n pass",
"def setUp(self):\n self.app = load_app(self.application_under_test)\n\n try:\n teardown_db()\n except Exception as e:\n print('-> err ({})'.format(e.__str__()))\n\n setup_app(se... | [
"0.8034924",
"0.7966587",
"0.7475684",
"0.7444913",
"0.74374974",
"0.74343306",
"0.73820174",
"0.7374081",
"0.7324077",
"0.7293779",
"0.7267342",
"0.7215689",
"0.718387",
"0.7175931",
"0.71700966",
"0.71652836",
"0.71581763",
"0.71337205",
"0.7123558",
"0.7123558",
"0.7115997... | 0.0 | -1 |
Yield successive nsized chunks from l. | def chunks(l, n):
for i in xrange(0, len(l), n):
yield l[i:i + n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]",
"def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def get_chunks(self, ... | [
"0.80388075",
"0.7924573",
"0.79226995",
"0.788447",
"0.7877021",
"0.781505",
"0.7764907",
"0.77549165",
"0.7743869",
"0.7731126",
"0.77281487",
"0.77241385",
"0.77024275",
"0.7688614",
"0.7688614",
"0.7663561",
"0.7656419",
"0.76552874",
"0.76552874",
"0.76452404",
"0.764524... | 0.0 | -1 |
Create a dependency object from a DB dependency dict. | def __init__(self, config_dict: dict):
self._config = config_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dict(cls, dikt) -> 'DependencyValue':\n return util.deserialize_model(dikt, cls)",
"def _from_dict(cls, _dict: dict) -> 'BaseDataConnection':\n pass",
"def from_dict(cls, odic):\n return dacite.from_dict(data_class=cls, data=odic)",
"def from_dict(self, dictionary, dao, user_id=... | [
"0.6852481",
"0.60002345",
"0.59658813",
"0.5847309",
"0.57865566",
"0.57640845",
"0.5764",
"0.574865",
"0.56398195",
"0.5509046",
"0.54535604",
"0.54454505",
"0.5443455",
"0.5420895",
"0.5417176",
"0.54124546",
"0.54124546",
"0.54124546",
"0.54124546",
"0.54124546",
"0.54124... | 0.0 | -1 |
Return the dependency type. | def type(self) -> str:
return self._config.get('type') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDependenceTypeAt(self, pos):\n return self.sentence[pos].getDependenceType()",
"def get_type(self):\n return self.type",
"def get_type(self):\n return self.type",
"def type(self):\n return self.container['type']",
"def type(self):\n return self.container['type']",
... | [
"0.66796106",
"0.6395118",
"0.6395118",
"0.6391446",
"0.6391446",
"0.6381704",
"0.63696474",
"0.63696474",
"0.63605577",
"0.63605577",
"0.63605577",
"0.63605577",
"0.63605577",
"0.63605577",
"0.63605577",
"0.63605577",
"0.63605577",
"0.63605577",
"0.63605577",
"0.63605577",
"... | 0.0 | -1 |
Get the height of the board. | def get_grid_height(self):
return self._grid_height | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def height(self):\n return self.board.shape[0]",
"def getHeight(self):\n return self.height",
"def getHeight(self):\n return self.height",
"def getHeight(self):\n return self._height",
"def get_grid_height(self):\n return self._height",
"def get_grid_height(self):\n ... | [
"0.85063905",
"0.78268176",
"0.78268176",
"0.77902925",
"0.77875626",
"0.77875626",
"0.77665955",
"0.77665955",
"0.77665955",
"0.77665955",
"0.7765325",
"0.7761614",
"0.7758976",
"0.7755297",
"0.77416444",
"0.77371883",
"0.77204704",
"0.7695517",
"0.7692841",
"0.7692841",
"0.... | 0.76299065 | 27 |
Ensure we can get student objects. | def test_get_Student_bulk(self):
school_ids = self.create_School(2,20)
url = '/students'
for i in range(10):
data = {'first_name': 'Poompatai', 'last_name': 'Puntitpong','age': 20, 'nationality': 'Thailand', 'school': school_ids[0]}
response = self.client.post(url, data, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_students_for_contact(self):\n pass",
"def __ui_list_students(self):\n try:\n print(str(self.__student_controller))\n except RepositoryException as re:\n print(re)\n return",
"def __init__(self):\n self.students = {}",
"def test_get_stu... | [
"0.67002726",
"0.60937667",
"0.6019808",
"0.59977525",
"0.59746265",
"0.5940141",
"0.5893593",
"0.5874697",
"0.58580077",
"0.5848654",
"0.5818573",
"0.5781427",
"0.5772508",
"0.5756074",
"0.575212",
"0.5670481",
"0.56360984",
"0.56344455",
"0.55732244",
"0.55711555",
"0.55393... | 0.5367133 | 34 |
Creates the SPARQL pattern to filter the graph according to the premise of this rule (i.e., all literals in the premise). | def antecedents_patterns(self,
graph: Graph,
subject_uri: URIRef,
relation_uri: URIRef,
object_uri: URIRef) -> Tuple[str, Optional[Literal]]:
# contains the concatenated SPARQL patterns of the lit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sql(self):\n rule_specs = []\n\n patterns = {}\n pattern_specs = []\n\n # It's safe to unpack `self.get_rules` because it can only\n # return A) an empty list or B) a list of two-tuples with two elements in\n # them (the path and the rule for each query directive).\n ... | [
"0.5640796",
"0.56134504",
"0.56025726",
"0.55813146",
"0.5409966",
"0.51362306",
"0.50652134",
"0.50593764",
"0.5034537",
"0.49820298",
"0.49720347",
"0.49263874",
"0.4914475",
"0.48920816",
"0.48728907",
"0.48647857",
"0.48603174",
"0.4859698",
"0.4849195",
"0.48317784",
"0... | 0.5490746 | 4 |
r"""Computes a sparsely evaluated softmax. | def softmax(
src: Tensor,
index: Optional[Tensor] = None,
ptr: Optional[Tensor] = None,
num_nodes: Optional[int] = None,
dim: int = 0,
) -> Tensor:
if ptr is not None:
dim = dim + src.dim() if dim < 0 else dim
size = ([1] * dim) + [-1]
count = ptr[1:] - ptr[:-1]
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sparse_softmax(sparse, dim):\n dtype = sparse.dtype\n device = sparse.device\n\n # softmax is non-linear operation, so sparse tensors must\n # be coalesced.\n sparse = sparse.coalesce()\n inf = float('inf')\n indices = sparse._indices... | [
"0.7821737",
"0.7569942",
"0.7551847",
"0.75240827",
"0.7449907",
"0.73949605",
"0.7382366",
"0.73781186",
"0.73700947",
"0.73700947",
"0.73700947",
"0.73700947",
"0.73700947",
"0.73700947",
"0.73700947",
"0.73700947",
"0.7347379",
"0.73378986",
"0.73333216",
"0.73306376",
"0... | 0.0 | -1 |
Gets the default embed url for this guild. If the widget is not enabled, this endpoint will 404. | def embed_url(self) -> str:
return (Endpoints.GUILD_BASE + "/embed.png").format(guild_id=self.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_embed_url(self):\n return self.embed_url",
"def get_embed_url(self):\n if not self._oembed:\n return ''\n \n if not self.original_url:\n return ''\n \n return 'https://w.soundcloud.com/player/?url=%s' % (self.original_url)",
"def get_embed_url(self):\n ... | [
"0.71179944",
"0.6908282",
"0.6827079",
"0.66636914",
"0.6631826",
"0.6496669",
"0.64584064",
"0.6445753",
"0.6255571",
"0.62260836",
"0.61648464",
"0.5945101",
"0.5915735",
"0.5906226",
"0.58611506",
"0.58585626",
"0.5837658",
"0.58164734",
"0.5771251",
"0.56905174",
"0.5666... | 0.74588627 | 0 |
Gets the invites for this guild. | async def get_invites(self) -> 'typing.List[dt_invite.Invite]':
invites = await self._bot.http.get_invites_for(self.id)
invites = [dt_invite.Invite(self._bot, **i) for i in invites]
try:
invite = await self.get_vanity_invite()
except (CuriousError, HTTPException):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list(self):\n invites = []\n from arcgis.gis import GIS\n isinstance(self._gis, GIS)\n url = self._url\n params = {\n 'f' : 'json',\n 'num':100,\n 'start':1\n }\n res = self._gis._con.get(url, params)\n invites = res[\"inv... | [
"0.7105344",
"0.69937795",
"0.6967634",
"0.6844363",
"0.6404758",
"0.6342184",
"0.6313638",
"0.61439383",
"0.61439383",
"0.6087891",
"0.60308194",
"0.585102",
"0.5832664",
"0.58262444",
"0.5749733",
"0.57105964",
"0.563897",
"0.5587444",
"0.5556794",
"0.5501028",
"0.547931",
... | 0.76706654 | 0 |
Gets the bans for this guild. | async def get_bans(self) -> 'typing.List[dt_user.User]':
if not self.me.guild_permissions.ban_members:
raise PermissionsError("ban_members")
bans = await self._bot.http.get_bans(self.id)
users = []
for user_data in bans:
# TODO: Audit log stuff, if it ever comes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def bans(self, ctx):\n try:\n bans = await self.bot.get_bans(ctx.message.server)\n except discord.Forbidden:\n await self.bot.say('I do not have the proper permissions')\n except discord.HTTPException:\n await self.bot.say('Getting bans failed')\n ... | [
"0.6886236",
"0.6713512",
"0.6689792",
"0.6257416",
"0.60631204",
"0.5812861",
"0.5782474",
"0.56242865",
"0.55663234",
"0.5406851",
"0.5211844",
"0.5188771",
"0.51777005",
"0.51518244",
"0.51489145",
"0.51450855",
"0.51394767",
"0.51219463",
"0.5105906",
"0.510097",
"0.50949... | 0.71995574 | 0 |
Gets the webhooks for this guild. | async def get_webhooks(self) -> 'typing.List[dt_webhook.Webhook]':
webhooks = await self._bot.http.get_webhooks_for_guild(self.id)
obbs = []
for webhook in webhooks:
obbs.append(self._bot.state.make_webhook(webhook))
return obbs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def webhooks(self) -> json:\r\n try:\r\n return self.api(method=\"GET\", endpoint=f\"all/webhooks.json\").json()\r\n except Exception as e:\r\n raise e",
"def webhooks(self):\n return SpaceWebhooksProxy(self._client, self.id)",
"def webhooks(self) -> Optional[Sequence... | [
"0.6820525",
"0.6778464",
"0.67231727",
"0.67025614",
"0.666831",
"0.62340087",
"0.62335944",
"0.611383",
"0.5872288",
"0.5559806",
"0.5405932",
"0.53790724",
"0.52683055",
"0.5257497",
"0.5236784",
"0.5202617",
"0.5202617",
"0.51657933",
"0.5126988",
"0.51090825",
"0.5097852... | 0.7003051 | 0 |
Gets the widget info for the current guild. | async def get_widget_info(self) -> 'typing.Tuple[bool, typing.Union[None, channel.Channel]]':
info = await self._bot.http.get_widget_status(self.id)
return info.get("enabled", False), self.channels.get(int(info.get("channel_id", 0))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def server_info(self, ctx):\n if ctx.author.bot == False:\n embed = discord.Embed(title= ctx.guild.name,\n colour= ctx.guild.owner.colour\n )\n\n embed.set_thumbnail(url=ctx.guild.icon_url)\n\n statuses = [len(list(filter(lambda m:... | [
"0.598221",
"0.58984613",
"0.58862126",
"0.57446456",
"0.5690402",
"0.564421",
"0.56369436",
"0.55805933",
"0.5483065",
"0.5479517",
"0.54745346",
"0.5445657",
"0.53902596",
"0.5382697",
"0.52869904",
"0.5268995",
"0.5254527",
"0.52532613",
"0.5236347",
"0.5227437",
"0.520712... | 0.7259492 | 0 |
Check that the fileupload field data contains a valid image (GIF, JPG, PNG, etc. whatever Pillow supports). | def to_python(self, data):
f = super().to_python(data)
if f is None:
return None
if hasattr(f, 'seek') and callable(f.seek):
f.seek(0)
return f | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_image(image):\n msg = image_validation(image)\n if msg:\n raise ValidationError(msg)",
"def test_upload_invalid_image_field(self):\n url = create_upload_image_url(self.recipe.id)\n\n res = self.client.post(url, {\"image\": \"not_image\"}, format=\"multipart\")\n\n s... | [
"0.7209003",
"0.701283",
"0.6928476",
"0.6868208",
"0.6840397",
"0.669595",
"0.66787404",
"0.6673956",
"0.6660406",
"0.6651892",
"0.66257185",
"0.66222644",
"0.65953416",
"0.6594749",
"0.65880215",
"0.657784",
"0.65657496",
"0.6558707",
"0.65190226",
"0.6509398",
"0.647481",
... | 0.0 | -1 |
Load a pfm file as a numpy array | def readPFM(file):
file = open(file, 'rb')
color = None
width = None
height = None
scale = None
endian = None
header = file.readline().rstrip()
if header == b'PF':
color = True
elif header == b'Pf':
color = False
else:
raise Exception('Not a PFM file.')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_pfm(filename):\n filename = process(filename)\n with open(filename, \"r\", encoding=\"ISO-8859-1\") as file:\n nc = 3 if file.readline().rstrip() == \"PF\" else 1\n width, height = [int(x) for x in file.readline().rstrip().split()]\n shape = (height, width, nc)\n img = np... | [
"0.7168331",
"0.67942333",
"0.6766622",
"0.6746099",
"0.66631687",
"0.66081446",
"0.6573312",
"0.64853144",
"0.64757055",
"0.64460194",
"0.63697314",
"0.6354761",
"0.6304555",
"0.62857765",
"0.6278143",
"0.6269284",
"0.62009907",
"0.6198456",
"0.6192154",
"0.61494",
"0.613625... | 0.7168952 | 0 |
Closes the input stream. Implement for each class inheriting from this base class. | def close(self):
raise NotImplementedError("`close` method is not implemented!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\n self.p.close(self.inStream)",
"def close(self):\n self._raw_stream.close()",
"def close(istream):\n # e.g. close files or disconnect apis\n istream.close()",
"def close(self):\n _check_init()\n if self._input is not None:\n self._input.Close()\n... | [
"0.77910525",
"0.74855524",
"0.72816855",
"0.72583944",
"0.71702224",
"0.7096506",
"0.707678",
"0.6951112",
"0.6813278",
"0.67478746",
"0.662871",
"0.66201234",
"0.6612518",
"0.6608153",
"0.6597965",
"0.6583388",
"0.6546983",
"0.6536023",
"0.6501895",
"0.6499266",
"0.6491975"... | 0.635868 | 30 |
Test the ``plt_residual_offsets`` function | def test_plt_residual_offsets():
ta = WATA()
wata_data = define_testdata()
ta.source = ColumnDataSource(data=wata_data)
ta.add_time_column()
ta.setup_date_range()
result = ta.plt_residual_offsets()
assert bokeh_plot_type == type(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _residual(function, p, x, y, y_err):\n return (y - function(p, x)) / y_err",
"def test_regress_residuals(self):\r\n x = [1.0, 2.0, 3.0, 4.0, 5.0]\r\n y = [2.1, 4.2, 5.9, 8.4, 9.6]\r\n result = regress_residuals(x, y)\r\n self.assertFloatEqual(result, [-0.1, 0.08, -0.14, 0.4... | [
"0.67898595",
"0.6704861",
"0.65182054",
"0.63889945",
"0.63721776",
"0.62628126",
"0.6231846",
"0.6057031",
"0.5902097",
"0.5881215",
"0.5877174",
"0.58343905",
"0.5807807",
"0.57777864",
"0.5720431",
"0.56970227",
"0.56752205",
"0.5602011",
"0.5599224",
"0.5550275",
"0.5507... | 0.6831052 | 0 |
For all OpenMM particle parameters, set charge to 0 | def zero_out_qq(omm_system, omm_context,
original_particle_parameters=None):
build_original_pparams = False
if original_particle_parameters is None:
original_particle_parameters = []
build_original_pparams = True
for force in omm_context.getSystem().getForces():
if isinstance... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_params(self):\n for pp in self.params:\n if 'optimizer_param' in pp.tags:\n pp.set_value(np.zeros(pp.get_value(borrow=True).shape, dtype=theano.config.floatX))",
"def resetMass(self):\n self.cm = np.array([0, 0, 0])\n self.m = 0\n self.iT = np.ident... | [
"0.6424862",
"0.60686916",
"0.59661573",
"0.59435624",
"0.5915792",
"0.5898966",
"0.5853008",
"0.58226246",
"0.58226246",
"0.57962126",
"0.57962126",
"0.57888985",
"0.5769204",
"0.5768316",
"0.5761745",
"0.5741",
"0.57274556",
"0.5710388",
"0.56893355",
"0.5670834",
"0.567017... | 0.58371806 | 7 |
Transform a matrix of positive elements to a markovlike matrix by dividing each row by the sum of the elements of the row. | def normalize_markov_matrix(transition_matrix, reversible=False):
t_matrix = np.array(transition_matrix, dtype=np.float64)
if reversible:
t_matrix = t_matrix.T + t_matrix
n_states = len(t_matrix)
assert n_states == len(t_matrix[0])
for i in range(n_states):
if (t_matrix[i, :] < 0).... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalizeMatrix( self, matrix, sums ):\n matrix = matrix.astype( float )\n\n numpy.multiply( matrix, matrix, matrix )\n numpy.divide( matrix, sums, matrix ) \n matrix = numpy.transpose( matrix )\n numpy.divide( matrix, sums, matrix )\n matrix *= 100\n\n r... | [
"0.5759078",
"0.5739116",
"0.5723317",
"0.5613334",
"0.55930793",
"0.55659616",
"0.5564418",
"0.55388045",
"0.5536578",
"0.5517576",
"0.551429",
"0.5498729",
"0.5493847",
"0.54323244",
"0.54098535",
"0.5359036",
"0.5287974",
"0.5270153",
"0.5248449",
"0.52344084",
"0.52234775... | 0.57102346 | 3 |
Normalize a vector by dividing each element by the total sum of all its elements | def normalize(my_vector):
my_vector = np.array(my_vector)
size = len(my_vector)
sum_ = sum(my_vector)
if sum_ != 0.0:
for i in range(size):
my_vector[i] = my_vector[i] / sum_
return my_vector | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normBySum(vector):\n\treturn np.divide(vector,float(sum(vector)))",
"def normalizeVector(v):\n normalizer = 1.0 / sum(v)\n\n normalized = [i * normalizer for i in v]\n return normalized",
"def normalize(arr):\n\n total = sum(arr)\n\n return list(map(lambda x: x / total, arr))",
"def normalize(... | [
"0.81921554",
"0.80004805",
"0.7677651",
"0.76440805",
"0.76382816",
"0.75637466",
"0.75351405",
"0.75155896",
"0.74846435",
"0.7402586",
"0.7385171",
"0.7378984",
"0.734323",
"0.7335654",
"0.7318486",
"0.72886264",
"0.7257571",
"0.72418565",
"0.7230987",
"0.71928865",
"0.711... | 0.82843494 | 0 |
Calculate the eigen values and eigen vectors of the transposed transition matrix | def pops_from_tmatrix(transition_matrix):
check_tmatrix(transition_matrix)
n_states = len(transition_matrix)
# Cleaning the transition matrix
cleaned_matrix, removed_states = clean_tmatrix(transition_matrix)
# Computing
eig_vals, eig_vecs = np.linalg.eig(cleaned_matrix.T)
eig_vecs = eig_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eigen(M):\n values, vectors = np.linalg.eig(M)\n return values, vectors",
"def eigen_decomp(matrix):\n w = None\n v = None\n ### YOUR CODE HERE\n w,v=np.linalg.eig(matrix)\n ### END YOUR CODE\n return w, v",
"def eigen_decomposition(self):\n w, V = linalg.eigh(self.K)\n ... | [
"0.72649026",
"0.7148297",
"0.70320636",
"0.68540686",
"0.6627855",
"0.6584551",
"0.65067756",
"0.6504993",
"0.64850354",
"0.6443049",
"0.64367837",
"0.6435948",
"0.6428457",
"0.6410131",
"0.6401041",
"0.6346989",
"0.6331505",
"0.6327404",
"0.6317906",
"0.63075197",
"0.630146... | 0.0 | -1 |
Test exporting assessments with conflicting custom attribute names. | def test_export_assessments_with_filters_and_conflicting_ca_names(self):
self.import_file(u"assessment_template_no_warnings.csv")
self.import_file(u"assessment_with_templates.csv")
# also create an object level custom attribute with a name that clashes
# with a name of a "regular" attribute
assessm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_import_assessments_with_templates(self):\n\n self.import_file(\"assessment_template_no_warnings.csv\")\n response = self.import_file(\"assessment_with_templates.csv\")\n self._check_csv_response(response, {})\n\n assessment = models.Assessment.query.filter(\n models.Assessment.slug == \... | [
"0.6372443",
"0.6248295",
"0.6026427",
"0.5942778",
"0.58766216",
"0.5788114",
"0.5778432",
"0.56836873",
"0.568146",
"0.56199855",
"0.56040704",
"0.55626106",
"0.55357933",
"0.5510906",
"0.5504582",
"0.5491917",
"0.54792255",
"0.54728407",
"0.54683757",
"0.5463582",
"0.54556... | 0.7195836 | 0 |
Return a name for this data set (likely set during the constructor) | def get_name(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataset_name(self):\n return self.dataset.name",
"def dataset_name(self):\n return self._dataset_name",
"def get_dataset_name(self):\n raise NotImplementedError",
"def get_dataset_name(self):\n return self.dataset_name",
"def name(self):\n return 'data_extraction_for_... | [
"0.7717186",
"0.76749545",
"0.7661689",
"0.7556866",
"0.7321283",
"0.7303024",
"0.72896355",
"0.7206409",
"0.7192157",
"0.7192157",
"0.71811366",
"0.71686035",
"0.71555495",
"0.71555495",
"0.71555495",
"0.71555495",
"0.71555495",
"0.71555495",
"0.71555495",
"0.71555495",
"0.7... | 0.0 | -1 |
Initialize Wav2Lip dataset class. | def __init__(self, dataroot, img_size, filelists_path, split):
self.image_path = dataroot
self.img_size = img_size
self.split = split
self.all_videos = get_image_list(self.image_path, self.split) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwargs):\n super(DeepSpeakerDataLoader, self).__init__(*args, **kwargs)",
"def __init__(self):\n self.__dataset = None",
"def __init__(self):\n log.msg(\"Initializing Twitch parser.\")\n\n # initialize our data members\n self.streams = tuple()\n ... | [
"0.6001145",
"0.5979969",
"0.5950341",
"0.5939494",
"0.5899911",
"0.5890568",
"0.58755016",
"0.58668",
"0.58588725",
"0.584755",
"0.5807136",
"0.57497144",
"0.5727289",
"0.57197326",
"0.5710834",
"0.5698481",
"0.5688412",
"0.56869924",
"0.5669083",
"0.5654246",
"0.56534135",
... | 0.0 | -1 |
Create a colormap of flats based no prace per square meter under development | def coords_plot(self):
self.load_coords()
x = []
y = []
px = []
for item in self.coords:
if item[1] >52.10 and item[1] <52.4 and item[2]>20.8 and item [2] <21.4:
x.append(item[1])
y.append(item[2])
px.append(item... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_density_cmap():\n # Add completely white color to Reds colormap in Matplotlib\n list_colors = plt.cm.datad['Reds']\n list_colors = list(list_colors)\n list_colors.insert(0, (1, 1, 1))\n list_colors.insert(0, (1, 1, 1))\n lscm = matplotlib.colors.LinearSegmentedColormap.from_list(\"my_Reds... | [
"0.6943691",
"0.6875001",
"0.68058205",
"0.67240196",
"0.6699318",
"0.6668012",
"0.666336",
"0.66537863",
"0.66451186",
"0.6640226",
"0.66197497",
"0.66197497",
"0.660369",
"0.6580764",
"0.6571373",
"0.6571373",
"0.65682155",
"0.6515903",
"0.64752007",
"0.6455428",
"0.6438120... | 0.0 | -1 |
Method returns a string representation of the deck | def _get_grid_representations(self):
representation = '-----------Loading Sequence----------------------------------------------------------------\n'
for row in self.grid:
for col in row:
if col == -1:
representation += 'X\t'
elif col == 0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n string = \"Deck contains \"\n\n for i in range(len(self.deck)):\n string += str(self.deck[i].get_suit()) + str(self.deck[i].get_rank()) + \" \"\n return string",
"def __str__(self):\r\n output = \"Deck contains\"\r\n for card in self.deck:\r\n ... | [
"0.8406452",
"0.8332581",
"0.82304335",
"0.81441444",
"0.80965894",
"0.79840666",
"0.79818296",
"0.7970407",
"0.7654539",
"0.76412016",
"0.74860907",
"0.74439895",
"0.74439895",
"0.74088955",
"0.7395283",
"0.7355099",
"0.7341276",
"0.7306411",
"0.726058",
"0.7257771",
"0.7220... | 0.0 | -1 |
Return whether a class is a valid Host Filter class. | def _is_filter_class(cls):
return type(cls) is types.TypeType and issubclass(cls, BaseHostFilter) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isValidFilter(klass):\n if not isclass(klass):\n logger.error(f\"{klass!r} is not a class\")\n return False\n if not callable(klass):\n logger.error(f\"{klass!r} is not callable\")\n return False\n if getfullargspec(klass.__call__).args != getfullargspec(BaseFilter.__call__... | [
"0.7400233",
"0.6322352",
"0.6105194",
"0.60316503",
"0.5810963",
"0.57681763",
"0.5738779",
"0.5673392",
"0.56654876",
"0.56495607",
"0.56482285",
"0.56318885",
"0.55875075",
"0.5574385",
"0.55625176",
"0.5555831",
"0.5548639",
"0.55474895",
"0.55452776",
"0.55308455",
"0.55... | 0.835078 | 0 |
Gets a substring of a line, from x1 to x2 [inclusive, exclusive) | def get_substr(self, y, x1, x2):
return self.lines[y][x1 : x2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_substring(\n self, start: ir.FloatingValue, end: ir.FloatingValue\n ) -> ir.LineStringValue:\n return ops.GeoLineSubstring(self, start, end).to_expr()",
"def get_substring(self, start, end):\n return self.input[start:end]",
"def get_str_between_s_and_e(start_str, end_str, line)... | [
"0.67367285",
"0.67278343",
"0.6501663",
"0.64438224",
"0.60840136",
"0.6077105",
"0.6071085",
"0.5976423",
"0.59403944",
"0.59112716",
"0.58666843",
"0.58606637",
"0.58606637",
"0.5832403",
"0.5779781",
"0.5741213",
"0.57312834",
"0.57237965",
"0.57098037",
"0.56422216",
"0.... | 0.81611043 | 0 |
Row normalization function Implement a function that normalizes each row of a matrix to have unit length. | def normalizeRows(x):
# this is the same as norm function which takes sqrt(sum of squares of elements along each matrix-row)
norm_row = np.sqrt(np.sum(x**2, axis=1)) # axis = 0 is column-wise sum. axis=1 is row-wise sum
# returns [5, 2.25] for below example in `test_normalize_rows`
norm_col = np.resha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalizeRows(x):\n\n ### YOUR CODE HERE\n norm2 = np.linalg.norm(x,2,axis = 1).reshape(x.shape[0],-1)\n x = x/norm2\n ### END YOUR CODE\n\n return x",
"def normalizeRows(x):\n\n ### YOUR CODE HERE\n # using l2 norm to normalize\n x = x / np.sqrt(np.sum(x * x, axis=-1, keepdims=True))... | [
"0.8100325",
"0.80679506",
"0.7920536",
"0.7845435",
"0.7514513",
"0.7423473",
"0.74134856",
"0.7315453",
"0.71876514",
"0.7096419",
"0.7090385",
"0.6912171",
"0.68501747",
"0.67711014",
"0.6762052",
"0.6597388",
"0.65409607",
"0.65031916",
"0.65025306",
"0.6491698",
"0.64803... | 0.7916425 | 3 |
|coro| Ban a user from the team. | async def ban(self, user: User, *,
reason: str = None,
delete_after: datetime.datetime = None,
delete_message_days: int = None
):
if delete_message_days is not None and delete_after is not None:
raise InvalidArgument('Specify delete_message_days or delete_after, not both.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def hackban(self, ctx, user_id: int):\n try:\n await self.liara.http.ban(str(user_id), str(ctx.guild.id))\n await ctx.send('Done. Good riddance.')\n except discord.NotFound:\n await ctx.send('That user doesn\\'t exist.')\n except discord.Forbidden:\n ... | [
"0.69669664",
"0.6923701",
"0.6905808",
"0.6826883",
"0.674119",
"0.67385405",
"0.6721724",
"0.6615344",
"0.6611648",
"0.65819037",
"0.6559862",
"0.6556454",
"0.64762133",
"0.6394379",
"0.63453287",
"0.63080794",
"0.63042814",
"0.62889004",
"0.6268676",
"0.62594694",
"0.62564... | 0.59082985 | 36 |
Return date and precipitation data as json | def precip():
date_prcp=session.query(measurements.date,measurements.prcp).all()
date_prcp_df=pd.DataFrame(date_prcp).set_index('date')
date_prcp_dict=date_prcp_df.to_dict()
return jsonify(date_prcp_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precipitation():\n # Query \n results = session.query(Measurement.date, Measurement.prcp).all()\n \n dict = {}\n for result in results:\n dict[result.date] = result.prcp\n\n return jsonify(dict)",
"def precipitation():\n results_precip = engine.execute(\"SELECT date, prcp FROM Mea... | [
"0.81172603",
"0.79339975",
"0.7873939",
"0.78680897",
"0.7852904",
"0.7848465",
"0.78243965",
"0.77953184",
"0.7762617",
"0.7752964",
"0.774965",
"0.7748303",
"0.7717237",
"0.77054465",
"0.76753086",
"0.7662834",
"0.7641662",
"0.7620495",
"0.7620462",
"0.7611507",
"0.7608559... | 0.80652446 | 1 |
Time when the instance was deleted. Empty if not deleted. | def delete_time(self) -> str:
return pulumi.get(self, "delete_time") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleted_time(self) -> str:\n return pulumi.get(self, \"deleted_time\")",
"def destroy_time(self) -> str:\n return pulumi.get(self, \"destroy_time\")",
"def deletion_date(self) -> str:\n return pulumi.get(self, \"deletion_date\")",
"def destroy_event_time(self) -> str:\n return... | [
"0.87649816",
"0.7832633",
"0.76353264",
"0.72575474",
"0.6848147",
"0.6733119",
"0.66159266",
"0.66159266",
"0.66159266",
"0.66159266",
"0.6463335",
"0.6421133",
"0.6415361",
"0.6377617",
"0.6340735",
"0.6326473",
"0.63263017",
"0.63263017",
"0.63263017",
"0.6304959",
"0.625... | 0.804285 | 2 |
Function converts string to date | def parse_date(sdate):
if sdate == '':
return None
else:
return dt.strptime(sdate, '%Y-%m-%d') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_to_date(string):\n params = string.strip().split('-')\n year = int(params[0])\n month = int(params[1])\n day = int(params[2])\n d = date(year, month, day)\n return d",
"def _str_to_date(self, date):\n return datetools.date_parser(date)",
"def str_to_d... | [
"0.824094",
"0.8038457",
"0.7912825",
"0.79072154",
"0.7751148",
"0.77165186",
"0.76758957",
"0.7671344",
"0.7669091",
"0.764955",
"0.7632643",
"0.76314145",
"0.76158357",
"0.7566669",
"0.75314397",
"0.7502928",
"0.7496041",
"0.7481978",
"0.74614275",
"0.73622155",
"0.734941"... | 0.0 | -1 |
Drop rows or cols based on the ratio of NA values along the axis. | def dropna(df, axis=0, th=0.4):
df = df.copy()
axis = 0 if axis==1 else 1
col_idx = df.isna().sum(axis=axis)/df.shape[axis] <= th
df = df.iloc[:, col_idx.values]
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def purgeNanEveryWhere(df):\n #Row-wise dropping\n toDrop = np.array([])\n for i in range(df.shape[0]):\n if( np.sum ( pd.isnull(df.iloc[i]) ) == df.shape[1]-1 ):\n toDrop= np.append(toDrop,i)\n df.drop(df.index[toDrop.astype(int)],inplace=True) \n #Column-wise dropping\n fo... | [
"0.68152285",
"0.66806734",
"0.6606132",
"0.64539176",
"0.6390422",
"0.6371664",
"0.6363131",
"0.62996393",
"0.6294165",
"0.6228186",
"0.62018967",
"0.6194754",
"0.6069667",
"0.6059363",
"0.6059216",
"0.6054782",
"0.59790504",
"0.5978665",
"0.5977065",
"0.59753233",
"0.589783... | 0.7240114 | 0 |
Compute area under the ROC for regression. | def reg_auroc(y_true, y_pred, th=0.5):
y_true = np.where(y_true < th, 1, 0)
y_score = np.where(y_pred < th, 1, 0)
reg_auroc_score = sklearn.metrics.roc_auc_score(y_true, y_score)
return reg_auroc_score | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(self):\n return 0.5*np.abs(np.dot(self.x,np.roll(self.y,1))-np.dot(self.y,np.roll(self.x,1)))",
"def total_area(self) :\n area = 0\n for i in self.residues :\n area += i.solvent_acc_area\n return area",
"def total_area(self):\n return numpy.prod([r[1] - r[... | [
"0.66914207",
"0.6691028",
"0.65666336",
"0.6514005",
"0.6275835",
"0.62515485",
"0.61757225",
"0.6159982",
"0.6149491",
"0.61308426",
"0.60962856",
"0.6095552",
"0.6091085",
"0.6045997",
"0.6041426",
"0.6035901",
"0.5994329",
"0.5972812",
"0.5966892",
"0.5961227",
"0.5958564... | 0.65511185 | 3 |
Takes dict of scores from sklean's cross_validate and converts to df with certain updates. | def update_cross_validate_scores(cv_scores):
# TODO: move this func to cvrun.py (rename cvrun.py utils_cv.py)
cv_folds = len(list(cv_scores.values())[0])
df = cv_scores_to_df(cv_scores, decimals=3, calc_stats=False)
# Add `metric` col
v = list(map(lambda x: '_'.join(x.split('_')[1:]), df.index))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess_scores(scores):\n\tscores['user_assessment_date'] = pd.to_datetime(scores['user_assessment_date'])\n\tscores['user_assessment_age'] = pd.to_datetime(scores['user_assessment_date'].max() + pd.DateOffset(1)) - scores['user_assessment_date']\n\n\t#converting Date to days\n\tscores['user_assessment_age'... | [
"0.6384957",
"0.63551456",
"0.617499",
"0.58769953",
"0.5742682",
"0.5715245",
"0.5707312",
"0.5681102",
"0.5660799",
"0.5657595",
"0.5647516",
"0.5562742",
"0.5552821",
"0.5547868",
"0.5507941",
"0.5467803",
"0.539571",
"0.5362884",
"0.53500915",
"0.5347908",
"0.5310593",
... | 0.6821416 | 0 |
Takes dict of scores from sklean's cross_validate and converts to df. | def cv_scores_to_df(cv_scores, decimals=3, calc_stats=False):
# Drop certain keys that come from cross_validate()
for k in ['fit_time', 'train_time', 'score_time']:
if k in cv_scores.keys():
del cv_scores[k] # cv_scores.pop(k, None)
cv_scores = pd.DataFrame(cv_scores).T
cv_scores.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_test_scores(estimator_scores):\n\n # Converting the dictionary of scores from cross_validate to a dataframe\n # and dropping unnecessary rows\n scores_df = (pd\n .DataFrame\n .from_dict(estimator_scores)\n .drop(['fit_time', 'score_time'], axis=1))... | [
"0.6150245",
"0.6125588",
"0.60803777",
"0.60243475",
"0.59991693",
"0.59424186",
"0.5929478",
"0.5906807",
"0.58710146",
"0.58463275",
"0.5824873",
"0.5717466",
"0.56560445",
"0.5653157",
"0.56246173",
"0.5624378",
"0.5621734",
"0.5594994",
"0.5584466",
"0.5580193",
"0.55772... | 0.6881527 | 0 |
waits 1 second so that the QT app is running and then launches the ball animation thread | def start_animation(self):
time.sleep(1)
self.fishbowl.animate_balls() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_loading_screen(self):\n self.timer = QtCore.QTimer()\n self.timer.timeout.connect(self.animation)\n self.timer.start(TIMER_INTERVAL_IN_MSEC)",
"def start(self):\n\n self.top.after(15, self.video_loop)",
"def start(self):\n if not self._is_running:\n self._... | [
"0.6708043",
"0.66499645",
"0.6612362",
"0.6566007",
"0.6504588",
"0.6421836",
"0.6352333",
"0.63310903",
"0.6311518",
"0.62918454",
"0.6288204",
"0.62429243",
"0.62421906",
"0.6222013",
"0.6204568",
"0.6203996",
"0.6195577",
"0.61907804",
"0.61905926",
"0.61809856",
"0.61631... | 0.68744594 | 0 |
Get base classes for the resulting extension type. For jit types, these are simply the bases of the Python class we decorated. For autojitdecorated classes we get a more complicated inheritance scheme (see AutojitExtensionCompiler.get_bases). | def get_bases(self):
return self.py_class.__bases__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_superclasses(self, t):\n if isinstance(t, pytd.ClassType):\n return sum((self.get_superclasses(c) for c in t.cls.bases), [t])\n elif isinstance(t, pytd.AnythingType):\n # All types, even \"?\", inherit from object.\n return [pytd.NamedType(\"builtins.object\")]\n elif isinstance(t, ... | [
"0.713211",
"0.7131509",
"0.6696836",
"0.666036",
"0.6574672",
"0.622522",
"0.6122663",
"0.61087",
"0.6108414",
"0.6091516",
"0.60429156",
"0.6001359",
"0.6000882",
"0.5891685",
"0.5888856",
"0.58801377",
"0.58759934",
"0.5856311",
"0.5814993",
"0.5803133",
"0.5767041",
"0.... | 0.7490308 | 0 |
Return true iff s appears as a substring | def hasSubstring(self, s):
node, off = self.followPath(s)
return node is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def issubstring(substring, string):\n return substring in string",
"def _is_substring(s1, s2):\n\treturn s1.find(s2) != -1",
"def isstringIs_substring(str1, str2):\r\n if str1 in str2:\r\n return True\r\n else:\r\n False",
"def isSubString(string1, string2, minMatchLength = 0):\n retu... | [
"0.7935169",
"0.76511735",
"0.7352866",
"0.70086056",
"0.6864206",
"0.6748644",
"0.6730506",
"0.6711265",
"0.65831876",
"0.65759295",
"0.6573499",
"0.65438676",
"0.6487382",
"0.64675325",
"0.6432309",
"0.6415039",
"0.6415039",
"0.6371927",
"0.63714164",
"0.6360899",
"0.634127... | 0.8062963 | 0 |
Return true iff s is a suffix | def hasSuffix(self, s):
node, off = self.followPath(s)
if node is None:
return False # fell off the tree
if off is None:
# finished on top of a node
return '$' in node.out
else:
# finished at offset 'off' within an edge leading to 'node'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_suffix(suffix: str, word: str):\n return word.endswith(suffix)",
"def is_suffix(v,s):\n c = len(v)-1\n n = len(s)\n return c + v[c] == 2*n",
"def hasSuffixLink(self):\n return False if self.suffix_link is None else True",
"def ends_with(strn, suffix):\n return strn.endswith(suffi... | [
"0.8135886",
"0.8091354",
"0.73786396",
"0.7286839",
"0.71542937",
"0.70127165",
"0.6860003",
"0.6797614",
"0.6696741",
"0.66883916",
"0.66883916",
"0.6622363",
"0.6605842",
"0.65794384",
"0.648719",
"0.64368826",
"0.640317",
"0.6397085",
"0.6335966",
"0.6133945",
"0.6125691"... | 0.8047783 | 2 |
The identity_block is the block that has no conv layer at shortcut Arguments | def identity_block(input_tensor, kernel_size, filters, stage, block,
use_bias=True, train_bn=True):
nb_filter1, nb_filter2, nb_filter3 = filters
conv_name_base = 'res' + str(stage) + block + '_branch'
bn_name_base = 'bn' + str(stage) + block + '_branch'
x = KL.Conv2D(nb_filter1, (1, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identity_block(self, input_tensor, filters, activation, stage, block, start_with_batch_norm = True):\n\n # Set the naming convention\n conv_name_base = 'res' + str(stage) + block + '_branch'\n batch_norm_name_base = 'batch_norm' + str(stage) + block + '_branch'\n\n x_shortcut = inpu... | [
"0.7417824",
"0.72852165",
"0.72147304",
"0.72146046",
"0.721052",
"0.71971375",
"0.71670413",
"0.7152859",
"0.7131995",
"0.71131915",
"0.7111289",
"0.708507",
"0.70782053",
"0.7077924",
"0.70730114",
"0.70315313",
"0.70171803",
"0.70157117",
"0.700963",
"0.6998712",
"0.69987... | 0.7029831 | 17 |
conv_block is the block that has a conv layer at shortcut Arguments | def conv_block(input_tensor, kernel_size, filters, stage, block,
strides=(2, 2), use_bias=True, train_bn=True):
nb_filter1, nb_filter2, nb_filter3 = filters
conv_name_base = 'res' + str(stage) + block + '_branch'
bn_name_base = 'bn' + str(stage) + block + '_branch'
x = KL.Conv2D(nb_filte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv_block(self, output_channel, filter_, activate):\n return self.add_layer(conv_block, output_channel, filter_, activate)",
"def conv_block(input, filters, phase=phase):\r\n\r\n conv_block = tf.layers.conv2d(\r\n inputs=input,\r\n filters=filters,\r\n kernel_s... | [
"0.75352484",
"0.7485905",
"0.7364652",
"0.72221285",
"0.7209271",
"0.72062933",
"0.72031564",
"0.71860236",
"0.7177927",
"0.7174483",
"0.7160332",
"0.71580297",
"0.71574706",
"0.71514505",
"0.7130759",
"0.71060336",
"0.70997053",
"0.7073006",
"0.70581305",
"0.70305437",
"0.7... | 0.6993496 | 24 |
Lazy powerset construction, automatically prunes itself | def determinize(A):
A = epsilon_remove(A)
subset2state = {frozenset({0}): 0}
state2subset = {0: frozenset({0})}
alphabet = A.alphabet
B = Automaton(1, set())
if 0 in A.accepting:
B.accepting.add(0)
frontier = {0}
while len(frontier) > 0:
new_frontier = set()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def powerset(a):\n if len(a) == 0:\n return set([frozenset()])\n accumulator = set()\n a = set(a)\n element = a.pop()\n for subset in powerset(a):\n accumulator.add(subset)\n accumulator.add(frozenset(set([element]) | subset))\n return accumulator",
"def power_set(self):\n ... | [
"0.6359265",
"0.6322484",
"0.6185431",
"0.613952",
"0.6014685",
"0.6001673",
"0.59770066",
"0.5972335",
"0.5948192",
"0.59262234",
"0.59124357",
"0.59046215",
"0.5901743",
"0.5848007",
"0.58461493",
"0.58295226",
"0.5825275",
"0.58178276",
"0.58114785",
"0.57671356",
"0.57671... | 0.0 | -1 |
Initialize your data structure here. Set the size of the queue to be k. | def __init__(self, k: int):
self.maxlen = k
# 在Python中这样的操作可以提高效率吗(空间或者时间)? leetcode 提交是一样的
self.circular = [None] * k
self.front = 0
self.rear = -1
self.size = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, k):\n self.queue = []\n self.size = k",
"def __init__(self, k):\n self.queue = [0]*k\n self.headIndex = 0\n self.count = 0\n self.capacity = k",
"def __init__(self, k: int):\n self.queue = [0]*k\n self.headIndex = 0\n self.count ... | [
"0.8516782",
"0.8472152",
"0.8441989",
"0.84088355",
"0.83643377",
"0.8301168",
"0.8067307",
"0.8067155",
"0.78686005",
"0.78605986",
"0.77475804",
"0.76817715",
"0.766867",
"0.76042986",
"0.7504088",
"0.71947587",
"0.71298",
"0.6975332",
"0.6913572",
"0.69102687",
"0.6889578... | 0.7387965 | 15 |
Get the front item from the queue. | def Front(self) -> int:
return self.circular[self.front] if self.size else -1
# if self.size:
# return self.cicular[self.front]
# else:
# return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFront(self):\n\t\tfront = self.queue[self.front]\n\t\treturn front\n\t\tpass",
"def front(self):\n return self.queue[0] if not self.empty() else None",
"def Front(self):\r\n if (len(self.queue) >= 1):\r\n return self.queue[0]\r\n else:\r\n return -1",
"def fr... | [
"0.90385115",
"0.89434814",
"0.846308",
"0.8426328",
"0.8357853",
"0.83309764",
"0.83309764",
"0.83211964",
"0.83211964",
"0.82988536",
"0.8279939",
"0.8216258",
"0.8213497",
"0.8213348",
"0.8209029",
"0.8205413",
"0.81683636",
"0.812805",
"0.81277895",
"0.8076473",
"0.799508... | 0.0 | -1 |
Get the last item from the queue. | def Rear(self) -> int:
return self.circular[self.rear] if self.size else -1
# if self.size:
# return self.circular[-1]
# # return self.circular[self.rear]
# else:
# return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last(self):\n if self.is_empty():\n raise ValueError('Queue is empty!')\n return self.last_node().element().value()",
"def last(self):\n return self.deque[-1]",
"def last_item(self):\n return self.container[self.length-1]",
"def Rear(self):\r\n if (len(self.q... | [
"0.82451856",
"0.80613",
"0.8023248",
"0.77849776",
"0.7629952",
"0.7628782",
"0.76055205",
"0.75932163",
"0.7584632",
"0.75637347",
"0.7543559",
"0.75429386",
"0.7518005",
"0.7494505",
"0.746898",
"0.7461607",
"0.74455327",
"0.73941535",
"0.73889613",
"0.73865324",
"0.737336... | 0.0 | -1 |
Checks whether the circular queue is empty or not. | def isEmpty(self) -> bool:
return not self.size | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return self.queue == []",
"def is_empty(self):\n return len(self.the_queue) == 0",
"def is_empty(self):\n return len(self.queue) == 0",
"def is_empty(self):\n return len(self.queue) == 0",
"def is_empty(self):\n return len(self.__queue) > 0",
"def ... | [
"0.84918785",
"0.84607804",
"0.8429387",
"0.8429387",
"0.83951026",
"0.82831895",
"0.8246613",
"0.82329935",
"0.8193397",
"0.8184179",
"0.81770307",
"0.8163974",
"0.81180215",
"0.8102001",
"0.80947953",
"0.8042463",
"0.79564434",
"0.7913296",
"0.7909012",
"0.7909012",
"0.7901... | 0.0 | -1 |
Checks whether the circular queue is full or not. | def isFull(self) -> bool:
return self.size == self.maxlen | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isFull(self):\n return len(self.queue) == self.size",
"def isFull(self):\r\n if (len(self.queue) == self.maxlen):\r\n return True\r\n else:\r\n return False",
"def is_empty(self):\n return len(self.__queue) > 0",
"def is_empty(self):\n return len(s... | [
"0.84751034",
"0.8299797",
"0.78827924",
"0.78358734",
"0.782498",
"0.782426",
"0.782426",
"0.7629194",
"0.76109856",
"0.76109785",
"0.75850576",
"0.7578127",
"0.7531097",
"0.7526271",
"0.7490314",
"0.7479896",
"0.747371",
"0.74505204",
"0.7448315",
"0.7435628",
"0.7421604",
... | 0.0 | -1 |
Checks parsed origin is None. Pass control to the validate_origin function. Returns ``True`` if validation function was successful, ``False`` otherwise. | def valid_origin(self, parsed_origin):
# None is not allowed unless all hosts are allowed
if parsed_origin is None and "*" not in self.allowed_origins:
return False
return self.validate_origin(parsed_origin) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_origin(self, parsed_origin):\n return any(\n pattern == \"*\" or self.match_allowed_origin(parsed_origin, pattern)\n for pattern in self.allowed_origins\n )",
"def check_origin(self, origin):\n return True",
"def check_origin(self, origin):\n retur... | [
"0.7646842",
"0.75754607",
"0.75754607",
"0.75754607",
"0.75754607",
"0.70084876",
"0.6954515",
"0.6388186",
"0.6255994",
"0.58356786",
"0.5776445",
"0.5742855",
"0.57113725",
"0.57013065",
"0.5669203",
"0.559975",
"0.55838186",
"0.5581787",
"0.5572417",
"0.5568081",
"0.55658... | 0.8300116 | 0 |
Validate the given origin for this site. Check than the origin looks valid and matches the origin pattern in specified list ``allowed_origins``. Any pattern begins with a scheme. After the scheme there must be a domain. Any domain beginning with a period corresponds to the domain and all its subdomains (for example, | def validate_origin(self, parsed_origin):
return any(
pattern == "*" or self.match_allowed_origin(parsed_origin, pattern)
for pattern in self.allowed_origins
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_origin(self, parsed_origin):\n # None is not allowed unless all hosts are allowed\n if parsed_origin is None and \"*\" not in self.allowed_origins:\n return False\n return self.validate_origin(parsed_origin)",
"def match_allowed_origin(self, parsed_origin, pattern):\n ... | [
"0.7817406",
"0.71039236",
"0.65975267",
"0.6359062",
"0.6315245",
"0.6315245",
"0.6315245",
"0.6315245",
"0.6104404",
"0.6009336",
"0.59931624",
"0.5918373",
"0.5909156",
"0.58889353",
"0.5634858",
"0.53963476",
"0.5246202",
"0.52342856",
"0.5225792",
"0.51650745",
"0.513451... | 0.77178377 | 1 |
Parse the message string message and return a intermediate representation of the message which can in turn be converted into a database tree. The structure is the following. For each keyed node, there is a tuple (node, items) where node is the node object itself and items is a list which contains the data matched by th... | def parse(self, message):
return self.parse_subtree(message)[1][0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message_parser(msg):\n # Start a new message\n new_msg = {\n \"messageType\": msg[\"messageType\"],\n \"messageID\": msg[\"messageID\"],\n \"messageURL\": msg[\"messageURL\"],\n \"messageIssueTime\": msg[\"messageIssueTime\"],\n 'messageBody'... | [
"0.5793024",
"0.5538835",
"0.54343635",
"0.5394789",
"0.5278391",
"0.5263013",
"0.52562886",
"0.5231319",
"0.5206912",
"0.5200666",
"0.5162891",
"0.5160833",
"0.5140216",
"0.50685716",
"0.5037561",
"0.5027684",
"0.50157744",
"0.5014303",
"0.5006186",
"0.50026345",
"0.50000435... | 0.6048471 | 0 |
Convert this message into a struct as required by | def unparse_struct(self):
result = {}
for node in filter(lambda x: x.parent is None, self.nodes):
_, child_list = result.setdefault(node.format_node.key, (node.format_node, []))
child_list.append(node.unparse_struct())
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_struct(self):\n return parsers.to_struct(self)",
"def to_struct(self):\n return {\"_class\": self.__class__.__name__,\n \"value\": self.__value, \n \"string\": cuni(self)}",
"def deserialize(self, str):\n if python3:\n codecs.lookup_error(\"rosmsg\").m... | [
"0.69606614",
"0.66855204",
"0.66295105",
"0.6625527",
"0.65596485",
"0.6548119",
"0.6547582",
"0.6521244",
"0.651251",
"0.64892447",
"0.64206463",
"0.64185786",
"0.6413732",
"0.6411368",
"0.63906705",
"0.6379438",
"0.63629615",
"0.6352646",
"0.63384295",
"0.6336275",
"0.6309... | 0.0 | -1 |
Return a string representation of this message. | def unparse(self):
return self.format.unparse(self.unparse_struct()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return self.message.as_string()",
"def __str__ (self):\n\n return self.message",
"def __str__(self) -> str:\n return \"Envelope(to={to}, sender={sender}, protocol_specification_id={protocol_specification_id}, message={message})\".format(\n to=self.to,\n ... | [
"0.82506686",
"0.8225756",
"0.80269396",
"0.78557736",
"0.7790642",
"0.7707805",
"0.7685787",
"0.7668287",
"0.7666409",
"0.7640587",
"0.763899",
"0.7625176",
"0.7625176",
"0.75903517",
"0.7587147",
"0.7585231",
"0.7575343",
"0.75542015",
"0.75542015",
"0.75542015",
"0.7554201... | 0.0 | -1 |
Apply a list conversion for all items in original_list. | def convert_list_by_key(
original_list, key_map, fill_in=False, whitelist=[], blacklist=[]
): # pylint: disable=dangerous-default-value
converted_list = []
for original in list(original_list):
converted_list.append(
convert_dict_by_key(original, key_map, fill_in=fill_in, whitelist=white... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_list(l):\r\n l = [list(elem) for elem in l]\r\n return l",
"def bulk_transform(self, list_of_data):\n new_list = []\n\n for item in list_of_data:\n new_list.append(self.transform(item))\n\n return new_list",
"def convert_items(self, items):\n if self.pre... | [
"0.669106",
"0.6690905",
"0.6584683",
"0.65592134",
"0.6412425",
"0.63520795",
"0.63383645",
"0.6265066",
"0.6143508",
"0.61312693",
"0.602669",
"0.5987237",
"0.59850675",
"0.59390295",
"0.5894239",
"0.586849",
"0.5865001",
"0.58510715",
"0.5829008",
"0.57371426",
"0.57090354... | 0.63884264 | 5 |
Sets the learning rate to the initial LR decayed by 1/decrease_rate every 10 epochs | def adjust_learning_rate_by_schedule(config, optimizer, epoch, decrease_rate=0.1):
if not isinstance(optimizer, torch.optim.SGD):
return
#lr = config.lr * (0.1 ** (epoch // 10))
if epoch and epoch % 10 == 0:
for i, param_group in enumerate(optimizer.param_groups):
param_group['lr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(initial_lr, optimizer, epoch, every_epoch):\n lr = initial_lr * (0.1 ** (epoch // every_epoch))\n for param_group in optimizer.param_groups:\n param_group['lr'] = lr",
"def adjust_learning_rate(optimizer, epoch, args):\n lr = args.lr\n if 20 < epoch <= 30:\n lr = 0.0001... | [
"0.76319885",
"0.75825876",
"0.75803655",
"0.75739485",
"0.7571104",
"0.75655967",
"0.7553353",
"0.7553347",
"0.75393635",
"0.753853",
"0.7529374",
"0.7522825",
"0.75174165",
"0.7517232",
"0.751665",
"0.7509014",
"0.74975663",
"0.74915737",
"0.74904794",
"0.7489288",
"0.74752... | 0.7426548 | 31 |
Generates a batch iterator; this is a generator function | def batch_iter(self, data, scores, batch_size):
data_size = len(data)
num_batches = math.ceil(len(data)/batch_size)
for batch_num in range(num_batches):
start_index = batch_num * batch_size
end_index = min((batch_num + 1) * batch_size, data_size)
yiel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n for batch in self.iterator:\n yield Batch.from_iterator_batch(batch, self.pad_index, self.sos_index, self.eos_index)",
"def batch_iter(input_data,batch_size):\r\n batch_ids,batch_mask,batch_segment,batch_label=[],[],[],[]\r\n for features in input_data:\r\n if... | [
"0.7835241",
"0.7798434",
"0.7786397",
"0.7754601",
"0.772694",
"0.7604501",
"0.74915266",
"0.7486854",
"0.7448429",
"0.7426344",
"0.73691976",
"0.733821",
"0.73252404",
"0.7299188",
"0.72931576",
"0.7280207",
"0.72485393",
"0.72469115",
"0.7235672",
"0.72192866",
"0.71851593... | 0.65765446 | 96 |
Decay the learning rate based on schedule | def adjust_learning_rate(lr, lr_decay_steps, optimizer, epoch, lr_decay_rate=0.1):
steps = list(map(int, lr_decay_steps.split(',')))
for milestone in steps:
lr *= lr_decay_rate if epoch >= milestone else 1.
for param_group in optimizer.param_groups:
param_group['lr'] = lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def learning_rate_decay(alpha, decay_rate, global_step, decay_step):\n \"\"\"if staircase == True\n decayed_learning_rate = learning_rate /\n (1 + decay_rate * floor(global_step / decay_step)))\"\"\"\n return tf.train.inverse_time_decay(\n alpha, global_step, decay_step, decay_rate, staircase=Tr... | [
"0.7373194",
"0.7292736",
"0.7228895",
"0.7211029",
"0.7203241",
"0.72028047",
"0.71989626",
"0.718389",
"0.7162159",
"0.71439254",
"0.7130453",
"0.7110413",
"0.7034126",
"0.70272094",
"0.7019835",
"0.700661",
"0.6999512",
"0.69994646",
"0.69744974",
"0.6970913",
"0.69616294"... | 0.6448708 | 94 |
Computes the accuracy over the k top predictions for the specified values of k | def accuracy(output, target, topk=(1,)):
with torch.no_grad():
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topk_accuracy(y, y_pred, k=2):\n pred = []\n for i in range(len(y)):\n if y[i] in y_pred[i][:k]:\n pred.append(1)\n else:\n pred.append(0)\n return sum(pred) / len(pred)",
"def accuracy(y_pred, y_actual, topk=(1, )):\n maxk = max(topk)\n batch_size = y_actua... | [
"0.83311",
"0.8286288",
"0.8239192",
"0.82308143",
"0.8221246",
"0.81875855",
"0.81859523",
"0.81764203",
"0.817261",
"0.81711614",
"0.8167704",
"0.8165669",
"0.8164918",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
"0.8163395",
... | 0.78628665 | 69 |
Create a string of k random characters including letters, digits and whitespace. | def random_string(k: int) -> str:
characters = string.ascii_letters + string.digits + ' '
return ''.join(random.choices(characters, k=k)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_string():\n\n k = random.randint(5, 10)\n return ''.join(random.choices(string.ascii_letters + string.digits, k=k))",
"def random_string() -> str:\n\n k = random.randint(5, 10)\n return ''.join(random.choices(string.ascii_letters + string.digits, k=k))",
"def rand_string():\n out = ''... | [
"0.8146227",
"0.8040712",
"0.760194",
"0.74491227",
"0.74265796",
"0.7365992",
"0.7250787",
"0.72305954",
"0.7218306",
"0.71683806",
"0.7147232",
"0.713552",
"0.71268374",
"0.7106268",
"0.71021384",
"0.70900416",
"0.7037375",
"0.703593",
"0.7031172",
"0.70232606",
"0.70229185... | 0.86409026 | 0 |
Sets the page_number_label of this CRFItemMetadata. | def page_number_label(self, page_number_label):
self._page_number_label = page_number_label | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_fetch_values_page_number(cls, page_number=None):\n cls._page_number = page_number",
"def set_page(self, page):\n\n\t\tif page is not None and not isinstance(page, int):\n\t\t\traise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: page EXPECTED TYPE: int', None, None)\n\t\t\n\t\tself.__page = page\n\... | [
"0.64171135",
"0.61489177",
"0.6137141",
"0.6114764",
"0.60671866",
"0.60616547",
"0.59743214",
"0.5770319",
"0.5686637",
"0.56367856",
"0.55440176",
"0.5525631",
"0.5525631",
"0.54636943",
"0.5457164",
"0.5397731",
"0.53417575",
"0.5326899",
"0.5301802",
"0.5284346",
"0.5258... | 0.84648216 | 0 |
Sets the question_number_label of this CRFItemMetadata. | def question_number_label(self, question_number_label):
self._question_number_label = question_number_label | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page_number_label(self, page_number_label):\n\n self._page_number_label = page_number_label",
"def get_label(self, list_question_int):\n \"\"\" list_question_int is 0 based, the question ids and labels are 1-based \"\"\"\n\n quiz_question = self.get_quiz_question(list_question_int)\n ... | [
"0.5779019",
"0.5340435",
"0.5264574",
"0.5264574",
"0.5136962",
"0.511571",
"0.5074241",
"0.5045586",
"0.5030891",
"0.5030891",
"0.5030891",
"0.5030891",
"0.5030891",
"0.5030891",
"0.5030891",
"0.5030891",
"0.5030891",
"0.5030891",
"0.5030891",
"0.49965665",
"0.49755958",
... | 0.8306851 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.