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 |
|---|---|---|---|---|---|---|
Feed text to the terminal, optionally coloured. | def feed(self, text, color=None):
if color is not None:
text = '\x1b[%sm%s\x1b[0m' % (color, text)
self.__term.feed(text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def echo(self, *args, **kwargs):\n text = \" \".join([str(item) for item in args])\n color = kwargs.get(\"color\", 32)\n sys.stdout.write(\"\\033[0;%dm%s\\033[0;m\" % (color, text))",
"def printcolor(color, text):\r\n pushcolor()\r\n setcolor(color)\r\n print text\r\n popcolor()",
"def _co... | [
"0.6622924",
"0.64206886",
"0.6357258",
"0.63003796",
"0.62403524",
"0.61998284",
"0.60963345",
"0.60852623",
"0.60215306",
"0.6020209",
"0.6004267",
"0.6002754",
"0.5989186",
"0.5984307",
"0.59810245",
"0.5946202",
"0.59064716",
"0.5834519",
"0.58303183",
"0.5786412",
"0.578... | 0.7780883 | 0 |
Preconfigured to connect to PostgreSQL. Returns connection and cursor. con, cur = connect_to_postgres() | def connect_to_postgres():
con = pg2.connect(host='this_postgres', user='postgres', database='postgres',password='example')
return con, con.cursor() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect():\r\n params = config()\r\n print('Connecting to the PostgreSQL database...')\r\n global conn\r\n conn = psycopg2.connect(**params)",
"def connect_to_postgres():\n postgres_creds = os.environ.get(\"POSTGRES_CREDS\")\n if not postgres_creds:\n postgres_creds = get_secret(\"PO... | [
"0.821492",
"0.8112321",
"0.8090787",
"0.8043392",
"0.80347914",
"0.80050254",
"0.7983001",
"0.79172885",
"0.7913603",
"0.79050726",
"0.78884816",
"0.7870761",
"0.7823819",
"0.78230494",
"0.78003716",
"0.7787864",
"0.77691585",
"0.7757965",
"0.77485025",
"0.773814",
"0.773206... | 0.816965 | 1 |
For compatibility with TextStringObject.original_bytes. | def original_bytes(self) -> bytes:
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def original_bytes(self) -> bytes:\n return self.get_original_bytes()",
"def from_bytes(self, ???):",
"def update_bytes_array(self):\n self.bytes = data_manipulation.convert_from_binary_array(self.binary_array)",
"def as_bytes(self) -> bytes:\n if isinstance(self.data, bytes):\n ... | [
"0.7931252",
"0.6291889",
"0.5968287",
"0.5956458",
"0.59013546",
"0.58908886",
"0.58832973",
"0.5871968",
"0.58539855",
"0.58534294",
"0.58392596",
"0.58381903",
"0.58164644",
"0.581248",
"0.58019733",
"0.57938397",
"0.5748567",
"0.57467866",
"0.5733384",
"0.5726523",
"0.572... | 0.7821226 | 1 |
It is occasionally possible that a text string object gets created where a byte string object was expected due to the autodetection mechanism if that occurs, this "original_bytes" property can be used to backcalculate what the original encoded bytes were. | def original_bytes(self) -> bytes:
return self.get_original_bytes() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def original_bytes(self) -> bytes:\n return self",
"def original_value(self):\n if not self.has_data:\n return None\n elif self.is_unknown or self.is_byte:\n return ida_bytes.get_original_byte(self.ea)\n elif self.is_word:\n return ida_bytes.get_origin... | [
"0.7318566",
"0.59987754",
"0.5761928",
"0.5738067",
"0.56802696",
"0.5621293",
"0.5587641",
"0.55251056",
"0.55210185",
"0.5502626",
"0.55021554",
"0.547816",
"0.54478115",
"0.54240817",
"0.54224706",
"0.5400651",
"0.5400651",
"0.53949475",
"0.5370121",
"0.53674865",
"0.5363... | 0.76152307 | 0 |
Retrieve XMP (Extensible Metadata Platform) data relevant to the this object, if available. | def xmp_metadata(self) -> Optional[PdfObject]:
from .xmp import XmpInformation
metadata = self.get("/Metadata", None)
if metadata is None:
return None
metadata = metadata.get_object()
if not isinstance(metadata, XmpInformation):
metadata = XmpInformation... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_metadata(self):\n return self.manager.get_metadata(self)",
"def get(self):\n return self._metadata",
"def get_metadata(self):\n return self._metadata",
"def get_metadata(self):\n url = 'https://www150.statcan.gc.ca/t1/wds/rest/getCubeMetadata'\n payload = [{'product... | [
"0.63130367",
"0.60853153",
"0.6084812",
"0.60322475",
"0.59912574",
"0.59872407",
"0.5919401",
"0.58863306",
"0.58826417",
"0.58561164",
"0.5853561",
"0.5828157",
"0.58194375",
"0.5790405",
"0.57841855",
"0.5768726",
"0.57628536",
"0.5761602",
"0.5759693",
"0.5746377",
"0.57... | 0.71648496 | 0 |
Given a string, create a ByteStringObject or a TextStringObject to represent the string. | def create_string_object(
string: Union[str, bytes],
forced_encoding: Union[None, str, List[str], Dict[int, str]] = None,
) -> Union[TextStringObject, ByteStringObject]:
if isinstance(string, str):
return TextStringObject(string)
elif isinstance(string, bytes_type):
if isinstance(forced_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_str(cls, string):",
"def from_string(cls, string):\n normalised = cls.normalise_string(string)\n return cls.from_normalised_string(normalised)",
"def fromString(cls, string):\n raise NotImplementedError(\n 'fromString is not implemented on %r' % (cls.__name__,))",
"de... | [
"0.7150578",
"0.69376075",
"0.69042987",
"0.6834089",
"0.6633464",
"0.6522328",
"0.6451764",
"0.6441739",
"0.6422768",
"0.63782126",
"0.63351977",
"0.62770694",
"0.6270792",
"0.625477",
"0.6189757",
"0.61865085",
"0.6179451",
"0.6178204",
"0.6153092",
"0.61475366",
"0.6131635... | 0.80600077 | 0 |
Converts arguments to a list | def convert_to_list(*args):
converted_list = []
for arg in args:
if isinstance(arg, list):
converted_list.extend(arg)
else:
converted_list.append(arg)
return converted_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arg_to_str_list(self) -> list:\n arg_list = []\n for arg in [*self.args]:\n if hasattr(arg, \"_ref\"):\n arg_list.append(arg.ref)\n else:\n arg_list.append(arg)\n return arg_list",
"def arglist(self) -> List:\n return self.argv[1... | [
"0.77689946",
"0.76700544",
"0.74144566",
"0.73685265",
"0.7333477",
"0.71985704",
"0.7191028",
"0.7151536",
"0.7028118",
"0.69829696",
"0.6883548",
"0.68657553",
"0.68619275",
"0.68552107",
"0.6844894",
"0.6798944",
"0.67582643",
"0.6755015",
"0.675383",
"0.67429656",
"0.672... | 0.76795894 | 1 |
Function to define a directed edge.Inputs are start vertex, end vertex and edge weight. | def __init__(self, startVertex, endVertex, edgeWeight):
self.startVertex = startVertex
self.endVertex = endVertex
self.edgeWeight = edgeWeight | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, graph, head_vertex, tail_vertex, weight):\n super(DirectedWeightedGraphEdge, self).__init__(\n graph, head_vertex, tail_vertex)\n self.weighted = True\n self.weight = weight",
"def add_edge(self, start_node, label, end_node, properties=None, **kwargs):\r\n\t\tif... | [
"0.6709069",
"0.66184264",
"0.66151136",
"0.65752894",
"0.65585893",
"0.6528305",
"0.65211207",
"0.6411849",
"0.6397351",
"0.63393235",
"0.63223445",
"0.63036877",
"0.6285012",
"0.6268333",
"0.6232148",
"0.62255114",
"0.6224129",
"0.6222099",
"0.61575484",
"0.6143384",
"0.612... | 0.66675925 | 1 |
Function to store/update current dijkstra criterion for edge. | def setDijkstraCriterion(self, dijkstraCriterion):
self.dijkstraCriterion = dijkstraCriterion | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dijkstra(self,start):\n path_weight = {i : float('inf') for i in range(self.n)}\n path_weight[start] = 0\n previous = {i : float('nan') for i in range(self.n)}\n remaining = PriorityQueue()\n for node,priority in path_weight.items():\n remaining.put((priority,node)... | [
"0.56717396",
"0.5586178",
"0.55331147",
"0.5530985",
"0.55005115",
"0.5455265",
"0.5428659",
"0.52848774",
"0.5283113",
"0.52777237",
"0.5271241",
"0.5260517",
"0.5260413",
"0.5249254",
"0.52415615",
"0.52400994",
"0.5223231",
"0.52225786",
"0.5210995",
"0.51972514",
"0.5194... | 0.63414305 | 0 |
Initializes heap instance.Inputs are no of elements in heap and limit of restructuring of heap. | def __init__(self, noOfElements, limitOfRestructuring):
self.heap = [ 'NaN' ] * noOfElements
self.noOfElements = noOfElements
self.i = 1
self.noOfRemovedElements = 0
self.limitOfRestructuring = limitOfRestructuring | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.min_heap = []\n self.max_heap = []\n self.size_max, self.size_min = 0, 0",
"def __init__(self, heap=[]):\n\n # logger_cagada.debug(\"pero si el orig heap %s\" % heap)\n heapq.heapify(heap)\n # logger_cagada.debug(\"a cihnga el heap %s\" % heap)... | [
"0.7872689",
"0.78718746",
"0.77746433",
"0.7703879",
"0.7700862",
"0.7640832",
"0.76038057",
"0.7587779",
"0.7543796",
"0.74869823",
"0.7466747",
"0.74636537",
"0.7434665",
"0.7433525",
"0.741593",
"0.741593",
"0.741593",
"0.74121726",
"0.7400985",
"0.7385111",
"0.7349339",
... | 0.8127257 | 0 |
Function to insert an element in the heap.Input is element to be added and i is the value returned from getI() function | def insertElement(self, element , i ):
self.heap[i] = element
# Parent of ith position
parenti = i // 2
# Inserting element into the heap
try:
# Bubbling up
if parenti != 0 and self.heap[i].dijkstraCriterion < self.heap[parenti].dijkstraCriterion:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self, i, x) -> None:\n pass",
"def insert(self, element):\n if self.size >= self.maxsize : \n return\n self.size+= 1\n self.Heap[self.size] = element \n \n current = self.size \n \n while self.Heap[current] < self.Heap[self.parent(current)]: \n ... | [
"0.73610723",
"0.7255235",
"0.7066214",
"0.7024207",
"0.69818157",
"0.6966509",
"0.6947374",
"0.684332",
"0.68415344",
"0.68343455",
"0.6796733",
"0.6793265",
"0.6771656",
"0.67460096",
"0.67460096",
"0.67280835",
"0.66908896",
"0.6680426",
"0.6617264",
"0.66159266",
"0.66109... | 0.8248737 | 0 |
Function to restructure heap to store elements in a continuous fashion in the list. | def restructureHeap(self):
self.i = 1
# Storing the elements that already exist in a temporary list
tempList = []
for heapElement in self.heap:
if heapElement != "NaN" :
tempList.append( heapElement )
# Initializing new heap
self.heap = ["NaN... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_heap(data):\n size = len(data)\n for i in range(size//2, -1,-1):\n shiftDown(data, i)",
"def _heapify(self):\n start = self._parent(len(self) - 1)\n for i in range(start, -1, -1):\n self._down_heap(i)",
"def buildHeap(self, alist):\n i = len(alist) // 2\n ... | [
"0.75522405",
"0.7437871",
"0.72836965",
"0.7224376",
"0.71689165",
"0.71542585",
"0.7145125",
"0.7145125",
"0.7111045",
"0.6952901",
"0.69036293",
"0.6897025",
"0.689172",
"0.68875325",
"0.6880433",
"0.67749697",
"0.6733229",
"0.67183167",
"0.66768026",
"0.65680516",
"0.6539... | 0.8265854 | 0 |
This function gets districts from state id | def load_districts(self):
response = requests.get("https://cdn-api.co-vin.in/api/v2/admin/location/districts/{}".format(self.state_id))
if response.ok:
df = pd.DataFrame(json.loads(response.text)["districts"])
self.districts_df = df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_district_ids(self, outputfolder):\n if not os.path.exists(outputfolder):\n os.makedirs(outputfolder)\n logger.info(\"Finding the States\")\n api = '/api/v2/admin/location/states'\n self.requestfunc(api)\n states = self.output['states']\n for state in st... | [
"0.7186166",
"0.6487493",
"0.6468509",
"0.6447121",
"0.64421237",
"0.63141286",
"0.62383133",
"0.6232772",
"0.62168545",
"0.6134443",
"0.60641253",
"0.6048713",
"0.6014922",
"0.599199",
"0.5975057",
"0.59658146",
"0.5943173",
"0.59303325",
"0.5918072",
"0.5912696",
"0.5905201... | 0.7419599 | 0 |
This function returns district id by name | def get_districtid_by_name(self, dname):
dname = process.extractOne(dname, self.districts_df["district_name"].tolist())
district_id = self.districts_df.loc[self.districts_df.district_name == dname[0],["district_id"]].values[0][0]
return district_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def district(self) -> str:\n return pulumi.get(self, \"district\")",
"def find_district_id(self, centroid, country_iso2):\n admin1_id = None\n country_id = Country.objects.get(iso=country_iso2)\n if country_id is not None:\n districts = District.objects.filter(country_id=co... | [
"0.661717",
"0.6293855",
"0.62194145",
"0.6191592",
"0.60643977",
"0.59079",
"0.58776575",
"0.5866809",
"0.58445525",
"0.5802834",
"0.5738989",
"0.570734",
"0.5647626",
"0.5633247",
"0.56203216",
"0.55725527",
"0.55521965",
"0.55499357",
"0.55360484",
"0.55298436",
"0.5502584... | 0.8112864 | 0 |
Counts the number of packets the host has sent to or received from different countries. If an ip address cannot be mapped to a country it is mapped to unknown. | def get_country_to_packet_count(stream):
# Get dictionary of ip addresses to counts, minus host IP address
ip_counts = get_ip_to_packet_count(stream)
host_ip_addr = get_host_ip_addr(stream, ip_counts)
ip_counts.pop(host_ip_addr, None)
# Coalesce country packet counts using ip count dict
countr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_country_to_traffic_size(stream):\n\n # Get dictionary of ip addresses to counts, minus host IP address\n ip_traffic_size = get_ip_to_total_traffic_size(stream)\n host_ip_addr = get_host_ip_addr(stream)\n ip_traffic_size.pop(host_ip_addr, None)\n\n # Coalesce country packet counts using ip co... | [
"0.61417985",
"0.57963526",
"0.5614256",
"0.5502428",
"0.5451923",
"0.53911674",
"0.5378044",
"0.5332435",
"0.5274192",
"0.526601",
"0.5259852",
"0.52389663",
"0.522042",
"0.51905954",
"0.5184138",
"0.5169154",
"0.51253057",
"0.5075679",
"0.5039514",
"0.5036074",
"0.503354",
... | 0.70671797 | 0 |
Size of traffic in bytes that the host has sent to or received from different countries. If an ip address cannot be mapped to a country it is mapped to unknown. | def get_country_to_traffic_size(stream):
# Get dictionary of ip addresses to counts, minus host IP address
ip_traffic_size = get_ip_to_total_traffic_size(stream)
host_ip_addr = get_host_ip_addr(stream)
ip_traffic_size.pop(host_ip_addr, None)
# Coalesce country packet counts using ip count dict
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SendPacketsSendSize(self) -> int:",
"def network_byte_length(self) -> int:",
"def get_country_to_packet_count(stream):\n\n # Get dictionary of ip addresses to counts, minus host IP address\n ip_counts = get_ip_to_packet_count(stream)\n host_ip_addr = get_host_ip_addr(stream, ip_counts)\n ip_cou... | [
"0.6398226",
"0.61363876",
"0.6099843",
"0.6062257",
"0.60615194",
"0.5848977",
"0.5731435",
"0.57133996",
"0.56278896",
"0.5581301",
"0.557631",
"0.5548331",
"0.5506326",
"0.54859084",
"0.547608",
"0.54748625",
"0.5441086",
"0.5426974",
"0.5387034",
"0.5376259",
"0.5366806",... | 0.6974524 | 0 |
Consolidates all known country data | def consolidate_country_data(stream):
country_data = {}
country_traffic_size = get_country_to_traffic_size(stream)
country_packet_count = get_country_to_packet_count(stream)
for country in country_traffic_size:
data = {}
data[PACKET_COUNT] = country_packet_count[country]
data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_data(self):\n for country in config.COUNTRIES:\n frames = []\n for year in config.years:\n incidence_path = (config.raw_data_path / country / 'complete'\n / (str(year) + '_' + str(year + 1) + '.csv'))\n\n if inc... | [
"0.65126336",
"0.6215403",
"0.61436677",
"0.61359936",
"0.6061766",
"0.60500836",
"0.6036935",
"0.5883955",
"0.5878647",
"0.57248145",
"0.56951463",
"0.5691833",
"0.56470484",
"0.5626918",
"0.559479",
"0.5589749",
"0.55401516",
"0.5532587",
"0.551245",
"0.5497665",
"0.5477871... | 0.6768704 | 0 |
Return from Lengow api all the orders made between start_date and end_date. | def get_orders_from_lengow(
start_date, end_date, account_id=ACCOUNT_ID, group_id=GROUP_ID, flux_id=FLUX_ID,
order_status="all", response_format="json"):
date_range = "{start_date:{df}}/{end_date:{df}}".format(
start_date=start_date, end_date=end_date, df="%Y-%m-%d")
flux_filter = "{... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_orders(access_token,start_date,end_date,status):\r\n\r\n orders_url = 'https://api.tdameritrade.com/v1/orders'\r\n headers={'Authorization': 'Bearer {}'.format(access_token)}\r\n #Parameters for the order\r\n params = {'accountId':TDAuth_Info.account_num,\r\n 'fromEnteredTime': sta... | [
"0.73048484",
"0.73011917",
"0.72144336",
"0.6945817",
"0.68958193",
"0.6753824",
"0.6610979",
"0.6488968",
"0.6465952",
"0.64019245",
"0.6384681",
"0.63700753",
"0.6364585",
"0.6363227",
"0.6230252",
"0.62262523",
"0.61927116",
"0.6180983",
"0.61612535",
"0.61421907",
"0.610... | 0.73980206 | 0 |
Process the data returned by Lengow api, to adapat it for the AWS CreateFulfillmentOrder. | def create_aws_order(lengow_order, order_id):
if (
lengow_order["marketplace"] in not_allowed_marketplaces or
lengow_order["order_status"]["lengow"] != "processing"):
return
# Data that will be sent to AWS CreateFulfillmentOrder method
aws_order_data = {}
aws_order_data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def handle_new_order_response(self, response: RequesterResponse\n ) -> HitbtcOrderModel:",
"def _handle_orders(self, response):\n response_type = response['type']\n state_updated = False\n if response_type == \"subscription_ack\":\n # I... | [
"0.65515363",
"0.6522039",
"0.64888304",
"0.6388835",
"0.6372217",
"0.6331766",
"0.62192327",
"0.62086433",
"0.6155687",
"0.61340165",
"0.6111006",
"0.5872786",
"0.5871076",
"0.5866634",
"0.586624",
"0.5839183",
"0.5835567",
"0.5827201",
"0.5826598",
"0.58086604",
"0.57943404... | 0.6579663 | 0 |
Custom variable getter that forces trainable variables to be stored in float32 precision and then casts them to the training precision. | def float32_variable_storage_getter(getter, name, shape=None, dtype=None,
initializer=None, regularizer=None,
trainable=True,
*args, **kwargs):
storage_dtype = tf.float32 if trainable else dtype
variable ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _float_feature(value):\n\treturn tf.train.Feature(float_list=tf.train.FloatList(value=[value]))",
"def _float_feature(value):\n return tf.train.Feature(float_list=tf.train.FloatList(value=value))",
"def _float_feature(value):\n return tf.train.Feature(float_list=tf.train.FloatList(value=value))",
"de... | [
"0.5975389",
"0.5938216",
"0.59241956",
"0.59241956",
"0.59009546",
"0.58934057",
"0.5891106",
"0.5882261",
"0.5882261",
"0.5882261",
"0.5882261",
"0.5882261",
"0.58691907",
"0.58691907",
"0.58691907",
"0.5824527",
"0.5776878",
"0.57477236",
"0.56837136",
"0.5644709",
"0.5643... | 0.6551529 | 0 |
Gets number of PDElements in active circuit. | def pdelements_count(self) -> int:
return self.dss_obj.PDElementsI(ctypes.c_int32(0), ctypes.c_int32(0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNumActive(self):\n return self._get_active( )",
"def pdelements_num_customers(self) -> int:\n return self.dss_obj.PDElementsI(ctypes.c_int32(4), ctypes.c_int32(0))",
"def element_count(self):\n return self._internal.get_element_count()",
"def pdelements_total_customers(self) -> in... | [
"0.67781013",
"0.6762339",
"0.6673967",
"0.6623951",
"0.65708965",
"0.65262514",
"0.64347017",
"0.64307946",
"0.64174765",
"0.6392291",
"0.6362646",
"0.6274327",
"0.6267513",
"0.6212998",
"0.62069196",
"0.6176611",
"0.6151829",
"0.61384267",
"0.61319375",
"0.61292356",
"0.611... | 0.7770808 | 0 |
Sets returns 1 if the PD element should be treated as a shunt element rather than a series element. Applies to capacitor and reactor elements in particular. | def pdelements_is_shunt(self) -> int:
return self.dss_obj.PDElementsI(ctypes.c_int32(3), ctypes.c_int32(0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isSetValue(self):\n return _libsbml.FluxBound_isSetValue(self)",
"def isSetValue(self):\n return _libsbml.SpeciesFeatureValue_isSetValue(self)",
"def setDrumType(self):\n\n if self.channel:\n error(\"You cannot change a track to DRUM once it has been used\")\n\n self.... | [
"0.5308057",
"0.50828123",
"0.5049454",
"0.49635267",
"0.47305813",
"0.47305813",
"0.47305813",
"0.47305813",
"0.47305813",
"0.47305813",
"0.4727102",
"0.46746454",
"0.4655441",
"0.46332616",
"0.46332616",
"0.46305537",
"0.46106032",
"0.45879367",
"0.4573778",
"0.45669994",
"... | 0.6013604 | 0 |
Gets the parent PD element to be the active circuit element. Returns 0 if no more elements upline. | def pdelements_parent_pd_element(self) -> int:
return self.dss_obj.PDElementsI(ctypes.c_int32(6), ctypes.c_int32(0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_parent(self):\n return self._find_by_locator().parent",
"def _get_parent(self, child_ix):\n if child_ix == 0:\n return None\n t = 1 if child_ix & 1 else 2\n return (child_ix - t) / 2",
"def parent(self, index):\n if index == 0:\n print(\"index 0 ... | [
"0.67082757",
"0.6586696",
"0.65853965",
"0.6575277",
"0.6525648",
"0.6486131",
"0.6461263",
"0.64561963",
"0.64538085",
"0.645137",
"0.64039505",
"0.63930196",
"0.63930196",
"0.6389424",
"0.6380705",
"0.636917",
"0.6367585",
"0.6332101",
"0.6332101",
"0.6332101",
"0.6324627"... | 0.74474406 | 0 |
Gets the number of the terminal of active PD element that is on the "from" side. This is set after the meter zone is determined. | def pdelements_from_terminal(self) -> int:
return self.dss_obj.PDElementsI(ctypes.c_int32(7), ctypes.c_int32(0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current(self):\n return self.node.sdo[0x221c].phys # mA",
"def read_current_stepsize(self):\n function_string = 'DELTAI' + self.output + '?'\n return self.scpi_comm(function_string)",
"def getNumActive(self):\n return self._get_active( )",
"def getPlungerPos(self):\n ... | [
"0.60825145",
"0.5865261",
"0.5603476",
"0.55617607",
"0.5542426",
"0.55111235",
"0.5410498",
"0.540583",
"0.53970623",
"0.5295192",
"0.5291269",
"0.52739096",
"0.5265048",
"0.52591",
"0.5257556",
"0.5252305",
"0.524203",
"0.5230821",
"0.5213554",
"0.52052367",
"0.5203081",
... | 0.6026718 | 1 |
Return decoded bytes data handling data written by java apps. | def _decode_binary(data):
try:
data = data.decode('utf-8')
except UnicodeDecodeError: # pragma: no cover
# for data written an upstream java App
data = data.decode('latin-1')
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode(self, data: bytes) -> bytes:\n ...",
"def decode(data): #@NoSelf",
"def decode(data):\n raise NotImplementedError",
"def bdecode_buffer(data):\n\tif isinstance(data, str):\n\t\tdata = data.encode()\n\twith BytesIO(data) as f:\n\t\treturn bdecode(f)",
"def raw_data(self):\n r... | [
"0.66809773",
"0.6650789",
"0.6392689",
"0.6290818",
"0.6075159",
"0.60708433",
"0.6000168",
"0.5989534",
"0.5971327",
"0.5942265",
"0.58939415",
"0.58909184",
"0.58824676",
"0.5867701",
"0.58589035",
"0.58589035",
"0.58568764",
"0.5813299",
"0.58129126",
"0.5780577",
"0.5768... | 0.70040286 | 0 |
Return True if provided data has proper structure for Key Value. | def _is_key_value(data):
if data is None:
return False
return all(x in data for x in ['key', 'value']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_key_value_array(self, data):\n for d in data:\n if not self._is_key_value(d):\n return False\n return True",
"def is_data_true(data):\n\n if not data:\n return False\n\n if not isinstance(data, dict):\n if not util.get_value_from_health_internal... | [
"0.7729435",
"0.7524385",
"0.6891004",
"0.682319",
"0.6766434",
"0.6744951",
"0.6598444",
"0.6588553",
"0.6563777",
"0.6562067",
"0.6550974",
"0.6541318",
"0.6500761",
"0.64796764",
"0.6453066",
"0.643909",
"0.6424107",
"0.63941187",
"0.6377569",
"0.63756615",
"0.63675785",
... | 0.8250224 | 0 |
Return True if provided data has proper structure for Key Value Array. | def _is_key_value_array(self, data):
for d in data:
if not self._is_key_value(d):
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_key_value(data):\n if data is None:\n return False\n return all(x in data for x in ['key', 'value'])",
"def _is_DataArrays(data):\n if isinstance(data, (Dataset, DataArray)):\n return True\n if isinstance(data, Mapping):\n for da in data.values... | [
"0.7309788",
"0.6849548",
"0.66966134",
"0.66381246",
"0.6612501",
"0.6579229",
"0.6545586",
"0.6437106",
"0.64228755",
"0.6403405",
"0.6401595",
"0.62689126",
"0.62642026",
"0.6219466",
"0.6209797",
"0.61530024",
"0.61085993",
"0.6055162",
"0.6040287",
"0.6025469",
"0.601294... | 0.8949254 | 0 |
Return True if provided data has proper structure for TC Entity. | def _is_tc_entity(data):
if data is None:
return False
return all(x in data for x in ['id', 'value', 'type']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_tc_entity_array(self, data):\n for d in data:\n if not self._is_tc_entity(d):\n return False\n return True",
"def is_valid_entity(self):\n return is_correct_cve_id(self.cve_id)",
"def isEntity(*args):\n return _libsbml.SBO_isEntity(*args)",
"def i... | [
"0.7894132",
"0.65946406",
"0.63335603",
"0.628487",
"0.62005854",
"0.61894",
"0.6154285",
"0.61466116",
"0.61183137",
"0.6106153",
"0.6066464",
"0.606181",
"0.60554606",
"0.60439426",
"0.6031995",
"0.60312456",
"0.6023757",
"0.60151803",
"0.5897398",
"0.5882162",
"0.5859692"... | 0.85349506 | 0 |
Return True if provided data has proper structure for TC Entity Array. | def _is_tc_entity_array(self, data):
for d in data:
if not self._is_tc_entity(d):
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_tc_entity(data):\n if data is None:\n return False\n return all(x in data for x in ['id', 'value', 'type'])",
"def is_array(self):\n return len(self.descriptor) > 1",
"def _is_key_value_array(self, data):\n for d in data:\n if not self._is_key_value(d):... | [
"0.7560587",
"0.68777174",
"0.6827968",
"0.6551447",
"0.64199686",
"0.6415051",
"0.619361",
"0.61661595",
"0.61449605",
"0.6061444",
"0.60472214",
"0.6040022",
"0.5984932",
"0.5964702",
"0.59617305",
"0.5959589",
"0.5951809",
"0.594367",
"0.58823645",
"0.58561146",
"0.5807584... | 0.89135975 | 0 |
Parse the output variables provided to Playbook Class. | def _parse_output_variables(self):
self._output_variables_by_name = {}
self._output_variables_by_type = {}
for ov in self._output_variables:
# parse the variable to get individual parts
parsed_variable = self.parse_variable(ov)
variable_name = parsed_variable.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _populate_output(self):\n pass",
"def output(self):\n return self._parser.result",
"def _parse_results(self):\n for line in self.file_dic['output'].splitlines():\n if line.startswith(' * GAMESS VERSION = '):\n temp = line.split('=')[1]\n ... | [
"0.5872523",
"0.5643313",
"0.5449664",
"0.54217076",
"0.54162735",
"0.53987",
"0.5351659",
"0.5349903",
"0.5325536",
"0.5322965",
"0.5322965",
"0.5322965",
"0.5322965",
"0.5322965",
"0.5322965",
"0.530451",
"0.52490526",
"0.52292705",
"0.52058434",
"0.5189824",
"0.5177945",
... | 0.61766785 | 0 |
Read method for "embedded" variables. | def _read_embedded(self, value):
if value is None: # pragma: no cover
return value
for variable in (v.group(0) for v in re.finditer(self._variable_parse, str(value))):
v = self.read(variable)
self.log.trace(f'embedded variable: {variable}, value: {v}')
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_var(self, time_idx, pressure_idx, var_idx, lat_idx, lng_idx):\n offset = self.item_size * (\n time_idx * self.t_idx + pressure_idx * self.p_idx +\n var_idx * self.v_idx + lat_idx * self.l_idx + lng_idx)\n self.mm.seek(offset)\n return self.unpacker.unpack(self.m... | [
"0.5898118",
"0.58264506",
"0.559327",
"0.55827427",
"0.5537502",
"0.54451066",
"0.54211825",
"0.5386915",
"0.53822416",
"0.5306469",
"0.5305793",
"0.528737",
"0.52683836",
"0.52524936",
"0.52468103",
"0.52181745",
"0.5152884",
"0.5130047",
"0.51151127",
"0.51119286",
"0.5075... | 0.718512 | 0 |
Regex pattern to match and parse a playbook variable. | def _variable_pattern(self):
variable_pattern = r'#([A-Za-z]+)' # match literal (#App,#Trigger) at beginning of String
variable_pattern += r':([\d]+)' # app id (:7979)
variable_pattern += r':([A-Za-z0-9_\.\-\[\]]+)' # variable name (:variable_name)
variable_pattern += r'!(StringArray|... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parse_substitution_variable():\n assert parse_substitution_variable(\"${SOME_VAR}\") == \"SOME_VAR\"\n assert parse_substitution_variable(\"$SOME_VAR\") == \"SOME_VAR\"\n assert parse_substitution_variable(\"SOME_STRING\") is None\n assert parse_substitution_variable(\"SOME_$TRING\") is None\n... | [
"0.58059424",
"0.5492177",
"0.5294386",
"0.5161863",
"0.5149831",
"0.5140792",
"0.504229",
"0.4944006",
"0.4844241",
"0.4829502",
"0.4760484",
"0.47480515",
"0.47444043",
"0.47170147",
"0.4708932",
"0.46951598",
"0.46946687",
"0.4692993",
"0.4690629",
"0.46653223",
"0.4649731... | 0.5986761 | 0 |
Return list of standard playbook array variable types. | def _variable_array_types(self):
return [
'BinaryArray',
'KeyValueArray',
'StringArray',
'TCEntityArray',
'TCEnhancedEntityArray',
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type_array():\n return []",
"def _variable_types(self):\n return self._variable_single_types + self._variable_array_types",
"def ntypes(self): # -> list[str]:\n ...",
"def variables_used (self) :\r\n\t\t## These names do not contain dimension specification (everything in brackets\r\n... | [
"0.7109091",
"0.6750778",
"0.60205364",
"0.59804296",
"0.59578115",
"0.59203815",
"0.589851",
"0.5843989",
"0.5775973",
"0.5638443",
"0.56376356",
"0.55983675",
"0.5590408",
"0.5577931",
"0.5535131",
"0.55259275",
"0.5524852",
"0.5512015",
"0.55065835",
"0.5492362",
"0.545865... | 0.7255851 | 0 |
Return list of standard playbook single variable types. | def _variable_single_types(self):
return [
'Binary',
'KeyValue',
'String',
'TCEntity',
'TCEnhancedEntity',
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _variable_types(self):\n return self._variable_single_types + self._variable_array_types",
"def get_variables_of_type(self, variable_type):\n if isinstance(variable_type,str):\n variable_key = variable_type\n else:\n #it is a class\n variable_key = variab... | [
"0.6429574",
"0.59807885",
"0.58772886",
"0.58626544",
"0.58337337",
"0.5782336",
"0.5708495",
"0.56645995",
"0.5657368",
"0.56285715",
"0.5627209",
"0.5618802",
"0.557904",
"0.5523723",
"0.55072105",
"0.5501268",
"0.54792243",
"0.546074",
"0.54157805",
"0.5411536",
"0.538897... | 0.6180898 | 1 |
Return list of standard playbook variable typesd. | def _variable_types(self):
return self._variable_single_types + self._variable_array_types | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variables(self):\n return {u for u in self if u.type == 'var'}",
"def vars(cls):\n for key in dir(cls):\n if key.startswith('var_'):\n yield key[4:]",
"def ntypes(self): # -> list[str]:\n ...",
"def gettypes(self):\n return [str(self.sd.xlate(t[0])) f... | [
"0.6229494",
"0.61989886",
"0.6119044",
"0.6087897",
"0.59676516",
"0.59419936",
"0.5933294",
"0.5902018",
"0.57896936",
"0.5771603",
"0.57483006",
"0.57068115",
"0.57008547",
"0.5697151",
"0.56232536",
"0.561799",
"0.56168795",
"0.5613887",
"0.56020916",
"0.55944794",
"0.557... | 0.6520751 | 0 |
Wrap keyvalue embedded variable in double quotes. | def _wrap_embedded_keyvalue(self, data):
# TODO: need to verify if core still sends improper JSON for KeyValueArrays
if data is not None: # pragma: no cover
variables = []
for v in re.finditer(self._vars_keyvalue_embedded, data):
variables.append(v.group(0))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quoted(val: str) -> str:\n return f'\"{val}\"' if ' ' in val else val",
"def _quote(v):\n return '\"' + v + '\"' if ' ' in v else v",
"def wrap_with_in_single_quote(s):\n return \"'{}'\".format(s)",
"def wrap_with_in_single_quote(s):\n return \"'{}'\".format(s)",
"def transform_inner(se... | [
"0.6500727",
"0.6460141",
"0.6404926",
"0.6404926",
"0.63859904",
"0.63004553",
"0.6255507",
"0.6255154",
"0.6240473",
"0.62400144",
"0.6081811",
"0.60609484",
"0.6010835",
"0.5974859",
"0.59447855",
"0.5914515",
"0.59110457",
"0.59106",
"0.5854077",
"0.57784784",
"0.5776997"... | 0.65247035 | 0 |
Test if the angle defined by arc.center and point "p" is in the range | def test_point_is_in_arc_range(p):
arc = ConstructionArc((0, 0), 1, -90, 90)
assert arc._is_point_in_arc_range(Vec2(p)) is True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_point_is_not_in_arc_range(p):\n arc = ConstructionArc((0, 0), 1, -90, 90)\n assert arc._is_point_in_arc_range(Vec2(p)) is False",
"def isinsidearcXY(c,p):\n\n x = c[0]\n r = c[1][0]\n if dist(x,p) > r:\n return False\n if iscircle(c):\n return True\n start = c[1][1]%36... | [
"0.7806284",
"0.7680775",
"0.71389997",
"0.63681877",
"0.6356038",
"0.629648",
"0.62209857",
"0.6157596",
"0.6125476",
"0.61092865",
"0.6099035",
"0.60850865",
"0.6072224",
"0.6062538",
"0.6062203",
"0.60182136",
"0.60182136",
"0.60143894",
"0.595781",
"0.5904161",
"0.5895323... | 0.818019 | 0 |
Test if the angle defined by arc.center and point "p" is NOT in the range | def test_point_is_not_in_arc_range(p):
arc = ConstructionArc((0, 0), 1, -90, 90)
assert arc._is_point_in_arc_range(Vec2(p)) is False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_point_is_in_arc_range(p):\n arc = ConstructionArc((0, 0), 1, -90, 90)\n assert arc._is_point_in_arc_range(Vec2(p)) is True",
"def isinsidearcXY(c,p):\n\n x = c[0]\n r = c[1][0]\n if dist(x,p) > r:\n return False\n if iscircle(c):\n return True\n start = c[1][1]%360.0\n... | [
"0.74086374",
"0.7201759",
"0.6761318",
"0.64898396",
"0.6108149",
"0.59994227",
"0.599469",
"0.59814745",
"0.5867209",
"0.58171624",
"0.5783848",
"0.5737691",
"0.57311845",
"0.572497",
"0.57046014",
"0.5694878",
"0.56613857",
"0.5653275",
"0.5651666",
"0.5649006",
"0.5637145... | 0.82505214 | 0 |
Test that Station overall votes page is rendered | def test_station_overall_votes_get(self):
request = self._get_request()
view = overall_votes.OverallVotes.as_view()
request = self.factory.get(
f'/reports/internal/station-overall-votes/{self.tally.pk}')
request.user = self.user
request.session = {}
response =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_vote_view_allows_to_vote(self):\n self.client.login(username=\"John\", password=\"newpass1234\")\n votes_len = len(PostVotes.objects.all())\n response = self.client.post('/posts/2/vote/', {\"vote\": \"-1\"})\n self.assertEqual(len(PostVotes.objects.all()), votes_len + 1)",
"d... | [
"0.650139",
"0.6376115",
"0.62473714",
"0.6238499",
"0.61792076",
"0.6062894",
"0.6049651",
"0.60236156",
"0.5963442",
"0.59394926",
"0.59087944",
"0.58981115",
"0.5886168",
"0.5859781",
"0.5803201",
"0.57948804",
"0.57878697",
"0.5783295",
"0.57520115",
"0.5719819",
"0.57130... | 0.75833786 | 0 |
Test that Center overall votes page is rendered | def test_center_overall_votes_get(self):
request = self._get_request()
view = overall_votes.OverallVotes.as_view()
request = self.factory.get(
f'/reports/internal/center-overall-votes/{self.tally.pk}')
request.user = self.user
request.session = {}
response = v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_station_overall_votes_get(self):\n request = self._get_request()\n view = overall_votes.OverallVotes.as_view()\n request = self.factory.get(\n f'/reports/internal/station-overall-votes/{self.tally.pk}')\n request.user = self.user\n request.session = {}\n ... | [
"0.6258364",
"0.6082336",
"0.6026259",
"0.57348734",
"0.57104206",
"0.5639288",
"0.5608108",
"0.56038415",
"0.55867565",
"0.557384",
"0.5561015",
"0.55369455",
"0.5519666",
"0.55196303",
"0.5509503",
"0.5509503",
"0.54806083",
"0.54739654",
"0.54216933",
"0.54116386",
"0.5410... | 0.7421584 | 0 |
disable form on ONA to prevent new submission | def _process(self):
disable_form(self.kwargs["collect"].ona_scan_form_pk) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disable(self):",
"def form_invalid(self, form, request):\n return",
"def form_invalid(self, form, request):\n return",
"def disable(self) -> None:",
"def disable(self):\n\t\tresponse = self.client.post(self._endpoint + \"/disable\")\n\t\treturn bool(response.json[\"success\"])",
"def _d... | [
"0.6149328",
"0.6095509",
"0.6095509",
"0.606329",
"0.59757644",
"0.5860466",
"0.5855243",
"0.5831941",
"0.58173203",
"0.5807923",
"0.58009744",
"0.5789551",
"0.57262915",
"0.5723605",
"0.5710719",
"0.56988764",
"0.56463355",
"0.56415784",
"0.56309557",
"0.5627955",
"0.562483... | 0.6570882 | 0 |
retrieve ONA data for form | def _process(self):
self.output["data"] = get_form_data(self.kwargs["collect"].ona_scan_form_pk) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_extra_payload(form):",
"def test_get_start_form_data(self):\n pass",
"def process_form(request):\n raw_data = request.form\n data = raw_data.copy()\n data['resources'] = request.form.getlist('resources')\n if request.remote_addr == '127.0.0.1':\n data['ip'] = '100.7.27.72'\n ... | [
"0.6258261",
"0.59764576",
"0.59138936",
"0.58315814",
"0.58055896",
"0.57019895",
"0.568891",
"0.5666468",
"0.56540024",
"0.5627375",
"0.5577858",
"0.5569501",
"0.555679",
"0.55227417",
"0.5504472",
"0.5498711",
"0.54734224",
"0.5463231",
"0.54562473",
"0.54407644",
"0.54236... | 0.61089295 | 1 |
change collect status to ENDED | def _process(self):
self.kwargs["collect"].change_status(self.kwargs["collect"].FINALIZED) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _revert(self):\n self.kwargs[\"collect\"].change_status(self.kwargs[\"collect\"].ENDED)",
"def old_collected_data_status(self, old_collected_data_status):\n\n self._old_collected_data_status = old_collected_data_status",
"def collected_data_status(self, collected_data_status):\n\n self... | [
"0.63012075",
"0.5838092",
"0.5536099",
"0.54330206",
"0.54094124",
"0.53459746",
"0.522914",
"0.51660573",
"0.5164088",
"0.5072961",
"0.5067657",
"0.50342417",
"0.4994877",
"0.49740368",
"0.4934098",
"0.4931574",
"0.49252388",
"0.49198726",
"0.49084428",
"0.4893677",
"0.4893... | 0.5919906 | 1 |
Extracting/converting omega and omegad (trajectories) from trajectories of Q, Qd, and Qdd. | def computeOmegaAndOmegaDotTrajectory(QT, QdT, QddT):
assert ((len(QT.shape) >= 1) and
(len(QT.shape) <= 2)), "QT has invalid number of dimensions!"
assert ((len(QdT.shape) >= 1) and
(len(QdT.shape) <= 2)), "QdT has invalid number of dimensions!"
assert ((len(QddT.shape) >= 1) and
(l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def computeQDotAndQDoubleDotTrajectory(QT, omegaT, omegadT):\n tensor_length = QT.shape[0]\n\n QdT = computeQDotTrajectory(QT, omegaT)\n QddT = computeQDoubleDotTrajectory(QT, QdT.reshape(tensor_length, 4), omegaT,\n omegadT)\n return QdT, QddT",
"def ADT_QCD_LEPTON():\n\n... | [
"0.72281843",
"0.6318777",
"0.6192413",
"0.6081164",
"0.59346646",
"0.583524",
"0.58191234",
"0.57784086",
"0.57722557",
"0.5680242",
"0.5680242",
"0.56509036",
"0.56509036",
"0.55569625",
"0.5494865",
"0.54602075",
"0.54602075",
"0.5447028",
"0.54262084",
"0.5409022",
"0.539... | 0.7004595 | 1 |
Given Quaternion trajectory and dt, compute the angular velocity (omega) trajectory. | def computeOmegaTrajectory(QT, dt):
assert (len(QT.shape) == 2), "QT has invalid number of dimensions!"
assert (QT.shape[0] >= 2), "QT must have at least two Quaternion data points!"
assert (dt > 0.0), "dt (sampling time) is invalid!"
tensor_length = QT.shape[0]
QtT = copy.deepcopy(QT)
QtT[-1, :] = copy.de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def angular_velocities(self, dt: float) -> np.ndarray:\n if not isinstance(dt, float):\n raise TypeError(f\"dt must be a float. Got {type(dt)}.\")\n if dt <= 0:\n raise ValueError(f\"dt must be greater than zero. Got {dt}.\")\n w = np.c_[\n self.w[:-1]*self.x[1... | [
"0.68343025",
"0.64290327",
"0.6392442",
"0.60243434",
"0.5848864",
"0.5847408",
"0.58383614",
"0.5826683",
"0.5818263",
"0.5808747",
"0.5789581",
"0.57841927",
"0.57598984",
"0.57505935",
"0.569952",
"0.5672744",
"0.5632308",
"0.5624721",
"0.56163865",
"0.5570721",
"0.552992... | 0.7333754 | 0 |
Extracting/converting Qd and Qdd (trajectories) from trajectories of Q, omega, and omegad. | def computeQDotAndQDoubleDotTrajectory(QT, omegaT, omegadT):
tensor_length = QT.shape[0]
QdT = computeQDotTrajectory(QT, omegaT)
QddT = computeQDoubleDotTrajectory(QT, QdT.reshape(tensor_length, 4), omegaT,
omegadT)
return QdT, QddT | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def computeOmegaAndOmegaDotTrajectory(QT, QdT, QddT):\n assert ((len(QT.shape) >= 1) and\n (len(QT.shape) <= 2)), \"QT has invalid number of dimensions!\"\n assert ((len(QdT.shape) >= 1) and\n (len(QdT.shape) <= 2)), \"QdT has invalid number of dimensions!\"\n assert ((len(QddT.shape) >= 1) an... | [
"0.6590861",
"0.62409633",
"0.62165076",
"0.5996562",
"0.5996562",
"0.5927555",
"0.58417743",
"0.5748552",
"0.57265306",
"0.57100147",
"0.57100147",
"0.5668859",
"0.56666297",
"0.56498903",
"0.56477606",
"0.56477606",
"0.5571762",
"0.54973704",
"0.5481573",
"0.545984",
"0.541... | 0.7017557 | 0 |
>>> s = Solution() >>> s.findKthLargest([3,2,1,5,6,4], 2) 5 >>> s.findKthLargest([3,2,3,1,2,4,5,5,6], 4) 4 | def findKthLargest(self, nums: List[int], k: int) -> int:
return sorted(nums)[-k] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kth_largest(arr: list, k: int):\n # Do not search if k is larger than total number of elements\n if k > len(arr):\n raise IndexError\n # Count all numbers\n nums = Counter(arr)\n # Go from the largest to smaller ones\n for key in sorted(nums, reverse=True):\n if nums[key] >= k:\... | [
"0.7556906",
"0.693774",
"0.6751622",
"0.66907436",
"0.66187215",
"0.6598453",
"0.6518774",
"0.64927214",
"0.64212143",
"0.6390339",
"0.63652146",
"0.6234809",
"0.6226635",
"0.61784065",
"0.6173131",
"0.61195916",
"0.61159575",
"0.61124295",
"0.61023104",
"0.60886",
"0.604873... | 0.84186244 | 0 |
Given a sequence and the alternative sequence yield all mfes. | def compute_mfes(seq, mutations):
for position, character in enumerate(mutations):
alt_seq = _replace(seq, position, character)
yield dotbracket(alt_seq) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def difference(seq, *seqs):\n yield from differenceby(None, seq, *seqs)",
"def sentinelize(inputSeq, sentinel=None, loopSentinel=False, failFun=None):\n for item in inputSeq:\n yield item\n yield sentinel\n while loopSentinel:\n yield loopSentinel\n if failFun:\n failFun()",
"def e_seq():\n yi... | [
"0.60232437",
"0.5683796",
"0.56831485",
"0.5667053",
"0.56568414",
"0.56452036",
"0.56023264",
"0.5602069",
"0.55491084",
"0.5485562",
"0.5450549",
"0.5342842",
"0.53096867",
"0.52991277",
"0.5290579",
"0.5288675",
"0.52817655",
"0.52763766",
"0.5240386",
"0.5233169",
"0.522... | 0.61841524 | 0 |
Plot matrix of unstability in the RNA sequence. | def plot_stability_matrix(self, file_name=None):
size = len(self.seq) / 2.5
plt.figure(figsize=(size, 2.5))
plt.imshow(self.matrix,
interpolation='none',
cmap=plt.get_cmap('YlOrRd'))
plt.yticks(range(4), ['A', 'C', 'G', 'U'], fontsize=12)
plt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_ransac():\n\n # simulate normal data\n activeday = 10000\n lazyday = 3000\n stepcounts, truelabels = make_blobs(n_samples=31, centers=[[activeday]], cluster_std=750, random_state=8)\n for i in range(len((stepcounts))):\n if (i % 6 == 0) and (i != 0):\n ... | [
"0.6086937",
"0.56867373",
"0.56793547",
"0.5537703",
"0.5492549",
"0.5435134",
"0.5399213",
"0.5367122",
"0.53595245",
"0.5343945",
"0.5317689",
"0.5317652",
"0.53174126",
"0.53142524",
"0.52944106",
"0.5281533",
"0.527728",
"0.5237348",
"0.5236701",
"0.52259475",
"0.5225897... | 0.6732296 | 0 |
Does the Qt kill ring maintain state with cursor movement? | def test_qt_cursor(self):
text_edit = QtWidgets.QPlainTextEdit()
ring = QtKillRing(text_edit)
ring.kill('foo')
ring.kill('bar')
ring.yank()
text_edit.moveCursor(QtGui.QTextCursor.Left)
ring.rotate()
self.assertEqual(text_edit.toPlainText(), 'bar') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_yankWithoutKillRing(self):\n s = 'hello world'\n n = 5\n self.widget.buffer = s\n self.widget.cursor = n\n self.widget.killRing = []\n self.widget.keystrokeReceived('\\x19', None)\n self.assertEqual(self.widget.buffer, s)\n self.assertEqual(self.widg... | [
"0.67450184",
"0.659391",
"0.6500618",
"0.631349",
"0.62125254",
"0.61748886",
"0.6078184",
"0.6036192",
"0.6008582",
"0.6007503",
"0.5974758",
"0.5970883",
"0.59500074",
"0.5926416",
"0.5908818",
"0.5874349",
"0.5851573",
"0.5848962",
"0.5847493",
"0.5847493",
"0.5847493",
... | 0.7201863 | 0 |
This method overrides the normal os.walk/fswalk in HydraWalker. The purpose is to add path prefixes to the actual walk so that we can distribute the work across multiple mount points/shares/drives. This works for some parallel file systems where you can have multiple mount points to the same name space but across multi... | def walk_dir(self, dir):
if self.ppath_prefix_len:
prefix = self.ppath_prefix[self.ppath_prefix_idx%self.ppath_prefix_len]
self.ppath_prefix_idx += 1
merged_path = os.path.join(prefix, dir)
for root, dirs, files in self.fswalk_base(merged_path):
yield merged_path, dirs, files
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _walk_dirs(self):\n for project_name in self.new_source_paths.keys():\n # print \"-------- Now mapping ---- \" + project_name\n search_path = self.root + project_name + '\\\\Data'\n for dirpath, subdirs, files in os.walk(search_path):\n for file in files:\... | [
"0.57290465",
"0.5540345",
"0.549327",
"0.52930176",
"0.5262545",
"0.5260721",
"0.5124712",
"0.51177645",
"0.50776994",
"0.5073814",
"0.506935",
"0.50689495",
"0.5064803",
"0.5058369",
"0.5056647",
"0.50524956",
"0.5051619",
"0.5023211",
"0.50152683",
"0.49906874",
"0.4962310... | 0.5676473 | 1 |
Send all our connected clients the command to start processing the stats from their individual DBs. Mark each of the clients as having not yet returned the stats data | def send_clients_db_consolidate_cmd(self):
self.send_all_clients_command(CMD_RETURN_STATS_DB)
for key in self.clients:
self.clients[key]['stat_db_received'] = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serviceQueries(self):\n #log.debug(f\"{self.name}: servicing queries for {len(self.connections)} connections.\")\n for ca, requester in self.connections.items():\n if requester.ims:\n log.info(\"Server %s received:\\n%s\\n\", self.name, requester.ims)\n re... | [
"0.66672623",
"0.6463625",
"0.64257437",
"0.6305658",
"0.62661815",
"0.6065686",
"0.6023132",
"0.5956768",
"0.5939555",
"0.5928041",
"0.58842725",
"0.58573294",
"0.57964593",
"0.57952714",
"0.5793756",
"0.5723789",
"0.5663772",
"0.56621426",
"0.562771",
"0.562704",
"0.5626418... | 0.751229 | 0 |
Make Find User Validations | def find_user_validations() -> Type[ValidatorComposite]:
arr_validations = [Builder.field("user_id").required().build()]
validations = sum(arr_validations, [])
return ValidatorComposite.build(validations) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_resource_user_resource_find_users_get(self):\n pass",
"def _validate_user(_):\n pass",
"def clean(self):\n\n # Fetch cleaned email and username data.\n email = self.cleaned_data.get('email')\n username = self.cleaned_data.get('username')\n\n # Fetch possible user ... | [
"0.6501683",
"0.62038416",
"0.6184967",
"0.61819196",
"0.6159867",
"0.6090602",
"0.60777676",
"0.6074158",
"0.6023889",
"0.58935875",
"0.58579177",
"0.58443046",
"0.58098054",
"0.5805503",
"0.580316",
"0.5789005",
"0.57801324",
"0.5776666",
"0.5745248",
"0.57297546",
"0.57287... | 0.70590025 | 0 |
Cast given locale to string. Supports also callbacks that return locales. | def cast_locale(obj, locale, attr):
if callable(locale):
args_count = get_args_count(locale)
if args_count == 0:
locale = locale()
elif args_count == 1:
locale = locale(obj)
elif args_count == 2:
locale = locale(obj, attr.key)
if isinstance(loc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetString(*args, **kwargs):\n return _gdi_.Locale_GetString(*args, **kwargs)",
"def get_locale():\n return babel.Locale.parse(_get_locale())",
"def format(self, fmt: str, locale: str | None = None) -> str:\n return self._formatter.format(self, fmt, locale)",
"def normalize_currency(curre... | [
"0.6052177",
"0.55995685",
"0.5441465",
"0.5332568",
"0.532277",
"0.5252318",
"0.5250403",
"0.52497745",
"0.52403075",
"0.5237608",
"0.5225941",
"0.51631624",
"0.5054695",
"0.5050819",
"0.50413287",
"0.5040657",
"0.50388926",
"0.5031137",
"0.50128025",
"0.49931708",
"0.498255... | 0.7257748 | 0 |
Return a hybrid_property getter function for given attribute. The returned getter first checks if object has translation for current locale. If not it tries to get translation for default locale. If there is no translation found for default locale it returns None. | def getter_factory(self, attr):
def getter(obj):
current_locale = cast_locale(obj, self.current_locale, attr)
try:
return getattr(obj, attr.key)[current_locale]
except (TypeError, KeyError):
default_locale = cast_locale(obj, self.default_locale... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_translated_attribute(actual_object, attribute_name, translated):\n from django.conf import settings\n if len(settings.LANGUAGES) > 1 and translated.count() and hasattr(translated[0], attribute_name):\n return getattr(translated[0], attribute_name)\n elif hasattr(actual_object, attribute_nam... | [
"0.6552517",
"0.63079727",
"0.5733428",
"0.5602844",
"0.5569151",
"0.55125445",
"0.5503892",
"0.5357985",
"0.5336438",
"0.5304151",
"0.52590704",
"0.5246566",
"0.5236186",
"0.5199783",
"0.51859045",
"0.5182544",
"0.515357",
"0.512722",
"0.5093937",
"0.5093674",
"0.50930804",
... | 0.7378383 | 0 |
Write ourselves out to a directory | def writeToFile(self, basedir, write_code=0): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_write_directory(self, path):\n if not os.path.isdir(path):\n print(\"[PathFitCyl] **** ERROR: '{0:s}' is not a directory.\".format(path))\n return\n\n if not os.path.exists(path):\n print(\"[PathFitCyl] **** ERROR: Directory '{0:s}' does not exist.\".format(pa... | [
"0.7046081",
"0.6876686",
"0.68362075",
"0.670245",
"0.66651195",
"0.6634564",
"0.65921456",
"0.6568307",
"0.65197563",
"0.64764935",
"0.64351887",
"0.6418582",
"0.6401057",
"0.6392427",
"0.63741374",
"0.6363067",
"0.6353968",
"0.631503",
"0.62932783",
"0.6287581",
"0.6278487... | 0.7038389 | 1 |
add the given vertex to each cluster. | def add_vertex_to_clusters(clusters,vertex):
for key in clusters:
clusters[key].append(vertex) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self, vertex):\n self.vertices.append(vertex)\n self.vertex_edge[vertex] = []",
"def add_vertex(self, vertex):\n raise NotImplementedError",
"def __add__(self, vertex):\n\n if isinstance(vertex, Vertex):\n vName = vertex.name\n self._vertices[vNa... | [
"0.738936",
"0.7228798",
"0.7145615",
"0.7021899",
"0.69024456",
"0.6896663",
"0.68675625",
"0.68639535",
"0.68639535",
"0.68464905",
"0.68456185",
"0.6763881",
"0.6730218",
"0.67227286",
"0.6690994",
"0.6688325",
"0.66764355",
"0.6658186",
"0.66529715",
"0.6647528",
"0.66068... | 0.82492626 | 0 |
return a list of vertices that is the best dropoff point for each of the clusters of homes in clusters. | def get_dropoff_vertices_efficient(G, clusters, all_pairs_distances):
best_dropoffs = []
for key in clusters:
dropoff = clustering_routines.best_dropoff_efficient(G,clusters[key],all_pairs_distances)
best_dropoffs.append(dropoff)
return best_dropoffs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sorted_clusters(self):\n return (c for _, c in sorted((-c.size(), c) for c in self.clusters))",
"def solver(graph,homes,source,home_clusters,all_pairs_distances,all_pairs_shortest_paths):\n\n car_path = [get_car_path(graph,home_clusters,source,all_pairs_distances,all_pairs_shortest_paths, \n ... | [
"0.5926781",
"0.5919962",
"0.5812934",
"0.5793345",
"0.5727919",
"0.5719611",
"0.56568784",
"0.56228846",
"0.5580642",
"0.5556335",
"0.5555758",
"0.554882",
"0.554284",
"0.5511986",
"0.55059296",
"0.5503299",
"0.548368",
"0.54417413",
"0.54017895",
"0.5397279",
"0.53967273",
... | 0.80381095 | 0 |
return the path to be followed by the car that visits the best dropoffs for each cluster of homes | def get_car_path(graph,home_clusters,source,all_pairs_distances,all_pairs_shortest_paths,
source_in_clusters = False, christofides = False):
if source_in_clusters:
add_vertex_to_clusters(home_clusters,source)
dropoff_vertices = get_dropoff_vertices_efficient(graph, home_clusters, all_pairs_dis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solver(graph,homes,source,home_clusters,all_pairs_distances,all_pairs_shortest_paths):\n\n car_path = [get_car_path(graph,home_clusters,source,all_pairs_distances,all_pairs_shortest_paths, \n source_in_clusters = B1, christofides = B2) for B1 in [False,True] for B2 in [False,True]]\n\n dropoff... | [
"0.6752765",
"0.66621745",
"0.65688705",
"0.655423",
"0.65081424",
"0.64112514",
"0.6367366",
"0.62029797",
"0.61800456",
"0.61724216",
"0.61435884",
"0.6139545",
"0.6113709",
"0.605717",
"0.6022356",
"0.59077555",
"0.5904586",
"0.5898162",
"0.58534366",
"0.58119905",
"0.5797... | 0.71340287 | 0 |
returns optimal_cost, optimal_dropoffs, optimal_route, optimal_number_of_clusters Iterate over all number of clusters (from 1 to len(homes)). Solve the problem for each number of clusters. Pick the best solution. | def optimal_route(graph,homes,source):
number_of_homes = len(homes)
all_pairs_distances = dict(nx.shortest_path_length(graph, weight = 'weight'))
all_pairs_shortest_paths = dict(nx.shortest_path(graph, weight = 'weight'))
homes_subgraph = tsp_routines.complete_shortest_path_subgraph_efficient(graph,home... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solver(graph,homes,source,home_clusters,all_pairs_distances,all_pairs_shortest_paths):\n\n car_path = [get_car_path(graph,home_clusters,source,all_pairs_distances,all_pairs_shortest_paths, \n source_in_clusters = B1, christofides = B2) for B1 in [False,True] for B2 in [False,True]]\n\n dropoff... | [
"0.76130867",
"0.67789674",
"0.6575912",
"0.6488812",
"0.648072",
"0.64455205",
"0.6395957",
"0.63047355",
"0.6107132",
"0.6096915",
"0.6083581",
"0.60746783",
"0.6067635",
"0.6049034",
"0.6045642",
"0.60264593",
"0.5995607",
"0.59611046",
"0.5922027",
"0.5874442",
"0.5845240... | 0.7407542 | 1 |
returns a dict equivalent to the numbered_dict but replaces all keys and values by the name associated with the number in num_to_name. Use this to map a numeric solution from the algorithm to a named solution for output. | def get_named_dict(numbered_dict,num_to_name):
named_dict = dict()
for num_key in numbered_dict.keys():
name_key = num_to_name[num_key]
num_values = numbered_dict[num_key]
named_dict[name_key] = [num_to_name[v] for v in num_values]
return named_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_to_name(number):\n for name, value in item_dict.items():\n if number == value:\n return name",
"def word_to_number(nb_word):\n return {\n \"Zero\": 0,\n \"One\": 1,\n \"Two\": 2,\n \"Three\": 3,\n \"Four\": 4,\n \"Five\": 5,\n }[nb_w... | [
"0.60368454",
"0.55205876",
"0.5437752",
"0.54234713",
"0.53693765",
"0.5307196",
"0.5304121",
"0.5294111",
"0.52729243",
"0.5262669",
"0.52268374",
"0.521653",
"0.5160667",
"0.515771",
"0.5129312",
"0.51256794",
"0.5121263",
"0.5108855",
"0.51082325",
"0.50797284",
"0.507850... | 0.7555376 | 0 |
return the optimal route and dropoffs for the given input file. The route and dropoffs use the location names specified in the input file. | def solve_inputfile(inputfile):
graph,source,homes,indexToLoc = graph_file_io.graph_from_input(inputfile)
cost, dropoffs, route, num_clusters = optimal_route(graph,homes,source)
named_route = [indexToLoc[r] for r in route]
named_dropoffs = get_named_dict(dropoffs,indexToLoc)
return named_route, name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def optimise(self):\n route = str(sorted(self.heuristic_path))\n\n if route in self.routes:\n saved = TSP.routes[route]\n self.heuristic_path = saved[\"path\"]\n self.heuristic_cost = saved[\"cost\"]\n else:\n self._optimise()\n\n return self.... | [
"0.5638484",
"0.557223",
"0.5484309",
"0.53904766",
"0.53646857",
"0.53040487",
"0.5242158",
"0.52284175",
"0.521549",
"0.5209351",
"0.5207887",
"0.5164908",
"0.5132994",
"0.50991523",
"0.50828385",
"0.5055171",
"0.50191015",
"0.49706462",
"0.49576405",
"0.49453408",
"0.49399... | 0.81944126 | 0 |
plots the cost against the number of clusters and saves the plot to filename | def plot_cost_vs_clusters(cost,num_clusters,filename):
fig, ax = plt.subplots()
ax.plot(num_clusters,cost)
ax.grid()
ax.set_xlabel("Number of clusters")
ax.set_ylabel("Cost of dropping off TAs")
fig.savefig(filename)
plt.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot(self, n_confs):\n \n import pandas as pd\n import numpy as np\n import matplotlib as mpl\n mpl.use('Agg')\n import matplotlib.pyplot as plt\n import csv\n \n n_iter = len(self.plot_data)\n \n data = np.ndarray((n_iter, n_... | [
"0.6900959",
"0.679509",
"0.67075634",
"0.6682047",
"0.6672755",
"0.6644289",
"0.65735656",
"0.6530145",
"0.6518724",
"0.64738566",
"0.6465143",
"0.6454971",
"0.6426282",
"0.64045286",
"0.63544804",
"0.634047",
"0.6317245",
"0.631699",
"0.6313847",
"0.63133085",
"0.62960076",... | 0.8854864 | 0 |
Given a suffix (i.e. "200.in", "100.in", "50.in") iterate through all the inputfiles of this type. Compute the cost for all possible clusterings. Generate the plots and save them to "plots/50 or 100 or 200/filename.png | def generate_all_cost_plots(suffix):
directory_name = "inputs/"
directory = os.fsencode(directory_name)
outfolder = "plots/" + suffix.strip(".in") + "/"
try:
os.makedirs(outfolder)
except FileExistsError:
pass
for file in os.listdir(directory):
filename = os.fsdecode(file... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _iterate_over_files(self):\n stats = Statistics()\n\n args = arguments.Args()\n\n for file in args.files:\n\n if isimage(file):\n before_size = stats.calculate_before_optimization(file)\n\n puts(\"%s %s\" % (\n e(\"==>\"),\n ... | [
"0.6135552",
"0.6022052",
"0.57560307",
"0.5691565",
"0.56533724",
"0.5648358",
"0.55965996",
"0.5595194",
"0.5591788",
"0.55846786",
"0.55802983",
"0.5574422",
"0.55693924",
"0.55691034",
"0.5487015",
"0.54830456",
"0.5479442",
"0.5450352",
"0.5420878",
"0.5407829",
"0.54032... | 0.8204629 | 0 |
Given a suffix (i.e. "200.in", "100.in", "50.in") iterate through all the inputfiles of this type. Compute the optimal solution for this file. Save the output in "outputs/50 or 100 or 200/filename.pickle The pickle when loaded yieds a dictionary such that dict["route"] gives the car route and dict["dropoffs"] gives the... | def generate_all_optimal_solutions(suffix):
directory_name = "inputs/"
directory = os.fsencode(directory_name)
outfolder = "outputs/" + suffix.strip(".in") + "/"
try:
os.makedirs(outfolder)
except FileExistsError:
pass
for file in os.listdir(directory):
filename = os.fsde... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(model_path='models/Nakakuki_Cell_2010_ODE'):\n n_file = []\n fitparam_files = os.listdir(model_path.strip('/') + '/fitparam')\n for file in fitparam_files:\n if re.match(r'\\d', file):\n n_file.append(int(file))\n for nth_paramset in n_file:\n os.makedirs(\n ... | [
"0.5858396",
"0.5850375",
"0.570409",
"0.56486404",
"0.5622358",
"0.5479492",
"0.5473794",
"0.5452889",
"0.5441329",
"0.5431054",
"0.5415864",
"0.5415864",
"0.5407371",
"0.5389245",
"0.53824794",
"0.5377114",
"0.5342723",
"0.53422844",
"0.53218275",
"0.53171223",
"0.5312557",... | 0.7993242 | 0 |
Decode Universal Transformer outputs from encoder representation. It is similar to "transformer.decode", but it uses "universal_transformer_util.universal_transformer_decoder" instead of "transformer.transformer_decoder". | def decode(self,
decoder_input,
encoder_output,
encoder_decoder_attention_bias,
decoder_self_attention_bias,
hparams,
cache=None,
nonpadding=None,
losses=None):
del losses
# TODO(dehghani): enable caching.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _decode_infer(self, decoder, _encoder_output, features, labels):\r\n\r\n return decoder(_encoder_output, labels)",
"def decode(decode_format):\n return output_from_decode",
"def _DecodeFn():\n _, decode_dict = self._model.ConstructDecodeGraph(\n input_batch=inp_instance.TpuD... | [
"0.7115461",
"0.64224404",
"0.6105867",
"0.6083909",
"0.5999015",
"0.597645",
"0.5946038",
"0.5922132",
"0.591021",
"0.5895676",
"0.585739",
"0.5833925",
"0.5784969",
"0.57802826",
"0.5767263",
"0.575825",
"0.5749525",
"0.57474536",
"0.572815",
"0.571991",
"0.5717582",
"0.5... | 0.72315073 | 0 |
Ask device for get_sysinfo. If no IP is provided, request is send as broadcast | def info(ip, poll):
message_str = SysInfoRequest().to_json()
udp = UdpSocket()
if ip is not None:
udp.send(encode(message_str), ip)
else:
udp.send(encode(message_str))
r = UDPRecvThread(udp)
s = UDPSendThread(message_str, udp)
if poll:
s.start()
r.start()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _request_info(self, callback=None):\n self.stick.send(\n NodeInfoRequest(self.mac),\n callback,\n )",
"def get_info(task):\n cmd = \"show version\"\n sh_version = task.run(\n task=netmiko_send_command, command_string=cmd, use_textfsm=True\n )\n # test No... | [
"0.56344044",
"0.55714345",
"0.5561606",
"0.5431455",
"0.542623",
"0.5380994",
"0.5328087",
"0.5316858",
"0.53099746",
"0.52828",
"0.52568614",
"0.52482736",
"0.520828",
"0.51851296",
"0.51715183",
"0.51604164",
"0.51575094",
"0.5134316",
"0.5131879",
"0.5095474",
"0.5073278"... | 0.68869704 | 0 |
Setup device (alias, WLAN) | def setup(wlan_type, wlan_name, alias, password, log_level):
if alias is None:
alias = click.prompt('Alias')
if wlan_name is None:
wlan_name = click.prompt("Wlan_name")
if wlan_type is None:
wlan_type = click.prompt("Wlan-type", type=click.Choice(['0', '1', '2', '3']))
if wlan_ty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup():\n print('Setup option is not working')\n quit()\n print('Long press the reset button until the blue Led is blinking quickly')\n print('Long press again until blinking slowly')\n print('Manually connect this device to the Wifi SSID named BlroadlinkProv')\n print('Press security mode (... | [
"0.692421",
"0.65914375",
"0.6512949",
"0.6412938",
"0.6307325",
"0.6264213",
"0.62157744",
"0.6203105",
"0.6142781",
"0.61204445",
"0.6085594",
"0.6075304",
"0.60519725",
"0.60140234",
"0.60140234",
"0.60136956",
"0.6013272",
"0.60012954",
"0.5994503",
"0.59616",
"0.595696",... | 0.6870175 | 1 |
Test correctnes of unitcircle coefficients | def test_coefficients(self):
coefs = self.cs.coefficients
self.assertEqual(coefs, (1, 0, 1, 0, 0, -1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_circumference():\n assert func_difficult.circumference_circle(1) == 2 * np.pi, \"returns pi *2\"\n assert func_difficult.circumference_circle(0) == 0, \"is 0\"\n assert func_difficult.circumference_circle(10) == 2 * np.pi * 10",
"def test_circumference():\n assert func1.circumference_circle(... | [
"0.6875692",
"0.66662586",
"0.63526946",
"0.6326146",
"0.62995327",
"0.62169224",
"0.62015414",
"0.61631733",
"0.61517346",
"0.6128758",
"0.6110059",
"0.6083497",
"0.60709924",
"0.6068433",
"0.6057219",
"0.60510814",
"0.6020407",
"0.6015406",
"0.5989602",
"0.5931723",
"0.5925... | 0.68648535 | 1 |
Test that circle has conictype 'circle' | def test_conicType(self):
self.assertEqual('circle', self.cs.conicType) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetCircle(circle):\r\n pass",
"def iscircle(a):\n if isarc(a):\n start=a[1][1] \n end=a[1][2]\n ## these are special, integer values that flag a true full\n ## circle.\n if start==0 and end==360:\n return True\n else:\n return False",
"def s... | [
"0.70595217",
"0.6920683",
"0.6839783",
"0.6788954",
"0.6702379",
"0.6702098",
"0.6630202",
"0.66251653",
"0.6585935",
"0.6585935",
"0.6563727",
"0.65614784",
"0.64469016",
"0.6244861",
"0.6182018",
"0.61555046",
"0.6135784",
"0.6122254",
"0.6097156",
"0.60702753",
"0.6038546... | 0.7881156 | 0 |
Test centered equation of unit circle | def test_centeredEquation(self):
A33, K = self.cs.centeredEquation
self.assertTrue((self.A33 == A33).all())
self.assertEqual(K, 1.) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_center():\n center = Coordinates(7, 3)\n radius = 12\n\n returned_center = get_center(center, radius, 25)\n\n assert returned_center.get_x() == center.get_x()\n assert returned_center.get_y() == center.get_y()",
"def point_inside_circle(x,y,center_x,center_y,radius):\n return (x-cent... | [
"0.67867744",
"0.66175085",
"0.661484",
"0.65713817",
"0.65665674",
"0.65385455",
"0.6520903",
"0.649745",
"0.6383827",
"0.6377882",
"0.63415563",
"0.6339983",
"0.6329733",
"0.630717",
"0.62781394",
"0.62155056",
"0.6210831",
"0.620541",
"0.6120175",
"0.6115635",
"0.6104461",... | 0.7045268 | 0 |
Return a copy of the glyph with added comments. | def add_comments(self, comments):
return Glyph(self._rows, self._comments + tuple(comments)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_comments(self):\n return Glyph(self._rows)",
"def comments(self):\r\n return GistComments(self)",
"def clone(self):\n return _libsbml.GeneralGlyph_clone(self)",
"def comments(self):\r\n return c.Comments(self)",
"def comments(self):\r\n return c.Comments(self)",
... | [
"0.6744839",
"0.619544",
"0.60908145",
"0.59813905",
"0.59813905",
"0.59813905",
"0.59651583",
"0.5939179",
"0.59275943",
"0.5911221",
"0.5911221",
"0.5911221",
"0.5843718",
"0.57151765",
"0.5709366",
"0.56915647",
"0.56523854",
"0.5649423",
"0.56320333",
"0.56063086",
"0.558... | 0.6890193 | 0 |
Return a copy of the glyph without comments. | def drop_comments(self):
return Glyph(self._rows) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone(self):\n return _libsbml.GeneralGlyph_clone(self)",
"def clone(self):\n return _libsbml.TextGlyph_clone(self)",
"def clone(self):\n return _libsbml.ReferenceGlyph_clone(self)",
"def clone(self):\n return _libsbml.CompartmentGlyph_clone(self)",
"def clone(self):\n ... | [
"0.67288643",
"0.6533426",
"0.6354009",
"0.612143",
"0.5950792",
"0.5894059",
"0.58463377",
"0.58195376",
"0.5602399",
"0.55595535",
"0.5524648",
"0.54354143",
"0.53472966",
"0.5252741",
"0.5223893",
"0.51743424",
"0.51584923",
"0.51584923",
"0.51322424",
"0.5090773",
"0.5083... | 0.7764554 | 0 |
Create glyph from bytes/bytearray/int sequence. | def from_bytes(byteseq, width, height=None):
if not width:
return Glyph()
if height is not None:
bytewidth = len(byteseq) // height
else:
bytewidth = ceildiv(width, 8)
byteseq = list(byteseq)
rows = [byteseq[_offs:_offs+bytewidth] for _offs in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_hex(hexstr, width, height):\n return Glyph.from_bytes(binascii.unhexlify(hexstr.encode('ascii')), width, height)",
"def from_bytes(data):\n return Cursor(data, 0, 0)",
"def from_glyphslot(char, slot):\n pixels = Glyph.unpack_mono_bitmap(slot.bitmap)\n width, height = slot.b... | [
"0.61535007",
"0.58968383",
"0.5844911",
"0.57841724",
"0.5783641",
"0.57175314",
"0.5625701",
"0.56247884",
"0.5536668",
"0.5528654",
"0.55182993",
"0.54959756",
"0.5495131",
"0.54709363",
"0.54671884",
"0.54635614",
"0.5394575",
"0.5385285",
"0.535783",
"0.5357672",
"0.5325... | 0.740402 | 0 |
Convert glyph to flat bytes. | def as_bytes(self):
if not self._rows:
return b''
width = len(self._rows[0])
bytewidth = ceildiv(width, 8)
# byte-align rows
rows = [
_row + (False,) * (bytewidth*8 - width)
for _row in self._rows
]
# chunk by byte and flatten
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toXML(self):\n return _libsbml.GeneralGlyph_toXML(self)",
"def toXML(self):\n return _libsbml.TextGlyph_toXML(self)",
"def _to_bytes(self):\n return self.to_uri().to_text().encode('ascii')",
"def get_byte_string(self):\n return \"\".join(['%02X' % i for i in self._data]).decod... | [
"0.605283",
"0.6006523",
"0.59040517",
"0.58397573",
"0.5831834",
"0.5734501",
"0.56847775",
"0.5664902",
"0.55310154",
"0.5524695",
"0.5475549",
"0.5474172",
"0.5446375",
"0.5444722",
"0.54189926",
"0.5381904",
"0.53794307",
"0.53464353",
"0.5346067",
"0.5339021",
"0.5284642... | 0.6808965 | 0 |
Create glyph from hex string. | def from_hex(hexstr, width, height):
return Glyph.from_bytes(binascii.unhexlify(hexstr.encode('ascii')), width, height) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_hex_str(value):\n \n return SHex(value)",
"def from_hex(cls, hexstr, width, height=NOT_SET, *, align='left'):\n byteseq = bytes.fromhex(hexstr)\n return cls.from_bytes(byteseq, width, height, align=align)",
"def hex_tofrom_hex(newsystem, coord):\n return newsystem.coord(x=coord.... | [
"0.6764258",
"0.667475",
"0.6068386",
"0.6056849",
"0.59312487",
"0.5859119",
"0.57902426",
"0.57766974",
"0.5768146",
"0.57573336",
"0.57428104",
"0.5718927",
"0.5717898",
"0.5690347",
"0.56288874",
"0.5627236",
"0.5557628",
"0.5510837",
"0.54668033",
"0.5466273",
"0.5458346... | 0.8342864 | 0 |
Crop glyph, inclusive bounds. | def crop(self, left:int=0, bottom:int=0, right:int=0, top:int=0):
return Glyph(tuple(
_row[left : (-right if right else None)]
for _row in self._rows[top : (-bottom if bottom else None)]
)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crop(self):\n\n return self.image.crop(self.x, self.y, self.width(), self.height(), centered = True)",
"def crop_img(image, bound):\n scale = 1.01 # 1%\n return image.crop((bound.vertices[0].x // scale, bound.vertices[0].y // scale,\n int(bound.vertices[2].x * scale), int(... | [
"0.6855742",
"0.67380065",
"0.66573066",
"0.66307855",
"0.6579562",
"0.6450231",
"0.63742936",
"0.63478243",
"0.6320375",
"0.6313073",
"0.6312432",
"0.6291033",
"0.62609375",
"0.6249132",
"0.62142026",
"0.6174183",
"0.61588687",
"0.6124995",
"0.61007535",
"0.6039044",
"0.5990... | 0.6867612 | 0 |
Constructs a ResNet18 model. | def resnet18(pretrained=False, **kwargs):
model = ResNet(BasicBlock, [2, 2, 2, 2], **kwargs)
if pretrained:
model.load_state_dict(model_zoo.load_url(model_urls['resnet18']), strict=False)
return model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet18(pretrained=False):\n model = ResNet(BasicBlock, [2, 2, 2, 2])\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet18']))\n return model",
"def resnet18(pretrained=False, **kwargs):\n model = ResNet(BasicBlock, [2, 2, 2, 2, 2], **kwargs)\n if pretrained... | [
"0.7326453",
"0.731685",
"0.7303916",
"0.7303916",
"0.7303916",
"0.7303916",
"0.7303916",
"0.7301021",
"0.7193934",
"0.7087913",
"0.7010579",
"0.7010579",
"0.7010579",
"0.69191164",
"0.6850467",
"0.68484443",
"0.6635187",
"0.6593119",
"0.6579829",
"0.65362495",
"0.6485443",
... | 0.7334039 | 0 |
Format the lat/lon as a PostGIS Point Geography, to be used in SQLAlchemy queries. | def _format_point_postgis(lat: float, lon: float) -> Point:
return sa.cast("POINT({} {})".format(lon, lat), ga.types.Geography) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_pseudo_epsg4326_coordinates(self):\n self.create_3d_coord_on_sphere(on_sphere=True)\n self.df_attributes['lat'] = 180*(pi/2 - np.arccos(self.df_attributes['coord_z']))/pi\n self.df_attributes['lon'] = 180*np.arctan2(self.df_attributes['coord_y'], self.df_attributes['coord_x'])/pi",
... | [
"0.6354036",
"0.6044724",
"0.59471714",
"0.5897849",
"0.5892224",
"0.58816624",
"0.5864313",
"0.58605057",
"0.5859211",
"0.5827331",
"0.5812064",
"0.58046454",
"0.57805395",
"0.5742158",
"0.5703753",
"0.5697407",
"0.56663966",
"0.56625515",
"0.5652814",
"0.56523573",
"0.56505... | 0.8651569 | 0 |
For a list of tuples containing Place + distance, set each provided distance value onthe distance property of the corresponding Place. | def _set_distances(results: List[(Place, float)]) -> List[Place]:
all_entities = []
for entity, distance in results:
entity.distance = distance
all_entities.append(entity)
return all_entities | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_distances(drives):\n for d in drives:\n d.set_distance()",
"def dv_update(self, dv_list):\n for line in dv_list:\n line_sep = line.split(',')\n other_name = line_sep[0] + ':' + line_sep[1]\n other_cost = float(line_sep[2])\n ... | [
"0.58054733",
"0.5626535",
"0.56000245",
"0.52971953",
"0.51886195",
"0.5162123",
"0.5162123",
"0.5162123",
"0.5147081",
"0.5137735",
"0.5116875",
"0.50832963",
"0.5079236",
"0.50570196",
"0.50565916",
"0.50563264",
"0.5042337",
"0.5020252",
"0.4989625",
"0.49584976",
"0.4931... | 0.6914028 | 0 |
For a given Point, return the geoalchemy ST_Distance instance denoting the distance that a point resides from a Place's center. Compiling the ST_Intersects function to raw SQL is handled by SQLAlchemy. | def _postgis_distance(cls, point: Point) -> STDistance:
return ga.functions.ST_Distance(cls.center_raw, point) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_to(self, point: Union[\"Unit\", Point2, Point3]) -> Union[int, float]:\n return self.position.distance_to_point2(point.position)",
"def distance(self, point):\r\n assert a6checks.is_point(point)\r\n assert len(point)==len(self._centroid)\r\n\r\n sum=0\r\n for i in ... | [
"0.6824983",
"0.6554473",
"0.65225244",
"0.64401704",
"0.64086807",
"0.6331995",
"0.6319463",
"0.6277746",
"0.6219058",
"0.6196922",
"0.61441356",
"0.6128329",
"0.6091922",
"0.6039725",
"0.60217184",
"0.6007005",
"0.59993577",
"0.598668",
"0.5984114",
"0.58960724",
"0.588035"... | 0.7104366 | 0 |
For a given Point, return the geoalchemy ST_Intersects instance denoting the filter for checking whether a buffered point intersects a Place's polygon. Compiling the ST_Intersects function to raw SQL is handled by SQLAlchemy. | def _postgis_buffered_intersect(
cls, point: Point, buffer: int = DEFAULT_INTERSECT_BUFFER
) -> STIntersects:
return ga.functions.ST_Intersects(
Place.polygon_raw, ga.functions.ST_Buffer(point, DEFAULT_INTERSECT_BUFFER)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __contains__(self, point):\n #### Original \n from pyresample.spherical_geometry import point_inside, Coordinate\n corners = self.corners\n\n if isinstance(point, tuple):\n return point_inside(Coordinate(*point), corners)\n else:\n return point_inside(po... | [
"0.6451758",
"0.62281686",
"0.6207443",
"0.59014815",
"0.5837364",
"0.58303154",
"0.5804181",
"0.5747233",
"0.5633233",
"0.5486501",
"0.5478541",
"0.53995526",
"0.53797233",
"0.5375333",
"0.5356589",
"0.5351182",
"0.53501034",
"0.5337037",
"0.533283",
"0.53269124",
"0.5320858... | 0.8002157 | 0 |
Find places nearest to the given lat/lon, limited to the provided radius in meters. | def nearby(cls, lat: float, lon: float, radius: float) -> List[Place]:
formatted_point = cls._format_point_postgis(lat, lon)
distance = cls._postgis_distance(formatted_point)
query = (
cls.query.with_entities(cls, distance)
.filter(distance < radius)
.order_by... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nearby(point, radius, unit):\n qs = MyModel.objects.all()\n qs = qs.filter(point__distance_lte=(point, D(**{unit: radius})))\n qs = qs.distance(point) # at this point, the type of queryset is GeoQuerySet\n qs = qs.order_by('distance')\n return qs",
"def proximity_search(self, latitude, longit... | [
"0.69890094",
"0.67637765",
"0.6754276",
"0.6674668",
"0.66336703",
"0.6588827",
"0.656497",
"0.6558636",
"0.64789915",
"0.646383",
"0.64427257",
"0.6431756",
"0.63616884",
"0.63034713",
"0.6291436",
"0.6244101",
"0.6192717",
"0.6138734",
"0.61366147",
"0.6133394",
"0.6082429... | 0.73391503 | 0 |
Gets base paths for the data directories If DATA_ROOT is set in the environment, use that as the root otherwise use "./data" individual paths can also be set in the environment | def get_default_paths():
DATA_ROOT = os.environ.get("DATA_ROOT", "data")
defaults = {
"TOKENIZE_DATA_DIR": DATA_ROOT + "/tokenize",
"MWT_DATA_DIR": DATA_ROOT + "/mwt",
"LEMMA_DATA_DIR": DATA_ROOT + "/lemma",
"POS_DATA_DIR": DATA_ROOT + "/pos",
"DEPPARSE_DATA_DIR": DATA_RO... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDataPath():\n\treturn \"..\" + os.sep + \"data\" + os.sep",
"def get_data_dir():\n return Path(current_app.config[\"USER_DIR\"]) / \"data\"",
"def get_data_path():\n return os.getcwd() + \"/data/\"",
"def data_dir():\n return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')",
... | [
"0.7406677",
"0.7309114",
"0.71558106",
"0.7086502",
"0.7073203",
"0.7061377",
"0.7024207",
"0.70034885",
"0.7000793",
"0.6972889",
"0.6858991",
"0.68468535",
"0.6798503",
"0.6786804",
"0.6725322",
"0.67091423",
"0.6696609",
"0.66939914",
"0.66862553",
"0.6677648",
"0.6662981... | 0.7681709 | 0 |
Computes the output size of the convolution for an input size | def _output_size_conv2d(conv, size):
o_size = np.array(size) + 2 * np.array(conv.padding)
o_size -= np.array(conv.dilation) * (np.array(conv.kernel_size) - 1)
o_size -= 1
o_size = o_size / np.array(conv.stride) + 1
return np.floor(o_size) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_conv1d_output_size(input_size, kernel_size, stride):\n return ((input_size - kernel_size)//stride) + 1",
"def get_conv1d_output_size(input_size, kernel_size, stride):\n return ((input_size - kernel_size)//stride) + 1",
"def outputSize(in_size, kernel_size, stride, padding):\n output = int((in_... | [
"0.8395626",
"0.8395626",
"0.791525",
"0.7697439",
"0.7266967",
"0.7062797",
"0.6977487",
"0.69722366",
"0.6958668",
"0.6910167",
"0.6910167",
"0.6910167",
"0.68975466",
"0.6889393",
"0.68615997",
"0.68195224",
"0.6790228",
"0.6773057",
"0.6769993",
"0.67444825",
"0.6736639",... | 0.8432406 | 0 |
Generator for flattening a list | def flatten(list_):
for elem in list_:
if type(elem) != list:
yield elem
else:
yield from flatten(elem) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flatten(l):\n if isinstance(l, list):\n for el in l:\n if isinstance(el, list):\n yield from flatten(el)\n else:\n yield el\n else:\n return l",
"def flatten(lst):\n \n for x in lst:\n if isin... | [
"0.80072737",
"0.7812708",
"0.7781866",
"0.7753037",
"0.7748497",
"0.76919585",
"0.7576929",
"0.75221777",
"0.75142586",
"0.74509925",
"0.7328201",
"0.73015046",
"0.7215094",
"0.72068834",
"0.7196183",
"0.716101",
"0.71484196",
"0.71413124",
"0.7091221",
"0.70742697",
"0.7053... | 0.8281699 | 0 |
Returns 'X' if the next play is player X, otherwise 'O'. | def next_player(self):
# Counter is a useful class that counts objects.
count = Counter(self.board)
if count.get('X', 0) > count.get('O', 0):
return 'O'
return 'X' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_player(current_player: Optional[str]) -> str:\n if current_player == c.X:\n return c.O\n else:\n return c.X",
"def opponent(self):\n \n if self.side == 'X':\n return 'O'\n else:\n return 'X'",
"def play_game(self, playerX, playerO):\r\... | [
"0.78836375",
"0.7374691",
"0.72335446",
"0.7131909",
"0.7131909",
"0.71021736",
"0.7066528",
"0.6987133",
"0.6833735",
"0.6827109",
"0.68047506",
"0.67475647",
"0.6744674",
"0.67023987",
"0.66803753",
"0.6667681",
"0.6654215",
"0.66286945",
"0.6595179",
"0.65725344",
"0.6539... | 0.8343033 | 0 |
If the game is over and there is a winner, returns 'X' or 'O'. If the game is a stalemate, it returns ' ' (space) If the game isn't over, it returns None. The test is to simple check for each combination of winnable states across, down, and diagonals. If none of the winning states is reached and there are no empty squa... | def is_game_over(self):
board = list(self.board)
for wins in self.WINNING:
# Create a tuple
w = (board[wins[0]], board[wins[1]], board[wins[2]])
if w == ('X', 'X', 'X'):
return 'X'
if w == ('O', 'O', 'O'):
return 'O'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winner(board):\n # Horizontal win check\n\n for i in board:\n if i[0] == i[1] and i[0] == i[2] and i[0] != EMPTY:\n if i[0] == X:\n return X\n else:\n return O\n \n # Vertical win check\n \n if board[0][0] == board[1][0] and b... | [
"0.75424594",
"0.75314796",
"0.7509053",
"0.73754984",
"0.7304914",
"0.7292957",
"0.7274899",
"0.72125685",
"0.72024804",
"0.71908337",
"0.7172468",
"0.71656585",
"0.7163477",
"0.71357334",
"0.71258956",
"0.70640254",
"0.7042327",
"0.70373565",
"0.7026418",
"0.6997687",
"0.69... | 0.8257241 | 0 |
Plays a square specified by ``index``. The player to play is implied by the board state. If the play is invalid, it raises a ValueError. | def play(self, index):
if index < 0 or index >= 9:
raise IndexError("Invalid board index")
if self.board[index] != ' ':
raise ValueError("Square already played")
# One downside of storing the board state as a string
# is that you can't mutate it in place.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_card_by_index(self, index, **kwargs):\n target = kwargs.get('target', None)\n self.hand[index].play(target=target)",
"def play_card(self, index):\n if index < self._hand.size():\n card = self._hand.pop(index)\n self._active.push(card)\n self._money =... | [
"0.65244544",
"0.6271359",
"0.62434167",
"0.6048085",
"0.6031997",
"0.6031933",
"0.60239553",
"0.5995939",
"0.5950507",
"0.5896504",
"0.5868393",
"0.5859252",
"0.5829434",
"0.57938194",
"0.574773",
"0.5732366",
"0.5729223",
"0.57218355",
"0.5710848",
"0.5704184",
"0.57040703"... | 0.85387015 | 0 |
Plays for any artificial/computers players. Returns when the computer players have played or the game is over. | def play_auto(self):
from .players import get_player
while not self.is_game_over:
next = self.next_player
player = self.player_x if next == 'X' else self.player_o
if player == 'human':
return
player_obj = get_player(player)
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def computer_play(self):\r\n # Depending on game flow, helped randomize when smack showed up\r\n # This is more of an Easter Egg than anything.\r\n if (self.tr.disks_on_board != 0 and (self.tr.disks_on_board % 6 == 0 or\r\n self.tr.disks_on_board % 6... | [
"0.75635016",
"0.6729926",
"0.67224723",
"0.6657568",
"0.65854204",
"0.6570179",
"0.653306",
"0.6512238",
"0.6473096",
"0.64597434",
"0.64450693",
"0.6369376",
"0.63294595",
"0.6306425",
"0.62985545",
"0.62729853",
"0.62689334",
"0.6259596",
"0.62440455",
"0.62413436",
"0.623... | 0.71014994 | 1 |
Test gradients of functions with NumPycompatible signatures. | def _test_gradgrad_array(func, optimized, *args):
def tangent_func():
func.__globals__['np'] = np
df = tangent.grad(func, motion='joint', optimized=optimized, verbose=True)
ddf = tangent.grad(df, motion='joint', optimized=optimized, verbose=True)
return ddf(*args)
def reference_func():
func.__... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testNestedFunctionGradientCall(self):\n check_numerics_callback.enable_check_numerics()\n\n x = constant_op.constant(1.0 - 1e-8, dtype=dtypes.float32)\n\n @def_function.function\n def asinp1(x):\n # asin()'s gradient overflows at the value close to 1.0.\n return math_ops.asin(x) + 1.0\n\n... | [
"0.68894726",
"0.67443156",
"0.6725878",
"0.66951513",
"0.6652144",
"0.6605683",
"0.6495546",
"0.6468291",
"0.646423",
"0.64637685",
"0.64289594",
"0.64160013",
"0.640552",
"0.63980377",
"0.63882357",
"0.6366985",
"0.63624823",
"0.6338595",
"0.6325254",
"0.6324864",
"0.625636... | 0.71214366 | 0 |
Return the norm of the point/vector a | def norm(a):
return distance((0, 0), a) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def norm(point):\n return np.sqrt(norm2(point))",
"def norm(x):\n return np.sqrt(norm2(x))",
"def norm(x):\n return np.sqrt(np.sum(x ** 2))",
"def norm(x):\r\n return sqrt(np.numerical.sum(x**2))",
"def norm(x):\n return inner_prod(x, x)[0].sqrt_()",
"def get_norm(x):\n return np.sqrt(n... | [
"0.83624023",
"0.7970097",
"0.78787774",
"0.7876061",
"0.7873363",
"0.7772225",
"0.7598335",
"0.7585738",
"0.7560051",
"0.7507995",
"0.7489533",
"0.74893105",
"0.7485881",
"0.7476741",
"0.74752015",
"0.74611664",
"0.74300367",
"0.7415786",
"0.7397848",
"0.73726404",
"0.736810... | 0.8523014 | 0 |
Blit surface2, centered, onto surface1 | def blit_centered(surface1, surface2):
rect = surface2.get_rect()
rect = rect.move((surface1.get_width()-rect.width)//2,
(surface1.get_height()-rect.height)//2)
surface1.blit(surface2, rect) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blit_center(screen, source_surface, pos_x, pos_y):\n screen.blit(source_surface, (pos_x - source_surface.get_width() / 2, pos_y - source_surface.get_height() / 2))",
"def draw(self, surface):\n\n\t\tsurface.blit(self.image, self.rect.topleft)",
"def blit(self, surface):\n surface.blit(self.surfac... | [
"0.6790366",
"0.62865055",
"0.6105203",
"0.60078996",
"0.5974837",
"0.58546734",
"0.57853323",
"0.57526255",
"0.5750747",
"0.57219654",
"0.56992954",
"0.5673495",
"0.5673495",
"0.5670575",
"0.56416076",
"0.5536424",
"0.55351275",
"0.5514574",
"0.55103725",
"0.5504038",
"0.547... | 0.8461208 | 0 |
Load an image file to get a pygame.Surface object | def load_image(self, filename):
return pygame.image.load(os.path.join('images', filename)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_image(file):\n\n\tfile = os.path.join(DIR_MENU_PICTURES, file)\n\ttry:\n\t\tsurface = pygame.image.load(file)\n\texcept pygame.error:\n\t\terror = \"Could not load image \\\"%s\\\" %s\"%(file, pygame.get_error())\n\t\traise SystemExit(error)\n\treturn surface.convert()",
"def load_pygame_image_file(imag... | [
"0.7788212",
"0.7500484",
"0.7495747",
"0.7308462",
"0.73018634",
"0.7167057",
"0.7153603",
"0.7048833",
"0.6874963",
"0.6826878",
"0.678292",
"0.67454195",
"0.67093194",
"0.6655639",
"0.6642116",
"0.6637948",
"0.6563296",
"0.6562086",
"0.6562086",
"0.6527124",
"0.6519311",
... | 0.7617071 | 1 |
Load a background image to get a pygame.Surface object | def load_background(self, filename):
img = pygame.image.load(filename)
return self.fit_image(img, self.width, self.height) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_background(self, image):\n self.bg = pygame.image.load(image).convert()",
"def draw(self, background, image_path):\n self.image = pygame.image.load(image_path).convert_alpha()\n background.blit(self.image, (self.x_pos, self.y_pos))",
"def blit_image_as_background(file_name, m):\n ... | [
"0.8298479",
"0.7243215",
"0.7029268",
"0.6945494",
"0.67007715",
"0.6673393",
"0.6639614",
"0.66286075",
"0.66277647",
"0.6585818",
"0.64869297",
"0.6443662",
"0.6362447",
"0.6341998",
"0.63399917",
"0.632472",
"0.6307057",
"0.6276536",
"0.6268824",
"0.6253294",
"0.62394637"... | 0.7897002 | 1 |
Load a sound file to get a pygame.mixer.Sound object | def load_sound(self, filename):
return mixer.Sound(os.path.join("sounds", filename)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadSound(path,name):\n\n class NoneSound:\n def play(self): pass\n if not pygame.mixer:\n return NoneSound()\n fullname = os.path.join(path,name)\n try:\n sound = mixer.Sound(fullname)\n except error, message:\n print \"Cannot load sound:\", name\n raise Syste... | [
"0.8373742",
"0.8346199",
"0.82731164",
"0.80291134",
"0.7898736",
"0.7575959",
"0.7433676",
"0.73934203",
"0.7203378",
"0.7201081",
"0.7186497",
"0.713058",
"0.7096019",
"0.698436",
"0.6894466",
"0.6852124",
"0.6779221",
"0.6774587",
"0.6755328",
"0.6752545",
"0.67349035",
... | 0.8446185 | 0 |
Announce a new target letter | def announce_target(self):
letter = self.bubbles[self.target].letter
question = self.load_sound("question-" + letter + ".wav")
question.play()
if android: # get_length() not supported by android.mixer
ms = 2000
else:
ms = int(question.get_length()*1000)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action(self, target, text):\n raise NotImplementedError",
"def notice(self, target, text):\n raise NotImplementedError",
"def message(self, target, *text):\n raise NotImplementedError",
"def announceGenerate(self):",
"def notice(self, target, text):\n time.sleep(1)\n ... | [
"0.64919466",
"0.6181858",
"0.5834026",
"0.5765047",
"0.57453144",
"0.5669203",
"0.5649949",
"0.56453276",
"0.56356895",
"0.5597444",
"0.55823034",
"0.55534476",
"0.55331993",
"0.5510012",
"0.5509405",
"0.5486684",
"0.54794246",
"0.54696876",
"0.54686445",
"0.5458295",
"0.545... | 0.6778086 | 0 |
Generate a new bubble | def make_bubble(self):
radius = self.bubble_radius
# Appear somewhere that doesn't interfere with any existing bubble
rangex = self.width - 2*radius
rangey = self.height - 2*radius
retry = True
while retry:
retry = False
position = [random.randran... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_bottonDown(self):\n posx = self.posx + self.sizex - 2*self.sizebotx \n posy = self.posy + self.sizeboty \n return Boton(posx, posy, self.sizebotx, self.sizeboty, color=(124, 117, 221), color_h=(95, 90, 173), text_color=(0,0,0), press_color = (36, 26, 117), font_size=5)",
"def generate_bo... | [
"0.6206574",
"0.6011409",
"0.599403",
"0.5960779",
"0.59553397",
"0.5929599",
"0.58589506",
"0.5806173",
"0.5780891",
"0.57755286",
"0.57110715",
"0.56048286",
"0.55595565",
"0.5558511",
"0.550373",
"0.549579",
"0.5465237",
"0.5449992",
"0.5449992",
"0.54353803",
"0.5409383",... | 0.7686899 | 0 |
Get the rectangle that contains this game's mode indicator | def get_mode_rect(self):
rect = self.mode_imgs[self.mode].get_rect()
return rect.move (self.width-rect.width-self.pad,
self.height-rect.height-self.pad) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRect(self):\n return self.rect()",
"def getRect(self):\n return self.rect",
"def get_roi_rect(self):\n return self.rect_list",
"def getbounds(self):\n return pygame.Rect(self.rect)",
"def get_rect (self) :\n return self.rect.copy()",
"def get_drawing_mode(self) -... | [
"0.7116032",
"0.7000409",
"0.67738515",
"0.66409504",
"0.651608",
"0.6445969",
"0.64413434",
"0.6426318",
"0.64243984",
"0.639391",
"0.62936693",
"0.6257269",
"0.6245199",
"0.6232853",
"0.62088543",
"0.6206786",
"0.6199634",
"0.61921155",
"0.6183893",
"0.61441004",
"0.6142307... | 0.8438175 | 0 |
Get the rectangle that contains the bubble count indicator | def get_bubbles_rect(self):
rect = self.bubble_imgs[len(self.bubbles)-1].get_rect()
return rect.move(self.pad, self.height-rect.height-self.pad) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_amount_rect(self):\n return pygame.Rect(self.amount.x, self.amount.y, self.amount.width, self.button_data.height)",
"def boundingRectPoints(cnt):\n\tx, y, w, h = cv2.boundingRect(cnt)\n\tfirst = (x, y)\n\tend = (x+w, y+h)\n\treturn {\"top-left\": first, \"bottom-right\":end}",
"def getRect(self)... | [
"0.6516115",
"0.64485776",
"0.6442028",
"0.6403461",
"0.6258107",
"0.6149483",
"0.61149144",
"0.6110232",
"0.6094395",
"0.6055794",
"0.60173583",
"0.59715766",
"0.59649837",
"0.59186924",
"0.5918474",
"0.5903999",
"0.58906347",
"0.5840515",
"0.58382225",
"0.5815105",
"0.58053... | 0.73384815 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.