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 |
|---|---|---|---|---|---|---|
Instantiate with the Pi and gpio to which the sensor is connected. | def __init__(self, pi, gpio):
self.pi = pi
self.gpio = gpio
self._start_tick = None
self._last_tick = None
self._low_ticks = 0
self._high_ticks = 0
pi.set_mode(gpio, pigpio.INPUT)
self._cb = pi.callback(gpio, pigpio.EITHER_EDGE, self._cbf) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_pi():\n global pi\n pi = modOrangePi.OrangePiOne()",
"def __init__(self):\n GPIO.setwarnings(False)\n GPIO.cleanup() # Reset the high and low levels of the GPIO port\n #The following code defines the GPIO used to control the L298N chip. This definition is different for differ... | [
"0.7157505",
"0.7084654",
"0.70404077",
"0.6880348",
"0.68294865",
"0.68004364",
"0.67805946",
"0.67064327",
"0.66922736",
"0.66071254",
"0.6603638",
"0.66022533",
"0.6582791",
"0.65667224",
"0.6541659",
"0.65408367",
"0.65235376",
"0.6501939",
"0.6480161",
"0.64743793",
"0.6... | 0.7198668 | 0 |
Calculates the percentage low pulse time and calibrated concentration in particles per 1/100th of a cubic foot since the last read. For proper calibration readings should be made over 30 second intervals. Returns a tuple of gpio, percentage, and concentration. | def read(self):
interval = self._low_ticks + self._high_ticks
if interval > 0:
ratio = float(self._low_ticks)/float(interval)*100.0
conc = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62;
else:
ratio = 0
conc = 0.0
self._start_tick = None
self._last_t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_servo_pct(pi, pin):\n return pulsewidth2pct(pi.get_servo_pulsewidth(pin))",
"def pulse_width_percent(self) -> float:",
"def _read_calibration_data(self):\n #Declare global variables.\n global calT1\n global calT2\n global calT3\n global calP1\n global calP2\... | [
"0.6391259",
"0.55923057",
"0.5536905",
"0.5487215",
"0.5478771",
"0.54635304",
"0.5459195",
"0.54591554",
"0.54579854",
"0.54572123",
"0.5377879",
"0.5315192",
"0.53110963",
"0.528621",
"0.5251018",
"0.5244876",
"0.5234616",
"0.52287734",
"0.52211034",
"0.5210247",
"0.520117... | 0.66794544 | 0 |
Convert concentration of PM2.5 particles per 0.01 cubic feet to ug/ metre cubed this method outlined by Drexel University students (2009) and is an approximation does not contain correction factors for humidity and rain | def pcs_to_ugm3(self, concentration_pcf):
if concentration_pcf < 0:
raise ValueError('Concentration cannot be a negative number')
# Assume all particles are spherical, with a density of 1.65E12 ug/m3
densitypm25 = 1.65 * math.pow(10, 12)
# Assume the... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pcs_to_ugm3(concentration_pcf):\n\n if concentration_pcf < 0:\n raise ValueError('Concentration cannot be a negative number')\n\n # Assume all particles are spherical, with a density of 1.65E12 ug/m3\n densitypm25 = 1.65 * math.pow(10, 12)\n\n # Assume the radius of a particle in the PM2.5 ... | [
"0.72812116",
"0.6710232",
"0.6445702",
"0.6202675",
"0.61451113",
"0.61373574",
"0.6093109",
"0.6075544",
"0.60333407",
"0.5979964",
"0.5971728",
"0.5960646",
"0.5960387",
"0.5955383",
"0.5954113",
"0.5920214",
"0.59088665",
"0.5883328",
"0.58557194",
"0.5840236",
"0.5838741... | 0.69339585 | 1 |
Parse command line args for `saml` module | def saml_args(subparsers: argparse.ArgumentParser) -> argparse.ArgumentParser:
example_usage = """example usage:
ticketsplease saml --adfs-config '...' --target-user-guid '...' --dkm-key '...' --assertion
ticketsplease saml --adfs-config-file config.bin --domain company.com --target-user tUser --domain-use... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_args():\n from argparse import ArgumentParser\n ap = ArgumentParser(prog=__exe__, description=__purpose__)\n ap.add_argument('session', help='Session Label')\n ap.add_argument('-sd', '--subjects_dir', help='Subjects Dir',\n default='/tmp')\n return ap.parse_args()",
"d... | [
"0.7090191",
"0.69268453",
"0.6795926",
"0.6786835",
"0.6571994",
"0.6458638",
"0.64371264",
"0.6427676",
"0.63967645",
"0.638476",
"0.6380541",
"0.637889",
"0.63538307",
"0.6335305",
"0.632227",
"0.6309462",
"0.63002795",
"0.62995756",
"0.62961483",
"0.6293663",
"0.6283503",... | 0.69307035 | 1 |
Test unitario que verifica que se guarda un socio de forma permanente | def test_guardar_socio(self):
con = ConexionSocio()
socio = Socio("49116666Q", "Don Juan", "Tenorio", "634824490", "daswirdaendern@jetzt.de")
con.guardar_socio(socio)
link = os.path.dirname(__file__)
link = link[:-5] + 'src/files/socios.csv'
tmp_file = open(link, 'r')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sacar_socio(self):\n con = ConexionSocio()\n socio = Socio(\"49116666Q\", \"Don Juan\", \"Tenorio\", \"634824490\", \"daswirdaendern@jetzt.de\")\n con.guardar_socio(socio)\n link = os.path.dirname(__file__)\n link = link[:-5] + 'src/files/socios.csv'\n tmp_file = ... | [
"0.6744489",
"0.66240126",
"0.6531882",
"0.6278651",
"0.6278651",
"0.61154157",
"0.61038077",
"0.60833657",
"0.6038469",
"0.5984626",
"0.5984338",
"0.596252",
"0.591274",
"0.59095997",
"0.5906191",
"0.5887979",
"0.5885842",
"0.58706224",
"0.58655715",
"0.58603054",
"0.5855142... | 0.7391387 | 0 |
Return a random alternative | def random_alternative(self, fmt_string):
# Find alternatives
try:
alts = self[fmt_string]
except KeyError:
# There are no alternatives for this string
return fmt_string
return random.choice(alts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def randomHelmet():\n return random.choice(HELMETS)",
"def random():\r\n return R.NextDouble()",
"def rs():\n return random.choice([-1,1])",
"def rs():\n return random.choice([-1,1])",
"def __call__(self):\n return random.choice(self.fakers)",
"def random():\n return constant(1)",
... | [
"0.72038704",
"0.7059211",
"0.70269835",
"0.70269835",
"0.68288124",
"0.679533",
"0.67832035",
"0.67832035",
"0.6728949",
"0.6724014",
"0.6668823",
"0.6668823",
"0.66581684",
"0.6654171",
"0.65952104",
"0.65869784",
"0.6532706",
"0.6525008",
"0.6479972",
"0.6478925",
"0.64749... | 0.7658681 | 0 |
Scan the alternatives directory and return dict | def read_files():
alts = Alternatives()
alt_dir = join(dirname(__file__), "alternatives")
fmt_str = "Retrieving alternative strings from file %s"
for dirpath, dirnames, filenames in walk(alt_dir, followlinks=True):
for filename in filenames:
if filename.lower().endswith(".json"):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recognize_languages_dir(directory: str) -> Dict[str, List[str]]:\n enry = get_enry()\n args = [enry, \"-json\", directory]\n res = subprocess.check_output(args)\n return json.loads(res)",
"def scan_dir(self, directory=\".\"):\n for root, dirs, files in os.walk(directory, topdown=False):\n ... | [
"0.60988235",
"0.5851258",
"0.5627173",
"0.56246066",
"0.56158876",
"0.5534256",
"0.55093044",
"0.54836005",
"0.5475982",
"0.54709464",
"0.5467215",
"0.54657656",
"0.54474604",
"0.5444949",
"0.5420799",
"0.5397485",
"0.5391387",
"0.53719014",
"0.5366439",
"0.53660506",
"0.535... | 0.66199005 | 0 |
Verifies the endpoint creates a new entry in the users_sensors_mobiles table | def test_create_sensor_mobile_pair():
headers['content-type'] = 'application/json'
# user_id = '3a07c79a-2e9f-487f-aef7-555954537e29' # Needs to match JWT token above
# user_id = '19bfad75-9d95-4fff-aec9-de4a93da214d'
user_id = 'e8514489-8de9-47e0-b3d5-b15da244783f'
sensor_mobile_info = {'sensor_pi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_device_registration_put_method_failure(flask_app, db): # pylint: disable=unused-argument\n\n request = create_registration(REQUEST_DATA, uuid.uuid4())\n headers = {'Content-Type': 'multipart/form-data'}\n modified_data = {'m_location': 'overseas', 'reg_id': request.id, 'user_id': USER_ID}\n r... | [
"0.5737035",
"0.5628522",
"0.56284237",
"0.5571442",
"0.5557598",
"0.5550344",
"0.55043447",
"0.5479529",
"0.54685986",
"0.545828",
"0.5451241",
"0.53942007",
"0.5381542",
"0.5365838",
"0.5358317",
"0.53446484",
"0.5340907",
"0.5340713",
"0.5340713",
"0.53316516",
"0.53222096... | 0.65191436 | 0 |
Creates listening sockets bound to the given port and address. Returns a list of socket objects (multiple sockets are returned if the given address maps to multiple IP addresses, which is most common for mixed IPv4 and IPv6 use). Address may be either an IP address or hostname. If it's a hostname, the server will liste... | def bind_sockets(port, address=None, family=socket.AF_UNSPEC,
backlog=_DEFAULT_BACKLOG, flags=None, reuse_port=False):
if reuse_port and not hasattr(socket, "SO_REUSEPORT"):
raise ValueError("the platform doesn't support SO_REUSEPORT")
sockets = []
if address == "":
address... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bind_sockets(port, address=..., family=..., backlog=..., flags=..., reuse_port=...):\n ...",
"def listen(self, address, backlog=1024, slave=True):\n if self.listening:\n raise RuntimeError(\"listen() called on active %r.\" % self)\n\n if self._closed:\n raise RuntimeErr... | [
"0.74207103",
"0.6945425",
"0.69005066",
"0.6876418",
"0.6618066",
"0.6612479",
"0.64867085",
"0.6467395",
"0.6412914",
"0.6222878",
"0.6100619",
"0.5947013",
"0.58689815",
"0.58162826",
"0.57599205",
"0.57177484",
"0.55687433",
"0.5550284",
"0.5526482",
"0.55125666",
"0.5480... | 0.7855075 | 0 |
Adds an `.IOLoop` event handler to accept new connections on ``sock``. When a connection is accepted, ``callback(connection, address)`` will be run (``connection`` is a socket object, and ``address`` is the address of the other end of the connection). Note that this signature is different from the ``callback(fd, events... | def add_accept_handler(sock, callback):
io_loop = IOLoop.current()
removed = [False]
def accept_handler(_fd, _events):
# More connections may come in while we're handling callbacks;
# to prevent starvation of other tasks we must limit the number
# of connections we accept at a time.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_accept_handler(sock, callback):\n ...",
"def registerCallback(self, cb, *args):\n\n conn = len(self.callbacks)\n self.callbacks[conn] = (cb, args)\n return conn",
"def add_listener(self, name, callback: Callable[..., Any], filter_fn=None, optional=False) -> 'CallbackDisconnector... | [
"0.68694955",
"0.5439899",
"0.5290388",
"0.5248967",
"0.5231983",
"0.5110135",
"0.49963936",
"0.49368846",
"0.49222544",
"0.48442623",
"0.483303",
"0.48286244",
"0.47883856",
"0.4717733",
"0.46983105",
"0.46869808",
"0.46778837",
"0.46525833",
"0.46241182",
"0.45754397",
"0.4... | 0.78751916 | 0 |
Test a plain text file for miscellaneous issues. | def test_plain_text():
source_file = os.path.join(_TESTS_DIR, 'plain_text_sample.txt')
file_reports = psca.analyze([source_file], _SETTINGS_FILE,
profile='test_04')
reports = file_reports[0].reports
# The elements of the found_errors and expected_errors sets are
# tup... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_nonfile(self):\n self.assertEqual(None,readfiles.read_file(\"tests.txt))",
"def test_read_raw_suggested(fname):\n with pytest.raises(ValueError, match='Try reading'):\n read_raw(fname)",
"def test_read_file():\n filename = 'sample'\n assert read_file(filename) == 'hello!\\n'",
... | [
"0.69077563",
"0.6679252",
"0.6510074",
"0.6481004",
"0.6433745",
"0.6433745",
"0.63907886",
"0.63527757",
"0.6352395",
"0.63454515",
"0.63325214",
"0.63009596",
"0.6260165",
"0.6260165",
"0.6142512",
"0.6127942",
"0.61194354",
"0.6090325",
"0.60827994",
"0.603354",
"0.602476... | 0.7418387 | 0 |
compare two hmacs, with double hmac verification | def macsEqual(mac1, mac2):
cmpKey = os.urandom(32)
# log.debug("macsEqual lengths:%s:%s:%s", len(cmpKey), len(mac1), len(mac2))
hmac1 = hmac.new(cmpKey, mac1, 'sha256').digest()
hmac2 = hmac.new(cmpKey, mac2, 'sha256').digest()
return hmac1 == hmac2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def secure_compare(a, b):\n\n def utf8(value):\n if six.PY2 and isinstance(value, six.text_type):\n return value.encode('utf-8')\n else:\n return value\n\n return hmac.compare_digest(utf8(a), utf8(b))",
"def verify_hmac(self, payload):\r\n \r\n new_hmac = hmac... | [
"0.6710913",
"0.6497679",
"0.6203819",
"0.609462",
"0.59927726",
"0.596196",
"0.59614146",
"0.58616465",
"0.58580554",
"0.58446604",
"0.57962346",
"0.5738112",
"0.5722327",
"0.5699178",
"0.5654888",
"0.5608298",
"0.5592351",
"0.55629313",
"0.55592614",
"0.55520517",
"0.554831... | 0.6685345 | 1 |
decryptEncryptionKey returns encryptionKey and macKey | def decryptEncryptionKey(cipherString, key):
encryptionType, iv, cipherText, mac = decodeCipherString(cipherString)
# log.debug("mac:%s", mac)
# log.debug("iv:%s", iv)
# log.debug("ct:%s", cipherText)
assert mac is None
if encryptionType != 0:
raise UnimplementedError("can not decrypt type:%s" % encryptionType... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cipher_key(key):\n k = (\n key[0] ^ key[4],\n key[1] ^ key[5],\n key[2] ^ key[6],\n key[3] ^ key[7])\n iv = key[4:6] + (0, 0)\n meta_mac = key[6:8]\n\n return k, iv, meta_mac",
"def decrypt(self, cypher):\n\n cypher = b64decod... | [
"0.6889936",
"0.6625478",
"0.6590175",
"0.6586037",
"0.65106726",
"0.64812505",
"0.6454514",
"0.6392883",
"0.6392093",
"0.63776135",
"0.6375416",
"0.63718826",
"0.63688797",
"0.63317287",
"0.6318328",
"0.63087946",
"0.62678766",
"0.6243097",
"0.624027",
"0.62250346",
"0.61986... | 0.754777 | 0 |
The complete id of the course we're configured to test with. This function is evaluated once per locust client and its return value is cached on a perclient basis (due to the decorator). It randomly selects a course from the "courses" dict specified in the settings file. The "ratio" keys of every course are used to con... | def course_id(self):
courses = settings.data['courses']
course_ratio_pairs = \
[(cid, cdata['ratio']) for cid, cdata in courses.iteritems()]
return util.choice_with_distribution(course_ratio_pairs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def canvas_course_id(url):\n cid = ''\n match = COURSERE.search(url)\n if match:\n cid = match.group(1)\n return cid",
"def id(self):\r\n return self.location.course_key",
"def _get_course_id(course_data):\r\n return SlashSeparatedCourseKey(course_data['org'], course_data['number']... | [
"0.616844",
"0.59577924",
"0.59359133",
"0.5884893",
"0.5829294",
"0.5716216",
"0.5615083",
"0.55417",
"0.55099803",
"0.54601365",
"0.5433023",
"0.5203132",
"0.51822907",
"0.5161159",
"0.5155441",
"0.51299965",
"0.5129537",
"0.5111986",
"0.51051956",
"0.5087785",
"0.5027093",... | 0.80617344 | 0 |
The 'org' part of the course_id. | def course_org(self):
return self.course_key.org | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def org_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"org_id\")",
"def org_id(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"org_id\")",
"def org_id(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"org_id\")",
"def user_org_id(self) -> str:\n ... | [
"0.7613866",
"0.74211437",
"0.733949",
"0.7155278",
"0.71283543",
"0.69651705",
"0.6902583",
"0.6889967",
"0.6731911",
"0.67278695",
"0.6667799",
"0.6657448",
"0.65949637",
"0.6433148",
"0.64102733",
"0.640995",
"0.640995",
"0.6384291",
"0.63614",
"0.634524",
"0.63179207",
... | 0.84543437 | 0 |
The 'num' (aka 'course') part of the course_id. | def course_num(self):
return self.course_key.course | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_id(self) -> str:\n return pulumi.get(self, \"num_id\")",
"def course(self) -> int:\n return self._course",
"def _get_course_id(course_data):\r\n return SlashSeparatedCourseKey(course_data['org'], course_data['number'], course_data['run'])",
"def get_course_id(self):\n return s... | [
"0.64206254",
"0.62837285",
"0.62681633",
"0.617112",
"0.61314756",
"0.60991526",
"0.59818035",
"0.594879",
"0.5902494",
"0.5899964",
"0.5828995",
"0.58193356",
"0.5799614",
"0.575354",
"0.5739018",
"0.5714931",
"0.5689089",
"0.5682858",
"0.5675486",
"0.5675486",
"0.56463635"... | 0.79815304 | 0 |
The 'run' part of the course_id. | def course_run(self):
return self.course_key.run | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_id(self) -> str:\n return self._step_execution_context.run_id",
"def getRunId(self):\n return self.runid",
"def run_id() -> int:\n return sg_covid_impact.config[\"flows\"][\"glass\"][\"run_id\"]",
"def run_id(self):\n if self._run_id is not None:\n return self._run_... | [
"0.69273543",
"0.6729144",
"0.6449546",
"0.63787335",
"0.6318323",
"0.6145828",
"0.61315894",
"0.6059584",
"0.6059379",
"0.5939561",
"0.59369683",
"0.5874441",
"0.58349293",
"0.58319956",
"0.5768009",
"0.5733007",
"0.5631648",
"0.5627364",
"0.5596727",
"0.55490065",
"0.554147... | 0.80205244 | 0 |
Accessor for the CourseData instance we're configured to test with. | def course_data(self):
course_data_name = self._get_course_setting('course_data')
return getattr(course_data, course_data_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_course(self):\r\n return self.descriptor.runtime.modulestore.get_course(self.course_id)",
"def course(self):\n return self.section.course",
"def get_courses_metadata(self):\n return Metadata(**settings.METADATA['course_ids'])",
"def set_up_course(self):\r\n course = Course... | [
"0.68768317",
"0.662616",
"0.6441367",
"0.64398867",
"0.6273828",
"0.6250787",
"0.6200913",
"0.61638105",
"0.60948956",
"0.6044396",
"0.6005691",
"0.598588",
"0.5925067",
"0.5880493",
"0.58427364",
"0.58271486",
"0.58267015",
"0.58120155",
"0.58094925",
"0.57689893",
"0.56996... | 0.7864934 | 0 |
Accessor for a setting specific to the current course. | def _get_course_setting(self, setting):
return settings.data['courses'][self.course_id][setting] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_setting(self, id):\n return __settings__.getSetting(id)",
"def setting(setting_name):\n\n return getattr(settings, setting_name)",
"def get_setting_value(self, title, setting):\r\n return self.parser.get(title, setting)",
"def get_setting(self, setting):\n return self.do_rpc(\... | [
"0.65132785",
"0.636397",
"0.6298962",
"0.6220281",
"0.61941284",
"0.60064334",
"0.5998761",
"0.59896207",
"0.59571224",
"0.5849541",
"0.58394676",
"0.5810019",
"0.580563",
"0.5740989",
"0.5691655",
"0.566663",
"0.56624395",
"0.5644879",
"0.5626616",
"0.5624554",
"0.5621901",... | 0.8053865 | 0 |
Loads subclasses of Particle. | def import_particles(particles=None):
this_dir = os.path.dirname(__file__)
particles_dir = os.path.join(this_dir, "particles")
from_list = ["particle"]
if particles is not None:
from_list.extend(particles)
else:
for root, dirs, files in os.walk(particles_dir):
for file_ ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def childs(cls, forceLoad: bool = True) -> list:\n if forceLoad:\n ModuleLoader.loadModules(cls.__module__)\n\n return type.__subclasses__(cls)",
"def __init__(self, particles):\n self.particles = particles",
"def load(self):\n for name, item in itertools.chain(\n ... | [
"0.58821154",
"0.5588011",
"0.5557076",
"0.5515848",
"0.5498231",
"0.5473326",
"0.5451055",
"0.53828424",
"0.5363186",
"0.53526497",
"0.5345035",
"0.52737206",
"0.52608335",
"0.5198949",
"0.5198648",
"0.51662326",
"0.5161112",
"0.5135964",
"0.5123929",
"0.5123696",
"0.5113908... | 0.686684 | 0 |
Create a new note | def create_a_note(self, data):
return self.client._post("/notes", json=data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createNote(self, authenticationToken, note):\r\n pass",
"def create_note(self, owner, title, text, note_type, important):\r\n note = self.create(owner=owner, title=title, text=text, note_type=note_type, important=important)\r\n return note",
"def createNote(self, authenticationToken, note)... | [
"0.823186",
"0.8121152",
"0.79066956",
"0.7873552",
"0.78250474",
"0.77949345",
"0.7792866",
"0.76785266",
"0.7587842",
"0.74096674",
"0.7334458",
"0.73061717",
"0.71856064",
"0.71042067",
"0.70213664",
"0.699548",
"0.6974468",
"0.69585586",
"0.69310886",
"0.6895078",
"0.6868... | 0.81451225 | 1 |
Retrieve an existing note | def retrieve_a_note(self, note_id):
return self.client._get("/notes/{}".format(note_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_note(note_id):\n return db.getdb().note.find_one({'id': note_id}, {'_id': False})",
"def get_note(self, id):\n try:\n note = self.session.query(models.Note).filter(\n (models.Note.id == id)\n & (models.Note.action != const.ACTION_DELETE)\n ).o... | [
"0.7924757",
"0.7354226",
"0.73209274",
"0.73204696",
"0.71853334",
"0.71749204",
"0.7162622",
"0.71188176",
"0.7055764",
"0.7042754",
"0.7013967",
"0.7006662",
"0.6979668",
"0.69306844",
"0.6906562",
"0.6902105",
"0.6843999",
"0.6838884",
"0.6763036",
"0.67178047",
"0.667485... | 0.77426255 | 1 |
Assert that resolution is calculated correctly when using the xarray rasterio backend. | def test_calc_res():
with xr.open_rasterio(TEST_RASTER_PATH) as src:
xr_res = ds.utils.calc_res(src)
with rasterio.open(TEST_RASTER_PATH) as src:
rio_res = src.res
assert np.allclose(xr_res, rio_res) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_size(self,x,y):\n assert(x <= 10**3), 'Width larger than 1000' \n assert(y <= 10**3), 'Height larger than 1000' \n assert(x*y <= 3*(10**5)), 'Resolution larger than 300000'",
"def test_change_resolution(self):\n\n def test(grid, *desired_resolution):\n ... | [
"0.6372065",
"0.6015322",
"0.59938735",
"0.59033257",
"0.5852334",
"0.58278245",
"0.57994336",
"0.5751685",
"0.57348406",
"0.5724172",
"0.5697906",
"0.56943977",
"0.56537974",
"0.5647166",
"0.5645956",
"0.56367785",
"0.5599529",
"0.55876565",
"0.5581748",
"0.5569151",
"0.5512... | 0.67046434 | 0 |
Assert that bounding boxes are calculated correctly when using the xarray rasterio backend. | def test_calc_bbox():
with xr.open_rasterio(TEST_RASTER_PATH) as src:
xr_res = ds.utils.calc_res(src)
xr_bounds = ds.utils.calc_bbox(src.x.values, src.y.values, xr_res)
with rasterio.open(TEST_RASTER_PATH) as src:
rio_bounds = src.bounds
assert np.allclose(xr_bounds, rio_bounds, atol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_bounding_box(self):\n\n # Note there are two possible correct values of bbox depending on\n # the version of gdal:\n # http://trac.osgeo.org/gdal/wiki/rfc33_gtiff_pixelispoint\n\n # Get gdal version number\n x = gdal.VersionInfo('').replace('dev', '').split()\n ... | [
"0.69227684",
"0.6805225",
"0.6798895",
"0.6790871",
"0.6737685",
"0.6674402",
"0.66645247",
"0.65982324",
"0.6555925",
"0.6520993",
"0.6493282",
"0.6447653",
"0.6408337",
"0.6389575",
"0.6373378",
"0.636101",
"0.6274943",
"0.6265265",
"0.6229025",
"0.62180036",
"0.6209007",
... | 0.7428076 | 0 |
Assert raster with ascending x and ycoordinates and a partial canvas range is aggregated correctly. | def test_raster_both_ascending_partial_range():
xs = np.arange(10)
ys = np.arange(5)
arr = xs*ys[np.newaxis].T
xarr = xr.DataArray(arr, coords={'X': xs, 'Y': ys}, dims=['Y', 'X'])
cvs = ds.Canvas(7, 3, x_range=(.5, 7.5), y_range=(.5, 3.5))
agg = cvs.raster(xarr)
assert np.allclose(agg.data,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_raster_x_ascending_y_descending_partial_range():\n xs = np.arange(10)\n ys = np.arange(5)[::-1]\n arr = xs*ys[np.newaxis].T\n xarr = xr.DataArray(arr, coords={'X': xs, 'Y': ys}, dims=['Y', 'X'])\n cvs = ds.Canvas(7, 2, x_range=(0.5, 7.5), y_range=(1.5, 3.5))\n agg = cvs.raster(xarr)\n\n ... | [
"0.7290736",
"0.72719604",
"0.71480185",
"0.6512315",
"0.6509897",
"0.64375144",
"0.6377085",
"0.6340407",
"0.6196886",
"0.61811996",
"0.61730856",
"0.6070395",
"0.5929373",
"0.5889656",
"0.58422434",
"0.57980466",
"0.5779752",
"0.57740796",
"0.5766816",
"0.575248",
"0.574883... | 0.7350646 | 0 |
Assert raster with ascending x and descending ycoordinates is aggregated correctly. | def test_raster_x_ascending_y_descending():
xs = np.arange(10)
ys = np.arange(5)[::-1]
arr = xs*ys[np.newaxis].T
xarr = xr.DataArray(arr, coords={'X': xs, 'Y': ys}, dims=['Y', 'X'])
cvs = ds.Canvas(10, 5, x_range=(-.5, 9.5), y_range=(-.5, 4.5))
agg = cvs.raster(xarr)
assert np.allclose(agg.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_raster_x_descending_y_ascending():\n xs = np.arange(10)[::-1]\n ys = np.arange(5)\n arr = xs*ys[np.newaxis].T\n xarr = xr.DataArray(arr, coords={'X': xs, 'Y': ys}, dims=['Y', 'X'])\n cvs = ds.Canvas(10, 5, x_range=(-.5, 9.5), y_range=(-.5, 4.5))\n agg = cvs.raster(xarr)\n\n assert np.... | [
"0.744521",
"0.6983739",
"0.6980309",
"0.69384867",
"0.6892292",
"0.6433484",
"0.6376983",
"0.6326659",
"0.5968603",
"0.59617025",
"0.5684936",
"0.557692",
"0.551352",
"0.55038357",
"0.5498421",
"0.5437988",
"0.5437047",
"0.5424282",
"0.542257",
"0.540059",
"0.53717786",
"0... | 0.74535775 | 0 |
Assert raster with descending x and ascending ycoordinates is aggregated correctly. | def test_raster_x_descending_y_ascending():
xs = np.arange(10)[::-1]
ys = np.arange(5)
arr = xs*ys[np.newaxis].T
xarr = xr.DataArray(arr, coords={'X': xs, 'Y': ys}, dims=['Y', 'X'])
cvs = ds.Canvas(10, 5, x_range=(-.5, 9.5), y_range=(-.5, 4.5))
agg = cvs.raster(xarr)
assert np.allclose(agg.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_raster_x_ascending_y_descending():\n xs = np.arange(10)\n ys = np.arange(5)[::-1]\n arr = xs*ys[np.newaxis].T\n xarr = xr.DataArray(arr, coords={'X': xs, 'Y': ys}, dims=['Y', 'X'])\n cvs = ds.Canvas(10, 5, x_range=(-.5, 9.5), y_range=(-.5, 4.5))\n agg = cvs.raster(xarr)\n\n assert np.... | [
"0.7493786",
"0.7191751",
"0.68614155",
"0.6814781",
"0.6783932",
"0.6406422",
"0.62806016",
"0.60354185",
"0.5915052",
"0.58697915",
"0.5565902",
"0.55442536",
"0.5538366",
"0.5471555",
"0.54258823",
"0.54209226",
"0.54178244",
"0.5393789",
"0.5358412",
"0.53221726",
"0.5303... | 0.74933386 | 1 |
Assert that an error is raised when incorrect upsample and/or downsample methods are provided to cvs.raster(). | def test_resample_methods():
with xr.open_rasterio(TEST_RASTER_PATH) as src:
try:
cvs.raster(src, upsample_method='santaclaus', downsample_method='toothfairy')
except ValueError:
pass
else:
assert False
try:
cvs.raster(src, upsample_me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rasterizer_rasterize_exception_raised(self, shapes, dtypes, backend):\n placeholders = self._create_placeholders(shapes, dtypes)\n with self.assertRaisesRegexp(KeyError, 'Backend is not supported'):\n rasterization_backend.rasterize(placeholders[0], placeholders[1],\n ... | [
"0.6772757",
"0.65957314",
"0.64102316",
"0.6217085",
"0.6118477",
"0.6067933",
"0.5954282",
"0.5933001",
"0.5852692",
"0.5851109",
"0.5826595",
"0.58197564",
"0.5804138",
"0.57922494",
"0.5780339",
"0.5728246",
"0.5684695",
"0.5677494",
"0.56632954",
"0.56592053",
"0.5648280... | 0.7481254 | 0 |
Generate all formats and versions of the Continuous Performance Trending and Analysis. | def generate_cpta(spec, data):
logging.info("Generating the Continuous Performance Trending and Analysis "
"...")
ret_code = _generate_all_charts(spec, data)
cmd = HTML_BUILDER.format(
date=datetime.utcnow().strftime('%Y-%m-%d %H:%M UTC'),
working_dir=spec.environment["pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n reportSample = CompatibilityReportSample()\n reportSample.run()",
"def main():\n log_files = []\n performances = []\n for local_file in os.listdir(\"../data\"):\n if local_file.endswith(\"-touches.csv\"):\n log_files.append(\"../data/\" + local_file)\n print(\"Lo... | [
"0.59122515",
"0.58874303",
"0.5551575",
"0.5518294",
"0.55130625",
"0.5490796",
"0.54892236",
"0.5482167",
"0.54549026",
"0.5437925",
"0.53925437",
"0.5381298",
"0.5375039",
"0.53588235",
"0.5325853",
"0.52840316",
"0.5283643",
"0.5279319",
"0.5279215",
"0.5278753",
"0.52755... | 0.6417979 | 0 |
Generate all charts specified in the specification file. | def _generate_all_charts(spec, input_data):
def _generate_chart(_, data_q, graph):
"""Generates the chart.
"""
logs = list()
logging.info(" Generating the chart '{0}' ...".
format(graph.get("title", "")))
logs.append(("INFO", " Generating the chart '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(self, chart):\n chart.create_visualization_files(self.__outputpath)",
"def make_charts(self):\n\n def _insert_pie_chart(wbook, wsheet, title, cell_pos, series):\n piechart = wbook.add_chart({\"type\": \"pie\"})\n piechart.set_title({\"name\": title})\n pi... | [
"0.6248313",
"0.58956814",
"0.5889163",
"0.5797727",
"0.575799",
"0.5702071",
"0.56948364",
"0.5692885",
"0.5687971",
"0.56689596",
"0.56218266",
"0.559038",
"0.5532577",
"0.5525566",
"0.5525251",
"0.5508235",
"0.5500401",
"0.54779744",
"0.54711485",
"0.5455648",
"0.5448928",... | 0.7123142 | 0 |
Compare three elements in comp_els according to specific implementation in inheriter's method. | def compare(self, comp_els):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare(self, comp_els):\n return min(comp_els, key= lambda x: x[1])[0]",
"def compare(self, comp_els):\n return max(comp_els, key=lambda x: x[1])[0]",
"def compare(self, *args):\n return _ida_hexrays.cwhile_t_compare(self, *args)",
"def compare(self, *args):\n return _ida_hex... | [
"0.6714349",
"0.663944",
"0.5810195",
"0.5765554",
"0.5596287",
"0.55922717",
"0.557216",
"0.55279785",
"0.54683954",
"0.5412732",
"0.53845376",
"0.53688097",
"0.5349028",
"0.5334935",
"0.53067285",
"0.52928555",
"0.5283947",
"0.5273153",
"0.52720165",
"0.52575946",
"0.525136... | 0.8182994 | 0 |
source_svc is a string vdisk is a dictionary for a vdisk | def remove_vdisk_from_svc(svc, vdisk):
svc_ssh = openSSH(svc, getpass.getuser())
## First we need to unmap from the host
print "Removing the mapping between %s on %s..." % (vdisk["name"],
vdisk["hostlist"][0])
command = "rmvdiskhostmap -host %... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_disk(self):\n self.command.package = self.input_ovf\n self.command.file_id = \"file1\"\n self.command.run()\n self.command.finished()\n self.check_diff(\"\"\"\n <ovf:References>\n- <ovf:File ovf:href=\"input.vmdk\" ovf:id=\"file1\" ovf:size=\"{vmdk_size}\" />\n ... | [
"0.557201",
"0.5454952",
"0.5437558",
"0.53695285",
"0.52890855",
"0.52807283",
"0.5209793",
"0.51589704",
"0.5132634",
"0.5127604",
"0.5082114",
"0.5072287",
"0.5058327",
"0.5057857",
"0.505458",
"0.5039305",
"0.50285256",
"0.502517",
"0.4984804",
"0.49821296",
"0.4965347",
... | 0.61584103 | 0 |
Computes the CRC24 used by OpenPGP Message Format | def opgp_crc24(data: bytes) -> int:
crc = 0xB704CE
for byte in data:
crc ^= byte << 16
for _ in range(8):
crc <<= 1
if (crc & 0x1000000) != 0:
crc ^= 0x1864CFB
assert 0 <= crc <= 0xFFFFFF
return crc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crc_calc(msg):\n new_crc = 0\n for letter in msg:\n temp = ord(letter)\n for _ in range(0, 8):\n temp ^= new_crc & 1\n new_crc >>= 1\n if (temp & 1) != 0:\n new_crc ^= 0xA001\n temp >>= 1\n\n ... | [
"0.73321456",
"0.7217655",
"0.6928603",
"0.6703114",
"0.6680484",
"0.6453052",
"0.63902175",
"0.6360492",
"0.6277814",
"0.6263143",
"0.6247372",
"0.6218449",
"0.6213269",
"0.6190279",
"0.6183493",
"0.61220324",
"0.6102516",
"0.6100329",
"0.60888386",
"0.60888386",
"0.60738844... | 0.7959176 | 0 |
Computes the CRC24 used by OpenPGP Message Format, encoded in base64 | def opgp_crc24_b64(data: bytes) -> str:
crc = opgp_crc24(data)
return "=" + base64.b64encode(crc.to_bytes(3, "big")).decode("ascii") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def opgp_crc24(data: bytes) -> int:\n crc = 0xB704CE\n for byte in data:\n crc ^= byte << 16\n for _ in range(8):\n crc <<= 1\n if (crc & 0x1000000) != 0:\n crc ^= 0x1864CFB\n assert 0 <= crc <= 0xFFFFFF\n return crc",
"def crc_calc(msg):\n ne... | [
"0.7413257",
"0.7129179",
"0.653207",
"0.64647317",
"0.63973945",
"0.62929195",
"0.62724423",
"0.6230039",
"0.619268",
"0.61744165",
"0.61371565",
"0.6115622",
"0.6109197",
"0.6100644",
"0.60924983",
"0.6092075",
"0.60364264",
"0.6026506",
"0.6015066",
"0.59719557",
"0.597195... | 0.7920905 | 0 |
Encode some data using the zbase32 encoding This encoding is specified for ZRTP protocol in | def zbase32_encode(data: bytes) -> str:
result = ""
for idx in range(0, len(data), 5):
result += ZBASE32_ALPHABET[(data[idx] & 0xF8) >> 3]
if idx + 1 == len(data):
result += ZBASE32_ALPHABET[(data[idx] & 0x07) << 2]
break
result += ZBASE32_ALPHABET[((data[idx] & 0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bech32_encode(hrp, data):\n combined = data + bech32_create_checksum(hrp, data)\n return hrp + '1' + ''.join([CHARSET[d] for d in combined])",
"def base32_encode(string: str) -> bytes:\n\n # encoded the input (we need a bytes like object)\n # then, b32encoded the bytes-like object\n return bas... | [
"0.69804114",
"0.64776635",
"0.62721366",
"0.619511",
"0.6183644",
"0.6168936",
"0.6035975",
"0.59342885",
"0.59005904",
"0.58804965",
"0.5852557",
"0.58006424",
"0.5793283",
"0.5751987",
"0.5742239",
"0.5737965",
"0.5730613",
"0.5726022",
"0.57224256",
"0.569951",
"0.5691203... | 0.73310757 | 0 |
Verify that the algorithm computing WKD URLs work | def self_check() -> None:
assert len(ZBASE32_ALPHABET) == 32
# Test vector from https://github.com/matusf/z-base-32/blob/0.1.2/src/lib.rs
assert zbase32_encode(b"asdasd") == "cf3seamuco"
assert zbase32_decode("cf3seamuco") == b"asdasd"
# Test vector from https://www.uriports.com/blog/setting-up-op... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hash_url(self):\r\n url = u'http://google.com'\r\n hashed = generate_hash(url)\r\n self.assertEqual('aa2239c17609b2', hashed)",
"def testLongURL(self):\n self.assertEqual([], grab('www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www... | [
"0.57088345",
"0.56966805",
"0.55900574",
"0.55895996",
"0.5535178",
"0.55189407",
"0.54513264",
"0.5427856",
"0.5400599",
"0.53939325",
"0.5391268",
"0.5373499",
"0.5354622",
"0.5346659",
"0.53463924",
"0.53402835",
"0.53162587",
"0.5307713",
"0.53010786",
"0.5293571",
"0.52... | 0.63866985 | 0 |
Get the identifier of a key, using GnuPG | def get_pgp_key_id(raw_key: bytes) -> str:
# Flush stdout and stderr to prevent interleaving messages from a subprocess
sys.stdout.flush()
sys.stderr.flush()
with tempfile.TemporaryDirectory(prefix="gnupghome") as tmpdir:
# Create an empty public keyring to avoid a GnuPG message
with (Pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_key_id(self):",
"def key(key):\n return key",
"def key(ctx):\n pem = _get_pem(ctx().source)\n click.echo(_get_gpg_key(pem, ctx().user, ctx().verbose))",
"def game_key(proto_obj):\n return game_key_full(proto_obj.id_str)",
"def key():",
"def extract_key_name(self):\n # quick a... | [
"0.704887",
"0.6817188",
"0.6768313",
"0.6727165",
"0.6648911",
"0.65785885",
"0.6537036",
"0.6528144",
"0.6524463",
"0.6521327",
"0.6422908",
"0.63885075",
"0.63885075",
"0.63663375",
"0.623665",
"0.62345964",
"0.62345964",
"0.62345964",
"0.62345964",
"0.62345964",
"0.623459... | 0.77540326 | 0 |
Fits a model according to the given test_ids and data. | def fit(model, data, test_ids, exp_name, train_ids=None):
if model.model_type == 'torch':
size = len(data[0])
else:
size = data[0].shape[0]
if train_ids == None:
train_ids = [i for i in range(size) if i not in test_ids]
scaler = pka_scaler(data[1][train_ids])
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit(model, data, test_ids, exp_name, datasets):\n if model.model_type == 'torch':\n size = len(data[0])\n else:\n size = data[0].shape[0]\n \n train_ids = [i for i in range(size) if i not in test_ids]\n scaler = pka_scaler(data[1][train_ids])\n if model.data_type == 'descrip... | [
"0.70261747",
"0.63892436",
"0.59818673",
"0.59672713",
"0.5885617",
"0.5824953",
"0.5812632",
"0.579831",
"0.5733478",
"0.57209295",
"0.5717925",
"0.57154495",
"0.5679553",
"0.567135",
"0.5598124",
"0.55948734",
"0.5593106",
"0.55747026",
"0.55588484",
"0.5555829",
"0.555462... | 0.7194922 | 0 |
Test if the lock is currently held. The lock is held if the PID file for this lock exists. | def is_locked(self):
result = pidfile_exists(self.path)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i_am_locking(self):\n result = False\n current_pid = os.getpid()\n pidfile_pid = self.read_pid()\n if current_pid == pidfile_pid:\n result = True\n return result",
"def is_unlocked(self):\r\n return self._lock_fd is None",
"def is_locked(self):\n retu... | [
"0.76640034",
"0.74272513",
"0.739706",
"0.72215617",
"0.7164151",
"0.70871043",
"0.7065373",
"0.70423764",
"0.7034546",
"0.6971728",
"0.696032",
"0.69589776",
"0.6932389",
"0.69277656",
"0.69038886",
"0.68906254",
"0.68663543",
"0.68499297",
"0.68330723",
"0.68126285",
"0.67... | 0.800034 | 0 |
Test if the lock is held by the current process. Returns ``True`` if the current process ID matches the number stored in the PID file. | def i_am_locking(self):
result = False
current_pid = os.getpid()
pidfile_pid = self.read_pid()
if current_pid == pidfile_pid:
result = True
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_locked(self):\n result = pidfile_exists(self.path)\n return result",
"def is_locked(self):\n return bool(int(self._fp(self.F_LOCKED).read()))",
"def check_pid(self, retry=True):\n first_retry = True\n attempt_ctr = 0\n while first_retry or retry:\n tr... | [
"0.7634392",
"0.6856725",
"0.68355775",
"0.67527246",
"0.6694726",
"0.6668597",
"0.66661763",
"0.6611861",
"0.66004646",
"0.6570404",
"0.65473074",
"0.64875805",
"0.6395865",
"0.63808095",
"0.63531977",
"0.6318848",
"0.6306414",
"0.6293243",
"0.6292794",
"0.627209",
"0.626877... | 0.79461324 | 0 |
Acquire the lock. Creates the PID file for this lock, or raises an error if the lock was already held. | def acquire(self):
if pidfile_exists(self.path):
error = AlreadyLocked()
raise error
try:
write_pid_to_pidfile(self.path)
except OSError:
error = LockFailed()
raise error | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acquire_lock():\n\n lock_file = get_lock_file()\n if exists(lock_file):\n LOG.critical('Lock file %r exists already. Is the process still running? Exiting with error...' % lock_file)\n sys.exit(9)\n\n LOG.info('Creating lock file: %r' % lock_file)\n with open(lock_file, 'w') as fptr:\... | [
"0.8165319",
"0.78820896",
"0.7815003",
"0.77452964",
"0.7529011",
"0.7518624",
"0.72868574",
"0.7194519",
"0.7183026",
"0.7181308",
"0.7028626",
"0.7007201",
"0.69705766",
"0.6931904",
"0.69086206",
"0.6888093",
"0.6888093",
"0.6849998",
"0.6827463",
"0.67233354",
"0.666444"... | 0.8707073 | 0 |
Release the lock. Removes the PID file to release the lock, or raises an error if the current process does not hold the lock. | def release(self):
if not self.is_locked():
error = NotLocked()
raise error
if not self.i_am_locking():
error = NotMyLock()
raise error
remove_existing_pidfile(self.path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def release_lock():\n lock_file = get_lock_file()\n if exists(lock_file):\n LOG.info('Removing lock file %r' % lock_file)\n os.unlink(lock_file)\n else:\n LOG.warning('Lock file %r did not exist.' % lock_file)",
"def _release(self):\n try:\n os.unlink(self.lockfile... | [
"0.8098958",
"0.78840387",
"0.7770334",
"0.7749819",
"0.76971185",
"0.76821244",
"0.76286703",
"0.7477902",
"0.7412101",
"0.73480296",
"0.7309963",
"0.72252554",
"0.7191456",
"0.71252495",
"0.71210337",
"0.710464",
"0.710464",
"0.70961607",
"0.69325686",
"0.69319993",
"0.6921... | 0.8193875 | 0 |
Break an existing lock. Removes the PID file if it already exists, otherwise does nothing. | def break_lock(self):
remove_existing_pidfile(self.path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def break_lock(self):\r\n pass",
"def unlock(self):\n self.remove_pid_file()",
"def _break_foreign_lock(self):\n # If the foreign process did not crash and just takes a bit longer\n # than expected, this may pull the rug from under their feet by\n # removing the lock they thi... | [
"0.6857863",
"0.6831098",
"0.6787846",
"0.66977036",
"0.6662554",
"0.66456306",
"0.6597146",
"0.6582683",
"0.6517292",
"0.64428556",
"0.6402308",
"0.64021885",
"0.6360131",
"0.63550323",
"0.63120204",
"0.6290557",
"0.6282644",
"0.61980087",
"0.61922324",
"0.6142368",
"0.61210... | 0.8273423 | 0 |
Return True if the named PID file exists on the filesystem. | def pidfile_exists(pidfile_path):
result = os.path.exists(pidfile_path)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_exists(self):\n if os.path.isfile(self.file_name):\n return True\n else:\n return False",
"def file_exists(path):\n\n try:\n with open(path):\n return True\n except IOError:\n return False",
"def file_exist() -> boo... | [
"0.72768027",
"0.7224909",
"0.7221191",
"0.72186655",
"0.7204386",
"0.7191531",
"0.7187692",
"0.7182469",
"0.7164429",
"0.7163358",
"0.7144959",
"0.71347356",
"0.7132595",
"0.71233577",
"0.7118674",
"0.71141416",
"0.7107467",
"0.70991755",
"0.70711684",
"0.7051729",
"0.703811... | 0.81579876 | 0 |
Get junction in front of ego vehicle by exploring route. | def get_junction_by_route(self, start_waypoint):
# get start waypoint
waypoint = start_waypoint
reached_junction = False
sampling_radius = 1.
while not reached_junction:
wp_choice = waypoint.next(sampling_radius)
waypoint = wp_choice[0]
if w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def junction_visitor(self, cell: Cell) -> None:\n for neighbor in self.junction_graph.neighbors(cell):\n direction = self.junction_direction(cell, neighbor)\n if direction in cell.open_walls and self.is_in_solution(neighbor):\n self.prev_cells[cell] = neighbor\n ... | [
"0.56934613",
"0.56271213",
"0.55727845",
"0.55098987",
"0.54290986",
"0.53944415",
"0.5314927",
"0.5233385",
"0.50737506",
"0.50083685",
"0.49816352",
"0.49744385",
"0.49284393",
"0.49279106",
"0.49106917",
"0.49000826",
"0.48722604",
"0.48660755",
"0.48339242",
"0.48218343",
... | 0.59667826 | 0 |
Generate a route for the scenario. Route is determined by class attribute turning_flag. | def get_route(self,
spawn_location,
distance: float = 10.,
turning_flag=-1, # left -> -1, straight -> 0, right -> 1
resolution: float = 1.):
waypoint_route = []
transform_route = []
location_route = []
spawn_waypo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_route(vehicle, turn_flag=0, hop_resolution=1.0):\n world = vehicle.get_world()\n map = world.get_map()\n\n # get initial location of ego_vehicle\n start_waypoint = map.get_waypoint(vehicle.get_location())\n\n # Using generate_target_waypoint to generate target waypoint\n # ref on sce... | [
"0.7264522",
"0.62697285",
"0.5961043",
"0.5861636",
"0.58537877",
"0.5848974",
"0.5789409",
"0.5695369",
"0.56698227",
"0.56673896",
"0.56593555",
"0.5637115",
"0.5611688",
"0.55985785",
"0.55552965",
"0.55428594",
"0.5526317",
"0.5515877",
"0.55048203",
"0.54545105",
"0.539... | 0.665654 | 1 |
Construct from `allnlp.Archive`'s file. | def from_archive(
cls, archive_path: Pathlike, dataset_reader_to_load: str = VALIDATION
):
# Uses lazy import because allennlp is an extra requirements.
from allennlp.data import DatasetReader
from allennlp.models.archival import load_archive
archive = load_archive(str(archi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_data(filename):\n data=''\n with zipfile.ZipFile(filename) as f:\n \n for file in f.namelist():\n subdata = tf.compat.as_str(f.read(file))\n data+=subdata\n return nlp(data)",
"def _archive(self):\n if self.__archive is None:\n ... | [
"0.5600649",
"0.55721915",
"0.55343556",
"0.5531448",
"0.54607564",
"0.5398358",
"0.53841674",
"0.53696007",
"0.5368538",
"0.53660625",
"0.5231782",
"0.51503015",
"0.51249224",
"0.51162094",
"0.5114986",
"0.5110746",
"0.5079069",
"0.5056772",
"0.5054571",
"0.50499773",
"0.504... | 0.6358133 | 0 |
Getting each extension of our files. | def get_file_extensions():
my_files_ext = []
for file in os.listdir(os.getcwd()):
if os.path.isfile(file):
file_info = os.path.splitext(file)
file_ext = file_info[1]
my_files_ext.append(file_ext)
return [file for file in my_files_ext] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_files_with_extensions(self, extension: str) -> List[str]:\n occurrences = []\n for position in os.listdir(self.directory):\n if os.path.isdir(position):\n for file in os.listdir(position):\n if os.path.isfile(os.path.join(position, file)) and f... | [
"0.74920076",
"0.7404873",
"0.7378643",
"0.736361",
"0.7165298",
"0.7151969",
"0.70642424",
"0.70529103",
"0.69641525",
"0.6957227",
"0.6876087",
"0.68703747",
"0.68572",
"0.6827209",
"0.6814356",
"0.6813735",
"0.67899555",
"0.6786368",
"0.678497",
"0.67771256",
"0.67739356",... | 0.8211374 | 0 |
Checks to see if the extensions of our current files are in the dictionary if so, it moves them to the according folder | def check_and_move_files(my_files, my_files_ext):
for key, value in file_types.items():
for filename, ext in zip(my_files, my_files_ext):
if ext in value:
# print(downloads_path + '\\' + filename)
folder_name = key
create_folders(folder_name)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_files_with_extension(self, extension: str):\n\n while True:\n files_with_extension = self.collect_files_with_extensions(extension)\n print(files_with_extension)\n folders_containing = set(\n [\n os.path.basename(os.path.dirname(file... | [
"0.67840004",
"0.6772865",
"0.65978503",
"0.6488871",
"0.6313732",
"0.62241954",
"0.6179439",
"0.61737764",
"0.61616313",
"0.6079816",
"0.60683465",
"0.6012346",
"0.59255433",
"0.5888225",
"0.58517814",
"0.57858694",
"0.5723288",
"0.5704709",
"0.57040685",
"0.567453",
"0.5640... | 0.7328674 | 0 |
Verifies all movements are returned when calling endpoint without paramaters | def test_movements_no_params(api_client):
MovementFactory(date=datetime.date(2000, 2, 11))
MovementFactory(date=datetime.date(2010, 2, 18))
MovementFactory(date=datetime.date(2017, 1, 15))
MovementFactory(date=datetime.date(2017, 5, 24))
response = api_client.get(reverse("api:movements-list"))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_trucks_api_empty_food(self):\n resp = self.app.get('/trucks?bounds=37.74552131083975,-122.45653323673707,37.74552131083975,-122.45653323673707')\n self.assertEqual(resp.status_code, 200)\n\n expected = '{ \"resp\": [] }'\n self.assertEqual(expected.split(), resp.data.split())",... | [
"0.5866163",
"0.5783787",
"0.568854",
"0.56051314",
"0.55835843",
"0.55388284",
"0.55282927",
"0.5481235",
"0.5479715",
"0.5466633",
"0.5452804",
"0.54147166",
"0.5403905",
"0.540083",
"0.5388773",
"0.5386678",
"0.53820884",
"0.5376921",
"0.5367751",
"0.5342901",
"0.5333576",... | 0.6602419 | 0 |
Verifies correct movements are returned when calling endpoint with date_from parameter | def test_movements_date_from(api_client):
MovementFactory(date=datetime.date(2017, 2, 10))
MovementFactory(date=datetime.date(2017, 2, 11))
response = api_client.get(
reverse("api:movements-list"), {"date_from": "2017-02-11"}
)
assert response.status_code == 200
assert len(response.da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_movements_date_from_date_to(api_client):\n\n MovementFactory(date=datetime.date(2017, 2, 9))\n MovementFactory(date=datetime.date(2017, 2, 10))\n MovementFactory(date=datetime.date(2017, 2, 11))\n MovementFactory(date=datetime.date(2017, 2, 12))\n\n response = api_client.get(\n rever... | [
"0.73917025",
"0.68469864",
"0.6572051",
"0.6261133",
"0.624902",
"0.61815745",
"0.61596745",
"0.6113522",
"0.6083936",
"0.6047931",
"0.5995476",
"0.598885",
"0.5977925",
"0.5930187",
"0.59242064",
"0.588148",
"0.58554065",
"0.58496237",
"0.5843393",
"0.58392453",
"0.58365417... | 0.7629143 | 0 |
Verifies correct movements are returned when calling endpoint with date_to parameter | def test_movements_date_to(api_client):
MovementFactory(date=datetime.date(2017, 2, 10))
MovementFactory(date=datetime.date(2017, 2, 11))
response = api_client.get(reverse("api:movements-list"), {"date_to": "2017-02-10"})
assert response.status_code == 200
assert len(response.data) == 1
asser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_movements_date_from_date_to(api_client):\n\n MovementFactory(date=datetime.date(2017, 2, 9))\n MovementFactory(date=datetime.date(2017, 2, 10))\n MovementFactory(date=datetime.date(2017, 2, 11))\n MovementFactory(date=datetime.date(2017, 2, 12))\n\n response = api_client.get(\n rever... | [
"0.75444436",
"0.7171447",
"0.6381192",
"0.6272402",
"0.622826",
"0.61708945",
"0.60254973",
"0.6025374",
"0.5996423",
"0.5962007",
"0.5922804",
"0.5908522",
"0.5850491",
"0.58432794",
"0.5814498",
"0.58084774",
"0.5796418",
"0.5776836",
"0.57725334",
"0.5753182",
"0.5747551"... | 0.7595078 | 0 |
Verifies correct movements are returned when calling endpoint with date_from and date_to parameter | def test_movements_date_from_date_to(api_client):
MovementFactory(date=datetime.date(2017, 2, 9))
MovementFactory(date=datetime.date(2017, 2, 10))
MovementFactory(date=datetime.date(2017, 2, 11))
MovementFactory(date=datetime.date(2017, 2, 12))
response = api_client.get(
reverse("api:movem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_movements_date_from(api_client):\n\n MovementFactory(date=datetime.date(2017, 2, 10))\n MovementFactory(date=datetime.date(2017, 2, 11))\n\n response = api_client.get(\n reverse(\"api:movements-list\"), {\"date_from\": \"2017-02-11\"}\n )\n\n assert response.status_code == 200\n a... | [
"0.72070694",
"0.71063983",
"0.66047335",
"0.65941304",
"0.6367212",
"0.6351668",
"0.61396873",
"0.61321056",
"0.6111464",
"0.6042157",
"0.6039266",
"0.601647",
"0.6012404",
"0.59864074",
"0.59639055",
"0.594397",
"0.5920478",
"0.5885743",
"0.58857226",
"0.58753604",
"0.58656... | 0.77782863 | 0 |
Verifies correct movements are returned when calling endpoint with amount_from parameter | def test_movements_amount_from(api_client):
MovementFactory(amount=Money(-10.00, "EUR"))
MovementFactory(amount=Money(50.00, "EUR"))
response = api_client.get(reverse("api:movements-list"), {"amount_from": -7})
assert response.status_code == 200
assert len(response.data) == 1
assert response.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_movements_amount_from_amount_to(api_client):\n\n MovementFactory(amount=Money(-300.00, \"EUR\"))\n MovementFactory(amount=Money(-10.00, \"EUR\"))\n MovementFactory(amount=Money(50.00, \"EUR\"))\n MovementFactory(amount=Money(1200.00, \"EUR\"))\n\n response = api_client.get(\n reverse... | [
"0.7546628",
"0.70245373",
"0.5939988",
"0.5717165",
"0.56993717",
"0.56568956",
"0.56473416",
"0.5626091",
"0.5595285",
"0.55786353",
"0.54762405",
"0.54456866",
"0.544392",
"0.5433366",
"0.5432547",
"0.54220843",
"0.5386647",
"0.53627807",
"0.5342655",
"0.5331804",
"0.52987... | 0.7576855 | 0 |
Verifies correct movements are returned when calling endpoint with amount_to parameter | def test_movements_amount_to(api_client):
MovementFactory(amount=Money(-10.00, "EUR"))
MovementFactory(amount=Money(50.00, "EUR"))
response = api_client.get(reverse("api:movements-list"), {"amount_to": -7})
assert response.status_code == 200
assert len(response.data) == 1
assert response.data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_movements_amount_from_amount_to(api_client):\n\n MovementFactory(amount=Money(-300.00, \"EUR\"))\n MovementFactory(amount=Money(-10.00, \"EUR\"))\n MovementFactory(amount=Money(50.00, \"EUR\"))\n MovementFactory(amount=Money(1200.00, \"EUR\"))\n\n response = api_client.get(\n reverse... | [
"0.76297957",
"0.72267956",
"0.5820834",
"0.56934524",
"0.5584937",
"0.557018",
"0.54385287",
"0.5373008",
"0.53690654",
"0.53675365",
"0.5360794",
"0.5350587",
"0.53204525",
"0.5320297",
"0.5313515",
"0.530011",
"0.5295129",
"0.5279611",
"0.52710915",
"0.52285343",
"0.521710... | 0.7639851 | 0 |
Verifies correct movements are returned when calling endpoint with amount_from and amount_to parameter | def test_movements_amount_from_amount_to(api_client):
MovementFactory(amount=Money(-300.00, "EUR"))
MovementFactory(amount=Money(-10.00, "EUR"))
MovementFactory(amount=Money(50.00, "EUR"))
MovementFactory(amount=Money(1200.00, "EUR"))
response = api_client.get(
reverse("api:movements-list"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_movements_amount_from(api_client):\n\n MovementFactory(amount=Money(-10.00, \"EUR\"))\n MovementFactory(amount=Money(50.00, \"EUR\"))\n\n response = api_client.get(reverse(\"api:movements-list\"), {\"amount_from\": -7})\n\n assert response.status_code == 200\n assert len(response.data) == 1... | [
"0.7062087",
"0.70377934",
"0.5874872",
"0.58140194",
"0.5774803",
"0.57024014",
"0.55702305",
"0.5544487",
"0.55412114",
"0.54944086",
"0.54939854",
"0.5484005",
"0.54797965",
"0.5443323",
"0.5435312",
"0.5434163",
"0.5407269",
"0.5406355",
"0.5403265",
"0.5397277",
"0.53755... | 0.7751913 | 0 |
Verifies correct movements are return when calling endpoint with search parameter | def test_movements_search(api_client):
MovementFactory(
description="Best Food Ever!", category="Lunch", sub_category="Lunch"
)
MovementFactory(description="Booze Monday", category="Food", sub_category="Beer")
MovementFactory(
description="Kindle book", category="E-Commerce", sub_catego... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_search(self):\n d = self._search()\n self._response([2, 5, 10])\n self.assertEqual(self.successResultOf(d), [2, 5, 10])",
"def test_act_is_searching(self):\n # setup\n self.strategy._is_searching = True\n\n # operation\n self.search_behaviour.act()\n\n ... | [
"0.6677054",
"0.66626686",
"0.62741387",
"0.60249394",
"0.60058206",
"0.5991723",
"0.594979",
"0.594979",
"0.594979",
"0.5947812",
"0.5865401",
"0.5856264",
"0.5854677",
"0.5850063",
"0.58249766",
"0.58098656",
"0.58026505",
"0.58022857",
"0.57901263",
"0.57807827",
"0.576730... | 0.680231 | 0 |
Checks if Raspberry PI. | def is_raspberry_pi(raise_on_errors=False):
try:
with io.open('/proc/cpuinfo', 'r') as cpuinfo:
found = False
for line in cpuinfo:
if line.startswith('Hardware'):
found = True
label, value = line.strip().split(':', 1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def os_is_pi():\n return \"raspberrypi\" in platform.uname()",
"def isRaspberryPi(self):\n return 'Raspberry Pi' in self.model",
"def is_on_pi() -> bool:\n return os.name != \"nt\" and os.uname()[4][:3] == \"arm\"",
"def isRaspberryPi3(self):\n return 'Raspberry Pi 3' in self.model",
... | [
"0.85019356",
"0.8228556",
"0.8124904",
"0.7477461",
"0.74495244",
"0.7016915",
"0.6768196",
"0.6402924",
"0.5913276",
"0.5866614",
"0.585562",
"0.58327895",
"0.57888585",
"0.5725158",
"0.5686038",
"0.56734174",
"0.5653238",
"0.5630947",
"0.5623121",
"0.5606344",
"0.5565444",... | 0.82383955 | 1 |
compute shape that results when slicing a totshape array with slicetuple | def sliceshape(slicetuple, totshape):
res = []
for i,s in enumerate(slicetuple):
if isinstance(s,int):
#n = 1
pass
else:
i0,i1,istep = s.indices(totshape[i])
n = (i1-i0)//istep
res.append(n)
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slice_output_shape(input_shape):\n shape_1 = input_shape[0]\n shape_2 = 80\n shape_3 = input_shape[2]\n return (shape_1, shape_2, shape_3)",
"def test_slice_other_dimension(self):\n for i, shape in enumerate([(3, 0), (1, 2, 0), (2, 0, 1)]):\n dset = self.f.create_dataset('x%d'%i... | [
"0.67716205",
"0.6630546",
"0.65801036",
"0.635861",
"0.6270541",
"0.6254978",
"0.6253582",
"0.6253582",
"0.620183",
"0.61709493",
"0.599753",
"0.5963255",
"0.5921808",
"0.59129655",
"0.5885287",
"0.5863016",
"0.58345616",
"0.581793",
"0.57899207",
"0.5777967",
"0.5756522",
... | 0.7532333 | 0 |
tm = tilemap('res_????/PP/PP_day.0000052704.%03d.001.data',(30,51,102),itile,'f4','r') tm = tilemap('res_????/PP/PP_day.0000052704.%03d.001.data',(30,51,102),ncs=510) tm = tilemap('res_%04d/PP/PP_day.0000052704.%03d.001.data',tshape=(30,51,102),ncs=510,dtype='>f4',mode='r') | def __init__(self, filepatt, tshape, itile=None, dtype='>f4', mode='r', offset=0, order=None, ncs=None, blankval=nan):
self.filepatt = filepatt
self.dtype = dtype
self.mode = mode
self.offset = offset
self.order = order
self.tshape = tuple(tshape)
self.tnx = tshap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_tiles(img,tilefile,tilesize,options=[]):\n\tlevels=ceil(log(max(img.get_xsize(),img.get_ysize())/tilesize)/log(2.0))\n\t\n\ttf=file(tilefile,\"w\")\n\t\n\ttile_dict={}\n\tpos=0\n\timg2=img.copy()\n\txs,ys=img2.get_xsize(),img2.get_ysize()\n\tfor l in range(int(levels)):\n\t\trmin=img2.get_attr(\"mean\")-... | [
"0.659524",
"0.6371323",
"0.6326302",
"0.62552017",
"0.6251998",
"0.6111109",
"0.60486454",
"0.6013473",
"0.6009589",
"0.5958689",
"0.5958689",
"0.593738",
"0.59126705",
"0.5907962",
"0.5881491",
"0.5868784",
"0.5855492",
"0.58497",
"0.578024",
"0.57768935",
"0.5776745",
"0... | 0.64405656 | 1 |
tm = tiledfile('res_????/PP/PP_day.0000052704.%03d.001.data',(30,51,102),itile,'f4','r') tm = tiledfile('res_????/PP/PP_day.0000052704.%03d.001.data',(30,51,102),ncs=510) tm = tiledfile('res_%04d/PP/PP_day.0000052704.%03d.001.data',tshape=(30,51,102),ncs=510,dtype='>f4',mode='r') | def __init__(self, filepatt, tshape, itile=None, dtype='>f4', ncs=None, blankval=nan):
self.filepatt = filepatt
self.dtype = dtype
self.tshape = tuple(tshape)
self.tnx = tshape[-1]
self.tny = tshape[-2]
self.tsize = prod(self.tshape)
self.glob = False
if '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, filepatt, tshape=None, itile=None, dtype='>f4', ncs=None, blankval=nan, its=None, cache=False,rot=None):\n self.filepatt = filepatt\n self.dtype = dtype\n if tshape is not None:\n self.tshape = tuple(tshape)\n else:\n metapatt = re.sub(r'\\.data$... | [
"0.6400587",
"0.62001103",
"0.5798554",
"0.57778674",
"0.57296735",
"0.5681079",
"0.5676247",
"0.56461257",
"0.56386924",
"0.5609319",
"0.5602701",
"0.5580019",
"0.55256796",
"0.5505903",
"0.5494636",
"0.5467613",
"0.54350436",
"0.54289526",
"0.542599",
"0.54103893",
"0.54027... | 0.64391273 | 0 |
tm = tiledfiles('res_%04d/PP/PP_day.%010d.%03d.001.data',(30,51,102),itile,'f4','r') tm = tiledfiles('res_????/PP/PP_day.%010d.%03d.001.data',(30,51,102),ncs=510,dtype='f4') | def __init__(self, filepatt, tshape=None, itile=None, dtype='>f4', ncs=None, blankval=nan, its=None, cache=False,rot=None):
self.filepatt = filepatt
self.dtype = dtype
if tshape is not None:
self.tshape = tuple(tshape)
else:
metapatt = re.sub(r'\.data$', '.meta', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, filepatt, tshape, itile=None, dtype='>f4', ncs=None, blankval=nan):\n self.filepatt = filepatt\n self.dtype = dtype\n self.tshape = tuple(tshape)\n self.tnx = tshape[-1]\n self.tny = tshape[-2]\n self.tsize = prod(self.tshape)\n self.glob = False\... | [
"0.6039202",
"0.58597225",
"0.57258296",
"0.56763935",
"0.5672991",
"0.56488055",
"0.56240547",
"0.5553152",
"0.55385166",
"0.55190784",
"0.55034626",
"0.5490213",
"0.5489161",
"0.54743075",
"0.544418",
"0.54430467",
"0.5438883",
"0.5432989",
"0.54133403",
"0.540952",
"0.5389... | 0.6032522 | 1 |
Outputs all the results of the jobs into a log file, including their errors and the total number of jobs that failed and passed | def print_result(job_managers: 'list[job_manager.JobManager]'):
info("Number of jobs run {}.".format(len(job_managers)))
failed_jobs = 0 # type: int
for job_item in job_managers:
if job_item.status.job_state != utils.JobState.COMPLETE:
failed_jobs += 1
warning(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report(self):\n\n job_summary = {}\n for job in self._jobs:\n \n if job.step_name not in job_summary:\n job_summary[ job.step_name ] = {}\n job_summary[ job.step_name ][ 'DONE' ] = 0\n job_summary[ job.step_name ][ 'RUNNING' ] = 0... | [
"0.69692606",
"0.6633501",
"0.6457554",
"0.6452104",
"0.64316124",
"0.64024013",
"0.63208956",
"0.60992986",
"0.60911095",
"0.60244954",
"0.6005684",
"0.59960204",
"0.5959447",
"0.5950406",
"0.5937937",
"0.5898583",
"0.58946645",
"0.58891076",
"0.5860652",
"0.5847653",
"0.582... | 0.7056434 | 0 |
Create/ Connect to the database and fetch the required data | def initialize_database():
db = Database(database_name)
i, m, u, p = db.fetch_needed_data()
return i, m, u, p | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_db(self):",
"def init_db(self):\n\n con = self.create_con()\n cursor = con.cursor()\n try:\n for query in self.create_tables():\n cursor.execute(query)\n con.commit()\n\n result = {\"Message\": \"Database connection established s... | [
"0.69363207",
"0.68122745",
"0.6790536",
"0.67504954",
"0.67037714",
"0.6622516",
"0.65980893",
"0.65819544",
"0.6569671",
"0.6566854",
"0.65496004",
"0.65405947",
"0.65339214",
"0.64957345",
"0.648952",
"0.64858234",
"0.6465934",
"0.64629954",
"0.64618576",
"0.644405",
"0.64... | 0.6940019 | 0 |
Turn the result returned from a thread into a dictionary | def from_thread_result_to_dictionary(returned_result):
keys = []
values = []
for returned_result_item in returned_result:
keys.append(returned_result_item[0])
values.append(returned_result_item[1])
dictionary = dict(zip(keys, values))
return dictionary | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_thread_execution(self, data, index):\n return {}",
"def _result_to_dict(line):\n f = line.split(':;')\n return {'server': f[0], 'os_name': f[1], 'status': f[2], 'ipv4': f[3]}",
"def result_dict(result):\n result_dict = [row.__dict__ for row in result]\n\n return re... | [
"0.6126064",
"0.6026588",
"0.5918713",
"0.5864295",
"0.5751967",
"0.5699933",
"0.5684607",
"0.56310153",
"0.5569832",
"0.5520475",
"0.54747033",
"0.5451546",
"0.54314053",
"0.5380337",
"0.53764755",
"0.53158504",
"0.5303644",
"0.52993417",
"0.5290768",
"0.5276298",
"0.5256038... | 0.80482376 | 0 |
Create a tuple of machines numbers | def create_machines_tuple(value):
tuple_values = []
for j in range(1, value + 1):
tuple_values.append(j)
return tuple(tuple_values) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def numreduct(vers):\n numvers = []\n for c in vers:\n try:\n numvers.append(int(c))\n except ValueError:\n break\n return tuple(numvers)",
"def GenDistinctId(self):\t\n \"\"\"4 bits to unique a machine \\\n\t5 bits for processes\"\"... | [
"0.6438027",
"0.59131694",
"0.58458954",
"0.5643387",
"0.55946964",
"0.5503662",
"0.5381281",
"0.53574973",
"0.5287933",
"0.5263834",
"0.5252346",
"0.5244251",
"0.52297616",
"0.52209663",
"0.52172345",
"0.5202592",
"0.5163228",
"0.5138069",
"0.5137676",
"0.5128667",
"0.511184... | 0.7769194 | 0 |
Center a Tkinter window | def center(window):
window.update_idletasks()
# Find the screen resolution
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
# Find new (x, y) coordinates
size = tuple(int(_) for _ in window.geometry().split('+')[0].split('x'))
x = screen_width/2 - 7 * s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def center(win):\n win.update_idletasks()\n width = 1120\n frm_width = win.winfo_rootx() - win.winfo_x()\n win_width = width + 2 * frm_width\n height = 630\n titlebar_height = win.winfo_rooty() - win.winfo_y()\n win_height = height + titlebar_height + frm_width\n x = win.winfo_screenwidth()... | [
"0.8368151",
"0.82453644",
"0.80583024",
"0.7998017",
"0.79803646",
"0.77359706",
"0.7735821",
"0.76757854",
"0.7672477",
"0.76220495",
"0.75433594",
"0.75433594",
"0.7457788",
"0.7398319",
"0.73812884",
"0.7374819",
"0.7374819",
"0.7361669",
"0.73200536",
"0.73154825",
"0.73... | 0.8301223 | 1 |
Bring calculations records of a certain date and save to a file | def bring_records_to_file_using_threads():
username = username_entry.get()
password = password_entry.get()
day = int(day_entry.get())
month = int(month_entry.get())
year = int(year_entry.get())
today = datetime.date(year, month, day)
if username in users:
if password == users[usernam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_file(self):\n name = datetime.today().date()\n with open(f'{name}.csv', 'w', newline='') as file_create:\n fieldnames = ['date', 'value_in_pln']\n writer = csv.DictWriter(file_create, fieldnames=fieldnames)\n writer.writeheader()\n while datetime.t... | [
"0.6610408",
"0.6236977",
"0.62272483",
"0.6113031",
"0.60338575",
"0.5939053",
"0.59343797",
"0.5901699",
"0.58597296",
"0.579244",
"0.57409453",
"0.5736686",
"0.5732707",
"0.56944853",
"0.5685865",
"0.5683208",
"0.5617142",
"0.56132406",
"0.56027955",
"0.56004995",
"0.55991... | 0.6805786 | 0 |
Return a list of (action, filename) that have changed in comparison with `ref`. | def _git_diff_files(ref="master"):
result = []
command = ["git", "diff", "--name-status", "%s" % (ref)]
exit_code, output = _execute(command)
if exit_code != 0:
print("Failed to diff files.")
sys.exit(1)
for line in output.decode("utf-8").splitlines():
parts = line.split("\t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_items_changed(self, base_ref='HEAD'):\n command = ['diff-index', '--name-only',\n '--cached', base_ref]\n res = self.run(command)\n items = res.split('\\n') if res else []\n return items",
"def fileCmp (working, ref, compare_content=0, verbose=0):\n\tif verbo... | [
"0.63654894",
"0.6294632",
"0.6262585",
"0.5971725",
"0.5957532",
"0.5957323",
"0.58469117",
"0.58443004",
"0.57912636",
"0.5781208",
"0.57787937",
"0.57783943",
"0.57463735",
"0.570197",
"0.567079",
"0.56555986",
"0.5601348",
"0.5586028",
"0.5547292",
"0.55136895",
"0.551205... | 0.7436575 | 0 |
Run checker on all the sources using `options` and sending results to `reporter`. | def check_sources(options, reporter=None):
if reporter is None:
reporter = Reporter(Reporter.CONSOLE)
reporter.call_count = 0
if options.diff_branch:
# We ignore the passed sources, and get the files from the VCS.
sources = []
for change in _git_diff_files(ref=options.diff_b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(args):\n p = OptionParser()\n p.add_option('-d', '--debug',\n action='store_true', default=False, dest='debug',\n help='debug')\n p.add_option('-w', '--w3c',\n action='store_true', default=False, dest='w3c',\n help='send file to vali... | [
"0.6246722",
"0.6190706",
"0.6074995",
"0.599145",
"0.5924092",
"0.5922893",
"0.5847676",
"0.58466774",
"0.57700986",
"0.57457656",
"0.5733095",
"0.5716981",
"0.5708985",
"0.57077795",
"0.5699328",
"0.56969637",
"0.55707437",
"0.55510914",
"0.55478066",
"0.5531311",
"0.552897... | 0.71474594 | 0 |
Answers the path of the PageBot test fonts. | def getTestFontsPath():
resourcesPath = getResourcesPath()
return '%s/%s' % (resourcesPath, 'testfonts') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRootFontPath():\n return getRootPath() + '/Fonts'",
"def getDemoFontPath():\n\ttestdata = os.path.join(os.path.dirname(__file__), \"testdata\")\n\treturn os.path.join(testdata, \"DemoFont.ufo\")",
"def getDemoFontGlyphSetPath():\n\treturn os.path.join(getDemoFontPath(), \"glyphs\")",
"def get_fonts... | [
"0.7425288",
"0.7186656",
"0.68676215",
"0.6820456",
"0.6728094",
"0.6635867",
"0.66236466",
"0.65527076",
"0.64544797",
"0.64544797",
"0.64544797",
"0.62491083",
"0.6175248",
"0.61343336",
"0.61082816",
"0.61082816",
"0.6105256",
"0.6093804",
"0.59763235",
"0.5949879",
"0.59... | 0.83270085 | 0 |
Answers the path that is source of the given font name. If the path is already a valid font path, then aswer it unchanged. Answer None if the font cannot be found. >>> from pagebot.fonttoolbox.objects.font import findFont >>> font = findFont('RobotoRegular') >>> path = getFontPathOfFont(font.path) Set as font path >>> ... | def getFontPathOfFont(font, default=None):
if hasattr(font, 'path'): # In case it is a Font instance, get its path.
font = font.path
if font is not None and not os.path.exists(font):
font = getFontPaths().get(font)
if font is None:
font = default or getDefaultFontPath()
return fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_font_path(family, font_format=\"normal\"):\n weight = \"roman\"\n weight = None\n if font_format == \"bold\":\n font_format = \"normal\"\n weight = \"bold\"\n font = matplotlib.font_manager.FontProperties(\n family=family, style=font_format, weight=weight)\n file = matpl... | [
"0.62161034",
"0.5880541",
"0.5654861",
"0.55488604",
"0.55204546",
"0.549259",
"0.5465275",
"0.5456224",
"0.53913563",
"0.53860724",
"0.5348195",
"0.52747077",
"0.5249685",
"0.52088547",
"0.5176159",
"0.5137632",
"0.51280576",
"0.5123983",
"0.5100328",
"0.5091444",
"0.508772... | 0.78634435 | 0 |
Recursive helper function for getFontPaths. If the fileName already exists in the fontPaths, then ignore. | def _recursivelyCollectFontPaths(path, collectedFontPaths):
if os.path.exists(path):
if os.path.isdir(path):
for fileName in os.listdir(path):
dirPath = path + '/' + fileName
_recursivelyCollectFontPaths(dirPath, collectedFontPaths)
else:
fontN... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _recursivelyCollectFontPaths(path, fontPaths):\n for fileName in os.listdir(path):\n filePath = path + '/' + fileName\n if os.path.isdir(filePath):\n _recursivelyCollectFontPaths(filePath, fontPaths)\n else:\n extension = fileName.split('.')[-1].lower()\n ... | [
"0.73603034",
"0.58159184",
"0.55177647",
"0.54106414",
"0.54106414",
"0.53974587",
"0.5350416",
"0.5230629",
"0.5093358",
"0.50800073",
"0.5037171",
"0.50139564",
"0.49889752",
"0.4953417",
"0.49403325",
"0.4938975",
"0.4909231",
"0.4904899",
"0.48884523",
"0.4883345",
"0.48... | 0.7276764 | 1 |
Prints all quadrants. Returns None | def print_board(self):
for i in range(0, self.quadrants_count, 2):
for row in range(3):
line = self.play_area[i].get_line(row) + " | " + self.play_area[i+1].get_line(row)
print(line)
if i < self.quadrants_count - 2:
print("----------------"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_board(self): \n for row in range(self.n):\n for col in range(self.n):\n if [row, col] in self.queens:\n print (' Q ', end = '')\n else:\n print (' - ', end = '')\n print()\n print()",
"d... | [
"0.63969034",
"0.6319256",
"0.62103415",
"0.6208199",
"0.6188663",
"0.61789155",
"0.61661476",
"0.6145801",
"0.61440533",
"0.6143841",
"0.6094081",
"0.6075543",
"0.6066864",
"0.6056026",
"0.6031269",
"0.60275656",
"0.6020766",
"0.60131294",
"0.5946148",
"0.5945328",
"0.593968... | 0.7028032 | 0 |
Rotates selected quadrant in specific direction either left or right. Calls Quadrant method. | def rotate_quadrant(self, quadrant, direction):
direction = Direction(direction)
self.play_area[quadrant].rotate(direction) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quadrant(self) -> Quadrant:\n\n if self.x > 0:\n if self.y > 0:\n return Quadrant.I\n if self.y < 0:\n return Quadrant.IV\n if self.x < 0:\n if self.y > 0:\n return Quadrant.II\n if self.y < 0:\n ... | [
"0.67372566",
"0.65096533",
"0.6229466",
"0.6184922",
"0.5887975",
"0.5764478",
"0.57570785",
"0.5704813",
"0.5704813",
"0.5671533",
"0.56543404",
"0.563273",
"0.55987436",
"0.5582323",
"0.55776024",
"0.5559777",
"0.5502261",
"0.549148",
"0.54798406",
"0.5465198",
"0.54340225... | 0.7841143 | 0 |
Generates specific player positions on the whole play area. Values are based on which quadrant position is held. First quadrant might contain values from 1 to 9, next quadrant might contain values from 10 to 18 etc. | def player_choices(self, player):
player_choices = []
for i in range(self.quadrants_count):
quadrant_board = self.play_area[i].get_board()
for j in range(self.quadrant_positions_count):
if quadrant_board[j] == player:
position = j + 1 + i * 9
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_first_quadrant(self):\n num_copies_x = ceil(self.max_x / self.room_x)\n num_copies_x = int(num_copies_x)\n num_copies_y = ceil(self.max_y / self.room_y)\n num_copies_y = int(num_copies_y)\n\n player_exp_x = []\n player_exp_y = []\n guard_exp_x = []\n ... | [
"0.64433724",
"0.62288547",
"0.6194927",
"0.6134559",
"0.60821056",
"0.60198635",
"0.59678465",
"0.59226555",
"0.5857793",
"0.58427656",
"0.58165175",
"0.57713056",
"0.5681919",
"0.5633634",
"0.5584842",
"0.5551713",
"0.5534889",
"0.55256873",
"0.55158997",
"0.5513899",
"0.54... | 0.68864065 | 0 |
Generates all available moves, from all quadrants, which player can make. First quadrant might contain values from 1 to 9, next quadrant might contain values from 10 to 18 etc. Returns | def available_moves(self):
available_moves = []
for i in range(self.quadrants_count):
quadrant_positions = self.play_area[i].available_positions()
for p in quadrant_positions:
position = p + i * 9
for j in range(self.quadrants_count):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_possible_moves(self):\r\n\t\t# Moves:\r\n\t\t# 0 - North\r\n\t\t# 1 - East\r\n\t\t# 2 - South\r\n\t\t# 3 - West\r\n\r\n\t\tmoves = []\r\n\r\n\t\tif self.x != 0:\r\n\t\t\tmoves.append(0)\r\n\t\tif self.y != self.n-1:\r\n\t\t\tmoves.append(1)\r\n\t\tif self.x != self.n-1:\r\n\t\t\tmoves.append(2)\r\n\t\... | [
"0.7041647",
"0.6426529",
"0.63518304",
"0.6341085",
"0.63361585",
"0.63185346",
"0.6301671",
"0.6271107",
"0.6242109",
"0.6200041",
"0.6184627",
"0.61758924",
"0.614454",
"0.61194867",
"0.61173284",
"0.6117292",
"0.6069023",
"0.60509765",
"0.60393727",
"0.6019526",
"0.599225... | 0.75347453 | 0 |
Test that we can create an invalid bill, and validation will fail | def test_basic_invalid_bill():
b = toy_bill()
b.identifier = None
with pytest.raises(ValueError):
b.validate() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_customer_fails(self):\n with self.assertRaises(IntegrityError):\n Customer.objects.create(\n email=None,\n billing_address=customer_data['billing_address']\n )",
"def test_create_invalid_price_higher_than_999(self)... | [
"0.6959924",
"0.68959254",
"0.68576455",
"0.6835606",
"0.67962855",
"0.6763143",
"0.6754872",
"0.6712775",
"0.670696",
"0.6699924",
"0.669079",
"0.6662048",
"0.6632659",
"0.66322994",
"0.6630322",
"0.66061264",
"0.6594423",
"0.65794605",
"0.65721965",
"0.65556145",
"0.6548419... | 0.8377441 | 0 |
Make sure related bills work | def test_add_related_bill():
b = toy_bill()
b.add_related_bill(
identifier="HB 2020", legislative_session="2011A", relation_type="companion"
)
assert len(b.related_bills) == 1
assert b.related_bills[0] == {
"identifier": "HB 2020",
"legislative_session": "2011A",
"rel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bidding_round_handle_transactions(self):\n self.order_1.save()\n self.order_2.save()\n self.order_3.save()\n self.order_4.save()\n self.order_5.save()\n self.order_6.save()\n self.order_7.save()\n self.order_8.save()\n self.order_9.save()\n ... | [
"0.6175008",
"0.59839773",
"0.59729123",
"0.57368916",
"0.5731432",
"0.5720903",
"0.5642837",
"0.56085277",
"0.5588224",
"0.55329233",
"0.55195403",
"0.5517622",
"0.55061704",
"0.5493753",
"0.54891664",
"0.5469919",
"0.54394513",
"0.5428492",
"0.54239583",
"0.54225034",
"0.54... | 0.6282879 | 0 |
Test that logging in as a new user creates a new docker service. | def test_creates_service(hub_service):
client = docker.from_env()
services_before_login = client.services.list()
# This request should create a new docker service to run the server for a-new-user
response = requests.post("http://127.0.0.1:8000/hub/login?next=", data={"username": "a-new-user", "passwor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_user(self):\n pass",
"def test_create_user(self):\n pass",
"def test_create_user(self):\n pass",
"def test_start_new_verification(self):\r\n user = UserFactory.create(username=\"rusty\", password=\"test\")\r\n self.client.login(username=\"rusty\", password=\... | [
"0.6685293",
"0.6685293",
"0.6685293",
"0.662675",
"0.6469443",
"0.64212",
"0.63803834",
"0.6281047",
"0.6267649",
"0.6201411",
"0.61628073",
"0.61608744",
"0.615122",
"0.6145756",
"0.61121744",
"0.6111382",
"0.6079029",
"0.6010172",
"0.6007868",
"0.59756124",
"0.596184",
"... | 0.7403956 | 0 |
Run the neural network as a subprocess. | def _run_neural_network(self):
program = ['mpiexec','-np',self._np,'python','./scripts/runClosedLoopNn.py',self._eesFreq,self._eesAmp,self._nnStructFile,self._species,self._totSimulationTime,self._perturbationParams]
self._neuralNetwork = subprocess.Popen(program, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stde... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n X_train, Y_train, y_train = load_batch(\"data_batch_1\")\n X_test, Y_test, y_test = load_batch(\"test_batch\")\n X_val, Y_val, y_val = load_batch((\"data_batch_2\"))\n\n X_train, X_train_mean, X_train_std = normalize(X_train)\n X_test = normalize_mean_std(X_test, X_train_mean, X_train_... | [
"0.65139234",
"0.63381696",
"0.6326427",
"0.6296576",
"0.627457",
"0.6172607",
"0.6143323",
"0.61160636",
"0.6070223",
"0.6062373",
"0.6032724",
"0.6025525",
"0.60128593",
"0.59977996",
"0.5979793",
"0.59712297",
"0.5965027",
"0.59492517",
"0.59252435",
"0.59130687",
"0.58754... | 0.8108845 | 0 |
Run webots as a subprocess | def _run_webots(self):
if self._experiment == "bed":
program = ["/Applications/Webots7/webots","--stdout","../../webots/worlds/743_formento_bed.wbt"]
elif self._experiment == "treadmill":
program = ["/Applications/Webots7/webots","--stdout","../../webots/worlds/743_formento_tbws.wbt"]
elif self._experiment ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runRobot():",
"def runmecall():\n os.system('sudo /home/pi/flask-video-streaming-v1.5/RunMe.sh')",
"def start_bot(self):\n self.proc = subprocess.Popen(\"./start\", stdin=subprocess.PIPE,\n\t\t\t\t\t\t\t\t\t stdout=subprocess.PIPE,\n\t\t\t\t\t\t\t\t\t cwd=os.path.abspath(self.path))",
"def webs... | [
"0.6531181",
"0.6097585",
"0.60131085",
"0.5871149",
"0.57693136",
"0.5732403",
"0.5684448",
"0.5672089",
"0.562822",
"0.5605895",
"0.5597993",
"0.55701894",
"0.55385846",
"0.550635",
"0.5503749",
"0.5501151",
"0.5478485",
"0.5470886",
"0.5463265",
"0.545501",
"0.544922",
"... | 0.8055326 | 0 |
Read the data coming from the webots controller. | def _wbt_read_data(self):
reaData = True
wbtIncomingData = False
wbtData = ""
while reaData:
wbtIncomingMsg = self._webots.stdout.readline().rstrip("\n").split()
if "COMM_OUT" in wbtIncomingMsg: wbtIncomingData = True
elif "END" in wbtIncomingMsg: reaData = False
elif wbtIncomingData: wbtData += " ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_data(self):",
"def read(self):",
"def read():\n # TODO",
"def read(self):\n pass",
"def read_data(self):\n raise NotImplementedError",
"def read_content(self):\n pass",
"def get_data_from_web():\n pass",
"def readOneData(self):\n\t\tpass",
"def read_data(self, l... | [
"0.66584593",
"0.64644367",
"0.6284747",
"0.62032473",
"0.60473686",
"0.6037577",
"0.59805804",
"0.59161663",
"0.5894147",
"0.5855311",
"0.5810196",
"0.58091164",
"0.57956994",
"0.57878864",
"0.57710856",
"0.57383895",
"0.57206744",
"0.57186884",
"0.5706663",
"0.57060796",
"0... | 0.6740469 | 0 |
Send webots' data to the neural network. | def _send_data_to_nn(self,wbtData):
self._neuralNetwork.stdin.write("COMM IN\n") # this shitty COMM IN is not really needed..to modify in closedloop.py
self._neuralNetwork.stdin.write(wbtData) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n\t\tself._run_neural_network()\n\t\tself._run_webots()\n\n\t\t# We first wait for webots inputs\n\t\twebotsTurn = True\n\t\tneuralNetworkTurn = False\n\t\twhile True:\n\t\t\tif webotsTurn:\n\t\t\t\tprint \"reading data from webots:\"\n\t\t\t\twbtData = self._wbt_read_data()\n\t\t\t\tprint \"sending... | [
"0.66242146",
"0.61485714",
"0.60616356",
"0.5903184",
"0.5718695",
"0.5693878",
"0.56667787",
"0.56667787",
"0.5643131",
"0.56267506",
"0.558443",
"0.5572693",
"0.5546241",
"0.5538926",
"0.5522096",
"0.55196345",
"0.5510155",
"0.5506162",
"0.5485437",
"0.5467363",
"0.5447285... | 0.62839013 | 1 |
Read the data coming form the neural network. | def _nn_read_data(self):
reaData = True
nnIncomingData = False
nnData = ""
while reaData and self._neuralNetwork.poll()==None:
nnIncomingMsg = self._neuralNetwork.stdout.readline().rstrip("\n").split()
if "COMM_OUT" in nnIncomingMsg: nnIncomingData = True
elif "END" in nnIncomingMsg: reaData = False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read():\n\n # load json and create model\n base_model = _model_builder.Network(0, model_type=\"load_model\")\n\n #load image and process\n digit = Image.open(\"./data/number.jpg\").convert(\"L\")\n digit = ImageOps.expand(digit,border=60,fill='black')\n digit = digit.resize((28, 28))\n\n #... | [
"0.7221467",
"0.6596244",
"0.6536683",
"0.653538",
"0.64975435",
"0.64378816",
"0.6265785",
"0.6263823",
"0.62479264",
"0.62405455",
"0.6219766",
"0.6184735",
"0.6122861",
"0.61192644",
"0.6112904",
"0.60669327",
"0.6044565",
"0.6025317",
"0.60169107",
"0.5997265",
"0.5908161... | 0.78346306 | 0 |
List all GoalProgress, or create a new GoalProgress. | def get(self, request, format = None):
goalProgress = GoalProgress.objects.all()
serializer = GoalProgressSerializer(goalProgress, many=True)
return Response(serializer.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self: \"InProgress\", progress: int = 0) -> None:\n self.progress = max(0, min(progress, 100))",
"def push_progress(self, status, object_id, progress):\n pass",
"def addAllProgressBar(self):\n all_run = sum(\n [\n self.run_dict[key][\"Progress\"]\n ... | [
"0.5440754",
"0.5276895",
"0.5266746",
"0.52662927",
"0.5265434",
"0.5219856",
"0.516846",
"0.5162692",
"0.5155152",
"0.5110558",
"0.5075913",
"0.5060737",
"0.50563693",
"0.50525624",
"0.50525624",
"0.5028871",
"0.5028524",
"0.49805808",
"0.4971807",
"0.49434188",
"0.49377668... | 0.6809591 | 0 |
Runs a command 'cmd' within an ssh connection. Upon success returns a list of lines from the output of the command. cmd mandatory string representing the command to be run against the remote ssh session verbose optional will default to global setting, can be set per cmd() as well here timeout optional integer used to t... | def cmd(self, cmd, verbose=None, timeout=120, listformat=False):
if verbose is None:
verbose = self.verbose
cmd = str(cmd)
t = None #used for timer
start = time.time()
output = []
if verbose:
self.debug( "[" + self.userna... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec_command(self, cmd, timeout=10):\n start = time()\n chan = self._ssh.get_transport().open_session()\n if timeout is not None:\n chan.settimeout(int(timeout))\n chan.exec_command(cmd)\n end = time()\n logger.trace('exec_command \"{0}\" on {1} took {2} sec... | [
"0.7692167",
"0.7318254",
"0.6974414",
"0.69679457",
"0.69009787",
"0.6828248",
"0.6775227",
"0.6700641",
"0.6522128",
"0.6465991",
"0.63532186",
"0.6318394",
"0.62847143",
"0.6265888",
"0.6262486",
"0.6243282",
"0.61692786",
"0.61637586",
"0.61160254",
"0.6105645",
"0.608253... | 0.81532127 | 0 |
This function mimics the bash command fs3cmd available in the fairusers_aws module on the FAIR cluster. Works on H2. Not tested on H1 this is a guess based on the definition in H2. | def fs3cmd(args):
os.environ["FAIR_CLUSTER_NAME"] = os.environ["FAIR_ENV_CLUSTER"].lower()
subprocess.check_call(["/public/apps/fairusers_aws/bin/fs3cmd"] + args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_s3_command(dataset, product, output_path='./', s3_sync=True):\n BASE_URL = 's3://stpubdata/hst/public/'\n \n if s3_sync == 'cp':\n cmd = 'aws s3 cp --request-payer requester {0}{1}/{2}/{2}_{3}.fits {4}/'.format(BASE_URL, dataset[:4].lower(), dataset.lower(), product.lower(), output_path)\n... | [
"0.5299197",
"0.50226414",
"0.5016781",
"0.49280542",
"0.48752022",
"0.48367625",
"0.47370374",
"0.47023085",
"0.46914586",
"0.4678361",
"0.46334416",
"0.462227",
"0.46189633",
"0.46102372",
"0.4593769",
"0.45906413",
"0.4577337",
"0.4573985",
"0.45729756",
"0.45546684",
"0.4... | 0.82234246 | 0 |
This allows an IR ARO to get their own details such as the electoral district they belong to and the polling districts under their control. | def get_my_details(self, request):
try:
user = request.user
staff = user.aro.staff
polling_districts = []
for pd in user.aro.polling_districts.all():
polling_districts.append(pd.polling_district)
polling_division = polling_districts[0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getInfo():\n\tcity_list_url = 'https://airnow.gov/index.cfm?action=airnow.local_state&stateid=5'\n\taq_info_url = 'https://airnow.gov/index.cfm?action=airnow.local_city&mapcenter=0&cityid='\n\tcity_list = []\n\tcity_name_list = []\n\tgetCityList(city_list, city_name_list, city_list_url)\n\tinfo = []\n\tgetAllA... | [
"0.5663855",
"0.55138344",
"0.54229933",
"0.5409267",
"0.5345916",
"0.53426963",
"0.5319705",
"0.5294409",
"0.5282497",
"0.52774864",
"0.526197",
"0.52570254",
"0.5207495",
"0.5205136",
"0.51875246",
"0.5177202",
"0.51544124",
"0.51467574",
"0.514669",
"0.5144349",
"0.5134696... | 0.5837514 | 0 |
Given a configuration dictionary return flags for the XST build if user flags are not specified take the default flags from site_scons/xst_default_flags.json | def get_xst_flags(config):
#print "Apply slave tags"
flags = {}
user_flags = {}
if "xst" in config.keys():
if "flags" in config["xst"].keys():
user_flags = config["xst"]["flags"]
fn = os.path.join(os.path.dirname(__file__), XST_DEFAULT_FLAG_FILE)
default_flags = json.load(op... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getdefflags(config_nm):\n if config_nm is 'train':\n user_params = user_params_train\n elif config_nm is 'eval':\n user_params = user_params_eval\n elif config_nm is 'tfrecorder':\n user_params = user_params_recorder\n else:\n print('Unrecognized configuration name : %s,... | [
"0.5856326",
"0.57966745",
"0.5700423",
"0.5476999",
"0.54227",
"0.5320488",
"0.5317347",
"0.5293593",
"0.525307",
"0.5230381",
"0.5162077",
"0.514846",
"0.509728",
"0.50937825",
"0.5085425",
"0.50502986",
"0.5047278",
"0.5047278",
"0.5017273",
"0.5016576",
"0.50126725",
"0... | 0.789345 | 0 |
Create an xst directiroy in the build folder | def create_xst_dir(config):
#Create a output directory if it does not exist
build_dir = utils.create_build_directory(config)
#Now I have an output directory to put stuff in
#Create an XST directory to put stuff related to XST
xst_dir = os.path.join(build_dir, XST_DIR)
if not os.path.exists(xst_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_xst_script(config):\n xst_abs_dir = create_xst_dir(config)\n flags = get_xst_flags(config)\n #print \"Flags: %s\" % str(flags)\n\n xst_dir = os.path.join(config[\"build_dir\"], XST_DIR)\n temp_dir = create_temp_dir(config)\n project_dir = os.path.join(xst_dir, PROJECT_FILENAME)\n\n ... | [
"0.6829207",
"0.6767734",
"0.65185505",
"0.587254",
"0.57758725",
"0.5764593",
"0.57134587",
"0.5710973",
"0.567468",
"0.565114",
"0.5647476",
"0.56292135",
"0.56022197",
"0.56010956",
"0.5584819",
"0.55694836",
"0.55437106",
"0.55184203",
"0.5513991",
"0.5492653",
"0.5418244... | 0.7496959 | 0 |
Create an xst temporary directory in the build folder | def create_temp_dir(config):
xst_dir = os.path.join(config["build_dir"], XST_DIR)
temp_dir = os.path.join(xst_dir, XST_TEMP_DIR)
temp_abs_dir = os.path.join(utils.get_project_base(), xst_dir, XST_TEMP_DIR)
if not os.path.exists(temp_abs_dir):
os.makedirs(temp_abs_dir)
return temp_dir | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_xst_dir(config):\n #Create a output directory if it does not exist\n build_dir = utils.create_build_directory(config)\n #Now I have an output directory to put stuff in\n #Create an XST directory to put stuff related to XST\n xst_dir = os.path.join(build_dir, XST_DIR)\n if not os.path.e... | [
"0.80544245",
"0.759219",
"0.7306151",
"0.7301406",
"0.71403354",
"0.7017957",
"0.6879915",
"0.6852833",
"0.68522996",
"0.6842682",
"0.68333536",
"0.68332696",
"0.6809047",
"0.68077433",
"0.6802132",
"0.6785533",
"0.67659724",
"0.67389554",
"0.67273563",
"0.67222214",
"0.6669... | 0.84921193 | 0 |
Given a configuration file create the .prj which holds the verilog filenames to be built | def create_xst_project_file(config):
#print "Creating xst project file"
xst_dir = create_xst_dir(config)
project_fn = os.path.join(xst_dir, PROJECT_FILENAME)
fp = open(project_fn, "w")
v = ""
#XXX: There should be allowances for adding different libraries in the future
for vf in config[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createCfg_project(self, jobOptions):\n last_line = '%s %s %s %s' % (jobOptions['projection_module'], self.era, jobOptions['histName'], jobOptions['outputFile'])\n if self.projection_module != 'puHist':\n last_line += ' %.6e' % jobOptions['ref_genWeight']\n lines = jobOptions['in... | [
"0.6347194",
"0.61011165",
"0.5976275",
"0.5926123",
"0.5904786",
"0.5896007",
"0.5847763",
"0.5847645",
"0.5847645",
"0.5847645",
"0.5824746",
"0.5819043",
"0.57901233",
"0.57586473",
"0.56815225",
"0.56808907",
"0.56678253",
"0.566736",
"0.56506085",
"0.5649789",
"0.5630688... | 0.7252458 | 0 |
Creates a library search order file location for the XST script This is to declutter the base directory | def create_lso_file(config):
xst_dir = os.path.join(config["build_dir"], XST_DIR)
lso_fn = os.path.join(xst_dir, XST_PROJECT_LSO)
xst_abs_dir = create_xst_dir(config)
fn = os.path.join(xst_abs_dir, XST_PROJECT_LSO)
#print "lSO filename: %s" % fn
fp = open(fn, "w")
#fp.write("DEFAULT_SEARCH_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _setLibraryRoot(self):\n\t\tself._libHome = os.path.abspath(rootDir)",
"def library_search_path(self, pedantic=False):\n return []",
"def library_dirs(self):",
"def create_xst_dir(config):\n #Create a output directory if it does not exist\n build_dir = utils.create_build_directory(config)\n ... | [
"0.61194116",
"0.60511726",
"0.60480165",
"0.5915033",
"0.5871853",
"0.5574441",
"0.55214137",
"0.5512927",
"0.55123276",
"0.5492987",
"0.54900146",
"0.5480147",
"0.54535997",
"0.5416187",
"0.53785366",
"0.53417236",
"0.53226453",
"0.5260737",
"0.5245522",
"0.5234602",
"0.521... | 0.60697126 | 1 |
Format an integer as a IPv6 string | def format_ipv6(value, mask):
value_ipv6 = ":".join(re.findall('..', "{:032x}".format(value)))
if mask is None:
return value_ipv6
value_mask = ":".join(re.findall('..', "{:032x}".format(mask)))
return "{}/{}".format(value_ipv6, value_mask) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ipv6_to_ipv4(ipv6_str):\n return '.'.join([str(b) for b in ipv6_str[12:]])",
"def int2ip(n: int) -> str:\n return socket.inet_ntoa(struct.pack(\"!I\", n))",
"def ipwrap(address: Any) -> str:\n try:\n if not isinstance(address, int):\n ipaddress.IPv6Address(address)\n r... | [
"0.684875",
"0.6847101",
"0.67964345",
"0.6782009",
"0.67144775",
"0.6704091",
"0.66590625",
"0.65081716",
"0.6469438",
"0.63565856",
"0.63354623",
"0.6289769",
"0.6272364",
"0.6267752",
"0.62631285",
"0.6259804",
"0.62279546",
"0.6136622",
"0.6107135",
"0.6043798",
"0.600751... | 0.7999735 | 0 |
Format an integer as a IPv4 string | def format_ipv4(value, mask=None):
value_ipv4 = ".".join([str(int(x, 16)) for x in re.findall('..', "{:08x}".format(value))])
if mask is None:
return value_ipv4
value_mask = ".".join([str(int(x, 16)) for x in re.findall('..', "{:08x}".format(mask))])
return "{}/{}".format(value_ipv4, value_mask) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_ipv4_to_str(n_int):\n return \".\".join([str(n_int >> n & 0xFF) for n in [24, 16, 8, 0]])",
"def int_ip_to_ip_str(ip_integer, ipv4=True):\n ip_byte_strings = []\n if ipv4:\n for i in range(3, -1, -1):\n byte = (ip_integer >> (i * 8)) & 0xFF\n ip_byte_strings.appe... | [
"0.7823642",
"0.7542794",
"0.73373216",
"0.7335863",
"0.7221276",
"0.70869535",
"0.6930596",
"0.6857159",
"0.6788355",
"0.66968757",
"0.6680628",
"0.6627507",
"0.6536425",
"0.6509217",
"0.64550817",
"0.64375126",
"0.64161605",
"0.63167006",
"0.6314882",
"0.6271475",
"0.625808... | 0.7827403 | 0 |
Get a list of SQL file paths based on parameters. | def get_sql_files(root=".", filterl=None, exclude=None):
paths = Path(root).rglob("*.sql")
if root:
if filterl:
return [
str(path)
for path in paths
if any(
re.match(path.parts[-2], name, re.IGNORECASE) for name in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_init_sql_files(custom_files: Optional[List[str]] = None) -> List[str]:\n # Common files.\n files = [\n os.path.join(os.path.dirname(__file__), \"../db/sql\", filename)\n for filename in (\n \"types.sql\",\n \"static.sql\",\n \"kibot.sql\",\n \... | [
"0.68614507",
"0.6355949",
"0.6283985",
"0.6162689",
"0.60923386",
"0.6040484",
"0.5923868",
"0.58959734",
"0.5869344",
"0.58370805",
"0.57662976",
"0.5747081",
"0.5650686",
"0.5640019",
"0.5611626",
"0.5608685",
"0.5604054",
"0.5587391",
"0.55654347",
"0.5548227",
"0.5509699... | 0.7004922 | 0 |
Get a runset of runner file path and SQL file names in the same directory. | def get_run_set(bdir, runs):
path = Path(bdir)
dirs = [unit for unit in path.iterdir() if unit.is_dir()]
run_set = [
(
"".join(list(map(str, (Path(dir).rglob(runs))))),
list(map(lambda sqlfile: sqlfile.name, (Path(dir).rglob("*.sql")))),
)
for dir in d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runs_loader(path):\n files = sorted(glob.glob(f\"{path}/*_runs.csv\"))\n df_lis = list(range(len(files)))\n for i, f in enumerate(files):\n try:\n df_lis[i] = pd.read_csv(f, sep=\",\", header=0)\n print('Read runs.csv\\n', f, df_lis[i].shape,\n df_lis[i]['... | [
"0.62455094",
"0.6202047",
"0.58496845",
"0.58378494",
"0.55996996",
"0.55756927",
"0.5515939",
"0.54770476",
"0.5462655",
"0.54617625",
"0.54517585",
"0.5427877",
"0.5372713",
"0.5371301",
"0.53358495",
"0.5334587",
"0.5320825",
"0.525531",
"0.52426225",
"0.52390087",
"0.523... | 0.7739845 | 0 |
Parse given runset to get collections of valid SQL `exa_run` cmds, SQL file names in directory, path to runner and wrong `exa_run` cmds in runner. | def parse_run_set(rset, ptrn_exarun, ptrn_valid, ptrn_sql):
valid_sqls = []
wrong_runs = []
sqlsl = None
runf = None
for runf, sqlsl in rset:
exa_runs = re.findall(ptrn_exarun, Path(runf).read_text(), re.I | re.M)
for exa_run in exa_runs:
if re.match(ptrn_valid, e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_run_set(bdir, runs):\r\n path = Path(bdir)\r\n dirs = [unit for unit in path.iterdir() if unit.is_dir()]\r\n run_set = [\r\n (\r\n \"\".join(list(map(str, (Path(dir).rglob(runs))))),\r\n list(map(lambda sqlfile: sqlfile.name, (Path(dir).rglob(\"*.sql\")))),\r\n ... | [
"0.66888875",
"0.5720118",
"0.53700846",
"0.52193743",
"0.5191989",
"0.5093926",
"0.5081452",
"0.50164145",
"0.5011747",
"0.50086933",
"0.494051",
"0.49007207",
"0.4887897",
"0.48654652",
"0.48530355",
"0.482971",
"0.4826515",
"0.4784667",
"0.47633275",
"0.47562602",
"0.47471... | 0.7797407 | 0 |
Reads a SQL file under given path and checks if each command contains required command. | def assert_sql_contains_only(path, cmds, exclude=False):
_, stmts, _ = parse_sql(path, DDL)
for cmd in cmds:
for stmt in stmts:
check = check_stmt(stmt, [cmd], exclude)
if exclude:
assert check, f"{path} should not contain {cmd} statement(s)!"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sql_from_file(self, sql_path):\n with open(sql_path, 'r') as f:\n sql = \"\"\n for line in f.readlines():\n line = line.strip()\n if not line.startswith(\"--\"):\n sql += \" \" + line\n return sql",
"def read_sql_from_fi... | [
"0.6486093",
"0.63021475",
"0.61518323",
"0.6104002",
"0.60762346",
"0.59611636",
"0.5958177",
"0.5883332",
"0.58813083",
"0.58169925",
"0.57966363",
"0.57161856",
"0.5711777",
"0.56983334",
"0.56913865",
"0.5605706",
"0.55455047",
"0.55114836",
"0.5481842",
"0.5462425",
"0.5... | 0.67594486 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.