query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Gets the colour of a z and step value. | def colour(z, i):
if abs(z) < self.threshold:
return self.background
v = np.log2(i + self.threshold - np.log2(np.log2(abs(z)))) / self.threshold
if v < 1.0:
return v ** b1, v ** b2, v ** b3 # background
else:
v = max(0, 2 -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_colour(self, r1, r2, r3, b1, b2, b3):\n\n def colour(z, i):\n \"\"\"\n Gets the colour of a z and step value.\n\n :param complex z: the z value from the mandelbrot set\n :param int i: the step value\n\n :rtype: tuple\n :return: the th... | [
"0.7341066",
"0.72083485",
"0.68963253",
"0.6640423",
"0.65460277",
"0.6530589",
"0.6423319",
"0.62713194",
"0.6260205",
"0.6229389",
"0.62234646",
"0.6208068",
"0.61786675",
"0.6175499",
"0.6157222",
"0.6157222",
"0.6157222",
"0.6157222",
"0.6140309",
"0.6133816",
"0.6130664... | 0.7172321 | 2 |
Gets the colour of a z and step value. | def colour(z, i):
if abs(z) < self.threshold:
return 0, 0, 0
v = np.log2(i + self.threshold - np.log2(np.log2(abs(z)))) / self.threshold
if v < 1.0:
return v ** b1, v ** b2, v ** b3 # coloured tones
else:
v = max(0, 2 - v)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_colour(self, r1, r2, r3, b1, b2, b3):\n\n def colour(z, i):\n \"\"\"\n Gets the colour of a z and step value.\n\n :param complex z: the z value from the mandelbrot set\n :param int i: the step value\n\n :rtype: tuple\n :return: the th... | [
"0.73403287",
"0.7172178",
"0.6895486",
"0.66384035",
"0.654349",
"0.65309036",
"0.64248663",
"0.62704283",
"0.6260564",
"0.62288976",
"0.622155",
"0.62071323",
"0.6176974",
"0.6173576",
"0.6155353",
"0.6155353",
"0.6155353",
"0.6155353",
"0.613839",
"0.61319745",
"0.6128805"... | 0.7208043 | 1 |
get returns a single user given its unique user_id | def get(self, user_id):
user, code = get_user(user_id)
if code == 404:
api.abort(code=404, message="The User with the user_id doesnt Exist")
return user, code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, user_id):\n return User.get(user_id)",
"def get(id):\n return User.query.filter_by(id=id).first()",
"def get_user_by_id(user_id):\n return User.query.get(user_id)",
"def get_user(self, user_id):\n uri = 'users/' + user_id\n return self.make_request(uri)",
"def get_user(... | [
"0.84332645",
"0.83980507",
"0.8261577",
"0.8222736",
"0.8221518",
"0.8178469",
"0.81775814",
"0.81763834",
"0.8173295",
"0.8173295",
"0.8173295",
"0.8173295",
"0.81669915",
"0.8094847",
"0.80743533",
"0.805296",
"0.8034785",
"0.8032745",
"0.80307204",
"0.8004",
"0.8000615",
... | 0.0 | -1 |
Create a pattern for dense op followed by activations. | def make_gemm_pattern(with_bias=True, with_act=None, out_dtype="float16"):
data = wildcard()
weight = wildcard()
bias = wildcard()
gemm = is_op("nn.dense")(data, weight)
if with_bias:
add_or_bias_add = is_op("add") | is_op("nn.bias_add")
gemm_out = add_or_bias_add(gemm, bias)
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dense_pattern():\n pattern = is_op(\"nn.dense\")(wildcard(), is_constant())\n return pattern",
"def build_dense(self): # Pass state_size and action_size\n model = Sequential()\n model.add(Dense(24, input_dim = grid_size*grid_size+2, activation = 'relu'))\n model.add(Dense(2... | [
"0.69449264",
"0.62637776",
"0.59782976",
"0.57860476",
"0.5729001",
"0.5647342",
"0.55941767",
"0.55772847",
"0.5576438",
"0.5543127",
"0.5528706",
"0.5513469",
"0.550603",
"0.5490817",
"0.5490472",
"0.547368",
"0.5409983",
"0.5396722",
"0.53857964",
"0.53843766",
"0.5366124... | 0.5065252 | 52 |
This function calculates the binary Hamming distance of 2 strings by converting | def edit_distance (str1, str2):
str1.strip()
str2.strip()
if len(str1) != len(str2):
raise ValueError("Strings have to be of equal lengths: " + str1 + " and " + str2)
return sum(bit=='1' for bit in bin(int(binascii.hexlify(xorstr(str1, str2)), 16))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def HammingDist(str1, str2):\n\tHdist = 0\n\tfor i, base in enumerate(str1):\n\t\tif base != str2[i]:\n\t\t\tHdist += 1\n\n\treturn Hdist",
"def hamming_dist(bytes1, bytes2):\n if type(bytes1) == str:\n bytes1 = [ord(c) for c in str1]\n if type(bytes2) == str:\n bytes2 = [ord(c) for c in str2... | [
"0.84647644",
"0.84023887",
"0.83347034",
"0.8326972",
"0.8308358",
"0.8137487",
"0.8136767",
"0.8125086",
"0.81187636",
"0.79529357",
"0.7932111",
"0.7905424",
"0.78473914",
"0.77683306",
"0.7704884",
"0.76946086",
"0.7677987",
"0.7667733",
"0.76575166",
"0.76161945",
"0.755... | 0.7592945 | 20 |
Get the unitary vector of direction. | def dir(self):
return unit_vector(normalize_angle(self.angle)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def direction(self):\n len = self.length()\n if len == 0.0:\n uvec = pos.Pos(np.transpose(np.array([0, 0, 0])))\n else:\n uvec = pos.Pos(np.transpose(np.array([(self.end.x - self.start.x) / len,\n (self.end.y - self.start.y... | [
"0.80650926",
"0.7714104",
"0.7688202",
"0.74529743",
"0.736431",
"0.73323345",
"0.72756165",
"0.721212",
"0.7031685",
"0.7012481",
"0.70107687",
"0.6999042",
"0.6971306",
"0.69533485",
"0.6934928",
"0.6934928",
"0.6934928",
"0.6921606",
"0.69211054",
"0.69203055",
"0.688539"... | 0.69447875 | 14 |
Update the node Id for the current node. | def setNodeId(self, recId):
if self.cursor:
self.cursor.nodeId = recId | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_id(self, node_id: int):\r\n self._node_id = node_id",
"def update_node_id(node: Element) -> None:\n new_ids: list[str] = []\n for node_id in node['ids']:\n new_id = self.fix_fragment('', node_id)\n if new_id not in new_ids:\n ... | [
"0.7829752",
"0.7489203",
"0.74335957",
"0.7393328",
"0.6981593",
"0.68572396",
"0.67971003",
"0.6588425",
"0.6580804",
"0.65778935",
"0.6553216",
"0.65527683",
"0.6539076",
"0.6539076",
"0.6514303",
"0.6485789",
"0.6476102",
"0.6347575",
"0.63162756",
"0.6252726",
"0.6208319... | 0.69661885 | 5 |
Updates the record id of the head sublist record. | def saveHeadId(self, headId):
self.headId = headId
record = dict(nextId=None, childId=headId, label='head pointer')
self.db.update(1, self.tableName, record) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadHeadId(self):\n rec = self.db.selectById(self.tableName, 1)\n if rec:\n self.headId = rec['childId']\n return self.headId\n print('Error! No first sublist record found.')\n return None",
"def _update_head(self, course_key, index_entry, branch, new_id):\n ... | [
"0.71913046",
"0.5909919",
"0.58707434",
"0.5700044",
"0.55987924",
"0.54624844",
"0.5406612",
"0.53759485",
"0.53540254",
"0.52908164",
"0.52557015",
"0.52411836",
"0.52329826",
"0.52329826",
"0.52329826",
"0.52329826",
"0.52329826",
"0.52329826",
"0.52329826",
"0.52329826",
... | 0.5978991 | 1 |
Export financial report Excel from the admin side. | def export_xlsx(request):
import openpyxl
try:
from openpyxl.cell import get_column_letter
except ImportError:
from openpyxl.utils import get_column_letter
from_date = request.GET.get('from_date')
to_date = request.GET.get('to_date')
search = request.GET.get('search_value') or '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export(self):\n\n rpt_date = datetime.now()\n filename = 'bushfire_report_{}.xls'.format(rpt_date.strftime('%d%b%Y'))\n response = HttpResponse(content_type='application/vnd.ms-excel')\n response['Content-Disposition'] = 'attachment; filename=' + filename\n\n book = Workbook(... | [
"0.74944603",
"0.7453464",
"0.74425185",
"0.74420345",
"0.74178195",
"0.74111104",
"0.73946965",
"0.7328942",
"0.729512",
"0.7261714",
"0.6878788",
"0.6865229",
"0.67143226",
"0.66296583",
"0.6595517",
"0.6570733",
"0.6570733",
"0.6454679",
"0.6449948",
"0.64201456",
"0.63465... | 0.62886864 | 22 |
Export financial report CSV from the admin side. | def export_repayment_csv(request):
import csv
from django.utils.encoding import smart_str
# response = HttpResponse(content_type='text/csv')
# response['Content-Disposition'] = 'attachment; filename=Repayment_report.csv'
from_date = request.GET.get('from_date')
to_date = request.GET.get('to_date... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dlCsvReport(self):\r\n requestElems = {'xf': 'csv'}\r\n requestElems.update(self.getReportConfig())\r\n \r\n csvdata = self.sendRequest(self.reportFormURL, self.fileOpener,\r\n requestElems, 'POST').read()\r\n\r\n self.writeExportFile('csv', ... | [
"0.7379921",
"0.73224705",
"0.7103962",
"0.68414193",
"0.6666803",
"0.66631263",
"0.6570242",
"0.6528814",
"0.65245694",
"0.64698297",
"0.6458403",
"0.64346254",
"0.6426312",
"0.63806766",
"0.6376845",
"0.6372116",
"0.6359299",
"0.6348953",
"0.6324408",
"0.63181615",
"0.63142... | 0.65966964 | 6 |
Export financial report Excel from the admin side. | def export_repayment_xlsx(request):
import openpyxl
try:
from openpyxl.cell import get_column_letter
except ImportError:
from openpyxl.utils import get_column_letter
from_date = request.GET.get('from_date')
to_date = request.GET.get('to_date')
search = request.GET.get('search_va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export(self):\n\n rpt_date = datetime.now()\n filename = 'bushfire_report_{}.xls'.format(rpt_date.strftime('%d%b%Y'))\n response = HttpResponse(content_type='application/vnd.ms-excel')\n response['Content-Disposition'] = 'attachment; filename=' + filename\n\n book = Workbook(... | [
"0.7495683",
"0.7454717",
"0.7443899",
"0.7443692",
"0.741883",
"0.7412455",
"0.73961747",
"0.7330415",
"0.7296676",
"0.72633135",
"0.6880631",
"0.686647",
"0.67169285",
"0.66300696",
"0.6596857",
"0.65736467",
"0.65736467",
"0.64546067",
"0.64511687",
"0.64222556",
"0.634818... | 0.60136884 | 37 |
Checks the expiration date of the card | def check(self):
validity_year = int(self.date[0:4])
validity_month = int(self.date[5:7])
validity_day = int(self.date[8:10])
if datetime.today().year > validity_year:
self.flag = False
elif datetime.today().year == validity_year:
if datetime.today().month... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_content_expiry_date(self):\n\n if self.expire_date < datetime.now():\n self.state = 'disabled'",
"def is_expired(self):\n return self.expiration_date <= self._now()",
"def clean_expiration_date(self):\n expiration_date = self.cleaned_data['expiration_date']\n if... | [
"0.7288992",
"0.71461076",
"0.71064097",
"0.6798181",
"0.6778251",
"0.6727741",
"0.67241824",
"0.6718817",
"0.6605499",
"0.65725285",
"0.6560101",
"0.6555981",
"0.6535536",
"0.6485778",
"0.6470241",
"0.647006",
"0.64549625",
"0.64269155",
"0.64255065",
"0.64250386",
"0.641015... | 0.6089248 | 43 |
Test case for create_nas_share_by_nas | def test_create_nas_share_by_nas(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_test_nas_share(self):\n pass",
"def test_show_nas_share_by_nas(self):\n pass",
"def test_test_result_nas_share(self):\n pass",
"def test_update_nas_share_by_nas(self):\n pass",
"def test_index_nas_shares_by_nas(self):\n pass",
"def test_show_nas_share(self):\n ... | [
"0.87092817",
"0.8525568",
"0.8476073",
"0.8432505",
"0.811207",
"0.8111951",
"0.79742056",
"0.7967393",
"0.7931208",
"0.7835071",
"0.7778211",
"0.7645673",
"0.7638049",
"0.75317097",
"0.7366997",
"0.7344222",
"0.7333957",
"0.7017911",
"0.6752469",
"0.66835386",
"0.65300155",... | 0.95934916 | 0 |
The model function represented by a sum of the Gaussian functions with variable positions, widths and amplitudes | def modelfun1(self, x, *par):
g = np.zeros(len(x[0]))
for j in range(len(par)/5):
x1 = par[j*5]
x2 = par[j*5+1]
x3 = par[j*5+2]
w = par[j*5+3]
a = par[j*5+4]
r1 = pow((x[0]-x1), 2)+pow((x[1]-x2), 2)+pow((x[2]-x3), 2)
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Gaussian(x, mu=0, sigma=26.4, A=1, y0=0):\r\n #width = sigma*(2*np.sqrt(2*np.log(2)))\r\n b = 1/(sigma*np.sqrt(2*np.pi))\r\n f = b*np.power(np.e, -(((x-mu)**2)/(2*sigma**2)))\r\n return A*f + y0",
"def gaussian(x, *parameters):\n position, sigma, amplitude, background = parameters\n return ... | [
"0.66367567",
"0.6560433",
"0.65372294",
"0.653147",
"0.646325",
"0.6463125",
"0.6366298",
"0.63595486",
"0.6355874",
"0.6349452",
"0.6348714",
"0.63399464",
"0.6332683",
"0.62884027",
"0.62640566",
"0.62518823",
"0.6249206",
"0.6184604",
"0.6174887",
"0.6136336",
"0.6109296"... | 0.5969462 | 42 |
Computes the value of the wave function in points stored in the vector x using fitting parameters and the model functions. | def show_func(self, x):
if (self._flag == 1):
g = self.modelfun(x, *self._gf)
elif (self._flag == 2):
g = self.modelfun1(x, *self._gf)
elif ((self._flag == 0) & (self._load != '0')):
pass
else:
# pass
sys.exit("Wrong flag in do... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wavefunction(self, x):\n return ( float(1) / math.pi**(float(1)/4)) * math.exp( x**2 / float(-2))",
"def f(self, x: np.array) -> float:\n return np.dot(x, self._w) + self._b",
"def get_value(self, x):\n return np.dot(self.w, x)",
"def __call__(self, x):\n if self.W.data is Non... | [
"0.7227406",
"0.68093836",
"0.6625069",
"0.6607957",
"0.6584455",
"0.64573056",
"0.6423362",
"0.6364259",
"0.63284844",
"0.6268312",
"0.6254425",
"0.61995685",
"0.61708206",
"0.61386824",
"0.61219203",
"0.61038744",
"0.6098201",
"0.6074191",
"0.605777",
"0.6016525",
"0.601011... | 0.0 | -1 |
Derivative of objective function | def func_deriv(x,remain):
#df_x0 = -1*remain[0]/x[0]**2
#df_x1 = -1*remain[2]/x[1]**2
#df_x2 = -1*remain[1]/x[2]**2
return np.array(-1*remain/x**2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deriv(self, x, d=None):\n if self.weights is None:\n self.compute_weights()\n\n val = 0.0\n for i in range(self.M):\n val += self.weights[i]*self.model_list[i].deriv(x, d)\n return val",
"def objective_function_derivative(\n terms,\n overlap_penalty,\n ... | [
"0.695038",
"0.6901204",
"0.68689436",
"0.67938876",
"0.67433965",
"0.6723132",
"0.6718581",
"0.67118424",
"0.6699861",
"0.6609691",
"0.6604677",
"0.66040355",
"0.6575055",
"0.65495205",
"0.65025395",
"0.64683104",
"0.6449893",
"0.6427921",
"0.6427921",
"0.64193326",
"0.64159... | 0.60648674 | 59 |
First test of the spin ID generation function. The function tested is pipe_control.mol_res_spin.generate_spin_id_data_array(). | def test_generate_spin_id_data_array1(self):
# The data.
data = ['1', 'GLY']
# The ID.
id = mol_res_spin.generate_spin_id_data_array(data, res_num_col=1, res_name_col=2)
# Test the string.
self.assertEqual(id, ':1') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_generate_spin_id_data_array6(self):\n\n # The data.\n data = ['1', 'GLY', None, None]\n\n # The ID.\n id = mol_res_spin.generate_spin_id_data_array(data, res_num_col=1, res_name_col=2)\n\n # Test the string.\n self.assertEqual(id, ':1')",
"def test_generate_spin... | [
"0.78925526",
"0.7822347",
"0.76349664",
"0.7610406",
"0.75354004",
"0.6579472",
"0.60722893",
"0.5760644",
"0.5730065",
"0.5698617",
"0.5577793",
"0.55716354",
"0.554988",
"0.55279154",
"0.5508247",
"0.5425098",
"0.5357982",
"0.53330165",
"0.52789444",
"0.527686",
"0.527214"... | 0.8076779 | 0 |
Test the function for returning the desired molecule data container. The function tested is pipe_control.mol_res_spin.return_molecule(). | def test_return_molecule(self):
# Ask for a few molecules.
mol1 = mol_res_spin.return_molecule('#Ap4Aase')
mol2 = mol_res_spin.return_molecule(selection='#RNA', pipe='orig')
# Test the data of molecule 1.
self.assertEqual(mol1.name, 'Ap4Aase')
# Test the data of molecu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_return_molecule_pipe_fail(self):\n\n # Try to get a molecule from a missing data pipe.\n self.assertRaises(RelaxNoPipeError, mol_res_spin.return_molecule, selection='#Ap4Aase', pipe='new')\n self.assertRaises(RelaxNoPipeError, mol_res_spin.return_molecule, selection='#RNA', pipe='new'... | [
"0.63652605",
"0.636043",
"0.6196237",
"0.61398995",
"0.6118704",
"0.59954035",
"0.5866117",
"0.5800223",
"0.57261777",
"0.56701607",
"0.56608844",
"0.55993",
"0.5499727",
"0.5499299",
"0.5475103",
"0.5424967",
"0.53821063",
"0.53715503",
"0.5311273",
"0.5283148",
"0.5275008"... | 0.82855994 | 0 |
Test the failure of the function for returning the desired molecule data container. The function tested is pipe_control.mol_res_spin.return_molecule(). | def test_return_molecule_pipe_fail(self):
# Try to get a molecule from a missing data pipe.
self.assertRaises(RelaxNoPipeError, mol_res_spin.return_molecule, selection='#Ap4Aase', pipe='new')
self.assertRaises(RelaxNoPipeError, mol_res_spin.return_molecule, selection='#RNA', pipe='new') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_return_molecule(self):\n\n # Ask for a few molecules.\n mol1 = mol_res_spin.return_molecule('#Ap4Aase')\n mol2 = mol_res_spin.return_molecule(selection='#RNA', pipe='orig')\n\n # Test the data of molecule 1.\n self.assertEqual(mol1.name, 'Ap4Aase')\n\n # Test the ... | [
"0.7752265",
"0.6388569",
"0.6297495",
"0.6286569",
"0.62686867",
"0.6196573",
"0.6173113",
"0.617114",
"0.6123175",
"0.60926574",
"0.59676576",
"0.5883313",
"0.587805",
"0.5837631",
"0.58120954",
"0.577729",
"0.5614546",
"0.56138414",
"0.56082726",
"0.55601",
"0.55297875",
... | 0.75012517 | 1 |
Test the proper operation of the spin loop when no data pipe is present. The function tested is pipe_control.mol_res_spin.spin_loop(). | def test_spin_loop_no_pipe(self):
# Reset relax.
reset()
# Function for the problem of catching an error in a generator function.
def fail_test():
for spin in mol_res_spin.spin_loop():
pass
# Test for the no pipe error.
self.assertRaises(Rel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_spin_loop_no_data(self):\n\n # Reset relax.\n reset()\n\n # Add a data pipe to the data store.\n ds.add(pipe_name='orig', pipe_type='mf')\n\n # Loop over the spins.\n i = 0\n for spin in mol_res_spin.spin_loop():\n i = i + 1\n\n # Test loo... | [
"0.8414788",
"0.7601054",
"0.7113457",
"0.7043407",
"0.7001332",
"0.673422",
"0.66587317",
"0.653782",
"0.64508295",
"0.6446371",
"0.62323546",
"0.5766039",
"0.5760466",
"0.57546294",
"0.5717464",
"0.5711903",
"0.57100135",
"0.5633577",
"0.5567761",
"0.55639905",
"0.55532223"... | 0.83668333 | 1 |
Return region field as a representation. | def to_representation(self, instance):
return instance.region | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def region(self):\n # type: () -> string_types\n return self._region",
"def region(self) -> str:\n return self.__region",
"def __repr__(self: RcnRegion) -> str:\n return f\"RcnRegion.{self.name}\"",
"def region(self):\n return self._region",
"def region(self):\n re... | [
"0.6821899",
"0.6763117",
"0.67216176",
"0.6716908",
"0.6716908",
"0.6671237",
"0.6656148",
"0.6619242",
"0.6594691",
"0.65667427",
"0.6521952",
"0.65041155",
"0.65041155",
"0.65041155",
"0.65041155",
"0.65041155",
"0.65041155",
"0.6379895",
"0.63188833",
"0.63188833",
"0.631... | 0.7870258 | 0 |
Raises ValidationError if the given list of working hours is empty, the list otherwise. | def validate_working_hours(self, value):
if len(value) == 0:
raise ValidationError('List should not be empty.')
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_delivery_hours(self, value):\n\n if len(value) == 0:\n raise ValidationError('List should not be empty.')\n return value",
"def save_hours(validated_data):\n\n for w_h in validated_data['working_hours']:\n new_w_h = WorkingHoursSerializer(data={\n ... | [
"0.7269126",
"0.6866808",
"0.6861681",
"0.67966706",
"0.6211005",
"0.6202418",
"0.59814394",
"0.58779675",
"0.5871235",
"0.57033545",
"0.5618451",
"0.55920196",
"0.5522947",
"0.5502552",
"0.5354208",
"0.5335648",
"0.52977383",
"0.525785",
"0.5205049",
"0.52016556",
"0.5159868... | 0.8444958 | 0 |
Raises ValidationError if the given list of delivery hours is empty, the list otherwise. | def validate_delivery_hours(self, value):
if len(value) == 0:
raise ValidationError('List should not be empty.')
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_working_hours(self, value):\n\n if len(value) == 0:\n raise ValidationError('List should not be empty.')\n return value",
"def save_hours(validated_data):\n\n for d_h in validated_data['delivery_hours']:\n new_d_h = DeliveryHoursSerializer(data={\n ... | [
"0.70854056",
"0.6905043",
"0.6794095",
"0.66818875",
"0.631159",
"0.58860403",
"0.58774155",
"0.56794053",
"0.5401232",
"0.53009903",
"0.52992254",
"0.5283572",
"0.52385384",
"0.52176595",
"0.51481444",
"0.5120775",
"0.5075307",
"0.506215",
"0.505264",
"0.5031269",
"0.501651... | 0.83690053 | 0 |
Mark given order as completed and increases related courier's earning if current delivery is over. | def create(self, validated_data):
order_obj = Order.objects.get(order_id=validated_data['order_id'])
order_obj.complete_time = validated_data['complete_time']
order_obj.save()
# if current delivery is over, add earnings
if not Order.objects.filter(courier_id=order_obj.courier_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_completed(self, order_id=None):\n self.status = \"paid\"\n if order_id and not self.order_id:\n self.order_id = order_id\n print(\"Order completed\")\n self.save()",
"def order_finish(self):\r\n logger.info(f'Remaining qty:{self.quantity-self.filled_quantity... | [
"0.7115944",
"0.65188056",
"0.63519084",
"0.6026853",
"0.59948623",
"0.5960341",
"0.58357316",
"0.57971895",
"0.56998575",
"0.56283593",
"0.5623195",
"0.5612759",
"0.5612759",
"0.5612759",
"0.5559784",
"0.5555224",
"0.55308384",
"0.5526902",
"0.55223775",
"0.5503282",
"0.5503... | 0.5629139 | 9 |
Returns a single entry in the generated dataset. Return a bunch of random values as an example. | def row_generator(x, H, W, C):
return {'frame_id': x,
'frame_data': np.random.randint(0, 10,
dtype=np.uint8, size=(H, W, C))} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRandom(self):\n \n return self.data[random.randint(0, len(self.data) - 1)]",
"def getRandom(self):\n return random.choice(self.data)",
"def randomRow(self):\r\n l = []\r\n for row in self.data:\r\n l.append(row)\r\n return random.choice(l)",
"def ge... | [
"0.6710937",
"0.6699718",
"0.6537949",
"0.64686054",
"0.6440445",
"0.6439815",
"0.6246304",
"0.62280905",
"0.61741596",
"0.6161315",
"0.6138543",
"0.61140835",
"0.6086445",
"0.60771036",
"0.6075611",
"0.6065098",
"0.6062155",
"0.6038981",
"0.6028018",
"0.60002375",
"0.5990621... | 0.0 | -1 |
Converts lightfield to np.uint8 with a white background and no alpha channel. | def convert_lf(self, lf):
lf = np.float32(lf)
if np.max(lf) > 1:
lf = lf/256
lf = np.uint8(lf*256)
if lf.shape[-1] > 3:
lf[lf[:,:,:,:,3] == 0] = (255,255,255,0) #convert alpha to white.
lf = lf[:,:,:,:,:3]
# while lf.ndim < 6:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_uint8(f):\n from numpy import array, clip, uint8\n\n img = array(clip(f,0,255),uint8)\n return img",
"def to_uint8(image):\n\tnp.clip(image, 0, 255, out=image)\n\treturn image.astype(np.uint8)",
"def float32_to_uint8(inputs):\n return np.uint8(np.clip(np.round(inputs * 255), 0, 255))",
"de... | [
"0.68301535",
"0.66983664",
"0.65882623",
"0.64155966",
"0.594869",
"0.592428",
"0.5862508",
"0.5862508",
"0.5721261",
"0.57063997",
"0.5657134",
"0.56439483",
"0.5588113",
"0.5578203",
"0.5555673",
"0.55530274",
"0.54991704",
"0.54975706",
"0.5489271",
"0.54839927",
"0.54407... | 0.6405364 | 4 |
visualisation of the input image interest points | def viz1(img, interest_points, color='r'):
x = [a[1] for a in interest_points] #blob detection x axis
y = [a[0] for a in interest_points] #blob detection y axis
s = [a[2] for a in interest_points] #blob detected at sigma
plt.imshow(img, cmap='gray') #adding the input image to plot
for x, y, s in zip(x, y, s)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_image_sequence(self):\r\n\r\n imv = pg.ImageView()\r\n\r\n imv.show()\r\n\r\n imv.setImage(self.imageData)\r\n\r\n self.layout.addWidget(imv, 0, 0)\r\n\r\n\r\n\r\n avgImage = np.mean(self.imageData, axis=0)\r\n\r\n ima = pg.ImageView()\r\n\r\n ima.setImage(... | [
"0.640478",
"0.63847405",
"0.63375556",
"0.6287032",
"0.62815773",
"0.62655914",
"0.62209034",
"0.6200891",
"0.6193365",
"0.61490846",
"0.6137267",
"0.6074347",
"0.60507184",
"0.6024846",
"0.6012585",
"0.6002759",
"0.59989774",
"0.5996514",
"0.5971851",
"0.59677815",
"0.59248... | 0.7920742 | 0 |
Return string representation of the date in the format YYYYMMDD. | def __str__(self):
# year, formatted unambiguously as YYYY, padded with zeros if not
# four-digit
yearString = "0" * (4 - len(str(self.get_year()))
) + str(self.get_year())
# month, formatted unambiguously as MM, padded with zeros if not
# two-digit
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_string(date):\n day = date.day\n month = date.month\n year = date.year\n formatted_string = str(month) + \"/\"\n formatted_string += str(day) + \"/\"\n formatted_string += str(year)\n return formatted_string",
"def date_to_final_str(date_obj: datetime) -> str:\n return date_o... | [
"0.7660189",
"0.75144106",
"0.74433655",
"0.742128",
"0.7315453",
"0.7315453",
"0.7257465",
"0.7158602",
"0.7029121",
"0.7015154",
"0.6990911",
"0.6990911",
"0.6988908",
"0.69664764",
"0.696561",
"0.6931559",
"0.68857795",
"0.6883072",
"0.6860537",
"0.6855554",
"0.68550855",
... | 0.7288755 | 6 |
Given another date, find out how many days passed since this date. | def days_since(self, otherDate):
# initialize days passed
days = 0
# time difference of the year
yearDiff = otherDate.get_year() - self.get_year()
days += yearDiff * 365
# if other date is in the future, traverse forwards otherwise go
# backwards
if yearDi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def datediff_today(date):\n today = datetime.date.today()\n datediff = (today - date).days\n return datediff",
"def diff_dates(date1, date2):\n\n return abs(date2 - date1).days",
"def _get_number_of_days(self, date_from, date_to):\n\n DATETIME_FORMAT = \"%Y-%m-%d %H:%M:%S\"\n from_dt ... | [
"0.7271025",
"0.71568805",
"0.69931793",
"0.687202",
"0.6865785",
"0.68303543",
"0.6826376",
"0.68105143",
"0.6737072",
"0.67137754",
"0.6684774",
"0.6589549",
"0.6587052",
"0.6512795",
"0.65027285",
"0.647871",
"0.64774734",
"0.6458868",
"0.64533335",
"0.6426467",
"0.6415163... | 0.7558373 | 0 |
Test when branch is not master | def test_multiple_branches(self, tmpgitdir):
with tmpgitdir.join('file_a.txt').open('w') as handle:
handle.write('first file')
subprocess.check_call(['git', 'add', '.'])
subprocess.check_call(['git', 'commit', '-m', 'first'])
subprocess.check_call(['git', 'checkout', '-b', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_default_repo_branch(self):\n # network may be unavailable, but we are not interested anyway,\n # so we ignore the exitcode\n output = self.run_command(\"selfupdate --check\", exitcode=None)\n self.assertIn(\"Target: ywangd:master\", output)\n self.assertNotIn(\"Target: y... | [
"0.74963045",
"0.7121406",
"0.68485004",
"0.68422204",
"0.6797293",
"0.67708224",
"0.66588646",
"0.65996534",
"0.65641767",
"0.6491489",
"0.6479997",
"0.64630324",
"0.636714",
"0.6359062",
"0.63192993",
"0.63192993",
"0.6304544",
"0.62983483",
"0.6282403",
"0.6232887",
"0.622... | 0.0 | -1 |
Ensure that a commit directly before another is correctly identified as an ancestor, and that the child is identified as not an ancestor | def test_two_commits(self, tmpgitdir):
with tmpgitdir.join('file_a.txt').open('w') as handle:
handle.write('first file')
subprocess.check_call(['git', 'add', '.'])
subprocess.check_call(['git', 'commit', '-m', 'first'])
first_hash = subprocess.check_output(
['git... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lint_commit_base(commit):\n success = True\n # Merge commits have two parents, we maintain a linear history.\n if len(commit.parents) > 1:\n error(\n \"Please resolve merges by re-basing. Merge commits are not allowed.\",\n commit)\n success = False\n\n return su... | [
"0.64292395",
"0.6359155",
"0.63076717",
"0.6198901",
"0.61818206",
"0.6159696",
"0.61231625",
"0.6046435",
"0.59505606",
"0.5904542",
"0.58570373",
"0.5819268",
"0.5811302",
"0.5809034",
"0.57591075",
"0.57033724",
"0.5699567",
"0.56659716",
"0.5589706",
"0.5573943",
"0.5563... | 0.5652296 | 18 |
add RZ gate (rotation around Zaxis). | def rz(self, q0, phase=DEF_PHASE, ctrl=None):
self.__add_quantum_gate(kind=ROTATION_Z, qid=[q0], phase=phase, ctrl=ctrl)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rz(self, phi, q): # pylint: disable=invalid-name\n return self.append(RZGate(phi), [q], [])",
"def rotateZ(self, *args, **kwargs):\n ...",
"def _r_z(angle: tf.Tensor) -> tf.Tensor:\n zero = tf.constant(0, dtype=tf.float64)\n exponent = tf.complex(zero, angle)\n exp = tf.exp(... | [
"0.70971054",
"0.6867665",
"0.6615164",
"0.65454346",
"0.654375",
"0.647146",
"0.64289933",
"0.64135015",
"0.6400951",
"0.62438506",
"0.62215066",
"0.6033293",
"0.6030118",
"0.60268694",
"0.60091794",
"0.5993204",
"0.5962274",
"0.59318596",
"0.590546",
"0.5898538",
"0.5860597... | 0.6309543 | 9 |
add P gate (phase shift gate). | def p(self, q0, phase=DEF_PHASE, ctrl=None):
self.__add_quantum_gate(kind=PHASE_SHIFT, qid=[q0], phase=phase, ctrl=ctrl)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, p):\n self._pumps.add(p)",
"def __add__(self, p: np.ndarray):\n return Quaternion(self.to_array() + p)",
"def Add(p, q):\n return p*q",
"def point_addition(self, P, Q):\n\t\traise Exception(NotImplemented)",
"def PLP(self, *_):\n self.reg.P = self.pop()",
"def update... | [
"0.6318269",
"0.59578127",
"0.5915731",
"0.5825227",
"0.5744571",
"0.5720372",
"0.5641655",
"0.559485",
"0.55680496",
"0.55604863",
"0.546399",
"0.5454236",
"0.5415402",
"0.53876317",
"0.5367949",
"0.52692",
"0.5242477",
"0.5239249",
"0.5235476",
"0.52338487",
"0.5204293",
... | 0.61503357 | 1 |
add CRZ gate (controlled RZ gate). | def crz(self, q0, q1, phase=DEF_PHASE, ctrl=None):
self.__add_quantum_gate(kind=CONTROLLED_RZ, qid=[q0,q1], phase=phase, ctrl=ctrl)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crz(self, theta, ctl, tgt):\n return self.append(CrzGate(theta), [ctl, tgt], [])",
"def __init__(self, theta):\n super().__init__(\"crz\", 2, [theta], num_ctrl_qubits=1)\n self.base_gate = RZGate(theta)",
"def rz(self, phi, q): # pylint: disable=invalid-name\n return self.append(RZGate... | [
"0.6958848",
"0.61419284",
"0.6064584",
"0.56396747",
"0.5535329",
"0.5404921",
"0.5390143",
"0.53515494",
"0.5310394",
"0.52780074",
"0.5277078",
"0.5226025",
"0.5192308",
"0.5169303",
"0.5124667",
"0.5121535",
"0.5059638",
"0.5004625",
"0.4980288",
"0.49734604",
"0.49685302... | 0.66018766 | 1 |
add CU3 gate (controlled U3 gate). | def cu3(self, q0, q1, alpha=DEF_PHASE, beta=DEF_PHASE, gamma=DEF_PHASE, ctrl=None):
self.__add_quantum_gate(kind=CONTROLLED_U3, qid=[q0,q1], phase=alpha, phase1=beta,
phase2=gamma, ctrl=ctrl)
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def u3(self, q0, alpha=DEF_PHASE, beta=DEF_PHASE, gamma=DEF_PHASE, ctrl=None):\n self.__add_quantum_gate(kind=ROTATION_U3, qid=[q0], phase=alpha, phase1=beta,\n phase2=gamma, ctrl=ctrl)\n return self",
"def test_special_U3(self):\n self.check_oneq_special_cases... | [
"0.6172833",
"0.60709476",
"0.59816235",
"0.597661",
"0.58950996",
"0.5756811",
"0.57265884",
"0.56782377",
"0.5533537",
"0.54784715",
"0.54042715",
"0.53975767",
"0.5389443",
"0.5381317",
"0.5351581",
"0.5308488",
"0.52944463",
"0.5283771",
"0.5253617",
"0.5241266",
"0.52193... | 0.69713616 | 0 |
Wrapper for dot product operation, in order to be compatible with both Theano and Tensorflow | def dot_product(x, kernel):
if K.backend() == 'tensorflow':
# todo: check that this is correct
return K.squeeze(K.dot(x, K.expand_dims(kernel)), axis=-1)
else:
return K.dot(x, kernel) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dot_prod(t1: torch.Tensor, t2: torch.Tensor, verbose: bool = False):\n assert t1.size() == t2.size(), \"Sizes for dot-product must match\"\n return mo.dot_prod(t1, t2, verbose)",
"def _dot(a, b):\n return np.einsum('ijk,ikl->ijl', a, b)",
"def dot(a, b):\r\n a, b = as_tensor_variable(a), as_ten... | [
"0.7651723",
"0.76122725",
"0.75896275",
"0.75178",
"0.74978065",
"0.74902385",
"0.74902385",
"0.74902385",
"0.74902385",
"0.7466889",
"0.74378735",
"0.7429341",
"0.7418364",
"0.73810273",
"0.7376632",
"0.7343613",
"0.7331493",
"0.73104995",
"0.7309816",
"0.72749436",
"0.7270... | 0.7535402 | 3 |
Returns path (relative to MEDIA_ROOT/MEDIA_URL) to directory for storing pagescope files. This allows multiple pages to contain files with identical names without namespace issues. Plugins such as Picture can use this method to initialise the 'upload_to' parameter for | def get_media_path(self, filename):
return join(settings.CMS_PAGE_MEDIA_PATH, "%d" % self.id, filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_dir(self):\n return os.path.join(settings.MEDIA_ROOT,self.upload_dir_rel())",
"def public_upload_dir(self):\n return os.path.join(settings.MEDIA_ROOT,\n self.public_upload_dir_rel())",
"def get_upload_path(instance, filename):\n return os.path.join(getattr... | [
"0.75417954",
"0.7337136",
"0.69482565",
"0.6842317",
"0.6789822",
"0.6673382",
"0.6609158",
"0.66040426",
"0.6584662",
"0.63800055",
"0.6354606",
"0.6346663",
"0.6338599",
"0.6182578",
"0.61359954",
"0.6135264",
"0.6113495",
"0.60989684",
"0.6035798",
"0.60146284",
"0.599824... | 0.6443212 | 9 |
viewfunction for home view | def home() -> 'html':
if request.method == 'POST':
# check if the http request was a post request
# the following if statements check which of the close buttons was clicked
# in order to delete the notification
if request.form.get('close-vacation'):
req_id = request.form... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(request):\n\treturn render(request, \"compta/home.html\")",
"def home(self, *args, **kwargs):\n pass",
"def home(request):\r\n return render(request, 'home.html')",
"def feature_view_home(request):\n return render(request, 'SNP_Feature_View/feature_view_home.html')",
"def home(request... | [
"0.7883946",
"0.7870451",
"0.7797532",
"0.7665668",
"0.7648475",
"0.76462525",
"0.7611321",
"0.7597093",
"0.7572959",
"0.7529134",
"0.7512292",
"0.7511995",
"0.750166",
"0.7486506",
"0.7486506",
"0.7486506",
"0.7486506",
"0.7486506",
"0.7486506",
"0.7486506",
"0.7486506",
"... | 0.0 | -1 |
Convert miles per imperial gallon into kilometers per liter. | def miles_per_gallon_to_kilometers_per_liter(miles_per_gallon):
converted_value = miles_per_gallon * ONE_MILE_IN_KILOMETERS / ONE_IMP_GALLON_IN_LITERS
return round(converted_value, 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def miles_to_kilometers(miles):\n #convert miles to km:\n return miles*1.60934",
"def miles_to_kilometers(miles: float) -> float:\n mile = float(miles)\n kilometers = float(float(mile) * 1.60934)\n return round(kilometers, 2)",
"def kilometers_to_miles(km):\n #convert km to miles:\n return... | [
"0.810501",
"0.77146244",
"0.7660003",
"0.7547199",
"0.7521227",
"0.7105088",
"0.7034444",
"0.6854184",
"0.6576829",
"0.6553181",
"0.6421252",
"0.6299841",
"0.62697154",
"0.6260179",
"0.6246678",
"0.62450707",
"0.6243071",
"0.6237388",
"0.6223361",
"0.6187523",
"0.6170195",
... | 0.81636584 | 0 |
Convert a name into initials | def abbrev_name(name):
arr = name.split()
if len(arr) == 2:
anw = arr[0][0] + "." + arr[1][0]
result = anw.upper()
else:
result = None
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_initials(name, force_upper=True):\r\n if force_upper:\r\n return name[0:1].upper()\r\n return name[0:1]",
"def initials(full_name):\r\n\r\n if full_name is not None and len(full_name) > 0:\r\n return ''.join([s[0] for s in full_name.split(' ')]).upper()\r\n else:\r\n retu... | [
"0.8376018",
"0.81219697",
"0.7692363",
"0.7692363",
"0.7692363",
"0.7686876",
"0.76175344",
"0.7615349",
"0.7572603",
"0.74991775",
"0.7491891",
"0.74680877",
"0.74660325",
"0.73977965",
"0.73952067",
"0.7293612",
"0.72790784",
"0.7277742",
"0.7218639",
"0.7168545",
"0.71612... | 0.694311 | 35 |
Returns a new Wall mirrored over the middle of the lanes. | def mirror(self):
newRot = [x for x in self.rot]
newRot[1] = -newRot[1]
newLRot = [x for x in self.lrot]
newLRot[1] = -newLRot[1]
newLRot[2] = -newLRot[2]
return Wall(self.beat, self.dur, -self.r, -self.l, self.d, self.u, newRot, newLRot) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def north_wall(self, x, y, z, width=10, length=10, height=10, details=None, name=\"wall\", mergeshape=None):\r\n global wallnum\r\n n = z + width / 2\r\n s = z - width / 2\r\n e = x + length / 2\r\n w = x - length / 2\r\n\r\n nwall = SolidObject(name+str(wallnum), Size(length, height, 1), Positio... | [
"0.63168657",
"0.63059783",
"0.6195468",
"0.6179768",
"0.6068646",
"0.60602653",
"0.60175794",
"0.5983031",
"0.59415644",
"0.59131116",
"0.5791608",
"0.5791608",
"0.5719669",
"0.569298",
"0.568444",
"0.566718",
"0.5666786",
"0.56274647",
"0.5609347",
"0.55890185",
"0.5540185"... | 0.7466312 | 0 |
Instantiate an environment wrapped to be compatible with stackrl.Training. | def make(
env='Stack-v0',
n_parallel=None,
block=None,
curriculum=None,
unwrapped=False,
as_path=False,
**kwargs,
):
if curriculum:
return make_curriculum(
env,
n_parallel=n_parallel,
block=block,
curriculum=curriculum,
unwrapped=unwrapped,
as_path=as_path,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_environment(\n evaluation: bool = False,\n task: str = 'MountainCarContinuous-v0') -> dm_env.Environment:\n del evaluation\n\n # Load the gym environment.\n environment = gym.make(task)\n\n # Make sure the environment obeys the dm_env.Environment interface.\n environment = wrappers.GymWrapper(e... | [
"0.69595337",
"0.6858885",
"0.6837624",
"0.67771894",
"0.6776568",
"0.66850716",
"0.6674813",
"0.6640321",
"0.6640321",
"0.65623885",
"0.6454325",
"0.6391635",
"0.63682014",
"0.6335106",
"0.6326718",
"0.6305858",
"0.63046753",
"0.62897015",
"0.62835145",
"0.6258138",
"0.62372... | 0.56070113 | 91 |
Loads and parses a YAML configuration file. | def load_config(path="configs/default.yaml") -> dict:
with open(path, "r", encoding="utf-8") as ymlfile:
cfg = yaml.safe_load(ymlfile)
return cfg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_from_yaml(self) -> Dict:\n config_path = path.join(path.dirname(path.abspath(__file__)), self.config_file)\n try:\n with open(config_path, \"r\") as f:\n config_dict = yaml.load(f, Loader=yaml.FullLoader)\n return config_dict\n except FileNotFoundError as fnfe:\n raise F... | [
"0.7902378",
"0.7885701",
"0.78658706",
"0.78286827",
"0.77730346",
"0.7747524",
"0.77428514",
"0.77232844",
"0.7719344",
"0.77055913",
"0.7682004",
"0.7681451",
"0.7674585",
"0.7672605",
"0.7634164",
"0.7608393",
"0.7578547",
"0.75417423",
"0.75334585",
"0.74926627",
"0.7486... | 0.73542976 | 26 |
Returns the latest checkpoint (by time) from the given directory. If there is no checkpoint in this directory, returns None | def get_latest_checkpoint(ckpt_dir: str) -> Optional[str]:
list_of_files = glob.glob("{}/*.ckpt".format(ckpt_dir))
latest_checkpoint = None
if list_of_files:
latest_checkpoint = max(list_of_files, key=os.path.getctime)
return latest_checkpoint | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_latest_checkpoint(cls, experiment_path):\n checkpoints_path = os.path.join(experiment_path, cls.CHECKPOINT_DIR_NAME)\n all_times = sorted(os.listdir(checkpoints_path), reverse=True)\n return os.path.join(checkpoints_path, all_times[0])",
"def get_latest_checkpoint_path(dirpath: str) ... | [
"0.7700107",
"0.74362636",
"0.7350826",
"0.70492095",
"0.70353407",
"0.686673",
"0.6788162",
"0.6776815",
"0.6733546",
"0.67268467",
"0.66239303",
"0.64845854",
"0.64429843",
"0.640534",
"0.62015307",
"0.6133778",
"0.6057183",
"0.6019879",
"0.59937334",
"0.5984722",
"0.595231... | 0.8131056 | 0 |
Freeze the parameters of this module, i.e. do not update them during training | def freeze_params(module: nn.Module):
for _, p in module.named_parameters():
p.requires_grad = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def freeze(self):\n # Freeze.\n self.frozen = True\n for param in self.parameters():\n param.requires_grad = False",
"def __freeze(self):\r\n features_layer = self._model._net\r\n for param in features_layer.parameters():\r\n param.requires_grad = False",
... | [
"0.77948684",
"0.76171887",
"0.7449217",
"0.73946375",
"0.7314692",
"0.729194",
"0.72498846",
"0.7186831",
"0.70168376",
"0.69934535",
"0.69930685",
"0.6821718",
"0.68051827",
"0.6795892",
"0.6745624",
"0.6734002",
"0.67038447",
"0.66956234",
"0.66798335",
"0.6644752",
"0.664... | 0.73185027 | 4 |
Simulate a PUT request to an ASGI application. | async def simulate_put(self, path='/', **kwargs) -> _ResultBase:
return await self.simulate_request('PUT', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simulate_put(app, path, **kwargs) -> _ResultBase:\n return simulate_request(app, 'PUT', path, **kwargs)",
"def put(self, *args, **kwargs):\n self.request(\"put\", *args, **kwargs)",
"def do_PUT(self,):\n self.http_method = 'PUT'\n # Nothing to do for now.\n pass",
"def _put... | [
"0.8130414",
"0.72275764",
"0.7175433",
"0.71189624",
"0.6995265",
"0.69159925",
"0.69084567",
"0.68669564",
"0.68038714",
"0.6794044",
"0.6616889",
"0.6588042",
"0.6564535",
"0.65348846",
"0.65348846",
"0.65348846",
"0.65310556",
"0.6496377",
"0.6471326",
"0.6454387",
"0.645... | 0.69048744 | 7 |
Simulate a PATCH request to an ASGI application. | async def simulate_patch(self, path='/', **kwargs) -> _ResultBase:
return await self.simulate_request('PATCH', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simulate_patch(app, path, **kwargs) -> _ResultBase:\n return simulate_request(app, 'PATCH', path, **kwargs)",
"def patch(self, *args, **kwargs):\n self.request(\"patch\", *args, **kwargs)",
"def simulate_patch(self, path='/', **kwargs):\n return self.simulate_request('PATCH', path, **kwarg... | [
"0.8286581",
"0.7499736",
"0.73026884",
"0.70985633",
"0.70926195",
"0.7085156",
"0.6907411",
"0.6900558",
"0.68608654",
"0.6830805",
"0.6811523",
"0.68058413",
"0.6804034",
"0.673692",
"0.67207915",
"0.6695585",
"0.6695585",
"0.6695585",
"0.6695585",
"0.6695585",
"0.6695585"... | 0.7162519 | 3 |
Simulate a PUT request to a WSGI or ASGI application. | def simulate_put(app, path, **kwargs) -> _ResultBase:
return simulate_request(app, 'PUT', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_PUT(self,):\n self.http_method = 'PUT'\n # Nothing to do for now.\n pass",
"def put(self, *args, **kwargs):\n self.request(\"put\", *args, **kwargs)",
"def _put(self, *args, **kwargs):\n return self._request('put', *args, **kwargs)",
"def simulate_put(self, path='/',... | [
"0.7430654",
"0.7420765",
"0.7254375",
"0.72292215",
"0.7130859",
"0.7076189",
"0.70692164",
"0.7004767",
"0.696957",
"0.69484067",
"0.692274",
"0.69176435",
"0.68755746",
"0.683001",
"0.6824943",
"0.68128455",
"0.67805594",
"0.6752393",
"0.6752393",
"0.6752393",
"0.6705847",... | 0.82123727 | 0 |
Simulate a PATCH request to a WSGI or ASGI application. | def simulate_patch(app, path, **kwargs) -> _ResultBase:
return simulate_request(app, 'PATCH', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch(self, *args, **kwargs):\n self.request(\"patch\", *args, **kwargs)",
"def simulate_patch(self, path='/', **kwargs):\n return self.simulate_request('PATCH', path, **kwargs)",
"def test_client_can_do_patch_request(self):\n response = self.httpbin_4.test_requests_patch_method()\n ... | [
"0.77237695",
"0.7579202",
"0.74945503",
"0.7375038",
"0.7336147",
"0.71931046",
"0.709597",
"0.7059055",
"0.70421225",
"0.70336956",
"0.6954821",
"0.6954437",
"0.69469035",
"0.69469035",
"0.69469035",
"0.69469035",
"0.69469035",
"0.69469035",
"0.69469035",
"0.69469035",
"0.6... | 0.843222 | 0 |
Simulate a PUT request to a WSGI application. | def simulate_put(self, path='/', **kwargs) -> _ResultBase:
return self.simulate_request('PUT', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simulate_put(app, path, **kwargs) -> _ResultBase:\n return simulate_request(app, 'PUT', path, **kwargs)",
"def do_PUT(self,):\n self.http_method = 'PUT'\n # Nothing to do for now.\n pass",
"def put(self, *args, **kwargs):\n self.request(\"put\", *args, **kwargs)",
"def PUT(... | [
"0.7857318",
"0.695292",
"0.6949761",
"0.6900196",
"0.68887955",
"0.68399256",
"0.6778951",
"0.676933",
"0.6731947",
"0.668466",
"0.6678236",
"0.66361004",
"0.6608237",
"0.6584145",
"0.65096",
"0.65074146",
"0.65074146",
"0.65074146",
"0.64896715",
"0.6464989",
"0.64510846",
... | 0.65861607 | 13 |
Simulate a PATCH request to a WSGI application. | def simulate_patch(self, path='/', **kwargs) -> _ResultBase:
return self.simulate_request('PATCH', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simulate_patch(app, path, **kwargs) -> _ResultBase:\n return simulate_request(app, 'PATCH', path, **kwargs)",
"def patch(self, *args, **kwargs):\n self.request(\"patch\", *args, **kwargs)",
"def simulate_patch(self, path='/', **kwargs):\n return self.simulate_request('PATCH', path, **kwarg... | [
"0.8154428",
"0.73881894",
"0.72425157",
"0.7032009",
"0.69893557",
"0.69432026",
"0.6927841",
"0.68865746",
"0.68196744",
"0.67764145",
"0.6765585",
"0.67158455",
"0.66943085",
"0.66934305",
"0.6676714",
"0.6676714",
"0.6676714",
"0.6673792",
"0.66581106",
"0.66523695",
"0.6... | 0.69515896 | 5 |
Estimated CRF, transform irradiance L to RGB image. If `crf_table` is inverted, transform RGB image to irradiance L. | def camera_response_function(inputs, crf_table, max_val=1):
inputs_norm = np.clip(inputs / max_val, 0, 1)
quant = crf_table.shape[0] - 1
inputs_index = (inputs_norm * quant).astype('int32')
ret = []
for i in inputs_index.flatten():
ret.append(crf_table[i])
return np.reshape(ret, inputs.shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crf_refine(label,\n img,\n crf_theta_slider_value,\n crf_mu_slider_value,\n crf_downsample_factor,\n gt_prob):\n\n Horig = label.shape[0]\n Worig = label.shape[1]\n\n l_unique = np.unique(label.flatten())#.tolist()\n scale = 1+(5 * (np.array(img.shape).max() / 3000))\n logging.inf... | [
"0.543145",
"0.54256666",
"0.54248387",
"0.537617",
"0.5180758",
"0.5143052",
"0.50994086",
"0.5099363",
"0.5006858",
"0.49987954",
"0.49229413",
"0.49061176",
"0.4905395",
"0.48856765",
"0.48807964",
"0.48664606",
"0.4861298",
"0.48559242",
"0.48515674",
"0.48475456",
"0.483... | 0.52573466 | 4 |
Return a dict of this object, with keys in JSON format. | def address_revision_json(address_revision):
country_description = ''
if address_revision.country:
country_description = pycountry.countries.search_fuzzy(address_revision.country)[0].name
return {
'streetAddress': address_revision.street,
'streetAddressAdditio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json(self):\n return json.dumps(self, default=lambda o: o.__dict__,\n sort_keys=True, indent=4)",
"def to_json(self) -> Dict[str, Any]:\n return self.__dict__",
"def json(self):\n return {\n 'id': self.id,\n 'name': self.name\n }",
... | [
"0.8144109",
"0.8142001",
"0.8105588",
"0.796904",
"0.7954904",
"0.7867204",
"0.78586286",
"0.7856205",
"0.7856205",
"0.785492",
"0.785492",
"0.785492",
"0.7854319",
"0.7854319",
"0.7854319",
"0.783863",
"0.783863",
"0.783863",
"0.783863",
"0.7835416",
"0.7831754",
"0.78317... | 0.0 | -1 |
Return incorporation agreement from filing json. | def get_incorporation_agreement_json(filing):
return filing.json['filing']['incorporationApplication'].get('incorporationAgreement', {}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_agreement(self):\n pass",
"def agreements():\n pass",
"def reconcile_somef_data(data):\n out = {}\n for key, value in data.items():\n # for now, we are not exporting provenance keys. Ignore all keys like somef_provenance\n if \"somef\" not in key:\n ... | [
"0.56559736",
"0.55618954",
"0.5244109",
"0.5151223",
"0.5143148",
"0.5112683",
"0.5045774",
"0.49902293",
"0.4906993",
"0.48691648",
"0.48342612",
"0.4829858",
"0.48195443",
"0.48008758",
"0.478164",
"0.47634107",
"0.47534582",
"0.47188726",
"0.47175965",
"0.4712452",
"0.465... | 0.7839245 | 0 |
This is a helper function for alignment models for embeddings. This function returns an embedding for features[name] of size params.name_embed_size assuming a vocab size of params.name_vocab_size. features[feature_name] has to be an integer tensor of shape [batch_size, max_sequence_length]. | def embed(self, features, feature_name, params):
with tf.variable_scope("%s_embed" % feature_name):
embed_matrix = tf.get_variable("embedding_matrix",
[getattr(params, "%s_vocab_size" % feature_name),
getattr(params, "%s_embed_size" % feature_name)])
return tf.nn.embedding_look... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_embedding_layer(inputs_, vocab_size, embed_size):\n embedding = tf.Variable(tf.random_uniform((vocab_size, embed_size), -1, 1))\n embed = tf.nn.embedding_lookup(embedding, inputs_)\n \n return embed",
"def embed_features(batch, f_size):\n for f in range(Config.num_feature):\n ... | [
"0.6896678",
"0.66577274",
"0.6655466",
"0.6557072",
"0.6546917",
"0.6513097",
"0.6508412",
"0.6499041",
"0.648341",
"0.6480802",
"0.63810956",
"0.6362331",
"0.6333119",
"0.62890506",
"0.6286926",
"0.62582594",
"0.6158827",
"0.61498016",
"0.61458313",
"0.61418664",
"0.6091481... | 0.7802241 | 0 |
Split a large 1D array into smaller nonoverlapping arrays | def window_blocks(large_array, window_size):
y_size = large_array.shape[0]/window_size
blocks_array = large_array.reshape(y_size, window_size)
return blocks_array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_array(array, size):\n arrays = []\n while len(array) > size:\n pice = array[:size]\n arrays.append(pice)\n array = array[size:]\n arrays.append(array)\n return arrays",
"def split_into_subarrays_of_max_len(arr, max_len=44100):\n return np.split(arr, np.arange(max_len... | [
"0.71960866",
"0.6999235",
"0.69500226",
"0.69150746",
"0.68858933",
"0.67999125",
"0.67823654",
"0.67116314",
"0.66916007",
"0.6638905",
"0.6625901",
"0.6571622",
"0.65425587",
"0.65102327",
"0.649938",
"0.64914256",
"0.64729416",
"0.6355834",
"0.631842",
"0.63149273",
"0.62... | 0.6572632 | 11 |
Preprocessing resize image to 300x300 RGB | def PreProcessing(image):
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = cv2.resize(image, (300, 300))
# type conversion to UINT8
image = image.astype(np.uint8).copy()
return image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_image(image):\n image = resize(image)\n return image",
"def resize_128(img): \n return cv2.resize(img,(128,128))",
"def preprocessImage(img):\n shape = img.shape\n img = img[math.floor(shape[0]/4) : shape[0] - 25, 0:shape[1]]\n img = cv2.resize(img, (img_columns, img_rows), interp... | [
"0.75653034",
"0.73177403",
"0.72640413",
"0.72331154",
"0.7159523",
"0.71543556",
"0.7111782",
"0.7074421",
"0.7067297",
"0.70329565",
"0.7021435",
"0.7020356",
"0.6993711",
"0.69357604",
"0.6925325",
"0.68780726",
"0.68340766",
"0.6830349",
"0.6808554",
"0.6788847",
"0.6787... | 0.63632196 | 100 |
Perform a horizontal shift on all rows. Pass left=True for left and left=False for right. The grid will be changed inplace. | def push_all_rows(grid, left=True):
r = 0
for i,row in enumerate(grid):
grid[i], r_ = push_row(row, left)
r += r_
return r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_all_rows(grid, left=True):\n\tfor i,row in enumerate(grid):\n\t\tgrid[i] = push_row(row, left)",
"def swipeLeft (self) :\n rotated = Grid(np.rot90(np.rot90(np.rot90(self.grid))))\n self.grid = np.rot90(rotated.swipeBase())",
"def push_left (grid):\r\n \r\n for row in range (4):\r\n... | [
"0.6738422",
"0.6710681",
"0.6562622",
"0.65071034",
"0.64332944",
"0.63762164",
"0.62841797",
"0.6200166",
"0.617695",
"0.6172406",
"0.60970026",
"0.6096321",
"0.5997006",
"0.5983838",
"0.598277",
"0.5941541",
"0.59146863",
"0.58851564",
"0.58777547",
"0.58430284",
"0.583664... | 0.6371835 | 6 |
Return a list of coordinate pairs corresponding to empty cells. | def get_empty_cells(grid):
empty = []
for j,row in enumerate(grid):
for i,val in enumerate(row):
if not val:
empty.append((j,i))
return empty | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_empty_cells(grid):\n\tempty = []\n\tfor j,row in enumerate(grid):\n\t\tfor i,val in enumerate(row):\n\t\t\tif not val:\n\t\t\t\tempty.append((j,i))\n\treturn empty",
"def empty_cells(state):\r\n cells = []\r\n for x, row in enumerate(state):\r\n for y, cell in enumerate(row):\r\n ... | [
"0.82954764",
"0.8106722",
"0.7881721",
"0.78399885",
"0.7816201",
"0.7774224",
"0.76896685",
"0.7566796",
"0.75358933",
"0.7367822",
"0.7362139",
"0.7313527",
"0.72766584",
"0.7221659",
"0.7109574",
"0.7071009",
"0.7039268",
"0.6926364",
"0.6887955",
"0.68496126",
"0.6788944... | 0.82016677 | 1 |
Resets the player list | def resetPlayerList(self):
self.playerList = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clearList(self):\r\n self.players.clear()",
"def reset(self):\n self.board_cards = []\n self.position = -1\n self._reset_players()",
"def Reset(self): \r\n self.player_draws.clear()\r\n self.player_points.clear()\r\n self.num_players=0\r\n self.car... | [
"0.83051455",
"0.7911027",
"0.76908463",
"0.7556388",
"0.74714035",
"0.7445043",
"0.73784745",
"0.7369854",
"0.73216003",
"0.71424335",
"0.7129414",
"0.7110906",
"0.7039333",
"0.7008726",
"0.697688",
"0.6962779",
"0.69450843",
"0.6891331",
"0.6891331",
"0.68692124",
"0.683343... | 0.9049031 | 0 |
Sets the sales of this PaymentTerm. | def sales(self, sales):
self._sales = sales | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_sales_rep(self, sales_rep):\r\n self._sales_rep = sales_rep",
"def sells(self, sells):\n\n self._sells = sells",
"def sales(self):\n\n # Scalar to range (consider creating function for this)\n if np.isscalar(self.demand_decr):\n self.demand_decr = np.full((1, self... | [
"0.6126827",
"0.602496",
"0.56689394",
"0.5279737",
"0.5215819",
"0.5194685",
"0.51591015",
"0.4797136",
"0.47962275",
"0.47865313",
"0.47671393",
"0.4763767",
"0.4688577",
"0.46609876",
"0.46363702",
"0.46235058",
"0.46217558",
"0.46022666",
"0.45736754",
"0.45663998",
"0.45... | 0.8079007 | 0 |
Compute an npoint moving sum of the data in vector x. Result will have a length of len(x) (n1). Using loop avoids the accumulated errors that can result from using numpy.cumsum, though cumsum is (probably) faster. | def _smooth_sum(x, n):
m = len(x)
result = _np.zeros(m - (n-1))
for i in range(n):
result += x[i:(m-n+i+1)]
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def running_mean(x, N):\n cumsum = np.cumsum(np.insert(x, 0, 0)) \n return (cumsum[N:] - cumsum[:-N]) / float(N)",
"def running_mean(x, N):\n cumsum = np.cumsum(np.insert(x, 0, 0))\n return (cumsum[N:] - cumsum[:-N]) / float(N)",
"def moving_sum(x, back, forward):\n bs, n_heads_mono, n_h... | [
"0.6777347",
"0.66602695",
"0.6657788",
"0.6452437",
"0.6445342",
"0.64377373",
"0.639484",
"0.6387214",
"0.6319946",
"0.6303997",
"0.62510145",
"0.6246268",
"0.6218636",
"0.61660457",
"0.6135385",
"0.61169654",
"0.61049765",
"0.60991657",
"0.60791415",
"0.6040553",
"0.597721... | 0.65586084 | 3 |
Infers whether the target is in indices format or one_hot format. | def infer_target_type(input: torch.Tensor, targets: torch.Tensor) -> str:
if input.shape == targets.shape:
return 'one_hot'
elif input.ndim == targets.ndim + 1:
return 'indices'
else:
raise RuntimeError(f'Unable to infer indices or one_hot. Targets has shape {targets.shape}'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_targets_one_hot(input: torch.Tensor,\n targets: torch.Tensor,\n num_classes: Optional[int] = None) -> torch.Tensor:\n if infer_target_type(input, targets) == 'indices':\n # If the number of classes isn't specified, attempt to infer it from th... | [
"0.6951809",
"0.68581086",
"0.6681324",
"0.66152394",
"0.66152394",
"0.66152394",
"0.66152394",
"0.6578733",
"0.6549587",
"0.65139776",
"0.63884944",
"0.63483554",
"0.63066226",
"0.6301925",
"0.6278177",
"0.6259506",
"0.6223372",
"0.61686593",
"0.61447483",
"0.61230075",
"0.6... | 0.7429881 | 0 |
r"""Ensures that the targets are in a onehot format rather than an index format. | def ensure_targets_one_hot(input: torch.Tensor,
targets: torch.Tensor,
num_classes: Optional[int] = None) -> torch.Tensor:
if infer_target_type(input, targets) == 'indices':
# If the number of classes isn't specified, attempt to infer it from the input
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_one_hot(targets, num_classes):\n ret = np.zeros((num_classes, targets.shape[0]))\n ret[targets, np.arange(targets.size)] = 1\n return ret",
"def infer_target_type(input: torch.Tensor, targets: torch.Tensor) -> str:\n if input.shape == targets.shape:\n return 'one_hot'\n ... | [
"0.70892847",
"0.70067805",
"0.6761015",
"0.6672298",
"0.652522",
"0.64999425",
"0.6430373",
"0.62493813",
"0.62427723",
"0.6210333",
"0.6210333",
"0.6210333",
"0.6210333",
"0.616038",
"0.6130909",
"0.609137",
"0.6088862",
"0.60704434",
"0.6039818",
"0.60286826",
"0.6021816",... | 0.75631934 | 0 |
Converts a tensor of index class labels to a tensor of onehot class labels. | def _one_hot(tensor: torch.Tensor, num_classes: int = -1, dim: int = -1) -> torch.Tensor:
if not check_for_index_targets(tensor):
raise ValueError(f'tensor must be integer type, current type: {tensor.dtype}')
max_index = tensor.max() + 1
if num_classes == -1:
num_classes = int(max_index)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_one_hot(labels, num_classes):\n shape = labels.size()\n shape = shape + (num_classes,)\n one_hot = torch.FloatTensor(shape)\n one_hot.zero_()\n dim = 1 if len(shape) == 2 else 2\n one_hot.scatter_(dim, labels.unsqueeze(-1), 1)\n return one_hot",
"def to_onehot(labels: torch.Tensor, nu... | [
"0.84751815",
"0.8467954",
"0.8271096",
"0.8237347",
"0.82299304",
"0.81946796",
"0.81946796",
"0.81946796",
"0.81946796",
"0.8180447",
"0.8169154",
"0.8150191",
"0.8135966",
"0.8088832",
"0.808789",
"0.8087213",
"0.80652124",
"0.8063023",
"0.8018135",
"0.8018135",
"0.7935499... | 0.81189996 | 13 |
Distance between two atoms. | def dist_single(self, g_num, at_1, at_2):
# Import used math library function(s)
import numpy as np
from scipy import linalg as spla
from .utils import safe_cast as scast
# The below errors are explicitly thrown since values are multiplied by
# three when they are used... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(cls, atom_1, atom_2):\n\t\t\n\t\treturn np.linalg.norm((atom_1-atom_2).atom_loc)",
"def calculate_distance(atom1,atom2): #dot string to show when you go into the help doc of this function\n x_distance = atom1[0]-atom2[0]\n y_distance = atom1[1]-atom2[1]\n z_distance = atom1[2]-atom2[2]\n ... | [
"0.836802",
"0.7753284",
"0.76746625",
"0.75178355",
"0.74930346",
"0.74093235",
"0.73726875",
"0.7370857",
"0.7370857",
"0.7344016",
"0.7344016",
"0.73347074",
"0.7324276",
"0.7320211",
"0.7310314",
"0.7278829",
"0.7278765",
"0.7270829",
"0.7265909",
"0.72642666",
"0.7259381... | 0.0 | -1 |
Set up variables for the GrandCanonicalMonteCarloSampler | def setup_BaseGrandCanonicalMonteCarloSampler():
# Make variables global so that they can be used
global base_gcmc_sampler
global base_gcmc_simulation
pdb = PDBFile(utils.get_data_file(os.path.join('tests', 'bpti-ghosts.pdb')))
ff = ForceField('amber14-all.xml', 'amber14/tip3p.xml')
system = ff... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_setup(self):\n self.DNN = SganMLP(self.settings.number_of_bins)\n self.D = SganMLP(self.settings.number_of_bins)\n self.G = Generator()",
"def initialize(self):\n self.gc1.reset_parameters()\n self.gc2.reset_parameters()\n\n for s in self.scores:\n s... | [
"0.65247303",
"0.64355326",
"0.6290882",
"0.62845963",
"0.6265411",
"0.6215736",
"0.6098296",
"0.60891455",
"0.60858494",
"0.6080878",
"0.60772467",
"0.6068644",
"0.60400265",
"0.603621",
"0.60180527",
"0.6005577",
"0.59941375",
"0.5993957",
"0.59704316",
"0.59679365",
"0.595... | 0.72094464 | 0 |
Set up variables for the GrandCanonicalMonteCarloSampler | def setup_NonequilibriumGCMCSphereSampler():
# Make variables global so that they can be used
global neq_gcmc_sphere_sampler
global neq_gcmc_sphere_simulation
pdb = PDBFile(utils.get_data_file(os.path.join('tests', 'bpti-ghosts.pdb')))
ff = ForceField('amber14-all.xml', 'amber14/tip3p.xml')
sys... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_BaseGrandCanonicalMonteCarloSampler():\n # Make variables global so that they can be used\n global base_gcmc_sampler\n global base_gcmc_simulation\n\n pdb = PDBFile(utils.get_data_file(os.path.join('tests', 'bpti-ghosts.pdb')))\n ff = ForceField('amber14-all.xml', 'amber14/tip3p.xml')\n ... | [
"0.7211087",
"0.6525977",
"0.6435302",
"0.62915516",
"0.6284481",
"0.6267818",
"0.62182075",
"0.6098433",
"0.60890055",
"0.6088116",
"0.60806596",
"0.6079379",
"0.60685253",
"0.6040332",
"0.603551",
"0.6017087",
"0.60072273",
"0.599423",
"0.5993949",
"0.59701514",
"0.59502614... | 0.59698236 | 20 |
u"""Split StringList into list of StringList | def split_blocks(strings):
blocks = [StringList()]
for item in strings.xitems(): # (source, offset, value)
if item[2].strip():
blocks[-1].append(item[2], source=item[0], offset=item[1])
elif len(blocks[-1]):
blocks.append(StringList())
# remove the last block if empt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _split_input_list(str_list):\r\n\r\n new_list = re.split(r'[\\n\\r\\s,]', str_list)\r\n new_list = [s.strip() for s in new_list]\r\n new_list = [s for s in new_list if s != '']\r\n\r\n return new_list",
"def multiSplit(stringList, tokenList=[\" \"]):\r\n if not stringList: return []\r\n if ... | [
"0.7860924",
"0.71834123",
"0.71373975",
"0.6994113",
"0.69898045",
"0.69133914",
"0.6884402",
"0.6856875",
"0.68344647",
"0.68336713",
"0.67163867",
"0.67152244",
"0.67131823",
"0.6695745",
"0.6667128",
"0.6640036",
"0.6596695",
"0.6583621",
"0.65143436",
"0.6511531",
"0.650... | 0.0 | -1 |
u"""Join list of StringList to single StringList | def join_blocks(blocks):
strings = StringList()
for block in blocks:
strings.extend(block)
strings.extend(StringList([u''])) # insert a blank line
# remove the last blank line
if strings and not strings[-1]:
del strings[-1]
return strings | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_join(the_list):\n return ' '.join(the_list)",
"def join_list(items: Iterable[str]) -> str:\n\n return ITEM_SEPARATOR.join(items)",
"def list_string(join_list):\n joined_list = '[{}]'.format(join_list, join_list)\n return joined_list",
"def join_list(jlist, joiner=', '):\n if len(jlist... | [
"0.8205867",
"0.81064206",
"0.7733766",
"0.7700534",
"0.762689",
"0.7539793",
"0.74885464",
"0.7354173",
"0.7304979",
"0.7285159",
"0.7253279",
"0.7208964",
"0.72020966",
"0.71971995",
"0.7148965",
"0.7118522",
"0.7087361",
"0.7035065",
"0.7017025",
"0.6976172",
"0.6976172",
... | 0.0 | -1 |
Creates a DH rotation matrix for forward kinematics. | def rot(a, alpha, S, theta):
return np.array([ # eqn 3.7 pg 36
[cos(theta), -sin(theta), 0.0, a],
[sin(theta) * cos(alpha), cos(theta) * cos(alpha), -sin(alpha), -sin(alpha) * S],
[sin(theta) * sin(alpha), cos(theta) * sin(alpha), cos(alpha), cos(alpha) * S],
[0.0, 0.0, 0.0, 1.0]
])
# return np.array([ # ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dhMatrix(self):\n row1 = np.array([np.cos(self.theta), -np.sin(self.theta)*np.cos(self.alpha), np.sin(self.theta)*np.sin(self.alpha), self.a*np.cos(self.theta)])\n row2 = np.array([np.sin(self.theta), np.cos(self.theta)*np.cos(self.alpha), -np.cos(self.theta)*np.sin(self.alpha), self.a*np.sin(s... | [
"0.7027864",
"0.6109269",
"0.6107896",
"0.59823763",
"0.5921101",
"0.5783457",
"0.57613975",
"0.5735776",
"0.5721824",
"0.55084693",
"0.5489177",
"0.5487608",
"0.5457247",
"0.54503125",
"0.54430765",
"0.5437407",
"0.5428085",
"0.54130256",
"0.5402257",
"0.5370192",
"0.5362484... | 0.0 | -1 |
Load pretrained weights for the CNN from the specified path | def load_weights_file(self, file_path):
# Load the weights
self._cnn_model.load_weights(file_path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_pretrained_net_weights(net, ckpt_path):\n print(\"Loading Model: \", ckpt_path)\n print('')\n\n net.load_weights(ckpt_path).expect_partial()",
"def load_weights(self, path: str):\n self.load_state_dict(torch.load(path))",
"def load_weights(self, path: str):\n self.load_state_dic... | [
"0.7715949",
"0.7478819",
"0.7478819",
"0.74023044",
"0.7388873",
"0.7361498",
"0.73348725",
"0.73348725",
"0.7241301",
"0.72256935",
"0.71313363",
"0.69333124",
"0.69114554",
"0.69024783",
"0.6840412",
"0.6821405",
"0.6792394",
"0.6791614",
"0.67718136",
"0.67372996",
"0.673... | 0.7162399 | 10 |
Given a state, returns the optimal action (according to the model policy) to be taken. | def act(self, state):
# Prepare the state for the neural network
state_image, state_scalars = state.unwrap_state()
# Predict the action using the CNN
predicted_actions = self._cnn_model.predict([np.asarray([state_image]),
np.asarray(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_optimal_action(self, state):\n # check if there are multiple equivalent optimal actions\n if sum(self.Q_values[state] == np.amax(self.Q_values[state])) > 1:\n # select one of the optimal actions randomly\n idxs = np.where(self.Q_values[state] == np.amax(self.Q_values[sta... | [
"0.81077707",
"0.8093176",
"0.7922624",
"0.79208237",
"0.79140586",
"0.790481",
"0.7872246",
"0.78628343",
"0.77500004",
"0.77186334",
"0.7693651",
"0.76785064",
"0.7668536",
"0.76535875",
"0.7647951",
"0.7631164",
"0.7619717",
"0.76134783",
"0.7589017",
"0.7585482",
"0.75512... | 0.72329056 | 63 |
Get the default service account for the host GCE instance. Fetches GOOGLE_GCE_METADATA_DEFAULT_ACCOUNT_URI and returns its contents. | def DefaultAccount(self):
if not self.connected:
return None
try:
return _ReadNoProxy(GOOGLE_GCE_METADATA_DEFAULT_ACCOUNT_URI)
except urllib2.HTTPError as e:
if e.code == 404:
return None
raise MetadataServerException(e)
except urllib2.URLError as e:
raise CannotC... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_credentials(scopes):\n credentials, _ = google.auth.default(scopes=scopes)\n return credentials",
"def get_service_account_name():\n # Get the credential\n if os.path.exists(os.getenv(\"GCP_AUTOMATION_CONFIG\")):\n credential_location = os.getenv(\"GCP_AUTOMATION_CONFIG\")\n ... | [
"0.6467155",
"0.61172706",
"0.60549235",
"0.60172904",
"0.5775506",
"0.574537",
"0.574537",
"0.57407176",
"0.5729527",
"0.56457466",
"0.56095725",
"0.551219",
"0.5442747",
"0.5438566",
"0.5413697",
"0.5372204",
"0.5372204",
"0.5372204",
"0.5355967",
"0.53399086",
"0.53399086"... | 0.8137239 | 0 |
The sum of width and height. Note that this is not ACTUALLY the circumference! | def circumference(self):
return self.width + self.height | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculatearea(self):\r\n return self.width * self.height",
"def calculateperimeter(self):\r\n return (self.width * 2) + (self.height * 2)",
"def perimeter(self):\n return 2 * (self.height + self.width)",
"def perimeter(self):\n\t\treturn 2 * (self.width + self.height)",
"def perime... | [
"0.71800035",
"0.7149736",
"0.71027356",
"0.7078878",
"0.702873",
"0.6946088",
"0.6882668",
"0.6881731",
"0.68220913",
"0.68220913",
"0.6779442",
"0.6777669",
"0.6764908",
"0.6764908",
"0.6764908",
"0.6764908",
"0.6764908",
"0.6764908",
"0.6764908",
"0.6764908",
"0.67477906",... | 0.76774967 | 0 |
Test calling the API with invalid hub parameters. | def test_execute_invalid_api_parameters(self):
quantum_program = self._get_quantum_program()
# Invoke with hub, group and project parameters.
FAKE_QE_HUB = 'HUB'
FAKE_QE_GROUP = 'GROUP'
FAKE_QE_PROJECT = 'PROJECT'
quantum_program.set_api(QE_TOKEN, QE_URL,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hubs_fail(self):\n with self.assertRaises(AssertionError):\n self.resource.hubs(-1)",
"def test_invalid_request(self):\n response = self.client.post(telemetry_url)\n self.assertEqual(400, response.status_code)\n\n response = self.client.post(telemetry_url, {\n ... | [
"0.7026234",
"0.66320807",
"0.66060495",
"0.660001",
"0.6568346",
"0.6549651",
"0.6541933",
"0.65326697",
"0.653062",
"0.6522051",
"0.6499948",
"0.6408988",
"0.6408759",
"0.6399277",
"0.63575727",
"0.62974006",
"0.6244453",
"0.6229556",
"0.62143123",
"0.62074286",
"0.6193638"... | 0.6960295 | 1 |
Return the value of the state (computed in __init__). | def getValue(self, state):
return self.values[state] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self, state):\n raise NotImplementedError",
"def value(self, state):\n raise NotImplementedError",
"def value(self, state):\n\t\traise NotImplementedError",
"def getValue(self, state):\n util.raiseNotDefined()",
"def getValue(self, state):\n util.raiseNotDefined()",
... | [
"0.830136",
"0.830136",
"0.82602024",
"0.8086008",
"0.8086008",
"0.7958413",
"0.78017086",
"0.7737145",
"0.77342933",
"0.7733657",
"0.7733657",
"0.7733657",
"0.7733657",
"0.7733657",
"0.7733657",
"0.7733657",
"0.7733657",
"0.7733657",
"0.7733657",
"0.7733657",
"0.7733657",
... | 0.7929993 | 6 |
Saves an image of the shape expected by other functions in this module. However, note this expects a numpy array. | def image_save(path, na: numpy.ndarray):
# change type
na = numpy.fmax(numpy.fmin(na * 255.0, 255), 0).astype("uint8")
# shape is now (1,3,h,w), remove 1
na = na.reshape(3,na.shape[2],na.shape[3])
# fix shape
na = numpy.moveaxis(na, [0,1,2], [2,0,1])
# shape is now (h,w,3)
# file
Image.fromarray(na).s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_img(img: np.ndarray, path: str) -> None:\n\n img_obj = Image.fromarray(img)\n img_obj.save(path)",
"def save_npimg(array: np.ndarray, path: str) -> None:\r\n img = Image.fromarray(array.squeeze())\r\n img.save(path)",
"def imwrite(image, path):\n\n if image.ndim == 3 and image.shape[2] ... | [
"0.7397582",
"0.72214085",
"0.7198307",
"0.71386844",
"0.71040505",
"0.70708066",
"0.7057253",
"0.7015668",
"0.698637",
"0.6963281",
"0.69594914",
"0.68962365",
"0.6883985",
"0.68804735",
"0.6848746",
"0.6804764",
"0.67976993",
"0.6780601",
"0.6767705",
"0.6767581",
"0.672906... | 0.7051175 | 7 |
Generate a dict to turn punctuation into a token. | def token_lookup():
token_dict = {}
token_dict['.'] = "||Period||"
token_dict[','] = "||Comma||"
token_dict['"'] = "||Quotation_Mark||"
token_dict[';'] = "||Semicolon||"
token_dict['!'] = "||Exclamation_Mark||"
token_dict['?'] = "||Question_Mark||"
token_dict['('] = "||Left_Parentheses||... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token_lookup():\n token_dict = {'.':'||Period||', ', ':'||Comma||', '\"':'||Quotation_Mark||', ';':'||Semicolon||',\n '!':'||Exclamation_mark||', '?':'||Question_mark||', '(':'||Left_Parentheses||',\n ')':'||Right_Parentheses||', '--':'||Dash||', '\\n':'||Return||'}\n re... | [
"0.66179246",
"0.6473263",
"0.63673395",
"0.63541335",
"0.6318267",
"0.6195351",
"0.6170302",
"0.61027676",
"0.61009026",
"0.6056571",
"0.583608",
"0.580536",
"0.57960415",
"0.5735746",
"0.5717652",
"0.5713248",
"0.5703686",
"0.56706595",
"0.56492156",
"0.56279296",
"0.562042... | 0.6736538 | 0 |
Create TF Placeholders for input, targets, and learning rate. | def get_inputs():
inputs = tf.placeholder(tf.int32, [None, None], name='input')
targets = tf.placeholder(tf.int32,[None, None], name='targets')
learning_rate = tf.placeholder(tf.float32, name='learning_rate')
return inputs, targets, learning_rate | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_placeholders(self):\n\n\t\twith tf.name_scope(\"input_data\"):\n\t\t\tself.input_words=tf.placeholder(shape=(None,self.look_back), dtype=tf.int32,name='input_tokens')\n\t\twith tf.name_scope(\"output_data\"):\t\n\t\t\tself.output_words=tf.placeholder(shape=(None,self.look_back),dtype=tf.int32,name='out... | [
"0.7744293",
"0.7662721",
"0.7621616",
"0.76179385",
"0.75356156",
"0.75137645",
"0.7418147",
"0.7405449",
"0.7404622",
"0.73941994",
"0.73695993",
"0.73649645",
"0.7349455",
"0.73242545",
"0.72866756",
"0.72504604",
"0.7224488",
"0.72090685",
"0.7191729",
"0.71353704",
"0.71... | 0.6295598 | 47 |
Create an RNN Cell and initialize it. | def get_init_cell(batch_size, rnn_size):
lstm = tf.contrib.rnn.BasicLSTMCell(rnn_size)
#drop = tf.contrib.rnn.DropoutWrapper(lstm, output_keep_prob=0.5)
cell = tf.contrib.rnn.MultiRNNCell([lstm] * 3)
initial_state = cell.zero_state(batch_size, tf.float32)
initial_state = tf.identity(initial_state, n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, rnn_cell, batch_size,\n input_size, num_outputs):\n super().__init__(name='RNNCellStateModel')\n self._rnn_cell = rnn_cell\n self._batch_size = batch_size\n self._input_size = input_size\n self._num_outputs = num_outputs",
"def constructCell():\n\t\tself.weightGene... | [
"0.71328205",
"0.6902493",
"0.6705795",
"0.6509429",
"0.6456088",
"0.6427877",
"0.64073706",
"0.63708305",
"0.6354739",
"0.6346675",
"0.6290552",
"0.62503237",
"0.62420845",
"0.6240313",
"0.6204581",
"0.61756074",
"0.6160576",
"0.61548066",
"0.6071491",
"0.5992168",
"0.59629"... | 0.6565958 | 3 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, ListDevicesRequest):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Gets the flow_contents of this VersionedFlowSnapshot. The contents of the versioned flow | def flow_contents(self):
return self._flow_contents | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contents(self):\n self.syncContents()\n return self._contents",
"def get_contents(self):\n return self.contents",
"def contents(self):\n return self._contents",
"def get_contents(self):\n with closing(self.open()) as handle:\n return handle.read()",
"def co... | [
"0.66757303",
"0.62290907",
"0.6197192",
"0.59705305",
"0.5878344",
"0.5796029",
"0.5763083",
"0.5516891",
"0.5505247",
"0.54965574",
"0.54637045",
"0.54631704",
"0.5415392",
"0.53776175",
"0.536303",
"0.5346532",
"0.5295824",
"0.5295824",
"0.5295824",
"0.5295824",
"0.5293879... | 0.75096315 | 0 |
Sets the flow_contents of this VersionedFlowSnapshot. The contents of the versioned flow | def flow_contents(self, flow_contents):
if flow_contents is None:
raise ValueError("Invalid value for `flow_contents`, must not be `None`")
self._flow_contents = flow_contents | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contents(self, contents):\n\n self._contents = contents",
"def set_contents(self, contents):\n self.validate_contents(contents)\n #Copy-ing the contents list is necessary because it can be modified \n #by UI elements that are based on this class\n self.contents = copy(conte... | [
"0.5873673",
"0.58573955",
"0.5356069",
"0.53205866",
"0.52961564",
"0.507953",
"0.5026219",
"0.50057846",
"0.49433386",
"0.48465547",
"0.48465547",
"0.47895524",
"0.47386765",
"0.47386765",
"0.46821818",
"0.46728328",
"0.4583075",
"0.4578419",
"0.4568628",
"0.45118272",
"0.4... | 0.7428742 | 0 |
Gets the external_controller_services of this VersionedFlowSnapshot. The information about controller services that exist outside this versioned flow, but are referenced by components within the versioned flow. | def external_controller_services(self):
return self._external_controller_services | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def external_controller_services(self, external_controller_services):\n\n self._external_controller_services = external_controller_services",
"def exposed_services(self):\n return self._exposed_services",
"def get_current_services(self,sim):\n current_services = sim.get_alloc_entities()\n ... | [
"0.63227344",
"0.56581736",
"0.53822076",
"0.5345333",
"0.53095484",
"0.530191",
"0.5297033",
"0.5236078",
"0.52339894",
"0.52310747",
"0.51765954",
"0.5120164",
"0.50976235",
"0.5094909",
"0.5077057",
"0.50099176",
"0.5002442",
"0.49720675",
"0.4959182",
"0.49488658",
"0.494... | 0.81535 | 0 |
Gets the parameter_providers of this VersionedFlowSnapshot. Contains basic information about parameter providers referenced in the versioned flow. | def parameter_providers(self):
return self._parameter_providers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def provider_params(self):\n return self.tree.get('provider_params', {})",
"def all_providers(self) -> List[ProviderInfo]:\n sp_key = self.__providers_key()\n value = self.get(name=sp_key)\n if value is None:\n return []\n js = utf8_decode(data=value)\n array ... | [
"0.7007249",
"0.61865747",
"0.60932356",
"0.6047994",
"0.60459554",
"0.6015926",
"0.6015926",
"0.6015926",
"0.6015926",
"0.6015926",
"0.6015926",
"0.59945995",
"0.59945995",
"0.59182954",
"0.58808595",
"0.58627284",
"0.5730422",
"0.5724208",
"0.571871",
"0.57134426",
"0.57121... | 0.80047333 | 0 |
Gets the parameter_contexts of this VersionedFlowSnapshot. The parameter contexts referenced by process groups in the flow contents. The mapping is from the name of the context to the context instance, and it is expected that any context in this map is referenced by at least one process group in this flow. | def parameter_contexts(self):
return self._parameter_contexts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_contexts(self):\n return tuple(getattr(self, name) for name in self.__argnames__)",
"def get_contexts(self):\n return self._contexts",
"def get_contexts(self):\n params = self._get_configurational_params()\n builds = self._get_builds()\n\n ctx_params = itertools.produ... | [
"0.6186989",
"0.60678494",
"0.6034285",
"0.57978076",
"0.5718987",
"0.5601156",
"0.55219734",
"0.5495203",
"0.5372476",
"0.5309605",
"0.5279569",
"0.52359176",
"0.5205325",
"0.51551515",
"0.51125336",
"0.5102993",
"0.50635713",
"0.50354475",
"0.5029947",
"0.50209457",
"0.5006... | 0.7592681 | 0 |
Sets the parameter_contexts of this VersionedFlowSnapshot. The parameter contexts referenced by process groups in the flow contents. The mapping is from the name of the context to the context instance, and it is expected that any context in this map is referenced by at least one process group in this flow. | def parameter_contexts(self, parameter_contexts):
self._parameter_contexts = parameter_contexts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_contexts(self, contexts):\n self._contexts = contexts",
"def parameter_contexts(self):\n return self._parameter_contexts",
"def update(self, contextset):\n self._contexts.update(contextset.get_contexts())",
"def set_contexts(self, path_context: str):\n self.path, self.mode... | [
"0.6403469",
"0.5939657",
"0.5094899",
"0.50620306",
"0.5013662",
"0.49896467",
"0.49327752",
"0.48905647",
"0.48811802",
"0.47928238",
"0.47024944",
"0.46778068",
"0.46764642",
"0.46742034",
"0.46499863",
"0.4630622",
"0.4608403",
"0.45698825",
"0.45489085",
"0.45285198",
"0... | 0.79279155 | 0 |
Gets the bucket of this VersionedFlowSnapshot. The bucket where the flow is located | def bucket(self):
return self._bucket | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bucket(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"bucket\")",
"def bucket(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"bucket\")",
"def bucket(self):\n if not hasattr(self, \"_bucket\"):\n self._bucket = self._get_or_create_bucket(self.bucket_name)\... | [
"0.78069574",
"0.78069574",
"0.7710763",
"0.7691495",
"0.7655935",
"0.76269865",
"0.76269865",
"0.7556832",
"0.7556832",
"0.7556832",
"0.7556832",
"0.7556832",
"0.7456765",
"0.72359926",
"0.7172862",
"0.71176875",
"0.69666916",
"0.6939062",
"0.6920855",
"0.6910778",
"0.683748... | 0.8017462 | 0 |
Sets the bucket of this VersionedFlowSnapshot. The bucket where the flow is located | def bucket(self, bucket):
self._bucket = bucket | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_image_bucket(self, value):\n self.image_bucket = value",
"def __init__(self, bucket):\n self.bucket = bucket",
"def bucket(self):\n if not hasattr(self, \"_bucket\"):\n self._bucket = self._get_or_create_bucket(self.bucket_name)\n return self._bucket",
"def buck... | [
"0.7186771",
"0.68779075",
"0.6785613",
"0.667325",
"0.66621596",
"0.65803295",
"0.6543764",
"0.6543764",
"0.6543764",
"0.6543764",
"0.6543764",
"0.6406765",
"0.6357553",
"0.6302178",
"0.6273225",
"0.6273225",
"0.6228045",
"0.6178882",
"0.61779845",
"0.61259234",
"0.6115869",... | 0.80024356 | 0 |
Gets the latest of this VersionedFlowSnapshot. | def latest(self):
return self._latest | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def latest(self):\n return self.journal_data[self.latest_id]",
"def get_latest_revision(self):\n revision_list = self.get_revision_list()\n if revision_list:\n return revision_list[-1]\n else:\n raise NoRevisionsExistError()",
"def get_latest(self, name):\n ... | [
"0.70233417",
"0.6663617",
"0.6593615",
"0.65461594",
"0.6545754",
"0.6521191",
"0.64221674",
"0.63784236",
"0.6323985",
"0.6314438",
"0.62969947",
"0.62746644",
"0.6249728",
"0.621321",
"0.6209161",
"0.6130742",
"0.6110239",
"0.6094407",
"0.60749656",
"0.60749656",
"0.607346... | 0.71543825 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, VersionedFlowSnapshot):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Turns the robot into specified direction. | def turn(self, world, direction):
world.__turn__(self.ID, int(direction)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setRobotDirection(self, direction):\n self.direction = direction",
"def setRobotDirection(self, direction):\n self.direction = direction",
"def setRobotDirection(self, direction):\n self.direction = direction\n #raise NotImplementedError",
"def setRobotDirection(self, directio... | [
"0.7838874",
"0.7838874",
"0.76411635",
"0.76411635",
"0.75555784",
"0.75247675",
"0.73792523",
"0.7336378",
"0.72886634",
"0.72776496",
"0.72776496",
"0.7100742",
"0.7089828",
"0.7087633",
"0.7057973",
"0.7036288",
"0.69716114",
"0.69710374",
"0.6963444",
"0.69305086",
"0.69... | 0.6965067 | 18 |
Verifies uniqueness of instance name, or raises AXApiInvalidParam if it already exists | def _verify_unique_instance_name(self, name):
existing = self.instances.find_one({'name': name, 'deleted': False})
if existing:
raise AXApiInvalidParam("Fixture instance with name '{}' already exists".format(name)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_duplicate_names_fail(self):\n name = 'some_name'\n instance_types.create(name, 256, 1, 120, 200, 'flavor1')\n self.assertRaises(exception.InstanceTypeExists,\n instance_types.create,\n name, 256, 1, 120, 200, 'flavor2')",
"def check_... | [
"0.6955145",
"0.64076835",
"0.6331418",
"0.6246967",
"0.6105957",
"0.6080625",
"0.60061294",
"0.5978304",
"0.5874458",
"0.5850276",
"0.5835531",
"0.5809082",
"0.57808006",
"0.5773074",
"0.5737927",
"0.5737927",
"0.57119274",
"0.57102257",
"0.56951034",
"0.5669034",
"0.5659929... | 0.79201096 | 0 |
Returns a single, unique fixture by name or id >>> fixmgr.get_fixture_instance(name='linux01') | def get_fixture_instance(self, id=None, name=None, verify_exists=True):
query = {}
if id:
query['_id'] = id
if name:
query['name_lower'] = name
if not query:
raise AXIllegalArgumentException("No query filters supplied")
fix_doc = self.instances... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fixture(name):\n path = os.path.join(os.environ.get(\"WORKSPACE\", \"./\"), \"fixtures\", name)\n if not os.path.isfile(path):\n raise NotFound(\"File {} not found\".format(path))\n return path",
"def _get_fixture(item, arg_name, fixture=None):\n if arg_name == \"request\":\n # ... | [
"0.6509923",
"0.62037605",
"0.6023634",
"0.5966281",
"0.59145325",
"0.5883537",
"0.576336",
"0.56827825",
"0.5630251",
"0.5515407",
"0.5480694",
"0.5458051",
"0.5450804",
"0.5437768",
"0.5419975",
"0.54180723",
"0.5371775",
"0.53615993",
"0.5356714",
"0.53151685",
"0.5307016"... | 0.7184157 | 0 |
Returns FixtureClass object from a template dictionary | def template_to_class(self, fix_template):
action_templates = {}
actions = fix_template.get('actions', {})
for action_name, action in actions.items():
if action['template'] not in action_templates:
service_template = self.axops_client.get_template(fix_template['repo']... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_template(cls, template, fpath, defaults=defaults, **kwargs):\n\n try:\n #use defaults first and overwrite with user's specs\n inp = template.substitute(defaults, **kwargs)\n return cls(fpath, inp_string=inp)\n except (KeyError, ValueError) as error:\n ... | [
"0.5881686",
"0.56846297",
"0.5514073",
"0.543241",
"0.5410768",
"0.5402855",
"0.54024947",
"0.5372281",
"0.53655285",
"0.5360564",
"0.53439814",
"0.5325336",
"0.5324815",
"0.5289122",
"0.5269114",
"0.5266425",
"0.5260116",
"0.5245977",
"0.5245977",
"0.5230463",
"0.52099055",... | 0.6678587 | 0 |
Test that an object and its attributes can both be assigned templates. | def test_template_assignment():
humidity_template = ConditionTemplate("Humidity", bounds=RealBounds(0.5, 0.75, ""))
template = ProcessTemplate("Dry", conditions=[[humidity_template, RealBounds(0.5, 0.65, "")]])
ProcessSpec("Dry a polymer", template=template, conditions=[
Condition("Humidity", value=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_object_template_validation():\n length_template = PropertyTemplate(\"Length\", bounds=RealBounds(2.0, 3.5, 'cm'))\n dial_template = ConditionTemplate(\"dial\", bounds=IntegerBounds(0, 5))\n color_template = ParameterTemplate(\"Color\", bounds=CategoricalBounds([\"red\", \"green\", \"blue\"]))\n\n... | [
"0.69322157",
"0.66817254",
"0.6182613",
"0.60178757",
"0.59672934",
"0.5823069",
"0.5780402",
"0.5737048",
"0.571049",
"0.5679045",
"0.5598014",
"0.5551784",
"0.5528739",
"0.5516997",
"0.5516243",
"0.5505534",
"0.54870075",
"0.54850197",
"0.54847145",
"0.5480541",
"0.5468632... | 0.5696904 | 9 |
Create the spark session and returns its object | def create_spark_session():
spark = SparkSession \
.builder \
.config("spark.jars.packages", "org.apache.hadoop:hadoop-aws:2.7.0") \
.getOrCreate()
return spark | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_sparksession():\n return SparkSession.builder.\\\n appName(\"Transforming the historical parking occupancy and blockface datasets\").\\\n getOrCreate()",
"def create_spark_session():\n\n spark = SparkSession. builder.\\\n config(\"spark.jars.packages\", \"org.apache.... | [
"0.86523557",
"0.8286961",
"0.82391435",
"0.81481373",
"0.7979438",
"0.7950069",
"0.7950069",
"0.7950069",
"0.7950069",
"0.79482985",
"0.7898484",
"0.7879878",
"0.78603834",
"0.78490996",
"0.7812462",
"0.7810376",
"0.77311814",
"0.7722151",
"0.76831895",
"0.7608785",
"0.75595... | 0.79879576 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.