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 |
|---|---|---|---|---|---|---|
Download all snaps that haven't already been downloaded. | def download_snaps(s):
existing = get_downloaded()
snaps = s.get_snaps()
for snap in snaps:
id = snap['id']
if id[-1] == 's' or id in existing:
print 'Skipping:', id
continue
result = download(s, snap)
if not result:
print 'FAILED:', id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downloadAll(self, force=False):\n if self.minutesSinceLastUpdate() == 0 and force == False:\n self.log(\"TOO SOON SINCE LAST DOWNLOAD!\")\n return\n for grabber in self.grabbers:\n self.downloadGrab(grabber[\"url\"], grabber[\"ID\"])+\"\\n\"",
"def _download_all... | [
"0.66632015",
"0.60274625",
"0.60035586",
"0.5957198",
"0.5934118",
"0.5919938",
"0.5897004",
"0.5831177",
"0.58302766",
"0.5794643",
"0.5774174",
"0.57472575",
"0.57161885",
"0.566392",
"0.55329263",
"0.5514549",
"0.54934376",
"0.5476704",
"0.5452481",
"0.543913",
"0.5403052... | 0.7774038 | 0 |
Encodes a native Python value in a way that the API expects. Encodes lists and dicts to JSON and boolean values to 'true' or 'false'. | def api_encode(value):
if type(value) in (dict, list):
return json_encode(value)
elif type(value) == bool:
return str(value).lower()
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def JsonEncode(py_value):\n return JSON_ENCODER.encode(py_value)",
"def _encode_value(data):\n\n if type(data) is bool:\n return f'{_TYPE_BOOL}{str(data).lower()}'\n elif type(data) is float:\n return f'{_TYPE_DOUBLE}{str(data)}'\n elif type(data) is int:\n return f'{_TYPE_INT}{str... | [
"0.7380409",
"0.73028606",
"0.6974219",
"0.6965896",
"0.6948547",
"0.69058067",
"0.68838495",
"0.67391557",
"0.67146885",
"0.67039376",
"0.65755284",
"0.64773065",
"0.64079785",
"0.64079565",
"0.6391889",
"0.6390388",
"0.6380185",
"0.63579655",
"0.6314916",
"0.62741226",
"0.6... | 0.8075695 | 0 |
Lowlevel method for making API calls. It handles encoding the parameters, constructing authentication headers, decoding the response, and converting API error responses into Python exceptions. | def call(self, api_call, **kwargs):
# Encode values for the API (JSON, bools, nulls)
params = dict((key, api_encode(value))
for key, value in kwargs.iteritems() if value is not None)
params.update(self.defaults)
if api_call[0] != "/":
api_call = "/" + api_call
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _do_api_call(\n self,\n endpoint_info: tuple[str, str],\n json: dict[str, Any] | None = None,\n wrap_http_errors: bool = True,\n ):\n method, endpoint = endpoint_info\n\n # TODO: get rid of explicit 'api/' in the endpoint specification\n url = f\"https://{sel... | [
"0.67149675",
"0.6664818",
"0.66358113",
"0.65830725",
"0.6512704",
"0.6511796",
"0.6474514",
"0.64474",
"0.643962",
"0.63296205",
"0.6321636",
"0.6317781",
"0.62910086",
"0.62778836",
"0.6247308",
"0.62412024",
"0.6229673",
"0.62191224",
"0.6215646",
"0.6215193",
"0.6207017"... | 0.6754091 | 0 |
Parse the response from the API, decoding the JSON and converting errors into exceptions. | def parse_response(self, response):
data = json_decode(response)
if data['stat'] == 'error':
self.logger.debug("Response:\n" + json_encode(data, indent=4))
try:
message = data['error_description']
except KeyError:
message = data['messa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_response(self, response, all_ops):\n try:\n parsed_response = json.loads(response)\n except Exception, e:\n raise ApiError(e)\n if 'error' in parsed_response: # needed anymore?\n raise ApiError(parsed_response['error'])\n # Return the true API return value.\n return parsed... | [
"0.8096695",
"0.78386664",
"0.77561957",
"0.77350914",
"0.7730008",
"0.7284812",
"0.7064459",
"0.6913496",
"0.68599725",
"0.68185",
"0.6777948",
"0.6726493",
"0.6713444",
"0.6688297",
"0.6655507",
"0.66511434",
"0.6546489",
"0.6541335",
"0.6493854",
"0.6456989",
"0.64395887",... | 0.8244902 | 0 |
Sign the API call by generating an "Authentication" header. This method will add headers to the request object and remove auth_token, client_id, and client_secret from the parameters if they exist. | def sign_request(self, request, api_call, params):
for key, value in params.items():
params[key] = value.encode('utf-8')
# Do not POST authentication parameters. Use them to create an
# authentication header instead.
access_token = params.pop('access_token', None)
cl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _addAuthenticationToRequestHeader(request, client):\n request.addAuthorization(client.id, client.secret)",
"def authenticate(self):\n\n headers = {\n 'Authorization': 'Bearer ' + self.access_token,\n 'ClientId': self.client_id,\n }\n self.headers.update(h... | [
"0.68053204",
"0.666631",
"0.62823254",
"0.6111792",
"0.6090263",
"0.6044804",
"0.60245746",
"0.6016039",
"0.5999951",
"0.59911007",
"0.5989135",
"0.59618855",
"0.5948747",
"0.5922021",
"0.59038025",
"0.5902988",
"0.5885357",
"0.5798895",
"0.57671404",
"0.5763989",
"0.5737275... | 0.7390419 | 0 |
Calculates softmax across a desired axis. Arguments | def softmax(x: jnp.DeviceArray, *, axis: int = 0) -> jnp.DeviceArray:
return jnp.exp(x) / jnp.expand_dims(jnp.sum(jnp.exp(x), axis=axis), axis) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(x):\r\n e_x = np.exp(x - np.expand_dims(np.max(x, axis=-1), axis=-1))\r\n return e_x / np.expand_dims(e_x.sum(axis=-1), axis=-1) # only difference\r",
"def softmax(x):\n \"\"\"\"\"\"\n return exp(x) / sum(exp(x), axis=0)",
"def softmax(x):\n return np.exp(x)/np.sum(np.exp(x),... | [
"0.82091117",
"0.8203848",
"0.819648",
"0.819648",
"0.81928647",
"0.81735945",
"0.81680465",
"0.8144589",
"0.8144145",
"0.813783",
"0.8125608",
"0.8100958",
"0.80981773",
"0.80939096",
"0.80836487",
"0.80836487",
"0.80836487",
"0.80836487",
"0.80836487",
"0.80836487",
"0.8083... | 0.8248852 | 0 |
Calculates logsoftmax across a desired axis. Arguments | def log_softmax(x: jnp.DeviceArray, *, axis: int = 0) -> jnp.DeviceArray:
return x - jnp.expand_dims(jnp.log(jnp.sum(jnp.exp(x), axis=axis)), axis) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_softmax(input, dim, inplace=False):\n return FunctionLib.apply(\n 'LogSoftmax', input.device, [input],\n outputs=[input if inplace else None], axis=dim)",
"def log_softmax_nd(logits, axes=(-1,)):\n logits -= tf.reduce_max(logits, axis=axes, keepdims=True)\n return logits - tf.reduc... | [
"0.79187274",
"0.78436774",
"0.78026515",
"0.7745838",
"0.7555003",
"0.7547153",
"0.7151152",
"0.7116799",
"0.70571184",
"0.70393515",
"0.7036909",
"0.6993901",
"0.69822043",
"0.6971128",
"0.6970583",
"0.69682556",
"0.69494355",
"0.6942103",
"0.6942103",
"0.6929219",
"0.69118... | 0.8242526 | 0 |
Copy contents of one stream into another. | def copyStreamToStream(streamFrom, streamTo, input_length=sys.maxint, offset=0,
buffer=2 ** 2 ** 2 ** 2):
streamFrom.seek(offset, 0)
nbytes = 0
while nbytes < input_length:
chunk = streamFrom.read(min(input_length - nbytes, buffer))
if not chunk:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_to(self, stream, bufsize=None):\n bufsize = bufsize or PRETZEL_BUFSIZE\n if isinstance(stream.write(b''), int):\n # destination stream is synchronous python stream\n try:\n while True:\n stream.write((yield self.read(bufsize)))\n ... | [
"0.6626283",
"0.6452199",
"0.61475044",
"0.6086651",
"0.5963692",
"0.57964855",
"0.5794431",
"0.5788323",
"0.5749928",
"0.56529135",
"0.5546919",
"0.55270535",
"0.5521073",
"0.54890835",
"0.5436751",
"0.543479",
"0.54131347",
"0.5392881",
"0.53848237",
"0.53318536",
"0.529196... | 0.7215272 | 0 |
Printout memory usage statistics. | def print_memory_stats(location_tag="undef"):
try:
import psutil
p = psutil.Process(os.getpid())
rm, vm = p.get_memory_info()
print "MEM_STAT (%s) rm=%s, vm=%s" % (location_tag, rm, vm)
except ImportError:
print "psutil module not available" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_memory_diags(disable_print=False):\n process = psutil.Process(os.getpid())\n memory = process.memory_info().rss/1000000000.0\n if not disable_print:\n logging.info('\\tMemory usage: {:.3f} GB'.format(memory))\n return memory",
"def print_current_mem_usage():\n mem = get_current_me... | [
"0.76514274",
"0.7634883",
"0.7584728",
"0.7564569",
"0.736413",
"0.7283178",
"0.6955679",
"0.6937322",
"0.6876623",
"0.6779077",
"0.671467",
"0.6708236",
"0.66627175",
"0.6650455",
"0.6588355",
"0.6583832",
"0.6578967",
"0.65692943",
"0.6550809",
"0.65389204",
"0.6524489",
... | 0.7896127 | 0 |
Cambiamos la potencia de disparo | def cambiar_potencia(self, potencia):
self.potencia += potencia
self.partida.actualizar_marcador() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mover_bm_derecha(self):\n self.nueva_posicion_posible_parte_superior = self.mapa.consultar_casilla_por_movimiento([self.casilla[0] + 1,\n self.casilla[1]],\n ... | [
"0.5895572",
"0.5794777",
"0.56389797",
"0.5613253",
"0.5611132",
"0.55967414",
"0.55967414",
"0.55967414",
"0.55967414",
"0.55967414",
"0.54503614",
"0.5439653",
"0.53975016",
"0.53975016",
"0.53975016",
"0.53975016",
"0.53975016",
"0.53975016",
"0.5377089",
"0.5350562",
"0.... | 0.6105102 | 0 |
Walk Animation walk_images = os.path.join(_RESFOLDERS, 'Walk', '.gif') walk_list = glob.glob(walk_images) | def iniciar_sprites(self):
res_gifs = os.path.join(_RESFOLDERS, '**', '*.gif')
gifs_list = glob.glob(res_gifs, recursive=True)
for gif in gifs_list:
self.guardar_sprite(gif) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_images(self):\r\n self.standing_frame = [load_image(\"cat1.png\")]\r\n self.walk_frames_r = [load_image(\"cat2.png\"), load_image(\"cat3.png\"),\r\n load_image(\"cat4.png\")]",
"def load_images(self, folder):\n cwd = os.getcwd()\n dir = cwd + '/' ... | [
"0.6584038",
"0.64543307",
"0.6450545",
"0.64224446",
"0.6325395",
"0.6270912",
"0.6255214",
"0.62539303",
"0.61220104",
"0.61161965",
"0.60567886",
"0.59772885",
"0.59587044",
"0.58857423",
"0.5868233",
"0.58653075",
"0.58591115",
"0.5856427",
"0.5824385",
"0.581767",
"0.579... | 0.65915805 | 0 |
Populate choices using installed apps names. | def _get_target_choices():
apps = [('public', _("Public website"))]
for model, entity in registry.registry.items():
if entity.menu:
appname = model._meta.app_label.lower()
apps.append((appname, unicode(entity.label)))
return tuple(apps) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_installed_applications(self):\n for application in self.settings.get('apps', None) or []:\n path = None\n if isinstance(application, six.string_types):\n application_name = application\n if application.startswith('gordon.contrib.'):\n ... | [
"0.63182974",
"0.6118882",
"0.61001414",
"0.5881627",
"0.5712084",
"0.56903887",
"0.56577164",
"0.56141806",
"0.55990887",
"0.5588868",
"0.5577193",
"0.5558418",
"0.555771",
"0.55525905",
"0.5540721",
"0.5527112",
"0.55160326",
"0.5498196",
"0.5469074",
"0.5469074",
"0.546878... | 0.67037904 | 0 |
Computes the difference between nuclear luminosity and stellar luminosity. Arguments radius (scaled units) mass (scaled units) delta_m, eta, xi convergence paramters mue mean molecular weight pp_factor multiplicative factor for rate Returns Lnuc(R) 4piR2sigmaTeff4 | def lum_difference(radius,mass,delta_m,eta,xi,mue,pp_factor):
m,r,p,Lnuc = integrate(mass,radius,delta_m,eta,xi,mue,pp_factor,max_steps=10000)
return Lnuc[-1]-surface_luminosity(Teff_for_main(m[-1]),r[-1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_radius(mass,delta_m,eta,xi,mue,pp_factor):\n\n #range of radii; reason in detail under step 9 of report\n r_low = 0.01*Rsun # MKS\n r_high = 3*Rsun # MKS\n \n radius = brentq(lum_difference, r_low, r_high, xtol=1.0e-4, args = (mass,delta_m,eta,xi,mue,pp_factor))\n return radius",
"def ... | [
"0.6105835",
"0.59289014",
"0.543074",
"0.5385494",
"0.5364295",
"0.52827114",
"0.52727747",
"0.5263927",
"0.5261019",
"0.5210305",
"0.5124193",
"0.50878245",
"0.5032547",
"0.4996151",
"0.49636453",
"0.49624547",
"0.49145013",
"0.49066216",
"0.48998904",
"0.48876116",
"0.4845... | 0.7697479 | 0 |
For a given mass calls rootfind over some range of radii, integrates over the function until the difference in luminosity is zero (nuclear luminosity = surface luminosity) Arguments mass (scaled units) delta_m, eta, xi convergence paramters mue mean molecular weight pp_factor multiplicative factor for rate Returns radi... | def find_radius(mass,delta_m,eta,xi,mue,pp_factor):
#range of radii; reason in detail under step 9 of report
r_low = 0.01*Rsun # MKS
r_high = 3*Rsun # MKS
radius = brentq(lum_difference, r_low, r_high, xtol=1.0e-4, args = (mass,delta_m,eta,xi,mue,pp_factor))
return radius | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lum_difference(radius,mass,delta_m,eta,xi,mue,pp_factor):\n m,r,p,Lnuc = integrate(mass,radius,delta_m,eta,xi,mue,pp_factor,max_steps=10000)\n return Lnuc[-1]-surface_luminosity(Teff_for_main(m[-1]),r[-1])",
"def omega_min(m,mu,R,epsilon):\r\n num = e**2*mu*m\r\n den = (1 + epsilon)*np.pi*epsilon... | [
"0.63628334",
"0.5616132",
"0.55902416",
"0.5445173",
"0.54239476",
"0.54030454",
"0.53585684",
"0.5299843",
"0.5293189",
"0.5257939",
"0.52509886",
"0.52108425",
"0.5198325",
"0.5182825",
"0.51755184",
"0.5121687",
"0.51188475",
"0.5108264",
"0.5085689",
"0.5066682",
"0.5065... | 0.7381081 | 0 |
Simple function to create or load existing label encoder If mode is train, alway create new label_encder | def get_or_make_label_encoder(params, problem, mode, label_list=None, zero_class=None):
problem_path = params.ckpt_dir
create_path(problem_path)
le_path = os.path.join(problem_path, '%s_label_encoder.pkl' % problem)
if mode == 'train' and not os.path.exists(le_path):
label_encoder = LabelEncode... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLabelEncoder():\n classes = list(string.letters + string.digits)\n classes.append('')\n le = LabelEncoder()\n le.fit(classes)\n\n return le",
"def load_encoder(checkpoint, encoder_cls,\n HIDDEN_SIZE, embedding, ENCODER_N_LAYERS, DROPOUT, encoder_name, bidirectional):\n mo... | [
"0.6811553",
"0.6775981",
"0.6624491",
"0.62879103",
"0.6285247",
"0.6068988",
"0.5997439",
"0.5965343",
"0.5961353",
"0.59140944",
"0.583923",
"0.57692605",
"0.576683",
"0.57488394",
"0.5745894",
"0.57296175",
"0.56971973",
"0.5688705",
"0.56653464",
"0.5649765",
"0.56185657... | 0.76493424 | 0 |
Given an input string, returns it as the body of an html document. Adapted from example.py included in docutils distribution. | def rst_to_html(input_string, source_path=None, destination_path=None,
input_encoding='unicode', doctitle=1, initial_header_level=1):
overrides = {'input_encoding': input_encoding,
'doctitle_xform': doctitle,
'initial_header_level': initial_header_level,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rest2html(s):\n return core.publish_string(s, writer=html_fragment_writer)",
"def htmlFormat( body = 'No text supplied', title = 'CS 5 project page' ):\n startString = \"\"\"\\\nContent-Type: text/html;\n\n<html>\n<head>\n<title>\n\"\"\"\n afterTitle = \"\"\"\\\n</title>\n</head>\n\n<body>\n\"\"\"\n... | [
"0.66641665",
"0.6609217",
"0.6305159",
"0.6242836",
"0.6172251",
"0.60931087",
"0.6054476",
"0.6012877",
"0.60044134",
"0.59778404",
"0.59670067",
"0.59541255",
"0.5941216",
"0.5902097",
"0.5884714",
"0.588471",
"0.583694",
"0.57947314",
"0.5752858",
"0.57214975",
"0.5713764... | 0.7353787 | 0 |
Runs this transform over the given content. We return a new string that is the result of this transform. | def run(self, content):
parts = []
offset = 0
for match in self.regexp.finditer(content):
parts.append(content[offset:match.start(0)])
parts.append(self.replace(match))
offset = match.end(0)
parts.append(content[offset:])
return ''.join(parts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(self, data, input_content_type, output_content_type):\n return self.transform_fn(data, input_content_type, output_content_type)",
"def transform(self, stdout):\n return stdout",
"def postprocess(self, text):\r\n return text",
"def render(*content, **context):\n return u'... | [
"0.63454944",
"0.6209116",
"0.6048773",
"0.5973691",
"0.5906884",
"0.5887378",
"0.5827559",
"0.58250016",
"0.57623434",
"0.5721566",
"0.56885874",
"0.5667268",
"0.56144154",
"0.5599922",
"0.5597909",
"0.5460976",
"0.5453108",
"0.5448828",
"0.54400074",
"0.5394049",
"0.5382979... | 0.69993293 | 0 |
Returns a list of roots of a linear polynomial. | def roots_linear(f):
r = -f.nth(0)/f.nth(1)
dom = f.get_domain()
if not dom.is_Numerical:
if dom.is_Composite:
r = factor(r)
else:
from sympy.simplify.simplify import simplify
r = simplify(r)
return [r] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def realpolyroots(*cs):\n if not cs:\n return [0]\n try:\n f = 1.0/cs[0]\n cs = [f*c for c in cs[1:]]\n except ArithmeticError:\n return realpolyroots(*cs[1:])\n else:\n n = len(cs)\n if n == 0:\n return []\n elif n == 1:\n return [... | [
"0.699301",
"0.68372566",
"0.6812553",
"0.6778328",
"0.6580493",
"0.6448303",
"0.64083934",
"0.62958246",
"0.6221394",
"0.6214463",
"0.6213689",
"0.620138",
"0.60809135",
"0.6045944",
"0.59933275",
"0.59385794",
"0.5924114",
"0.5923547",
"0.5893801",
"0.58751374",
"0.58578867... | 0.70028156 | 0 |
r""" Returns a list of roots of a quartic polynomial. There are many references for solving quartic expressions available [15]. This reviewer has found that many of them require one to select from among 2 or more possible sets of solutions and that some solutions work when one is searching for real roots but do not wor... | def roots_quartic(f):
_, a, b, c, d = f.monic().all_coeffs()
if not d:
return [S.Zero] + roots([1, a, b, c], multiple=True)
elif (c/a)**2 == d:
x, m = f.gen, c/a
g = Poly(x**2 + a*x + b - 2*m, x)
z1, z2 = roots_quadratic(g)
h1 = Poly(x**2 - z1*x + m, x)
h2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _realroots_quartic(a3, a2, a1, a0):\n # see http://mathworld.wolfram.com/QuarticEquation.html for details\n ys = _realroots_cubic(-a2, a1*a3 - 4*a0, 4*a0*a2 - a1*a1 - a0*a3*a3)\n ys = [y for y in ys if a3*a3-4*a2+4*y >= 0 and y*y-4*a0 >= 0]\n if not ys:\n return []\n y1 = min(ys)\n if... | [
"0.7691381",
"0.70223194",
"0.67854947",
"0.6726414",
"0.6687224",
"0.66422635",
"0.66170025",
"0.6552937",
"0.63935107",
"0.63915175",
"0.6389726",
"0.6380986",
"0.62318456",
"0.6211318",
"0.61140424",
"0.60838556",
"0.60170877",
"0.5920878",
"0.58423185",
"0.57521677",
"0.5... | 0.7383764 | 1 |
Returns a list of roots of a binomial polynomial. If the domain is ZZ then the roots will be sorted with negatives coming before positives. The ordering will be the same for any numerical coefficients as long as the assumptions tested are correct, otherwise the ordering will not be sorted (but will be canonical). | def roots_binomial(f):
n = f.degree()
a, b = f.nth(n), f.nth(0)
base = -cancel(b/a)
alpha = root(base, n)
if alpha.is_number:
alpha = alpha.expand(complex=True)
# define some parameters that will allow us to order the roots.
# If the domain is ZZ this is guaranteed to return roots... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def almost_positive_roots(self):\n assert self.cartan_type().is_finite()\n return sorted([ -beta for beta in self.simple_roots() ] + list(self.positive_roots()))",
"def realpolyroots(*cs):\n if not cs:\n return [0]\n try:\n f = 1.0/cs[0]\n cs = [f*c for c in cs[1:... | [
"0.63752747",
"0.6269281",
"0.6176525",
"0.6108229",
"0.6071052",
"0.6057403",
"0.5983822",
"0.5921927",
"0.5852689",
"0.58482456",
"0.57848656",
"0.5704563",
"0.5699721",
"0.56636614",
"0.56186897",
"0.54831684",
"0.54757977",
"0.54500794",
"0.54273564",
"0.5352519",
"0.5346... | 0.7264747 | 0 |
Find ``(L, U)`` such that ``L >> from sympy.polys.polyroots import _inv_totient_estimate >>> _inv_totient_estimate(192) (192, 840) >>> _inv_totient_estimate(400) (400, 1750) | def _inv_totient_estimate(m):
primes = [ d + 1 for d in divisors(m) if isprime(d + 1) ]
a, b = 1, 1
for p in primes:
a *= p
b *= p - 1
L = m
U = int(math.ceil(m*(float(a)/b)))
P = p = 2
primes = []
while P <= U:
p = nextprime(p)
primes.append(p)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findPotential(L, boundaryConditions, Minv = None):\n\tX = findStableState(L, boundaryConditions, Minv)\n\treturn np.trace(X.T.dot(L).dot(X))",
"def Findlt(l,sp,rhs):\n m = sp.M(l)\n return (m / l**3) - rhs",
"def linear_inv_state_estimate(results: List[ExperimentResult],\n ... | [
"0.5654112",
"0.5446574",
"0.5408425",
"0.5286101",
"0.5229726",
"0.5152003",
"0.51416683",
"0.5085175",
"0.5065494",
"0.5054303",
"0.5050599",
"0.50233173",
"0.5016458",
"0.5014176",
"0.49979034",
"0.49948668",
"0.49875477",
"0.49864754",
"0.49744186",
"0.4971717",
"0.495969... | 0.6683084 | 0 |
Calculate exact roots of a solvable irreducible quintic with rational coefficients. Return an empty list if the quintic is reducible or not solvable. | def roots_quintic(f):
result = []
coeff_5, coeff_4, p_, q_, r_, s_ = f.all_coeffs()
if not all(coeff.is_Rational for coeff in (coeff_5, coeff_4, p_, q_, r_, s_)):
return result
if coeff_5 != 1:
f = Poly(f / coeff_5)
_, coeff_4, p_, q_, r_, s_ = f.all_coeffs()
# Cancel coe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _realroots_quartic(a3, a2, a1, a0):\n # see http://mathworld.wolfram.com/QuarticEquation.html for details\n ys = _realroots_cubic(-a2, a1*a3 - 4*a0, 4*a0*a2 - a1*a1 - a0*a3*a3)\n ys = [y for y in ys if a3*a3-4*a2+4*y >= 0 and y*y-4*a0 >= 0]\n if not ys:\n return []\n y1 = min(ys)\n if... | [
"0.6811202",
"0.6796312",
"0.6786293",
"0.6716183",
"0.66416746",
"0.65845186",
"0.65421104",
"0.65183496",
"0.65000635",
"0.6442644",
"0.64239186",
"0.63015795",
"0.6251539",
"0.62388915",
"0.62045044",
"0.6190044",
"0.61316377",
"0.60060287",
"0.5985993",
"0.58836967",
"0.5... | 0.7315998 | 0 |
Compute coefficient basis for a polynomial over integers. Returns the integer ``div`` such that substituting ``x = divy`` ``p(x) = mq(y)`` where the coefficients of ``q`` are smaller than those of ``p``. For example ``x5 + 512x + 1024 = 0`` with ``div = 4`` becomes ``y5 + 2y + 1 = 0`` Returns the integer ``div`` or ``N... | def _integer_basis(poly):
monoms, coeffs = list(zip(*poly.terms()))
monoms, = list(zip(*monoms))
coeffs = list(map(abs, coeffs))
if coeffs[0] < coeffs[-1]:
coeffs = list(reversed(coeffs))
n = monoms[0]
monoms = [n - i for i in reversed(monoms)]
else:
return None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def divisor_num(x):\n factor_pow = map(lambda y: y + 1, factorint(x).values())\n div_num = reduce(mul, factor_pow)\n return div_num",
"def integerpolynomialfactorization(f):\n cont = f.content()\n prim = f.primitive_part()\n F = [prim]\n G = prim\n c = 0\n one = G.getRing().one\n wh... | [
"0.5803568",
"0.5495862",
"0.53540903",
"0.5195812",
"0.5137353",
"0.50611347",
"0.5049097",
"0.49525103",
"0.48945084",
"0.4893453",
"0.48900345",
"0.48405665",
"0.48327824",
"0.47568256",
"0.47512928",
"0.4697377",
"0.46737888",
"0.46663266",
"0.46649405",
"0.4663487",
"0.4... | 0.73283625 | 0 |
Try to get rid of symbolic coefficients from ``poly``. | def preprocess_roots(poly):
coeff = S.One
poly_func = poly.func
try:
_, poly = poly.clear_denoms(convert=True)
except DomainError:
return coeff, poly
poly = poly.primitive()[1]
poly = poly.retract()
# TODO: This is fragile. Figure out how to make this independent of constr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear_simplify_poly(poly):\n if len(poly) < 4:\n return poly\n\n q = Queue()\n for v in poly:\n q.put(v)\n\n new_poly = []\n a = q.get()\n b = q.get()\n while True:\n if q.empty():\n new_poly += [a,b]\n break\n c = q.get()\n e1 = (b... | [
"0.62805736",
"0.6251077",
"0.61265767",
"0.6063948",
"0.59309864",
"0.58919007",
"0.5861226",
"0.58583367",
"0.58181924",
"0.58060616",
"0.5801948",
"0.5798098",
"0.5743815",
"0.5664095",
"0.5663453",
"0.56335896",
"0.5619114",
"0.56125027",
"0.56103873",
"0.55965537",
"0.55... | 0.6638182 | 0 |
Computes symbolic roots of a univariate polynomial. Given a univariate polynomial f with symbolic coefficients (or a list of the polynomial's coefficients), returns a dictionary with its roots and their multiplicities. Only roots expressible via radicals will be returned. To get a complete set of roots use RootOf class... | def roots(f, *gens,
auto=True,
cubics=True,
trig=False,
quartics=True,
quintics=False,
multiple=False,
filter=None,
predicate=None,
strict=False,
**flags):
from sympy.polys.polytools import to_rational_coeffs
flags = dict(flags)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roots_cubic(f, trig=False):\n if trig:\n a, b, c, d = f.all_coeffs()\n p = (3*a*c - b**2)/(3*a**2)\n q = (2*b**3 - 9*a*b*c + 27*a**2*d)/(27*a**3)\n D = 18*a*b*c*d - 4*b**3*d + b**2*c**2 - 4*a*c**3 - 27*a**2*d**2\n if (D > 0) == True:\n rv = []\n for k... | [
"0.6896479",
"0.6696928",
"0.65651536",
"0.6392125",
"0.6328955",
"0.6318705",
"0.63019294",
"0.623209",
"0.6114012",
"0.5993156",
"0.5949037",
"0.5923371",
"0.5701059",
"0.5666536",
"0.5619273",
"0.5569309",
"0.54927284",
"0.5336779",
"0.52657783",
"0.52145165",
"0.5202273",... | 0.70961726 | 0 |
Returns all factors of a univariate polynomial. Examples ======== >>> from sympy.abc import x, y >>> from sympy.polys.polyroots import root_factors >>> root_factors(x2 y, x) [x sqrt(y), x + sqrt(y)] | def root_factors(f, *gens, filter=None, **args):
args = dict(args)
F = Poly(f, *gens, **args)
if not F.is_Poly:
return [f]
if F.is_multivariate:
raise ValueError('multivariate polynomials are not supported')
x = F.gens[0]
zeros = roots(F, filter=filter)
if not zeros:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_factors(roots, multiplicity, include_powers=False):\n current = cupy.array([1])\n suffixes = [current]\n for pole, mult in zip(roots[-1:0:-1], multiplicity[-1:0:-1]):\n monomial = cupy.r_[1, -pole]\n for _ in range(int(mult)):\n current = cupy.polymul(current, monomia... | [
"0.7069163",
"0.6946843",
"0.6769513",
"0.6616636",
"0.6602128",
"0.65511125",
"0.65452355",
"0.64717513",
"0.63566077",
"0.6323654",
"0.6308325",
"0.62574553",
"0.62244284",
"0.6213336",
"0.6190737",
"0.6173634",
"0.6167063",
"0.61606395",
"0.6150739",
"0.61217386",
"0.61190... | 0.7182827 | 0 |
Modify the land cover to create rocks in the large gradient pixels (large steepness) | def set_rocks_in_grad(self, elevation, landcover):
# Compute the steepness of each pixel
grad = gaussian_gradient_magnitude(elevation, 1.0)
grad /= self.mercator.Resolution(self.__zoom)
# Get the mask of rock (with a smooth transition)
mask = (grad >= ROCK_STEEPNESS).astype(np.fl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess_land_cover(\n src_files, dst_raster, dst_crs, dst_bounds, dst_res, geom=None, overwrite=False\n):\n if os.path.isfile(dst_raster) and not overwrite:\n log.info(\"Land cover data already preprocessed. Skipping.\")\n return\n log.info(\"Starting preprocessing of land cover data.... | [
"0.5887975",
"0.5787736",
"0.57740206",
"0.56503314",
"0.5611882",
"0.55984235",
"0.55739576",
"0.5566662",
"0.5542999",
"0.55224055",
"0.551903",
"0.5480114",
"0.5477756",
"0.5398472",
"0.53926384",
"0.53850454",
"0.5373012",
"0.53565186",
"0.53404105",
"0.53380716",
"0.5336... | 0.71222955 | 0 |
Make the object directory and file for the adding file. | def make_directory_and_object_file(file_sha1_hash, file_content, parent_dir):
try:
# Create a path for the new directory, which is the first 2 characters
# of the hash.
new_dir_path = join(parent_dir, ".lgit/objects", file_sha1_hash[:2])
# Create the directory
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeLibrary(self):\n #------------------------------------------ Instance for the output file\n outputFile = open(\"%s/%s\" % (self.sceneryPath,self.libTxtFileName),\"w\")\n #------------------------------------------------------ write the header\n for line in self.header:\n ... | [
"0.67735976",
"0.6593304",
"0.6487546",
"0.6399611",
"0.62541074",
"0.6146902",
"0.6131344",
"0.6102639",
"0.6092799",
"0.6058326",
"0.60511124",
"0.60165167",
"0.60149306",
"0.59659183",
"0.59595376",
"0.59442127",
"0.59324336",
"0.5891388",
"0.58593774",
"0.58547544",
"0.58... | 0.67971694 | 0 |
Sets the aux_input_type1 of this UpdateVehicleRequest. | def aux_input_type1(self, aux_input_type1):
allowed_values = ["none", "emergencyLights", "emergencyAlarm", "stopPaddle", "powerTakeOff", "plow", "sweeper", "salter", "reefer", "door", "boom", "auxiliaryEngine", "generator", "eightWayLights"] # noqa: E501
if self.local_vars_configuration.client_side_val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aux_input_type2(self, aux_input_type2):\n allowed_values = [\"none\", \"emergencyLights\", \"emergencyAlarm\", \"stopPaddle\", \"powerTakeOff\", \"plow\", \"sweeper\", \"salter\", \"reefer\", \"door\", \"boom\", \"auxiliaryEngine\", \"generator\", \"eightWayLights\"] # noqa: E501\n if self.local... | [
"0.6881577",
"0.6247039",
"0.61682045",
"0.6168174",
"0.61245406",
"0.6103021",
"0.59515715",
"0.57475",
"0.55829304",
"0.526451",
"0.48469332",
"0.47708565",
"0.47298566",
"0.4703361",
"0.46092513",
"0.45240486",
"0.44671947",
"0.44662634",
"0.439882",
"0.4355716",
"0.434613... | 0.8198986 | 0 |
Sets the aux_input_type10 of this UpdateVehicleRequest. | def aux_input_type10(self, aux_input_type10):
allowed_values = ["none", "emergencyLights", "emergencyAlarm", "stopPaddle", "powerTakeOff", "plow", "sweeper", "salter", "reefer", "door", "boom", "auxiliaryEngine", "generator", "eightWayLights"] # noqa: E501
if self.local_vars_configuration.client_side_v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aux_input_type9(self, aux_input_type9):\n allowed_values = [\"none\", \"emergencyLights\", \"emergencyAlarm\", \"stopPaddle\", \"powerTakeOff\", \"plow\", \"sweeper\", \"salter\", \"reefer\", \"door\", \"boom\", \"auxiliaryEngine\", \"generator\", \"eightWayLights\"] # noqa: E501\n if self.local... | [
"0.6725952",
"0.610575",
"0.5790601",
"0.5682387",
"0.56456137",
"0.54830354",
"0.5383829",
"0.53816664",
"0.53323066",
"0.440578",
"0.43797588",
"0.4314514",
"0.43111408",
"0.42576176",
"0.4198845",
"0.4124491",
"0.41100422",
"0.4049688",
"0.40081385",
"0.40019417",
"0.39651... | 0.8267368 | 0 |
Sets the aux_input_type2 of this UpdateVehicleRequest. | def aux_input_type2(self, aux_input_type2):
allowed_values = ["none", "emergencyLights", "emergencyAlarm", "stopPaddle", "powerTakeOff", "plow", "sweeper", "salter", "reefer", "door", "boom", "auxiliaryEngine", "generator", "eightWayLights"] # noqa: E501
if self.local_vars_configuration.client_side_val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aux_input_type1(self, aux_input_type1):\n allowed_values = [\"none\", \"emergencyLights\", \"emergencyAlarm\", \"stopPaddle\", \"powerTakeOff\", \"plow\", \"sweeper\", \"salter\", \"reefer\", \"door\", \"boom\", \"auxiliaryEngine\", \"generator\", \"eightWayLights\"] # noqa: E501\n if self.local... | [
"0.67737305",
"0.60007954",
"0.5945109",
"0.5709236",
"0.5614584",
"0.55712336",
"0.5553947",
"0.54106337",
"0.52731603",
"0.5124387",
"0.5114672",
"0.46984407",
"0.469242",
"0.46270508",
"0.46270508",
"0.45326632",
"0.4530033",
"0.45260003",
"0.45230535",
"0.4521897",
"0.450... | 0.8351475 | 0 |
Sets the aux_input_type3 of this UpdateVehicleRequest. | def aux_input_type3(self, aux_input_type3):
allowed_values = ["none", "emergencyLights", "emergencyAlarm", "stopPaddle", "powerTakeOff", "plow", "sweeper", "salter", "reefer", "door", "boom", "auxiliaryEngine", "generator", "eightWayLights"] # noqa: E501
if self.local_vars_configuration.client_side_val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aux_input_type9(self, aux_input_type9):\n allowed_values = [\"none\", \"emergencyLights\", \"emergencyAlarm\", \"stopPaddle\", \"powerTakeOff\", \"plow\", \"sweeper\", \"salter\", \"reefer\", \"door\", \"boom\", \"auxiliaryEngine\", \"generator\", \"eightWayLights\"] # noqa: E501\n if self.local... | [
"0.60051674",
"0.59958714",
"0.59745276",
"0.5884165",
"0.573058",
"0.55547076",
"0.5548062",
"0.5489199",
"0.54143596",
"0.5395056",
"0.5113174",
"0.5069129",
"0.49999794",
"0.49934226",
"0.49783775",
"0.49597377",
"0.49532253",
"0.48770082",
"0.48317355",
"0.4767722",
"0.47... | 0.833222 | 0 |
Sets the aux_input_type4 of this UpdateVehicleRequest. | def aux_input_type4(self, aux_input_type4):
allowed_values = ["none", "emergencyLights", "emergencyAlarm", "stopPaddle", "powerTakeOff", "plow", "sweeper", "salter", "reefer", "door", "boom", "auxiliaryEngine", "generator", "eightWayLights"] # noqa: E501
if self.local_vars_configuration.client_side_val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aux_input_type6(self, aux_input_type6):\n allowed_values = [\"none\", \"emergencyLights\", \"emergencyAlarm\", \"stopPaddle\", \"powerTakeOff\", \"plow\", \"sweeper\", \"salter\", \"reefer\", \"door\", \"boom\", \"auxiliaryEngine\", \"generator\", \"eightWayLights\"] # noqa: E501\n if self.local... | [
"0.6177032",
"0.6103347",
"0.5953408",
"0.5917011",
"0.58011657",
"0.5769559",
"0.5681293",
"0.56600946",
"0.53610873",
"0.4841803",
"0.45973018",
"0.4593053",
"0.45379746",
"0.45276865",
"0.45267612",
"0.44020706",
"0.4333473",
"0.4321829",
"0.4218026",
"0.42120838",
"0.4156... | 0.82154655 | 0 |
Sets the aux_input_type5 of this UpdateVehicleRequest. | def aux_input_type5(self, aux_input_type5):
allowed_values = ["none", "emergencyLights", "emergencyAlarm", "stopPaddle", "powerTakeOff", "plow", "sweeper", "salter", "reefer", "door", "boom", "auxiliaryEngine", "generator", "eightWayLights"] # noqa: E501
if self.local_vars_configuration.client_side_val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aux_input_type6(self, aux_input_type6):\n allowed_values = [\"none\", \"emergencyLights\", \"emergencyAlarm\", \"stopPaddle\", \"powerTakeOff\", \"plow\", \"sweeper\", \"salter\", \"reefer\", \"door\", \"boom\", \"auxiliaryEngine\", \"generator\", \"eightWayLights\"] # noqa: E501\n if self.local... | [
"0.6735667",
"0.61671937",
"0.6084544",
"0.60733855",
"0.6030134",
"0.57733315",
"0.57299143",
"0.56766456",
"0.5534028",
"0.5277805",
"0.50033385",
"0.45613086",
"0.45503688",
"0.44486523",
"0.43939793",
"0.43528506",
"0.4218385",
"0.41903195",
"0.41550255",
"0.41463068",
"0... | 0.84810084 | 0 |
Sets the aux_input_type6 of this UpdateVehicleRequest. | def aux_input_type6(self, aux_input_type6):
allowed_values = ["none", "emergencyLights", "emergencyAlarm", "stopPaddle", "powerTakeOff", "plow", "sweeper", "salter", "reefer", "door", "boom", "auxiliaryEngine", "generator", "eightWayLights"] # noqa: E501
if self.local_vars_configuration.client_side_val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aux_input_type7(self, aux_input_type7):\n allowed_values = [\"none\", \"emergencyLights\", \"emergencyAlarm\", \"stopPaddle\", \"powerTakeOff\", \"plow\", \"sweeper\", \"salter\", \"reefer\", \"door\", \"boom\", \"auxiliaryEngine\", \"generator\", \"eightWayLights\"] # noqa: E501\n if self.local... | [
"0.6811139",
"0.6711326",
"0.6464062",
"0.61897624",
"0.60081035",
"0.59919214",
"0.5962499",
"0.58940566",
"0.5785702",
"0.50470114",
"0.49827394",
"0.4801943",
"0.4498699",
"0.44764334",
"0.43467817",
"0.431762",
"0.42938703",
"0.42625344",
"0.4177838",
"0.4142461",
"0.4113... | 0.8384907 | 0 |
Sets the aux_input_type7 of this UpdateVehicleRequest. | def aux_input_type7(self, aux_input_type7):
allowed_values = ["none", "emergencyLights", "emergencyAlarm", "stopPaddle", "powerTakeOff", "plow", "sweeper", "salter", "reefer", "door", "boom", "auxiliaryEngine", "generator", "eightWayLights"] # noqa: E501
if self.local_vars_configuration.client_side_val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aux_input_type6(self, aux_input_type6):\n allowed_values = [\"none\", \"emergencyLights\", \"emergencyAlarm\", \"stopPaddle\", \"powerTakeOff\", \"plow\", \"sweeper\", \"salter\", \"reefer\", \"door\", \"boom\", \"auxiliaryEngine\", \"generator\", \"eightWayLights\"] # noqa: E501\n if self.local... | [
"0.737313",
"0.70987934",
"0.68551147",
"0.6368619",
"0.6157716",
"0.61507314",
"0.61456496",
"0.60045",
"0.5644334",
"0.46709234",
"0.4624464",
"0.45685434",
"0.4289816",
"0.420974",
"0.41962048",
"0.41751334",
"0.41050494",
"0.40700984",
"0.39788634",
"0.39388323",
"0.38861... | 0.818187 | 0 |
Sets the aux_input_type8 of this UpdateVehicleRequest. | def aux_input_type8(self, aux_input_type8):
allowed_values = ["none", "emergencyLights", "emergencyAlarm", "stopPaddle", "powerTakeOff", "plow", "sweeper", "salter", "reefer", "door", "boom", "auxiliaryEngine", "generator", "eightWayLights"] # noqa: E501
if self.local_vars_configuration.client_side_val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aux_input_type9(self, aux_input_type9):\n allowed_values = [\"none\", \"emergencyLights\", \"emergencyAlarm\", \"stopPaddle\", \"powerTakeOff\", \"plow\", \"sweeper\", \"salter\", \"reefer\", \"door\", \"boom\", \"auxiliaryEngine\", \"generator\", \"eightWayLights\"] # noqa: E501\n if self.local... | [
"0.6755058",
"0.633114",
"0.629067",
"0.62043154",
"0.58486116",
"0.5745061",
"0.56476486",
"0.55395204",
"0.54535085",
"0.5100648",
"0.48467347",
"0.4543333",
"0.4463553",
"0.44145846",
"0.4389607",
"0.43863967",
"0.43651605",
"0.42814347",
"0.4237928",
"0.42126638",
"0.4205... | 0.8293582 | 0 |
Sets the aux_input_type9 of this UpdateVehicleRequest. | def aux_input_type9(self, aux_input_type9):
allowed_values = ["none", "emergencyLights", "emergencyAlarm", "stopPaddle", "powerTakeOff", "plow", "sweeper", "salter", "reefer", "door", "boom", "auxiliaryEngine", "generator", "eightWayLights"] # noqa: E501
if self.local_vars_configuration.client_side_val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aux_input_type10(self, aux_input_type10):\n allowed_values = [\"none\", \"emergencyLights\", \"emergencyAlarm\", \"stopPaddle\", \"powerTakeOff\", \"plow\", \"sweeper\", \"salter\", \"reefer\", \"door\", \"boom\", \"auxiliaryEngine\", \"generator\", \"eightWayLights\"] # noqa: E501\n if self.loc... | [
"0.6592232",
"0.6393137",
"0.6386548",
"0.6197008",
"0.59048843",
"0.57917714",
"0.5618292",
"0.5533515",
"0.5376587",
"0.46700698",
"0.45658058",
"0.4494469",
"0.43490845",
"0.4330773",
"0.43188262",
"0.4283189",
"0.4261341",
"0.41801286",
"0.40957448",
"0.40957448",
"0.4087... | 0.81162375 | 0 |
Sets the engine_hours of this UpdateVehicleRequest. | def engine_hours(self, engine_hours):
self._engine_hours = engine_hours | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def work_hours_setting(self, work_hours_setting):\n\n self._work_hours_setting = work_hours_setting",
"def active_hours(self, active_hours):\n\n self._active_hours = active_hours",
"def obd_engine_seconds(self, obd_engine_seconds):\n\n self._obd_engine_seconds = obd_engine_seconds",
"def... | [
"0.55531627",
"0.51219904",
"0.5094751",
"0.48254585",
"0.4715887",
"0.46753588",
"0.46118993",
"0.459567",
"0.45515487",
"0.4540938",
"0.45212317",
"0.45212197",
"0.44924808",
"0.44742528",
"0.4456462",
"0.4445044",
"0.44345856",
"0.44310075",
"0.44294956",
"0.44075277",
"0.... | 0.8141102 | 0 |
Sets the external_ids of this UpdateVehicleRequest. | def external_ids(self, external_ids):
self._external_ids = external_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def external_ids(self, **kwargs):\n path = self._get_movie_id_path('external_ids')\n resp = self._get_method(path, kwargs)\n return resp",
"def external_id(self, external_id):\n\n self._external_id = external_id",
"def external_id(self, external_id):\n\n self._external_id = e... | [
"0.5645812",
"0.56326723",
"0.56326723",
"0.56326723",
"0.55220467",
"0.5430042",
"0.5307687",
"0.5243291",
"0.5185779",
"0.51405275",
"0.51405275",
"0.5116388",
"0.508638",
"0.5023836",
"0.49995106",
"0.49790815",
"0.49639636",
"0.4961317",
"0.49294525",
"0.49190345",
"0.489... | 0.7786375 | 0 |
Sets the gateway_serial of this UpdateVehicleRequest. | def gateway_serial(self, gateway_serial):
self._gateway_serial = gateway_serial | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setGateway(self, gateway):\n # type: (str)->None\n\n self._validator.validate_one(\n 'gateway', VALID_OPTS['gateway'], gateway)\n self._ifAttributes['gateway'] = gateway",
"def gateway_id(self, gateway_id):\n\n self._gateway_id = gateway_id",
"def set_serial(self, ser... | [
"0.63021106",
"0.5979875",
"0.56400514",
"0.5633011",
"0.54569376",
"0.526742",
"0.52273846",
"0.51936847",
"0.5030974",
"0.49815518",
"0.49481562",
"0.4906431",
"0.4822673",
"0.47393987",
"0.47254622",
"0.47191525",
"0.4696486",
"0.46910635",
"0.46563208",
"0.46563208",
"0.4... | 0.8186771 | 0 |
Sets the harsh_acceleration_setting_type of this UpdateVehicleRequest. | def harsh_acceleration_setting_type(self, harsh_acceleration_setting_type):
allowed_values = ["passengerCar", "lightTruck", "heavyDuty", "off", "automatic"] # noqa: E501
if self.local_vars_configuration.client_side_validation and harsh_acceleration_setting_type not in allowed_values: # noqa: E501
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_acceleration(self, acceleration):\n self.device.set_acceleration(acceleration)\n return \"OK\"",
"def set_adjustment_type(self, adjustment_type):\n self.single_selection_from_kendo_dropdown(self.adjustment_type_dropdown_locator, adjustment_type)\n self.wait_for_ajax_spinner_lo... | [
"0.5853659",
"0.50912744",
"0.49172306",
"0.48173192",
"0.47014672",
"0.4634827",
"0.46120846",
"0.4590229",
"0.4576279",
"0.45042148",
"0.4476712",
"0.43912166",
"0.43879282",
"0.4383811",
"0.4366613",
"0.4360031",
"0.4352631",
"0.43397018",
"0.43366387",
"0.43263713",
"0.43... | 0.8702775 | 0 |
Sets the license_plate of this UpdateVehicleRequest. | def license_plate(self, license_plate):
if (self.local_vars_configuration.client_side_validation and
license_plate is not None and len(license_plate) > 12):
raise ValueError("Invalid value for `license_plate`, length must be less than or equal to `12`") # noqa: E501
self._l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def license(self, license):\n\n self._license = license",
"def save(self, *args, **kwargs):\n if self.license_plate:\n self.license_plate = self.license_plate.replace('-','').replace(' ','')\n super(VehicleRegistration,self).save(*args, **kwargs)",
"def license_number(self, lice... | [
"0.6482215",
"0.60094345",
"0.5971417",
"0.57393056",
"0.5617041",
"0.55561376",
"0.53961915",
"0.5359062",
"0.5322539",
"0.5291167",
"0.52001405",
"0.5070711",
"0.5057579",
"0.49738538",
"0.49601606",
"0.49601606",
"0.49461326",
"0.4945529",
"0.49165577",
"0.4910613",
"0.487... | 0.7658375 | 0 |
Sets the odometer_meters of this UpdateVehicleRequest. | def odometer_meters(self, odometer_meters):
self._odometer_meters = odometer_meters | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obd_odometer_meters(self, obd_odometer_meters):\n\n self._obd_odometer_meters = obd_odometer_meters",
"def gps_odometer_meters(self, gps_odometer_meters):\n\n self._gps_odometer_meters = gps_odometer_meters",
"def drive_distance_meters(self, drive_distance_meters):\n\n self._drive_dist... | [
"0.78520304",
"0.6952166",
"0.6625439",
"0.5700278",
"0.5330142",
"0.51499796",
"0.49836195",
"0.49621317",
"0.49096128",
"0.4897436",
"0.4849823",
"0.4838554",
"0.4810013",
"0.47394198",
"0.4714336",
"0.4705788",
"0.4705542",
"0.46347386",
"0.46201065",
"0.45941296",
"0.4515... | 0.8017434 | 0 |
Sets the static_assigned_driver_id of this UpdateVehicleRequest. | def static_assigned_driver_id(self, static_assigned_driver_id):
self._static_assigned_driver_id = static_assigned_driver_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def driver_id(self, driver_id):\n\n self._driver_id = driver_id",
"def driver_id(self, driver_id: int):\n if driver_id is None:\n raise ValueError(\"Invalid value for `driver_id`, must not be `None`\") # noqa: E501\n\n self._driver_id = driver_id",
"def static_finding(self, sta... | [
"0.58979875",
"0.52223",
"0.50875014",
"0.45650956",
"0.45579106",
"0.45233056",
"0.45233056",
"0.44840404",
"0.44335097",
"0.43853715",
"0.4371814",
"0.43593413",
"0.43487522",
"0.42879018",
"0.42818657",
"0.42814112",
"0.42524332",
"0.4240414",
"0.4240414",
"0.4225884",
"0.... | 0.8492683 | 0 |
Sets the tag_ids of this UpdateVehicleRequest. | def tag_ids(self, tag_ids):
self._tag_ids = tag_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_tags(self, tags):\r\n current_tags = set(self.tag_names())\r\n updated_tags = set(tags)\r\n removed_tags = current_tags.difference(updated_tags)\r\n new_tags = updated_tags.difference(current_tags)\r\n \r\n for tag in new_tags:\r\n self.add_tag(tag)\r\n ... | [
"0.6124682",
"0.61125207",
"0.60852545",
"0.6005471",
"0.6005471",
"0.6005471",
"0.6005471",
"0.6005471",
"0.6005471",
"0.6005471",
"0.6005471",
"0.6005471",
"0.6005471",
"0.5952815",
"0.59259295",
"0.59259295",
"0.59259295",
"0.5924576",
"0.5871416",
"0.5602764",
"0.55914205... | 0.75711256 | 0 |
Sets the vin of this UpdateVehicleRequest. | def vin(self, vin):
if (self.local_vars_configuration.client_side_validation and
vin is not None and len(vin) > 17):
raise ValueError("Invalid value for `vin`, length must be less than or equal to `17`") # noqa: E501
if (self.local_vars_configuration.client_side_validation a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_vin(self, value):\n return self.sendCMD(\"ATSET VIN={}\".format(value))",
"def vm_volume_num_in(self, vm_volume_num_in):\n\n self._vm_volume_num_in = vm_volume_num_in",
"def vehicle(self, vehicle):\n\n self._vehicle = vehicle",
"def vehicle(self, vehicle):\n\n self._vehicl... | [
"0.6181508",
"0.54808533",
"0.5342333",
"0.5342333",
"0.5278952",
"0.51032424",
"0.50570464",
"0.4902143",
"0.48931664",
"0.48747736",
"0.48244667",
"0.4768621",
"0.47286236",
"0.46440622",
"0.4581164",
"0.4552281",
"0.44910336",
"0.44724986",
"0.44671312",
"0.44606727",
"0.4... | 0.7512381 | 0 |
Return True if command return type is string | def is_string(self):
answer = self._call('is_string')
return answer.yes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_string(arg):\n return isinstance(arg, types.StringTypes)",
"def is_string(value):\n return isinstance(value, (str, bytes))",
"def is_string_action(func: CLIActionType) -> bool:\n return check_function_type(func, [HammerDriver, Callable[[str], None]], Optional[str]) is None",
"def _is... | [
"0.72101504",
"0.67675126",
"0.67398417",
"0.66946656",
"0.6686076",
"0.667609",
"0.6644599",
"0.66220903",
"0.65879357",
"0.65586376",
"0.65518516",
"0.6525141",
"0.6505778",
"0.6503069",
"0.6468777",
"0.64370143",
"0.6400437",
"0.6391969",
"0.63687015",
"0.6319832",
"0.6310... | 0.7352662 | 0 |
Return True if command return type is long | def is_long(self):
answer = self._call('is_long')
return answer.yes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convertToLong(boolean: bool) -> int:\n ...",
"def is_of_type(cmd):\r\n raise NotImplementedError()",
"def hasNextLong(self) -> bool:\n raise NotImplementedError",
"def command_type(self):\n if self.cmd_type is not None:\n return self.cmd_type # should be true only ... | [
"0.5989811",
"0.57864743",
"0.5738203",
"0.5530481",
"0.55091196",
"0.5501726",
"0.5487508",
"0.54735243",
"0.5433546",
"0.5368896",
"0.534729",
"0.5277097",
"0.52574474",
"0.5248837",
"0.51971203",
"0.5174398",
"0.5158678",
"0.515556",
"0.51363266",
"0.5130246",
"0.5119427",... | 0.74627966 | 0 |
Return True if command return type is double | def is_double(self):
answer = self._call('is_double')
return answer.yes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_double(self, size=None):\n return False",
"def _type_check_double(self, data):\n if type(data) not in self._VALID_TYPES:\n return False\n return True",
"def double(self):\n if self.__valeur1 == self.__valeur2:\n return True\n else:\n return... | [
"0.68060154",
"0.6694105",
"0.6278531",
"0.6156558",
"0.6122468",
"0.60317355",
"0.59308475",
"0.59101456",
"0.58420163",
"0.5835771",
"0.56978625",
"0.5695271",
"0.56179863",
"0.55873126",
"0.5555344",
"0.5545467",
"0.54628015",
"0.54531217",
"0.5441905",
"0.5435553",
"0.540... | 0.7801225 | 0 |
Return True if command return type is datetime | def is_datetime(self):
answer = self._call('is_datetime')
return answer.yes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_datetime(self) -> bool:\n return False",
"def has_datetime_type(obj: _std_typing.Any) -> bool:\n return obj.dtype == sc.DType.datetime64",
"def is_datetime(s: Union[str, int, float]):\n if is_number(s):\n return False\n\n try:\n parse_datetime(s)\n return True\n e... | [
"0.7951076",
"0.6984303",
"0.6577533",
"0.6427492",
"0.6338919",
"0.62653446",
"0.62532926",
"0.6224089",
"0.6207788",
"0.6151861",
"0.5996967",
"0.59684855",
"0.59437066",
"0.58614635",
"0.584531",
"0.5838218",
"0.5837798",
"0.5829952",
"0.5794449",
"0.57770663",
"0.57770663... | 0.7957955 | 0 |
Return True if command return type is bool | def is_bool(self):
answer = self._call('is_bool')
return answer.yes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_bool(self):\n return False",
"def is_bool (self, phrase):\r\n \r\n return isinstance(phrase,bool)",
"def __bool__(self) -> bool:\n return self.return_code == 0",
"def __bool__(self) -> bool:\n return self.return_code == 0",
"def __bool__(self) -> bool:\n ... | [
"0.7300168",
"0.6982025",
"0.69479877",
"0.69479877",
"0.69479877",
"0.6931669",
"0.6860637",
"0.684384",
"0.6820059",
"0.6804663",
"0.6776833",
"0.6743398",
"0.67413884",
"0.67388",
"0.6701831",
"0.66715646",
"0.66706675",
"0.6627555",
"0.6617246",
"0.6615943",
"0.65937847",... | 0.71876997 | 1 |
Return True if command return type is map | def is_map(self):
answer = self._call('is_map')
return answer.yes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _msg_is_command(self, msg):\n return isinstance(msg, dict)",
"def is_mapping(self) -> bool:\n return isinstance(self.yaml_node, yaml.MappingNode)",
"def is_map(self, alias):\n maps = {\"Ensembl2Reactome_All_Levels\": False,\n \"ReactomePathways\": True,\n ... | [
"0.6289078",
"0.6281217",
"0.6242795",
"0.61640793",
"0.6034122",
"0.5948415",
"0.58508986",
"0.58115065",
"0.5724521",
"0.56458396",
"0.5560745",
"0.55398226",
"0.55355984",
"0.5446891",
"0.54456025",
"0.5439933",
"0.5427514",
"0.54028404",
"0.53899914",
"0.53831494",
"0.537... | 0.69451547 | 0 |
Return True if command return type is list | def is_list(self):
answer = self._call('is_list')
return answer.yes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_list(self) -> bool:\n return False",
"def is_multi_commands(args: list) -> bool:\n for arg in args:\n if not isinstance(arg, list):\n return False\n # all elements must be lists\n return True",
"def _is_list(arg):\n return isinstance(arg, collecti... | [
"0.74882597",
"0.7068153",
"0.69201654",
"0.68849444",
"0.68486714",
"0.6833843",
"0.6674785",
"0.66685194",
"0.6642766",
"0.66335183",
"0.66288596",
"0.6529805",
"0.65188724",
"0.6512905",
"0.6460788",
"0.64399505",
"0.6422735",
"0.6361648",
"0.6349589",
"0.63341206",
"0.630... | 0.7490665 | 0 |
Set command return value | def set_result(self, value):
value_rpc = utils.get_rpc_value(type(value), value)
self._call('set_result', value=value_rpc) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_success(self, *args, **kwargs):\n return 0, self.shell_output, None",
"def execute_return(cmd):\n args = cmd.split()\n proc = Popen(args,stdout=PIPE,stderr=PIPE)\n out,err = proc.communicate()\n return out,err",
"def execute(self, rc):\n pass",
"def _set_returncode(self,... | [
"0.64630413",
"0.6332911",
"0.62538105",
"0.6227985",
"0.61576617",
"0.6150565",
"0.61106575",
"0.6073182",
"0.59837717",
"0.59783006",
"0.5948261",
"0.5886567",
"0.58848333",
"0.58677804",
"0.58380526",
"0.5837768",
"0.5819132",
"0.5764613",
"0.5763976",
"0.5747505",
"0.5742... | 0.63785946 | 1 |
Set exception in command. Information about exception will be called for adapter's side. | def set_exception(self, reason):
self._call('set_exception', exception=reason) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_exception(self, exception):\n self._is_done = True\n if self._exception:\n self._log(logging.DEBUG, \"'{}.{}' has overwritten exception. From '{}.{}' to '{}.{}'.\".format(\n self.__class__.__module__,\n self.__class__.__name__,\n self._e... | [
"0.65251386",
"0.65130377",
"0.640264",
"0.6400604",
"0.6305449",
"0.6302403",
"0.62972367",
"0.6162168",
"0.6148929",
"0.6125187",
"0.60864145",
"0.60796374",
"0.6046624",
"0.6018471",
"0.59831905",
"0.5967945",
"0.59093523",
"0.5906773",
"0.5851401",
"0.58388805",
"0.581141... | 0.67082244 | 0 |
Reloads the datatype from Riak. | def reload(self, **params):
if not self.bucket:
raise ValueError('bucket property not assigned')
if not self.key:
raise ValueError('key property not assigned')
dtype, value, context = self.bucket._client._fetch_datatype(
self.bucket, self.key, **params)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reload_data(self):\n self._avro_payload.reload_data()",
"def reload(self):\n self.restore()",
"def reloadData(self):\n self.dto.readFromData()\n print(\"Record reloaded.\")",
"def reload(self):",
"def reload(self):",
"def reload(self):\n\n pass",
"def reload_data(self... | [
"0.69468844",
"0.6571157",
"0.652524",
"0.6443367",
"0.6443367",
"0.62622434",
"0.6048451",
"0.6042948",
"0.6036892",
"0.60049",
"0.5873903",
"0.5867182",
"0.5855046",
"0.58414084",
"0.5838228",
"0.58149874",
"0.57650065",
"0.5740696",
"0.57311875",
"0.5674174",
"0.56657064",... | 0.6577614 | 1 |
Raises an exception if the context is not present | def _require_context(self):
if not self._context:
raise ContextRequired() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_context_invalid():\n\n with pytest.raises(ContextAttributeError):\n application_services.get_context('not_present_context')",
"def handle_context_missing(self):",
"def test_stored_context_err(self):\n self.stack = stack.Stack(self.ctx, 'creds_stack', self.tmpl)\n ex = self.... | [
"0.76646805",
"0.7559883",
"0.6614295",
"0.6527365",
"0.64800733",
"0.64293313",
"0.6406461",
"0.6245151",
"0.6196592",
"0.61848545",
"0.6142678",
"0.60623604",
"0.60348666",
"0.6032899",
"0.60134035",
"0.60021675",
"0.5999621",
"0.59995925",
"0.5892164",
"0.5860368",
"0.5839... | 0.800951 | 0 |
Scrubs sys.path and sys.modules to a raw state. | def _scrub_import_environment(sys_modules_whitelist: typing.List[str], logger: typing.Callable):
pex_root = pathlib.Path(Variables().PEX_ROOT)
# A generator that emits sys.path elements
def scrubbed_sys_path():
"""Yields a scrubbed version of sys.path."""
for p in sys.path[:]:
if not isinstance(p, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_sys(cls):\n def patch_dict(old_value, new_value):\n old_value.clear()\n old_value.update(new_value)\n\n def patch_all(path, path_importer_cache, modules):\n sys.path[:] = path\n patch_dict(sys.path_importer_cache, path_importer_cache)\n patch_dict(sys.modules, modules)\n\n ... | [
"0.6124312",
"0.6062598",
"0.59543145",
"0.5901678",
"0.56766284",
"0.56067514",
"0.5542571",
"0.54748863",
"0.5422463",
"0.5348224",
"0.53475314",
"0.53056484",
"0.52948594",
"0.51196456",
"0.51149005",
"0.51118445",
"0.50935435",
"0.5014209",
"0.50100213",
"0.5005435",
"0.4... | 0.64339405 | 0 |
Yields a scrubbed version of sys.path. | def scrubbed_sys_path():
for p in sys.path[:]:
if not isinstance(p, str):
yield p
# Scrub any/all pex locations from sys.path.
pp = pathlib.Path(p)
if pex_root not in pp.parents:
yield p | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrub_from_sys_modules():\n for k, m in sys.modules.items():\n if k in sys_modules_whitelist:\n continue\n\n if hasattr(m, '__file__') and m.__file__ is not None:\n mp = pathlib.Path(m.__file__)\n if pex_root in mp.parents:\n yield k",
"def add_sys_paths(paths):\n ... | [
"0.6704874",
"0.64456856",
"0.63815147",
"0.61018676",
"0.6091217",
"0.6007068",
"0.596048",
"0.5937054",
"0.5828322",
"0.5781934",
"0.5675717",
"0.567165",
"0.56604296",
"0.5641513",
"0.56188345",
"0.5617912",
"0.55805993",
"0.5579308",
"0.5575357",
"0.5502024",
"0.54931635"... | 0.80444944 | 0 |
Yields keys of sys.modules as candidates for scrubbing/removal. | def scrub_from_sys_modules():
for k, m in sys.modules.items():
if k in sys_modules_whitelist:
continue
if hasattr(m, '__file__') and m.__file__ is not None:
mp = pathlib.Path(m.__file__)
if pex_root in mp.parents:
yield k | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_registered_modules():\n yield from iterchain(modules.values() for modules in Registry.monomers.values())",
"def modules(self):\n for desc in self._mappings.values():\n if hasattr(desc, 'module'):\n yield desc.module\n else:\n continue",
"def... | [
"0.6842569",
"0.6502843",
"0.6499838",
"0.647568",
"0.6403681",
"0.6330229",
"0.62831795",
"0.62433136",
"0.61260855",
"0.6123235",
"0.60469973",
"0.6040864",
"0.603489",
"0.59373957",
"0.59103936",
"0.58853215",
"0.5881549",
"0.5876056",
"0.5848127",
"0.5820939",
"0.5803232"... | 0.80843186 | 0 |
Extracts exactly 1 binary from a dir and returns a Path. | def _extract_resulting_binary(self, build_dir: pathlib.PosixPath, extension: str) -> pathlib.PosixPath:
assert build_dir.is_dir(), f'build_dir {build_dir} was not a dir!'
# N.B. It's important we use pathlib.Path.rglob (recursive) here, since pants v2 prefixes dist dirs
# with their address namespace.
b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dir_bin():\n return abspath('bin')",
"def _search_path_to_file(self, directory, binary_name):\n for root, dirs, files in os.walk(directory):\n if binary_name in files:\n return os.path.join(root, binary_name)\n raise micp_kernel.NoExecutableError",
"def _extract_a... | [
"0.57858336",
"0.5713639",
"0.5676852",
"0.5615714",
"0.5572907",
"0.541237",
"0.53744745",
"0.5344345",
"0.5302235",
"0.5284864",
"0.52758974",
"0.52424115",
"0.51901644",
"0.5142074",
"0.51340926",
"0.5104739",
"0.50982463",
"0.50942296",
"0.50817",
"0.50708187",
"0.5032798... | 0.65847987 | 0 |
Creates an Accordion widget and yields under care of its output capturer. | def _accordion_widget(self, title, height='300px', collapsed=True):
# Generate unique class for multiple invocations
unique_class = self._append_random_id('nb-console-output')
auto_scroll_script = '''
const config = { childList: true, subtree: true };
const callback = function(mutationsList, observe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_accordion(summary, main):\n return \"\"\"\n <details>\n <summary>{}</summary>\n <main>{}</main>\n </details>\n \"\"\".format(summary, main)",
"def render_accordion(request, course, chapter, section, field_data_cache):\r\n # grab the table ... | [
"0.5763516",
"0.5742236",
"0.53615534",
"0.50737333",
"0.50410753",
"0.5024527",
"0.49162087",
"0.4911946",
"0.48652512",
"0.47383875",
"0.45927936",
"0.44744775",
"0.44410545",
"0.44230998",
"0.43919158",
"0.4383531",
"0.43767828",
"0.43757036",
"0.4363259",
"0.4358932",
"0.... | 0.72215044 | 0 |
Bootstraps a pex with widget UI display. | def _bootstrap_pex(self, pex_path: pathlib.PosixPath):
title = f'[Bootstrap] {pex_path.name}'
with self._accordion_widget(title) as (expand, collapse, set_output_glyph):
try:
with environment_as(PEX_VERBOSE='2'):
# Scrub the environment.
_scrub_import_environment(self._ORIGINAT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bootstrap():\n Bootstrap()",
"def bootstrap(self):\n None",
"def create_widgets(self):",
"def _do_bootstrap(self, configs=None):\n pass",
"def create_widgets( self ):",
"def widgets(self):\r\n self.setWindowTitle(\"PyCrypt\")\r\n self.setMinimumSize(QSize(500, 5... | [
"0.63333535",
"0.5799136",
"0.5798117",
"0.57466966",
"0.57229584",
"0.5599561",
"0.5393727",
"0.5355387",
"0.5324116",
"0.5302776",
"0.52597296",
"0.5256661",
"0.5252348",
"0.52225083",
"0.522084",
"0.521721",
"0.51877075",
"0.5168642",
"0.5132846",
"0.51302344",
"0.51216316... | 0.61450976 | 1 |
Validates a given or stored path is a valid pants repo. | def _validate_pants_repo(self, pants_repo: pathlib.PosixPath) -> bool:
return (
pants_repo and
pants_repo.is_dir() and
pants_repo.joinpath('pants').is_file()
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ValidateRepoPath(context, parameter, value):\n if value.startswith('/TEST/'):\n # Hackish command to allow for unit testing\n return value\n\n for name in ['BUILD.gn', '.gn', os.path.join('scripts', 'bootstrap.sh')]:\n expected_file = os.path.join(value, name)\n if not os.path... | [
"0.6693658",
"0.64390516",
"0.6414603",
"0.6258947",
"0.62280005",
"0.6122691",
"0.6122691",
"0.61224514",
"0.60444325",
"0.5846379",
"0.5826569",
"0.58253604",
"0.5780301",
"0.57039803",
"0.57003903",
"0.5675232",
"0.5675232",
"0.5665029",
"0.5649705",
"0.56372535",
"0.56351... | 0.77448916 | 0 |
Updates the important game information for each round of play. In this case, that means the puzzle is revealed and the jumper is cut if necessary. | def _do_updates(self):
is_right = self._puzzle.is_guess_right()
if is_right:
self._puzzle.reveal_puzzle()
else:
self._jumper.cut_line() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game_updated(self):\n # <<-- Creer-Merge: game-updated -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.\n game = self.game\n\n for x in range(game.board_width):\n for y in range(game.board_height):\n self.checke... | [
"0.6821897",
"0.65869373",
"0.6301358",
"0.6244406",
"0.6205162",
"0.61089224",
"0.60870314",
"0.6009552",
"0.59923613",
"0.59637344",
"0.5959768",
"0.59509295",
"0.5935243",
"0.59325224",
"0.59208655",
"0.5909505",
"0.59034586",
"0.5883476",
"0.5867642",
"0.58632934",
"0.586... | 0.69500154 | 0 |
Outputs the important game information for each round of play. In this case, that means the hider provides a hint. | def _do_outputs(self):
self._puzzle.display_revealed_puzzle()
hint = self._puzzle.get_hint()
self._console.write(hint)
print("")
self._jumper.draw_jumper()
print("")
# These ifs end the game
if self._puzzle.is_solved():
self._keep_playing = Fa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def info():\n print(\"Made using the OOP RPG game creator (c) Claire.\\n\")",
"def player_tie(self):\r\n\r\n self.summary = (\" \"* 78) + \"TIE. TRY AGAIN\"\r\n print(\"Match ends in a draw.\\n\")",
"def print_statistics(self):\n print 'Ran %s iterations in %0.3f seconds\\n' % (\n ... | [
"0.66959804",
"0.662896",
"0.661329",
"0.65989345",
"0.6507802",
"0.64726734",
"0.6438309",
"0.6436374",
"0.63636094",
"0.6347345",
"0.6319752",
"0.6309312",
"0.6309008",
"0.62329",
"0.6201972",
"0.6197924",
"0.618897",
"0.6177045",
"0.617191",
"0.6145641",
"0.61397576",
"0... | 0.66408557 | 1 |
If trainable, returns variable, otherwise the original embedding | def embedding_setup(self, embedding, emb_trainable):
if emb_trainable == True:
emb_variable = tf.get_variable(
name="embedding_matrix", shape=embedding.shape,
initializer = tf.constant_initializer(embedding))
return emb_variable
else:
return embedding | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def embedding_trainable_variables(self) -> Sequence[tf.Variable]:\n return self._embedding_layer.trainable_variables",
"def forward(self, input_variable):\r\n return self.embedding(input_variable)",
"def embedding_layer(self):\n with tf.name_scope(\"Embedding_Layer\"):\n V_size = le... | [
"0.7058622",
"0.702349",
"0.6737134",
"0.66756374",
"0.665749",
"0.6568265",
"0.65501094",
"0.6522559",
"0.6482883",
"0.64559466",
"0.64411855",
"0.64393085",
"0.6317404",
"0.630891",
"0.62915754",
"0.62392634",
"0.62351906",
"0.62319773",
"0.6220624",
"0.6140934",
"0.6062287... | 0.7045865 | 1 |
Looks if the received block is in the waiting list. If yes we check if the address is already recorded. If no it is added to the waiting list and broadcasted. | def arrivingBlock(self,data, addr, receivedBlock):
if self.blockchain.waiting_blocks == []:
self.confirmed.clear()
self.neighboursOk.clear()
self.confirmed.append(addr)
self.blockchain.putting_block(receivedBlock)
self.message = self.setMessa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_call_waiting(self) -> bool:",
"def BlockheightCheck(self):\n if self.CurrentBlockheight == BC.Default().Height:\n if len(self.Peers) > 0:\n logger.debug(\"Blockheight is not advancing ...\")\n next_hash = BC.Default().GetHeaderHash(self.CurrentBlockheight + ... | [
"0.5706097",
"0.5541932",
"0.5535595",
"0.55307394",
"0.5490348",
"0.5457724",
"0.5444099",
"0.54275596",
"0.542084",
"0.54196537",
"0.5404514",
"0.53694296",
"0.53550977",
"0.5339095",
"0.5308351",
"0.5284784",
"0.5277014",
"0.52734613",
"0.526288",
"0.52274597",
"0.5192736"... | 0.614878 | 0 |
Test that a new DynamicCadence is created by form submission | def test_create_cadence_for_new_site(self):
new_form_data = {
'site': 'cpt',
'cadence_frequency': 10,
'target_id': self.target.id
}
original_dc_count = DynamicCadence.objects.all().count()
response = self.client.post(reverse('nres_calibrations:nres_sub... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_submit_calibration_valid(self):\n new_form_data = {\n 'site': 'tlv',\n 'cadence_frequency': 2, # new cadence_frequency\n 'target_id': self.target.id\n }\n response = self.client.post(reverse('nres_calibrations:nres_submission'),\n ... | [
"0.70193005",
"0.6708431",
"0.66458005",
"0.6469265",
"0.64464295",
"0.6391832",
"0.6252196",
"0.62489915",
"0.6191535",
"0.6154543",
"0.6122482",
"0.6101032",
"0.60874194",
"0.6073931",
"0.604443",
"0.6040367",
"0.6038633",
"0.6028261",
"0.6002224",
"0.59992266",
"0.5994009"... | 0.7397608 | 0 |
Test that the nres_home target list contains the NRES calibration targets | def test_nres_targets_list(self):
response = self.client.get(reverse('nres_calibrations:nres_home'))
self.assertContains(response, self.target.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_which_targets():\n num_multi_targets = 0\n for which_targets_day in which_targets:\n # All inputs have a label\n assert np.all(which_targets_day.sum(axis=1) > 0)\n # No inputs have more than 3 targets\n assert np.all(which_targets_day.sum(axis=1) < 4)\n\n num_multi... | [
"0.58674073",
"0.5667292",
"0.5577143",
"0.5518126",
"0.54473",
"0.54211724",
"0.5411076",
"0.5409779",
"0.54086864",
"0.53584373",
"0.53370976",
"0.531879",
"0.52858996",
"0.52696484",
"0.52417976",
"0.52324855",
"0.5231467",
"0.51975954",
"0.51834714",
"0.5156341",
"0.51380... | 0.7668798 | 0 |
Test that the NRES Cadence list contains the ObservationGroup name of the DynamicCadence | def test_nres_cadence_list(self):
response = self.client.get(reverse('nres_calibrations:nres_home'))
self.assertContains(response, self.observation_group_name) # should appear in History column | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_ca_groups(self, admin_dashboard):\n ca_tab = admin_dashboard.select_custom_attributes()\n expected_ca_groups_set = set(\n [objects.get_normal_form(item) for item in objects.ALL_CA_OBJS])\n actual_ca_groups_set = set(\n [item.text for item in ca_tab.get_items_list()])\n asse... | [
"0.51378435",
"0.502584",
"0.50022244",
"0.49259534",
"0.48699087",
"0.48539323",
"0.48403198",
"0.4828131",
"0.48271948",
"0.48038292",
"0.47950238",
"0.47871473",
"0.4785799",
"0.4756255",
"0.47553796",
"0.47491336",
"0.4746582",
"0.4743038",
"0.47408164",
"0.47399324",
"0.... | 0.6860291 | 0 |
Gets user input such as the localhost and the similarity value for the comparision. Reads all the ringsugars in the given database and and creates a data frame with aglycons, their coconut_id and taxonomy. The biological names are delete and if there are two different taxonomies for an aglycon, the taxonomy is called '... | def complete_databank(port="localhost:27017",coconut_database="COCONUT2020-10",sweetcoconut_database="sweetcoconut"):
client = MongoClient(port)
db_complete = client[coconut_database]
collection = db_complete.uniqueNaturalProduct
db_complete_only_ring_sugars = pd.DataFrame(list(collection.find({"contain... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sweetcoconut_databank(df_tax_id_fromCompleteDatabank, taxonomy_Double,sweetcoconut_database,port):\n client2 = MongoClient(port)\n db_s = client2[sweetcoconut_database]\n collection2 = db_s.sweetNaturalProduct\n sweetnp = pd.DataFrame(list(collection2.find({\"contains_sugar\": True})))\n sweetnp... | [
"0.58430374",
"0.5564186",
"0.54623526",
"0.5419678",
"0.5353768",
"0.5343155",
"0.5265147",
"0.5263287",
"0.5258324",
"0.52520347",
"0.5207315",
"0.51895225",
"0.51715577",
"0.51707095",
"0.5153093",
"0.51300794",
"0.50969017",
"0.5094018",
"0.5078065",
"0.50657225",
"0.5031... | 0.652284 | 0 |
Gets the created data frame with the three columns aglycon, coconut id and taxonomy Merges sweetcocunt data frame with incoming data frame via their coconut id. Replaces nan with "no" if there isn't a known taxonomy in the row for the aglycon. Summarize all aglycons with the same structure into one row. Writes a .pkl f... | def sweetcoconut_databank(df_tax_id_fromCompleteDatabank, taxonomy_Double,sweetcoconut_database,port):
client2 = MongoClient(port)
db_s = client2[sweetcoconut_database]
collection2 = db_s.sweetNaturalProduct
sweetnp = pd.DataFrame(list(collection2.find({"contains_sugar": True})))
sweetnp_with_tax = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reduce_and_save():\n ### Get the signature information\n sig_info = pd.read_csv(join(FILE_PATH, \"GSE92742_Broad_LINCS_sig_info.txt\"), sep=\"\\t\")\n ### Columns are:\n ### Index([u'sig_id', u'pert_id', u'pert_iname', u'pert_type', u'cell_id',\n ### u'pert_dose', u'pert_dose_unit', u'per... | [
"0.615126",
"0.5918436",
"0.5613667",
"0.55950755",
"0.5493555",
"0.5440564",
"0.53833544",
"0.53545773",
"0.53458494",
"0.53149766",
"0.5311221",
"0.5273746",
"0.526471",
"0.5234631",
"0.5224225",
"0.52036613",
"0.5177393",
"0.5147963",
"0.5131519",
"0.5126816",
"0.51184547"... | 0.6074063 | 1 |
Gets a data frame with all the same aglycon structures in one row. Counts all taxonomies and create a barplot. 'Double' is also a taxonomy. Saves the bar plot with the numbers of different taxonomies as .png. | def bar_plot(df_NP):
cnt = Counter()
for tax_list in df_NP.taxonomy:
for tax in list(tax_list):
if tax != 'no':
cnt[tax] += 1
plt.bar(cnt.keys(),cnt.values())
plt.xlabel('taxonomic provenance')
plt.ylabel('number of molecules')
plt.title('number of aglycons wi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eda_plot():\n\n df1 = pd.read_csv('eda_malware.csv')\n df2 = pd.read_csv('eda_random.csv')\n df3 = pd.read_csv('eda_popular.csv')\n\n df = pd.concat([df1, df2, df3], ignore_index=True)\n df['label'].replace([0,1],['Benign','Malware'],inplace=True)\n\n colors = ['#EAB6AB','#D9E6F3','#CBAACB','... | [
"0.670801",
"0.6379678",
"0.62803435",
"0.62481606",
"0.621397",
"0.6171354",
"0.614709",
"0.612319",
"0.6084341",
"0.604334",
"0.6034777",
"0.5924511",
"0.5897462",
"0.5889659",
"0.5855359",
"0.58464646",
"0.58460945",
"0.57800704",
"0.57795185",
"0.57522184",
"0.572955",
... | 0.7676816 | 0 |
Gets a data frame with all the same aglycon structures in one row. Counts all taxonomies and creates a venn diagram with the four taxonomies plants, bacteria, animals, fungi. Reads the original taxonmies of the 'Double' entries. Saves a venndiagram of the different taxonmies as .png. | def venn_diagram(df_NP, taxonomy_Double):
taxonomy_Single = [list(tax) for tax in df_NP.taxonomy if 'double' not in tax]
taxonomy_All = taxonomy_Single + taxonomy_Double
plants = set()
bacteria = set()
animals = set()
fungi = set()
for tax_list in taxonomy_All:
if "plants" in tax_lis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eda_plot():\n\n df1 = pd.read_csv('eda_malware.csv')\n df2 = pd.read_csv('eda_random.csv')\n df3 = pd.read_csv('eda_popular.csv')\n\n df = pd.concat([df1, df2, df3], ignore_index=True)\n df['label'].replace([0,1],['Benign','Malware'],inplace=True)\n\n colors = ['#EAB6AB','#D9E6F3','#CBAACB','... | [
"0.61547685",
"0.5806181",
"0.5550293",
"0.5549266",
"0.5513179",
"0.54985404",
"0.5479837",
"0.54608345",
"0.54200816",
"0.54113746",
"0.5385822",
"0.5380591",
"0.53727204",
"0.53407085",
"0.5332196",
"0.5309217",
"0.5293119",
"0.5277534",
"0.526739",
"0.52268946",
"0.520937... | 0.7490416 | 0 |
Gets a data frame with all the same aglycon structures in one row. Deletes all rows with more than one entry in the taxonomy row. Passes a data frame with only one entry (superkingdom or 'no') in the taxonomy row. | def aglycon_single_tax(df_NP):
# **seperate aglycons with at least two different entries in taxonomy**
index_Unique_Tax = [ind for ind, tax_list in enumerate(df_NP.taxonomy) if len(tax_list) == 1]
df_Without_Double = df_NP.iloc[index_Unique_Tax[:]]
#df_Without_Double
# **check for 'double' or 'tripl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(df):",
"def gb_cleaner(df):\n df['tag'] = df.tags.apply(retagger)\n \n c_list = df.text.tolist()\n\n clean_corpus = []\n for docs in c_list:\n clean_corpus.append(data_cleaner(docs))\n \n df['clean'] = clean_corpus\n\n df = df.drop(['text', 'tags', 'stars'], axis= 1)\n ... | [
"0.5444545",
"0.5277261",
"0.52311677",
"0.5200804",
"0.51652235",
"0.51347816",
"0.51267016",
"0.51248044",
"0.50985575",
"0.5084206",
"0.50411373",
"0.5032984",
"0.5006409",
"0.49748224",
"0.49653932",
"0.48951414",
"0.48935908",
"0.48864013",
"0.4885388",
"0.48809195",
"0.... | 0.5743044 | 0 |
Draw a histogram given the graph. | def draw_histogram(graph: Graph) -> Optional[Graph]:
if not graph:
return None
try:
# generate and open a new figure
figure, ax = plt.subplots()
# When graph.x or y is str, the histogram is ill-defined.
ax.barh(graph.y, graph.x, color=graph.color)
ax.set_title(graph.title)
if graph.xlabe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_histogram(xx, hist_ax, alpha=1.0, colorV=None, facecolor='#80D080', edgecolor=None, nbins=75,\n fontsize=8, linewidth=1, xlabel=None, ylabel=None, label=None):\n plt.sca(hist_ax)\n if colorV is None:\n n, bins, patches = hist_ax.hist(xx, nbins, histtype='stepfilled', alpha=a... | [
"0.6689416",
"0.65681064",
"0.6548414",
"0.6526117",
"0.64784855",
"0.6347681",
"0.62804496",
"0.6251401",
"0.62138206",
"0.62123525",
"0.6209556",
"0.62087065",
"0.6201147",
"0.6197796",
"0.61838293",
"0.61743563",
"0.6154292",
"0.61535",
"0.61413497",
"0.61310756",
"0.61112... | 0.74443585 | 0 |
Converts a Matplotlib figure to a base64 string encoding. | def figure_to_base64str(fig: matplotlib.figure.Figure) -> str:
buf = io.BytesIO()
fig.savefig(buf, bbox_inches='tight', format='png')
return base64.b64encode(buf.getbuffer().tobytes()).decode('ascii') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot2uri(figure):\n image = io.BytesIO()\n figure.savefig(image, format=\"png\")\n image.seek((0))\n string = base64.b64encode(image.read())\n uri = urllib.parse.quote(string)\n\n return uri",
"def base64(self):\n image = self.png.getvalue()\n return base64.encodestring(image)... | [
"0.7147997",
"0.68165886",
"0.6809981",
"0.6809981",
"0.6721276",
"0.6467986",
"0.6416611",
"0.64131576",
"0.6268338",
"0.62255985",
"0.6189878",
"0.6181082",
"0.5922518",
"0.5921818",
"0.5912652",
"0.5896791",
"0.5858558",
"0.5847519",
"0.5846032",
"0.58170253",
"0.5803382",... | 0.88419247 | 0 |
Get person's ID from mbank.tcredits (turnes DB) | def get_person_id(contract_num, phone):
exfin_connection = MySQLdb.connect(
host="10.10.100.27", # host of MySQL database
user="root", # user's username
passwd="Orraveza(99)", # your password
db="mbank", # nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_person_id_and_tel(contract_num):\n exfin_connection = MySQLdb.connect(\n host=\"10.10.100.27\", # host of MySQL database\n user=\"root\", # user's username\n passwd=\"Orraveza(99)\", # your password\n db=\"mbank\", ... | [
"0.6560628",
"0.6496635",
"0.6305405",
"0.62735915",
"0.6225594",
"0.6144446",
"0.60823274",
"0.5909578",
"0.5867553",
"0.5829623",
"0.5829623",
"0.5829623",
"0.5829623",
"0.5757211",
"0.57547575",
"0.57257414",
"0.5696543",
"0.56823105",
"0.56737465",
"0.56495553",
"0.564790... | 0.68747634 | 0 |
Get person's ID from mbank.tcredits (turnes DB) | def get_person_id_and_tel(contract_num):
exfin_connection = MySQLdb.connect(
host="10.10.100.27", # host of MySQL database
user="root", # user's username
passwd="Orraveza(99)", # your password
db="mbank", # na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_person_id(contract_num, phone):\n exfin_connection = MySQLdb.connect(\n host=\"10.10.100.27\", # host of MySQL database\n user=\"root\", # user's username\n passwd=\"Orraveza(99)\", # your password\n db=\"mbank\", ... | [
"0.68761975",
"0.6497191",
"0.63046885",
"0.6275422",
"0.62251246",
"0.61442626",
"0.6080249",
"0.59082514",
"0.58671093",
"0.58295715",
"0.58295715",
"0.58295715",
"0.58295715",
"0.5758327",
"0.5754676",
"0.5724665",
"0.56968856",
"0.56817",
"0.5672638",
"0.5647657",
"0.5647... | 0.65625286 | 1 |
Adapting numpy.int64 type to SQLconform int type using psycopg extension, see [1]_ for more info. | def adapt_numpy_int64(numpy_int64):
return AsIs(numpy_int64) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def castData(data, type='int64'):\n data = data.astype(type)\n return data",
"def cast_to_integer(array, attributes):\n atts = array.att_names\n\n for nm, typ, null in array.sdbtype.full_rep:\n if nm not in attributes:\n continue\n if 'int' in typ:\n continue\n ... | [
"0.6342146",
"0.62293154",
"0.6208453",
"0.5914053",
"0.5862272",
"0.5841508",
"0.5763204",
"0.5722632",
"0.57082486",
"0.5705555",
"0.5675615",
"0.5662397",
"0.565685",
"0.5637229",
"0.5554309",
"0.54482377",
"0.5430291",
"0.53955346",
"0.5389029",
"0.53852504",
"0.53627807"... | 0.7526429 | 0 |
Gets a dict of bestfit information from the database regarding the specified form factor. Also gets some "meta" information like the associated momentum, current, and lattice size. | def get_best_fit_information(engine, form_factor_id):
Nstates = collections.namedtuple(
'NStates', ['n', 'no', 'm', 'mo'], defaults=(1, 0, 0, 0)
)
def _float_or_none(astr):
if astr is None:
return None
if (astr.lower() == 'nan') or (astr.lower() == 'none'):
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_stats(trj_datasets, ff_form):\n\n stats_data = {}\n\n params = ff_form['hyperparams']\n stats_func = ff_func[ff_form['potential']]\n\n for key, trj in trj_datasets.items():\n \n stats_dict = {'energy':[]}\n \n for ii, (xyz, box) in enumerate(zip(trj['xyz'], trj['box'])):... | [
"0.5544596",
"0.54875684",
"0.5375364",
"0.5314797",
"0.5159251",
"0.51468754",
"0.51262325",
"0.5124719",
"0.50992376",
"0.5055376",
"0.5029532",
"0.5029249",
"0.49983555",
"0.4981368",
"0.4980224",
"0.49532855",
"0.49397266",
"0.4906085",
"0.48953032",
"0.48906365",
"0.4883... | 0.75372094 | 0 |
Locates rows in which NaNs appear. | def locate_nan_rows(arr):
# Count the number of NaNs in each row
nan_counts = np.sum(~np.isfinite(arr), axis=1)
# Trigger on a NaN appearing anywhere in a line/row
nans, = np.where(nan_counts > 1)
return frozenset(nans) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _nan_cells(traces):\n # Find all cells with NaNs\n nancells = []\n ncells = -1\n for cs in traces:\n if len(traces[cs]) > 0:\n ncells = np.shape(traces[cs])[1]\n ns = np.sum(np.sum(np.invert(np.isfinite(\n traces[cs])), axis=2), axis=0)\n vals ... | [
"0.692097",
"0.6758517",
"0.6730393",
"0.66897637",
"0.6636106",
"0.65987986",
"0.6463813",
"0.6380045",
"0.6338059",
"0.6218934",
"0.62157136",
"0.6210175",
"0.61391306",
"0.61234987",
"0.61117244",
"0.6083047",
"0.60659695",
"0.60418135",
"0.60125595",
"0.60119325",
"0.6011... | 0.82622176 | 0 |
Sanitizes the dict 'record' for writing to 'table', i.e., restricts to keys which appear as columns of table. | def sanitize_record(record, table):
try:
columns = table.columns
except AttributeError:
columns = vars(table)
return {key: value for key, value in record.items() if key in columns} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sanitise_fields(self, record):\n sanitised = {}\n for k, v in record.items():\n new_key = k.replace('(', '_').replace(')', '_')\n sanitised[new_key] = v\n return sanitised",
"def clean_record(self):\n _dict = {\n key: value for (key, value) in sel... | [
"0.7768705",
"0.65373653",
"0.62795115",
"0.60765547",
"0.6009481",
"0.59517825",
"0.5927419",
"0.5893116",
"0.5849048",
"0.584391",
"0.5767355",
"0.57646644",
"0.57419175",
"0.5702649",
"0.5685503",
"0.5644447",
"0.55450684",
"0.54949075",
"0.54631734",
"0.54530233",
"0.5444... | 0.8198284 | 0 |
Parse a string representation of a dictionary, e.g., | def parse_string_dict(dict_as_string):
new_dict = ast.literal_eval(dict_as_string[1:-1])
new_dict = {key: parse_string(val) for key, val in new_dict.items()}
return new_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_dict(txt):\n pairs = txt[txt.index('{')+1:txt.rindex('}')].split(',') # need to inplement a correct split by comma\n d = {}\n for p in pairs:\n if p:\n splt = p.split(':')\n key = splt[0].strip()\n value = splt[1].strip()\n if value[0] == '{':\n... | [
"0.6813349",
"0.67471504",
"0.65554583",
"0.6505521",
"0.6483303",
"0.6417136",
"0.63636893",
"0.629334",
"0.6261636",
"0.62039405",
"0.6178307",
"0.6155987",
"0.6088658",
"0.6058405",
"0.60359",
"0.60221696",
"0.5994995",
"0.5986573",
"0.59692",
"0.5951037",
"0.59507596",
... | 0.79582787 | 0 |
Parse a string representation of an array of gvars into an array of gvars. This operation arises frequently, for example, when reading from the various "glance" tables, which store preprocessed data. | def parse_string(str_arr):
def to_arr(str_arr):
""" Switch to list. """
row = str_arr.replace(']', '').\
replace('[', '').\
replace('{', '').\
replace('}', '').\
replace('\n', '').split()
if '+-' in row:
row = kludge_gvars(row)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(arr_str):\n return arr_str.rstrip().replace(' ', '').split(',')[:-1]",
"def convert_strings_to_array(strings):\n row_strings = strings.split(\"\\n\")\n new_array = np.array([[float(i) for i in row_string.split(\",\")] for row_string in row_strings])\n shape = new_array.shape\n if shape[1... | [
"0.63184726",
"0.5962173",
"0.5946905",
"0.593627",
"0.59265995",
"0.5860213",
"0.579188",
"0.56896275",
"0.5681272",
"0.5645227",
"0.5643714",
"0.56135464",
"0.5585567",
"0.5552104",
"0.5551407",
"0.5538226",
"0.5523727",
"0.5477755",
"0.5459959",
"0.5417494",
"0.5411672",
... | 0.79506093 | 0 |
Occasionally, gvars get rendered to strings as, e.g., 4e06 + 1 instead of 0.000006(1.0). This makes a complete mess of trying to parse the a list of gvar which has been turned into a string, e.g., '[1(2) 1 + 2 0.003(2)]', since the usual str.split() separates '1 + 2' > ['1','+','2']. This function is a kludge which wor... | def kludge_gvars(mangled):
# Loop in reverse looking for '+-', but don't run off the end
for idx in range(len(mangled) - 1)[::-1]:
if mangled[idx + 1] == '+-':
reunited = ' '.join(mangled[idx:idx + 3])
# Throw away the used elements...
for _ in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_string(str_arr):\n def to_arr(str_arr):\n \"\"\" Switch to list. \"\"\"\n row = str_arr.replace(']', '').\\\n replace('[', '').\\\n replace('{', '').\\\n replace('}', '').\\\n replace('\\n', '').split()\n\n if '+-' in row:\n r... | [
"0.73184675",
"0.5792925",
"0.56992584",
"0.56166935",
"0.5463357",
"0.53742534",
"0.5349036",
"0.53430367",
"0.5340777",
"0.5338637",
"0.53287876",
"0.5321281",
"0.531979",
"0.5301091",
"0.5295797",
"0.5219765",
"0.5208033",
"0.516347",
"0.51579887",
"0.5147878",
"0.51474804... | 0.6465308 | 1 |
Upsert the content of a DataFrame into a db table | def upsert(engine, table_name, dataframe):
# Reflect table from db
metadata = sqla.MetaData(bind=engine)
table = sqla.Table(
table_name,
metadata,
autoload=True,
autoload_with=engine)
# Unpackage DataFrame
records = []
for _, row in dataframe.iterrows():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_data(df, database, table, db_uri):\n try:\n engine = sqlalchemy.create_engine(db_uri)\n df = create_hash_id(df)\n\n def create_insert_sql(x):\n cols = \"`\" + \"`,`\".join(list(df.columns)) + \"`\"\n values = \"\\'\" + \"\\',\\'\".joi... | [
"0.72344434",
"0.71951675",
"0.715494",
"0.7140779",
"0.70340526",
"0.7006468",
"0.6899513",
"0.6865268",
"0.6854902",
"0.68426687",
"0.67907673",
"0.6712339",
"0.6708589",
"0.670759",
"0.67042094",
"0.66936225",
"0.6693597",
"0.66493917",
"0.6645235",
"0.659",
"0.657526",
... | 0.7500038 | 0 |
Writes the dictionary 'src' to the table named 'table_name'. | def write(engine, table_name, src, return_id=True, do_update=False):
query = build_upsert_query(engine, table_name, src, do_update=do_update)
LOGGER.debug(query)
engine.execute(query)
if return_id:
return fetch_id(engine, table_name, src) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_table(source_table, destination_table, db='default'):\n try:\n with connections[db].cursor() as cursor:\n cursor.execute('CREATE TABLE IF NOT EXISTS %s LIKE %s;' % (destination_table, source_table))\n except:\n pass",
"def _schema_write(self, table: Tab... | [
"0.59626514",
"0.5931484",
"0.5827578",
"0.5823976",
"0.57344264",
"0.57290435",
"0.56961876",
"0.5692005",
"0.56391126",
"0.56303656",
"0.5589605",
"0.5557386",
"0.55331343",
"0.5516523",
"0.55136675",
"0.5495206",
"0.54833347",
"0.5448401",
"0.54384375",
"0.5437824",
"0.539... | 0.62851363 | 0 |
Gets the unique columns from the table's contraints. | def get_unique_columns(table):
for constraint in table.constraints:
if isinstance(constraint, sqla.UniqueConstraint):
return constraint.columns
# We should never get this far.
# All tables in my db should have unique constraints
assert False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_cols(self):\n return list(set([coord[1] for coord in self.landscape]))",
"def get_attr_cols(self):\n all_cols = np.arange(self.col_count)\n attr_cols = np.setdiff1d(all_cols, self.time_cols)\n return attr_cols",
"def constraints(self):\n ans = self.execute(self.com... | [
"0.65937907",
"0.6296229",
"0.6262106",
"0.62196285",
"0.61645097",
"0.6027742",
"0.6019557",
"0.5972942",
"0.59648323",
"0.59523666",
"0.5932074",
"0.59089965",
"0.5894359",
"0.5856457",
"0.58301574",
"0.5824588",
"0.5823334",
"0.5823334",
"0.5815539",
"0.5815517",
"0.580525... | 0.85034263 | 0 |
Builds a raw SQL query for "upserting" data into the database. | def build_upsert_query(engine, table_name, src_dict, do_update=False):
def _for_pgsql(value, dtype):
"""
Converts a python datatype to the appropriate string (including, e.g., \
the necessary single quotes and/or brackets ) for use in a raw \
postgresql query.
Args:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_upsert_sql(mon_loc):\n mon_loc_db = [(k, _manipulate_values(v, k in TIME_COLUMNS)) for k, v in mon_loc.items()]\n all_columns = ','.join(col for (col, _) in mon_loc_db)\n all_values = ','.join(value for (_, value) in mon_loc_db)\n update_query = ','.join(f\"{k}={v}\" for (k, v) in mon_loc... | [
"0.6856745",
"0.62934977",
"0.6097199",
"0.6094336",
"0.6082441",
"0.6049717",
"0.59614617",
"0.5931908",
"0.5901273",
"0.57127017",
"0.56941617",
"0.56601083",
"0.56386846",
"0.557427",
"0.55658185",
"0.55294424",
"0.5524274",
"0.5510159",
"0.5497966",
"0.54956716",
"0.54865... | 0.72920215 | 0 |
Converts a python datatype to the appropriate string (including, e.g., \ the necessary single quotes and/or brackets ) for use in a raw \ postgresql query. | def _for_pgsql(value, dtype):
if dtype.startswith(('int', 'float', 'double', 'numeric')):
if value is None:
return "Null"
elif str(value).lower() == 'nan':
return "'nan'"
elif dtype.endswith('[]'):
value = ', '.join([str(v) for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def typecast(dtype: Any) -> str:\n if dtype is int:\n return \"Int64\"\n elif dtype is float:\n return \"Float64\"\n elif dtype is bool:\n return \"bool\"\n return \"string\"",
"def escapeinput_data_for_sql(self, value, sql_type):\n\t\t# print value\n\... | [
"0.72594017",
"0.7176732",
"0.70983726",
"0.701285",
"0.7011267",
"0.69050854",
"0.6897729",
"0.6891294",
"0.66907203",
"0.65747005",
"0.65560377",
"0.6526946",
"0.6434319",
"0.6389201",
"0.6378415",
"0.6377122",
"0.6342456",
"0.6311862",
"0.62993383",
"0.6254328",
"0.6250282... | 0.7943686 | 0 |
Gets a list of "set pairs" for use in a raw SQL query, e.g., INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...) ON CONFLOCT (column1) DO UPDATE SET column1=value1, column2=value2 This function returns a string "column1=value1, column=value2 | def _get_set_pairs(uprow, types):
pairs = []
for key, val in uprow.items():
pairs.append("{0}={1}".format(key, _for_pgsql(val, types[key])))
return ", ".join(pairs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_sql_update_set_formatted_string(keys_list: List[str]):\n\n return \", \".join([f\"{key} = :{key}\" for key in keys_list])",
"def sql_filtered_insert(table, set_columns, values):\n for index in range(len(set_columns) - 1, -1, -1):\n if values[index] is None:\n del set_columns[... | [
"0.60592306",
"0.5937135",
"0.5752619",
"0.55114925",
"0.5503095",
"0.5496429",
"0.546202",
"0.5449382",
"0.5340713",
"0.5311094",
"0.5305011",
"0.52147573",
"0.51948994",
"0.5189435",
"0.51842463",
"0.5181503",
"0.51571256",
"0.5146145",
"0.51329595",
"0.5124207",
"0.5090333... | 0.7233016 | 0 |
Fetches a list of correlators matching the specified form factor. | def fetch_basenames(engine, form_factor):
for key in ['current', 'm_mother', 'm_daughter', 'm_spectator', 'momentum']:
if key not in form_factor:
raise KeyError(f"Required key '{key}' is missing.")
def abspath(dirname):
return os.path.join(pathlib.Path(__file__).parent.absolute(), d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_corr_ids(engine, basename):\n query = (\n \"SELECT id AS correlator_id \"\n \"FROM correlators \"\n f\"WHERE name LIKE '{basename}%%';\")\n corr_ids = pd.read_sql_query(query, engine)['correlator_id']\n return corr_ids",
"def _all_word_forms(self):\n all_word_forms = ... | [
"0.5065303",
"0.49833453",
"0.48512962",
"0.48390126",
"0.47684383",
"0.47402024",
"0.47051248",
"0.46746743",
"0.46732098",
"0.46706173",
"0.46581146",
"0.4630977",
"0.46242094",
"0.461068",
"0.46085858",
"0.46028313",
"0.46000963",
"0.45869887",
"0.4582591",
"0.45775443",
"... | 0.5916252 | 0 |
Gets an alias for a quark mass (e.g., '1.0 m_light') from a table. | def get_alias(a_fm, description, quark_mass):
quark = conventions.quark_masses
mask = utils.bundle_mask(quark, a_fm=a_fm, description=description, mq=quark_mass)
return utils.extract_unique(quark[mask], 'alias') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _masses_string(self):\n return_str = 'Masses\\n\\n'\n for at in self.atom_types:\n return_str += '{} {:9.5f} # {}\\n'.format( at.atom_type_index, float(at.mass), at.label)\n return_str += '\\n'\n return return_str",
"def loc_massmet(mass):\n return np.interp(mass, ma... | [
"0.52080846",
"0.50464433",
"0.49144888",
"0.48627576",
"0.48407552",
"0.4818113",
"0.48110572",
"0.47752094",
"0.47583362",
"0.47391355",
"0.47382006",
"0.47375157",
"0.47296125",
"0.47048503",
"0.46953273",
"0.4686729",
"0.4680874",
"0.46636742",
"0.4646696",
"0.46301967",
... | 0.65231496 | 0 |
Test that variant libraries load and initialize. | def test_load_variant(variant):
try:
f = fvs.FVS(variant)
except ImportError:
pytest.skip('No variant library: {}'.format(variant))
return None
except:
raise
assert f.variant == variant
assert not f.fvslib is None
f = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_load_libs(self):\n script = 'var %s = {foo: \"foo\"};' % _global\n\n with js_file(script) as path:\n utils.load_libs([path])\n\n self.assertEqual('foo', utils.run_script('%s.foo' % _global))\n self.assertEqual('true', utils.run_script('delete %s.foo' % _global))",
... | [
"0.63410246",
"0.6289428",
"0.60788304",
"0.6077451",
"0.60713",
"0.6050606",
"0.6022049",
"0.5979783",
"0.59417397",
"0.59394777",
"0.589408",
"0.589276",
"0.58614826",
"0.583448",
"0.58229786",
"0.58219177",
"0.5816688",
"0.5816469",
"0.57959235",
"0.57952666",
"0.57904017"... | 0.7319842 | 0 |
Set a new sudoku matrix with new matrix | def set_sudoku_matrix(self, matrix):
self.sudoku_matrix = matrix | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_sudoku(size):\r\n def mutate_list_1(lst, size):\r\n \"\"\"Helper function for removing part of a list from the beginning and add it to the end.\"\"\"\r\n count = 0\r\n while count < size:\r\n elem = lst[0]\r\n lst.remove(elem)\r\n lst.append(elem)\r... | [
"0.6697235",
"0.6546988",
"0.6452423",
"0.6357415",
"0.6334121",
"0.6234853",
"0.6204221",
"0.61754245",
"0.60981035",
"0.6080238",
"0.6060617",
"0.5981177",
"0.59771913",
"0.59540534",
"0.5935847",
"0.59132874",
"0.5873409",
"0.5855094",
"0.5833647",
"0.5826307",
"0.5797247"... | 0.75624293 | 0 |
Print the sudoku matrix in the console | def print_sudoku_matrix(self):
row_list = 'ABCDEFGHI'
print " 1 2 3 4 5 6 7 8 9 "
for i in range(9):
if i % 3 == 0:
print " +-------+-------+-------+"
var = row_list[i] + " "
for j in range(9):
if j % 3 == 0:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_sudoku_solution(solution):\n for row in range(9):\n for col in range(9):\n print solution['%d-%d' % (row, col)][0],\n if col == 2 or col == 5:\n print '|',\n print\n if row == 2 or row == 5:\n print '------+-------+------'",
"def p... | [
"0.76974213",
"0.7565851",
"0.742648",
"0.7263379",
"0.70990515",
"0.7066005",
"0.70275044",
"0.70215726",
"0.69965345",
"0.69322765",
"0.6923831",
"0.689935",
"0.68883264",
"0.6876396",
"0.6810913",
"0.678954",
"0.6756092",
"0.6743901",
"0.6702986",
"0.66843426",
"0.6683793"... | 0.8277411 | 0 |
Hide cell in the Sudoku Matrix | def hide_values_in_matrix(self, difficult):
row = random.randint(0, 8)
column = random.randint(0, 8)
if (difficult != 0):
self.sudoku_matrix[row][column].set_cell_visibility(True)
self.sudoku_matrix[row][column].set_cell_value(0)
self.hide_values_in_matrix(dif... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _hide_numbers(self):\n global counter\n\n # num of attempts allow for more blocks to be removed\n attempts = self._difficulty\n\n while attempts > 0:\n # selecting random cell and rotational counterpart\n row = randint(0, 8)\n col = randint(0, 8)\n ... | [
"0.65699524",
"0.64596504",
"0.6226179",
"0.6132422",
"0.6060004",
"0.5992399",
"0.59386015",
"0.58700484",
"0.5865002",
"0.5862993",
"0.58458006",
"0.5845631",
"0.5832931",
"0.5831914",
"0.58127666",
"0.57925963",
"0.5776719",
"0.57695794",
"0.5753077",
"0.5743643",
"0.57357... | 0.81077296 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.