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 |
|---|---|---|---|---|---|---|
Compute Quantile values over each time period | def compute_quantile(risk, T_max: int, scenario_numbers, quantile):
print("\tComputing Quantile...")
# Init quantile
q = np.zeros(T_max)
for t in range(T_max):
risk[t].sort()
q[t] = risk[t][int(np.ceil(scenario_numbers[t] * quantile)) - 1]
print("\tDone")
return q | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quantileValues(data, device):\n r = pd.DataFrame([])\n if isinstance(data, pd.DataFrame) or isinstance(data, pd.Series):\n minValue = data.min()\n maxValue = data.max()\n q1 = data.quantile(0.25)\n # q2 = tmp['deltaSeconds'].quantile(0.5)\n q3 = data.quantile(0.75)\n ... | [
"0.70179975",
"0.6637474",
"0.6607721",
"0.65887874",
"0.65606374",
"0.6460167",
"0.6450106",
"0.6416188",
"0.6412151",
"0.63913745",
"0.6365912",
"0.635687",
"0.6346664",
"0.634572",
"0.6327879",
"0.632202",
"0.632202",
"0.632202",
"0.63001335",
"0.6290029",
"0.6271301",
"... | 0.6449152 | 7 |
Any slice along dim that are all paddings get NaN's. This is consistent with the behavior of torch.nn.functional.softmax. | def _entmax_helper(
entmax_fn, vector: torch.Tensor, mask: torch.Tensor = None, dim: int = -1
):
masked_vector = (
vector.masked_fill(~(mask.to(dtype=torch.bool)), -1e32)
if mask is not None
else vector
)
values = entmax_fn(masked_vector, dim=dim)
if mask is not None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def padding(a, dim):\n\n return np.pad(a, (0, dim-len(a)), 'constant', constant_values=(0))",
"def padding_mask(lens):\n bs, max_len = len(lens), max(lens)\n mask = torch.zeros(bs, 1, max_len)\n for i, l in enumerate(lens):\n mask[i, :, :l] = 1\n mask = mask > 0\n return mask",
"def ze... | [
"0.6107781",
"0.59069073",
"0.5836757",
"0.5821989",
"0.5801986",
"0.57980037",
"0.5790158",
"0.5785852",
"0.5747389",
"0.5689081",
"0.56709427",
"0.5653924",
"0.56453276",
"0.5637119",
"0.5615174",
"0.5608277",
"0.5575804",
"0.55475116",
"0.5547329",
"0.55186284",
"0.5495482... | 0.0 | -1 |
Load data into dimension tables on Redshift | def insert_tables(cur, conn):
for query in insert_table_queries:
try:
cur.execute(query)
conn.commit()
except Exception as e:
print(e) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_dim_table_dag(\n parent_dag,\n task_id,\n redshift_conn_id,\n aws_credentials_id,\n table,\n sql_create=\"\",\n drop_first=False,\n sql_insert=\"\",\n truncate=True,\n *args, **kwargs):\n \n dag = DAG(f\"{parent_dag}.{task_id}\", **kwargs) \n \n load_dim_table = Lo... | [
"0.6840421",
"0.6615215",
"0.61756873",
"0.6146566",
"0.59563226",
"0.58539027",
"0.5831086",
"0.5789012",
"0.5746865",
"0.56846136",
"0.5658749",
"0.5623414",
"0.56126744",
"0.5603778",
"0.55968577",
"0.5589508",
"0.5563197",
"0.55597264",
"0.55570364",
"0.5553531",
"0.55248... | 0.0 | -1 |
Load weights and masks. | def load_model(self, model_path: str, with_mask=True) -> None:
checkpt = torch.load(model_path, map_location=self.device)
model_utils.initialize_params(
self.model, checkpt["state_dict"], with_mask=with_mask
)
logger.info(f"Loaded the model from {model_path}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_weights(self):\n self.npz_weights = np.load(self._weight_file)\n self._load_byte_embedding()\n self._load_cnn_weights()\n self._load_highway()\n self._load_projection()",
"def load_networks(self, dir_weights, idx_load):\n\n path_p = dir_weights + 'p_{}.ckpt'\n ... | [
"0.7961758",
"0.7166298",
"0.70300215",
"0.70300215",
"0.69845223",
"0.69528276",
"0.69500786",
"0.6939333",
"0.68869025",
"0.68713963",
"0.6855805",
"0.68260014",
"0.6793269",
"0.6779611",
"0.67392933",
"0.6722277",
"0.6705517",
"0.66891134",
"0.66755396",
"0.6670835",
"0.66... | 0.57325125 | 94 |
Load weights and masks. | def load_params(self, model_path: str, with_mask=True) -> None:
checkpt = torch.load(model_path, map_location=self.device)
model_utils.initialize_params(
self.model, checkpt["state_dict"], with_mask=with_mask
)
model_utils.initialize_params(
self.optimizer, checkp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_weights(self):\n self.npz_weights = np.load(self._weight_file)\n self._load_byte_embedding()\n self._load_cnn_weights()\n self._load_highway()\n self._load_projection()",
"def load_networks(self, dir_weights, idx_load):\n\n path_p = dir_weights + 'p_{}.ckpt'\n ... | [
"0.7961758",
"0.7166298",
"0.70300215",
"0.70300215",
"0.69845223",
"0.69528276",
"0.69500786",
"0.6939333",
"0.68869025",
"0.68713963",
"0.6855805",
"0.68260014",
"0.6793269",
"0.6779611",
"0.67392933",
"0.6722277",
"0.6705517",
"0.66891134",
"0.66755396",
"0.6670835",
"0.66... | 0.0 | -1 |
Return list of values for given fields. | def get_fields_list(self, fields):
# choose one value
if isinstance(fields, str):
return self.get_field_or_id(fields)
# choose only values matching given fields
if isinstance(fields, list):
return [self.get_field_or_id(field) for field in fields]
raise T... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_values(self, *fields):\n result = []\n for field in fields:\n if isinstance(field, (str, basestring)):\n result.append(self.get_value(field))\n elif isinstance(field, (tuple, list)):\n result.append(self.get_values(*field))\n else... | [
"0.8723149",
"0.7426816",
"0.7031264",
"0.69835556",
"0.6836851",
"0.67784333",
"0.66391236",
"0.66389525",
"0.6635673",
"0.65960205",
"0.65839875",
"0.6575771",
"0.65732145",
"0.65510637",
"0.6550201",
"0.6492002",
"0.64426064",
"0.64378166",
"0.643667",
"0.6398097",
"0.6303... | 0.74277955 | 1 |
Return copy of dict data. | def to_dict(self):
return dict(self.__data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __copy__(self):\n d = dict()\n d.update(self.items())\n return d",
"def copy(self):\n return pdict(dict.copy(self))",
"def copy(self):\n return self.from_dict(self.to_dict(True))",
"def copy_dictionary(self,dictionary):\r\n return dictionary.copy()",
"def copy(self... | [
"0.79844546",
"0.7816612",
"0.7783952",
"0.75684714",
"0.7526634",
"0.73915166",
"0.7367053",
"0.72636545",
"0.7176331",
"0.7172961",
"0.7127571",
"0.7091412",
"0.7032571",
"0.6966958",
"0.6859877",
"0.68366426",
"0.6811056",
"0.68078583",
"0.678716",
"0.67858106",
"0.6744708... | 0.0 | -1 |
Make an axis as Open3d LineSet. | def make_open3d_axis(axis_vector=None, origin=None, scale=1.0):
if origin is None:
origin = np.zeros(3)
if axis_vector is None:
axis_vector = np.array([0, 0, 1], dtype=np.float)
axis_vector = axis_vector * scale
axis_point = origin + axis_vector
points = np.stack([origin, axis_point]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetLineMode(self, *args):\n return _ShapeUpgrade.ShapeUpgrade_ConvertCurve3dToBezier_SetLineMode(self, *args)",
"def Set3dLineConversion(self, *args):\n return _ShapeUpgrade.ShapeUpgrade_ShapeConvertToBezier_Set3dLineConversion(self, *args)",
"def create_line(uniform = True, *args):\n axis... | [
"0.6121122",
"0.5922313",
"0.5715896",
"0.5589312",
"0.55739",
"0.5564336",
"0.5550376",
"0.55465806",
"0.5542209",
"0.5491709",
"0.54822916",
"0.5352685",
"0.535085",
"0.53244257",
"0.53082526",
"0.52949154",
"0.5284981",
"0.5282798",
"0.52684623",
"0.52638584",
"0.5261142",... | 0.62776756 | 0 |
Sets current environment (and initializes episode) | def set_env(self, env):
self.env = env
self.sim_env = copy.deepcopy(self.env)
self.sim_env.reset_at_episode_end = False # Avoids expensive re-sampling of jets every time we parse a path
self.init_episode() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_episode(self):\n self.last_sensation = self.env()\n self.next_action = self.agent(self.last_sensation)",
"def InitEnvironment(self):\r\n\t\t\r\n\t\t# Turn antialiasing on\r\n\t\trender.setAntialias(AntialiasAttrib.MMultisample,1)\r\n\t\t\r\n\t\t# load the falcon model\r\n\t\tfalcon = load... | [
"0.6493258",
"0.6491669",
"0.64316636",
"0.64199936",
"0.64152956",
"0.64152956",
"0.6382024",
"0.6382024",
"0.6382024",
"0.6240911",
"0.6228559",
"0.6207403",
"0.6182203",
"0.61762697",
"0.61270976",
"0.6124821",
"0.60715103",
"0.60715103",
"0.6064561",
"0.6035142",
"0.60247... | 0.7375576 | 0 |
Creates an instance of this model from a dictionary | def from_dictionary(cls,
dictionary):
if dictionary is None:
return None
# Extract variables from the dictionary
hosts = None
if dictionary.get('hosts') != None:
hosts = list()
for structure in dictionary.get('hosts'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction... | [
"0.83190626",
"0.81680465",
"0.81680465",
"0.81198996",
"0.80894077",
"0.7979489",
"0.79510856",
"0.7923969",
"0.78998214",
"0.7894075",
"0.788929",
"0.7883757",
"0.7883385",
"0.7877541",
"0.78598565",
"0.78387827",
"0.7804587",
"0.7804587",
"0.7804587",
"0.7804587",
"0.78045... | 0.0 | -1 |
Check that a future recurring ride is built from the RecurringRideFactory. | def test_build__params__future_recurring_ride(self) -> None:
future_ride: dict = RecurringRideFactory.build(future_recurring_ride=True)
expected_pickup: str = future_ride['ride']['pickup']['timestamp']
assert date.isoformat(date.today() + timedelta(days=1)) in expected_pickup | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_build__params__same_day_future_ride(self) -> None:\n same_day_future_ride: dict = RecurringRideFactory.build(same_day_future_recurring_ride=True)\n\n assert (\n date.isoformat(date.today() + timedelta(hours=3))\n in same_day_future_ride['ride']['pickup']['timestamp']\n ... | [
"0.7456613",
"0.73427016",
"0.7275607",
"0.6940479",
"0.6881276",
"0.66944987",
"0.6414177",
"0.6359864",
"0.62482643",
"0.5836848",
"0.57694674",
"0.57608503",
"0.57221305",
"0.56549877",
"0.56404084",
"0.55933625",
"0.55550027",
"0.55436283",
"0.5365987",
"0.535568",
"0.529... | 0.7680453 | 0 |
Check that a ride with note is built from the RecurringRideFactory. | def test_build__params__ride_with_note(self) -> None:
ride_with_note: dict = RecurringRideFactory.build(ride_with_note=True)
assert ride_with_note['ride']['note'] is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_build__generate_ride_object(self) -> None:\n ride: dict = RecurringRideFactory.build()\n\n assert ride['ride'] is not None",
"def test_build__subsequent_calls_return_new_recurring_ride(self) -> None:\n ride_one: dict = RecurringRideFactory.build()\n ride_two: dict = Recurring... | [
"0.72921115",
"0.70708066",
"0.7069345",
"0.6884601",
"0.68277663",
"0.6664638",
"0.6464132",
"0.63748646",
"0.62851715",
"0.6284203",
"0.59420234",
"0.55068743",
"0.5476783",
"0.54169554",
"0.5285549",
"0.5192731",
"0.51549476",
"0.51543796",
"0.5150797",
"0.51382023",
"0.51... | 0.7517945 | 0 |
Check that a new RecurringRide is returned from the RideFactory build method. | def test_build__subsequent_calls_return_new_recurring_ride(self) -> None:
ride_one: dict = RecurringRideFactory.build()
ride_two: dict = RecurringRideFactory.build()
assert ride_one != ride_two | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_build__generate_ride_object(self) -> None:\n ride: dict = RecurringRideFactory.build()\n\n assert ride['ride'] is not None",
"def test_build__subsequent_calls_return_new_ride_object(self) -> None:\n ride_one: dict = RecurringRideFactory.build()\n ride_two: dict = RecurringRid... | [
"0.76770884",
"0.750304",
"0.6990865",
"0.69740254",
"0.692608",
"0.67045677",
"0.63399756",
"0.6338585",
"0.59933513",
"0.57535136",
"0.567084",
"0.5505825",
"0.550326",
"0.54477274",
"0.53295237",
"0.5258997",
"0.523484",
"0.5193835",
"0.51036257",
"0.5063497",
"0.5025257",... | 0.7743962 | 0 |
Check that a new ride object is returned from the RideFactory build method. | def test_build__subsequent_calls_return_new_ride_object(self) -> None:
ride_one: dict = RecurringRideFactory.build()
ride_two: dict = RecurringRideFactory.build()
assert ride_one['ride'] != ride_two['ride'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_build__generate_ride_object(self) -> None:\n ride: dict = RecurringRideFactory.build()\n\n assert ride['ride'] is not None",
"def test_build__subsequent_calls_return_new_recurring_ride(self) -> None:\n ride_one: dict = RecurringRideFactory.build()\n ride_two: dict = Recurring... | [
"0.77962303",
"0.7479432",
"0.6826083",
"0.6815011",
"0.6433893",
"0.6046089",
"0.60266894",
"0.5990073",
"0.58527935",
"0.5688818",
"0.55321676",
"0.5413793",
"0.53909314",
"0.53860873",
"0.5330898",
"0.5317841",
"0.5294483",
"0.5282539",
"0.5264896",
"0.5264896",
"0.5263967... | 0.77697796 | 1 |
Check that a future recurring ride is created from the RecurringRideFactory. | def test_create__params__future_recurring_ride(self, service: fixture) -> None:
ride = RecurringRideFactory.create(service=service, future_recurring_ride=True)
expected_pickup: str = ride['ride']['pickup']['timestamp']
assert date.isoformat(date.today() + timedelta(days=1)) in expected_pickup | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_build__params__future_recurring_ride(self) -> None:\n future_ride: dict = RecurringRideFactory.build(future_recurring_ride=True)\n expected_pickup: str = future_ride['ride']['pickup']['timestamp']\n\n assert date.isoformat(date.today() + timedelta(days=1)) in expected_pickup",
"def ... | [
"0.7426905",
"0.733312",
"0.7245862",
"0.6984218",
"0.64994544",
"0.6389633",
"0.5931136",
"0.59171605",
"0.5901186",
"0.5856912",
"0.5809988",
"0.57689464",
"0.57332313",
"0.57285935",
"0.5694355",
"0.5642183",
"0.56345916",
"0.5617561",
"0.55897343",
"0.557134",
"0.5540266"... | 0.7556249 | 0 |
Check that a ride with note is created from the RecurringRideFactory. | def test_create__params__ride_with_note(self, service: fixture) -> None:
ride: dict = RecurringRideFactory.create(service=service, ride_with_note=True)
assert ride['ride']['note'] is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_build__params__ride_with_note(self) -> None:\n ride_with_note: dict = RecurringRideFactory.build(ride_with_note=True)\n\n assert ride_with_note['ride']['note'] is not None",
"def test_build__generate_ride_object(self) -> None:\n ride: dict = RecurringRideFactory.build()\n\n a... | [
"0.7108772",
"0.68941957",
"0.68113863",
"0.6592972",
"0.6592731",
"0.6445494",
"0.6359918",
"0.62323457",
"0.61794555",
"0.607684",
"0.5889995",
"0.5687784",
"0.5497407",
"0.5468263",
"0.54404134",
"0.5431983",
"0.5396597",
"0.5373425",
"0.53728896",
"0.53616935",
"0.5357806... | 0.7213159 | 0 |
Check that a same day future recurring ride is created from the RecurringRideFactory. | def test_create__params__same_day_future_ride(self, service: fixture) -> None:
ride: dict = RecurringRideFactory.create(
service=service, same_day_future_recurring_ride=True,
)
expected_pickup: str = ride['ride']['pickup']['timestamp']
assert date.isoformat(date.today() + ti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_build__params__same_day_future_ride(self) -> None:\n same_day_future_ride: dict = RecurringRideFactory.build(same_day_future_recurring_ride=True)\n\n assert (\n date.isoformat(date.today() + timedelta(hours=3))\n in same_day_future_ride['ride']['pickup']['timestamp']\n ... | [
"0.8056913",
"0.77959085",
"0.7594824",
"0.6843804",
"0.6228385",
"0.617112",
"0.6157976",
"0.60910773",
"0.60662645",
"0.60192704",
"0.601434",
"0.5998579",
"0.598041",
"0.59690124",
"0.59445214",
"0.5927137",
"0.59185636",
"0.59126633",
"0.5909948",
"0.5836224",
"0.5821111"... | 0.8012396 | 1 |
returns True, if type represents C++ integral or floating point type, False otherwise | def is_arithmetic(type):
return is_integral(type) or is_floating_point(type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_integral(type):\n integral_def = (\n create_cv_types(cpptypes.char_t()) +\n create_cv_types(cpptypes.unsigned_char_t()) +\n create_cv_types(cpptypes.signed_char_t()) +\n create_cv_types(cpptypes.wchar_t()) +\n create_cv_types(cpptypes.short_int_t()) +\n create_cv... | [
"0.6631692",
"0.6588647",
"0.6586306",
"0.64957446",
"0.6374232",
"0.63691604",
"0.6334088",
"0.63270116",
"0.6276062",
"0.62758094",
"0.62695205",
"0.6262216",
"0.61434585",
"0.6131299",
"0.6084664",
"0.60317874",
"0.6029375",
"0.6017151",
"0.6004724",
"0.59942067",
"0.59933... | 0.6380168 | 4 |
returns True, if type represents C++ reference type, False otherwise | def is_reference(type):
nake_type = remove_alias(type)
return isinstance(nake_type, cpptypes.reference_t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_const_ref(type):\n is_const = tt.is_const(type) or (hasattr(type,'base') and tt.is_const(type.base))\n is_ref = tt.is_reference(type) or (hasattr(type,'base') and tt.is_reference(type.base))\n return (is_ref and is_const)\n #[Roman]If you create unit tests for this code, I will add it to type traits... | [
"0.72547483",
"0.6942767",
"0.6629437",
"0.6546131",
"0.64801556",
"0.64221776",
"0.62602913",
"0.6254145",
"0.6230019",
"0.61748505",
"0.6156219",
"0.6098374",
"0.6092407",
"0.60902387",
"0.60100204",
"0.6001219",
"0.59770197",
"0.596749",
"0.59079665",
"0.58903676",
"0.5883... | 0.8142678 | 0 |
returns True, if type represents C++ const type, False otherwise | def is_const(type):
nake_type = remove_alias(type)
return isinstance(nake_type, cpptypes.const_t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_const_ref(type):\n is_const = tt.is_const(type) or (hasattr(type,'base') and tt.is_const(type.base))\n is_ref = tt.is_reference(type) or (hasattr(type,'base') and tt.is_reference(type.base))\n return (is_ref and is_const)\n #[Roman]If you create unit tests for this code, I will add it to type traits... | [
"0.6958227",
"0.6910033",
"0.65865797",
"0.6290368",
"0.6227741",
"0.60773766",
"0.60537726",
"0.6050793",
"0.6018981",
"0.60043234",
"0.59523064",
"0.588276",
"0.5840154",
"0.5823267",
"0.5811727",
"0.5699804",
"0.5659577",
"0.56406635",
"0.56158596",
"0.5543699",
"0.5525821... | 0.80221224 | 0 |
returns True, if type1 and type2 are same types | def is_same(type1, type2):
nake_type1 = remove_declarated(type1)
nake_type2 = remove_declarated(type2)
return nake_type1 == nake_type2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def same_type(one, two):\n\n return isinstance(one, type(two))",
"def _is_equal_same_type(self, other):\n return True",
"def _values_of_same_type(self, val1, val2):\n if self.f_supports(val1) != self.f_supports(val2):\n return False\n\n if not self.f_supports(val1) and not se... | [
"0.8232314",
"0.7990644",
"0.77117264",
"0.7667614",
"0.75037205",
"0.74987614",
"0.74972105",
"0.73906344",
"0.7282398",
"0.7219325",
"0.6998093",
"0.6970877",
"0.6940486",
"0.69266087",
"0.68406993",
"0.6822092",
"0.6814113",
"0.6782477",
"0.6775843",
"0.6721488",
"0.669458... | 0.83862215 | 0 |
returns True, if type represents C++ fundamental type | def is_fundamental(type):
return does_match_definition(
type,
cpptypes.fundamental_t,
(cpptypes.const_t, cpptypes.volatile_t)) \
or does_match_definition(
type,
cpptypes.fundamental_t,
(cpptypes.volatile_t, cpptypes.const_t)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_basic_ctype(self, objtype):\n if objtype in [self.c_char_p, self.c_void_p, self.CString]:\n return False\n # DOC: if <ctypes.c_uint> is not in self.__basic_types, its probably\n # because you are using the wrong ctypes Proxy instance\n return objtype in self.__basic_ty... | [
"0.7030364",
"0.66599476",
"0.6046835",
"0.5938325",
"0.5906367",
"0.5809609",
"0.5791076",
"0.57610685",
"0.5754151",
"0.5729177",
"0.5705968",
"0.5655816",
"0.56143767",
"0.5609009",
"0.5598526",
"0.5592075",
"0.5587478",
"0.5582749",
"0.5565113",
"0.55348295",
"0.5534587",... | 0.76821107 | 0 |
returns True if type represents a C++ union | def is_union(type_):
if not is_class(type_):
return False
decl = class_traits.get_declaration(type_)
return decl.class_type == class_declaration.CLASS_TYPES.UNION | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_union(typeval: Type) -> bool:\n return get_origin(typeval) is Union",
"def is_union_type(self, objtype):\n # force ignore the longdouble construct\n if objtype == self.c_longdouble:\n return False\n # force ignore the CString construct\n #if objtype == self.CStri... | [
"0.80529803",
"0.79514694",
"0.76344645",
"0.75142926",
"0.74388856",
"0.7316637",
"0.7015306",
"0.6959607",
"0.695248",
"0.69521606",
"0.67257667",
"0.5995503",
"0.59941846",
"0.58286303",
"0.57918674",
"0.57349396",
"0.5732569",
"0.571059",
"0.57092524",
"0.57077",
"0.57077... | 0.8039434 | 1 |
returns True, if class has public assign operator, False otherwise | def has_public_assign(class_):
class_ = class_traits.get_declaration(class_)
decls = class_.mem_opers(
lambda o: o.symbol == '=' and o.access_type == 'public',
recursive=False,
allow_empty=True)
return bool(decls) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_assignable_from(self, typ: Type) -> bool:\n raise NotImplementedError()",
"def has_public_equal(type):\n return has_public_binary_operator(type, '==')",
"def is_assign(self):\n return self.var.initializer is not None",
"def has_public_binary_operator(type_, operator_symbol):\n type... | [
"0.6159163",
"0.61377376",
"0.6065221",
"0.5974117",
"0.5791719",
"0.57146794",
"0.567876",
"0.56639594",
"0.5640697",
"0.5609316",
"0.5609316",
"0.55776316",
"0.5557651",
"0.5530487",
"0.54604375",
"0.54604375",
"0.53952974",
"0.5370379",
"0.5364252",
"0.5336572",
"0.5336572... | 0.71238023 | 0 |
returns True, if class has public operator==, otherwise False | def has_public_equal(type):
return has_public_binary_operator(type, '==') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def... | [
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476",
"0.72278476"... | 0.77270144 | 0 |
returns True, if class has public operator<, otherwise False | def has_public_less(type):
return has_public_binary_operator(type, '<') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __lt__(self, other: t.Any) -> bool:\n return self._op_bool('__lt__', other)",
"def __lt__(self, other):\n return True",
"def __lt__(self, other):\n return True",
"def __lt__(self, other):\n return self._obj_func() < other._obj_func()",
"def __lt__(self, other):\n retu... | [
"0.75423485",
"0.7450696",
"0.7450696",
"0.7238786",
"0.70503134",
"0.6956891",
"0.6956891",
"0.6936417",
"0.69186276",
"0.690914",
"0.68925947",
"0.6876835",
"0.68632543",
"0.68559986",
"0.6852951",
"0.67471904",
"0.67216414",
"0.67096484",
"0.6693922",
"0.6681374",
"0.66667... | 0.7840395 | 0 |
Sets the learning rate to the initial LR decayed by 10 every 30 epochs | def adjust_learning_rate(optimizer, epoch, args):
lr = args.lr * (0.1 ** (epoch // 30))
for param_group in optimizer.param_groups:
param_group['lr'] = lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr",
"def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l... | [
"0.79135466",
"0.7906959",
"0.78501177",
"0.77753556",
"0.7734022",
"0.77317274",
"0.7722737",
"0.7719314",
"0.7709071",
"0.7693548",
"0.76741743",
"0.766576",
"0.766576",
"0.766576",
"0.7655009",
"0.76420027",
"0.7639289",
"0.76378644",
"0.7626088",
"0.7624756",
"0.76212347"... | 0.77221584 | 7 |
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 = []... | {
"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.8331214",
"0.8284662",
"0.82381004",
"0.8229767",
"0.82202226",
"0.81864446",
"0.81847763",
"0.8175173",
"0.8171541",
"0.81699467",
"0.81664646",
"0.81645083",
"0.81637454",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"0.81622064",
"... | 0.78591996 | 77 |
Wrapper for ray casting that moves the ray into object space | def obj_ray_cast(obj, matrix):
# get the ray relative to the object
matrix_inv = matrix.inverted()
ray_origin_obj = matrix_inv * ray_origin
ray_target_obj = matrix_inv * ray_target
ray_direction_obj = ray_target_obj - ray_origin_obj
# cast the ray
success, locat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obj_ray_cast(obj, matrix):\r\n \r\n # get the ray relative to the object\r\n matrix_inv = matrix.inverted()\r\n ray_origin_obj = matrix_inv * ray_origin\r\n ray_target_obj = matrix_inv * ray_target\r\n ray_direction_obj = ray_target_obj - ray_origin_ob... | [
"0.71598464",
"0.7108806",
"0.7093949",
"0.6975007",
"0.62521666",
"0.61117506",
"0.60194856",
"0.59293383",
"0.5882952",
"0.5871332",
"0.5810898",
"0.58108354",
"0.576089",
"0.5749889",
"0.5703415",
"0.56720555",
"0.560589",
"0.5594175",
"0.5577506",
"0.55460733",
"0.5533887... | 0.700609 | 3 |
Wrapper for ray casting that moves the ray into object space | def obj_ray_cast(obj, matrix):
# get the ray relative to the object
matrix_inv = matrix.inverted()
ray_origin_obj = matrix_inv * ray_origin
ray_target_obj = matrix_inv * ray_target
ray_direction_obj = ray_target_obj - ray_origin_obj
# cast the ray
succes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obj_ray_cast(obj, matrix):\r\n \r\n # get the ray relative to the object\r\n matrix_inv = matrix.inverted()\r\n ray_origin_obj = matrix_inv * ray_origin\r\n ray_target_obj = matrix_inv * ray_target\r\n ray_direction_obj = ray_target_obj - ray_origin_ob... | [
"0.7159447",
"0.7108588",
"0.70054984",
"0.69744205",
"0.6251917",
"0.6112991",
"0.6019621",
"0.5928927",
"0.5882911",
"0.58706033",
"0.58095115",
"0.5809462",
"0.5759563",
"0.5748744",
"0.5703533",
"0.56732535",
"0.56046677",
"0.5592776",
"0.55776376",
"0.55461746",
"0.55331... | 0.7093163 | 2 |
Gets the id of this DownloadableDataSampleInterface. Sample(or link) id | def id(self) -> int:
return self._id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSampleId(self):\n return self.getDbRecord().getColumnValue(SAMPLE_ID_COLUMN)",
"def id(self):\n return self.get_data(\"id\")",
"def id(self):\n return self.data.id",
"def sample_id(self) -> pd.Series:\n return self.meta.get(\"sample_id\")",
"def id(self):\n return ... | [
"0.7211298",
"0.70066905",
"0.69921154",
"0.69172263",
"0.68228966",
"0.67824453",
"0.6753421",
"0.66502434",
"0.6642416",
"0.6635184",
"0.6635184",
"0.6635184",
"0.6635184",
"0.6630262",
"0.662553",
"0.66248924",
"0.6591769",
"0.6585858",
"0.6585858",
"0.6585858",
"0.6572214... | 0.6558124 | 34 |
Sets the id of this DownloadableDataSampleInterface. Sample(or link) id | def id(self, id: int):
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_id(self, id):\n self.data['id'] = id",
"def set_id(self, id):\n self.__id = id",
"def setID(self, id):\r\n raise NotImplementedError(\"must be implemented in subclass\")",
"def SetId(self, id):\n self.id = int(id)",
"def id(self, _id):\n self.metadata[\"id\"] = _i... | [
"0.74035764",
"0.7258344",
"0.7247008",
"0.7173011",
"0.71543205",
"0.714274",
"0.714274",
"0.714274",
"0.714274",
"0.714274",
"0.71323144",
"0.7128423",
"0.7128423",
"0.7128423",
"0.7128423",
"0.7128423",
"0.7128423",
"0.7128423",
"0.7128423",
"0.7128423",
"0.7128423",
"0.... | 0.7038888 | 33 |
Gets the title of this DownloadableDataSampleInterface. Title | def title(self) -> str:
return self._title | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"title\")",
"def GetTitle(self):\n return self._title",
"def title(self) -> str:\n return pulumi.get(self, \"title\")",
"def title(self) -> str:\n return pulumi.get(self, \"title\")",
"def title(self) -> str:\n ... | [
"0.79032",
"0.7849867",
"0.78181666",
"0.78181666",
"0.78181666",
"0.77949154",
"0.7772092",
"0.7772092",
"0.7772092",
"0.7772092",
"0.7772092",
"0.7772092",
"0.77552855",
"0.7740091",
"0.7740091",
"0.7740091",
"0.77367586",
"0.77336985",
"0.7720172",
"0.76942873",
"0.7678182... | 0.76773095 | 25 |
Sets the title of this DownloadableDataSampleInterface. Title | def title(self, title: str):
if title is None:
raise ValueError("Invalid value for `title`, must not be `None`")
self._title = title | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_title (self, title):\n self.title = title",
"def settitle(self, title):\n self.__title = title",
"def settitle(self, title):\n self.__title = title",
"def title(self, title):\n\n self._title = title",
"def title(self, title):\n\n self._title = title",
"def title... | [
"0.80639064",
"0.8056699",
"0.8056699",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8052254",
"0.8038005",
"0.802649",
"0.80196995",
"0.8005869",
... | 0.7591208 | 35 |
Gets the sample_type of this DownloadableDataSampleInterface. | def sample_type(self) -> str:
return self._sample_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type(self) -> DataType:\n return self._type",
"def get_type(self):\n return self._type",
"def get_type(self):\n return self._type",
"def get_type(self):\n return self._TYPE",
"def getType(self):\n return self.type_",
"def get_type (self):\n return self._stype... | [
"0.6375784",
"0.63182354",
"0.63182354",
"0.62555885",
"0.62287116",
"0.62264156",
"0.6217507",
"0.6217507",
"0.62034005",
"0.61728305",
"0.6171515",
"0.6161314",
"0.6122495",
"0.6087958",
"0.60686564",
"0.6066251",
"0.60631776",
"0.6058182",
"0.6058182",
"0.6058182",
"0.6058... | 0.7003912 | 0 |
Sets the sample_type of this DownloadableDataSampleInterface. | def sample_type(self, sample_type: str):
if sample_type is None:
raise ValueError("Invalid value for `sample_type`, must not be `None`")
self._sample_type = sample_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_type(self, sample_type):\n sql = \"\"\"UPDATE barcodes.sample\n SET sample_type = %s\n WHERE sample_id = %s\"\"\"\n with pm.sql.TRN:\n pm.sql.TRN.add(sql, [sample_type, self.id])",
"def setDataSetType(self, type):\n self.__data_set_type__... | [
"0.6727752",
"0.62468135",
"0.6178982",
"0.6153391",
"0.6153391",
"0.5903703",
"0.5824452",
"0.5806498",
"0.5806498",
"0.5806498",
"0.5779497",
"0.5779497",
"0.5779497",
"0.5779497",
"0.5779497",
"0.5779497",
"0.5779497",
"0.5779497",
"0.5779497",
"0.5779497",
"0.5779497",
... | 0.7641073 | 0 |
Gets the sample_file of this DownloadableDataSampleInterface. relative file path | def sample_file(self) -> str:
return self._sample_file | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_path(self):\n return self._file_path",
"def file_path(self):\n return self.lib.file_path",
"def path(self):\n return self._data_file",
"def file_path(self):\n return self._obs_file()",
"def get_file(self):\n return self.dir + self.file_name + self.extension",... | [
"0.7221411",
"0.70626414",
"0.7056722",
"0.68962747",
"0.680585",
"0.6804241",
"0.6771714",
"0.673996",
"0.672983",
"0.66897184",
"0.66225195",
"0.6608245",
"0.65686506",
"0.65686506",
"0.6558293",
"0.65196383",
"0.6476549",
"0.6433655",
"0.6422759",
"0.64183885",
"0.6414791"... | 0.7584514 | 0 |
Gets the sample_file_content of this DownloadableDataSampleInterface. | def sample_file_content(self) -> DownloadableDataFileContentInterface:
return self._sample_file_content | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_content(self):\n s = StringIO.StringIO()\n\n s.write(self.get_header())\n s.write(self.get_content())\n\n return s.getvalue()",
"def read_content(self):\n return self.file.read()",
"def sample_file_content(self, sample_file_content: DownloadableDataFileContentInt... | [
"0.68037874",
"0.66366905",
"0.66286397",
"0.6613036",
"0.64783525",
"0.6361968",
"0.6254303",
"0.6192874",
"0.61926347",
"0.61247975",
"0.6120483",
"0.6088796",
"0.60769576",
"0.6052164",
"0.60362566",
"0.60362566",
"0.60362566",
"0.60178477",
"0.60162324",
"0.59985334",
"0.... | 0.8653033 | 0 |
Gets the sample_url of this DownloadableDataSampleInterface. file URL | def sample_url(self) -> str:
return self._sample_url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_url(self):\n try:\n return self._file.url\n except AttributeError:\n raise NotImplementedError(\"Underlying file does not have a URL.\")",
"def get_url(self):\n return self.get_file(uri_type=URI_URL, no_copy=True)",
"def url(self):\n if not self.fid:\n ... | [
"0.7632803",
"0.7380087",
"0.69870204",
"0.69837725",
"0.69777703",
"0.69118893",
"0.6859784",
"0.68208104",
"0.681425",
"0.681425",
"0.67761064",
"0.6763739",
"0.67304885",
"0.665028",
"0.65707445",
"0.65652823",
"0.65235984",
"0.649572",
"0.6494899",
"0.6490884",
"0.6458094... | 0.7540534 | 1 |
Sets the sample_url of this DownloadableDataSampleInterface. file URL | def sample_url(self, sample_url: str):
self._sample_url = sample_url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_url(self, url):\n self.data['url'] = url",
"def input_file_url(self, input_file_url):\n\n self._input_file_url = input_file_url",
"def set_url(self, url):\n if url is not None:\n self.url = url",
"def set_url(self, url):\n self.url = url",
"def sample_url(self... | [
"0.66698116",
"0.65751445",
"0.65353626",
"0.6518724",
"0.64884794",
"0.6353621",
"0.6298433",
"0.62912536",
"0.6224944",
"0.6224944",
"0.6224944",
"0.6189533",
"0.6189533",
"0.6189533",
"0.6189533",
"0.6189533",
"0.6189533",
"0.6189533",
"0.61572945",
"0.6151396",
"0.6108914... | 0.76989466 | 0 |
Checks if the coin age exceeds the age from the condition | def mempool_assert_relative_block_height_exceeds(
condition: ConditionWithArgs, unspent: CoinRecord, prev_transaction_block_height: uint32
) -> Optional[Err]:
try:
expected_block_age = int_from_bytes(condition.vars[0])
block_index_exceeds_this = expected_block_age + unspent.confirmed_block_index... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_vintage(self):\n return self.get_age()>=AGE",
"async def age_prompt_validator(prompt_context: PromptValidatorContext) -> bool:\n return (\n prompt_context.recognized.succeeded\n and 0 < prompt_context.recognized.value < 150\n )",
"def is_vintage(self):\n ag... | [
"0.71658814",
"0.6958408",
"0.6913825",
"0.6733932",
"0.6672007",
"0.66271484",
"0.6581271",
"0.65602267",
"0.65021706",
"0.64722687",
"0.64722687",
"0.642189",
"0.63391894",
"0.630778",
"0.61229753",
"0.6122615",
"0.6079695",
"0.6036498",
"0.6008758",
"0.6005665",
"0.5960272... | 0.0 | -1 |
Check if the current time in seconds exceeds the time specified by condition | def mempool_assert_absolute_time_exceeds(condition: ConditionWithArgs, timestamp: uint64) -> Optional[Err]:
try:
expected_seconds = int_from_bytes(condition.vars[0])
except ValueError:
return Err.INVALID_CONDITION
if timestamp is None:
timestamp = uint64(int(time.time()))
if tim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_time():\n times = get_times()\n time_difference = abs((times['local'] - times['target']).total_seconds())\n return time_difference < post_time_tol_seconds",
"def check_timer(self, wanted_time):\n if time.time() - self.start_time >= wanted_time:\n return True\n return F... | [
"0.7562202",
"0.71025753",
"0.6916898",
"0.6874118",
"0.6869155",
"0.68624634",
"0.67953074",
"0.6778832",
"0.67521226",
"0.6740149",
"0.67286193",
"0.67286193",
"0.6676113",
"0.6667953",
"0.6666035",
"0.6665621",
"0.6635951",
"0.65261716",
"0.65129775",
"0.64674014",
"0.6449... | 0.647807 | 19 |
Check if the current time in seconds exceeds the time specified by condition | def mempool_assert_relative_time_exceeds(
condition: ConditionWithArgs, unspent: CoinRecord, timestamp: uint64
) -> Optional[Err]:
try:
expected_seconds = int_from_bytes(condition.vars[0])
except ValueError:
return Err.INVALID_CONDITION
if timestamp is None:
timestamp = uint64(i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_time():\n times = get_times()\n time_difference = abs((times['local'] - times['target']).total_seconds())\n return time_difference < post_time_tol_seconds",
"def check_timer(self, wanted_time):\n if time.time() - self.start_time >= wanted_time:\n return True\n return F... | [
"0.7560055",
"0.70983523",
"0.69155896",
"0.68737674",
"0.6867066",
"0.686113",
"0.679441",
"0.67775565",
"0.67518276",
"0.6739354",
"0.67290646",
"0.67290646",
"0.66760504",
"0.66663533",
"0.6665307",
"0.666515",
"0.66334695",
"0.6525863",
"0.6511511",
"0.6478202",
"0.646489... | 0.6199085 | 34 |
Checks if coin's puzzlehash matches the puzzlehash from the condition | def mempool_assert_my_puzzlehash(condition: ConditionWithArgs, unspent: CoinRecord) -> Optional[Err]:
if unspent.coin.puzzle_hash != condition.vars[0]:
return Err.ASSERT_MY_PUZZLEHASH_FAILED
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_transaction(transaction: str, hash: str, psk: str = PSK) -> bool:\n global challenge\n correct_response = hashlib.sha512(str(transaction + get_crypto_challenge() + psk).encode(\"utf-8\")).hexdigest()\n print(correct_response)\n challenge = \"\".join(random.SystemRandom().choice(ascii_letters)... | [
"0.6387728",
"0.63675094",
"0.63513815",
"0.62906873",
"0.6281194",
"0.6229039",
"0.6060662",
"0.6060424",
"0.5956857",
"0.58501714",
"0.5839406",
"0.5818684",
"0.57849085",
"0.57588345",
"0.57562876",
"0.5737729",
"0.5726918",
"0.57232445",
"0.57202446",
"0.56678194",
"0.566... | 0.7178541 | 0 |
return true if the element is tagged with this tag_name. | def is_tagged(self,tag_name,element):
return (tag_name in self.tag2elements.keys()) and (element in self.tag2elements[tag_name]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has(self, tag_name: str) -> bool:\n return hasattr(self, tag_name)",
"def has_tag(self, tag):\n return tag in self.tags",
"def has_tag(self, tag):\n return tag in self.tags",
"def is_tagged(self, instance_id, tag_name):\n tag_value = self.get_tag_for_instance(instance_id, tag_... | [
"0.7885216",
"0.7811932",
"0.7811932",
"0.7800693",
"0.7607107",
"0.7334519",
"0.72071403",
"0.70080936",
"0.6851873",
"0.6838376",
"0.6777755",
"0.6719842",
"0.67196035",
"0.6685162",
"0.6685069",
"0.66277754",
"0.6587601",
"0.6573966",
"0.65495265",
"0.65388155",
"0.651897"... | 0.8433415 | 0 |
Get the user first name and last name from the information we have in the record. | def get_user_firstname_lastname(self, record):
lower_first_name, lower_last_name = self.clean_user_names(record)
#No first name and last name check email
if lower_first_name is None and lower_last_name is None:
lower_first_name, lower_last_name = \
self.extract_na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_user_names(record):\n if 'first_name' in record and 'last_name' in record:\n #Remove all special characters from first_name/last name\n lower_first_name = record['first_name'].replace('-', '')\\\n .replace('_', '').replace('[', '')\\\n .replace('... | [
"0.75281817",
"0.74878085",
"0.7447014",
"0.7406673",
"0.7402745",
"0.7394262",
"0.7337658",
"0.72492516",
"0.72129667",
"0.72013754",
"0.7197006",
"0.71755356",
"0.71623415",
"0.7162276",
"0.7159904",
"0.71576285",
"0.71522796",
"0.7132452",
"0.7116366",
"0.70820224",
"0.705... | 0.83301103 | 0 |
This function presents how to create the json file. This json file should have a specific template in our case. | def to_json(self, python_object):
if isinstance(python_object, tuple):
python_object = {'__class__': 'tuple',
'__value__': list(python_object)}
else:
raise TypeError(repr(python_object) + ' is not JSON serializable')
return python_object | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_file(output_json):\n folder = \"data/\"\n filename = datetime.now().strftime(\"%d-%m-%Y\") + \"-moisture-read.json\"\n filepath = folder+filename\n\n # Create Local folder\n try:\n os.mkdir(folder)\n except OSError:\n pass\n #print(\"Directory already created or a ... | [
"0.71226233",
"0.68502873",
"0.67792517",
"0.6747514",
"0.6703053",
"0.66543293",
"0.6540852",
"0.65318674",
"0.6516783",
"0.64526427",
"0.6401962",
"0.63873285",
"0.6270197",
"0.6264846",
"0.62082565",
"0.6202838",
"0.6202838",
"0.61921763",
"0.61898893",
"0.6178573",
"0.613... | 0.0 | -1 |
Sample an action from the logits generated by the policy network. | def call(self, logits):
return tf.squeeze(tf.random.categorical(logits, 1), axis=-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_action(self, obs, explore_prob):\n raise NotImplementedError",
"def sample_action(self, obs):\n pass",
"def sample_action(self):\n raise NotImplementedError",
"def sample_actions(self, agent_outputs):\n logits, state_values = agent_outputs\n policy = np.exp(logits) /... | [
"0.72112405",
"0.71781105",
"0.697705",
"0.69668126",
"0.6901296",
"0.685864",
"0.6787162",
"0.67868304",
"0.67384255",
"0.66717106",
"0.6663651",
"0.66570956",
"0.6621281",
"0.6614722",
"0.6603717",
"0.65745276",
"0.64987457",
"0.6456226",
"0.64557815",
"0.64438295",
"0.6434... | 0.0 | -1 |
The starting X coordinates at a particular level | def x0(self, level):
resolution = self.resolution(level)
return np.arange(0, (self.x_extent + resolution - 1) // resolution, 64) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_x(self):\n return self.position.x",
"def get_x(self):\n return self.posX",
"def x1(self, level):\n resolution = self.resolution(level)\n x1 = self.x0(level) + 64\n x1[-1] = (self.x_extent + resolution - 1) // resolution\n return x1",
"def n_x(self, level):\n... | [
"0.6999703",
"0.6996245",
"0.6980217",
"0.69114256",
"0.68604106",
"0.6843933",
"0.6824889",
"0.6809815",
"0.675921",
"0.67421",
"0.67335",
"0.6709175",
"0.6688985",
"0.66655886",
"0.6661438",
"0.6661438",
"0.6646134",
"0.6631138",
"0.6502996",
"0.6501843",
"0.64950234",
"0... | 0.7193848 | 0 |
The starting Y coordinates at a particular level | def y0(self, level):
resolution = self.resolution(level)
return np.arange(0, (self.y_extent + resolution - 1) // resolution, 64) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def y1(self, level):\n resolution = self.resolution(level)\n y1 = self.y0(level) + 64\n y1[-1] = (self.y_extent + resolution - 1) // resolution\n return y1",
"def getY(self):\n return self.position[1]",
"def get_ly(self):\r\n return self.dy * self.ny - self.oy",
"def... | [
"0.7052544",
"0.6906553",
"0.6877149",
"0.67688185",
"0.67623544",
"0.6604809",
"0.65925467",
"0.6569983",
"0.65501165",
"0.6543653",
"0.64941573",
"0.64924115",
"0.6491091",
"0.64834034",
"0.6463733",
"0.64487743",
"0.639934",
"0.63954216",
"0.6389561",
"0.6378861",
"0.63788... | 0.71204114 | 0 |
The ending Y coordinates at a particular level | def y1(self, level):
resolution = self.resolution(level)
y1 = self.y0(level) + 64
y1[-1] = (self.y_extent + resolution - 1) // resolution
return y1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def n_y(self, level):\n resolution = self.resolution(level)\n return (self.y_extent // resolution + 63) // 64",
"def y0(self, level):\n resolution = self.resolution(level)\n return np.arange(0, (self.y_extent + resolution - 1) // resolution, 64)",
"def get_y(self):\n return s... | [
"0.7667739",
"0.7018228",
"0.6923539",
"0.6920812",
"0.69157594",
"0.6860041",
"0.6811079",
"0.6717444",
"0.6709046",
"0.6703756",
"0.6678104",
"0.6665206",
"0.66042924",
"0.6573715",
"0.6571491",
"0.6524065",
"0.65123487",
"0.64857894",
"0.64807516",
"0.6474685",
"0.6460209"... | 0.6812981 | 6 |
Return a dict with current stroke, fill and font state. | def get_state(canvas):
return {
'stroke.color': canvas.stroke.color,
'stroke.alpha': canvas.stroke.alpha,
'stroke.line_width': canvas.stroke.line_width,
'stroke.line_cap': canvas.stroke.line_cap,
'stroke.line_join': canvas.stroke.line_join,
'stroke.miter_limit': canva... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_style_dict(self, gc, rgbFace):\n attrib = {}\n\n forced_alpha = gc.get_forced_alpha()\n\n if gc.get_hatch() is not None:\n attrib['fill'] = \"url(#%s)\" % self._get_hatch(gc, rgbFace)\n if rgbFace is not None and len(rgbFace) == 4 and rgbFace[3] != 1.0 and not fo... | [
"0.6404495",
"0.58136624",
"0.56519884",
"0.55915356",
"0.5516411",
"0.5510207",
"0.546083",
"0.54357326",
"0.542887",
"0.54155576",
"0.54126924",
"0.5401923",
"0.5394472",
"0.5393469",
"0.5369328",
"0.53623194",
"0.53563344",
"0.5321655",
"0.5306464",
"0.52977645",
"0.529123... | 0.7944336 | 0 |
This is the only place where to_numpy() relies on to_pandas(). It does so because pandas is good with the parquet and dtypes. | def to_numpy(
id:int
, columns:list = None
, samples:list = None
):
columns = listify(columns)
samples = listify(samples)
df = File.Tabular.to_pandas(id=id, columns=columns, samples=samples)
arr = df.to_numpy()
return arr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_numpy(self, **kwargs): # noqa: PR02\n return DataFrameDefault.register(pandas.DataFrame.to_numpy)(self, **kwargs)",
"def to_numpy(self) -> np.ndarray:\n log_advice(\n \"`to_numpy` loads all data into the driver's memory. \"\n \"It should only be used if the resulting N... | [
"0.7519041",
"0.6828039",
"0.6787758",
"0.66769284",
"0.66769284",
"0.631002",
"0.629958",
"0.6248261",
"0.6206761",
"0.6143321",
"0.6133862",
"0.608684",
"0.60692483",
"0.6056966",
"0.60505116",
"0.60505116",
"0.60505116",
"0.6030656",
"0.60119265",
"0.5998219",
"0.596397",
... | 0.5764011 | 36 |
Parquet naturally preserves pandas/numpy dtypes. fastparquet engine preserves timedelta dtype, alas it does not work with bytes! | def df_to_compressed_parquet_bytes(dataframe:object):
blob = io.BytesIO()
dataframe.to_parquet(
blob
, engine = 'pyarrow'
, compression = 'gzip'
, index = False
)
blob = blob.getvalue()
return blob | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_infer_parquet_types(tmpdir):\n # Create a temporary directory to store the parquet file\n tmpdir = str(tmpdir)\n\n # Create a dataframe with all the types\n df = pd.DataFrame(\n {\n \"int\": [1, 2, 3],\n \"float\": [1.1, 2.2, 3.3],\n \"string\": [\"a\", ... | [
"0.6559313",
"0.62552786",
"0.5994356",
"0.5918388",
"0.5896982",
"0.58349276",
"0.58282673",
"0.5764214",
"0.5762636",
"0.5751022",
"0.57334983",
"0.57322365",
"0.57030886",
"0.56707656",
"0.56155217",
"0.56097865",
"0.5606253",
"0.55490816",
"0.5547418",
"0.5480142",
"0.547... | 0.53675026 | 26 |
Create the dataset from either df or file. | def parse_tabular_input(dataFrame_or_filePath:object, dtype:dict=None):
d = dataFrame_or_filePath
data_type = str(type(d))
if (data_type == "<class 'pandas.core.frame.DataFrame'>"):
dataset = Dataset.Tabular.from_pandas(dataframe=d, dtype=dtype)
elif (data_type == "<class 'str'>"):
if '.csv' in d:
sou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_dataset(self, df, **kwargs):\n\t\treturn df",
"def prepare_dataset(fpath):\n raise NotImplementedError",
"def create_dataset(opt):\n\tdata_loader = CustomDatasetDataLoader(opt)\n\tdataset = data_loader.load_data()\n\treturn dataset",
"def create_dataset(opt):\n data_loader = CustomDatasetDataL... | [
"0.7607132",
"0.71523976",
"0.67038745",
"0.66413754",
"0.6638536",
"0.6634561",
"0.6525281",
"0.6491794",
"0.6447092",
"0.64079976",
"0.6397729",
"0.6388853",
"0.63811934",
"0.638089",
"0.6367692",
"0.6314475",
"0.6291905",
"0.62874436",
"0.6283287",
"0.62817943",
"0.6276859... | 0.64169204 | 9 |
Function to check if the chain is a protein or a nucleic acid. | def check_type(chain):
atoms = chain.get_atoms()
type_chain = ""
list_c = []
for element in atoms:
list_c.append(element.get_name())
if "CA" in list_c:
type_chain = "protein"
else:
type_chain = "nucleic_acid"
return type_chain | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_nucleic_acid(self):\n return True",
"def is_nucleic_acid(self):\n return False",
"def is_dna(sequentie):\r\n for nucleotide in sequentie:\r\n if nucleotide not in \"ACGTN\":\r\n return False\r\n return True",
"def is_amino_acid(self):\n return True",
"def... | [
"0.70060664",
"0.6924548",
"0.67444307",
"0.6445812",
"0.6374522",
"0.6287852",
"0.60768706",
"0.5966777",
"0.596334",
"0.5868802",
"0.58141494",
"0.5791949",
"0.5751857",
"0.5735891",
"0.56966263",
"0.5599283",
"0.5598436",
"0.55966276",
"0.55887216",
"0.55754817",
"0.555542... | 0.6957291 | 1 |
Create a new instance of Payment. | def post(self, args):
with api.commit_or_abort(
db.session,
default_error_message="Failed to create a new Payment"
):
payment = Payment(**args)
db.session.add(payment)
return payment | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(**data):\n http_client = HttpClient()\n response, _ = http_client.post(routes.url(routes.PAYMENT_RESOURCE), data)\n return resources.Payment(**response)",
"def __create_payment_object(self, data, direction):\n\n from_account = self.__fetch_user_account(guid=data.get(\"from_... | [
"0.758857",
"0.7019123",
"0.67243093",
"0.66414416",
"0.663829",
"0.6602848",
"0.6519209",
"0.6460364",
"0.63391745",
"0.6311164",
"0.6290242",
"0.6228037",
"0.6169697",
"0.6073626",
"0.59844005",
"0.59595215",
"0.59171563",
"0.5912023",
"0.59038657",
"0.58912116",
"0.5867552... | 0.7088595 | 1 |
Patch Payment details by ID. | def patch(self, args, payment):
with api.commit_or_abort(
db.session,
default_error_message="Failed to update Payment details."
):
parameters.PatchPaymentDetailsParameters.perform_patch(args, obj=payment)
db.session.merge(payment)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_payment_gateway(cls, api, id, **data):\n return api.update_payment_gateway(id, **data)",
"def update_payment(self,\n payment_id,\n body):\n\n return super().new_api_call_builder.request(\n RequestBuilder().server('default')\n ... | [
"0.6707248",
"0.66860867",
"0.6220003",
"0.62071866",
"0.61642337",
"0.61028665",
"0.61028665",
"0.61028665",
"0.60585904",
"0.6038431",
"0.60195494",
"0.6015923",
"0.59859246",
"0.5957179",
"0.59421325",
"0.59367704",
"0.593086",
"0.59210515",
"0.5880024",
"0.5863566",
"0.57... | 0.71683985 | 0 |
Check whether the pixel coordinate of marker is in a valid range. | def in_pixel_range(self, pixmin: int, pixmax: int) -> bool:
if any(i < pixmin or i > pixmax or np.isnan(i) for i in self.datapos):
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_coord_in_range(self, x, y):\n return 0 <= x < self.cols and 0 <= y < self.lines",
"def _in_bounds(self, x, y):\r\n return 0 <= x < 8 and 0 <= y < 8",
"def in_bounds(self, x, y):\n return x >= 0 and x < 8 and y >= 0 and y < 8",
"def isRangeValid(self) -> bool:\n ...",
"... | [
"0.7689891",
"0.7528888",
"0.7285114",
"0.7263985",
"0.7215859",
"0.72029746",
"0.7099152",
"0.6864531",
"0.6820962",
"0.67709464",
"0.6679181",
"0.66635686",
"0.6662689",
"0.6616535",
"0.66059893",
"0.6597834",
"0.6594002",
"0.6588306",
"0.6584573",
"0.65811867",
"0.65394926... | 0.7415017 | 2 |
Property that is True if data can be colourmap normalised. | def normalisable(self):
return np.abs(np.nansum(self.data)) > 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_change_PhotometricInterpretation_to_RGB(ds: \"Dataset\") -> bool:\n return False",
"def needs_to_convert_to_RGB(ds: \"Dataset\") -> bool:\n return False",
"def rgb(self) -> bool:\n return self.image_shape[2] == 3",
"def is_grayscale(self):\n return self.r == self.g == self.b",
... | [
"0.65376264",
"0.653758",
"0.6286492",
"0.59674203",
"0.59674203",
"0.5822328",
"0.57541865",
"0.5704884",
"0.5701421",
"0.57007426",
"0.5666162",
"0.5616968",
"0.5615069",
"0.56148565",
"0.5548846",
"0.552823",
"0.55227816",
"0.5418004",
"0.54004663",
"0.5399651",
"0.5396256... | 0.6446703 | 2 |
Transform WCS to a frame centred on the image. | def switch_to_offsets(self):
cdelt1, cdelt2 = proj_plane_pixel_scales(self.wcs)
ctype = self.wcs.wcs.ctype
crpix = self.wcs.wcs_world2pix(self.ra, self.dec, 1)
# Create new WCS as Skymapper does weird things with CDELT
self.wcs = WCS(naxis=2)
# Centre pixel is offset b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fixBorder(frame):\n s = frame.shape\n # Scale the image 2% without moving the center\n T = cv2.getRotationMatrix2D((s[1]/2, s[0]/2), 0, 1.02)\n frame = cv2.warpAffine(frame, T, (s[1], s[0]))\n return frame",
"def _get_frame_center(self, src):\n w, h = get_size(src)\n x = w / 2\n ... | [
"0.64261657",
"0.58739823",
"0.5801011",
"0.57116616",
"0.5693262",
"0.56858474",
"0.5612682",
"0.55887204",
"0.5571909",
"0.55364543",
"0.55344856",
"0.55134726",
"0.5496375",
"0.5457848",
"0.54260415",
"0.54260415",
"0.5367976",
"0.5363072",
"0.5356434",
"0.53177714",
"0.53... | 0.5527715 | 11 |
Display a group from the given group id. | def groups_by_id(request, gid):
group = Group()
filtered_groups = group.query({"gid":str(gid)})
if len(filtered_groups) == 0:
badRequest("No available group under GID "+str(gid))
return HttpResponse(json.dumps(filtered_groups)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli(ctx, group_id):\n return ctx.gi.groups.show_group(group_id)",
"def show_group(self, group_id):\n\n return Client._get(self, id=group_id)",
"def groups(request, group_id = 1):\n group = get_object_or_404(ResearchGroup, pk=group_id)\n groups = ResearchGroup.objects.order_by('name')\n g... | [
"0.84070766",
"0.7740285",
"0.710813",
"0.706569",
"0.70525783",
"0.69074094",
"0.68271923",
"0.6798981",
"0.6787939",
"0.6716215",
"0.6705907",
"0.67016923",
"0.66988087",
"0.66607374",
"0.6616495",
"0.6611702",
"0.6568064",
"0.6509636",
"0.64655566",
"0.6438668",
"0.6383196... | 0.6297019 | 27 |
Display a 404 page with a given message after any bad request. | def badRequest(message):
raise Http404(message) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_404(error):\n return render_template('/error.html'), 404",
"def page_not_found(er):\n return render_template('errors.html'), 404",
"def page_not_found(e):\n return render_template('404.html'), 404",
"def page_not_found(e):\n return render_template('404.html'), 404",
"def page_not_fo... | [
"0.8235648",
"0.81195563",
"0.8113618",
"0.8113618",
"0.8112197",
"0.81021154",
"0.8090558",
"0.80553967",
"0.8050602",
"0.8037045",
"0.80208427",
"0.79905635",
"0.7980727",
"0.79504347",
"0.7945613",
"0.7925859",
"0.79064953",
"0.7890391",
"0.7870355",
"0.78605354",
"0.78436... | 0.75103325 | 63 |
Check if the given two digit encoded message is a valid char. | def is_valid_two_digit_char(code: str) -> bool:
return 10 <= int(code) <= 26 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_input_valid(char):\n\n # is there a char at all?\n if char is None:\n return False\n\n # check for embedded 0 byte\n if char == \"\\0\":\n return False\n\n return True",
"def _validate_ascii(message):\n return all(ord(c) < 128 for c in message)",
"def is_valid_msg(msg):\n... | [
"0.71109474",
"0.7062189",
"0.6548195",
"0.65020955",
"0.64892834",
"0.644029",
"0.6439921",
"0.64247704",
"0.6344382",
"0.63188714",
"0.62968117",
"0.62936205",
"0.62808067",
"0.6224203",
"0.62086666",
"0.6137437",
"0.61113614",
"0.6081801",
"0.60787374",
"0.60777146",
"0.60... | 0.73531914 | 0 |
Get a random element from the set. | def getRandom(self) -> int:
return random.choice(tuple(self.l)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRandom(self):\n return self.nums[random.randint(0, len(self.nums) - 1)]\n\n # Your RandomizedSet object will be instantiated and called as such:\n # obj = RandomizedSet()\n # param_1 = obj.insert(val)\n # param_2 = obj.remove(val)\n # param_3 = obj.getRandom()",
"... | [
"0.77060276",
"0.738916",
"0.7296881",
"0.72187954",
"0.6871744",
"0.68453854",
"0.68330806",
"0.67740154",
"0.67226046",
"0.6703282",
"0.6665089",
"0.66356236",
"0.66217655",
"0.6612035",
"0.66000897",
"0.6567767",
"0.6477719",
"0.6462421",
"0.64428514",
"0.64162946",
"0.640... | 0.6122921 | 52 |
Get clifford operators, build based on symmetries and singlequbit X. | def cliffords(self) -> List[PauliSumOp]:
cliffords = [
(PauliOp(pauli_symm) + PauliOp(sq_pauli)) / np.sqrt(2)
for pauli_symm, sq_pauli in zip(self._symmetries, self._sq_paulis)
]
return cliffords | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_CC_operators():\n i = symbols('i', below_fermi=True, cls=Dummy)\n a = symbols('a', above_fermi=True, cls=Dummy)\n t_ai = AntiSymmetricTensor('t', (a,), (i,))\n ai = NO(Fd(a)*F(i))\n i, j = symbols('i,j', below_fermi=True, cls=Dummy)\n a, b = symbols('a,b', above_fermi=True, cls=Dummy)\n ... | [
"0.64887905",
"0.6393771",
"0.6334227",
"0.63176847",
"0.6156194",
"0.60782033",
"0.6074436",
"0.60564524",
"0.6018028",
"0.60011035",
"0.58997136",
"0.58405644",
"0.58351237",
"0.5812727",
"0.57892907",
"0.5787637",
"0.5758515",
"0.57326216",
"0.57319075",
"0.5700948",
"0.56... | 0.0 | -1 |
Finds Z2 Paulitype symmetries of an Operator. | def find_Z2_symmetries(cls, operator: PauliSumOp) -> "Z2Symmetries":
pauli_symmetries = []
sq_paulis = []
sq_list = []
stacked_paulis = []
if operator.is_zero():
logger.info("Operator is empty.")
return cls([], [], [], None)
for pauli in operato... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_find_z2_symmetries_op_without_sym(self):\n qubit_op = SparsePauliOp.from_list(\n [\n (\"I\", -1.0424710218959303),\n (\"Z\", -0.7879673588770277),\n (\"X\", -0.18128880821149604),\n ]\n )\n z2_symmetries = Z2Symmetries... | [
"0.6892468",
"0.6586291",
"0.6491791",
"0.62042934",
"0.6083347",
"0.5920768",
"0.5814815",
"0.56970036",
"0.55275255",
"0.55129266",
"0.5485052",
"0.5474561",
"0.54484516",
"0.53852695",
"0.5349764",
"0.52995557",
"0.52523893",
"0.5237814",
"0.5208543",
"0.5200767",
"0.51892... | 0.76096714 | 0 |
Overload `==` operation to evaluate equality between Z2Symmetries. | def __eq__(self, other: object) -> bool:
if not isinstance(other, Z2Symmetries):
return False
return (
self.symmetries == other.symmetries
and self.sq_paulis == other.sq_paulis
and self.sq_list == other.sq_list
and self.tapering_values == othe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if other is self:\n return True\n if isinstance(other, CoordFunctionSymb):\n if other.parent() != self.parent():\n return False\n else:\n return bool(other._express == self._express)\n else:\n ... | [
"0.6431645",
"0.61523557",
"0.6150391",
"0.61166376",
"0.60961133",
"0.60693336",
"0.6035471",
"0.60161793",
"0.5984229",
"0.5927028",
"0.59111166",
"0.59111166",
"0.59050834",
"0.5896308",
"0.58933914",
"0.5891502",
"0.5887405",
"0.58856267",
"0.5828395",
"0.5822424",
"0.581... | 0.7667618 | 0 |
Create a sqlalchemy engine and session to interact with the database. | def setup_db(config):
# create the URL from the configuration
db_url = URL(**config)
db = create_engine(db_url)
Session = sessionmaker(db)
# Link the relational model to the database
Model.metadata.create_all(db)
return db, Session | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_db_session(self, engine):\r\n dbsession = sessionmaker(bind=engine)\r\n session = dbsession()\r\n return session",
"def setup_session():\n print(\"Setting up session\")\n engine = setup_engine()\n Base.metadata.bin = engine\n\n DBSession = sessionmaker(bind=engine)\n ... | [
"0.81359595",
"0.8040083",
"0.7979236",
"0.78089476",
"0.7701222",
"0.77003556",
"0.764165",
"0.7622947",
"0.7579027",
"0.755317",
"0.7521227",
"0.7505744",
"0.74904746",
"0.7463159",
"0.74597645",
"0.7455637",
"0.7415893",
"0.74005294",
"0.7356361",
"0.73400027",
"0.73347634... | 0.7439551 | 16 |
Check if a password is the same than the hashed password. | def check_password(password, hashed_password):
return bcrypt.checkpw(
_encode_string(password), _encode_string(hashed_password)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __is_correct_password(salt: bytes, pw_hash: bytes, password: str) -> bool:\n return hmac.compare_digest(\n pw_hash, hashlib.pbkdf2_hmac(\"sha256\", password.encode(), salt, 100000)\n )",
"def is_correct_password(salt: bytes, pw_hash: bytes, password: str) -> bool:\n return hmac.compare_digest... | [
"0.8016892",
"0.7881232",
"0.78616977",
"0.7829685",
"0.7827264",
"0.7801725",
"0.77869296",
"0.77302456",
"0.7635051",
"0.76084554",
"0.7603575",
"0.75913775",
"0.75641733",
"0.7497149",
"0.7484627",
"0.7476307",
"0.74737895",
"0.7446123",
"0.7428713",
"0.7428713",
"0.741909... | 0.70709556 | 72 |
Calculates the position of the rectangular patch, relative to the event duration. | def calculate_graph_element_position(self, keyInfo, key, index, duration, average):
# Rectangle takes (lowerleftpoint=(X, Y), width, height)
xy = (float(key[0]), self.ax.get_ylim()[1])
# If not the latest element in the key-change data
if index < len(keyInfo) - 1:
# Swap width and height as we a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_rect(self):\r\n self.rect.x = int(self.view_pt.x_to_scr(self.x) / self.z)\r\n self.rect.y = int(self.view_pt.y_to_scr(self.y) / self.z)",
"def adjust_position(self):\n\n # Adjust position for x-axis\n r = self.rect.x % 30\n if r != 0:\n if r <= 16:\n ... | [
"0.64458704",
"0.6313074",
"0.6254609",
"0.60468507",
"0.6017669",
"0.5855488",
"0.58349967",
"0.58349967",
"0.57846844",
"0.57711947",
"0.57698476",
"0.5750508",
"0.5731958",
"0.5722748",
"0.5657773",
"0.5657773",
"0.5604806",
"0.5583857",
"0.5514846",
"0.54797363",
"0.54797... | 0.5178504 | 54 |
Returns a colour map for key changes to ensure consistent patterns across CALMA plots. | def get_colour_map(self):
try:
return {'C# minor' : 'Grey', 'A major' : 'Red', 'D minor' : 'Green',
'Eb Purple': 'greenyellow', 'D major' : 'Pink', 'G major' : 'Orange',
'G minor': 'goldenrod', 'A minor' : 'indianred', 'C minor' : 'peachpuff',
'B minor'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_color_map(self):\n unique_labels = np.unique(self.out_labels)\n color_map = {}\n for unique_label in unique_labels:\n color_map[unique_label] = self._random_color()\n\n return color_map",
"def get_colormap(self):\n return colors.ev_colormaps[self.name]",
... | [
"0.63322717",
"0.62229353",
"0.61901695",
"0.6187851",
"0.6162454",
"0.6134169",
"0.60871094",
"0.60867405",
"0.6079857",
"0.60154575",
"0.5999817",
"0.5987499",
"0.5973997",
"0.5958746",
"0.5956373",
"0.59459084",
"0.59447443",
"0.59309727",
"0.5908865",
"0.58996123",
"0.584... | 0.67521995 | 0 |
Returns the velocity of the peak channel for each pixel, and the pixel value. | def peak_pixel(data, x0=0.0, dx=1.0, axis=0):
x_max = np.argmax(data, axis=axis)
y_max = np.max(data, axis=axis)
return x0 + dx * x_max, 0.5 * dx, y_max | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peak_height(self):\n return np.array([max(self.waveform[ch]) for ch in range(self.nchannels)])",
"def peak_time(self):\n return np.array([self.wftime[ch][self.waveform[ch].argmax()] for ch in range(self.nchannels)])",
"def compute_desired_velocity(self):\n mask_red = (self.image_red == 255) \\... | [
"0.6498354",
"0.63442695",
"0.6305139",
"0.6020289",
"0.59217495",
"0.58739406",
"0.5829068",
"0.58127123",
"0.5699084",
"0.56868404",
"0.5650007",
"0.5641548",
"0.5582975",
"0.55801904",
"0.5567978",
"0.5551847",
"0.5546675",
"0.5541983",
"0.55090886",
"0.5497814",
"0.548988... | 0.57913303 | 8 |
Renders the home page. | def home():
return render_template(
'index.html',
title='Home Page',
year=datetime.now().year,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_home():\r\n\treturn render_template(\"index.html\")",
"def home():\n\n return render_template('home_page.html')",
"def home():\n\n return render_template(\"home.html\")",
"def home():\n return render_template('home.html')",
"def home():\n return render_template('home.html')",
"def ... | [
"0.85574406",
"0.853399",
"0.8351404",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.827363",
"... | 0.8061255 | 38 |
Computes sigmoid(x) for some activation x. | def sigmoid(x):
return 1 / (1 + np.exp(-x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid_activation(x):\n return 1.0 / (1 + np.exp(-x))",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\r\n\r\n return 1 / (1 + np.exp(-x))",
"def sigmoid(x):\n return 1.0/(1.0+exp(-x))",
"def sigmoid(x):\n return 1.0 / (... | [
"0.9055437",
"0.8951119",
"0.8951119",
"0.8895742",
"0.88867384",
"0.8863933",
"0.8856317",
"0.88494825",
"0.8817724",
"0.8813557",
"0.88082683",
"0.88082683",
"0.87988925",
"0.8798874",
"0.87912995",
"0.87906015",
"0.878794",
"0.874856",
"0.87038004",
"0.8679779",
"0.867409"... | 0.8826303 | 11 |
Assert that the response has the given status code and parsed content | def assert_response_correct(self, response, expected_status, expected_content):
assert response.status_code == expected_status
parsed_content = json.loads(response.content.decode('utf-8'))
assert parsed_content == expected_content | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_response_correct(self, response, expected_status, expected_content):\n assert response.status_code == expected_status\n\n if expected_content:\n assert response.content.decode('utf-8') == expected_content",
"def assert_response_correct(self, response, expected_status, expected... | [
"0.80223584",
"0.79831654",
"0.7913485",
"0.7828235",
"0.7765568",
"0.76866055",
"0.76342833",
"0.75451547",
"0.74794745",
"0.7425999",
"0.7380393",
"0.73432505",
"0.7319662",
"0.72661155",
"0.72251016",
"0.7222837",
"0.7151803",
"0.7144004",
"0.7133448",
"0.70640194",
"0.703... | 0.8269274 | 0 |
Assert that the response has the given status code and content | def assert_response_correct(self, response, expected_status, expected_content):
assert response.status_code == expected_status
if expected_content:
assert response.content.decode('utf-8') == expected_content | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_response_correct(self, response, expected_status, expected_content):\n assert response.status_code == expected_status\n\n if expected_content:\n assert str(response.content) == expected_content",
"def assertResponse(self, response, status_code=None, content=None):\n sel... | [
"0.82645446",
"0.8243966",
"0.8210479",
"0.8058191",
"0.792817",
"0.791679",
"0.77907085",
"0.7712697",
"0.7665939",
"0.7612862",
"0.7587554",
"0.757176",
"0.75260836",
"0.748018",
"0.7466748",
"0.7355775",
"0.7244242",
"0.72410995",
"0.7178826",
"0.7160397",
"0.7143551",
"... | 0.8222443 | 2 |
Helper function for creating headers for the JWT authentication. | def build_jwt_headers(self, user):
token = create_jwt_for_user(user)
headers = {'HTTP_AUTHORIZATION': 'JWT ' + token}
return headers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_headers(self):\n return {\n 'Authorization': 'JWT {}'.format(self.token)\n }",
"def create_authorization_header(self, **kwargs):\n return {\"Authorization\": \"Bearer {}\".format(self.create_jwt(**kwargs))}",
"def get_headers(self):\n headers = self.headers\n\n ... | [
"0.7734756",
"0.76987463",
"0.7658371",
"0.7586913",
"0.7532777",
"0.7520249",
"0.7433449",
"0.73901826",
"0.7326667",
"0.72288257",
"0.72168773",
"0.71755236",
"0.71555465",
"0.71477264",
"0.7124218",
"0.7103212",
"0.7012003",
"0.6997966",
"0.69950837",
"0.69733036",
"0.6958... | 0.80058163 | 0 |
Assert that the response has the given status code and content | def assert_response_correct(self, response, expected_status, expected_content):
assert response.status_code == expected_status
if expected_content:
assert str(response.content) == expected_content | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assertResponse(self, response, status_code=None, content=None):\n self.assertIsInstance(response, HttpResponse)\n if status_code is not None and response.status_code != status_code:\n self.fail(\n \"Expected status code of {}, got {}. Content:\\n{}\".format(\n ... | [
"0.8243966",
"0.8222443",
"0.8210479",
"0.8058191",
"0.792817",
"0.791679",
"0.77907085",
"0.7712697",
"0.7665939",
"0.7612862",
"0.7587554",
"0.757176",
"0.75260836",
"0.748018",
"0.7466748",
"0.7355775",
"0.7244242",
"0.72410995",
"0.7178826",
"0.7160397",
"0.7143551",
"0... | 0.82645446 | 0 |
Helper function for creating headers for the JWT authentication. | def build_jwt_headers(self, user):
token = create_jwt_for_user(user)
headers = {'HTTP_AUTHORIZATION': 'JWT ' + token}
return headers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_headers(self):\n return {\n 'Authorization': 'JWT {}'.format(self.token)\n }",
"def create_authorization_header(self, **kwargs):\n return {\"Authorization\": \"Bearer {}\".format(self.create_jwt(**kwargs))}",
"def get_headers(self):\n headers = self.headers\n\n ... | [
"0.7734756",
"0.76987463",
"0.7658371",
"0.7586913",
"0.7532777",
"0.7520249",
"0.7433449",
"0.73901826",
"0.7326667",
"0.72288257",
"0.72168773",
"0.71755236",
"0.71555465",
"0.71477264",
"0.7124218",
"0.7103212",
"0.7012003",
"0.6997966",
"0.69950837",
"0.69733036",
"0.6958... | 0.80058163 | 1 |
Tests discussion topic does not exist for the given topic id. | def test_discussion_topic_404(self):
topic_id = "courseware-topic-id"
self.make_discussion_xblock(topic_id, "test_category", "test_target")
url = f"{self.url}?topic_id=invalid_topic_id"
response = self.client.get(url)
self.assert_response_correct(
response,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_topic_notification_create_no_access(self):\n private = utils.create_private_topic()\n\n utils.login(self)\n form_data = {'is_active': True, }\n response = self.client.post(\n reverse(\n 'spirit:topic:notification:create',\n kwargs={'topi... | [
"0.6463931",
"0.63495606",
"0.6338876",
"0.6110078",
"0.60847676",
"0.5970361",
"0.59135574",
"0.58561516",
"0.58535457",
"0.58110976",
"0.5782986",
"0.57260275",
"0.56990814",
"0.56968343",
"0.56950593",
"0.56912136",
"0.5689643",
"0.5673871",
"0.56513",
"0.5645895",
"0.5614... | 0.814976 | 0 |
Tests discussion topic details against a requested topic id | def test_topic_id(self):
topic_id_1 = "topic_id_1"
topic_id_2 = "topic_id_2"
self.make_discussion_xblock(topic_id_1, "test_category_1", "test_target_1")
self.make_discussion_xblock(topic_id_2, "test_category_2", "test_target_2")
url = f"{self.url}?topic_id=topic_id_1,topic_id_2"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_post_on_topic(self):\n url = reverse(\n 'post-detail',\n args=[\n self.topic1.url_name,\n self.post1.id\n ]\n )\n response = self.client.get(url)\n\n self.assertEqual(response.status_code, status.HTTP_200_OK)\n ... | [
"0.7070069",
"0.67060006",
"0.66090375",
"0.6494381",
"0.64904827",
"0.64530283",
"0.6398895",
"0.63194615",
"0.628795",
"0.62767637",
"0.62225556",
"0.6186123",
"0.61689126",
"0.61286986",
"0.61005974",
"0.6080214",
"0.6029419",
"0.5990907",
"0.59878266",
"0.59845114",
"0.59... | 0.72078526 | 0 |
Tests thread has user profile image details if called in requested_fields | def test_profile_image_requested_field(self):
user_2 = UserFactory.create(password=self.password)
# Ensure that parental controls don't apply to this user
user_2.profile.year_of_birth = 1970
user_2.profile.save()
source_threads = [
self.create_source_thread(),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_profile_image_requested_field(self):\n self.register_get_user_response(self.user)\n cs_thread = make_minimal_cs_thread({\n \"id\": self.thread_id,\n \"course_id\": str(self.course.id),\n \"username\": self.user.username,\n \"user_id\": str(self.use... | [
"0.8350714",
"0.8009413",
"0.7845835",
"0.7689106",
"0.6404223",
"0.6321115",
"0.6115614",
"0.59864986",
"0.5790376",
"0.57836694",
"0.5743967",
"0.5681056",
"0.56474423",
"0.5644567",
"0.5641627",
"0.5600402",
"0.557616",
"0.55577576",
"0.55448985",
"0.5521472",
"0.5514169",... | 0.82767236 | 1 |
Tests all comments retrieved have user profile image details if called in requested_fields | def test_profile_image_requested_field(self):
source_comments = [self.create_source_comment()]
self.register_get_thread_response({
"id": self.thread_id,
"course_id": str(self.course.id),
"thread_type": "discussion",
"children": source_comments,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_profile_image_requested_field(self):\n self.register_get_user_response(self.user)\n cs_comment_child = self.make_comment_data('test_child_comment', self.comment_id, children=[])\n cs_comment = self.make_comment_data(self.comment_id, None, [cs_comment_child])\n cs_thread = make_... | [
"0.8378507",
"0.786277",
"0.76741105",
"0.7170395",
"0.71419144",
"0.6993679",
"0.62927294",
"0.5908545",
"0.58488584",
"0.5830102",
"0.5702719",
"0.56787133",
"0.5664201",
"0.56540376",
"0.5638272",
"0.562767",
"0.55817664",
"0.5566697",
"0.5558393",
"0.5552993",
"0.5548348"... | 0.83859634 | 0 |
Tests thread has user profile image details if called in requested_fields | def test_profile_image_requested_field(self):
self.register_get_user_response(self.user)
cs_thread = make_minimal_cs_thread({
"id": self.thread_id,
"course_id": str(self.course.id),
"username": self.user.username,
"user_id": str(self.user.id),
})
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_profile_image_requested_field(self):\n user_2 = UserFactory.create(password=self.password)\n # Ensure that parental controls don't apply to this user\n user_2.profile.year_of_birth = 1970\n user_2.profile.save()\n source_threads = [\n self.create_source_thread... | [
"0.82767236",
"0.8009413",
"0.7845835",
"0.7689106",
"0.6404223",
"0.6321115",
"0.6115614",
"0.59864986",
"0.5790376",
"0.57836694",
"0.5743967",
"0.5681056",
"0.56474423",
"0.5644567",
"0.5641627",
"0.5600402",
"0.557616",
"0.55577576",
"0.55448985",
"0.5521472",
"0.5514169"... | 0.8350714 | 0 |
Returns comment dict object as returned by comments service | def make_comment_data(self, comment_id, parent_id=None, children=[]): # pylint: disable=W0102
return make_minimal_cs_comment({
"id": comment_id,
"parent_id": parent_id,
"course_id": str(self.course.id),
"thread_id": self.thread_id,
"thread_type": "dis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convert_comment(self, data):\n\n output = {}\n output['id'] = int(data['id'])\n output['author'] = data['user_display_name']\n output['profile_url'] = data['user_url']\n output['date'] = data['comment_added_at']\n output['date_ago'] = timeago.format(self._parse_dateti... | [
"0.7624234",
"0.73207664",
"0.7291462",
"0.726618",
"0.71346116",
"0.7124576",
"0.7046029",
"0.6970595",
"0.6937162",
"0.687293",
"0.6854054",
"0.6828101",
"0.68238384",
"0.67981327",
"0.6777456",
"0.67468834",
"0.67468834",
"0.67468834",
"0.6743909",
"0.673812",
"0.67092174"... | 0.6570009 | 30 |
Tests all comments retrieved have user profile image details if called in requested_fields | def test_profile_image_requested_field(self):
self.register_get_user_response(self.user)
cs_comment_child = self.make_comment_data('test_child_comment', self.comment_id, children=[])
cs_comment = self.make_comment_data(self.comment_id, None, [cs_comment_child])
cs_thread = make_minimal_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_profile_image_requested_field(self):\n source_comments = [self.create_source_comment()]\n self.register_get_thread_response({\n \"id\": self.thread_id,\n \"course_id\": str(self.course.id),\n \"thread_type\": \"discussion\",\n \"children\": source_... | [
"0.83859634",
"0.786277",
"0.76741105",
"0.7170395",
"0.71419144",
"0.6993679",
"0.62927294",
"0.5908545",
"0.58488584",
"0.5830102",
"0.5702719",
"0.56787133",
"0.5664201",
"0.56540376",
"0.5638272",
"0.562767",
"0.55817664",
"0.5566697",
"0.5558393",
"0.5552993",
"0.5548348... | 0.8378507 | 1 |
Test and verify that authentication is required for this endpoint. | def test_authentication_required(self, method):
self.client.logout()
response = getattr(self.client, method)(self.path)
assert response.status_code == 401 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_auth_required(self):\n\n res = self.client.get(SERVICES_URL)\n self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED)",
"def test_auth_required(self):\n res = self.client.get(RECIPE_URL)\n self.assertEqual(res.status_code,status.HTTP_401_UNAUTHORIZED)",
"def test_a... | [
"0.7950448",
"0.76868105",
"0.76661503",
"0.76661503",
"0.7642662",
"0.76391345",
"0.7570461",
"0.7530811",
"0.7526535",
"0.7511525",
"0.73548096",
"0.72665995",
"0.72506523",
"0.72483444",
"0.7175282",
"0.71737605",
"0.7169906",
"0.7169906",
"0.71577156",
"0.7152676",
"0.713... | 0.7206106 | 14 |
Test the response when this endpoint is passed a nonexistent course id. | def test_non_existent_course_id(self):
self._login_as_staff()
response = self.client.get(
reverse('discussion_course_settings', kwargs={
'course_id': 'a/b/c'
})
)
assert response.status_code == 404 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_non_existent_course_id(self):\n self._login_as_staff()\n path = self.path(course_id='a/b/c')\n response = self.client.get(path)\n\n assert response.status_code == 404\n\n response = self.client.post(path)\n assert response.status_code == 404",
"def test_api_get_... | [
"0.8322255",
"0.8022509",
"0.7757447",
"0.76497215",
"0.75796556",
"0.7559593",
"0.74963504",
"0.7455874",
"0.7155128",
"0.7124054",
"0.7032479",
"0.686246",
"0.6849403",
"0.6825156",
"0.67567396",
"0.67308384",
"0.6718114",
"0.67143536",
"0.6705622",
"0.66414255",
"0.6636364... | 0.796745 | 2 |
Test the response status code on sending a PATCH request with an empty body or missing fields. | def test_empty_body_patch_request(self):
self._login_as_staff()
response = self.patch_request("")
assert response.status_code == 400
response = self.patch_request({})
assert response.status_code == 400 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_PATCH(self):\n if not self.url:\n return\n response = self.client.patch(self.url, {}, format='json')\n self.assertIn(response.status_code, [status.HTTP_405_METHOD_NOT_ALLOWED,\n status.HTTP_401_UNAUTHORIZED])",
"def test_client_... | [
"0.7514054",
"0.7330896",
"0.6851677",
"0.6822737",
"0.6770208",
"0.67126334",
"0.66794896",
"0.6600391",
"0.65654063",
"0.65277135",
"0.65268874",
"0.6487522",
"0.64785326",
"0.6471589",
"0.6409385",
"0.6401854",
"0.6366732",
"0.6316152",
"0.6305031",
"0.6302076",
"0.6293325... | 0.7643463 | 0 |
Test the response status code on sending a PATCH request with parameters having incorrect types. | def test_invalid_body_parameters(self, body):
self._login_as_staff()
response = self.patch_request(body)
assert response.status_code == 400 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_PATCH(self):\n if not self.url:\n return\n response = self.client.patch(self.url, {}, format='json')\n self.assertIn(response.status_code, [status.HTTP_405_METHOD_NOT_ALLOWED,\n status.HTTP_401_UNAUTHORIZED])",
"def test_client_... | [
"0.71415395",
"0.71362484",
"0.7032255",
"0.69430655",
"0.6938978",
"0.6889845",
"0.6740354",
"0.6675492",
"0.66588426",
"0.65660495",
"0.6517692",
"0.6494218",
"0.6461693",
"0.6443991",
"0.643274",
"0.64230174",
"0.6376",
"0.6360994",
"0.6360465",
"0.6354983",
"0.63522065",
... | 0.6492817 | 12 |
Test whether the 'always_divide_inline_discussions' setting is updated. | def test_update_always_divide_inline_discussion_settings(self):
config_course_cohorts(self.course, is_cohorted=True)
self._login_as_staff()
expected_response = self._get_expected_response()
self._assert_current_settings(expected_response)
expected_response['always_divide_inline_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_inline_discussion_settings(self):\n config_course_cohorts(self.course, is_cohorted=True)\n self._login_as_staff()\n expected_response = self._get_expected_response()\n self._assert_current_settings(expected_response)\n\n now = datetime.now()\n ItemFactory.c... | [
"0.65155196",
"0.5639965",
"0.56395197",
"0.5564846",
"0.5544021",
"0.5508103",
"0.5503728",
"0.5492476",
"0.54195917",
"0.5390445",
"0.5389848",
"0.53006417",
"0.52866846",
"0.52555525",
"0.5229147",
"0.52077377",
"0.5200304",
"0.5185702",
"0.518409",
"0.5166526",
"0.5159768... | 0.7850817 | 0 |
Test whether the 'divided_inline_discussions' setting is updated. | def test_update_inline_discussion_settings(self):
config_course_cohorts(self.course, is_cohorted=True)
self._login_as_staff()
expected_response = self._get_expected_response()
self._assert_current_settings(expected_response)
now = datetime.now()
ItemFactory.create(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_always_divide_inline_discussion_settings(self):\n config_course_cohorts(self.course, is_cohorted=True)\n self._login_as_staff()\n expected_response = self._get_expected_response()\n self._assert_current_settings(expected_response)\n expected_response['always_divid... | [
"0.7398982",
"0.62203187",
"0.6201276",
"0.61978525",
"0.616984",
"0.6059117",
"0.5911428",
"0.5720757",
"0.5578674",
"0.555912",
"0.5522277",
"0.55078506",
"0.544886",
"0.5399877",
"0.53951263",
"0.5355195",
"0.5341761",
"0.5339367",
"0.5334819",
"0.53326404",
"0.530437",
... | 0.70513904 | 1 |
Test and verify that authentication is required for this endpoint. | def test_authentication_required(self, method):
self.client.logout()
response = getattr(self.client, method)(self.path())
assert response.status_code == 401 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_auth_required(self):\n\n res = self.client.get(SERVICES_URL)\n self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED)",
"def test_auth_required(self):\n res = self.client.get(RECIPE_URL)\n self.assertEqual(res.status_code,status.HTTP_401_UNAUTHORIZED)",
"def test_a... | [
"0.7950448",
"0.76868105",
"0.76661503",
"0.76661503",
"0.7642662",
"0.76391345",
"0.7570461",
"0.7530811",
"0.7526535",
"0.7511525",
"0.73548096",
"0.72665995",
"0.72483444",
"0.7206106",
"0.7175282",
"0.71737605",
"0.7169906",
"0.7169906",
"0.71577156",
"0.7152676",
"0.7137... | 0.72506523 | 12 |
Test the response when the endpoint URL contains a nonexistent course id. | def test_non_existent_course_id(self):
self._login_as_staff()
path = self.path(course_id='a/b/c')
response = self.client.get(path)
assert response.status_code == 404
response = self.client.post(path)
assert response.status_code == 404 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_non_existent_course_id(self):\n self._login_as_staff()\n response = self.client.get(\n reverse('discussion_course_settings', kwargs={\n 'course_id': 'a/b/c'\n })\n )\n assert response.status_code == 404",
"def test_api_get_course_by_id_cou... | [
"0.8015396",
"0.7954541",
"0.77625984",
"0.76741165",
"0.7661086",
"0.75876415",
"0.75582665",
"0.74304533",
"0.7287139",
"0.727886",
"0.7076672",
"0.6984809",
"0.6852281",
"0.6805588",
"0.6771466",
"0.67493176",
"0.6741063",
"0.67005354",
"0.6689674",
"0.6653416",
"0.6641232... | 0.82176054 | 0 |
Test the response when the endpoint URL contains a nonexistent role. | def test_non_existent_course_role(self):
self._login_as_staff()
path = self.path(role='A')
response = self.client.get(path)
assert response.status_code == 400
response = self.client.post(path)
assert response.status_code == 400 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_returns_403_if_user_doesnt_have_PM_role(self):\n # Act\n response = self.client.get(\n self.url,\n headers={\"Authorization\": self.user_session_token},\n )\n self.assertEqual(response.status_code, 403)",
"def test_returns_403_if_user_doesnt_have_PM_role... | [
"0.6680411",
"0.6680411",
"0.6680411",
"0.6630807",
"0.66241336",
"0.65975183",
"0.65004057",
"0.64912117",
"0.6464126",
"0.64608115",
"0.64225084",
"0.6398633",
"0.6396459",
"0.6396459",
"0.63877106",
"0.63877106",
"0.63877106",
"0.63877106",
"0.63733333",
"0.6356531",
"0.63... | 0.72400665 | 0 |
Test the response with a POST request without a body. | def test_post_missing_body(self):
self._login_as_staff()
response = self.client.post(self.path())
assert response.status_code == 400 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_missing_body(self):\n self.is_authenticated()\n response = self.post_without_body()\n self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)",
"def test_post(self):\n return self.doRequest(self.url, method=\"POST\", body=self.input)",
"def test_service_api_post... | [
"0.760882",
"0.7349504",
"0.72575694",
"0.7159831",
"0.7158061",
"0.7130226",
"0.7128347",
"0.71203625",
"0.7119646",
"0.71075845",
"0.7084577",
"0.7048706",
"0.69651973",
"0.6936803",
"0.69351226",
"0.68292725",
"0.67844677",
"0.67838746",
"0.6767015",
"0.6765974",
"0.675845... | 0.6979357 | 12 |
Gets the name of this Lecture. | def name(self) -> str:
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self) -> str:\n return pulumi.get(self, \"name\")",
"def name(self) -> str:\n return pulumi.get(self, \"name\")",
"def name(self) -> str:\n return pulumi.get(self, \"name\")",
"def name(self) -> str:\n return pulumi.get(self, \"name\")",
"def name(self) -> str:\n ... | [
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884",
"0.68905884"... | 0.0 | -1 |
Sets the name of this Lecture. | def name(self, name: str):
if name is None:
raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501
self._name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n ... | [
"0.7256778",
"0.7256778",
"0.7256778",
"0.7256778",
"0.7256778",
"0.7219376",
"0.7174746",
"0.71650887",
"0.71171784",
"0.71171784",
"0.71074295",
"0.70908993",
"0.70908993",
"0.7088028",
"0.7085079",
"0.7079584",
"0.70190406",
"0.6983657",
"0.6983657",
"0.6971501",
"0.693708... | 0.0 | -1 |
Gets the start_time of this Lecture. | def start_time(self) -> str:
return self._start_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_time(self) -> str:\n return pulumi.get(self, \"start_time\")",
"def start_time(self) -> str:\n return pulumi.get(self, \"start_time\")",
"def start_time(self):\n return self._start_time",
"def start_time(self):\n return self._start_time",
"def start_time(self):\n ... | [
"0.7776385",
"0.7776385",
"0.7720497",
"0.7720497",
"0.7720497",
"0.7720497",
"0.7720497",
"0.7720497",
"0.7720497",
"0.7720497",
"0.7684102",
"0.76729786",
"0.764936",
"0.76383525",
"0.7582366",
"0.7562215",
"0.7558154",
"0.75506216",
"0.75506216",
"0.7548388",
"0.74300706",... | 0.7641603 | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.