query stringlengths 9 3.4k | document stringlengths 9 87.4k | metadata dict | negatives listlengths 4 101 | negative_scores listlengths 4 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Test to see if profile for leothelion can be viewed anon and logged in | def test_view_profile(self):
LOGGER.debug("Test GET /rango/view/leothelion/ for anon user")
anon_view_response = self.client.get('/rango/view/leothelion/')
self.assertContains(anon_view_response, "leothelion@hotmail.com")
LOGGER.debug("Test GET /rango/view/leothelion/ for logged in use... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user_has_access(self):\n return self.user_has_access(users.get_current_user())",
"def test_06_user_public_profile(self):\r\n # As Anonymou user\r\n url = \"/account/%s\" % self.name\r\n res = self.app.get(url, follow_redirects=True)\r\n dom = BeautifulSoup(res.data)\r\n... | [
"0.69051546",
"0.6754408",
"0.67433447",
"0.66899693",
"0.6672601",
"0.6667041",
"0.6631646",
"0.66299933",
"0.6568902",
"0.6545809",
"0.6544475",
"0.65014887",
"0.6479417",
"0.64605063",
"0.64309174",
"0.6402466",
"0.63988775",
"0.6398008",
"0.6369444",
"0.6363515",
"0.63518... | 0.70540863 | 0 |
Test to see if profile for user1 can be edited anon and logged in | def test_edit_profile(self):
LOGGER.debug("Test GET /rango/edit/ for anon user")
anon_edit_response = self.client.get('/rango/edit/')
# redirected to login page
self.assertEquals(302, anon_edit_response.status_code)
self.assertRedirects(anon_edit_response, "http://testse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_edit_by(self, user2_compare):\n if user2_compare.is_superuser:\n return True\n\n if user2_compare == self.user:\n return True\n\n if (self.creator and self.creator == user2_compare) or \\\n (self.owner and self.owner == user2_compare):\n if... | [
"0.7439114",
"0.7438289",
"0.71257675",
"0.7101223",
"0.69775563",
"0.6966782",
"0.6948189",
"0.69078314",
"0.67476374",
"0.67433494",
"0.67346734",
"0.66897315",
"0.6654319",
"0.6628165",
"0.66166735",
"0.66134465",
"0.6602346",
"0.6597451",
"0.6586665",
"0.65701985",
"0.649... | 0.70152277 | 4 |
Get the news from the most recent 2 days | def predictionSentiment(company):
#change the key for the API in here. This is the AlchemyDataNews
KEY = '2190f450728492113ce4e5b880a72eefbea73308'
alchemy_data_news = AlchemyDataNewsV1(api_key=KEY)
timeBegin ='now-2d'
timeEnd = 'now'
company_query = '|text=' + company + ',type=company|'
res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_top_news_and_the_rest(self):\n queryset = self.news.order_by('-marked', '-publication_date')\n return queryset.first(), queryset[1:]",
"def _fetch_latest_for_tag(self, tag, today):\n result = []\n url = Fetch163.search_link % urllib2.quote(tag.name.encode('utf8'))\n try... | [
"0.69510067",
"0.6841948",
"0.6503372",
"0.64803505",
"0.62224877",
"0.61349916",
"0.6086453",
"0.60744727",
"0.5931258",
"0.59277415",
"0.5867593",
"0.5849643",
"0.583051",
"0.5791152",
"0.5756185",
"0.57509756",
"0.57450515",
"0.5736691",
"0.5669512",
"0.56580955",
"0.56272... | 0.0 | -1 |
Support two kind of enties MiCloud and Gateway. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
# entry for MiCloud login
if 'servers' in entry.data:
return await _setup_micloud_entry(hass, entry)
# migrate data (also after first setup) to options
if entry.data:
hass.config_entries.async_update_entry(entry, dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_hyperflex_server_model_by_moid(self):\n pass",
"def test_get_cloud(self):\n pass",
"def test_entities__entity_by_interface__2(stubEntities, entityAdapters):\n assert stubEntities.kwack == IEntity(IKwack)",
"def server_type(self):\n ...",
"def test_entities__entity_by_ob... | [
"0.48487583",
"0.4777232",
"0.47737986",
"0.47334749",
"0.46941045",
"0.46241567",
"0.45508718",
"0.45479214",
"0.45473605",
"0.44906086",
"0.44813046",
"0.44812977",
"0.44805592",
"0.44465515",
"0.44199583",
"0.4387522",
"0.4384807",
"0.4382557",
"0.43769178",
"0.43653962",
... | 0.0 | -1 |
Remove device from Hass and Mi Home if the device is renamed to `delete`. | async def _handle_device_remove(hass: HomeAssistant):
async def device_registry_updated(event: Event):
if event.data['action'] != 'update':
return
registry = hass.data['device_registry']
hass_device = registry.async_get(event.data['device_id'])
# check empty identifier... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_device(self, path):\n pass",
"def test_delete_device(self):\n pass",
"def test_delete_device(self):\n pass",
"def remove_device(hass: HomeAssistant, mac: str):\n registry = dr.async_get(hass)\n device = registry.async_get_device({(DOMAIN, mac)}, None)\n if device:\n ... | [
"0.7273544",
"0.71494186",
"0.71494186",
"0.71473706",
"0.7069529",
"0.7050124",
"0.694185",
"0.68908465",
"0.6889722",
"0.67441875",
"0.6650383",
"0.6551819",
"0.6442136",
"0.6419247",
"0.6365878",
"0.63445854",
"0.63432455",
"0.6313089",
"0.629934",
"0.62790984",
"0.6268683... | 0.7145953 | 4 |
Defines a function that embeds x to (x, sin(2^k x), cos(2^k x), ...) | def __init__(self,
max_logscale,
N_freqs,
logscale=True,
multi_pi=False,):
super().__init__()
self.N_freqs = N_freqs
self.funcs = [torch.sin, torch.cos]
if logscale:
self.freqs = 2 ** torch.linspace(0, max_logscale, N_freqs)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xsin(x):\n return x + tf.sin(x)",
"def f(x):\r\n return x * np.sin(x)",
"def f(x):\n return (2.0*math.sin(10.0*x+1.0)+1.0)",
"def f(x):\n return x * np.sin(x)",
"def f(x):\n return x * np.sin(x)",
"def f(x):\n return x * np.sin(x)",
"def f(x):\n return x * np.sin(x)",
"def si... | [
"0.7025602",
"0.68409157",
"0.68117076",
"0.68071175",
"0.68071175",
"0.68071175",
"0.68071175",
"0.6745642",
"0.66318744",
"0.65937865",
"0.65460086",
"0.65131843",
"0.65039134",
"0.6454636",
"0.64518243",
"0.643566",
"0.64254206",
"0.64077926",
"0.6390913",
"0.6357719",
"0.... | 0.0 | -1 |
Sample samples from with distribution defined by . | def sample_pdf(bins,
weights,
N_importance,
det=False,
eps=1e-5):
N_rays, N_samples_ = weights.shape
weights = weights + eps # prevent division by zero (don't do inplace op!)
pdf = weights / torch.sum(weights, -1, keepdim=True) # (N_rays, N_samples_)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_samples(bins, dist):\n N = dist.shape[0]\n samples = np.empty([N,1], dtype=np.float32)\n \n for i in range(N):\n smpl = np.random.choice(bins, p=dist[i,:]/np.sum(dist[i,:]))\n samples[i,0] = smpl.astype(np.float32)\n \n return samples",
"def generate_samples(self):\... | [
"0.7242518",
"0.7146093",
"0.7093125",
"0.7030691",
"0.7030691",
"0.70207727",
"0.6894814",
"0.6866932",
"0.68521553",
"0.6850891",
"0.68316853",
"0.6819255",
"0.67906827",
"0.67631334",
"0.67386174",
"0.6695345",
"0.669489",
"0.6660871",
"0.66569257",
"0.66350967",
"0.662805... | 0.67308974 | 15 |
Performs NeRF volumetric rendering. | def fancy_integration(rgb_sigma,
z_vals,
device,
dim_rgb=3,
noise_std=0.5,
last_back=False,
white_back=False,
clamp_mode=None,
fill_mode=None):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RenderTexture(self, vtkVolume, vtkRenderer, p_int=..., p_int=..., *args, **kwargs):\n ...",
"def render(self, scene):\n if self.degenerate:\n return\n # The number of subdivisions around the hoop's radial direction.\n if self.thickness:\n band_coverage = scen... | [
"0.6838916",
"0.6541767",
"0.6468038",
"0.59699476",
"0.58094686",
"0.5786827",
"0.57639813",
"0.57540566",
"0.57414097",
"0.57234275",
"0.5663613",
"0.5647489",
"0.5633562",
"0.56289995",
"0.56223303",
"0.5615157",
"0.5612053",
"0.56066537",
"0.5579746",
"0.5531261",
"0.5528... | 0.0 | -1 |
Perturb z_vals and then points | def perturb_points(points,
z_vals,
ray_directions,
device):
distance_between_points = z_vals[:, :, 1:2, :] - z_vals[:, :, 0:1, :] # (n, num_rays, 1, 1)
offset = (torch.rand(z_vals.shape, device=device) - 0.5) \
* distance_between_points # [-0.5, 0.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zscore(vals):",
"def pz_fn(self, z):\n pass",
"def test_rr_pz(results):\n truepz = np.asarray([4.43677606e-09, 7.89531535e-01, 7.89747372e-01,\n 8.04473756e-08, 2.22044605e-15])\n test_pz = results.params_pvalue()\n assert test_pz == pytest.approx(truepz)",
"def _d... | [
"0.61707187",
"0.5969978",
"0.5948121",
"0.5771447",
"0.5753422",
"0.5751763",
"0.5720874",
"0.570925",
"0.56714046",
"0.5606835",
"0.5599319",
"0.55912805",
"0.5566265",
"0.5564544",
"0.55581784",
"0.5551306",
"0.5541329",
"0.5482284",
"0.5461766",
"0.54337835",
"0.5431512",... | 0.56568754 | 9 |
Samples bs random locations along a sphere of radius r. Uses the specified distribution. | def sample_camera_positions(device,
bs=1,
r=1,
horizontal_stddev=1,
vertical_stddev=1,
horizontal_mean=math.pi * 0.5,
vertical_mean=math.pi * 0.5,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def randomPointOnSphere(r):\n x = np.random.normal()\n y = np.random.normal()\n z = np.random.normal()\n point = np.array([x, y, z])\n point *= r/(x**2 + y**2 + z**2)**.5\n return point",
"def sample_hypersphere(n_samples, sample_shape, radius, l_norm=2, mode='sphere', sample_gen=None, seed=Non... | [
"0.7045139",
"0.6714708",
"0.6683562",
"0.6669991",
"0.65136045",
"0.6468937",
"0.6257552",
"0.6257188",
"0.62165225",
"0.6169153",
"0.6119341",
"0.6071606",
"0.6061659",
"0.60455453",
"0.6028003",
"0.60168177",
"0.60071576",
"0.59225005",
"0.5913367",
"0.59113646",
"0.586713... | 0.0 | -1 |
Takes in the direction the camera is pointing and the camera origin and returns a cam2world matrix. | def create_cam2world_matrix(forward_vector,
origin,
device=None):
""""""
forward_vector = normalize_vecs(forward_vector)
up_vector = torch.tensor([0, 1, 0], dtype=torch.float, device=device) \
.expand_as(forward_vector)
left_vector = normalize_vecs(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_to_matrix(x, y):\n x_pos = round(x * ((MATRIX_SIZE_X - 1)/(FRAME_W - 1)))\n y_pos = round(y * ((MATRIX_SIZE_Y - 1)/(FRAME_H - 1)))\n\n x_pos = (MATRIX_SIZE_X - 1) - x_pos #invert x direction (left and right) to account for camera perspective\n\n return x_pos, y_pos",
"def cam_to_world(cam_poi... | [
"0.6586465",
"0.6576377",
"0.6565738",
"0.6500614",
"0.64989525",
"0.6413747",
"0.61989534",
"0.6179077",
"0.6152811",
"0.6126261",
"0.59229445",
"0.5909412",
"0.59015703",
"0.5897311",
"0.57085705",
"0.568021",
"0.5642607",
"0.5634",
"0.56108457",
"0.558792",
"0.5587084",
... | 0.78033996 | 0 |
Perturb z_vals and points; Samples a camera position and maps points in camera space to world space. | def transform_sampled_points(points,
z_vals,
ray_directions,
device,
h_stddev=1,
v_stddev=1,
h_mean=math.pi * 0.5,
v_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perturb_points(points,\n z_vals,\n ray_directions,\n device):\n distance_between_points = z_vals[:, :, 1:2, :] - z_vals[:, :, 0:1, :] # (n, num_rays, 1, 1)\n offset = (torch.rand(z_vals.shape, device=device) - 0.5) \\\n * distance_between_points... | [
"0.6049411",
"0.60473865",
"0.6045746",
"0.58854824",
"0.5848199",
"0.58449686",
"0.58036494",
"0.5799261",
"0.5791324",
"0.5775069",
"0.5753067",
"0.5746451",
"0.5705016",
"0.56961274",
"0.56343555",
"0.56067497",
"0.5599403",
"0.5573139",
"0.5569328",
"0.55522996",
"0.55279... | 0.65007573 | 0 |
Returns sample points, z_vals, and ray directions in camera space. | def get_initial_rays_trig(bs,
num_steps,
fov,
resolution,
ray_start,
ray_end,
device, ):
W, H = resolution
# Create full screen NDC (-1 to +1) coords [x, y, 0,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_real_samples(self):\n # Define the camera poses\n if not self.opt.same_view:\n if self.opt.full_sphere_sampling:\n self.cam_pos = uniform_sample_sphere(\n radius=self.opt.cam_dist, num_samples=self.opt.batchSize,\n axis=None, ang... | [
"0.640642",
"0.600557",
"0.59173113",
"0.5725458",
"0.5716723",
"0.5709173",
"0.57036126",
"0.5633035",
"0.561526",
"0.5612545",
"0.5612545",
"0.542751",
"0.53976744",
"0.53932536",
"0.535119",
"0.53496736",
"0.5346758",
"0.53297174",
"0.52854574",
"0.5274969",
"0.5254882",
... | 0.55181867 | 11 |
Converts an Rmd document as a string into a list of ``Cell`` objects for easier handling with code designed originally for Jupyter notebooks. | def rmd_to_cells(rmd_string):
cells, cell_lines, cell_type, in_block, in_begin = [], [], "markdown", False, False
for line in rmd_string.split("\n"):
if in_block and (line.strip() == "```" or re.match(END_REGEX, line)):
in_block = False
# collect cell_lines into a new cell
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markdown_cells(notebook):\n cells = all_cells(notebook)\n return [cell[\"source\"] for cell in cells if cell[\"cell_type\"] == \"markdown\"]",
"def convert(cell):\r\n\r\n markdownResult=\"\"\r\n if cell['cell_type'] == 'code':\r\n markdownResult += '```\\n'\r\n\r\n for line in cell['sou... | [
"0.659269",
"0.57998616",
"0.54991925",
"0.5440537",
"0.54145265",
"0.5360483",
"0.5280241",
"0.5191896",
"0.51772344",
"0.51759666",
"0.51577157",
"0.51485837",
"0.5141294",
"0.51053214",
"0.50847465",
"0.50440603",
"0.5038209",
"0.49959463",
"0.4994819",
"0.49679536",
"0.49... | 0.74898815 | 0 |
Collapses all runs of cells with empty sources into a single cell with an empty source | def collapse_empty_cells(cells):
in_run, run_start = False, 0
replacements = []
for i, cell in enumerate(cells):
if in_run and cell["source"].strip():
if (run_start > 0 and cells[run_start-1]["source"].endswith("\n")) or cell["source"].startswith("\n"):
replacement = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collapse(self):\n # TODO: not implemented\n pass",
"def collapsed(self) -> None:",
"def collapseUp(self):\n retval = False\n for cStartInd in range(self.col):\n lst = [self.get_cell(i) for i in range(cStartInd, self.length, self.col)]\n lst, tmp = self.collapseRow(... | [
"0.5843393",
"0.5662654",
"0.5656175",
"0.5561178",
"0.5532706",
"0.55238676",
"0.5440617",
"0.5401576",
"0.53815573",
"0.5375235",
"0.5353397",
"0.5295118",
"0.5245139",
"0.5245116",
"0.5235098",
"0.5224786",
"0.51737785",
"0.517261",
"0.51705515",
"0.5094087",
"0.50495225",... | 0.7354216 | 0 |
Make dir if it not exist | def ensure_dir(directory):
if directory is not None:
if not os.path.exists(directory):
os.makedirs(directory) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_dir_if_needed(dir) :\n\tif not exists(dir) :\n\t\tos.makedirs(dir)",
"def make_dir_if_needed(path):\n\n if not os.path.exists(path):\n os.makedirs(path)\n return path",
"def maybe_make_dir(path):\n if not os.path.exists(path):\n os.makedirs(path)",
"def dirChecking(dir):\n ... | [
"0.83525157",
"0.7894296",
"0.7739406",
"0.7735228",
"0.76740175",
"0.7567629",
"0.7558264",
"0.75076646",
"0.7502438",
"0.7420244",
"0.7420244",
"0.7413042",
"0.7400551",
"0.7387143",
"0.73770565",
"0.7352647",
"0.7344708",
"0.7333861",
"0.73256356",
"0.7296938",
"0.7295181"... | 0.0 | -1 |
Storage service is unavailable. | def test_store_is_unavailable(self, mock_current_session):
mock_store = mock.MagicMock()
mock_store.is_available.return_value = False
mock_current_session.return_value = mock_store
with self.assertRaises(ServiceUnavailable):
controllers.service_status() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_service_unavailable():\n if WithingsDataManager.service_available is not False:\n _LOGGER.error(\"Looks like the service is not available at the moment\")\n WithingsDataManager.service_available = False\n return True",
"def _async_device_unavailable(\n _se... | [
"0.668266",
"0.61864495",
"0.60823864",
"0.6079669",
"0.6038685",
"0.59237933",
"0.59164035",
"0.5869149",
"0.5832894",
"0.572674",
"0.5605072",
"0.5605072",
"0.5580025",
"0.55637956",
"0.5485156",
"0.5483856",
"0.5440075",
"0.5376526",
"0.5344619",
"0.5323179",
"0.5311567",
... | 0.64220196 | 1 |
Storage service is available. | def test_store_is_available(self, mock_current_session):
mock_store = mock.MagicMock()
mock_store.is_available.return_value = True
mock_current_session.return_value = mock_store
_, code, _ = controllers.service_status()
self.assertEqual(code, status.OK) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def storage_available(self):\n logger.debug('Function storage_available start')\n \n # 2.9 GB\n max_size = 2.9*10**9\n \n if self.total_image_data_size >= max_size:\n logger.info(\"Storage not available\")\n return False\n else:\n lo... | [
"0.7299551",
"0.7047413",
"0.6764259",
"0.6512866",
"0.6387074",
"0.6320405",
"0.62880373",
"0.6273855",
"0.6273855",
"0.6273855",
"0.626729",
"0.6261934",
"0.6261934",
"0.6153272",
"0.6149133",
"0.6149133",
"0.6111657",
"0.61076444",
"0.60751134",
"0.60751134",
"0.60751134",... | 0.65668076 | 3 |
All requests are in the context of a source + checksum. | def setUp(self):
self.source_id = '12345'
self.checksum = 'asdfqwert1=='
self.stream = io.BytesIO(b'fakecontent') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getFile_requests(self, _src, _dst):\n\n #-------------------- \n # Get the content size from scan json\n #-------------------- \n self.downloadTracker['downloadedSize']['bytes'] = 0 \n self.downloadTracker['totalDownloadSize'] = self.getFileSize(_src)\... | [
"0.5741865",
"0.56754804",
"0.5671285",
"0.5593456",
"0.5500024",
"0.53267413",
"0.51559365",
"0.51559365",
"0.4986746",
"0.4984093",
"0.49587265",
"0.49504185",
"0.49468344",
"0.49462953",
"0.49332276",
"0.49249297",
"0.48337004",
"0.48267663",
"0.48258984",
"0.48092392",
"0... | 0.4804576 | 20 |
An error occurs when storing the preview. | def test_deposit_fails(self, mock_current_session):
mock_store = mock.MagicMock()
mock_store.deposit.side_effect = store.DepositFailed
mock_current_session.return_value = mock_store
with self.assertRaises(InternalServerError):
controllers.deposit_preview(self.source_id, self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self):\r\n if self._storage:\r\n self._storage.store(self, *self._storage_args)\r\n else:\r\n raise StorageNotSetError()",
"def save(self, *args, **kwargs):\n super(Preview, self).save(*args, **kwargs)\n self.use_effect()",
"def save_fail_img(self):\n ... | [
"0.5526675",
"0.54620713",
"0.51442325",
"0.5133656",
"0.5126114",
"0.51065654",
"0.5087885",
"0.5013163",
"0.50059056",
"0.49991783",
"0.49591127",
"0.49037382",
"0.4895158",
"0.48786893",
"0.4858735",
"0.48422378",
"0.4839045",
"0.48291415",
"0.4827193",
"0.48241448",
"0.48... | 0.0 | -1 |
The preview already exists. | def test_already_exists(self, mock_current_session):
mock_store = mock.MagicMock()
mock_store.deposit.side_effect = store.PreviewAlreadyExists
mock_current_session.return_value = mock_store
with self.assertRaises(Conflict): # 409 Conflict
controllers.deposit_preview(self.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upd_preview(self):\n\n if self.data_type != \"layer\":\n self.dlg.uLabelImgPreview.clear()\n self.dlg.uLabelImgPreview.setText(\"No preview available\")\n return\n\n if self.get_preview(\"300x200\", 0.5):\n return\n if self.get_preview(\"150x100\... | [
"0.6237067",
"0.5998938",
"0.59585685",
"0.5936331",
"0.58514047",
"0.5833355",
"0.58192414",
"0.58160555",
"0.57726073",
"0.5763644",
"0.5718817",
"0.57129294",
"0.5625983",
"0.560919",
"0.55987835",
"0.5598265",
"0.5556675",
"0.54856384",
"0.5413032",
"0.53611124",
"0.53594... | 0.6862947 | 0 |
The store service returns malformed data. | def test_deposit_return_malformed(self, mock_current_session):
mock_store = mock.MagicMock()
# Doesn't add metadata.
mock_store.deposit.side_effect = lambda obj, **kw: obj
mock_current_session.return_value = mock_store
with self.assertRaises(InternalServerError):
con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_store_error(self, response):\n default_msg = \"Failure working with the Store: [{}] {!r}\".format(\n response.status_code, response.content\n )\n try:\n error_data = response.json()\n except ValueError:\n return default_msg\n\n try:\n ... | [
"0.5764938",
"0.55986315",
"0.5596168",
"0.5541464",
"0.5519843",
"0.5405051",
"0.5389781",
"0.5347264",
"0.53199744",
"0.5239421",
"0.5220404",
"0.5220244",
"0.52064836",
"0.519568",
"0.51739466",
"0.5168379",
"0.51491594",
"0.5144948",
"0.5109275",
"0.5109275",
"0.5102696",... | 0.48676693 | 69 |
The preview is deposited successfully. | def test_deposit_successful(self, mock_current_session):
mock_store = mock.MagicMock()
added = datetime.now(UTC)
def mock_deposit(obj, overwrite, **kwargs):
"""Deposit implementation sets metadata on Preview."""
return Preview(source_id=obj.source_id,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_deposit(obj, overwrite, **kwargs):\n return Preview(source_id=obj.source_id,\n checksum=obj.checksum,\n metadata=Metadata(added=added,\n checksum='foopdfchex==',\n ... | [
"0.6338141",
"0.5979675",
"0.59421855",
"0.57830966",
"0.57375795",
"0.56633556",
"0.5594401",
"0.5583082",
"0.55299044",
"0.54851264",
"0.54364324",
"0.5425671",
"0.5414658",
"0.5412717",
"0.5406029",
"0.53997284",
"0.5370651",
"0.5346766",
"0.53250915",
"0.5285307",
"0.5258... | 0.68985367 | 0 |
Deposit implementation sets metadata on Preview. | def mock_deposit(obj, overwrite, **kwargs):
return Preview(source_id=obj.source_id,
checksum=obj.checksum,
metadata=Metadata(added=added,
checksum='foopdfchex==',
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_deposit_successful(self, mock_current_session):\n mock_store = mock.MagicMock()\n added = datetime.now(UTC)\n\n def mock_deposit(obj, overwrite, **kwargs):\n \"\"\"Deposit implementation sets metadata on Preview.\"\"\"\n return Preview(source_id=obj.source_id,\n ... | [
"0.63907486",
"0.5510283",
"0.54667133",
"0.53128654",
"0.5308596",
"0.51845413",
"0.5147838",
"0.5139438",
"0.51325536",
"0.51286876",
"0.51013607",
"0.5079927",
"0.5060331",
"0.5060331",
"0.5060331",
"0.5060331",
"0.5060331",
"0.5060331",
"0.5060331",
"0.50552124",
"0.48929... | 0.7150155 | 0 |
All requests are in the context of a source + checksum. | def setUp(self):
self.source_id = '12345'
self.checksum = 'asdfqwert1=='
self.stream = io.BytesIO(b'fakecontent') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getFile_requests(self, _src, _dst):\n\n #-------------------- \n # Get the content size from scan json\n #-------------------- \n self.downloadTracker['downloadedSize']['bytes'] = 0 \n self.downloadTracker['totalDownloadSize'] = self.getFileSize(_src)\... | [
"0.5741865",
"0.56754804",
"0.5671285",
"0.5593456",
"0.5500024",
"0.53267413",
"0.51559365",
"0.51559365",
"0.4986746",
"0.4984093",
"0.49587265",
"0.49504185",
"0.49468344",
"0.49462953",
"0.49332276",
"0.49249297",
"0.48337004",
"0.48267663",
"0.48258984",
"0.48092392",
"0... | 0.4804576 | 21 |
The requested preview does not exist. | def test_does_not_exist(self, mock_current_session):
mock_store = mock.MagicMock()
mock_store.get_metadata.side_effect = store.DoesNotExist
mock_current_session.return_value = mock_store
with self.assertRaises(NotFound):
controllers.get_preview_metadata(self.source_id, self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview():\n return render_template(\"controls/preview.html\")",
"def preview(self) -> Optional[bool]:\n return pulumi.get(self, \"preview\")",
"def is_preview(self) -> Optional[bool]:\n return pulumi.get(self, \"is_preview\")",
"def preview(self):\n if self._preview is None:\n ... | [
"0.6932928",
"0.69147325",
"0.6717905",
"0.66248643",
"0.6608829",
"0.6445171",
"0.63463944",
"0.62198687",
"0.62103397",
"0.61491686",
"0.6142581",
"0.6139042",
"0.6125083",
"0.6059475",
"0.603868",
"0.59660536",
"0.59536135",
"0.586978",
"0.58629507",
"0.5857521",
"0.585588... | 0.54417545 | 45 |
The requested preview does exist. | def test_exists(self, mock_current_session):
added = datetime.now(UTC)
mock_store = mock.MagicMock()
mock_store.get_metadata.return_value = \
Metadata(added=added, checksum='foopdfchex==', size_bytes=1_234)
mock_current_session.return_value = mock_store
data, code, h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview(self) -> Optional[bool]:\n return pulumi.get(self, \"preview\")",
"def is_preview(self) -> Optional[bool]:\n return pulumi.get(self, \"is_preview\")",
"def check_preview_exists(source_id: str, checksum: str) -> Response:\n data, code, headers = controllers.check_preview_exists(sour... | [
"0.70255387",
"0.68321574",
"0.65946746",
"0.6521715",
"0.6419572",
"0.63909525",
"0.63894945",
"0.63726383",
"0.6349645",
"0.6239161",
"0.623568",
"0.6186789",
"0.6059854",
"0.6032061",
"0.59937024",
"0.5962594",
"0.59311116",
"0.5928331",
"0.5839377",
"0.5800868",
"0.575025... | 0.58587426 | 18 |
All requests are in the context of a source + checksum. | def setUp(self):
self.source_id = '12345'
self.checksum = 'asdfqwert1=='
self.stream = io.BytesIO(b'fakecontent') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getFile_requests(self, _src, _dst):\n\n #-------------------- \n # Get the content size from scan json\n #-------------------- \n self.downloadTracker['downloadedSize']['bytes'] = 0 \n self.downloadTracker['totalDownloadSize'] = self.getFileSize(_src)\... | [
"0.5741865",
"0.56754804",
"0.5671285",
"0.5593456",
"0.5500024",
"0.53267413",
"0.51559365",
"0.51559365",
"0.4986746",
"0.4984093",
"0.49587265",
"0.49504185",
"0.49468344",
"0.49462953",
"0.49332276",
"0.49249297",
"0.48337004",
"0.48267663",
"0.48258984",
"0.48092392",
"0... | 0.4804576 | 22 |
The requested preview does not exist. | def test_does_not_exist(self, mock_current_session):
mock_store = mock.MagicMock()
mock_store.get_preview_checksum.side_effect = store.DoesNotExist
mock_current_session.return_value = mock_store
with self.assertRaises(NotFound):
controllers.check_preview_exists(self.source_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview():\n return render_template(\"controls/preview.html\")",
"def preview(self) -> Optional[bool]:\n return pulumi.get(self, \"preview\")",
"def is_preview(self) -> Optional[bool]:\n return pulumi.get(self, \"is_preview\")",
"def preview(self):\n if self._preview is None:\n ... | [
"0.6932928",
"0.69147325",
"0.6717905",
"0.66248643",
"0.6608829",
"0.6445171",
"0.63463944",
"0.62198687",
"0.62103397",
"0.61491686",
"0.6142581",
"0.6139042",
"0.6125083",
"0.6059475",
"0.603868",
"0.59660536",
"0.59536135",
"0.586978",
"0.58629507",
"0.5857521",
"0.585588... | 0.5380449 | 52 |
The requested preview does exist. | def test_exists(self, mock_current_session):
added = datetime.now(UTC)
mock_store = mock.MagicMock()
mock_store.get_preview_checksum.return_value = 'foopdfchex=='
mock_current_session.return_value = mock_store
data, code, headers = \
controllers.check_preview_exists(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview(self) -> Optional[bool]:\n return pulumi.get(self, \"preview\")",
"def is_preview(self) -> Optional[bool]:\n return pulumi.get(self, \"is_preview\")",
"def check_preview_exists(source_id: str, checksum: str) -> Response:\n data, code, headers = controllers.check_preview_exists(sour... | [
"0.70255387",
"0.68321574",
"0.65946746",
"0.6521715",
"0.6419572",
"0.63909525",
"0.63894945",
"0.63726383",
"0.6349645",
"0.6239161",
"0.623568",
"0.6186789",
"0.6059854",
"0.59937024",
"0.5962594",
"0.59311116",
"0.5928331",
"0.58587426",
"0.5839377",
"0.5800868",
"0.57502... | 0.6032061 | 13 |
All requests are in the context of a source + checksum. | def setUp(self):
self.source_id = '12345'
self.checksum = 'asdfqwert1=='
self.stream = io.BytesIO(b'fakecontent') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getFile_requests(self, _src, _dst):\n\n #-------------------- \n # Get the content size from scan json\n #-------------------- \n self.downloadTracker['downloadedSize']['bytes'] = 0 \n self.downloadTracker['totalDownloadSize'] = self.getFileSize(_src)\... | [
"0.5741865",
"0.56754804",
"0.5671285",
"0.5593456",
"0.5500024",
"0.53267413",
"0.51559365",
"0.51559365",
"0.4986746",
"0.4984093",
"0.49587265",
"0.49504185",
"0.49468344",
"0.49462953",
"0.49332276",
"0.49249297",
"0.48337004",
"0.48267663",
"0.48258984",
"0.48092392",
"0... | 0.4804576 | 23 |
The requested preview does not exist. | def test_does_not_exist(self, mock_current_session):
mock_store = mock.MagicMock()
mock_store.get_preview.side_effect = store.DoesNotExist
mock_current_session.return_value = mock_store
with self.assertRaises(NotFound):
controllers.get_preview_content(self.source_id, self.ch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview():\n return render_template(\"controls/preview.html\")",
"def preview(self) -> Optional[bool]:\n return pulumi.get(self, \"preview\")",
"def is_preview(self) -> Optional[bool]:\n return pulumi.get(self, \"is_preview\")",
"def preview(self):\n if self._preview is None:\n ... | [
"0.6932928",
"0.69147325",
"0.6717905",
"0.66248643",
"0.6608829",
"0.6445171",
"0.63463944",
"0.62198687",
"0.62103397",
"0.61491686",
"0.6142581",
"0.6139042",
"0.6125083",
"0.6059475",
"0.603868",
"0.59660536",
"0.59536135",
"0.586978",
"0.5857521",
"0.58558834",
"0.584628... | 0.58629507 | 18 |
The requested preview does exist. | def test_exists(self, mock_current_session):
added = datetime.now(UTC)
mock_store = mock.MagicMock()
mock_store.get_preview.return_value = Preview(
source_id=self.source_id,
checksum=self.checksum,
metadata=Metadata(added=added, checksum='foopdfchex==',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview(self) -> Optional[bool]:\n return pulumi.get(self, \"preview\")",
"def is_preview(self) -> Optional[bool]:\n return pulumi.get(self, \"is_preview\")",
"def check_preview_exists(source_id: str, checksum: str) -> Response:\n data, code, headers = controllers.check_preview_exists(sour... | [
"0.70255387",
"0.68321574",
"0.65946746",
"0.6521715",
"0.6419572",
"0.63909525",
"0.63894945",
"0.6349645",
"0.6239161",
"0.623568",
"0.6186789",
"0.6059854",
"0.6032061",
"0.59937024",
"0.5962594",
"0.59311116",
"0.5928331",
"0.58587426",
"0.5839377",
"0.5800868",
"0.575025... | 0.63726383 | 7 |
Request includes ifnonematch param with matching etag. | def test_if_none_match_matches(self, mock_current_session):
added = datetime.now(UTC)
mock_store = mock.MagicMock()
mock_store.get_preview_checksum.return_value = 'foopdfchex=='
mock_current_session.return_value = mock_store
data, code, headers = \
controllers.get_pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def etag(etag):\n if_none_match = parse_multi_value_header(request.headers.get(\"If-None-Match\"))\n if_match = parse_multi_value_header(request.headers.get(\"If-Match\"))\n\n if if_none_match:\n if etag in if_none_match or \"*\" in if_none_match:\n response = status_code(304)\n ... | [
"0.73439604",
"0.6542843",
"0.6495738",
"0.6244675",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
"0.6226908",
... | 0.0 | -1 |
Request includes ifnonematch param with nonmatching etag. | def test_if_none_match_does_not_match(self, mock_current_session):
added = datetime.now(UTC)
mock_store = mock.MagicMock()
mock_store.get_preview_checksum.return_value = 'foopdfchex=='
mock_store.get_preview.return_value = Preview(
source_id=self.source_id,
checks... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def etag(etag):\n if_none_match = parse_multi_value_header(request.headers.get(\"If-None-Match\"))\n if_match = parse_multi_value_header(request.headers.get(\"If-Match\"))\n\n if if_none_match:\n if etag in if_none_match or \"*\" in if_none_match:\n response = status_code(304)\n ... | [
"0.71609896",
"0.7148011",
"0.6632554",
"0.6209622",
"0.61147344",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"0.589288",
"... | 0.0 | -1 |
Initialize parameters using 6/sqrt(fanin+fanout) | def initParams(self):
sizes = [self.inputDim]+self.layerSizes+[self.outputDim]
scales = [np.sqrt(6)/np.sqrt(n+m) for n,m in zip(sizes[:-1],sizes[1:])]
self.stack = [[np.random.rand(m,n)*2*s-s,np.zeros((m,1))] \
for n,m,s in zip(sizes[:-1],sizes[1:],scales)]
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xavier_init(fan_in, fan_out, constant=1):\n low = -constant*np.sqrt(6/(fan_in + fan_out))\n high = constant*np.sqrt(6.0/(fan_in + fan_out))\n return tf.random_uniform((fan_in, fan_out), minval=low, maxval=high, dtype=tf.float32)",
"def xavier_init(fan_in, fan_out, constant=1):\n low = -constant*n... | [
"0.69680864",
"0.69680864",
"0.6911937",
"0.6851623",
"0.6725929",
"0.6668688",
"0.64314777",
"0.63509566",
"0.62880355",
"0.62276816",
"0.62222147",
"0.6196339",
"0.6129628",
"0.60937446",
"0.599177",
"0.5940592",
"0.5920254",
"0.5912472",
"0.5905206",
"0.5896622",
"0.582124... | 0.0 | -1 |
Sets view of gpu memory to be correct size for utterance. | def setViews(self,batchSize):
assert batchSize <= self.maxBatch, "Batch size exceeds max batch"
self.hActs = [H.get_col_slice(0,batchSize) for H in self.hActs_M]
self.hActsFor = self.hActsFor_M.get_col_slice(0,batchSize)
self.hActsBack = self.hActsBack_M.get_col_slice(0,batchSize)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_used_mem(self, u_mem):\n self.used_mem = u_mem\n return",
"def set_memory_mode(self):\n self.debug_print('set memory mode')\n self.send_com(0x08)",
"def deviceMemory(self):\n return 1",
"def Limit_GPU_Memory(self,percent):\n import tensorflow as tf\n f... | [
"0.64669544",
"0.64529026",
"0.6365059",
"0.6254416",
"0.6236937",
"0.62085134",
"0.61972654",
"0.61693656",
"0.6155046",
"0.61519665",
"0.61170065",
"0.61028135",
"0.6089239",
"0.60674715",
"0.6051803",
"0.60345435",
"0.5992248",
"0.5866435",
"0.5826131",
"0.5797469",
"0.577... | 0.0 | -1 |
Saves only the network parameters to the given fd. | def toFile(self,fid):
stack = []
for w,b in self.stack:
w.copy_to_host()
b.copy_to_host()
stack.append([w.numpy_array,b.numpy_array])
pickle.dump(stack,fid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self):\n self.save_network_architecture( network_path=self.network_path )\n self.save_network_parameters(\n file_name='net_parameters', file_path=self.network_path )",
"def flowdetail_save(fd):\n return IMPL.flowdetail_save(fd)",
"def save_network(network, fpath):\n\twith o... | [
"0.64642584",
"0.6331068",
"0.6227034",
"0.6127043",
"0.59193313",
"0.59085625",
"0.5902859",
"0.58604264",
"0.58418906",
"0.5839694",
"0.5766401",
"0.5760571",
"0.5748318",
"0.5719922",
"0.56778675",
"0.5676676",
"0.56725526",
"0.5656104",
"0.5649511",
"0.56446576",
"0.56169... | 0.0 | -1 |
Constructor of each node | def __init__(self, data, prev, nxt):
self.data = data
self.prev = prev
self.nxt = nxt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, nodes=None):\r\n self.nodes = nodes",
"def __init__(self, nodes):\n\n self._nodes = nodes",
"def __init__(self):\n\n self.nodes = {}",
"def __init__(self, content=None):\n for elem in content:\n self.append(self.convertNode(elem))",
"def __init__(se... | [
"0.79859227",
"0.7693718",
"0.7513955",
"0.7472571",
"0.73876494",
"0.7340143",
"0.72956204",
"0.7262092",
"0.7262092",
"0.72567016",
"0.72478724",
"0.7234917",
"0.7230481",
"0.7215225",
"0.72074395",
"0.7188803",
"0.71782845",
"0.71782845",
"0.71782845",
"0.71782845",
"0.717... | 0.0 | -1 |
Convert Node to string | def __repr__(self):
return str(self.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodeToString(cls, node):\n return lxml.etree.tostring(node, method='html').decode()",
"def as_str(node):\n node_string = ' '.join(k for k, _ in node.leaves())\n return u' '.join(node_string.split())",
"def convertXMLNodeToString(*args):\n return _libsbml.XMLNode_convertXMLNodeTo... | [
"0.8408117",
"0.8214098",
"0.7415175",
"0.7378646",
"0.7310514",
"0.7247914",
"0.69681686",
"0.69587487",
"0.6936375",
"0.6902002",
"0.6853445",
"0.6851775",
"0.67991513",
"0.67764467",
"0.6768847",
"0.6712302",
"0.6707059",
"0.6660956",
"0.66056967",
"0.65918684",
"0.6575423... | 0.0 | -1 |
Empty the linked list O(n) | def clear(self):
trav = self.head
while trav is not None:
nxt = trav.nxt
trav.prev = trav.nxt
trav.data = None
trav = nxt
self.head = None
self.tail = None
trav = None
self.size = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear(self):\n self.head = None",
"def clear(self):\n SortedList.clear(self)\n self.head = None",
"def clear(self):\n self._head = None\n self._tail = None\n self._size = 0",
"def delete_node_at_start(self):\n if not self.head:\n print('List alr... | [
"0.7618228",
"0.758952",
"0.7434152",
"0.716568",
"0.71470666",
"0.71089613",
"0.70733416",
"0.7044231",
"0.69825834",
"0.68761986",
"0.6806461",
"0.67757773",
"0.6737707",
"0.66606444",
"0.65375364",
"0.6524759",
"0.65140676",
"0.64742666",
"0.6388031",
"0.63806",
"0.6374855... | 0.7664343 | 0 |
Return number of elements sorted in array | def __len__(self):
return self.llSize | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rank(array: Union[np.ndarray, List]) -> int:\n return len(array) - np.argsort(array).argsort()",
"def countingSort(arr):\n freq = [0] * 100\n for el in arr:\n freq[el] += 1\n return freq",
"def maxChunksToSorted(self, arr: List[int]) -> int:\n count = 0\n sorted_array =... | [
"0.7465923",
"0.7299019",
"0.7227783",
"0.71708244",
"0.7122489",
"0.7085062",
"0.70188546",
"0.6987113",
"0.6859038",
"0.6815892",
"0.67860085",
"0.676799",
"0.67341924",
"0.6719253",
"0.67115945",
"0.66975874",
"0.6668733",
"0.65580624",
"0.6519034",
"0.650895",
"0.65035194... | 0.0 | -1 |
Return the size of linked list | def size(self):
return self.size | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self):\n size = 0\n node = self.head\n while node:\n size += 1\n node = node.next\n return size",
"def size(self):\n size = 0 \n node = self.head \n while node is not None:\n size += 1 \n node = node.next_node \... | [
"0.87322253",
"0.8641411",
"0.8641411",
"0.8631897",
"0.860557",
"0.8601854",
"0.85598856",
"0.8538769",
"0.85350037",
"0.84760994",
"0.846983",
"0.8424573",
"0.84155864",
"0.83893484",
"0.8341703",
"0.83122355",
"0.82868487",
"0.8282582",
"0.82504666",
"0.8242577",
"0.822259... | 0.0 | -1 |
Check if the list is empty | def is_empty(self):
return self.size == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return self.list.length == 0",
"def is_empty(self):\n return self.list.length == 0",
"def is_list_empty(list):\n if not list:\n return True\n else:\n return False",
"def is_empty(self):\n if len(self.list) == 0:\n return True\n ... | [
"0.87505645",
"0.87505645",
"0.87083834",
"0.8594917",
"0.85775536",
"0.85438627",
"0.8399935",
"0.8349426",
"0.83099616",
"0.81763446",
"0.8101779",
"0.80872667",
"0.8030569",
"0.8026555",
"0.8018689",
"0.80130774",
"0.8009051",
"0.8009051",
"0.7948802",
"0.7944556",
"0.7913... | 0.7565048 | 71 |
Add an element to the linked list using add_last | def add(self, elem):
self.add_last(elem) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_last(self, elem):\n if self.is_empty():\n self.head = self.tail = self.Node(elem, None, None)\n else:\n self.tail.nxt = self.Node(elem, self.tail, None)\n self.tail = self.tail.nxt\n\n self.size += 1",
"def addLast(self, element):\n if element ... | [
"0.82564276",
"0.8080936",
"0.7951037",
"0.794131",
"0.7875399",
"0.7835852",
"0.77919906",
"0.76805675",
"0.7517425",
"0.7477709",
"0.68978375",
"0.6834634",
"0.6787018",
"0.67224365",
"0.67016476",
"0.66619736",
"0.65850174",
"0.65378225",
"0.6514077",
"0.65035224",
"0.6492... | 0.7951242 | 2 |
Add element to the front of the linked list | def add_first(self, elem):
if self.is_empty():
self.head = self.tail = self.Node(elem, None, None)
else:
self.head.prev = self.Node(elem, None, self.head)
self.head = self.head.prev
self.size += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_front(self, item):\n new_node = Node(item)\n # if the list is empty, make it head\n if self.head is None:\n self.head = new_node\n # else, \n else:\n new_node.next = self.head # new node points to current head\n self.head = new_node # c... | [
"0.80121136",
"0.79267305",
"0.7808346",
"0.7732094",
"0.76805055",
"0.76805055",
"0.7647048",
"0.7646265",
"0.75800365",
"0.7575906",
"0.7505272",
"0.74870515",
"0.7333277",
"0.73185617",
"0.7314353",
"0.73134905",
"0.7302316",
"0.7267416",
"0.724614",
"0.7222592",
"0.717940... | 0.71153533 | 25 |
Add to the end of the Linked list by append to tail.next O(n) | def add_last(self, elem):
if self.is_empty():
self.head = self.tail = self.Node(elem, None, None)
else:
self.tail.nxt = self.Node(elem, self.tail, None)
self.tail = self.tail.nxt
self.size += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addAtTail(self, val):\n node = ListNode(val)\n if self.head == None:\n self.head = node\n else:\n cur = self.head\n while cur.next != None:\n cur = cur.next\n cur.next = node",
"def addAtTail(self, val):\n curr = self.head... | [
"0.80428195",
"0.80340844",
"0.7985346",
"0.7985346",
"0.79472816",
"0.7919729",
"0.7888224",
"0.78487927",
"0.784192",
"0.7733067",
"0.76617414",
"0.7581593",
"0.7545408",
"0.75196856",
"0.74800986",
"0.74454",
"0.7366315",
"0.7358709",
"0.7313949",
"0.730378",
"0.72863746",... | 0.6921185 | 36 |
Obtain data from head of linked list O(1) | def peek_first(self):
if self.is_empty(): raise RuntimeError("Empty list")
return self.head.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first(self):\r\n if self.head == None: #check if first(head) node is empty\r\n return 'null' #if yes, then return null\r\n else: #if it is not empty\r\n return self.head.data #return the data of head node\r",
"def get(self, index):\r\n if index >= self.length():\r\n... | [
"0.7262619",
"0.7033946",
"0.69992024",
"0.69802266",
"0.688625",
"0.6812085",
"0.6749111",
"0.6720148",
"0.6715752",
"0.6712102",
"0.6700454",
"0.668674",
"0.65855867",
"0.65336317",
"0.65283626",
"0.64966935",
"0.64835984",
"0.6479097",
"0.646512",
"0.6455154",
"0.6453674",... | 0.7192319 | 1 |
Obtain data from tail of linked list O(1) | def peek_last(self):
if self.is_empty(): raise RuntimeError("Empty list")
return self.tail.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_last(self):\n if self.is_empty():\n raise self.NoSuchNodeException()\n\n tail = self.getNode(self.list_size - 1)\n tail_data = tail.data\n\n if self.list_size == 1:\n self.head = None\n else:\n before_tail = self.getNode(self.list_size ... | [
"0.6827692",
"0.68033373",
"0.6787032",
"0.6713353",
"0.6656795",
"0.66173166",
"0.6605389",
"0.6585034",
"0.656764",
"0.65581566",
"0.65382594",
"0.65274656",
"0.65145355",
"0.6505743",
"0.6500952",
"0.64953417",
"0.64916885",
"0.64655113",
"0.6456848",
"0.64051723",
"0.6399... | 0.7195302 | 0 |
Remove Node at the head of the linked list O(1) | def remove_first(self):
if self.is_empty(): raise RuntimeError("Empty list")
data = self.head.data
self.head = self.head.nxt
self.size -= 1
if self.is_empty(): self.tail = None
else: self.head.prev = None
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_from_head(self):\n\n if self.size == 0: # no elements in list\n return None # nothing to return\n\n removed_value = self.head.value # make a copy of the node to be deleted\n\n if self.size == 1: # if only one element in list (node is head and tail)\n self.h... | [
"0.79713875",
"0.7858995",
"0.77923083",
"0.7786379",
"0.7730542",
"0.7659608",
"0.76138735",
"0.7592778",
"0.7565751",
"0.75073975",
"0.7501189",
"0.7483941",
"0.7467383",
"0.7463325",
"0.74611574",
"0.7460435",
"0.7448749",
"0.7430704",
"0.7361645",
"0.73521364",
"0.7331011... | 0.71386814 | 33 |
Start off a watchdog oberver thread to watch filesystem event changes. Also take actions accordingly. | def watch_filesystem(ip_queue=None, watch_dir='', notify=False, recursive=False, syncer=None,
accountant=None, daemon=False):
event_handler = FSChangesHandler(
ip_queue=ip_queue,
notify=notify,
syncer=syncer,
accountant=accountant
)
observer = Observer()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def watchdog(self):\n pass",
"def start(self):\n self._watchdog_thread.start()",
"async def watchForFileSystemEvents(self):\n\n # Things that can throw this off:\n #\n # * Moving a watched directory out of the watch tree (will still\n # generate events even when outside of directory... | [
"0.72295666",
"0.6957864",
"0.6949954",
"0.6841553",
"0.66199434",
"0.6614409",
"0.6484203",
"0.6436937",
"0.63962716",
"0.63687074",
"0.61726284",
"0.6132843",
"0.61001366",
"0.6085916",
"0.6078239",
"0.59859455",
"0.5980399",
"0.596954",
"0.5952259",
"0.59522104",
"0.592634... | 0.6716316 | 4 |
Create an image for the distancefitness. | def distance(save: bool = True):
cfg = GameConfig()
diagonal = 10
# Define the function
def get_score(d, reached=False):
"""Get a score for the given distance."""
return 1 if reached else clip((1 - (d - cfg.target_reached) / diagonal) ** 2, a_min=0, a_max=1)
# Create the fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_image(self,true_dist):\n N_POINTS = 128\n RANGE = 3\n\n points = np.zeros((N_POINTS, N_POINTS, 2), dtype='float32')\n points[:, :, 0] = np.linspace(-RANGE, RANGE, N_POINTS)[:, None]\n points[:, :, 1] = np.linspace(-RANGE, RANGE, N_POINTS)[None, :]\n points = p... | [
"0.69731706",
"0.65236455",
"0.62047195",
"0.62047195",
"0.60851663",
"0.59192204",
"0.5819876",
"0.5781068",
"0.5772448",
"0.5725983",
"0.56625533",
"0.5645423",
"0.5642831",
"0.55975425",
"0.5589141",
"0.54756784",
"0.5423435",
"0.54200286",
"0.54118854",
"0.540616",
"0.538... | 0.5404766 | 20 |
Get a score for the given distance. | def get_score(d, reached=False):
return 1 if reached else clip((1 - (d - cfg.target_reached) / diagonal) ** 2, a_min=0, a_max=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score_waypoint(distance):\n return max(0,\n float(settings.SATISFIED_WAYPOINT_DIST_MAX_FT - distance) /\n settings.SATISFIED_WAYPOINT_DIST_MAX_FT)",
"def score(self):\n return self.client.call('GET', self.name + 'score')",
"def getScore(data):\n return s... | [
"0.66342354",
"0.63590884",
"0.62544674",
"0.6177079",
"0.6177079",
"0.6177079",
"0.61623144",
"0.6160462",
"0.6152823",
"0.61117935",
"0.60700047",
"0.60700047",
"0.60700047",
"0.60120547",
"0.60100543",
"0.59864867",
"0.5963997",
"0.5941403",
"0.59333926",
"0.59293413",
"0.... | 0.57218426 | 33 |
Convert from ParseResults to normal list. | def result2list(foo):
if isinstance(foo, ParseResults):
return [result2list(bar) for bar in foo]
else:
return foo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_result_list(self,res):\n res_list = []\n for r in res:\n res_list.append(r)\n\n return res_list",
"def __to_list(__results):\n rows = []\n for row in __results:\n rows.append(row)\n \n __results.c... | [
"0.67065823",
"0.6454018",
"0.6392541",
"0.61657304",
"0.6103048",
"0.60968775",
"0.600516",
"0.5954104",
"0.58549696",
"0.5853532",
"0.5851375",
"0.5830539",
"0.5825065",
"0.5800057",
"0.5794257",
"0.57913077",
"0.57792944",
"0.5751782",
"0.5738138",
"0.57195807",
"0.5705452... | 0.7606971 | 0 |
My delimited list. Allows for length zero list and uses no delimiter by default. | def List(expr, delim=""):
if not delim:
return Group(ZeroOrMore(expr))
else:
return Group(Optional(expr + ZeroOrMore( Suppress(delim) + expr))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenlist(sep, item):\n return item + ZeroOrMore(sep + item) + Optional(sep)",
"def listify(item, delimiter=\",\"):\n if not item:\n return []\n if type(item) is str:\n item = item.split(delimiter)\n if type(item) is not list:\n raise TypeError(\"'listify' must take None, str... | [
"0.7051483",
"0.6357497",
"0.6287068",
"0.62133163",
"0.6168434",
"0.61420405",
"0.6067352",
"0.5842047",
"0.57866776",
"0.5777707",
"0.5761801",
"0.57346326",
"0.5694061",
"0.56513804",
"0.5629008",
"0.56282747",
"0.5587309",
"0.55792344",
"0.5534608",
"0.5531955",
"0.551274... | 0.6472422 | 1 |
A flag identifier. It is either present or not and returns True or False. | def Flag(expr):
p = Optional(expr)
p.setParseAction(lambda s, l, t: bool(t))
return p | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFlag(self, flag) -> bool:\n ...",
"def flag_exists(self):\n return os.path.exists(self.flag_file)",
"def flag(self) -> str:\n return pulumi.get(self, \"flag\")",
"def isFlagged(self):\n return self.flag",
"def HasFlag(self, flag):\r\n \r\n return (self.state... | [
"0.7263921",
"0.68097705",
"0.6766756",
"0.66460085",
"0.64297765",
"0.6428721",
"0.6422417",
"0.6416679",
"0.6353587",
"0.6350606",
"0.63242626",
"0.6236302",
"0.62132204",
"0.61666334",
"0.61495423",
"0.6141802",
"0.61412627",
"0.61013937",
"0.60498106",
"0.5993112",
"0.596... | 0.0 | -1 |
Load system connectivity file | def load_system(filename, args, prefix, path):
try:
# Open file and do parameter substitution
doc = substitute(filename, args)
except ParseBaseException as e:
print()
print("Parsing error in system:", filename)
print(e)
sys.exit(1)
try:
# Load data
declare, statements = docume... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_disk(self):",
"def _load_disk(self):",
"def load_device():",
"def _load_disk(self):\r\n pass",
"def load_network(self):\t\t\r\n\t\tself.dqn.load_network(self.path)",
"def load(self, path):\n checkpoint = torch.load(path, map_location=torch.device(\"cpu\"))\n self.load_state_dic... | [
"0.61815464",
"0.61815464",
"0.61380976",
"0.6013895",
"0.5943033",
"0.57814723",
"0.57351536",
"0.5730525",
"0.5622977",
"0.5605681",
"0.55794024",
"0.55638885",
"0.55422413",
"0.55422413",
"0.55201924",
"0.5477085",
"0.5403135",
"0.53515655",
"0.5346899",
"0.5312842",
"0.52... | 0.50706136 | 57 |
Returns True if the user has the specified permission. This method queries all available auth backends, but returns immediately if any backend returns True. Thus, a user who has permission from a single auth backend is assumed to have permission in general. If an object is provided, permissions for this specific object... | def has_perm(self, user, perm, obj=None):
# Active superusers have all permissions.
if user.is_active and user.is_superuser:
return True
# Otherwise we need to check the backends.
return _user_has_perm(user, perm, obj) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_perm(self, perm, obj=None):\n\n # Active superusers have all permissions.\n if self.is_active and self.is_superuser:\n return True\n\n # Otherwise we need to check the backends.\n return _user_has_perm(self, perm, obj)",
"def has_perm(self, perm, obj=None):\n\n ... | [
"0.7863119",
"0.7828964",
"0.7681567",
"0.7681567",
"0.7347684",
"0.730742",
"0.7284849",
"0.72575694",
"0.72098434",
"0.7167823",
"0.7167823",
"0.71654195",
"0.7089648",
"0.70708424",
"0.70448405",
"0.7043486",
"0.69482195",
"0.6947326",
"0.69120204",
"0.69032484",
"0.684018... | 0.7860136 | 1 |
Test with no changes to commit. | def test_nothing_to_commit(caplog, local, exclude):
if exclude:
contents = local.join('README').read()
pytest.run(local, ['git', 'rm', 'README']) # Stages removal of README.
local.join('README').write(contents) # Unstaged restore.
old_sha = pytest.run(local, ['git', 'rev-parse', 'HEAD'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_commit(self):\n # TODO: Test errors while committing and recovery\n pass",
"def test_commit_empty(repository: Repository) -> None:\n head = repository.head.commit\n\n repository.commit(message=\"empty\")\n\n assert head == repository.head.commit",
"def test_no_change(self):\r\n ... | [
"0.8253829",
"0.7821866",
"0.74691355",
"0.7384211",
"0.723795",
"0.71273226",
"0.7091897",
"0.70902246",
"0.70545626",
"0.7054516",
"0.70184803",
"0.7005536",
"0.69929045",
"0.68062663",
"0.6781008",
"0.6743241",
"0.6726573",
"0.6611585",
"0.6605191",
"0.658828",
"0.65878654... | 0.6951611 | 13 |
Test ignoring of alwayschanging generated Sphinx files. | def test_nothing_significant_to_commit(caplog, local, subdirs):
local.ensure('sub' if subdirs else '', '.doctrees', 'file.bin').write('data')
local.ensure('sub' if subdirs else '', 'searchindex.js').write('data')
old_sha = pytest.run(local, ['git', 'rev-parse', 'HEAD']).strip()
actual = commit_and_push(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_include_hidden(app: Sphinx) -> None:\n app.build()\n tree = parse_html(app.outdir / \"another.html\")\n nav = tree.select(\"#sidebar > nav\")\n # navigation should include the 'another' document (toctree with hidden option)\n li = nav[0](\"li\", class_=\"current\")\n assert len(li) ==... | [
"0.64324826",
"0.6341341",
"0.6314648",
"0.62386554",
"0.6189981",
"0.61759055",
"0.6072166",
"0.60447466",
"0.60012555",
"0.59461933",
"0.59182143",
"0.59134215",
"0.5902175",
"0.5898704",
"0.5870646",
"0.58697766",
"0.5863391",
"0.585655",
"0.58209133",
"0.58180183",
"0.580... | 0.0 | -1 |
Test with changes to commit and push successfully. | def test_changes(monkeypatch, local):
monkeypatch.setenv('LANG', 'en_US.UTF-8')
monkeypatch.setenv('TRAVIS_BUILD_ID', '12345')
monkeypatch.setenv('TRAVIS_BRANCH', 'master')
old_sha = pytest.run(local, ['git', 'rev-parse', 'HEAD']).strip()
local.ensure('new', 'new.txt')
local.join('README').write... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_git_commits(self):\n event_id = dog.Event.create(title=\"Testing git commits\", text=\"\"\"$$$\n eac54655 * Merge pull request #2 from DataDog/alq-add-arg-validation (alq@datadoghq.com)\n |\\\n 760735ef | * origin/alq-add-arg-validation Simple typecheck between me... | [
"0.73422813",
"0.72160816",
"0.72070307",
"0.7081722",
"0.7039419",
"0.7008153",
"0.6994642",
"0.6889295",
"0.68850315",
"0.67943203",
"0.6715791",
"0.6667755",
"0.66391635",
"0.66081595",
"0.6576652",
"0.6536103",
"0.65090233",
"0.64961314",
"0.64915466",
"0.6472651",
"0.646... | 0.70432556 | 4 |
Test scenario where branch is deleted by someone. | def test_branch_deleted(local):
pytest.run(local, ['git', 'checkout', 'feature'])
pytest.run(local, ['git', 'push', 'origin', '--delete', 'feature'])
local.join('README').write('Changed by local.')
# Run.
actual = commit_and_push(str(local), 'origin', Versions(REMOTES))
assert actual is True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def branch_delete(request, branch_id):\n branch = models.Branch.get_by_id(int(branch_id))\n if branch.owner != request.user:\n return HttpTextResponse('You do not own this branch', status=403)\n\n repo_key = branch.repo_key\n branch.key.delete()\n num_branches = models.Branch.query(models.Branch.repo_key =... | [
"0.70407706",
"0.6978257",
"0.6950403",
"0.69398266",
"0.69226867",
"0.6910521",
"0.68338317",
"0.6806933",
"0.67489284",
"0.6737305",
"0.67202115",
"0.6653965",
"0.65832716",
"0.65230274",
"0.65227497",
"0.6496914",
"0.64698577",
"0.6468279",
"0.6465555",
"0.64556766",
"0.64... | 0.7768845 | 0 |
Test race condition scenario where another CI build pushes changes first. | def test_retryable_race(tmpdir, local, remote, collision):
local_other = tmpdir.ensure_dir('local_other')
pytest.run(local_other, ['git', 'clone', remote, '.'])
local_other.ensure('sub', 'ignored.txt').write('Added by other. Should be ignored by commit_and_push().')
if collision:
local_other.ens... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_changes(monkeypatch, local):\n monkeypatch.setenv('LANG', 'en_US.UTF-8')\n monkeypatch.setenv('TRAVIS_BUILD_ID', '12345')\n monkeypatch.setenv('TRAVIS_BRANCH', 'master')\n old_sha = pytest.run(local, ['git', 'rev-parse', 'HEAD']).strip()\n local.ensure('new', 'new.txt')\n local.join('REA... | [
"0.65928596",
"0.6187518",
"0.6125277",
"0.6112565",
"0.6095274",
"0.60608625",
"0.60585433",
"0.60419315",
"0.60243315",
"0.6010667",
"0.6003018",
"0.59950435",
"0.5964446",
"0.59346914",
"0.5933556",
"0.5927633",
"0.5918303",
"0.59118086",
"0.5850472",
"0.58455765",
"0.5829... | 0.6144106 | 2 |
Test scenario where the remote repo is unavailable (e.g. repo deleted from GitHub). | def test_origin_deleted(local, remote):
local.join('README').write('Changed by local.')
remote.remove()
with pytest.raises(GitError) as exc:
commit_and_push(str(local), 'origin', Versions(REMOTES))
assert 'Could not read from remote repository' in exc.value.output | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_repo_no_remote(repo):\n\n with pytest.raises(ValueError):\n gitb.pull(repo.working_tree_dir)",
"def test_fetch_non_github_repo(self):\n url = 'http://gitlab.com/ivacf/archi'\n with self.assertRaises(InvalidGitHubUrl):\n GitHubRepoFetcher().fetch(url)",
"def test_path... | [
"0.7890153",
"0.74834275",
"0.73048943",
"0.7264386",
"0.72429395",
"0.722274",
"0.7192378",
"0.7177005",
"0.6923777",
"0.6869419",
"0.6749882",
"0.66887414",
"0.66767913",
"0.666739",
"0.6656174",
"0.6620313",
"0.6619437",
"0.6606312",
"0.6595402",
"0.65802604",
"0.65629005"... | 0.6526773 | 21 |
Get and validate user input for a bounded number. Loops until true. Uses GLOBAL BOUNDS | def get_number():
valid_input = False
while not valid_input:
try:
user_num = int(input("Enter a number between {} and {}: ".format(LOWER_BOUND, UPPER_BOUND)))
if LOWER_BOUND <= user_num <= UPPER_BOUND:
return user_num
except ValueError:
pass
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boundary(quantity, lower, upper):\r\n in_range = False\r\n while not in_range:\r\n if quantity < lower or quantity > upper:\r\n quantity = int(input(\"That is out of range, please try a number between \" + \\\r\n str(lower) + \" and \" + str(upper) + \": ... | [
"0.7017077",
"0.6891233",
"0.6279303",
"0.6265519",
"0.6217458",
"0.6194167",
"0.6188855",
"0.6186043",
"0.6179174",
"0.61711013",
"0.6162517",
"0.6142887",
"0.6130406",
"0.61281335",
"0.6114784",
"0.60892946",
"0.60543203",
"0.6048339",
"0.6033415",
"0.6026771",
"0.5994991",... | 0.70898324 | 0 |
Constructor responsible to set class attributes | def __init__( self, xml_raw = None ):
# Instantiates class attributes
self.xml_root = None
self.error_message = None
self.validated = True
# Loads raw xml
if xml_raw is not None:
self.validated = self.validate_and_load( xml_raw ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, **attributes):\n self.set(**attributes)",
"def __init__(self, **attributes):\n for key, value in attributes.items():\n setattr(self, key, value)",
"def __init__(self, **kwargs):\n # loop over the given kwargs\n for key, value in kwargs.items():\n ... | [
"0.79277956",
"0.78259635",
"0.7801492",
"0.7793976",
"0.77121234",
"0.7671171",
"0.7597051",
"0.75740623",
"0.75551635",
"0.75551635",
"0.75551635",
"0.7543516",
"0.7539322",
"0.7518218",
"0.75133216",
"0.7482738",
"0.7476779",
"0.74638295",
"0.74638295",
"0.7429665",
"0.739... | 0.0 | -1 |
Returns root tag name | def get_tag_name( self, element = None, base_element = None ):
if element is None:
element = self.xml_root
if not etree.iselement( element ):
element = self.get_element( element, base_element )
return element.tag | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_root_element_name(self):\n return self.__root_element_name",
"def getRootName(self):\n return self.__rootName",
"def name(self) -> str:\n return self._root.name",
"def root_namespace(self) -> str:\n return self.name_components[0]",
"def get_name(self):\n return se... | [
"0.7892724",
"0.77635694",
"0.75134933",
"0.72182333",
"0.7164747",
"0.709409",
"0.67647254",
"0.6700711",
"0.6686538",
"0.6680884",
"0.6641399",
"0.66005594",
"0.64556885",
"0.64020383",
"0.6342914",
"0.63312685",
"0.61291957",
"0.6115762",
"0.6109509",
"0.6094142",
"0.60403... | 0.66504335 | 10 |
Gets the xml element by name (if there are multiple elements, only the first one is returned). Use 'get_element_list' for that. | def get_element( self, element_name, base_element = None ):
if base_element is not None:
if not etree.iselement( base_element ):
return None
else:
base_element = self.xml_root
element = base_element.find( element_name )
if element == 'None':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_element_by_name(self, name):\n for element in self._elements:\n if element.get_name() == name:\n return element",
"def get_element_by_name(self, name):\n for e in self.E:\n if e.name == name:\n return e",
"def get_element_by_element_name... | [
"0.82248026",
"0.80964357",
"0.7880741",
"0.73215145",
"0.72206604",
"0.71292984",
"0.70910096",
"0.672098",
"0.66810983",
"0.65876305",
"0.6440619",
"0.64195085",
"0.6349644",
"0.6347792",
"0.62927306",
"0.62775034",
"0.62585694",
"0.62585694",
"0.62386495",
"0.6190849",
"0.... | 0.74982464 | 3 |
Create new child element | def create_element( self, element, base_element = None, text = None ):
if base_element is None:
base_element = self.xml_root
if etree.iselement( base_element ):
if etree.iselement( element ):
base_element.append( element )
else:
element... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_child(self, parent, *args, **kwargs):\n child = self.new_element(*args, **kwargs)\n parent.append(child)\n return child",
"def create_child(self):\n raise NotImplementedError",
"def addChild(node):",
"def create_new_child(self,instance):\n\t\tnew_child = self.tree.makeTree... | [
"0.80920964",
"0.7474572",
"0.718052",
"0.7134105",
"0.69696164",
"0.6876409",
"0.6833619",
"0.6820078",
"0.6746456",
"0.6739231",
"0.6736323",
"0.6652847",
"0.66326356",
"0.66155267",
"0.65942514",
"0.6569377",
"0.6550921",
"0.65295774",
"0.6515567",
"0.6472473",
"0.644232",... | 0.6189585 | 31 |
Gets the xml element content by element name | def get_element_text( self, element, base_element = None ):
if etree.iselement( element ):
return element.text
element = self.get_element( element, base_element )
if element is not None:
return element.text
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_element_by_name(self, name):\n for e in self.E:\n if e.name == name:\n return e",
"def get_element_by_name(self, name):\n for element in self._elements:\n if element.get_name() == name:\n return element",
"def get_element(self, el_name, ... | [
"0.686001",
"0.6723485",
"0.66473246",
"0.6601518",
"0.653543",
"0.62724406",
"0.6168405",
"0.6121693",
"0.6121693",
"0.6038361",
"0.603488",
"0.6021699",
"0.60184187",
"0.59644955",
"0.5953448",
"0.5897908",
"0.58952117",
"0.5893641",
"0.5880698",
"0.5855775",
"0.58438605",
... | 0.0 | -1 |
Sets the content of a tag | def create_element_text( self, text, element, base_element = None ):
if not etree.iselement( element ):
element = self.get_element( element, base_element )
if element is None:
return False
element.text = text
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_content(self, content):\n self.content = content",
"def set_content(self, content):\n self.content = content",
"def set_content(self, content):\n self.data['content'] = content",
"def setContent(self, content):\n self.__content = content",
"def content(self, content):\n\... | [
"0.7499632",
"0.7499632",
"0.7335743",
"0.7320139",
"0.70204324",
"0.70204324",
"0.7014569",
"0.6822154",
"0.68124235",
"0.67152965",
"0.6689585",
"0.66718143",
"0.6620999",
"0.6578273",
"0.6548062",
"0.64491004",
"0.64278066",
"0.63899183",
"0.6383145",
"0.6341337",
"0.63337... | 0.0 | -1 |
Gets a list of xml elements by name | def get_element_list( self, element_name, base_element = None ):
if base_element is None:
base_element = self.xml_root
elements = base_element.findall( element_name )
if elements == 'None':
return None
return elements | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getElements(self, name=\"\"):\n\n if not name:\n return self.children\n else:\n elements = []\n for element in self.children:\n if element.name == name:\n elements.append(element)\n return elements",
"def get_by_tag(s... | [
"0.7893648",
"0.7721635",
"0.7721635",
"0.70215195",
"0.6872237",
"0.6834357",
"0.6826853",
"0.67398834",
"0.67178655",
"0.6604317",
"0.6576377",
"0.65583396",
"0.65491104",
"0.6446991",
"0.64128536",
"0.6256395",
"0.6242515",
"0.6201132",
"0.6183202",
"0.61223495",
"0.611530... | 0.6966036 | 4 |
Check the command line arguments. | def check_argv():
parser = argparse.ArgumentParser(description=__doc__.strip().split("\n")[0], add_help=False)
parser.add_argument("keywordslist", help="Numpy output file")
parser.add_argument("dirs", help="Numpy output file")
parser.add_argument("npz_train", help="Numpy output file")
if len(sys.arg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_args():\n schema = Schema({\n 'FOLDREC': Use(open, error='FOLDREC file should be readable'),\n 'CLUSTAL': Use(open, error='CLUSTAL file should be readable'),\n 'CCMPRED': Use(open, error='CCMPRED file should be readable'),\n '--metafold': Use(open, error='METAFOLD_FILE shou... | [
"0.8022634",
"0.7872992",
"0.77849925",
"0.7758825",
"0.7749583",
"0.7748146",
"0.7736978",
"0.7720457",
"0.76651484",
"0.7590784",
"0.7546356",
"0.73678654",
"0.73570716",
"0.73493856",
"0.72692305",
"0.7255995",
"0.72467524",
"0.7244977",
"0.7243071",
"0.7237292",
"0.722691... | 0.76607525 | 9 |
Bind to the ``IID_str`` with the given ``version`` | def bind(self, IID_str, version=(1,0)):
IID = windows.com.IID.from_string(IID_str)
request = self._forge_bind_request(IID, version, self.number_of_bind_if)
response = self._send_request(request)
# Parse reponse
request_type = self._get_request_type(response)
if request_ty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_server_ident(name, version=None):\n global server_ident\n \n server_ident[\"server_name\"] = name\n \n if version != None and len(version) > 0:\n server_ident[\"server_version\"] = str(version)\n version_text = \"/%s\" % server_ident[\"server_version\"]\n else:\n v... | [
"0.5488293",
"0.5464984",
"0.5414237",
"0.5216008",
"0.5216008",
"0.5132779",
"0.5110682",
"0.50267404",
"0.49960196",
"0.49960196",
"0.49735996",
"0.49455595",
"0.4940661",
"0.49362436",
"0.49324334",
"0.49238288",
"0.48973906",
"0.48956478",
"0.48696187",
"0.48696187",
"0.4... | 0.7529546 | 0 |
Craft an ALPC message containing an RPC request to call ``method_offset`` of interface ``IID` with ``params``. Can be used to craft request without directly sending it | def forge_alpc_request(self, IID, method_offset, params, ipid=None):
iid_hash = hash(buffer(IID)[:])
interface_nb = self.if_bind_number[iid_hash] # TODO: add __hash__ to IID
if len(params) > 0x900: # 0x1000 - size of meta-data
request = self._forge_call_request_in_view(interface_nb, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(self, IID, method_offset, params, ipid=None):\n request = self.forge_alpc_request(IID, method_offset, params, ipid=ipid)\n response = self._send_request(request)\n # Parse reponse\n request_type = self._get_request_type(response)\n if request_type != gdef.RPC_RESPONSE_TY... | [
"0.7709393",
"0.6050143",
"0.5798952",
"0.5638268",
"0.5624949",
"0.55940336",
"0.5567791",
"0.5512863",
"0.5477219",
"0.537469",
"0.5337115",
"0.53062266",
"0.52889895",
"0.5286633",
"0.52851754",
"0.5255648",
"0.5251362",
"0.52488613",
"0.52292114",
"0.5226254",
"0.51244795... | 0.7918275 | 0 |
Call method number ``method_offset`` of interface ``IID`` with mashalled ``params`` | def call(self, IID, method_offset, params, ipid=None):
request = self.forge_alpc_request(IID, method_offset, params, ipid=ipid)
response = self._send_request(request)
# Parse reponse
request_type = self._get_request_type(response)
if request_type != gdef.RPC_RESPONSE_TYPE_SUCCESS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(self, method, params, callback=None):\n cur_id = self._next_id()\n if callback:\n self._callbacks[cur_id] = callback\n self.send({'msg': 'method', 'id': cur_id, 'method': method, 'params': params})",
"def call(self, method, params, callback=None):\n cur_id = self._... | [
"0.6457688",
"0.6457688",
"0.63944983",
"0.60446113",
"0.60007215",
"0.5442638",
"0.5425219",
"0.5395106",
"0.53930616",
"0.5373983",
"0.5315418",
"0.5293637",
"0.52931386",
"0.5262458",
"0.5239935",
"0.5228087",
"0.520957",
"0.5179884",
"0.5162715",
"0.5161636",
"0.5153802",... | 0.6616697 | 0 |
return a 2tuple list (idx, run) filter out not incrementables | def compress_runs(runs, incrementable):
return [(i, r) for i, r in enumerate(runs) if r.analysis_type in incrementable] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_idxs(self):\n return list(range(len(self._h5[RUNS])))",
"def runs(lst):\n for j, two in enumerate(lst):\n if j == 0:\n one, i = two, 0\n if one != two:\n yield j - i, one\n i = j\n one = two\n yield j - i + 1, two",
"def run_traj_idxs(s... | [
"0.61934006",
"0.59456134",
"0.5884365",
"0.58346885",
"0.57831305",
"0.57831305",
"0.5749621",
"0.57459706",
"0.568972",
"0.5641108",
"0.56102896",
"0.560884",
"0.5552723",
"0.55208975",
"0.54915106",
"0.54656136",
"0.5431433",
"0.5424431",
"0.54129857",
"0.5407284",
"0.5405... | 0.6838056 | 0 |
Implementing classes can override to perform a transformation | def _transform_point(self, x, y):
return (x, y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(self):",
"def transform(self, *args, **kwargs):\n raise NotImplementedError",
"def transform():",
"def transform():\n pass",
"def transform(self, X):\n ...",
"def transform(self, X):\n ...",
"def transform(self, X):\n ...",
"def transform(self, X):\n ... | [
"0.85904545",
"0.8393356",
"0.82972276",
"0.828475",
"0.81815124",
"0.81815124",
"0.81815124",
"0.81815124",
"0.81815124",
"0.81815124",
"0.81815124",
"0.8021208",
"0.79371977",
"0.77974856",
"0.77755135",
"0.77438164",
"0.77143264",
"0.77143264",
"0.77143264",
"0.7607391",
"... | 0.0 | -1 |
Implemented label methods should place labels within a LETTER_HEIGHT x len(label) LETTER_WIDTH region centered at label_x, label_y | def _draw_label(label, label_x, label_y):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_label(self, contig_name, width, height, font, title_width, upper_left, vertical_label,\n strand, canvas, horizontal_centering=False, center_vertical=False, chop_text=True,\n label_color=(50, 50, 50, 255)):\n upper_left = list(upper_left) # to make it mutable\... | [
"0.71363807",
"0.68898165",
"0.6765323",
"0.6661851",
"0.65560156",
"0.6492479",
"0.6486989",
"0.64741296",
"0.644576",
"0.6443592",
"0.6416232",
"0.63992846",
"0.63034606",
"0.62848526",
"0.62837756",
"0.6281372",
"0.6280866",
"0.62708366",
"0.62629914",
"0.6259574",
"0.6256... | 0.7144518 | 0 |
Get the ElasticSearch index or indices to query. By default, we obtain the index from the foreign table options. However, this method can be overridden to derive the index from the query quals. For example, the `timestamp` qual could be used to select one or more timebased indices. | def get_index(self, _quals):
return self._options['index'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_index(self, *args, **dargs):\n pass",
"def get_index(\n self,\n ) -> Callable[[datastore_admin.GetIndexRequest], Awaitable[index.Index]]:\n # Generate a \"stub function\" on-the-fly which will actually make\n # the request.\n # gRPC handles serialization and deserial... | [
"0.62230533",
"0.6008187",
"0.58028996",
"0.57998234",
"0.57949215",
"0.57949215",
"0.57921827",
"0.56789416",
"0.5601105",
"0.5534349",
"0.552037",
"0.5520204",
"0.5516885",
"0.55096304",
"0.55079347",
"0.54522127",
"0.5441961",
"0.5438087",
"0.54296577",
"0.53880614",
"0.53... | 0.68531275 | 0 |
Given a nested dict and a dotseparated field path, returns the value | def _get_nested(nested_dict, field):
print(nested_dict, field)
keys = field.split('.')
current = nested_dict
for k in keys:
print('key', k, 'current', current)
# return None for nested fields without a value in this doc
if isinstance(current, list):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _nested_lookup(doc, field):\n value = doc\n keys = field.split(\".\")\n try:\n for k in keys:\n value = value[k]\n except KeyError:\n return None\n\n return str(value)",
"def nested_lookup(doc, field):\n value = doc\n keys = field.... | [
"0.72812533",
"0.70375586",
"0.7027419",
"0.690127",
"0.67872345",
"0.6541964",
"0.634685",
"0.63271713",
"0.6324483",
"0.61930674",
"0.6185184",
"0.6156394",
"0.60894597",
"0.6084815",
"0.60825056",
"0.6075377",
"0.6072617",
"0.6042237",
"0.60361457",
"0.6025189",
"0.6017177... | 0.69397694 | 3 |
Converts a CoreBluetooth UUID to a Python string. If ``_uuid`` is a 16bit UUID, it is assumed to be a Bluetooth GATT UUID (``0000xxxx00001000800000805f9b34fb``). Args | def cb_uuid_to_str(_uuid: CBUUID) -> str:
_uuid = _uuid.UUIDString()
if len(_uuid) == 4:
return "0000{0}-0000-1000-8000-00805f9b34fb".format(_uuid.lower())
# TODO: Evaluate if this is a necessary method...
# elif _is_uuid_16bit_compatible(_uuid):
# return _uuid[4:8].lower()
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uuid(_uuid=uuid4):\n return str(_uuid())",
"def _format_uuid(self, uuid):\n uuid_format = self.uuid_format\n uuid_list=uuid_format.split(\"-\")\n pad=len(uuid_list[-1])\n last_element=uuid.zfill(pad)\n formatted_uuid=uuid_format.replace(uuid_list[-1], last_element)\n ... | [
"0.67531985",
"0.6394974",
"0.6309436",
"0.6288315",
"0.6235836",
"0.6185628",
"0.61492383",
"0.61275625",
"0.6092875",
"0.60705936",
"0.6040981",
"0.595578",
"0.59540427",
"0.5948298",
"0.59475523",
"0.58622694",
"0.5757375",
"0.575162",
"0.575162",
"0.57498914",
"0.5726065"... | 0.83089083 | 0 |
Start the actual training. | def start(self):
start_time = time()
def callback(res):
env, data, game_id = res.result()
if env is None:
logger.info('invalid data: {}'.format(game_id))
return
self.save_data(data, game_id)
logger.debug(f"game {game_id}"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_training(self):\n self.training = True",
"def start_training(self):\n if self.task_env is None:\n rospy.logfatal(\"No task environment found for training.\")\n if self.agent is None:\n rospy.logfatal(\"No agent found for training.\")\n self.agent.start_... | [
"0.85329",
"0.8220099",
"0.7970064",
"0.7902157",
"0.7856861",
"0.7830066",
"0.78190035",
"0.78005296",
"0.76683235",
"0.765422",
"0.75742763",
"0.75742763",
"0.75598806",
"0.7525017",
"0.75164604",
"0.75163966",
"0.75138336",
"0.74506795",
"0.74190724",
"0.74041206",
"0.7404... | 0.0 | -1 |
Loads game data from pgn files | def get_games_from_all_files(self):
files = find_kif_files(self.config.resource.play_data_dir)
logger.debug(files)
games = []
for filename in files:
games.extend(self.get_games_from_file(filename))
logger.debug("done reading")
return games | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_pgn(filename: str) -> List[chess.pgn.Game]:\n with open(filename) as pgn:\n games = []\n while True:\n game = chess.pgn.read_game(pgn)\n if game is not None:\n games.append(game)\n else:\n break\n return games",
"def ... | [
"0.73185784",
"0.70502716",
"0.67713994",
"0.65052766",
"0.64290106",
"0.6397501",
"0.6386656",
"0.6374426",
"0.6358037",
"0.63467526",
"0.6342266",
"0.63245165",
"0.6316038",
"0.6237152",
"0.6212215",
"0.6186619",
"0.6179433",
"0.61740726",
"0.610337",
"0.6101432",
"0.607228... | 0.0 | -1 |
Gets data to load into the buffer by playing a game using PGN data. | def _get_buffer(config, game, tot_num, idx):
env = ShogiEnv().reset()
white = ShogiPlayer(config, dummy=True)
black = ShogiPlayer(config, dummy=True)
for move in game["moves"]:
if env.white_to_move:
action = white.sl_action(env.observation, move) # ignore=True
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data(self):\n return self.source_data[\"game\"]",
"def play_game(self):\n game_data, game_stats = play_game_startpos(self.config, self.policy)\n monitor.add_scalar(\n 'datagen/moves_per_second',\n game_stats['moves_per_game'] / game_stats['seconds_per_game'])\n ... | [
"0.6437023",
"0.6204137",
"0.5851889",
"0.56304264",
"0.559814",
"0.5597615",
"0.5590954",
"0.5511871",
"0.53625566",
"0.5344706",
"0.5335907",
"0.5326878",
"0.53197557",
"0.5313001",
"0.5311973",
"0.5299501",
"0.52922344",
"0.5252059",
"0.5189141",
"0.51600635",
"0.51113707"... | 0.5843951 | 3 |
Wrapper around subprocess, calls an external process, logging stdout and stderr to debug | def execute(command):
logger = logging.getLogger()
if command:
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = process.communicate()
logger.debug('Executed %s, stdout: "%s", stderr: "%s"', command[0], output.strip(), error.strip())
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_subprocess_with_logging(command, my_env=None):\n logger.info(\"About to call : {0}\".format(command))\n return_code = 0\n try:\n if my_env:\n return_out = subprocess.check_output(command, stderr=subprocess.STDOUT, env=my_env, shell=True)\n else:\n return_out = ... | [
"0.70910186",
"0.708103",
"0.6922527",
"0.6852711",
"0.67550564",
"0.67189914",
"0.670283",
"0.66723627",
"0.6662327",
"0.66421163",
"0.65973556",
"0.6532676",
"0.6509501",
"0.6507134",
"0.64754534",
"0.6462841",
"0.6462112",
"0.64519936",
"0.6441999",
"0.64398474",
"0.643742... | 0.0 | -1 |
Create specified directory. Stay silent if it already exists, but complain loudly if it isn't a directory | def make_target_dir(directory):
logger = logging.getLogger()
try:
makedirs(directory)
logger.debug('Created directory %s', directory)
return True
except OSError as err:
if err.errno != errno.EEXIST:
raise
if exists(directory):
if isdir(director... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dir(dir_):\n try:\n os.makedirs(dir_)\n logger.debug(\"Creating directory %s\", dir_)\n except OSError as err:\n if err.errno != errno.EEXIST:\n raise",
"def create_dir(dir_path):\n\n if not path.exists(dir_path):\n log('Creating directory: {0}'.format(d... | [
"0.8223434",
"0.82182723",
"0.8165802",
"0.8128069",
"0.8049007",
"0.8048717",
"0.80351573",
"0.80351573",
"0.80349743",
"0.80310404",
"0.801574",
"0.80120736",
"0.8010556",
"0.8010556",
"0.79897314",
"0.7989509",
"0.79854655",
"0.7983546",
"0.7981484",
"0.7981154",
"0.798115... | 0.0 | -1 |
Create Person This path operation creates a person in the app and save the information in the dadabase | def create_person(person: Person = Body(...)):
return person | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_person(self):",
"def insert_person():\r\n body = request.get_json()\r\n\r\n try:\r\n INSERT_PERSON_SCHEMA.validate(body)\r\n except SchemaError as err:\r\n raise ServiceBodyError(str(err))\r\n\r\n with sqlite_client:\r\n person = (body.get('name'), body.get('cpf'))\r\n... | [
"0.7738525",
"0.7273424",
"0.70011073",
"0.69518965",
"0.6814352",
"0.6792122",
"0.67399067",
"0.6730581",
"0.6661279",
"0.659992",
"0.6581125",
"0.657672",
"0.6572996",
"0.65058935",
"0.646036",
"0.6459561",
"0.641186",
"0.63995534",
"0.63995534",
"0.6348176",
"0.6334964",
... | 0.6247324 | 22 |
Setup the Awesome Light platform. | def setup_platform(hass, config, add_devices, discovery_info=None):
# import awesomelights
# Assign configuration variables. The configuration check takes care they are
# present.
host = config.get(CONF_HOST)
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
# Setup... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_platform(\n hass: HomeAssistant,\n config: ConfigType,\n add_entities: AddEntitiesCallback,\n discovery_info: DiscoveryInfoType | None = None,\n) -> None:\n name = config[CONF_NAME]\n host = config[CONF_HOST]\n entity = OppleLight(name, host)\n\n add_entities([entity])\n\n _LOG... | [
"0.7064935",
"0.6602694",
"0.65638894",
"0.65371436",
"0.64411795",
"0.63974077",
"0.6249045",
"0.62374127",
"0.62064946",
"0.61928594",
"0.6191015",
"0.615344",
"0.615077",
"0.61218876",
"0.61058104",
"0.60810417",
"0.6056982",
"0.6035329",
"0.60312074",
"0.5972297",
"0.5971... | 0.6171732 | 11 |
Return the display name of this light. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._light.name",
"def get_display_name(self):\n return DisplayText(self._display_name)",
"def name(self):\n return f\"{get_device_name(self._data, self._device.id)} Light\"",
"def get_display_name(self):\n return self.display_name",
"def get_display_na... | [
"0.8419186",
"0.79949266",
"0.7932655",
"0.7864694",
"0.77409434",
"0.7726647",
"0.7726647",
"0.7726647",
"0.7726647",
"0.7726647",
"0.7726647",
"0.7726647",
"0.7726647",
"0.7726647",
"0.7726647",
"0.7726647",
"0.7726647",
"0.7716824",
"0.7705757",
"0.76947725",
"0.7663317",
... | 0.0 | -1 |
Return the brightness of the light. This method is optional. Removing it indicates to Home Assistant that brightness is not supported for this light. | def brightness(self):
return self._brightness | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_brightness(self):\n response = self.parent.backlight.get_brightness()\n if response is not None:\n response = response[0]\n return response",
"def brightness(self):\n return brightness_from_percentage(self._brightness_pct)",
"def _get_brightness(self):\n re... | [
"0.81454575",
"0.80562174",
"0.7982195",
"0.7960312",
"0.79019403",
"0.78584355",
"0.7818193",
"0.777205",
"0.777205",
"0.7749119",
"0.7607747",
"0.75495696",
"0.74634945",
"0.72554505",
"0.72445774",
"0.7103418",
"0.7075153",
"0.7001918",
"0.7000528",
"0.69840914",
"0.691102... | 0.7907485 | 14 |
Return true if light is on. | def is_on(self):
return self._state | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def light_is_on(self):\r\n return self._light == \"ON\"",
"def light_is_on(self):\n return self._light == \"ON\"",
"def is_on(self):\n return self._light_on",
"def is_light(self) -> bool:\n return ATTRIBUTE.Light.value in self.type_data.attributes",
"def is_light(self) -> bool:\... | [
"0.9035416",
"0.89275813",
"0.86664206",
"0.8008696",
"0.8008696",
"0.78880787",
"0.7866302",
"0.7610281",
"0.7565963",
"0.7415077",
"0.7345493",
"0.7335999",
"0.73116577",
"0.7303292",
"0.72991306",
"0.7243393",
"0.71792775",
"0.71722543",
"0.7157757",
"0.7157757",
"0.715775... | 0.0 | -1 |
Instruct the light to turn on. You can skip the brightness part if your light does not support brightness control. | def turn_on(self, **kwargs):
self._brightness = 100
self._state = 'on'
#self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
#self._light.turn_on()
_LOGGER.info("turn_on() is called") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_on(self, **kwargs: Any) -> None:\n self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255)\n self._light.turn_on()",
"def set_light_on(self):\r\n self._light = \"ON\"",
"async def async_turn_on(self, **kwargs: Any) -> None:\n if (brightness := kwargs.get(ATTR_BRIGHTNESS))... | [
"0.876063",
"0.86473703",
"0.86437523",
"0.86226034",
"0.86144036",
"0.83741844",
"0.8299596",
"0.8281327",
"0.82521445",
"0.8087994",
"0.8022874",
"0.80080384",
"0.78507304",
"0.7818195",
"0.77767706",
"0.7775988",
"0.7701322",
"0.7684567",
"0.767373",
"0.761866",
"0.7589698... | 0.8921207 | 0 |
Instruct the light to turn off. | def turn_off(self, **kwargs):
#self._light.turn_off()
self._brightness = 0
self._state = 'off'
_LOGGER.info("turn_off() is called") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_off(self):\n GPIO.output(self.gpio, False) # turn off light",
"def set_light_off(self):\n self._light = \"OFF\"",
"def set_light_off(self):\r\n self._light = \"OFF\"",
"def lightning_turnoff(self):\n self.turnOff()",
"def turn_off(self, **kwargs: Any) -> None:\n ... | [
"0.9141917",
"0.89695406",
"0.89557284",
"0.89015293",
"0.8897358",
"0.8873913",
"0.87862444",
"0.87764317",
"0.86670524",
"0.86476165",
"0.847877",
"0.8473624",
"0.84669805",
"0.8463841",
"0.8435901",
"0.8370482",
"0.83494097",
"0.8275936",
"0.82717854",
"0.82705396",
"0.825... | 0.8805522 | 6 |
Fetch new state data for this light. This is the only method that should fetch new data for Home Assistant. | def update(self):
#self._light.update()
#self._state = 'on' #self._light.is_on()
#self._brightness = 80 #self._light.brightness
_LOGGER.info("update() is called") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def update(self):\n resp = await self._request('get', 'state')\n if resp:\n for line in resp.splitlines():\n key, val = line.strip().split(None, 1)\n if val == 'on' or val == 'off':\n val = (val == 'on')\n self.state... | [
"0.6163379",
"0.58823276",
"0.5866186",
"0.58516115",
"0.5845145",
"0.58341724",
"0.58107907",
"0.57916033",
"0.57654613",
"0.5740478",
"0.57302564",
"0.57082814",
"0.57056934",
"0.5679791",
"0.5667786",
"0.56626356",
"0.56270146",
"0.5622498",
"0.5618415",
"0.55984426",
"0.5... | 0.5371108 | 51 |
Predicts whether the faces belong to a trained class. | def face_prediction(self, frame, faces):
predictions = FaceModel.model.predict_proba(FaceModel.emb_array)
best_class_indices = np.argmax(predictions, axis=1)
best_class_probabilities = predictions[
np.arange(len(best_class_indices)),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_trained(self) -> bool:\r\n return not getattr(self._lda, \"classes_\", None) is None",
"def apply_classifier(self):\n for detected_object in self.detected_objects:\n detected_object.predict_class(self.original_image)",
"def is_trained(self) -> bool:",
"def classification(self)... | [
"0.6539211",
"0.64435315",
"0.642666",
"0.64105463",
"0.6291514",
"0.62014234",
"0.6199739",
"0.61470646",
"0.60917354",
"0.60511786",
"0.6036084",
"0.6013855",
"0.6013855",
"0.6013855",
"0.6013592",
"0.6008291",
"0.5985599",
"0.59688056",
"0.5966839",
"0.5940728",
"0.5940728... | 0.70823354 | 0 |
Performs all necessary work to do face classification. Returns | def classification(self):
if self.video_in != None:
ret, frame = self.video_in.get_a_frame()
elif self.camera_in != None:
ret, frame = self.camera_in.get_a_frame()
if ret == True:
# detect face
faces = FaceModel.detect_face(self, frame)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify_face(im):\r\n faces = get_encoded_faces()\r\n faces_encoded = list(faces.values())\r\n known_face_names = list(faces.keys())\r\n\r\n img = cv2.imread(im, 1)\r\n \"\"\"\r\n Resize optinal \r\n \"\"\"\r\n #img = cv2.resize(img, (0, 0), fx=0.5, fy=0.5)\r\n #img = img[:,:,::-1]\... | [
"0.72616476",
"0.70782316",
"0.6882108",
"0.6881206",
"0.6809572",
"0.6784606",
"0.67753196",
"0.66968185",
"0.6624295",
"0.65775526",
"0.6573839",
"0.6529528",
"0.65139365",
"0.6483432",
"0.6458223",
"0.6457295",
"0.6426916",
"0.6408628",
"0.6396731",
"0.6369119",
"0.6361105... | 0.71059865 | 1 |
This method is called by the StreamOut parent class. The StreamOut class has a thread that periodically calls this method to grab a frame and provide that to web server. | def frames(self):
while True:
ret, frame = self.classification()
if ret == True:
yield cv2.imencode('.jpg', frame)[1].tobytes()
else:
break | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _request_frame(self):\n self._send_command('GET_FRAME')",
"def update_frame(self):\r\n while not self.stopped:\r\n if not self.grabbed or not self.cap.isOpened():\r\n self.stop()\r\n else:\r\n (self.grabbed, self.frame) = self.cap.read()",
"... | [
"0.6792106",
"0.653926",
"0.6485652",
"0.64724773",
"0.6468046",
"0.6462333",
"0.64513797",
"0.63242877",
"0.6295482",
"0.6205932",
"0.6194944",
"0.6183502",
"0.61737967",
"0.61667466",
"0.6126697",
"0.61256397",
"0.61173517",
"0.6107282",
"0.60879606",
"0.6071895",
"0.606682... | 0.0 | -1 |
ML application invokes this method to perform classification. | def run(self):
while True:
ret, frame = self.classification()
# valid frame
if ret == True:
# output the recognized face
if self.video_out != None:
self.video_out.display(frame)
if self.pic_out != None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_classifier(self):\n for detected_object in self.detected_objects:\n detected_object.predict_class(self.original_image)",
"def classify(self, data):\n \"*** YOUR CODE HERE ***\"\n return self.sklearn_classifier.predict(data)",
"def start_training(self):\n self.tr... | [
"0.7225942",
"0.6836525",
"0.67134684",
"0.66997033",
"0.66642874",
"0.66251534",
"0.6577366",
"0.6555927",
"0.6527767",
"0.65242875",
"0.649298",
"0.64876366",
"0.6481546",
"0.648005",
"0.6470728",
"0.6420012",
"0.6403459",
"0.6403459",
"0.6403459",
"0.6403459",
"0.6403459",... | 0.0 | -1 |
Class add entry in the tag inventory | def __init__(self):
self.__parser=OptionParser(option_class=MyOption)
self.__source=''
self.__dest=''
self.__all=False
self.__inv=False
self.__tree=''
self.__authpath=''
self.__verbose=False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, tag):\n self.tags[tag.name] = tag",
"def add(self, item):",
"def add_tag(self, **kwargs):\n key = kwargs['key']\n value = kwargs['value']\n volume_info = self.cm.find_name(name=kwargs['NAME'])\n volume_info = self.update_volume_tag(info=volume_info, key=key,\n ... | [
"0.6757013",
"0.65357596",
"0.6487376",
"0.6423579",
"0.6360834",
"0.63499016",
"0.6330379",
"0.63226503",
"0.63226503",
"0.63226503",
"0.62932813",
"0.62790316",
"0.6211367",
"0.62079006",
"0.6198882",
"0.61972827",
"0.6132275",
"0.6131941",
"0.61282265",
"0.60810953",
"0.60... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.