query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
form clusters of similar quantities from input 'values'. Clustered values are not necessarily contiguous in the input array. Clusters size (that is maxmin) is < relScluster_average | def clusterValues( values, relS=0.1 , refScaleAbs='range' ):
if len(values)==0:
return []
if len(values.shape)==1:
sortedV = numpy.stack([ values , numpy.arange(len(values))] ,1)
else:
# Assume value.shape = (N,2) and index are ok
sortedV = values
sortedV = sortedV[ num... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_dimension_val_clutering(vals, max_distance=5):\n vals = sorted(vals)\n clusters = []\n for (idx, i) in enumerate(vals):\n cluster = [j for j in vals if abs(j - i) < max_distance]\n clusters.append(cluster)\n clusters = sorted(clusters, key=len, reverse=True)\n cluster = cluster... | [
"0.73040986",
"0.70678765",
"0.7027042",
"0.662122",
"0.62348586",
"0.6203026",
"0.61463094",
"0.60974455",
"0.599269",
"0.59352785",
"0.5928146",
"0.59084487",
"0.5879814",
"0.58721775",
"0.5863479",
"0.5838369",
"0.58130205",
"0.57866824",
"0.57753193",
"0.5773827",
"0.5753... | 0.7795913 | 0 |
Remove small Path objects which stand between 2 Segments (or at the ends of the sequence). Small means the bbox of the path is less then 5% of the mean of the 2 segments. | def removeSmallEdge(self, paths, wTot,hTot):
if len(paths)<2:
return
def getdiag(points):
xmin,ymin,w,h = computeBox(points)
return sqrt(w**2+h**2), w, h
removeSeg=[]
def remove(p):
removeSeg.append(p)
if p.next : p.next.prev = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filter_out_bad_segments(img1, seg1, img2, seg2):\n minval = tf.reduce_min(tf.reduce_sum(seg1, [0,1])*tf.reduce_sum(seg2, [0,1]))\n if minval < 0.5:\n warnings.warn(\"filtering bad segment\")\n return False\n else:\n return True",
"def remove_small_regions(img, size):\n img =... | [
"0.6171433",
"0.5879706",
"0.58459765",
"0.5784335",
"0.5751192",
"0.5610062",
"0.54972976",
"0.5459702",
"0.5439348",
"0.53872854",
"0.534481",
"0.5344355",
"0.53415835",
"0.53393614",
"0.53139246",
"0.5294009",
"0.5284884",
"0.5276648",
"0.5275304",
"0.52669966",
"0.5226888... | 0.7323768 | 0 |
group circles radius and distances into cluster. Then set circles radius according to the mean of the clusters they belong to. | def prepareRadiusEqualization(self, circles, otherDists, relSize=0.2):
ncircles = len(circles)
lengths = numpy.array( [c.radius for c in circles]+otherDists )
indices = numpy.array( range(ncircles+len(otherDists) ) )
clusters = clusterValues(numpy.stack([ lengths, indices ],1 ), relSize,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def circos_group(\n G,\n group_by: Hashable,\n radius: float = None,\n radius_offset: float = 1,\n ax=None,\n midpoint=True,\n):\n nt = utils.node_table(G)\n groups = nt.groupby(group_by).apply(lambda df: len(df)).sort_index()\n proportions = groups / groups.sum()\n starting_points = ... | [
"0.64176863",
"0.6369268",
"0.6258704",
"0.62341636",
"0.60311884",
"0.59979504",
"0.5996026",
"0.59005344",
"0.5783774",
"0.57792956",
"0.57403165",
"0.57343054",
"0.57321036",
"0.57255703",
"0.5724053",
"0.5721485",
"0.5712469",
"0.57092756",
"0.57078475",
"0.570783",
"0.57... | 0.69055325 | 0 |
move centers of circles onto the segments if close enough | def centerCircOnSeg(self, circles, segments, relSize=0.18):
for circ in circles:
circ.moved = False
for seg in segments:
for circ in circles:
d = seg.distanceTo(circ.center)
#debug( ' ', seg.projectPoint(circ.center))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trackCircle( center, rad, imShape ):\n \n \"\"\"\n center = ccnt\n rad = rd\n inShape = segImg.shape\n debug = False\n \"\"\"\n \n # check if whole circle is inside image\n if (center[0] - rad) < 0 or (center[0] + rad) >= imShape[1] or (center[1] - rad) < 0 or (center[1] + rad) >... | [
"0.6516794",
"0.6343374",
"0.6338622",
"0.6290852",
"0.61642444",
"0.60784537",
"0.5991765",
"0.5983093",
"0.59555656",
"0.59367436",
"0.59208304",
"0.59181565",
"0.5874289",
"0.58307153",
"0.580138",
"0.5777856",
"0.5776776",
"0.5753908",
"0.5735313",
"0.5734168",
"0.572242"... | 0.80131227 | 0 |
Determine if the points and their tangents represent a circle The difficulty is to be able to recognize ellipse while avoiding paths small fluctuations a nd false positive due to badly drawn rectangle or nonconvex closed curves. | def checkForCircle(self, points, tangents):
if len(points)<10:
return False, 0
if all(points[0]==points[-1]): # last exactly equals the first.
# Ignore last point for this check
points = points[:-1]
tangents = tangents[:-1]
#print 'Removed las... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_circle(points, scale, verbose=False):\n\n # make sure input is a numpy array\n points = np.asanyarray(points)\n scale = float(scale)\n\n # can only be a circle if the first and last point are the\n # same (AKA is a closed path)\n if np.linalg.norm(points[0] - points[-1]) > tol.merge:\n ... | [
"0.7632414",
"0.74126965",
"0.7285531",
"0.6912834",
"0.6614201",
"0.65936637",
"0.65917677",
"0.65516406",
"0.64774555",
"0.6470427",
"0.64515245",
"0.6450744",
"0.6419962",
"0.6400582",
"0.63568485",
"0.6324377",
"0.6290452",
"0.6290188",
"0.6264349",
"0.6225267",
"0.620742... | 0.7528203 | 1 |
Finds segments part in a list of points represented by svgCommandsList. The method is to build the (averaged) tangent vectors to the curve. Aligned points will have tangent with similar angle, so we cluster consecutive angles together to define segments. Then we extend segments to connected points not already part of o... | def segsFromTangents(self,svgCommandsList, refNode):
sourcepoints, svgCommandsList = toArray(svgCommandsList)
d = D(sourcepoints[0],sourcepoints[-1])
x,y,wTot,hTot = computeBox(sourcepoints)
aR = min(wTot/hTot, hTot/wTot)
maxDim = max(wTot, hTot)
isClosing = aR*0.2 > d/m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inters_segment(self, s):\r\n x1 = s.start[0] - self.center[0]\r\n y1 = s.start[1] - self.center[1]\r\n x2 = s.end[0] - self.center[0]\r\n y2 = s.end[1] - self.center[1]\r\n dx = x2 - x1\r\n dy = y2 - y1\r\n dr = math.sqrt(dx * dx + dy * dy)\r\n D = x1 * y... | [
"0.59912634",
"0.5772904",
"0.57562643",
"0.57245094",
"0.56736404",
"0.55451804",
"0.55313295",
"0.5482719",
"0.53559184",
"0.53400856",
"0.53045857",
"0.5265515",
"0.5261249",
"0.52208287",
"0.52068585",
"0.5206842",
"0.5199147",
"0.51852065",
"0.5166792",
"0.51617396",
"0.... | 0.76697 | 0 |
Testing the TMDB API discover endpoint | def test_discover(self):
response = Tmdb.discover()
self.assertTrue(int(response.status_code) == 200)
data = response.json()
self.assertTrue(isinstance(data['results'], list))
# TODO check if all the shows are in the good format (can be from_dict/to_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_discover(self):\n client = Client()\n response = client.get('/discover/authors')\n print 'status code for authors', response.status_code\n self.failUnlessEqual(response.status_code, 200)\n\n response = client.get('/simple_search') \n print 'status code for ... | [
"0.6929612",
"0.63831156",
"0.6364406",
"0.6298877",
"0.62697476",
"0.62697476",
"0.62628806",
"0.6246104",
"0.61367726",
"0.61354584",
"0.6127925",
"0.6062728",
"0.60194474",
"0.59909433",
"0.59762007",
"0.59665745",
"0.5960747",
"0.5959758",
"0.5957677",
"0.5949807",
"0.594... | 0.70736927 | 0 |
Testing the TMDB API get show | def test_detail(self):
response = Tmdb.detail(69740)
self.assertTrue(int(response.status_code) == 200)
data = response.json()
self.assertTrue(data['id'])
self.assertTrue(data['name'])
# TODO check if all the shows are in the good format (can be from_dict/to_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_discover(self):\n response = Tmdb.discover()\n self.assertTrue(int(response.status_code) == 200)\n data = response.json()\n self.assertTrue(isinstance(data['results'], list))\n # TODO check if all the shows are in the good format (can be from_dict/to_dict)",
"def test_... | [
"0.6933966",
"0.67880017",
"0.678729",
"0.66252756",
"0.6617515",
"0.65987664",
"0.65862215",
"0.65674835",
"0.65623534",
"0.6535953",
"0.6472472",
"0.6442956",
"0.6407322",
"0.63845325",
"0.63786584",
"0.63675475",
"0.63613594",
"0.6324026",
"0.6302684",
"0.62680805",
"0.624... | 0.7839818 | 0 |
Testing the TMDB API seasons endpoint | def test_seasons(self):
response = Tmdb.season(tmdb_show_id = 69740, season_number = 1)
self.assertTrue(int(response.status_code) == 200)
data = response.json()
self.assertTrue(isinstance(data['episodes'], list))
# TODO check if all the shows are in the good format (can be from_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_seasonal_faceoffs(self):\n msg = \"Response status is not 200\"\n response = self.api.get_seasonal_faceoffs(self.season, self.nhl_season, self.team_id)\n self.assertEqual(response.status_code, 200, msg)",
"def test_get_standings(self):\n msg = \"Response status is not 200... | [
"0.7294995",
"0.7227316",
"0.71596456",
"0.69653505",
"0.6889411",
"0.6691677",
"0.66718614",
"0.66319495",
"0.65817046",
"0.6420952",
"0.63585925",
"0.6336846",
"0.631154",
"0.631154",
"0.62844133",
"0.62566775",
"0.62529695",
"0.6246284",
"0.617973",
"0.6154505",
"0.6148209... | 0.7882173 | 0 |
Converts a base64 encoded Netscape SPKI DER to a crypto.NetscapeSPKI. PyOpenSSL does not yet support doing that by itself, so some work around through FFI and "internalspatching" trickery is required to perform this | def netscape_spki_from_b64(b64):
if not hasattr(netscape_spki_from_b64, 'NETSCAPE_SPKI_b64_decode'):
from cffi import FFI as CFFI
from OpenSSL._util import ffi as _sslffi, lib as _ssllib
cffi = CFFI()
cffi.cdef('void* NETSCAPE_SPKI_b64_decode(const char *str, int len);')
lib ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_cert_for_spki_request(spki_req_b64, serial, ident):\n spki_obj = netscape_spki_from_b64(spki_req_b64)\n if spki_obj is None:\n raise ValueError('Invalid SPKI object')\n\n root_crt = _try_load_ca_cert(cfg.ca_cert_path())\n root_key = _try_load_ca_private_key(cfg.ca_private_key_path())\n ... | [
"0.6001079",
"0.55291533",
"0.55100334",
"0.54639065",
"0.53914726",
"0.5386586",
"0.5371301",
"0.5363465",
"0.5347163",
"0.53363645",
"0.52513164",
"0.5245167",
"0.5239797",
"0.5229423",
"0.522883",
"0.5190209",
"0.51870984",
"0.51460814",
"0.51236945",
"0.5122466",
"0.51210... | 0.7954151 | 0 |
Generates a new private key and saves it to the given path. | def _generate_ca_private_key(path):
DEFAULT_KEY_ALG = crypto.TYPE_RSA
DEFAULT_KEY_BITS = 2048
pkey = crypto.PKey()
pkey.generate_key(DEFAULT_KEY_ALG, DEFAULT_KEY_BITS)
data = crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey)
open(path, 'wb').write(data)
return pkey | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_key():\n key = Fernet.generate_key()\n with open(\"pass.key\", \"wb\") as key_file:\n key_file.write(key)",
"def gen_key(self):\n\n if not self.private_key:\n self._gen_key()\n else:\n raise CryptoError(\"Private Key already existing\")",
"def gener... | [
"0.68091214",
"0.67993647",
"0.6777343",
"0.67254627",
"0.66951996",
"0.66795206",
"0.66601604",
"0.66367877",
"0.660339",
"0.6588916",
"0.6524175",
"0.6459134",
"0.64352334",
"0.6392895",
"0.63732886",
"0.63706726",
"0.637061",
"0.6359129",
"0.63333434",
"0.63222814",
"0.630... | 0.7051212 | 0 |
Returns the CA private key as a crypto.PKey object. Caches the result forever we do not support reloading the CA key dynamically during runtime, and the global configuration object is not expected to change either. | def get_ca_private_key():
return _try_load_ca_private_key(cfg.ca_private_key_path()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_ca_private_key(path):\n DEFAULT_KEY_ALG = crypto.TYPE_RSA\n DEFAULT_KEY_BITS = 2048\n\n pkey = crypto.PKey()\n pkey.generate_key(DEFAULT_KEY_ALG, DEFAULT_KEY_BITS)\n data = crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey)\n open(path, 'wb').write(data)\n\n return pkey",
"def g... | [
"0.6964099",
"0.6667013",
"0.6625479",
"0.6599153",
"0.6599153",
"0.6537986",
"0.65284795",
"0.6483498",
"0.64739066",
"0.6466347",
"0.6445477",
"0.64331657",
"0.63586897",
"0.63507473",
"0.6332369",
"0.63318497",
"0.63318497",
"0.629014",
"0.62888664",
"0.62876743",
"0.62612... | 0.7320571 | 0 |
Generates a new certificate and saves it to the given path. | def _generate_ca_cert(path, pkey):
crt = _make_base_cert(pkey, 5000, socket.gethostname(),
random.randrange(0, 2**64))
crt.set_issuer(crt.get_subject())
crt.sign(pkey, 'sha256')
data = crypto.dump_certificate(crypto.FILETYPE_PEM, crt)
open(path, 'wb').write(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, cert_path: Union[Path, str], key_path: Union[Path, str]):\n cert_path, key_path = Path(cert_path), Path(key_path)\n\n cert_path.parent.mkdir(parents=True, exist_ok=True)\n with cert_path.open(\"wb\") as file:\n file.write(OpenSSL.crypto.dump_certificate(OpenSSL.crypto... | [
"0.70143706",
"0.65010035",
"0.649043",
"0.64069223",
"0.63382506",
"0.632874",
"0.61461985",
"0.6079066",
"0.60784847",
"0.60784847",
"0.60484076",
"0.5987101",
"0.5968675",
"0.59634995",
"0.5952945",
"0.594052",
"0.5912546",
"0.5904556",
"0.59020805",
"0.58758533",
"0.57713... | 0.69298 | 1 |
Creates a certificate for a given Netscape SPKI request. | def make_cert_for_spki_request(spki_req_b64, serial, ident):
spki_obj = netscape_spki_from_b64(spki_req_b64)
if spki_obj is None:
raise ValueError('Invalid SPKI object')
root_crt = _try_load_ca_cert(cfg.ca_cert_path())
root_key = _try_load_ca_private_key(cfg.ca_private_key_path())
crt = _ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_ssl_cert_request ( ssl_hostnames ) :\n first_hostname = ssl_hostnames[ 0 ]\n csr_filename = get_ssl_csr_filename( first_hostname )\n key_filename = get_ssl_key_filename( first_hostname )\n openssl_cnf = \"\"\"\n[req]\ndistinguished_name = req_distinguished_name\nreq_extensions = san_ext\n\n[req_... | [
"0.6908966",
"0.687956",
"0.6502294",
"0.64450103",
"0.6369535",
"0.63060254",
"0.6201516",
"0.6175826",
"0.61685216",
"0.614009",
"0.6070419",
"0.59930366",
"0.59869313",
"0.5965952",
"0.5957936",
"0.5913469",
"0.59037393",
"0.5891826",
"0.58573335",
"0.5816905",
"0.5793223"... | 0.76016754 | 0 |
main(quiet=False) Pulling all necessary files for using the starformation script This script pulls the fitsfiles for the radiation models from the MPIAfolder of Thomas Robitaille, if the files have been moved feel free to contact robitaille.de It also pulls the extinction law from | def main(quiet=False):
if quiet:
output_stream = StringIO()
else:
output_stream = sys.stdout
newpath = r'%s/models' % os.getcwdu()
if not os.path.exists(newpath): os.makedirs(newpath)
newpath = r'%s/out' % os.getcwdu()
if not os.path.exists(newpath): os.makedirs(newpath)
exi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n #Getthefiles\n all_fna_file_path = []\n path_to_all_info = '/Users/gustavotamasco/mdrkrp/project_MDR_KRPgenomes_parsnp'\n #path_to_all_info = argv[1]\n dirpath=os.getcwd()\n os.chdir(path_to_all_info)\n genome_files = list_directories(path_to_all_info)\n os.chdir(\"/Users/gu... | [
"0.6801153",
"0.67483914",
"0.65790725",
"0.63969",
"0.6382732",
"0.6378606",
"0.63148403",
"0.62836134",
"0.6281692",
"0.6239557",
"0.62235945",
"0.6214176",
"0.61772096",
"0.6150948",
"0.61502886",
"0.61474967",
"0.6133583",
"0.61139715",
"0.60590863",
"0.6047038",
"0.60463... | 0.7089952 | 0 |
Open Arduino's serial port and encode incoming message to files. Calculates average activity of each bin. | def encode(port,baudrate,n_pir,template,winsize,destructive):
template_filename=template+"%02d"
if destructive:
for n in range(n_pir):
with open(template_filename%(n+1),'wb') as f:
f.write()
try:
t1=time.time()
click.echo("[ ] Serial port")
ser=ser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_live_data(wearable_port):\r\n IMU1_num = []\r\n IMU2_num = []\r\n IMU3_num = []\r\n\r\n try:\r\n wearable = serial.Serial(wearable_port, baudrate=115200, timeout=5)\r\n #arduino = serial.Serial(arduino_port, timeout=1)\r\n # Delay for 2 seconds to wait for serial port to b... | [
"0.6158431",
"0.58251077",
"0.5772528",
"0.56499165",
"0.55148417",
"0.540058",
"0.53279567",
"0.532681",
"0.52397716",
"0.521093",
"0.51850545",
"0.5178048",
"0.51608855",
"0.5160255",
"0.5157739",
"0.51465076",
"0.5142989",
"0.5131824",
"0.51228344",
"0.51218516",
"0.504416... | 0.5855985 | 1 |
Save figure in specified format(s) | def save_figure(plt, name, fmt='all'):
if fmt in ('jpg', 'all'):
fname = os.path.join(SAVEDIR, f"{name}.jpg")
plt.savefig(fname, **FIGURE_KWARGS['jpg'])
if fmt in ('svg', 'all'):
fname = os.path.join(SAVEDIR, f"{name}.svg")
plt.savefig(fname, **FIGURE_KWARGS['svg']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_figure(\n self,\n filename,\n format=\"png\",\n dpi=None,\n face_colour=\"w\",\n edge_colour=\"w\",\n orientation=\"portrait\",\n paper_type=\"letter\",\n transparent=False,\n pad_inches=0.1,\n overwrite=False,\n ):\n f... | [
"0.756413",
"0.7480592",
"0.731232",
"0.7185951",
"0.7185095",
"0.7137242",
"0.7086419",
"0.7067175",
"0.7059328",
"0.70473254",
"0.70351684",
"0.69807106",
"0.69435185",
"0.69182205",
"0.6908527",
"0.6878023",
"0.6859317",
"0.68229365",
"0.6812285",
"0.6802542",
"0.6788735",... | 0.7669392 | 0 |
Plot frequency of unique list items for coded columns Handle columns with list values differently from columns with single values | def plot_coded_column(df_all, col, saveFig=False, figParams=None, label='', orient='h', size=None, plotType='bar', scaleToMax=True):
df = df_all.copy(deep=True)
isListCol = any([isinstance(d, list) for d in df[col]])
if isListCol:
# Make sure all values in column are lists
df[col] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualizeData(df):\n for column in df:\n df[column].value_counts().plot(kind = 'bar', rot = 'vertical', use_index = False)",
"def freq_table(a):\n Detail_freq = a.loc[:, (a.dtypes == object) | (a.dtypes == long) ].columns.get_values().tolist()\n print(Detail_freq)\n for freq in Detail_freq... | [
"0.6546641",
"0.61946946",
"0.5966976",
"0.59606946",
"0.59166116",
"0.59025997",
"0.58944577",
"0.5879031",
"0.5758055",
"0.5751387",
"0.5751023",
"0.57490605",
"0.5742544",
"0.57063174",
"0.56987226",
"0.5692799",
"0.56561565",
"0.563815",
"0.562986",
"0.56030226",
"0.55812... | 0.652042 | 1 |
Generates a valid system description. Makes a best effort to autopopulate some of the fields, but should be manually checked prior to submission. The system name is autogenerated as ``"[world_size]x[device_name]_composer"``, e.g. ``"8xNVIDIA_A100_80GB_composer"``. | def get_system_description(
submitter: str,
division: str,
status: str,
system_name: Optional[str] = None,
host_processors_per_node: Optional[int] = None,
) -> Dict[str, str]:
is_cuda = torch.cuda.is_available()
cpu_info = cpuinfo.get_cpu_info()
system_desc = {
'submitter': subm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logic_program_form(self):\r\n return '% ASP{f} Translation of System Description ' + self.name + '\\n\\n'",
"def create_system(sys_structure):\n pass",
"def split_system_desc(sys_id):\n with open(os.path.join(\"systems\", sys_id + \".json\")) as f:\n original_dict = json.loads(f.read())... | [
"0.6212724",
"0.6024637",
"0.60095024",
"0.5979918",
"0.58107364",
"0.57802993",
"0.5719285",
"0.5633054",
"0.55747783",
"0.5564474",
"0.55626595",
"0.5555423",
"0.55427414",
"0.5507808",
"0.5484637",
"0.5460589",
"0.54522824",
"0.54510486",
"0.53948706",
"0.5368994",
"0.5368... | 0.67261016 | 0 |
Fetch feature and labels from dataset using index of the sample. | def __getitem__(self, idx):
sample = self.samples[idx]
from PIL import Image
image = Image.open(self.DatasetWrapper.features(sample))
label = self.DatasetWrapper.label(sample)
image = self.transformer(image)
return image, label | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getitem__(self, index):\n return self.features[index], self.labels[index]",
"def __getitem__(self, index):\n\n # get and load sample from index file\n sample = self.samples[index]\n # labels = self.labels\n return load_sample(sample, self.imgTransform,\n ... | [
"0.71945214",
"0.6827715",
"0.65036714",
"0.6477738",
"0.63652015",
"0.6319679",
"0.6267225",
"0.62178856",
"0.62015533",
"0.61926824",
"0.61733335",
"0.61640805",
"0.61638105",
"0.6146079",
"0.61259353",
"0.6107271",
"0.608265",
"0.6060241",
"0.6042281",
"0.6042281",
"0.6027... | 0.69733894 | 1 |
Fetches the DataLoader object for each type in types. | def fetch_dataloader(types, params, CViters):
dataloaders = {}
assert CViters[0] != CViters[1], 'ERROR! Test set and validation set cannot be the same!'
if len(types)>0:
for split in types:
if split in ['train', 'val', 'test']:
dl = DataLoader(imageDataset(split, params, CViters), batch_size=params.batch_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_dataloader(types, dataset_dir, params):\n\n dataloaders = {}\n samplers = {}\n\n for split in ['train', 'val', 'test']:\n if split in types:\n path = os.path.join(dataset_dir, \"{}\".format(split))\n\n # Use the train_transformer if training data, else use eval_trans... | [
"0.77953446",
"0.73648304",
"0.6888941",
"0.6882041",
"0.65158087",
"0.6447888",
"0.6436889",
"0.6422035",
"0.6362394",
"0.6354395",
"0.630299",
"0.62888855",
"0.62565106",
"0.62565106",
"0.62565106",
"0.62565106",
"0.62565106",
"0.62565106",
"0.62565106",
"0.62565106",
"0.62... | 0.75840735 | 1 |
T1_int = 90e3 Intrinsic T1 of the qubit QPT1 = 1.5e6 Guess the lifetime of the quasiparticles half_decay_point = 1e6 The QP_delay time that would make qubit relax halfway to ground state with T1_delay=0, i.e. relax during readout pulse eff_T1_delay = 800.0 The effective T1_delay due to the finite length of the readout ... | def smart_T1_delays(T1_int=90e3, QPT1=1.5e6, half_decay_point=1e6, eff_T1_delay=800.0, probe_point=0.5, meas_per_QPinj=30, meas_per_reptime=5):
# rep_time = 1.0e9/fg.get_frequency()
# T1_QPref = 1/(np.log(2)/eff_T1_delay-1/T1_int) # T1 at half decay point = effective readout delay/ln(2), excluding intrinsi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ipdTft(length,gamma,epsilon,alpha = .8):\r\n #possible previous states (what each did in the last iteration)\r\n states = [(\"*\",\"*\"),(\"C\",\"D\"), (\"C\",\"C\"), (\"D\",\"C\"), (\"D\",\"D\")]\r\n #actions: Defect or Cooperate\r\n actions = [\"D\",\"C\"]\r\n #payoff matrix (as dict)\r\n p... | [
"0.5892847",
"0.5711629",
"0.5668245",
"0.5665878",
"0.55209196",
"0.54578435",
"0.54400754",
"0.5435594",
"0.5414743",
"0.54006404",
"0.54006404",
"0.54000205",
"0.5366368",
"0.533042",
"0.5327378",
"0.5305733",
"0.5301528",
"0.5284758",
"0.52657825",
"0.5231014",
"0.5227927... | 0.85748225 | 0 |
Checks if the container could in theory accept the fluid given. When returning False, accept is never called | async def could_accept_fluid(
cls,
itemstack: ItemStack,
fluidstack: FluidStack,
) -> bool:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def accept_fluid(\n cls,\n itemstack: ItemStack,\n fluidstack: FluidStack,\n insert_parts=True,\n ) -> bool:\n return False",
"async def can_provide_fluid(\n cls,\n itemstack: ItemStack,\n fluidstack: FluidStack,\n ) -> bool:\n return Fal... | [
"0.6557333",
"0.5988655",
"0.5509068",
"0.5440271",
"0.525685",
"0.52441037",
"0.51456326",
"0.5127606",
"0.5126393",
"0.5097903",
"0.5059888",
"0.504443",
"0.5013073",
"0.49919274",
"0.49653342",
"0.49588668",
"0.49395832",
"0.49386904",
"0.49359524",
"0.49305153",
"0.492082... | 0.702076 | 0 |
Inserts a certain amount of fluid The fluidstack may contain remaining liquid if not everything could be accepted if insert_parts is True | async def accept_fluid(
cls,
itemstack: ItemStack,
fluidstack: FluidStack,
insert_parts=True,
) -> bool:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_parts(self, parts):\r\n self.board.insert_parts(parts)\r\n self.set_changed(parts)",
"async def provide_fluid(\n cls,\n itemstack: ItemStack,\n fluidstack: FluidStack,\n extract_parts=True,\n ) -> bool:",
"def insertSlot(self, position, finalsize, propaga... | [
"0.61568004",
"0.5479874",
"0.5202303",
"0.4958527",
"0.48208642",
"0.4809991",
"0.4802973",
"0.47998685",
"0.47818148",
"0.47121218",
"0.4710949",
"0.4706339",
"0.46889675",
"0.46766698",
"0.46664187",
"0.46609753",
"0.46507466",
"0.4641474",
"0.4635545",
"0.4610594",
"0.458... | 0.6628436 | 0 |
Checks if the given fluid container can provide the given fluid with the given amount | async def can_provide_fluid(
cls,
itemstack: ItemStack,
fluidstack: FluidStack,
) -> bool:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def could_accept_fluid(\n cls,\n itemstack: ItemStack,\n fluidstack: FluidStack,\n ) -> bool:\n return False",
"async def accept_fluid(\n cls,\n itemstack: ItemStack,\n fluidstack: FluidStack,\n insert_parts=True,\n ) -> bool:\n return Fa... | [
"0.6258178",
"0.6130406",
"0.58301955",
"0.5805676",
"0.5552054",
"0.54147243",
"0.53036696",
"0.52512157",
"0.52505225",
"0.52373165",
"0.52367795",
"0.52086353",
"0.51716274",
"0.51505864",
"0.5114416",
"0.5110379",
"0.5086769",
"0.5082768",
"0.507358",
"0.5052755",
"0.5001... | 0.66408217 | 0 |
Removes a certain amount of fluid from the container Is allowed to modify the fluidstack when not everything is provided when extract_parts is True | async def provide_fluid(
cls,
itemstack: ItemStack,
fluidstack: FluidStack,
extract_parts=True,
) -> bool: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trim(x):\n # make sure we get a 3D stack not 2D slice\n assert (x.shape) != 3\n if x.shape[-1] > 576:\n newx = x[:,32:-32, 32:-32]\n else:\n newx = x\n return newx[np.newaxis,...]",
"def remove_useless_div(self):\n div_nodes = [node for node in self.nodes() if node.op_type... | [
"0.5234476",
"0.51051915",
"0.507491",
"0.50372875",
"0.49112388",
"0.48782098",
"0.48603016",
"0.485077",
"0.4834302",
"0.48078853",
"0.48017246",
"0.47651115",
"0.47506255",
"0.4742193",
"0.47413254",
"0.47018492",
"0.4694087",
"0.46848938",
"0.46792746",
"0.4675697",
"0.46... | 0.553794 | 0 |
View that allows to assign task quotas for accepted GHOP organization. This view allows the program admin to set the task quota limits and change them at any time when the program is active. | def assignTaskQuotas(self, request, access_type, page_name=None,
params=None, filter=None, **kwargs):
# TODO: Once GAE Task APIs arrive, this view will be managed by them
program_entity = ghop_program_logic.logic.getFromKeyFieldsOr404(kwargs)
from soc.modules.ghop.views.models impor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assignTaskQuotasGet(self, request, context, org_params,\n page_name, params, entity, **kwargs):\n\n from soc.modules.ghop.views.models.organization import view as org_view\n \n logic = params['logic']\n program_entity = logic.getFromKeyFieldsOr404(kwargs)\n \n org_par... | [
"0.7411483",
"0.6703575",
"0.63483495",
"0.598709",
"0.59854597",
"0.58200175",
"0.5791137",
"0.5775227",
"0.56800556",
"0.56640637",
"0.5663814",
"0.5625307",
"0.56105137",
"0.53730065",
"0.5361226",
"0.53318155",
"0.5325526",
"0.52944356",
"0.52893436",
"0.5245989",
"0.5244... | 0.6804764 | 1 |
Handles the POST request for the task quota allocation page. | def assignTaskQuotasPost(self, request, context, org_params,
page_name, params, entity, **kwargs):
ghop_org_logic = org_params['logic']
error_orgs = ''
for link_id, task_count in request.POST.items():
fields = {
'link_id': link_id,
'scope': entity,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assignTaskQuotasGet(self, request, context, org_params,\n page_name, params, entity, **kwargs):\n\n from soc.modules.ghop.views.models.organization import view as org_view\n \n logic = params['logic']\n program_entity = logic.getFromKeyFieldsOr404(kwargs)\n \n org_par... | [
"0.60221636",
"0.5842323",
"0.5726367",
"0.5721088",
"0.5623718",
"0.5616648",
"0.5288906",
"0.5278047",
"0.5238898",
"0.52262145",
"0.5210421",
"0.51569146",
"0.5149547",
"0.5121791",
"0.5119199",
"0.50712955",
"0.5056978",
"0.5052108",
"0.5050397",
"0.5049965",
"0.5036452",... | 0.6783139 | 0 |
Handles the GET request for the task quota allocation page. | def assignTaskQuotasGet(self, request, context, org_params,
page_name, params, entity, **kwargs):
from soc.modules.ghop.views.models.organization import view as org_view
logic = params['logic']
program_entity = logic.getFromKeyFieldsOr404(kwargs)
org_params['list_tem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show(self, req, tenant_id, id):\n LOG.info(\"Indexing quota info for tenant '%(id)s'\\n\"\n \"req : '%(req)s'\\n\\n\", {\"id\": id, \"req\": req})\n\n context = req.environ[wsgi.CONTEXT_KEY]\n if id != tenant_id and not context.is_admin:\n raise exception.TroveOp... | [
"0.6443864",
"0.6412696",
"0.6097484",
"0.6028667",
"0.59382164",
"0.5762788",
"0.5729395",
"0.55972415",
"0.55917937",
"0.5580373",
"0.547017",
"0.5430022",
"0.5415658",
"0.5407623",
"0.53178394",
"0.53146815",
"0.52996427",
"0.5211656",
"0.51968664",
"0.50985384",
"0.506178... | 0.6840709 | 0 |
View method used to edit Task Type tags. | def taskTypeEdit(self, request, access_type, page_name=None,
params=None, filter=None, **kwargs):
params = dicts.merge(params, self._params)
try:
entity = self._logic.getFromKeyFieldsOr404(kwargs)
except out_of_band.Error, error:
return helper.responses.errorResponse(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def taskTypeTagEdit(self, request, access_type, page_name=None,\n params=None, filter=None, **kwargs):\n\n get_params = request.GET\n\n order = get_params.getlist('order')\n program_key_name = get_params.get('program_key_name')\n\n program_entity = ghop_program_logic.logic.getFromK... | [
"0.7168224",
"0.6094467",
"0.5898548",
"0.5641401",
"0.5553177",
"0.55296516",
"0.5519473",
"0.551101",
"0.54902524",
"0.54667073",
"0.5450806",
"0.54396856",
"0.5430242",
"0.54250866",
"0.5413324",
"0.53181523",
"0.5293028",
"0.5252777",
"0.52232796",
"0.5208241",
"0.5195102... | 0.7190762 | 0 |
View method used to edit a supplied Task Type tag. | def taskTypeTagEdit(self, request, access_type, page_name=None,
params=None, filter=None, **kwargs):
get_params = request.GET
order = get_params.getlist('order')
program_key_name = get_params.get('program_key_name')
program_entity = ghop_program_logic.logic.getFromKeyName(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def taskTypeEdit(self, request, access_type, page_name=None,\n params=None, filter=None, **kwargs):\n\n params = dicts.merge(params, self._params)\n\n try:\n entity = self._logic.getFromKeyFieldsOr404(kwargs)\n except out_of_band.Error, error:\n return helper.responses.errorRes... | [
"0.75198364",
"0.6854278",
"0.64941573",
"0.6300326",
"0.59668833",
"0.5938335",
"0.5938012",
"0.59221256",
"0.59047407",
"0.58689153",
"0.5763128",
"0.5722479",
"0.5676428",
"0.56655097",
"0.5614879",
"0.5550425",
"0.54831946",
"0.54711336",
"0.5467548",
"0.5466259",
"0.5454... | 0.7372973 | 1 |
List all the accepted orgs for the given program. | def acceptedOrgs(self, request, access_type,
page_name=None, params=None, filter=None, **kwargs):
from soc.modules.ghop.views.models.organization import view as org_view
logic = params['logic']
program_entity = logic.getFromKeyFieldsOr404(kwargs)
fmt = {'name': program_entity.name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def program(cls, program):\n search_str = ArtePlus7.PROGRAMS[program]\n all_programs = cls.search(search_str)\n programs = [p for p in all_programs if p.name == program]\n return programs",
"def list_orgs(self):\n orgs = list(self.orgs.keys())\n orgs.sort()\n retu... | [
"0.5811697",
"0.5592299",
"0.54907256",
"0.54396605",
"0.5346195",
"0.52138436",
"0.52085614",
"0.5186158",
"0.5172441",
"0.50362426",
"0.50262475",
"0.5017905",
"0.50124145",
"0.49932298",
"0.4930581",
"0.49157086",
"0.4905166",
"0.48753628",
"0.48668417",
"0.4837194",
"0.47... | 0.65828925 | 0 |
Load point cloud from filename csv | def from_csv(self, filename):
points = np.genfromtxt(filename, delimiter=",")
assert points.shape[1] == 2
self.N = points.shape[0]
self.points = points
self.original_points = points | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_point_cloud(self, filename):\n f = sio.loadmat(filename)\n data = f['blob'][:]\n data -= np.mean(data, 0)\n data /= np.amax(abs(data))\n label = DataHandler.get_label_from_filename(filename)\n if self.use_softmax:\n l = np.zeros([2])\n l[labe... | [
"0.68757343",
"0.6783464",
"0.6693441",
"0.66853374",
"0.6428212",
"0.63949144",
"0.6363062",
"0.6356902",
"0.63549",
"0.6341535",
"0.63358086",
"0.63152814",
"0.6303154",
"0.62307936",
"0.6193113",
"0.6186763",
"0.61776775",
"0.61501724",
"0.6141395",
"0.6133267",
"0.6115353... | 0.6849514 | 1 |
Two dimensional rotation matrix to rotate a line parallel with xaxis given gradient m If m is negative, we want to rotate through | arctan(m) | degrees, while if m is positive we want to rotate through |arctan(m)|. But sgn(arctan(m)) = sgn(m), so set theta = np.arctan(m). | def _rotation_from_gradient(self,m):
theta = -np.arctan(m)
self.current_theta = theta
return self._rotation_from_angle(theta) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rotate_(self, x: np.array, m: np.array) -> (np.array, np.array):\n # get a random angle\n angle = np.random.randint(0, self.rotate)\n # get a random sign for the angle\n sign = np.random.randint(0, 2)\n x = rotate(x, -sign * angle, reshape=False)\n m = rotate(m, -sign... | [
"0.66367084",
"0.639626",
"0.632834",
"0.6299804",
"0.6273584",
"0.6244695",
"0.61834306",
"0.617259",
"0.61208767",
"0.6080826",
"0.607324",
"0.6051412",
"0.60360944",
"0.60246086",
"0.6020136",
"0.59961134",
"0.5995045",
"0.5949767",
"0.5941537",
"0.59287906",
"0.59282464",... | 0.7921828 | 0 |
Reverse hat transformation on a vector P_star = (0,c) > (x,y) | def rev_hat_transformation(self, P_star):
rotation_matrix = self._rotation_from_angle(self.current_theta)
P_star = np.dot(rotation_matrix, P_star)
P_star = P_star + self.current_point
return P_star | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hat(B):\n\n U, S, V = svd(B, False)\n H = dot(U, U.T)\n return H",
"def h( self , x , u , t ):\n \n #y = np.zeros(self.p) # Output vector\n \n y = x # default output is all states\n \n return y",
"def __invert__(self):\n \n return Vector... | [
"0.5672115",
"0.5627254",
"0.556655",
"0.55468315",
"0.55394346",
"0.5536857",
"0.55222523",
"0.55082595",
"0.5462884",
"0.54502594",
"0.5447146",
"0.5425735",
"0.54064816",
"0.5405898",
"0.54054534",
"0.53994673",
"0.53970295",
"0.53636795",
"0.5353813",
"0.53451127",
"0.533... | 0.74490964 | 0 |
For xy = (x,y) fit a weighted (by W) regression of the form y = ax^2 + bx + c, then return c | def quadratic_fit(self, xy, W):
# first construct the independent matrix
y = xy[:,1]
x = xy[:,0]
X = np.column_stack([np.ones(len(x)),
x, np.power(x,2)])
wls_model = sm.WLS(y, X, weights = 1.0/W)
wls_model_results = wls_model.fit()
[c,b,a] = wls_model_results.params
return [a,b,c] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit(self, X, y):\n # compute W, b\n # pull W from the normal distribution, and b from 0->2 pi\n\n self.N, d = X.shape\n\n # weights go from R^d -> R^D\n self.W = rng.normal(loc=0, scale=1, size=(self.D, d))\n # bias is in R, need D terms\n self.b = rng.uniform(0... | [
"0.6684267",
"0.6327786",
"0.6317065",
"0.6277411",
"0.62769395",
"0.62406504",
"0.62039423",
"0.61945146",
"0.6172592",
"0.6167964",
"0.61626905",
"0.61591876",
"0.61528915",
"0.61344075",
"0.61161375",
"0.61022925",
"0.61022925",
"0.61022925",
"0.6084247",
"0.6078178",
"0.6... | 0.70182323 | 0 |
setting of Target and Features of ML_data + choose beetween ModelQua() or ModelQuali() depend of Target type | def test(self, test):
self.ml_data.set_target(test[0])
self.ml_data.set_features(test[1])
if self.ml_data.target_type.all() == np.float64 or self.ml_data.target_type.all() == np.int64:
self.model_qua.open()
else:
self.model_quali.open() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit(self, features, targets):\n self.model_features = features\n self.model_targets= targets",
"def trainModel( self, featureTrain, classTrain):",
"def train(self, data, option, param_map):\n if option == \"lr\":\n md = self.logistic_regression(elastic_param=param_map[\"elas... | [
"0.63262177",
"0.6296559",
"0.6171426",
"0.60570484",
"0.6000306",
"0.5971856",
"0.58749247",
"0.5794077",
"0.5762501",
"0.5744882",
"0.573404",
"0.5730235",
"0.572915",
"0.5695069",
"0.56850237",
"0.56704247",
"0.5665366",
"0.56612265",
"0.5653308",
"0.56507576",
"0.5641448"... | 0.710821 | 0 |
Launch all model from dict signal of ModelQua() After the result output from model Will be stored in the result windows by a setting and then these windows will be sent to the main window by signal | def model_qua_launch(self, dict):
list_result = []
if "SVR" in dict:
SVR = dict["SVR"]
if SVR["Auto"]:
result = SVR_b(self.ml_data.feature, self.ml_data.target, SVR["Auto"])
model, score, graph, time = result
result_win = Win... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setModels(self):\n \n if self.showDirectResult: \n table = QTableView()\n view = MSTableView(table, model=self.buildModel(self.sampleList[0].rawPeaks[0]), selection=True)\n self.qApp.view.addMdiSubWindow(view, \"identification of mapped peaks of %s\"%self.s... | [
"0.6662796",
"0.6181124",
"0.6070383",
"0.6039999",
"0.58284736",
"0.5803053",
"0.56733716",
"0.5660017",
"0.5644201",
"0.5588236",
"0.5575847",
"0.5516149",
"0.55106914",
"0.5496581",
"0.5459005",
"0.5449541",
"0.5434256",
"0.5430283",
"0.54299176",
"0.5406696",
"0.53593963"... | 0.74788404 | 0 |
Function which browse csv file/Text file/Xlsx file | def browse_1(self):
file = QFileDialog()
filter_name = "Csv files (*.csv);;Text files (*.txt);;Xls files (*.xls);; Xlsx files (*.xlsx)"
file.setNameFilter(filter_name)
if file.exec():
filenames = file.selectedFiles()
self.browseLine.setText(str(filenames[0])... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def browse(self):\n formats = [\n \"Text - comma separated (*.csv, *)\",\n \"Text - tab separated (*.tsv, *)\",\n \"Text - all files (*)\"\n ]\n\n dlg = QFileDialog(\n self, windowTitle=\"Open Data File\",\n acceptMode=QFileDialog.AcceptOp... | [
"0.67593515",
"0.66040856",
"0.6513391",
"0.6458141",
"0.62818354",
"0.6260895",
"0.6206894",
"0.6027771",
"0.60216516",
"0.60052425",
"0.58967555",
"0.5893942",
"0.586425",
"0.5851608",
"0.5804941",
"0.5784217",
"0.57512665",
"0.57025474",
"0.5694707",
"0.5684429",
"0.568388... | 0.6673959 | 1 |
Returns true if the success status is between [200, 300). | def _default_is_success(status_code):
return status_code >= 200 and status_code < 300 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def result_success(result):\n\n if 200 <= result < 300:\n return True\n\n return False",
"def is_success(self):\r\n if self.status_code < 400:\r\n return True\r\n return False",
"def is_success(self):\r\n if self.status_code < 400:\r\n return ... | [
"0.7914325",
"0.73219746",
"0.73219746",
"0.7060564",
"0.6745932",
"0.66712356",
"0.65533984",
"0.65164405",
"0.64274627",
"0.6422827",
"0.6405921",
"0.6352617",
"0.6296991",
"0.6269795",
"0.6269795",
"0.62214124",
"0.62176394",
"0.6188059",
"0.6145357",
"0.61120003",
"0.6093... | 0.740333 | 1 |
Silence warnings from requests.packages.urllib3. See DCOS1007. | def silence_requests_warnings():
requests.packages.urllib3.disable_warnings() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DisableSSLVerify():\n\n\t\ttry:\n\t\t\trequests.packages.urllib3.disable_warnings()\n\t\texcept:\n\t\t\tpass",
"def no_additional_complaints() -> None:\n logging.getLogger(\"asyncio\").setLevel(\"CRITICAL\")\n warnings.simplefilter(\"ignore\")",
"def ignore_warnings(my_func):\n\n def wrapper(self,... | [
"0.69257754",
"0.61207926",
"0.6016308",
"0.6011752",
"0.58316225",
"0.56686425",
"0.56470096",
"0.55972177",
"0.5583384",
"0.55542463",
"0.55511755",
"0.54967076",
"0.5340722",
"0.5340722",
"0.5340722",
"0.5340722",
"0.5340722",
"0.5340722",
"0.5340722",
"0.5340722",
"0.5331... | 0.8688666 | 0 |
Sift up an element in the heap. | def _sift_up(self, i):
while i > 0:
p = (i-1)//2
if self._heap[i] < self._heap[p]:
self._swap(i, p)
i = p
else:
break | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sift_up(self, index):\n if self.size() == 1:\n return\n parent_index = self.parent(index)\n # sift up if it is larger than its parent\n while index > 0 and self.heap[index] > self.heap[parent_index]:\n self.heap[index], self.heap[parent_index] = self.heap[paren... | [
"0.821945",
"0.7959089",
"0.7853257",
"0.77530557",
"0.7692144",
"0.7648635",
"0.7554632",
"0.7554632",
"0.7523918",
"0.7507099",
"0.7501031",
"0.7402723",
"0.7287082",
"0.72624105",
"0.72581136",
"0.7222675",
"0.7200926",
"0.7080144",
"0.70542455",
"0.7007618",
"0.7006154",
... | 0.79797375 | 1 |
Sift down an element in the heap. | def _sift_down(self, i):
mini = i
l = 2*i + 1
if l < self._size and\
self._heap[l] < self._heap[mini]:
mini = l
r = 2*i + 2
if r < self._size and\
self._heap[r] < self._heap[mini]:
mini = r
if mini != i:
self._sw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __siftup(heap, nodes, pos, stopPos = 0):\n # Loop until past stopping position\n while pos > stopPos:\n # Set parent position\n parentPos = (pos - 1) >> 1\n\n # Swap if child less than parent\n if heap[pos][0] < heap[parentPos][0]:\n Grap... | [
"0.77886724",
"0.7721911",
"0.7647797",
"0.76317453",
"0.74968386",
"0.7436151",
"0.7389913",
"0.7355171",
"0.72879857",
"0.7270983",
"0.72180074",
"0.71543145",
"0.71488154",
"0.7137806",
"0.7124663",
"0.7124663",
"0.7111923",
"0.70747966",
"0.7052639",
"0.7049477",
"0.70183... | 0.7802144 | 0 |
return the index of the current cup, it moves around while we poke and prod the list | def current_cup_idx(self):
return self.cups.index(self.current_cup) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pick_up_1_cup(self) -> int:\n current_position = self.cups.index(self.current)\n if current_position < len(self.cups) - 1: # Current cup is not on the end of the list.\n return self.cups.pop(current_position + 1)\n return self.cups.pop(0)",
"def select_new_current_cup(self)... | [
"0.7146994",
"0.67673033",
"0.67197514",
"0.64592206",
"0.5957742",
"0.5853137",
"0.5770496",
"0.5722364",
"0.5686424",
"0.56243104",
"0.55375403",
"0.5475489",
"0.54686207",
"0.5448841",
"0.5423443",
"0.5419709",
"0.53983104",
"0.539803",
"0.5392012",
"0.5384782",
"0.5368565... | 0.7591079 | 0 |
remove the cup after the provided index from the list and return it | def take_cup_after(self, idx: int):
target_idx = idx + 1
if target_idx >= len(self.cups):
target_idx = 0
result = self.cups[target_idx]
del self.cups[target_idx]
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, index):\n self.__validate_index(index)\n value = self.__list[index]\n self.__list = self.__list[:index] + self.__list[index + 1:]\n return value",
"def remove_from_list(self,list_,index):\r\n try:\r\n return list_.pop(self._index_to_int(index))\r\n ... | [
"0.7149489",
"0.7007915",
"0.6613231",
"0.6446563",
"0.63091123",
"0.62467587",
"0.62387824",
"0.6231107",
"0.62284297",
"0.62177646",
"0.6153903",
"0.6117337",
"0.60955703",
"0.6070349",
"0.60495186",
"0.6035283",
"0.60228014",
"0.60223246",
"0.59714824",
"0.5937881",
"0.591... | 0.7583994 | 0 |
insert [cups_to_insert] to the right of target_idx | def add_cups(self, target_idx, cups_to_insert):
part_a = self.cups[0 : target_idx + 1]
part_b = self.cups[target_idx + 1 :]
print(f"cups: {self.cups} part_a[{part_a}], part_b[{part_b}]")
self.cups = part_a + cups_to_insert + part_b | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_index(self):\n pass",
"def moveCurveToIndex(self, idxsource, idxtarget):\n tmp = self.data.pop(idxsource)\n self.data.insert(idxtarget, tmp)\n return True",
"def insert(self, indexes: Tuple[int, ...], tree: 'Tree') -> None:\n ...",
"def join_index(file_name, targ... | [
"0.60429084",
"0.5753519",
"0.5515036",
"0.55132055",
"0.5404266",
"0.5384004",
"0.53823304",
"0.5380641",
"0.52677786",
"0.52226144",
"0.5214957",
"0.51667833",
"0.51560074",
"0.5120977",
"0.51053214",
"0.51030535",
"0.5024681",
"0.5020633",
"0.50172246",
"0.49900654",
"0.49... | 0.78624845 | 0 |
Make one move in the cup game.. The crab picks up the three cups that are immediately clockwise of the current cup. They are removed from the circle; cup spacing is adjusted as necessary to maintain the circle. | def play_one_move(self):
self.print("top of move")
# 1) grab three cups
c1 = self.take_cup_after(self.current_cup_idx())
c2 = self.take_cup_after(self.current_cup_idx())
c3 = self.take_cup_after(self.current_cup_idx())
print(f"pick up: {c1}, {c2}, {c3}")
self.prin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def moveCirc(self):\n\t\tfor circle in self.circles:\n\t\t\tcircle.moveStep()",
"def com_turn(self):\r\n circle = copy.deepcopy(self.circle)\r\n# Creates a turtle to use in the computer turns\r\n t = turtle.Turtle()\r\n t.hideturtle()\r\n com_take= circle%5\r\n if com_take==0:\... | [
"0.65909505",
"0.6432389",
"0.63179606",
"0.6248185",
"0.5985733",
"0.58992255",
"0.5889503",
"0.5846774",
"0.58458936",
"0.5811926",
"0.57429713",
"0.5737269",
"0.5697694",
"0.5640242",
"0.56055504",
"0.56015927",
"0.5592851",
"0.5511586",
"0.54701674",
"0.5468903",
"0.54591... | 0.70051146 | 0 |
Generate random attitudes To generate a random quaternion a mapping in SO(3) is first created and then transformed as explained originally by [Shoemake]_ and summarized in [Kuffner]_. | def random_attitudes(n: int = 1, representation: str = 'quaternion') -> np.ndarray:
if not isinstance(n, int):
raise TypeError(f"n must be an integer. Got {type(n)}")
if n < 1:
raise ValueError(f"n must be greater than 0. Got {n}")
if not isinstance(representation, str):
raise TypeEr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_rotate():\n u = np.random.uniform(size=3)\n\n # Random quaternion\n q = np.array([np.sqrt(1-u[0])*np.sin(2*np.pi*u[1]),\n np.sqrt(1-u[0])*np.cos(2*np.pi*u[1]),\n np.sqrt(u[0])*np.sin(2*np.pi*u[2]),\n np.sqrt(u[0])*np.cos(2*np.pi*u[2])])\n \n # Convert the q... | [
"0.669615",
"0.661402",
"0.6477656",
"0.6466201",
"0.6424329",
"0.6349754",
"0.6294519",
"0.62690204",
"0.6232189",
"0.61595255",
"0.61102754",
"0.60693043",
"0.5926776",
"0.59151584",
"0.5884495",
"0.5877461",
"0.58065665",
"0.57699054",
"0.56350946",
"0.561055",
"0.5588173"... | 0.69179857 | 0 |
Third element of the vector part of the Quaternion. | def z(self) -> float:
return self.A[3] if self.scalar_vector else self.A[2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def I3_u3(self) -> complex:\n return self.I3_u1() * cmath.rect(1, 120 / 180 * cmath.pi)",
"def vector3(x, y, z):\n return np.array([x, y, z], dtype=np.float)",
"def vector3(x, y, z):\n return np.array([x, y, z], dtype=float)",
"def x3(self):\n return self._x + self._x3",
"def I3_u1(self... | [
"0.6793091",
"0.6354686",
"0.6310501",
"0.629769",
"0.6229241",
"0.6211433",
"0.6158919",
"0.61401063",
"0.6086546",
"0.60671574",
"0.60487324",
"0.6037592",
"0.6028574",
"0.6008026",
"0.60024035",
"0.59860307",
"0.5975794",
"0.5969387",
"0.59557444",
"0.59555686",
"0.5933567... | 0.6457046 | 1 |
Exponential of Quaternion The quaternion exponential works as in the ordinary case, defined with | def exponential(self) -> np.ndarray:
if self.is_real():
return np.array([1.0, 0.0, 0.0, 0.0])
t = np.linalg.norm(self.v)
u = self.v/t
q_exp = np.array([np.cos(t), *u*np.sin(t)])
if self.is_pure():
return q_exp
q_exp *= np.e**self.w
return q... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exp(cls, q):\n tolerance = 1e-17\n v_norm = np.linalg.norm(q.vector)\n vec = q.vector\n if v_norm > tolerance:\n vec = vec / v_norm\n magnitude = exp(q.scalar)\n return Quaternion(scalar = magnitude * cos(v_norm), vector = magnitude * sin(v_norm) * vec)",
... | [
"0.77629757",
"0.7213486",
"0.70180804",
"0.682456",
"0.66706365",
"0.6653395",
"0.6598257",
"0.6447853",
"0.63795894",
"0.6351678",
"0.6327198",
"0.6223102",
"0.6176798",
"0.6152401",
"0.615056",
"0.612286",
"0.608904",
"0.6088102",
"0.6056831",
"0.6003446",
"0.5965981",
"... | 0.74150074 | 1 |
Returns array of quaternion to the power of ``a`` Assuming the quaternion is a versor, its power can be defined using the | def __pow__(self, a: float) -> np.ndarray:
return np.e**(a*self.logarithm) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def power(self, a):\n if self.getDegree() == -1:\n return Polynomial([])\n \n if a == 0:\n return Polynomial([1])\n \n root = self.power(a/2)\n if a % 2 == 0:\n return root.multiply(root)\n \n else:\n return root.mu... | [
"0.67424685",
"0.64013994",
"0.59977734",
"0.57419217",
"0.5641796",
"0.5641358",
"0.55518377",
"0.55466807",
"0.55255187",
"0.54125184",
"0.54019636",
"0.5397587",
"0.5384828",
"0.5372495",
"0.5359254",
"0.5335806",
"0.53277475",
"0.5322797",
"0.53170353",
"0.53149205",
"0.5... | 0.65999967 | 1 |
Returns a bool value, where ``True`` if quaternion is pure. | def is_pure(self) -> bool:
return self.w==0.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_pure(self):\r\n return True",
"def is_pure(self) -> bool:\r\n return self.is_valid and np.all([x[\"operation\"].is_pure for x in self.operations_by_name.values()])",
"def test_check_quaternion():\n q_list = [1, 0, 0, 0]\n q = pr.check_quaternion(q_list)\n assert_array_almost_equal... | [
"0.6396453",
"0.6283286",
"0.6101912",
"0.59468055",
"0.5885787",
"0.5799285",
"0.5798887",
"0.57788783",
"0.576559",
"0.5762862",
"0.57241136",
"0.57171667",
"0.5717132",
"0.57046723",
"0.5689904",
"0.56590533",
"0.5645887",
"0.5569135",
"0.5559882",
"0.55593055",
"0.5520994... | 0.69090956 | 0 |
Returns a bool value, where ``True`` if quaternion is real. | def is_real(self) -> bool:
return not any(self.v) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_real(self):\r\n return self._imag.is_zero()",
"def is_real(self):\n return all([isinstance(dim, Real) for dim in self.dimensions])",
"def is_same_quaternion(q0, q1):\r\n q0 = numpy.array(q0)\r\n q1 = numpy.array(q1)\r\n return numpy.allclose(q0, q1) or numpy.allclose(q0, -q1)",
... | [
"0.6654259",
"0.65283984",
"0.6380824",
"0.63371676",
"0.6321449",
"0.62616616",
"0.622338",
"0.6177528",
"0.61768085",
"0.6135937",
"0.61193335",
"0.60988134",
"0.6009501",
"0.60006416",
"0.59393764",
"0.592297",
"0.58443695",
"0.58435535",
"0.58217216",
"0.580912",
"0.57537... | 0.660653 | 1 |
Returns a bool value, where ``True`` if quaternion is a versor. | def is_versor(self) -> bool:
return np.isclose(np.linalg.norm(self.A), 1.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isVersor(self) -> bool:\n\n Vhat = self.gradeInvol()\n Vrev = ~self\n Vinv = Vrev/(self*Vrev)[0]\n\n gpres = grades_present(Vhat*Vinv, 0.000001)\n if len(gpres) == 1:\n if gpres[0] == 0:\n if np.sum(np.abs((Vhat*Vinv).value - (Vinv*Vhat).value)) < 0.... | [
"0.6624686",
"0.6141388",
"0.607578",
"0.58304137",
"0.5686447",
"0.5610308",
"0.5585004",
"0.55494475",
"0.5529789",
"0.54932797",
"0.54904616",
"0.54658014",
"0.5465406",
"0.54376364",
"0.53878516",
"0.5376702",
"0.5349552",
"0.52943695",
"0.52917916",
"0.52914804",
"0.5284... | 0.6576094 | 1 |
Returns a bool value, where ``True`` if quaternion is identity quaternion. An identity quaternion has its scalar part equal to 1, and its | def is_identity(self) -> bool:
return np.allclose(self.A, np.array([1.0, 0.0, 0.0, 0.0])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_identity(self):\n if self.domain() != self.codomain():\n return False\n # testing for the identity matrix will only work for\n # endomorphisms which have the same basis for domain and codomain\n # so we test equality on a basis, which is sufficient\n return ... | [
"0.7109503",
"0.69755125",
"0.6887652",
"0.628405",
"0.61470884",
"0.61040676",
"0.6058109",
"0.60360384",
"0.5997914",
"0.59737426",
"0.58850616",
"0.58454806",
"0.5800313",
"0.5777062",
"0.573623",
"0.5719141",
"0.56766295",
"0.56581765",
"0.56505877",
"0.56291234",
"0.5592... | 0.70858943 | 1 |
Quaternion from given RPY angles. The quaternion can be constructed from the Aerospace cardanian angle | def from_rpy(self, angles: np.ndarray) -> np.ndarray:
_assert_iterables(angles, 'Roll-Pitch-Yaw angles')
angles = np.array(angles)
if angles.ndim != 1 or angles.shape[0] != 3:
raise ValueError(f"Expected `angles` must have shape (3,), got {angles.shape}.")
for angle in angles... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_rpy(self, Angles: np.ndarray) -> np.ndarray:\n _assert_iterables(Angles, 'Roll-Pitch-Yaw angles')\n Angles = np.copy(Angles)\n if Angles.ndim != 2 or Angles.shape[-1] != 3:\n raise ValueError(f\"Expected `angles` must have shape (N, 3), got {Angles.shape}.\")\n # RPY... | [
"0.72458893",
"0.7219291",
"0.7140985",
"0.7110881",
"0.7102752",
"0.7051442",
"0.6981416",
"0.6928739",
"0.69277245",
"0.68430847",
"0.6818834",
"0.6807934",
"0.6774795",
"0.67527354",
"0.6746149",
"0.6664876",
"0.66427106",
"0.6594205",
"0.65873754",
"0.65663016",
"0.655875... | 0.7358275 | 0 |
Returns an array of boolean values, where a value is ``True`` if its corresponding quaternion is pure. | def is_pure(self) -> np.ndarray:
return np.isclose(self.w, np.zeros_like(self.w.shape[0])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_quaternion():\n q_list = [1, 0, 0, 0]\n q = pr.check_quaternion(q_list)\n assert_array_almost_equal(q_list, q)\n assert_equal(type(q), np.ndarray)\n assert_equal(q.dtype, np.float64)\n\n random_state = np.random.RandomState(0)\n q = random_state.randn(4)\n q = pr.check_quater... | [
"0.5961922",
"0.56531376",
"0.56339306",
"0.56226987",
"0.5518682",
"0.55110884",
"0.5493016",
"0.5473003",
"0.5443064",
"0.5402659",
"0.53975224",
"0.538451",
"0.5331396",
"0.52891237",
"0.5267912",
"0.5235985",
"0.52105314",
"0.51778424",
"0.5168667",
"0.5147354",
"0.514050... | 0.5986106 | 0 |
Returns an array of boolean values, where a value is ``True`` if its corresponding quaternion is real. | def is_real(self) -> np.ndarray:
return np.all(np.isclose(self.v, np.zeros_like(self.v)), axis=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_boolean_vector(f,q,r,DIMS):\n b = None\n for i in range(DIMS):\n if b is None:\n b = (f[:,i]<q[i]+r[i]) & (f[:,i]>q[i])\n else :\n b = b & (f[:,i]<q[i]+r[i]) & (f[:,i]>q[i])\n return b",
"def test_check_quaternion():\n q_list = [1, 0, 0, 0]\n q = p... | [
"0.61067146",
"0.5979163",
"0.5943935",
"0.59045786",
"0.57789",
"0.57787526",
"0.56879425",
"0.5658934",
"0.5658666",
"0.5624529",
"0.5575649",
"0.551808",
"0.53933126",
"0.5277632",
"0.52341044",
"0.5207885",
"0.51732683",
"0.5141719",
"0.51355517",
"0.5106095",
"0.50997406... | 0.6612799 | 0 |
Returns an array of boolean values, where a value is ``True`` if its corresponding quaternion has a norm equal to one. A versor is a quaternion, whose `euclidean norm | def is_versor(self) -> np.ndarray:
return np.isclose(np.linalg.norm(self.array, axis=1), 1.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_quaternions():\n Q_list = [[1, 0, 0, 0]]\n Q = pr.check_quaternions(Q_list)\n assert_array_almost_equal(Q_list, Q)\n assert_equal(type(Q), np.ndarray)\n assert_equal(Q.dtype, np.float64)\n assert_equal(Q.ndim, 2)\n assert_array_equal(Q.shape, (1, 4))\n\n Q = np.array([\n ... | [
"0.5856265",
"0.5821219",
"0.57011765",
"0.5637552",
"0.5497815",
"0.54871833",
"0.54563683",
"0.5391063",
"0.53876686",
"0.5356134",
"0.53234273",
"0.52845675",
"0.5278347",
"0.5269679",
"0.52634925",
"0.5238706",
"0.52078223",
"0.51939327",
"0.519059",
"0.5169945",
"0.51685... | 0.66096723 | 0 |
Returns an array of boolean values, where a value is ``True`` if its quaternion is equal to the identity quaternion. An identity quaternion has its scalar part equal to 1, and its | def is_identity(self) -> np.ndarray:
if self.scalar_vector:
return np.all(np.isclose(self.array, np.tile([1., 0., 0., 0.], (self.array.shape[0], 1))), axis=1)
return np.all(np.isclose(self.array, np.tile([0., 0., 0., 1.], (self.array.shape[0], 1))), axis=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_identity(self) -> bool:\n return np.allclose(self.A, np.array([1.0, 0.0, 0.0, 0.0]))",
"def identity() -> Quaternion:\n return Quaternion(1, np.array([0, 0, 0]))",
"def has_equal_values_vec(x):\n return jnp.all(x == x[0])",
"def is_identity(self):\n if self.domain() != self.cod... | [
"0.6140441",
"0.5773314",
"0.5722752",
"0.5606294",
"0.5585368",
"0.5525312",
"0.5476391",
"0.54104227",
"0.53336585",
"0.5297858",
"0.52870846",
"0.52720225",
"0.52336746",
"0.5204923",
"0.5202606",
"0.5199137",
"0.5159378",
"0.5142767",
"0.5110038",
"0.5072934",
"0.50708324... | 0.67343414 | 0 |
Quaternion Array from given RPY angles. The quaternion can be constructed from the Aerospace cardanian angle | def from_rpy(self, Angles: np.ndarray) -> np.ndarray:
_assert_iterables(Angles, 'Roll-Pitch-Yaw angles')
Angles = np.copy(Angles)
if Angles.ndim != 2 or Angles.shape[-1] != 3:
raise ValueError(f"Expected `angles` must have shape (N, 3), got {Angles.shape}.")
# RPY to Quaterni... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_rpy(self, angles: np.ndarray) -> np.ndarray:\n _assert_iterables(angles, 'Roll-Pitch-Yaw angles')\n angles = np.array(angles)\n if angles.ndim != 1 or angles.shape[0] != 3:\n raise ValueError(f\"Expected `angles` must have shape (3,), got {angles.shape}.\")\n for ang... | [
"0.7644639",
"0.7046615",
"0.69144994",
"0.6751744",
"0.67498493",
"0.67286915",
"0.6699655",
"0.6676206",
"0.66539806",
"0.66473985",
"0.66402453",
"0.6624343",
"0.6602038",
"0.65801984",
"0.6568063",
"0.6566676",
"0.6558134",
"0.6548521",
"0.649762",
"0.64747137",
"0.643528... | 0.7633397 | 1 |
Compute the angular velocity between N Quaternions. It assumes a constant sampling rate of ``dt`` seconds, and returns the angular velocity around the X, Y and Zaxis (rollpitchyaw angles), in radians per second. | def angular_velocities(self, dt: float) -> np.ndarray:
if not isinstance(dt, float):
raise TypeError(f"dt must be a float. Got {type(dt)}.")
if dt <= 0:
raise ValueError(f"dt must be greater than zero. Got {dt}.")
w = np.c_[
self.w[:-1]*self.x[1:] - self.x[:-1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_angular_velocity(r, T):\n # http://www.hep.fsu.edu/~berg/teach/phy2048/0918.pdf\n # velocity = 2(pi)r/T\n return (2*math.pi*r)/T",
"def angular_velocity(self):\n trig = gyro_trigger_mode.GET_ANGULAR_VELOCITY_TRIGGER_READ\n if self.__trigger == trig:\n self.re... | [
"0.60365844",
"0.589868",
"0.5530912",
"0.5343137",
"0.5340064",
"0.531805",
"0.52950907",
"0.52598435",
"0.5248815",
"0.5240846",
"0.51982886",
"0.518282",
"0.51756936",
"0.5173302",
"0.5148685",
"0.5147778",
"0.5134542",
"0.5054865",
"0.5037756",
"0.50374854",
"0.4996944",
... | 0.7034754 | 0 |
Visualize a quantiative measurement on a label image by replacing the label IDs with specified table colum values. | def visualize_measurement_on_labels(labels_layer:"napari.layers.Labels", column:str = "label", viewer:"napari.Viewer" = None) -> "napari.types.ImageData":
import pandas as pd
import dask.array as da
from dask import delayed
from functools import partial
from napari.utils import notifications
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conf_mat(label, cm):\n for i in range(len(label)):\n cm_pd = pd.DataFrame(data=cm[i],\n index=['ICEV', 'EV'],\n columns=['ICEV', 'EV'])\n cm_pd = cm_pd.style.set_caption(label[i])\n display(cm_pd)",
"def make_cutout_table(ra_in, ... | [
"0.5888906",
"0.5484892",
"0.541713",
"0.5364118",
"0.5358979",
"0.5350954",
"0.5342818",
"0.530245",
"0.5271664",
"0.5245833",
"0.52161694",
"0.52084637",
"0.5197425",
"0.51968986",
"0.519159",
"0.5183196",
"0.51760757",
"0.5175722",
"0.5171299",
"0.51665187",
"0.5150696",
... | 0.5784906 | 1 |
Produce parametric map image from a label image, a list of labels and a list of measurements. The two lists must provide labels and corresponding values in the same order. See also | def relabel_with_map_array(image, label_list, measurement_list):
from skimage.util import map_array
return map_array(np.asarray(image), np.asarray(label_list), np.array(measurement_list)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_label_map(path, label_list):\r\n \r\n img = []\r\n for name in path:\r\n now = np.zeros((224,224))\r\n im = cv2.resize(cv2.imread(name), (224,224)).tolist()\r\n for y, i in enumerate(im):\r\n for x, j in enumerate(i):\r\n try:\r\n ... | [
"0.6597516",
"0.65695256",
"0.6437341",
"0.62600076",
"0.6172021",
"0.60025924",
"0.596679",
"0.59609866",
"0.5926957",
"0.5925364",
"0.5902554",
"0.58438545",
"0.5841471",
"0.5830358",
"0.58179533",
"0.5813503",
"0.58015454",
"0.5742335",
"0.5736796",
"0.5721127",
"0.5718691... | 0.6909794 | 0 |
Resizes img of shape (h, w, ch) or (h, w) to square of size (side, side, ch) or (side, side), respectively, while preserving aspect ratio. Image is being padded with pad_cval if needed. | def resize_image_to_square(img, side, pad_cval=0, dtype=np.float64):
if len(img.shape) == 2:
h, w = img.shape
if h == w:
padded = img.copy()
elif h > w:
padded = np.full((h, h), pad_cval, dtype=dtype)
l = int(h / 2 - w / 2) # guaranteed to be non-negativ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_img_size(self, img, C):\n img_min_side = float(C.im_size)\n (height,width,_) = img.shape\n\n if width <= height:\n ratio = img_min_side/width\n new_height = int(ratio * height)\n new_width =... | [
"0.6817739",
"0.669824",
"0.669824",
"0.6611915",
"0.6569353",
"0.6548102",
"0.642557",
"0.6359551",
"0.63417906",
"0.6284157",
"0.6283958",
"0.6256211",
"0.6227813",
"0.62074584",
"0.61986834",
"0.6185165",
"0.6152146",
"0.6147032",
"0.6128839",
"0.61176044",
"0.6089307",
... | 0.81708586 | 0 |
Initializes lists, an x list, and a y value list with corresponding indicies | def __init__(self, dataList):
xList = []
yList = []
for index in range(0, len(dataList)):
xList.append(dataList[index][0])
yList.append(dataList[index][1])
self.xList = xList
self.yList = yList
self.dataList = dataList | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, x: float = 0, y: float = 0):\n self.data: [float, float] = [x, y]",
"def __init__(self, xs, ys):\n self.xs = xs\n self.ys = ys",
"def __init__(self, x=None, y=None):\n if y is None:\n if x is None:\n object.__setattr__(self, 'x', 0)\n ... | [
"0.71280056",
"0.6649238",
"0.6326161",
"0.62563497",
"0.6225144",
"0.6221007",
"0.62060875",
"0.62008744",
"0.619568",
"0.61806154",
"0.61472994",
"0.6146515",
"0.6138016",
"0.61349875",
"0.61338866",
"0.61166334",
"0.6102992",
"0.6098293",
"0.60692614",
"0.6043588",
"0.6035... | 0.73330647 | 0 |
Fetch the usd layer's contents on disk. | def _GetDiskContents(self, layer):
# type: (Sdf.Layer) -> str
# with USD Issue #253 solved, we can do a cheaper check of just
# comparing time stamps and getting contents only if needed.
if not layer.realPath:
# New() or anonymous layer that cant be loaded from disk.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch(self, url) -> bytes:\n buffer = self.download(url)\n zfs = ZipFileSystem(buffer, \"r\")\n return zfs.open(zfs.glob(\"*\")[0]).read()",
"def _fetch_full():\n resource(\n target=data_path(\"eeg\", \"eeg_full.tar\"),\n url=\"https://kdd.ics.uci.edu/databases/eeg/eeg_f... | [
"0.603792",
"0.5985936",
"0.573881",
"0.5643167",
"0.5642991",
"0.5642991",
"0.5633864",
"0.5609176",
"0.5457929",
"0.5426018",
"0.5424711",
"0.5401132",
"0.53708553",
"0.53632677",
"0.53595394",
"0.53546363",
"0.53546363",
"0.5339055",
"0.5314588",
"0.53069973",
"0.5301708",... | 0.6334028 | 0 |
Create the hierarchy view for the outliner. This is provided as a convenience for subclass implementations. | def _CreateView(self, stage, role):
# type: (Usd.Stage, Union[Type[OutlinerRole], OutlinerRole]) -> QtWidgets.QAbstractItemView
return OutlinerTreeView(
contextMenuActions=role.GetContextMenuActions(self),
contextProvider=self,
parent=self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_hierarchy(self):\n\t\tpass",
"def makeTree(self):\n return makeTree(self.events,self.outTree)",
"def getHierarchies():",
"def getHierarchies():",
"def createHierarchy(self, hierarchy):\n self.tprint('create_bd_cell -type hier ' + hierarchy)",
"def create_hierarchy(self):\n\t\tif ... | [
"0.6979215",
"0.6086779",
"0.5929871",
"0.5929871",
"0.5839252",
"0.5743391",
"0.57101893",
"0.56922823",
"0.557813",
"0.5572132",
"0.55678654",
"0.55678654",
"0.55678654",
"0.5560746",
"0.5527302",
"0.55102926",
"0.54962623",
"0.54931355",
"0.5462376",
"0.5436",
"0.54320335"... | 0.63843745 | 1 |
Reset the stage for this outliner and child dialogs. | def ResetStage(self, stage):
self._stage = stage
self._dataModel.ResetStage(stage)
self.stageChanged.emit(stage) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_stage():\n return set_stage('')",
"def reset_step(self):\n # reset all levels\n for l in self.levels:\n l.reset_level()",
"def reset(self, window, context):\n pass",
"def reset(self):\n self.current = self.root\n env = self.env\n obs, infos = env.... | [
"0.67629087",
"0.6052151",
"0.6004065",
"0.59872866",
"0.5976821",
"0.59689575",
"0.59572196",
"0.5944264",
"0.59157413",
"0.58872324",
"0.58732116",
"0.581481",
"0.58093554",
"0.5793779",
"0.57754314",
"0.5764354",
"0.5762724",
"0.5721282",
"0.5713886",
"0.57050663",
"0.5704... | 0.6522153 | 1 |
Convenience method to get or create a shared editor dialog instance. | def GetSharedLayerTextEditorInstance(self, layer):
# type: (Sdf.Layer, bool, Optional[QtWidgets.QWidget]) -> LayerTextEditorDialog
dialog = self._sharedLayerTextEditors.get(layer)
if dialog is None:
readOnly = not layer.permissionToEdit
dialog = LayerTextEditorDialog(laye... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_editor(self):\n from traitsui.api import TextEditor\n\n return TextEditor()",
"def get_editor ( self, object ):\n return None",
"def get_editor(self, trait=None):\n if self.editor is None:\n self.editor = self.create_editor()\n\n return self.editor",
"... | [
"0.6187553",
"0.61788833",
"0.6121907",
"0.60303044",
"0.5981322",
"0.5788249",
"0.5686811",
"0.5545502",
"0.55353457",
"0.5526849",
"0.5510445",
"0.5504017",
"0.5496606",
"0.5455931",
"0.54120713",
"0.5381751",
"0.5261122",
"0.52552396",
"0.5250571",
"0.52435714",
"0.5240286... | 0.67833054 | 0 |
Checks if there is a source file added. | def has_source_file( self ):
return self._source_file is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_source(self):\n return any(map(utils.assert_package_is_source, self.pkg_arguments))",
"def _source_filename_field_was_properly_initialized(self):\n if not Rule.sources_list_is_initialized:\n Rule.sources_list.append(self.source)\n Rule.sources_list_is_initialized = Tru... | [
"0.69670993",
"0.6747514",
"0.666378",
"0.6538926",
"0.648508",
"0.638255",
"0.63765925",
"0.63729256",
"0.63016784",
"0.61769664",
"0.6175357",
"0.6156924",
"0.6154293",
"0.6151352",
"0.61510915",
"0.6137194",
"0.6130207",
"0.60617703",
"0.6061695",
"0.6060982",
"0.60576624"... | 0.81429505 | 0 |
Make fragment data coherent. Evaluates that the columns ``neighbors``, ``neighbor`` and ``position`` are coherent with the data contained according to ``frame`` and ``size``. | def coerce( self ):
df = self.copy()
gcond = ['neighbor', 'pdb'] if 'source' not in df.columns else ['neighbor', 'pdb', 'source']
for frame_id, frame in df.groupby('frame'):
g = frame.groupby(gcond)
neighbors = len(g)
neighbor = list(g.ngroup() + 1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(\n self,\n node_size_x,\n node_size_y,\n bin_center_x,\n bin_center_y,\n target_density,\n xl,\n yl,\n xh,\n yh,\n bin_size_x,\n bin_size_y,\n num_movable_nodes,\n num_terminals,\n num_filler_nodes... | [
"0.51830035",
"0.4996016",
"0.4975639",
"0.49513358",
"0.48802227",
"0.48324516",
"0.4732223",
"0.47306255",
"0.4729021",
"0.47098547",
"0.47089085",
"0.46393326",
"0.4609485",
"0.46067432",
"0.45889568",
"0.45811534",
"0.45494598",
"0.45487177",
"0.45247036",
"0.4519667",
"0... | 0.5445559 | 0 |
Add to a given position a set of fragments more fragments. | def add_fragments( self, fragments, ini, how='replace' ):
if (self['size'].unique() != fragments['size'].unique()).any():
raise ValueError('Only same-sized fragments can be merged.')
frags = fragments.copy()
df = self.copy()
columns = ['frame', 'neighbor', 'position']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addfragment(self, fragment):\n self.__fragments.append(fragment)",
"def add_fragment(self, fragment, delay_sort=False):\n Segment.add_fragment(self, fragment, delay_sort)\n fragment.chain = self",
"def add_fragment(self, fragment, delay_sort = False):\n assert isinstance(fragmen... | [
"0.63945395",
"0.63077974",
"0.60750926",
"0.5941844",
"0.5919532",
"0.5895623",
"0.58803624",
"0.5873478",
"0.5869461",
"0.56383944",
"0.56084305",
"0.55681735",
"0.5543599",
"0.5514613",
"0.54223704",
"0.54153585",
"0.5411248",
"0.5378081",
"0.5375992",
"0.53418994",
"0.533... | 0.6320141 | 1 |
Limit to the top selected neighbors for each frame. | def sample_top_neighbors( self, max_count=200 ):
df = self.copy()
return df[df['neighbor'] <= max_count].coerce() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_limit( self, limit ):\n df = self.copy()\n max_frame = df[df['position'] == limit]['frame'].min()\n # If we don't find the top limit frame\n if max_frame is np.nan:\n # If the fragments set is smaller, we fix it,\n # otherwise we will return empty FragmentF... | [
"0.5950453",
"0.57046854",
"0.5664642",
"0.5624852",
"0.5582167",
"0.5517088",
"0.5434039",
"0.54066813",
"0.5388029",
"0.53584456",
"0.53567183",
"0.5324778",
"0.52538997",
"0.52523506",
"0.51884615",
"0.51789093",
"0.5161289",
"0.5139068",
"0.5130061",
"0.5123967",
"0.51226... | 0.5843866 | 1 |
Add RMSD quality measure to the fragment data. The RMSD quality measurement is performed by the ``r_fraq_qual`` application | def add_quality_measure( self, filename, pdbfile=None ):
if filename is None and not self.has_source_file():
raise AttributeError("No quality file is provided and no source file can be found.")
# Make the quality fragmet eval if needed.
if filename is None:
sofi = self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_quality(df):\n df = pd.concat([df, convert_quality(df['quality'])], \n axis=1)\n\n df['Q_min'] = df.filter(regex='Q_\\d+', axis=1).min(axis=1)\n df['Q_mean'] = df.filter(regex='Q_\\d+', axis=1).mean(axis=1)\n return df",
"def quality(self): \n\n subsetInt = [int(s... | [
"0.55618787",
"0.5458036",
"0.5448144",
"0.5436811",
"0.523412",
"0.514078",
"0.5081098",
"0.50534576",
"0.5024433",
"0.49815696",
"0.49395585",
"0.48970348",
"0.48374268",
"0.48342085",
"0.48068976",
"0.4801528",
"0.4788782",
"0.47875133",
"0.47782525",
"0.47781703",
"0.4777... | 0.70806515 | 0 |
Generate a graph representation of the perresidue frequency. | def make_per_position_frequency_network( self ):
matrix = self.make_sequence_matrix(frequency=True)
g = nx.DiGraph()
for i, row in matrix.iterrows():
if i == matrix.iloc[0].name:
nterm = ["0X", ]
invrow = (1 - row[row > 0])
cterm = [str(i) + ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_graph(self, seed=None):\n block = make_residue_graph(self.molecule, attrs=('resid', 'resname'))\n resnames = nx.get_node_attributes(block, 'resname')\n graph = nx.Graph()\n graph.add_nodes_from(block.nodes)\n graph.add_edges_from(block.edges)\n nx.set_node_attribut... | [
"0.6406834",
"0.60664165",
"0.5965293",
"0.5897972",
"0.5878967",
"0.5783444",
"0.57667893",
"0.57122815",
"0.558401",
"0.55590343",
"0.55431765",
"0.551942",
"0.54389316",
"0.5434995",
"0.5433267",
"0.5405912",
"0.5397127",
"0.53662306",
"0.53543574",
"0.53141916",
"0.527845... | 0.61996233 | 1 |
Consensus sequence with the highest representative per position. | def quick_consensus_sequence( self ):
consensus = []
for i in range(1, max(self["position"].values) + 1):
values = self[self["position"] == i]["aa"].values
qseq = sorted(Counter(values).most_common(), key=lambda x: (-x[1], x[0]))[0]
consensus.append(qseq[0])
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consensus_sequence(self):\n consensus = \"\"\n alphabet = Motif.getAlphabet(self).getSymbols()\n for pos in range(self.cols):\n best_letter = alphabet[0]\n best_p = self.counts[pos].getFreq(best_letter)\n for letter in alphabet[1:]:\n p = sel... | [
"0.7054654",
"0.66571254",
"0.65322965",
"0.63453954",
"0.62225604",
"0.6124779",
"0.60827804",
"0.60332733",
"0.5960024",
"0.5925765",
"0.58008057",
"0.5779397",
"0.57781863",
"0.5777583",
"0.57560086",
"0.5744476",
"0.5738173",
"0.56754535",
"0.566056",
"0.5651965",
"0.5638... | 0.76218927 | 0 |
Consensus secondary structure with the highest representative per position. | def quick_consensus_secondary_structure( self ):
consensus = []
for i in range(1, max(self["position"].values) + 1):
values = self[self["position"] == i]["sse"].values
qseq = sorted(Counter(values).most_common(), key=lambda x: (-x[1], x[0]))[0]
consensus.append(qseq[0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calculate_secondary_structure(seq, window):\n # STRUCTS = {0: \"Helix\", 1: \"Turn\", 2: \"Sheet\"}\n window_sequence = iterutils.windowed(seq, window) # sliding windows\n residue_num = len(seq)\n struct = [0 for _ in range(residue_num)]\n tail = (window - 1) // 2\n for i in range(residue_n... | [
"0.60657233",
"0.5858897",
"0.5845189",
"0.58027166",
"0.5623448",
"0.55966604",
"0.5536919",
"0.5493595",
"0.54932415",
"0.5476676",
"0.5422758",
"0.53977877",
"0.53903866",
"0.5377685",
"0.53761035",
"0.53531325",
"0.53321755",
"0.5325642",
"0.5314711",
"0.5306678",
"0.5296... | 0.77103025 | 0 |
Queries the blocks status for a specific proposal and returns the blocks code with the specified status. | def get_blocks_status(proposal_code, blocks_status_id):
sql = '''SELECT BlockCode AS block_code
FROM Block
JOIN BlockCode USING (BlockCode_Id)
JOIN ProposalCode USING (ProposalCode_Id)
JOIN BlockStatus USING (BlockStatus_Id)
WHERE Proposal_Code=%s
AND BlockStatus_Id=%s'''
df = pd.read_sql(sql, params=(proposal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_proposals(self, current_block_height: int, type: int = None, status: int = None) -> dict:\n if type is not None and not self._validate_proposal_type(type):\n revert(f\"Invalid type parameter: {type}\")\n\n if status is not None and not self._validate_proposal_status(status):\n ... | [
"0.5843596",
"0.5430601",
"0.5421692",
"0.53857696",
"0.5384508",
"0.5340105",
"0.5308046",
"0.52552867",
"0.5251174",
"0.51868504",
"0.51868504",
"0.51852936",
"0.5180307",
"0.5161613",
"0.50952536",
"0.5094569",
"0.5052609",
"0.50174975",
"0.5009693",
"0.5001549",
"0.499852... | 0.75376165 | 0 |
Cleanup old backups, keeping the number of backups specified by DBBACKUP_CLEANUP_KEEP and any backups that occur on first of the month. | def cleanup_old_backups(self):
print("Cleaning Old Backups for media files")
file_list = utils.get_backup_file_list(
self.get_databasename(),
self.get_servername(),
'media.tar.gz',
self.storage
)
for backup_date, filename in file_list[0:-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_old_backups(self, encrypted=None, compressed=None,\n content_type=None, database=None,\n keep_number=None):\n if keep_number is None:\n keep_number = settings.CLEANUP_KEEP if content_type == 'db' \\\n else settings.MEDIA_F... | [
"0.7020303",
"0.6642059",
"0.6418035",
"0.6148927",
"0.59084123",
"0.5893219",
"0.5891463",
"0.5784416",
"0.5773006",
"0.57176554",
"0.5635604",
"0.56337184",
"0.55745715",
"0.55662006",
"0.55608666",
"0.55372256",
"0.5532012",
"0.54824024",
"0.54577196",
"0.54546976",
"0.544... | 0.6850731 | 1 |
findSquares intend to locate rectangle in the image of minimum area, minSize, and maximum angle, maxAngle, between sides | def findSquares(img,minSize = 2000,maxAngle = 1):
squares = []
contours, hierarchy = cv2.findContours(img, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
for cnt in contours:
cnt_len = cv2.arcLength(cnt, True)
cnt = cv2.approxPolyDP(cnt, 0.08*cnt_len, True)
if len(cnt) == 4 and cv2.conto... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_squares(img,minArea=1000):\n\n squares = []\n\n contours, hierarchy = cv2.findContours(img, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)\n\n for cnt in contours:\n cnt_len = cv2.arcLength(cnt, True)\n cnt = cv2.approxPolyDP(cnt, 0.02*cnt_len, True)\n if len(cnt) == 4 and cv2.contourArea(cnt) > 1000... | [
"0.71420354",
"0.6896417",
"0.6698013",
"0.65799165",
"0.6282704",
"0.621045",
"0.6110718",
"0.6105998",
"0.6091099",
"0.6052047",
"0.6050924",
"0.6037672",
"0.6021396",
"0.5986449",
"0.59541947",
"0.59449285",
"0.5932716",
"0.5906322",
"0.587209",
"0.58589774",
"0.5855369",
... | 0.76502085 | 0 |
Fetch the testing data for a fixed period but the testing start may not in the dataframe So we need to look for the next available start date | def fetch_testing(df, testing_start, curr_date_set, duration=1):
dt_testing_start = dt.datetime.strptime(testing_start, '%Y-%m-%d')
for _ in range(200):
if testing_start in curr_date_set:
dt_testing_end = dt_testing_start + dt.timedelta(days=duration)
break
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_training(df, training_start, duration):\n # if not dt.datetime.strptime(training_start, '%Y-%m-%d').weekday() < 5:\n # print('Start date should be weekday!')\n # return False\n\n dt_training_start = dt.datetime.strptime(training_start, '%Y-%m-%d')\n dt_training_end = dt_training_st... | [
"0.68176293",
"0.6374164",
"0.6306623",
"0.6201109",
"0.6198516",
"0.60506344",
"0.6047852",
"0.6005284",
"0.5949988",
"0.5943957",
"0.59437215",
"0.5908154",
"0.58975947",
"0.58928615",
"0.58496845",
"0.58437943",
"0.58247435",
"0.58179814",
"0.5761374",
"0.5742843",
"0.5696... | 0.7817672 | 0 |
Check a proper oidc user can be added. | def test_add_oidc(self, db_session: Session) -> None:
user_service = get_user_service(db_session)
identity_provider = RandomDbAdder().random_identity_provider(db_session)
profile = RandomDbAdder().random_profile(db_session)
oidc_user_dict = InputDictGenerator().random_oidc_user(profile.n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_user(self, user): # pylint: disable=unused-argument\r\n return False",
"def validate_user_existence():\n from sfa_api.utils.storage import get_storage\n storage = get_storage()\n if not storage.user_exists():\n try:\n info = request_user_info()\n except (requests... | [
"0.6781529",
"0.64783305",
"0.6422051",
"0.63401365",
"0.62716377",
"0.627131",
"0.6268141",
"0.6244082",
"0.62347066",
"0.62128186",
"0.6204552",
"0.6192932",
"0.61716366",
"0.61443716",
"0.614201",
"0.6141389",
"0.61342645",
"0.61148345",
"0.61139995",
"0.6113494",
"0.60992... | 0.6725915 | 1 |
Check a proper basic user can be added. | def test_add_basic(self, db_session: Session) -> None:
user_service = get_user_service(db_session)
profile = RandomDbAdder().random_profile(db_session)
basic_user_dict = InputDictGenerator().random_basic_user(profile.name)
response = user_service.add_user(**basic_user_dict)
ass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_000_add_user(self):\n # This case is always passed because it's tested in setup_module,\n # If setup module fails, this case will never run\n pass",
"def test_add_user(self):\n pass",
"def add_check(self, username, password):\n can_login, msg = self.db.add_user(usern... | [
"0.7416194",
"0.6910111",
"0.6904892",
"0.6715081",
"0.6707439",
"0.6677544",
"0.6627211",
"0.657824",
"0.657573",
"0.65698606",
"0.65638804",
"0.6561401",
"0.6557545",
"0.6557291",
"0.65423733",
"0.65246785",
"0.65187037",
"0.6513014",
"0.6495206",
"0.6449799",
"0.6442791",
... | 0.70921445 | 1 |
Check the get_entity_by rpc functions all return a correct user entity dict. | def test_user_entity_by(self, db_session: Session, get_user: Callable, attribute: str, db_column: Column,
entity_attr: str, entity_column: Column) -> None:
user_service = get_user_service(db_session)
user = get_user(db_session)
profile = db_session.query(Profiles).fil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def harvest_user(client, entity):\n user = entity.__getattribute__(\"user\")\n username = user.__getattribute__(\"username\")\n photo_location = client.download_profile_photo(username)\n is_bot = user.__getattribute__('bot')\n about = entity.__getattribute__(\"about\")\n tid = user.__getattribute... | [
"0.64620256",
"0.6228434",
"0.60452044",
"0.6011696",
"0.5758852",
"0.5681902",
"0.56337464",
"0.5595828",
"0.55929345",
"0.55601907",
"0.55523837",
"0.55441475",
"0.5505762",
"0.54832315",
"0.54705554",
"0.5457779",
"0.5444499",
"0.5414821",
"0.53975636",
"0.53808707",
"0.53... | 0.6344203 | 1 |
Checks that val matches expval within tol. | def check_eq(val, expval, tol=None):
if type(val) == dict:
for k in val:
check_eq(val[k], expval[k], tol)
else:
try:
if tol and hasattr(val, '__rsub__'):
are_eq = abs(val - expval) < tol #absolute check
if not are_eq:
ar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_eq(self, val, expval, tol=None):\n\tif type(val) == dict:\n\t for k in val:\n\t\tcheck_eq(val[k], expval[k], tol)\n\telse:\n\t try:\n\t\tif tol and hasattr(val, '__rsub__'):\n\t\t are_eq = abs(val - expval) < tol\n\t\telse:\n\t\t are_eq = val == expval\n\t\tif hasattr(are_eq, 'all'):\n\t\t ... | [
"0.74899966",
"0.7339071",
"0.6660492",
"0.64926594",
"0.6435002",
"0.6362428",
"0.63567203",
"0.6344736",
"0.6262961",
"0.6020252",
"0.5947068",
"0.58810514",
"0.5869496",
"0.58220625",
"0.5806817",
"0.575431",
"0.5746518",
"0.5743135",
"0.5712562",
"0.5700089",
"0.5691608",... | 0.74818563 | 1 |
Makes a hash from a dictionary, list, tuple or set to any level, that contains only other hashable types (including any lists, tuples, sets, and dictionaries). | def make_hash(o):
if isinstance(o, (set, tuple, list)):
return hash(tuple([make_hash(e) for e in o]))
elif not isinstance(o, dict) and o.__class__.__module__ == 'builtins':
return hash(o)
elif not isinstance(o, dict):
return make_hash(o.__dict__)
new_o = copy.deepcopy(o)
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_hash(o):\n\n if isinstance(o, (set, tuple, list)):\n\n return hash( tuple([make_hash(e) for e in o]) )\n\n elif not isinstance(o, dict):\n\n return hash(o)\n\n new_o = copy.deepcopy(o)\n for k, v in new_o.items():\n new_o[k] = make_hash(v)\n\n return hash(tuple(frozenset(sorted(new_o.items()... | [
"0.71846974",
"0.68153507",
"0.6767326",
"0.6484648",
"0.64506185",
"0.6423317",
"0.6351386",
"0.6260348",
"0.62244236",
"0.61374485",
"0.6102901",
"0.6026307",
"0.5953725",
"0.5952019",
"0.5942762",
"0.5885439",
"0.5735936",
"0.5721072",
"0.56306976",
"0.56081104",
"0.559697... | 0.71686065 | 1 |
Load from l2 or l3 in case of l2 cache miss | def load(self, name: str):
result = self.l2.load(name)
if result is not None:
logging.debug(f'{name} l2 hit')
return result
result = self.l3.load(name, self.l2)
if result is not None:
logging.debug(f'{name} l3 hit')
return result
l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_cached_2to3(self, path, cache):\n try:\n cache_stats = os.stat(cache)\n source_stats = os.stat(path)\n except OSError as e:\n if e.errno == errno.ENOENT: # FileNotFoundError\n self.logger.debug('Cache miss: %s' % cache)\n return... | [
"0.6927087",
"0.65668494",
"0.60721755",
"0.5680265",
"0.56409395",
"0.56320816",
"0.5608747",
"0.559807",
"0.55883527",
"0.55764914",
"0.548972",
"0.5482407",
"0.5479272",
"0.54643595",
"0.54545844",
"0.5434416",
"0.5391044",
"0.53518105",
"0.5311775",
"0.5309931",
"0.529630... | 0.8038461 | 0 |
Load from l2 or download from l3 in case of l2 cache miss | def download(self, name: str):
result = self.l2.load(name)
if result is not None:
logging.debug(f'{name} l2 hit')
return result
result = self.l3.download(name, self.l2.get_path(name))
if result is not None:
logging.debug(f'{name} l3 hit')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self, name: str):\n result = self.l2.load(name)\n if result is not None:\n logging.debug(f'{name} l2 hit')\n return result\n\n result = self.l3.load(name, self.l2)\n if result is not None:\n logging.debug(f'{name} l3 hit')\n return re... | [
"0.74881405",
"0.7016366",
"0.6018097",
"0.58592004",
"0.5849694",
"0.57933414",
"0.5741677",
"0.57367516",
"0.5735617",
"0.5734149",
"0.57306796",
"0.567963",
"0.5677758",
"0.56626546",
"0.56296843",
"0.5591846",
"0.5591846",
"0.5585988",
"0.5564299",
"0.55234194",
"0.552247... | 0.7758989 | 0 |
This test confirms that mg flux has many groups when loaded with the history tracker. armi.bookeeping.db.hdf.hdfDB.readBlocksHistory requires historical_values[historical_indices] to be cast as a list to read more than the first energy group. This test shows that this behavior is preserved. | def test_calcMGFluence(self):
o = self.o
b = o.r.core.childrenByLocator[o.r.core.spatialGrid[0, 0, 0]].getFirstBlock(
Flags.FUEL
)
bVolume = b.getVolume()
bName = b.name
hti = o.getInterface("history")
# duration is None in this DB
timesInYea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_chunk_n(self):\n st, frontend_setup = self.get_st_and_fill_frontends()\n\n sf = st.storage[0]\n st_new = st.new_context()\n st_new.storage = [sf]\n key = st_new.key_for(self.run_id, self.target)\n backend, backend_key = sf.find(key, **st_new._find_options)\n... | [
"0.5284996",
"0.52815616",
"0.5158735",
"0.51446086",
"0.5122909",
"0.51206213",
"0.5112286",
"0.50974864",
"0.5093032",
"0.50866073",
"0.50524634",
"0.502347",
"0.5022532",
"0.50194997",
"0.5006884",
"0.4995052",
"0.49868587",
"0.4953218",
"0.49530247",
"0.4943559",
"0.49113... | 0.6472034 | 0 |
Test generation of history report. | def test_historyReport(self):
history = self.o.getInterface("history")
history.interactBOL()
history.interactEOL()
testLoc = self.o.r.core.spatialGrid[0, 0, 0]
testAssem = self.o.r.core.childrenByLocator[testLoc]
fileName = history._getAssemHistoryFileName(testAssem)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_history(self):\n self.reporter.generate()",
"def test_get_team_history(self):\n pass",
"def test_history(admin_client):\n book = BookFactory()\n url = reverse(\"admin:books_book_history\", args=(book.pk,))\n\n response = admin_client.get(url)\n templates_used = [t.name fo... | [
"0.7868642",
"0.7011366",
"0.6935231",
"0.6782552",
"0.66714996",
"0.6664326",
"0.65281725",
"0.6494625",
"0.6473761",
"0.6454421",
"0.6398351",
"0.63496244",
"0.63456535",
"0.6314245",
"0.63029486",
"0.6292308",
"0.6237949",
"0.6230372",
"0.62290144",
"0.6200345",
"0.619887"... | 0.78573567 | 1 |
Simulate zooming effect by upscaling/downscaling image using OpenCV | def img_zoom(img, fx, fy, interp=cv2.INTER_AREA):
res = cv2.resize(img, None, fx=fx, fy=fy,
interpolation=interp)
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zoom_augmentation():\n # Get the width and the height of the zoomed version\n x_len, y_len = np.random.randint(250, 350, size=2)\n # Get left upper ,right and lower bound of the pixels in the original image\n left = np.random.randint(x_size-x_len)\n upper = np.random.randint(... | [
"0.6990665",
"0.64548546",
"0.63606477",
"0.6329623",
"0.6279746",
"0.6274322",
"0.62713194",
"0.6265151",
"0.6264785",
"0.6142311",
"0.6136701",
"0.6105528",
"0.61019236",
"0.60897654",
"0.60855496",
"0.608053",
"0.6050872",
"0.6039135",
"0.6038562",
"0.5993082",
"0.5991592"... | 0.6605406 | 1 |
Roulettewheel (Proportional) solution selection. | def select_roulette(solver, pop, bias=1, minimising=False):
assert min(c.fitness for c in pop) >= 0
assert len(pop) > 0
assert minimising is False # Done to ensure consistency. Check could be moved to solver (roulette can only do maxi)
point = random.uniform(0, sum(c.fitness**bias for c in pop))
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RouletteWheel(self, fitness):\n idx = 0\n totalFitness = sum(fitness)\n for i in range(self.jumlahPopulasi):\n if (fitness[i]/totalFitness) > random.uniform(0, 1):\n idx = i\n break\n i = i + 1\n return self.populasi[idx]",
"def ... | [
"0.57537264",
"0.5655364",
"0.5618614",
"0.56066096",
"0.5560072",
"0.55592394",
"0.55310315",
"0.5499745",
"0.5439662",
"0.53862244",
"0.53682995",
"0.53526306",
"0.5340396",
"0.5339818",
"0.5320436",
"0.5317737",
"0.53070056",
"0.5264427",
"0.5247817",
"0.5219584",
"0.52066... | 0.5669033 | 1 |
Select best n solutions from a population | def select_best_n(solver, pop, n, minimising=None):
assert n <= len(pop)
if minimising is None:
minimising = solver.alg_params.minimising
key_f = operator.attrgetter('fitness')
if minimising:
f = copy.deepcopy(sorted(pop, key=key_f, reverse=False))
else:
f = copy.deepcopy(so... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_n_best(self):\n pass",
"def select(individuals, n):\r\n # return selBest(individuals, n)\r\n return individuals[:n]",
"def _find_solution(self, population, num_of_best_chromosomes):\n data = self._Individuals()\n for x in population:\n curr_fit = self._fitness(x)\n... | [
"0.7206025",
"0.71654224",
"0.71230745",
"0.6725943",
"0.6594718",
"0.65439",
"0.65414584",
"0.6531062",
"0.6422889",
"0.6337787",
"0.6282793",
"0.62078166",
"0.62029624",
"0.6191008",
"0.61795396",
"0.61662084",
"0.6162691",
"0.61474377",
"0.6122851",
"0.6112423",
"0.6077574... | 0.73968315 | 0 |
One point crossover for the SAES | def crossover_one_point_saes(solver, par1, par2, xo_chance=None, point=None):
assert len(par1.es_params) == len(par1.trace)
assert len(par2.es_params) == len(par2.trace)
if xo_chance is None:
xo_chance = solver.alg_params.crossover_rate
r = random.random()
if r < xo_chance:
if point... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cross_over(self,mp,cross_rate,eta):",
"def twoPointCrossover(self, cl):\n points = []\n changed = False\n points.append( int( random.random() * ( cons.env.format_data.numb_attributes + 1 ) ) )\n secondPoint = int( random.random() * ( cons.env.format_data.numb_attributes + 1 ) )\n... | [
"0.6608391",
"0.61052114",
"0.5985639",
"0.59796673",
"0.59577096",
"0.59250337",
"0.5918458",
"0.5893332",
"0.5882094",
"0.579808",
"0.5778123",
"0.5771123",
"0.57590336",
"0.5736131",
"0.5725958",
"0.5703707",
"0.56662047",
"0.5663461",
"0.56455594",
"0.5641402",
"0.5622837... | 0.6559052 | 1 |
Cuts off the top line of the parachute | def cut_line(self):
self.parachute.pop(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _output_skip_line(self):\n self.buf += '...'\n self._pad_horizontally(3)\n\n if self.num_parents >= 3 and self.commit_index < self.num_columns - 1:\n self._update_state(GraphState.PRE_COMMIT)\n else:\n self._update_state(GraphState.COMMIT)",
"def _trunc_lines... | [
"0.6020949",
"0.5995834",
"0.5848266",
"0.58072305",
"0.5774203",
"0.57281834",
"0.5699135",
"0.5645718",
"0.56223774",
"0.5585376",
"0.54822284",
"0.5467732",
"0.5461679",
"0.544144",
"0.5441034",
"0.54198235",
"0.54164356",
"0.53618854",
"0.53547484",
"0.53395873",
"0.52963... | 0.74140626 | 0 |
Checks to see how much parachute is left. If there is only the guy left, you are dead. Returns true or false. Also changes the guy's head to an 'x' if he is dead. | def is_dead(self):
if len(self.parachute) <= 5:
self.parachute.pop(0)
self.parachute.insert(0, " x")
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dead(left_hp: int, right_hp: int) -> bool:\n if left_hp <= 0:\n return True\n elif right_hp <= 0:\n return True\n else:\n return False",
"def is_dead(self):\n return self.hp <= 0",
"def is_left(self):\n if self.pupils_located:\n return self.horiz... | [
"0.6884417",
"0.6786529",
"0.6410917",
"0.640569",
"0.636418",
"0.6354022",
"0.62738305",
"0.6232323",
"0.62270254",
"0.6132943",
"0.59474987",
"0.5922174",
"0.5894712",
"0.5884026",
"0.585941",
"0.5840951",
"0.58322376",
"0.5822756",
"0.58067816",
"0.5786097",
"0.5785562",
... | 0.75005907 | 0 |
Announce the agent about your intention to modify the collection. | def assert_modification_intention(self, db_cfg_name, collection_cfg_name):
return self.__assert_collection_change(db_cfg_name,
collection_cfg_name, False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Action(self) -> NotifyCollectionChangedAction:",
"def modified(self):\n raise NotImplementedError",
"def notify_modification(self):\n self._trigger_modification(done=True)",
"def change(some_list):\n some_list[0] = 'Changed' # will change the original list",
"def _update_beliefs(self, ... | [
"0.5871195",
"0.5787927",
"0.56628335",
"0.551136",
"0.5461681",
"0.54537725",
"0.5393876",
"0.5386586",
"0.53787476",
"0.53651303",
"0.5363231",
"0.5306034",
"0.52794105",
"0.526683",
"0.52450925",
"0.5229401",
"0.5229401",
"0.5229401",
"0.5217223",
"0.5195496",
"0.5153035",... | 0.59757656 | 0 |
Tell the agent the collection will be/has been modified. | def __assert_collection_change(self, db_cfg_name, collection_cfg_name,
is_finished):
import time
from ir_config import IRConfig
db_name = IRConfig.get_instance().get(db_cfg_name)
collection_name = IRConfig.get_instance().get(collection_cfg_name)
meta_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_collection(self):\n pass",
"def modified(self):\n raise NotImplementedError",
"def assert_modification_intention(self, db_cfg_name, collection_cfg_name):\n return self.__assert_collection_change(db_cfg_name,\n collection_cfg_nam... | [
"0.63974476",
"0.63365954",
"0.63201237",
"0.6228585",
"0.6144578",
"0.61015207",
"0.60833395",
"0.59951407",
"0.5955909",
"0.59214276",
"0.5857855",
"0.578181",
"0.57437116",
"0.5714152",
"0.57014394",
"0.56974936",
"0.5692626",
"0.5655071",
"0.5625928",
"0.56135875",
"0.557... | 0.63886523 | 1 |
Find the information of the collection in meta data. | def __find_collection_in_meta(self, db_name, collection_name):
meta_collection = self.__get_meta_collection(db_name)
return meta_collection.find({self.__meta_key_name : collection_name}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_details(cls, collection, uid):\n result = collection.find_one({\"_id\": cls.object_id(uid)})\n if result is None:\n raise APIError(\n \"No object matching _id '{}' in collection '{}'\".format(\n uid, collection.name\n ),\n ... | [
"0.65785575",
"0.6411984",
"0.63073933",
"0.6298958",
"0.62095857",
"0.6193939",
"0.61037266",
"0.6089877",
"0.60765624",
"0.6032068",
"0.6005529",
"0.5992885",
"0.5980991",
"0.59519726",
"0.5933023",
"0.5927597",
"0.5927597",
"0.5927597",
"0.58947194",
"0.58932394",
"0.58704... | 0.7060371 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.