query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
load and return the given JSON file | def load_JSON_settings(settings_name):
with open(settings_name, 'r') as fp:
setting_params = json.load(fp)
return setting_params | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_json(file_name):\n return json.load(open(file_name))",
"def loadJsonFromFile(filename):\n with open(filename) as f:\n return json.loads(f.read())",
"def loadJSONFile(filename):\n\twith open(filename, 'r') as f:\n\t\treturn json.loads(f.read())",
"def load_json_data(filepath):\n with ... | [
"0.8605273",
"0.8432861",
"0.84252906",
"0.8382293",
"0.8363001",
"0.83205587",
"0.83200425",
"0.8314659",
"0.8296076",
"0.82947344",
"0.828702",
"0.828702",
"0.8284714",
"0.82845104",
"0.825566",
"0.82483953",
"0.8241864",
"0.82348406",
"0.8230863",
"0.82261556",
"0.82178605... | 0.0 | -1 |
writes the given np coord_arr to a list a coordinates as a list of patients | def write_coord_arr_to_list(coord_arr):
l_all = []
for patient_idx in range(coord_arr.shape[0]):
l_patient = []
for idx_ in range(4):
try:
l_patient.append(coord_arr[patient_idx, idx_].tolist())
except:
l_pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_data(self, coords):\n return np.array([coords])",
"def _tolist(self, ndarray, parameter_list):\n self.elem_list = parameter_list\n for sub_elem in ndarray:\n if isinstance(sub_elem, scipy.io.matlab.mio5_params.mat_struct):\n self.elem_list.append(self._... | [
"0.5878021",
"0.571191",
"0.5638124",
"0.5474692",
"0.53919196",
"0.53831273",
"0.53269404",
"0.53227115",
"0.53191984",
"0.530413",
"0.5277807",
"0.52479595",
"0.5229723",
"0.5220619",
"0.5200421",
"0.5199747",
"0.5195946",
"0.5180879",
"0.51756644",
"0.5146393",
"0.51446664... | 0.8372239 | 0 |
r""" Computes the values of the Cumulative Error Distribution (CED). | def compute_cumulative_error(errors, bins):
n_errors = len(errors)
return [np.count_nonzero([errors <= x]) / n_errors for x in bins] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ecdf(data):\n x = np.sort(data)\n cdf = np.linspace(0, 1, len(x))\n return cdf, x",
"def cdf(self,x):\n if hasattr(x,'__len__'):\n returnCdf = np.array([self.cdf(i) for i in x])\n else:\n returnCdf = self._distribution.cdf(x)\n return returnCdf",
"def ecdf(x):\n vals, counts ... | [
"0.7010093",
"0.6755887",
"0.6752917",
"0.6749294",
"0.66857624",
"0.6573476",
"0.654841",
"0.654841",
"0.65326905",
"0.65326905",
"0.65250206",
"0.65250206",
"0.6517472",
"0.65031844",
"0.6484895",
"0.64760935",
"0.6474268",
"0.6470994",
"0.6470994",
"0.646547",
"0.6461453",... | 0.0 | -1 |
Total transit duration. See equation (3) from Seager and MalenOrnelas, 2003ApJ...585.1038S. | def transit_width(r, k, b, P=1):
return P*math.asin(r*math.sqrt( ((1+k)**2-b**2) / (1-b**2*r**2) ))/math.pi | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transit_duration(rstar, logg, per, ecc):\n # Replace large ecc values with 0.99\n ecc = np.where(ecc > 0.99, 0.99, ecc)\n # Convert logg and rstar into stellar mass\n mstar = mstar_from_stellarprops(rstar, logg)\n # Semi-major axis in AU\n semia = mstar**(1.0/3.0) * (per/365.25)**(2.0/3.0)\n ... | [
"0.7096795",
"0.68628156",
"0.68602616",
"0.6846423",
"0.68450725",
"0.67899996",
"0.6749672",
"0.6695576",
"0.66878676",
"0.6668585",
"0.66409487",
"0.6612929",
"0.65995055",
"0.65910804",
"0.65910804",
"0.6584658",
"0.6581283",
"0.65688455",
"0.6523357",
"0.6520654",
"0.651... | 0.0 | -1 |
Implementa a derivada da Sigmoid | def sigmoidPrime(self, x):
# Derivada da sigmoid
return x * (1 - x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid_derivative(x):\n return x * (1-x)",
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def sigmoid_derivative(x):\n return x * (1.0 - x)",
"def sigmoid_derivative(x):\n\n return sigmoid(x) * (1 - sigmoid(x))",
"def der_sigmoid... | [
"0.8580124",
"0.85785854",
"0.85785854",
"0.8527939",
"0.83017606",
"0.82727605",
"0.807137",
"0.807137",
"0.8047223",
"0.8037905",
"0.79700243",
"0.7969462",
"0.7944848",
"0.79404265",
"0.79317915",
"0.79248416",
"0.79248416",
"0.7923019",
"0.79199",
"0.7911824",
"0.78941286... | 0.76678085 | 48 |
Creates a TXT file with timebased name | def createFile():
with open(filename.strftime("%Y-%m-%d-%H") + ".txt", "w") as file:
file.write("") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_file():\r\n with open(fileName.strftime(\"%Y-%m-%d-%H-%M\")+\".txt\",\"w\") as file:\r\n file.write(\"\")",
"def make_time_stamp_file():\n with open(TIME_STAMP_FILE_NAME, 'w') as f:\n f.write(datetime.datetime.now().strftime('%m/%d/%Y %I:%M%p'))",
"def create_file():\n with op... | [
"0.7933328",
"0.7287594",
"0.7102997",
"0.6870335",
"0.6746742",
"0.67456836",
"0.665673",
"0.6633307",
"0.66232324",
"0.6594594",
"0.6542827",
"0.65420777",
"0.6475703",
"0.63353705",
"0.6291757",
"0.62890893",
"0.6279455",
"0.6229585",
"0.6174819",
"0.61295915",
"0.6128992"... | 0.8028866 | 0 |
Get the duration of the datathreader as a 2 decimal float | def duration(self):
return float('{0:.2f}'.format(self.end_time - self.start_time)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_duration(self):\n try:\n dur = self.im.info[\"duration\"] / 1000.0\n except KeyError:\n dur = DEFAULT_DURATION / 1000.0 \n\n return dur",
"def get_duration(self):\n return float(self.time.iloc[-1] - self.time.iloc[0])",
"def getDuration(self):\n ... | [
"0.7152822",
"0.7082311",
"0.7017189",
"0.6985959",
"0.68384147",
"0.68360186",
"0.67696273",
"0.6760591",
"0.6700899",
"0.66946393",
"0.66746825",
"0.6671913",
"0.66481084",
"0.6640803",
"0.66045827",
"0.6592772",
"0.6577906",
"0.65234166",
"0.65171283",
"0.65130013",
"0.651... | 0.7118095 | 1 |
Convert to a binary image with either 0 or 255 intensities Use Otsu's method for thresholding | def get_binary_image(grayscale_image):
_, thresholded_image = cv2.threshold(grayscale_image, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
return thresholded_image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_binary(image_convert):\n image_bit=cv2.bitwise_not(image_convert)\n _, image_bina = cv2.threshold(image_bit, 125, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)\n image_bina=image_bina/255.0\n return image_bina",
"def image_thresholding(image: np.ndarray):\n # Resize image to a shape of (48,... | [
"0.7611862",
"0.7219519",
"0.69992256",
"0.6796117",
"0.67838985",
"0.67176074",
"0.6640925",
"0.66357946",
"0.6541265",
"0.652868",
"0.6505166",
"0.6495383",
"0.6480386",
"0.6475992",
"0.643688",
"0.64328784",
"0.64195794",
"0.64106095",
"0.6399366",
"0.6386796",
"0.63596416... | 0.7171628 | 2 |
Init the weight of Conv2d in the net. | def _initialize_weights(self):
for _, cell in self.cells_and_names():
if isinstance(cell, nn.Conv2d):
cell.weight.set_data(orthogonal(cell.weight.shape, 0.6))
if cell.bias is not None:
cell.bias.set_data(
init.initializer(in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weight(self):\n init_layer(self.conv1)\n init_layer(self.conv2)\n init_bn(self.norm1)\n init_bn(self.norm2)",
"def _init_layers(self) -> None:\n super()._init_layers()\n self.controller = nn.Conv2d(\n self.feat_channels, self.num_params, 3, padding=1)... | [
"0.82414556",
"0.74198586",
"0.7410088",
"0.73912406",
"0.7264764",
"0.7261629",
"0.7248499",
"0.7234122",
"0.7192434",
"0.7192434",
"0.7123366",
"0.7091389",
"0.7086175",
"0.7085363",
"0.7078414",
"0.7064087",
"0.70600504",
"0.7002883",
"0.69863266",
"0.69817424",
"0.6950328... | 0.7712266 | 1 |
Sets the max_occupancy_percent_for_deferred_work of this SchedulingSettingsRequest. Max occupancy percent for deferred work | def max_occupancy_percent_for_deferred_work(self, max_occupancy_percent_for_deferred_work):
self._max_occupancy_percent_for_deferred_work = max_occupancy_percent_for_deferred_work | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_occupancy_percent_for_deferred_work(self):\n return self._max_occupancy_percent_for_deferred_work",
"def max_percentage(self) -> Optional[pulumi.Input[float]]:\n return pulumi.get(self, \"max_percentage\")",
"def set_progress_range(self, maximum):\r\n\r\n pass",
"def default_shri... | [
"0.7916947",
"0.5605253",
"0.5389626",
"0.5234109",
"0.5221029",
"0.52034205",
"0.5157952",
"0.51552176",
"0.5151411",
"0.5104686",
"0.5000993",
"0.49827918",
"0.49774668",
"0.4961677",
"0.49162063",
"0.48640174",
"0.48483905",
"0.4846329",
"0.4841003",
"0.483904",
"0.483904"... | 0.88194746 | 0 |
Gets the planning_period of this SchedulingSettingsRequest. Planning period settings for scheduling | def planning_period(self):
return self._planning_period | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def planning_period(self, planning_period):\n \n self._planning_period = planning_period",
"def scheduled_plan(self):\n return self._scheduled_plan",
"def payment_plan(self) -> Optional[pulumi.Input['GoogleCloudChannelV1RenewalSettingsPaymentPlan']]:\n return pulumi.get(self, \"paym... | [
"0.63097066",
"0.59322",
"0.57464033",
"0.5674838",
"0.5603584",
"0.55621403",
"0.55040866",
"0.54830056",
"0.5382483",
"0.5374944",
"0.5337149",
"0.5322155",
"0.52829057",
"0.5267297",
"0.5257149",
"0.52156997",
"0.52156997",
"0.52156997",
"0.52156997",
"0.52156997",
"0.5215... | 0.8269513 | 0 |
Sets the planning_period of this SchedulingSettingsRequest. Planning period settings for scheduling | def planning_period(self, planning_period):
self._planning_period = planning_period | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def planning_period(self):\n return self._planning_period",
"def scheduled_plan(self, scheduled_plan):\n\n self._scheduled_plan = scheduled_plan",
"def preset_period(self, preset_period):\n\n self._preset_period = preset_period",
"def period(self, period):\n\n self._period = perio... | [
"0.6623461",
"0.5530358",
"0.5446455",
"0.54360896",
"0.54360896",
"0.53161466",
"0.527272",
"0.52092683",
"0.5157237",
"0.50245416",
"0.48391896",
"0.47863162",
"0.4706275",
"0.46703228",
"0.46328416",
"0.4610133",
"0.4602447",
"0.45497674",
"0.45356178",
"0.45113328",
"0.45... | 0.85098517 | 0 |
Sets the start_day_of_weekend of this SchedulingSettingsRequest. Start day of weekend for scheduling | def start_day_of_weekend(self, start_day_of_weekend):
allowed_values = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
if start_day_of_weekend.lower() not in map(str.lower, allowed_values):
# print("Invalid value for start_day_of_weekend -> " + start_day_of_wee... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setDayStart(self, dayStart = 0):\n\t\turl = \"https://habitica.com/api/v3/user/custom-day-start\"\n\t\tpayload = {\"dayStart\": dayStart}\n\t\treturn(postUrl(url, self.credentials, payload))",
"def start_day_of_weekend(self):\n return self._start_day_of_weekend",
"def day_of_week_for_start_day(self)... | [
"0.677228",
"0.66612124",
"0.62740433",
"0.61270875",
"0.5961627",
"0.5961627",
"0.5848539",
"0.5753996",
"0.5689008",
"0.5663529",
"0.5552338",
"0.5552192",
"0.5533401",
"0.5533401",
"0.5533401",
"0.5533401",
"0.5533401",
"0.5533401",
"0.5533401",
"0.5533401",
"0.5533401",
... | 0.7426136 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.7961088",
"0.7961088",
"0.79433626",
"0.79303336",
"0.7926563",
"0.7897525",
"0.78826123",
"0.78826123",
"0.78806067",
"0.7872423",
"0.7868354",
"0.78668815",
"0.7825702",
"0.7819993",
"0.78162885",
"0.78078854",
"0.78068... | 0.79670393 | 23 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Class constructor. maxSize argument defines the size (number of data points) of the signal to be kept. maxSize must be an odd integer >= 3. | def __init__(self, maxSize=3):
try:
if maxSize % 2 == 1 and maxSize >= 3:
self._maxSize = maxSize
else:
raise ValueError("maxSize must be an odd integer >= 3")
except ValueError:
raise
self._data = np.ndarray(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, max_size):\n self.buffer = cns.deque(maxlen=max_size)",
"def __init__(self, maxSize = 100):\n self.data = [None] * maxSize\n self.size = 0\n self.maxSize = maxSize\n\n self._ratingsAdded = [] # A 'private' property to store the ratings of movies already added... | [
"0.6511763",
"0.6489326",
"0.64764595",
"0.63213646",
"0.6319538",
"0.6170838",
"0.6134951",
"0.60491717",
"0.6016471",
"0.60128975",
"0.5993277",
"0.59709257",
"0.5936412",
"0.59345204",
"0.5911776",
"0.59103847",
"0.59103286",
"0.590599",
"0.59057987",
"0.5900791",
"0.58994... | 0.7923318 | 0 |
Returns the manifest with the specified digest under the specified repository or None if none. If allow_dead is True, then manifests referenced by only dead tags will also be returned. If require_available is True, the manifest will be marked with a temporary tag to ensure it remains available. | def lookup_manifest(
repository_id,
manifest_digest,
allow_dead=False,
allow_hidden=False,
require_available=False,
temp_tag_expiration_sec=TEMP_TAG_EXPIRATION_SEC,
):
if not require_available:
return _lookup_manifest(
repository_id, manifest_digest, allow_dead=allow_dead... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_metadata(\n self,\n digest: Optional[Digest] = None,\n ignore_errors: bool = True,\n ) -> BareAsset:\n ...",
"def require_manifest(func):\n\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n # Assume the manifest is in the current directory\n try... | [
"0.546768",
"0.50335866",
"0.47207847",
"0.46484664",
"0.46398264",
"0.4575447",
"0.45535564",
"0.4481002",
"0.4471687",
"0.4456622",
"0.445138",
"0.44260305",
"0.43464047",
"0.4333441",
"0.43313584",
"0.43222734",
"0.43173176",
"0.43038434",
"0.43028927",
"0.42886522",
"0.42... | 0.81689847 | 0 |
Connects manifests to a manifest list. Raises a _ManifestAlreadyExists if any of the manifest children already exist. | def connect_manifests(manifests: list[Manifest], parent: Manifest, repository_id: int):
children = [
dict(manifest=parent, child_manifest=manifest, repository=repository_id)
for manifest in manifests
]
try:
ManifestChild.insert_many(children).execute()
except IntegrityError as e:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_manifests_to_collections(self, form):\n context = self.get_context_data()\n manifests = context['manifests']\n if form.is_valid():\n collections = form.cleaned_data['collections']\n for manifest in manifests:\n manifest.collections.add(*collections)\n ... | [
"0.6243751",
"0.58792615",
"0.5768118",
"0.5626791",
"0.5188674",
"0.51292086",
"0.5117899",
"0.51132846",
"0.50748414",
"0.50509536",
"0.50431377",
"0.5042348",
"0.5014866",
"0.50029254",
"0.48857605",
"0.48846412",
"0.48406807",
"0.481894",
"0.480648",
"0.47851428",
"0.4763... | 0.78085464 | 0 |
Returns a CreatedManifest for the manifest in the specified repository with the matching digest (if it already exists) or, if not yet created, creates and returns the manifest. Returns None if there was an error creating the manifest, unless raise_on_error is specified, in which case a CreateManifestException exception... | def get_or_create_manifest(
repository_id,
manifest_interface_instance,
storage,
temp_tag_expiration_sec=TEMP_TAG_EXPIRATION_SEC,
for_tagging=False,
raise_on_error=False,
retriever=None,
):
existing = lookup_manifest(
repository_id,
manifest_interface_instance.digest,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_manifest(\n repository_id: int,\n manifest: ManifestInterface | ManifestListInterface,\n raise_on_error: bool = True,\n) -> Optional[Manifest]:\n media_type = Manifest.media_type.get_id(manifest.media_type)\n created_manifest = None\n try:\n created_manifest = Manifest.create(\n... | [
"0.7141548",
"0.5967414",
"0.5507048",
"0.5342076",
"0.5301754",
"0.52534074",
"0.5217506",
"0.5106381",
"0.5017768",
"0.49947146",
"0.49866408",
"0.48591572",
"0.48345315",
"0.47064662",
"0.46252936",
"0.46001607",
"0.4595236",
"0.4555103",
"0.44942406",
"0.4485108",
"0.4445... | 0.60022354 | 1 |
Initialize the window with various settings. | def __init__(self, refresh_interval, total_columns):
self.total_columns = total_columns
self.window = curses.initscr()
# Initialize colors with red, green, yellow, and blue
curses.start_color()
curses.use_default_colors()
for i in range(1, 5):
curses.init_pai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init(self):\n sg.theme(gui.app_theme)\n self.window = sg.Window(\n gui.app_title,\n gui.create_layout(),\n **gui.window_config,\n )\n gui.after_window_init(self.window)",
"def __init__(self):\n self.window = Tk() # The main window\n ... | [
"0.81116277",
"0.78383064",
"0.76972675",
"0.7531565",
"0.73979884",
"0.73139054",
"0.7203358",
"0.7172624",
"0.71674234",
"0.7151764",
"0.7140042",
"0.7131872",
"0.7131455",
"0.7125354",
"0.7124967",
"0.71091825",
"0.70838815",
"0.70751417",
"0.7003645",
"0.6987067",
"0.6967... | 0.0 | -1 |
Get the color to use based on the name given. | def _get_color(self, color_name):
if not color_name:
return 0
if color_name == 'ORANGE':
color = self.COLOR_ORANGE
else:
color = getattr(curses, 'COLOR_' + color_name)
return curses.color_pair(color) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getColorValueFromName( strName ):\n dictColor = {\n \"blue\": 0x0000FF,\n \"red\": 0xFF0000,\n \"green\": 0x00FF00,\n \"yellow\": 0xFFFF00,\n \"purple\": 0x801187,\n \"pink\": 0xff00ff,\n \"orange\": 0xff9e00,\n \"brown\": 0x733300,\n \"black\":... | [
"0.7887865",
"0.74149126",
"0.7381673",
"0.7339285",
"0.7250954",
"0.71953315",
"0.7117161",
"0.7089339",
"0.6866281",
"0.6850116",
"0.66796917",
"0.66732955",
"0.6664946",
"0.66224515",
"0.66138417",
"0.6574086",
"0.64418656",
"0.64360833",
"0.64112645",
"0.63856333",
"0.637... | 0.7867748 | 1 |
Get the character input as an ASCII string. Also update the dimensions of the window if the terminal was resized. | def getch(self):
char = self.window.getch()
if char == curses.KEY_RESIZE:
self._update_dimensions()
if char == curses.KEY_ENTER or char == 10 or char == 13:
return 10
try:
return chr(char)
except ValueError:
return '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def curses_input(window, y, x, prompt, max_size=100):\n window.addstr(y, x, prompt)\n curses.echo()\n curses.curs_set(True)\n output = str(window.getstr(max_size))[2:] # Using max_size to keep user from inputting past the text area wall.\n output = output[:len(outp... | [
"0.68096846",
"0.62419784",
"0.5981157",
"0.59340024",
"0.58678216",
"0.58605695",
"0.5836747",
"0.58134633",
"0.5799098",
"0.5692625",
"0.56376284",
"0.56321806",
"0.56080884",
"0.5587672",
"0.5468298",
"0.5465023",
"0.54628885",
"0.5456365",
"0.545129",
"0.5435142",
"0.5410... | 0.6620879 | 1 |
This function modifies courses. | def update(request):
course_id = request.GET.get('course_id')
if request.method == 'POST':
course_title = request.POST['course_title']
institute_name = request.POST['institute_name']
course_desc = request.POST['course_desc']
current_data = Course.objects.get(course_id = course_id)
current_data.course_title ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_courses(self) -> None:\n\n courses_content: NavigableString = self.soup.find(\"div\", \n {\"class\": \"coursesContent\"})\n course_items: ResultSet = courses_content.find_all(\"div\", \n {\"class\": \"courseItem\"})\n\n for item in course_items:\n cour... | [
"0.7038976",
"0.69328934",
"0.6778545",
"0.67587835",
"0.67204857",
"0.669931",
"0.66926116",
"0.6624501",
"0.6541768",
"0.6522183",
"0.64383715",
"0.6368891",
"0.6358034",
"0.6225171",
"0.61680156",
"0.6141214",
"0.61330444",
"0.60902524",
"0.60539603",
"0.60107607",
"0.5991... | 0.58475745 | 38 |
Called when other + self returns NotImplemented. This function simply calls self + other when other + self cannot be performed. | def __radd__(self, other):
return self + other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __le__(self, other):\r\n return NotImplemented",
"def interferes(self, other):\n return True",
"def __ge__(self, other):\r\n return NotImplemented",
"def __ne__(self, other):\r\n if isinstance(other, self.__class__):\r\n return not self.__eq__(other)\r\n ... | [
"0.7039496",
"0.68769675",
"0.6862525",
"0.68060946",
"0.67659485",
"0.67588377",
"0.67588377",
"0.67244256",
"0.6539488",
"0.6539488",
"0.6527184",
"0.6515127",
"0.6485772",
"0.6478766",
"0.64409494",
"0.64409494",
"0.6434636",
"0.6398984",
"0.63852173",
"0.63671446",
"0.636... | 0.0 | -1 |
Checks to see if two matrices are equal. | def __eq__(self, other):
if not isinstance(other, Matrix):
return NotImplemented
if self.num_cols != other.num_cols:
return False
if self.num_rows != other.num_rows:
return False
for i in xrange(self.num_rows):
for j in xrange(self.num_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equal_size(self, other):\n if not isinstance(other, Matrix):\n raise ValueError(\"Can only compare two matrices\")\n return other.m == self.m and other.n == self.n",
"def _compare_matrix(mat1, mat2):\n\n length = len(mat1)\n if len(mat2) != length:\n return False\n\n ... | [
"0.76436555",
"0.7593046",
"0.75442225",
"0.75372857",
"0.7515891",
"0.73347795",
"0.72870797",
"0.7277634",
"0.727177",
"0.7255099",
"0.71972746",
"0.71178424",
"0.71157444",
"0.7070955",
"0.7038315",
"0.70373404",
"0.7030889",
"0.7025308",
"0.70180637",
"0.69755465",
"0.690... | 0.7593201 | 1 |
For each invariant in the dictionary, this function adds the two invariant arrays together and returns a dictionary with the aggregated numpy.array invariants. | def addInvariants(invar1, invar2):
invar_sum= {}
for key in invar1.keys():
invar_sum[key] = np.array(np.add(invar1[key], invar2[key]))
return(invar_sum) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_array(self, indep, keys, values):\n if np.ndim(values) > 1:\n values = orient(values, keys)\n dep = {k: v for k, v in zip(keys, values)}\n self.add_dict(indep, dep)",
"def concat_dicts(self, dict1, dict2):\n result = dict()\n for key, value in dict1.items():\... | [
"0.6159443",
"0.57339114",
"0.5495201",
"0.5480699",
"0.54551023",
"0.5263554",
"0.52052265",
"0.51885694",
"0.5176828",
"0.516453",
"0.51413053",
"0.51364255",
"0.5115815",
"0.50825745",
"0.5076765",
"0.5047703",
"0.50345707",
"0.49933296",
"0.49430785",
"0.4930683",
"0.4888... | 0.75019485 | 0 |
get and return the maximum value one or more health pools. | def get_max_health(self):
raise NotImplementedError('Subclasses must define max health') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_health():\r\n max_health = max(Titan.health_titans())\r\n return max_health",
"def max(self):\n assert self.__stack\n return self.__max_values[-1]",
"def get_max_value(self):\n max_value = max(self.values)\n return max_value",
"def get_max(self):\n ret... | [
"0.6779962",
"0.6637045",
"0.66275364",
"0.65154564",
"0.6500346",
"0.64756984",
"0.64756984",
"0.6422864",
"0.6329641",
"0.62989205",
"0.62914973",
"0.62818646",
"0.6269274",
"0.6262936",
"0.62550855",
"0.62526524",
"0.62502164",
"0.624022",
"0.62267345",
"0.6225227",
"0.618... | 0.66665095 | 1 |
Search for first occurance of data_after value in linked list And insert data_to_insert after data_after node | def insert_after_value(self, data_after, data_to_insert):
node_to_insert = Node(data_to_insert)
for n in self:
if n.data == data_after:
node_to_insert.next = n.next
n.next = node_to_insert
break
else:
raise ValueError(f'valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_after(self, node_to_insert_after, data):\n node = Node(data)\n temp = self.head\n while temp:\n if temp.data == node_to_insert_after:\n break\n temp = temp.next\n if not temp:\n print('Item does not exist')\n return\n... | [
"0.7964905",
"0.7177248",
"0.7085177",
"0.69286186",
"0.68221045",
"0.6644125",
"0.6558498",
"0.6512899",
"0.6457839",
"0.64519167",
"0.64303625",
"0.6349934",
"0.634939",
"0.6316602",
"0.6245741",
"0.62348914",
"0.61691016",
"0.6156659",
"0.6134268",
"0.61139137",
"0.6091736... | 0.84754515 | 0 |
Gets the destination_config of this FunctionAsyncConfig. | def destination_config(self):
return self._destination_config | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destination_config(self) -> pulumi.Output[Optional['outputs.EventSourceMappingDestinationConfig']]:\n return pulumi.get(self, \"destination_config\")",
"def destination_config(self) -> Optional[pulumi.Input['EventSourceMappingDestinationConfigArgs']]:\n return pulumi.get(self, \"destination_con... | [
"0.75422513",
"0.74022645",
"0.6830634",
"0.6475935",
"0.6430264",
"0.63108826",
"0.6212998",
"0.6045058",
"0.6009286",
"0.5964343",
"0.58853084",
"0.58707345",
"0.58563805",
"0.5793735",
"0.5772857",
"0.5772857",
"0.57362014",
"0.5721614",
"0.5701767",
"0.56813705",
"0.56788... | 0.8179568 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, FunctionAsyncConfig):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Create and return a `User` with an email, username and password. | def create_user(self, email, password=None):
if not email:
raise ValueError('Users Must Have an email address')
user = self.model(
email=self.normalize_email(email),
)
user.set_password(password)
user.save(using=self._db)
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email=None, password=None, **extra_fields):\n if not email:\n raise ValueError('The given email must be set')\n email = self.normalize_email(email)\n user = self.model(email=email, username=email, **extra_fields)\n user.set_password(password)\n u... | [
"0.8711828",
"0.86917835",
"0.8683678",
"0.86736417",
"0.86486745",
"0.86486745",
"0.8618047",
"0.8614819",
"0.86066765",
"0.8605765",
"0.8605765",
"0.8605765",
"0.8605765",
"0.8605765",
"0.8605765",
"0.8605765",
"0.8605765",
"0.85976475",
"0.8597028",
"0.8596434",
"0.8593557... | 0.8361648 | 68 |
Returns starting state of the board. | def initial_state():
return [[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_state(self):\r\n return np.zeros(self.board_size, dtype=np.int8)",
"def start_state():\n return chess.Board()",
"def startingState(self):\n # Returns starting position and 4 false because no corners are visited yet\n return (self.startingPosition, (False, False, False, False))... | [
"0.8081514",
"0.7890486",
"0.7534929",
"0.72789717",
"0.72789717",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
... | 0.0 | -1 |
Returns player who has the next turn on a board. | def player(board):
n_x,n_y=0,0
for i in range(len(board)):
for j in range(len(board[i])):
if board[i][j]==X:
n_x+=1
elif board[i][j]==O:
n_y+=1
if n_x==n_y:
return X
elif n_x>n_y:
return O
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_player(board, prev_player):\n opp = Othello.opponent(prev_player)\n if Othello.any_legal_move(opp, board):\n return opp\n elif Othello.any_legal_move(prev_player, board):\n return prev_player\n return None",
"def next_player(self,board, prev_player):\r\n... | [
"0.7911148",
"0.7521969",
"0.74204457",
"0.73687756",
"0.71954805",
"0.69775087",
"0.69621766",
"0.69253695",
"0.69208723",
"0.69010353",
"0.6845991",
"0.6841043",
"0.6838282",
"0.68265843",
"0.67751175",
"0.67751175",
"0.6769739",
"0.6713109",
"0.67060393",
"0.66561204",
"0.... | 0.62434524 | 54 |
Returns the optimal action for the current player on the board. | def minimax(board):
act=list(actions(board))[0]
if player(board)==X:
val=-1
for a in actions(board):
minval=min_val(result(board, a))
if minval>val:
act=a
val=minval
if player(board)==O:
val=1
for a in actions(board):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_best_action(self):\n if self.bestAction is None:\n self.calculate_best_action()\n return self.bestAction",
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = min... | [
"0.7766856",
"0.76323676",
"0.75855315",
"0.75285065",
"0.75175256",
"0.74667144",
"0.7460485",
"0.74263537",
"0.7416421",
"0.73943585",
"0.7375846",
"0.7333894",
"0.73147565",
"0.7306611",
"0.7284639",
"0.72650313",
"0.72650313",
"0.7250975",
"0.72331834",
"0.7203267",
"0.71... | 0.6902402 | 52 |
last_index(list, value) > integer Analogous to list.index, but returns the last index rather than the first Raises ValueError if the value is not present. | def last_index(list_, value):
found = None
for index, val in enumerate(list_):
if val == value:
found = index
if found is None:
raise ValueError("{} is not in list {}".format(value, list_))
return found | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_index_of(my_list, my_value):\n return len(my_list) - my_list[::-1].index(my_value)",
"def findlastindex(iteratee, seq):\n iteratee = fnc.iteratee(iteratee)\n return next((i for i, value in reversed(tuple(enumerate(seq))) if iteratee(value)), -1)",
"def last_index(self, item):\n ret... | [
"0.83587736",
"0.75329614",
"0.72827363",
"0.6892178",
"0.6655559",
"0.64761627",
"0.64508086",
"0.64470047",
"0.6365233",
"0.6356602",
"0.62479776",
"0.62398463",
"0.62106943",
"0.6174529",
"0.6161564",
"0.6097497",
"0.6060634",
"0.60237026",
"0.600141",
"0.5998404",
"0.5981... | 0.84004164 | 0 |
Create a list of stations available. | def processStationInfo(obs_loc_df, source, st_list=None):
if not st_list:
st_list = dict()
st_data = obs_loc_df['station_id']
lat_data = obs_loc_df['latitude (degree)']
lon_data = obs_loc_df['longitude (degree)']
for k, station_name in enumerate(st_data):
if station_name in st_list:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stations():\n\n return station_list",
"def station_list() -> List[Dict]:\n return STATIONS",
"def stations():\n # Create a link to the session\n session = Session(engine)\n \n # Query all station records\n results = session.query(Stations.station, Stations.name).all()\n \n sessio... | [
"0.80500036",
"0.72249866",
"0.6809083",
"0.67845684",
"0.676385",
"0.675018",
"0.67354494",
"0.6727803",
"0.6701201",
"0.66933435",
"0.6692809",
"0.6689335",
"0.66735435",
"0.66543055",
"0.66502094",
"0.6646061",
"0.6645725",
"0.66127",
"0.65765095",
"0.65728426",
"0.6570038... | 0.0 | -1 |
set the rvdistribution. This method defines which kind of rv_continuous distribution you use | def _set_rvdist_(self):
from astrobject.utils.decorators import make_method
from scipy import stats
kde = stats.gaussian_kde(self.samplers)
@make_method(stats.kde.gaussian_kde)
def cdf(kde, value):
return kde.integrate_box(-np.inf, value)
@ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(\n self, dist: rv_continuous, *args: Any, seed: int = 0, **kwds: Any\n ) -> None:\n rv_continuous_frozen.__init__(self, dist, *args, **kwds)\n Distribution.__init__(self, seed=seed)",
"def rset(self, parametername, rand_distr):\n raise NotImplementedError",
"def rvs(... | [
"0.60671",
"0.6033313",
"0.5764759",
"0.572546",
"0.571166",
"0.5701268",
"0.5700494",
"0.56894165",
"0.56797594",
"0.55486715",
"0.5533841",
"0.5529329",
"0.55078727",
"0.54932576",
"0.54749393",
"0.5450476",
"0.54371136",
"0.54371",
"0.5420855",
"0.5419722",
"0.5403492",
... | 0.66562265 | 0 |
get length random str | def get_random_str(length=16):
if length is None or not isinstance(length, int) or length > 1000 or length <= 0:
length = 16
alph = list("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
res_str = ""
for idx in range(length):
res_str += random.choice(alph)
return res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_str(len):\n return base64.urlsafe_b64encode(os.urandom(len))[0:len]",
"def get_random_string(length):\n return \"{0:0{1}x}\".format(random.getrandbits(length * 4), length)",
"def rndstr(length):\n return ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(length... | [
"0.7793161",
"0.76819235",
"0.767752",
"0.76543474",
"0.76537144",
"0.7653103",
"0.7531513",
"0.7523674",
"0.7476367",
"0.7473149",
"0.7467764",
"0.7455696",
"0.74454755",
"0.7408826",
"0.74076396",
"0.73925596",
"0.73435915",
"0.7332382",
"0.7311155",
"0.730733",
"0.7303771"... | 0.7372118 | 16 |
Removes entries in database after each test for a clean slate | def tearDown(self):
account_models.User.objects.all().delete()
photo_models.PhotoFeed.objects.all().delete()
photo_models.PhotoClassification.objects.filter(name__in=["Rural", "Abstract", "City"]).delete()
test_helpers.clear_directory('backend/media/', '*.jpg') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n te... | [
"0.8225033",
"0.8225033",
"0.8225033",
"0.8225033",
"0.8225033",
"0.8225033",
"0.8076206",
"0.8076206",
"0.8076206",
"0.8076206",
"0.8076206",
"0.8076206",
"0.8076206",
"0.8076206",
"0.8076206",
"0.7927216",
"0.791138",
"0.78681284",
"0.78681284",
"0.7737073",
"0.7671373",
... | 0.0 | -1 |
Test that we cannot create a new category | def test_photo_classification_view_set_post_category_not_allowed(self):
# Test data
user = account_models.User.objects.get(email='mrtest@mypapaya.io')
# Simulate auth
token = test_helpers.get_token_for_user(user)
# Get data from endpoint
client = APIClient()
cli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_category_does_not_exist(self):\n self.delete_does_not_exist_fail('hats')",
"def test_create_category(self):\n pass",
"def test_category_invalid(self):\n # wiki and questions\n ques = QuestionFactory(title=u'q1 audio')\n ques.tags.add(u'desktop')\n ans =... | [
"0.7824445",
"0.7800751",
"0.7709474",
"0.7647009",
"0.7639245",
"0.74068135",
"0.73377675",
"0.72732276",
"0.72309",
"0.7224855",
"0.7188348",
"0.7176157",
"0.7116542",
"0.7080896",
"0.7050572",
"0.7047519",
"0.704534",
"0.70413333",
"0.70413333",
"0.7022944",
"0.6987402",
... | 0.7148001 | 12 |
Test that we cannot update existing category | def test_photo_classification_view_set_post_category_update_not_allowed(self):
# Test data
user = account_models.User.objects.get(email='mrtest@mypapaya.io')
photo_models.PhotoClassification.objects.create_or_update(name='night', classification_type='category')
# Simulate auth
t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_category(self):\n pass",
"def test_edit_non_existing_item(self):\n response = self.client.put('/api/v1/category/200',\n data=json.dumps(category[3]),\n content_type='application/json',\n ... | [
"0.8009445",
"0.7693967",
"0.74554336",
"0.7302799",
"0.7285175",
"0.72747463",
"0.707762",
"0.70426387",
"0.7039388",
"0.70200515",
"0.6936492",
"0.6884651",
"0.6870146",
"0.6867035",
"0.6844735",
"0.682341",
"0.68009883",
"0.6761447",
"0.67571384",
"0.6751319",
"0.6731953",... | 0.7199024 | 6 |
Test that we create new tag even if category already exists | def test_photo_classification_view_set_post_tag_category_exists(self):
# Test data
user = account_models.User.objects.get(email='mrtest@mypapaya.io')
photo_models.PhotoClassification.objects.create_or_update(name='night', classification_type='category')
# Simulate auth
token = t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_category(self):\n pass",
"def test_create_tag(self):\n\n tag_payload = {'name': 'Test Tag'}\n self.client.post(URL_TAGS, tag_payload)\n\n is_tag_created = Tag.objects.filter(\n user=self.user,\n name=tag_payload['name']\n ).exists()\n\n ... | [
"0.7568833",
"0.74355465",
"0.7213198",
"0.7195615",
"0.7183682",
"0.7154734",
"0.711848",
"0.7118079",
"0.70748216",
"0.70475274",
"0.70018613",
"0.69618815",
"0.6912658",
"0.6908307",
"0.6898697",
"0.6851479",
"0.6788414",
"0.67860925",
"0.67504007",
"0.672034",
"0.67180616... | 0.694999 | 12 |
Test that unauthenticated users cannot create a tag | def test_photo_classification_view_set_post_category_not_authenticated(self):
# Get data from endpoint
client = APIClient()
payload = {
'name': 'Night',
'classification_type': 'tag'
}
request = client.post('/api/photo_classifications', data=payload, form... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_tag_invalid(self):\n payload = {'name':''}\n res = self.client.post(TAGS_URL,payload)\n\n # exist = Tag.objects.filter(\n # user = self.user,\n # name = payload['name']\n # ).exist()\n # self.assertFalse(exist)\n self.assertEqual(res.status_co... | [
"0.765244",
"0.7597475",
"0.7597377",
"0.7592456",
"0.745583",
"0.738124",
"0.72637075",
"0.72534597",
"0.7216722",
"0.71853924",
"0.71424145",
"0.7139631",
"0.707397",
"0.7008247",
"0.6954742",
"0.69404024",
"0.6929219",
"0.6928253",
"0.6928253",
"0.69277984",
"0.6866543",
... | 0.0 | -1 |
Test that tag updates if it already exists | def test_photo_classification_view_set_post_update(self):
# Test data
user = account_models.User.objects.get(email='mrtest@mypapaya.io')
# Simulate auth
token = test_helpers.get_token_for_user(user)
# Get data from endpoint
client = APIClient()
client.credential... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def case_update_record(self, refresh_db_before):\n original_name = \"tag3\"\n update_name = \"tag33\"\n\n original_tag = TagOp.add(original_name)\n\n updated_tag_local = TagOp.update(original_tag, update_name)\n\n self.assertEqual(updated_tag_local.name, update_name)\n\n u... | [
"0.6752314",
"0.6645033",
"0.6605625",
"0.65266347",
"0.64991987",
"0.64845186",
"0.6472134",
"0.6426415",
"0.6388547",
"0.6367146",
"0.6351428",
"0.63510734",
"0.63500595",
"0.6307069",
"0.62685674",
"0.62224436",
"0.61875325",
"0.618205",
"0.61776465",
"0.61609906",
"0.6058... | 0.0 | -1 |
Entropy of softmax distribution from logits. | def tent(x: torch.Tensor) -> torch.Tensor:
return -(x.softmax(1) * x.log_softmax(1)).sum(1).mean(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_entropy_loss(logits):\n policy = F.softmax(logits, dim=-1)\n log_policy = F.log_softmax(logits, dim=-1)\n return torch.sum(policy * log_policy)",
"def entropy(self, logits):\n probs = torch.exp(logits)\n entropy = - torch.sum(probs * logits, dim=-1)\n return entropy",
... | [
"0.7966522",
"0.79658586",
"0.7916042",
"0.7810517",
"0.7522901",
"0.74168384",
"0.74123365",
"0.7400734",
"0.73035353",
"0.72315216",
"0.72182524",
"0.7217247",
"0.72030485",
"0.71921307",
"0.7168925",
"0.7139233",
"0.7093064",
"0.70716107",
"0.7060354",
"0.7057157",
"0.7057... | 0.6606451 | 97 |
Restore the model states from copies. | def load_model_state(model, model_state):
model.load_state_dict(model_state, strict=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore(self):\n self.u = self.ub.copy()\n self.w = self.wb.copy()\n self.v = self.vb.copy()\n if self.en_bias: self.b = self.bb.copy()",
"def reset_states(self):\n self.model.reset_states()",
"def copy_model_state(model):\n model_state = deepcopy(model.state_dict())\n... | [
"0.7420439",
"0.71600735",
"0.71301925",
"0.69811624",
"0.6966658",
"0.69341594",
"0.6910358",
"0.6904161",
"0.68637836",
"0.6859912",
"0.6813869",
"0.6773659",
"0.67676014",
"0.6717044",
"0.66513556",
"0.6640452",
"0.6606937",
"0.6592264",
"0.6560918",
"0.6560918",
"0.656091... | 0.0 | -1 |
RedisDict bonded to empty hash in Redis. | def redis_empty_dict(r):
return RedisDict(r, REDIS_TEST_KEY_NAME) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redis_dict_without_pickling(r, str_dict):\n return RedisDict(r, REDIS_TEST_KEY_NAME, str_dict, pickling=False)",
"def mempty(self) -> 'Dictionary':\n return Dictionary()",
"def clear(self):\n super(ReadOnlyDict, self).clear() # pragma: no cover",
"def redis_dict(r, str_dict):\n retur... | [
"0.64201534",
"0.6219713",
"0.6125247",
"0.5951614",
"0.57764703",
"0.5716999",
"0.5537034",
"0.5528273",
"0.551253",
"0.5501525",
"0.55012083",
"0.5500777",
"0.5489906",
"0.54686487",
"0.5437877",
"0.54261166",
"0.54261166",
"0.53179675",
"0.53132236",
"0.5286398",
"0.528476... | 0.80164963 | 0 |
Return Redis key name for the attribute. | def get_key_name(self, instance):
return REDIS_TEST_KEY_NAME | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attribute_key(self) -> str:\n return pulumi.get(self, \"attribute_key\")",
"def attribute_key(self) -> Optional[str]:\n return pulumi.get(self, \"attribute_key\")",
"def key(self) -> \"str\":\n return self._attrs.get(\"key\")",
"def key(self):\n return key_for_name(self.name)"... | [
"0.8305955",
"0.77183694",
"0.76684827",
"0.75221753",
"0.7517357",
"0.7443731",
"0.742038",
"0.7283869",
"0.725613",
"0.7186136",
"0.7126229",
"0.7126229",
"0.7126229",
"0.7126229",
"0.7126229",
"0.7126229",
"0.7126229",
"0.7126229",
"0.7126229",
"0.7126229",
"0.7126229",
... | 0.69791734 | 74 |
Class with RedisDictField attribute. | def model_with_redis_dict_field(r):
class Model(object):
redis_field = RedisTestDictField(r)
return Model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_with_redis_dict_field_without_pickling(r):\n class Model(object):\n redis_field = RedisTestDictField(r, pickling=False)\n\n return Model",
"def redis_dict(r, str_dict):\n return RedisDict(r, REDIS_TEST_KEY_NAME, str_dict)",
"def __init__(self, dict):\n self.dict = dict",
"def... | [
"0.75536007",
"0.65944356",
"0.64880127",
"0.64880127",
"0.63377225",
"0.6124745",
"0.6121959",
"0.6121959",
"0.60784256",
"0.60784256",
"0.59534425",
"0.5888958",
"0.5888958",
"0.58729315",
"0.5864974",
"0.5864974",
"0.58613485",
"0.58509606",
"0.5841727",
"0.5823304",
"0.58... | 0.80719596 | 0 |
Class with RedisDictField attribute without pickling. | def model_with_redis_dict_field_without_pickling(r):
class Model(object):
redis_field = RedisTestDictField(r, pickling=False)
return Model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_with_redis_dict_field(r):\n class Model(object):\n redis_field = RedisTestDictField(r)\n\n return Model",
"def redis_dict_without_pickling(r, str_dict):\n return RedisDict(r, REDIS_TEST_KEY_NAME, str_dict, pickling=False)",
"def __init__(self, dict):\n self.dict = dict",
"def... | [
"0.76974267",
"0.72041583",
"0.6281665",
"0.6281665",
"0.6214466",
"0.6043084",
"0.6043084",
"0.6006625",
"0.6006625",
"0.59520364",
"0.591041",
"0.5866702",
"0.5846227",
"0.5835017",
"0.582894",
"0.58205587",
"0.58055514",
"0.5805501",
"0.57616353",
"0.57616353",
"0.5760138"... | 0.8135568 | 0 |
Test that values are subtracted and returned | def test_subtract_numbers(self):
self.assertEqual(subtract(5, 11), 6) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_subtract(self):\n self.assertEqual(work_file.subtract(10, 5), 5)\n self.assertEqual(work_file.subtract(-1, 1), -2)\n self.assertEqual(work_file.subtract(-1, -1), 0)",
"def test_subtract_numbers(self):\n self.assertEqual(subtract(8, 4), 4)",
"def test_subtract_all_args_less_... | [
"0.77646315",
"0.7661046",
"0.76025593",
"0.758968",
"0.74826324",
"0.74406016",
"0.73435175",
"0.7326791",
"0.7326791",
"0.73003215",
"0.7268925",
"0.72362894",
"0.7199234",
"0.71817863",
"0.7157751",
"0.71565974",
"0.7133214",
"0.71297365",
"0.71252316",
"0.7100931",
"0.708... | 0.75898397 | 4 |
Set a value to the default value field. | async def save(self, category, key, value=None):
await super(MemoryKVCache, self).save(category, key, value)
if self.in_transaction:
self.dirty_categories.add(category) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default(self, default):\n\n self._set_field(\"value\", default)",
"def set_value_to_default(self):\n self.setValue(self.default_value)",
"def default_value(self, default_value):\n\n self._default_value = default_value",
"def default_value(self, default_value):\n\n self._defaul... | [
"0.8779659",
"0.85444957",
"0.84207463",
"0.84207463",
"0.84207463",
"0.8336261",
"0.82971627",
"0.8248145",
"0.8235928",
"0.78229636",
"0.76896775",
"0.7598059",
"0.7531874",
"0.75219864",
"0.7491882",
"0.7438307",
"0.73879236",
"0.73678184",
"0.73588204",
"0.7180897",
"0.71... | 0.0 | -1 |
Generate one hot binary matrix | def encode(self, label, length_frames=None, length_seconds=None):
if length_frames is None and length_seconds is None:
length_frames = self.length_frames
elif length_seconds is not None:
length_frames = self._length_to_frames(length_seconds)
# Initialize binary matrix
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_encode(x):\n # TODO: Implement Function\n output = np.zeros((len(x), 10))\n \n for i, j in enumerate(x):\n output[i,j] = 1\n \n return output",
"def one_hot(y_):\n y_ = y_.reshape(len(y_))\n n_values = int(np.max(y_)) + 1\n n_values = 6\n return np.eye(n_va... | [
"0.8056837",
"0.78720427",
"0.77532697",
"0.7739419",
"0.7723329",
"0.77147806",
"0.7691257",
"0.7685687",
"0.7681857",
"0.7680022",
"0.76333004",
"0.76247257",
"0.7618028",
"0.76124305",
"0.76044375",
"0.75935614",
"0.7585162",
"0.75542283",
"0.7552957",
"0.7540989",
"0.7526... | 0.0 | -1 |
Generate one hot binary matrix | def encode(self, label_list, length_frames=None, length_seconds=None):
if length_frames is None and length_seconds is None:
length_frames = self.length_frames
elif length_seconds is not None:
length_frames = self._length_to_frames(length_seconds)
# Initialize binary ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_encode(x):\n # TODO: Implement Function\n output = np.zeros((len(x), 10))\n \n for i, j in enumerate(x):\n output[i,j] = 1\n \n return output",
"def one_hot(y_):\n y_ = y_.reshape(len(y_))\n n_values = int(np.max(y_)) + 1\n n_values = 6\n return np.eye(n_va... | [
"0.8056837",
"0.78720427",
"0.77532697",
"0.7739419",
"0.7723329",
"0.77147806",
"0.7691257",
"0.7685687",
"0.7681857",
"0.7680022",
"0.76333004",
"0.76247257",
"0.7618028",
"0.76124305",
"0.76044375",
"0.75935614",
"0.7585162",
"0.75542283",
"0.7552957",
"0.7540989",
"0.7526... | 0.0 | -1 |
(Onetime setup) Set the Steam API key to use `steamlink` and `update` commands | async def steamkey(self, ctx, key):
set_steam_key(key)
await self.bot.say("The Steam API key has been successfully added! Delete the previous message for your own safety!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def osukey(self, ctx, key):\r\n\r\n # Load config\r\n config_boards = await self.config.apikey()\r\n\r\n # Set new config\r\n await self.config.apikey.set(key)\r\n await ctx.send(\"The apikey has been added.\")",
"def __init__(self, api_key):\n SteamAPI.__init__(se... | [
"0.64083797",
"0.6353094",
"0.6185101",
"0.61739564",
"0.5894398",
"0.57930386",
"0.5777126",
"0.57766205",
"0.57760954",
"0.5773908",
"0.57033867",
"0.56754607",
"0.56754607",
"0.55801696",
"0.5563842",
"0.5533823",
"0.5533064",
"0.54983777",
"0.5498307",
"0.5458175",
"0.544... | 0.6823392 | 0 |
Initialize a Player instance. | def __init__(self):
self.score = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, player):\n\t\tself.player = player",
"def __init__(self, player):\n self.player = player",
"def __init__(self, *args, **kwargs):\n super(Player, self).__init__(*args, **kwargs)",
"def setUp(self):\n self.player = Player()",
"def __init__(self,player,name,playerFn):\n... | [
"0.7197622",
"0.7167967",
"0.7063115",
"0.70306",
"0.67478096",
"0.669692",
"0.6631112",
"0.6600225",
"0.65990525",
"0.64398825",
"0.6438824",
"0.6408511",
"0.63888615",
"0.63688785",
"0.6362048",
"0.6334238",
"0.6327995",
"0.629456",
"0.627034",
"0.6222803",
"0.6205392",
"... | 0.0 | -1 |
Returns samples from GP at evenlyspaced gridpoints given paded datapoints | def get_GP_samples(self):
Z = tf.zeros([0, self.max_x_len, self.input_dim])
# setup tf while loop (have to use this bc loop size is variable)
def cond(i, Z):
return i < self.N
def body(i, Z):
Yi = tf.reshape(tf.slice(self.Y, [i, 0], [1, self.num_obs_values[i]])... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sampleFromGrid(grid, xypoints, method='nearest'):\n samples = []\n for lon, lat in xypoints:\n sample = grid.getValue(lat, lon, method=method)\n samples.append(sample)\n\n return np.array(samples)",
"def gendata(params,xmin,xmax,npts=4000):\n F = lorentzian.ForwardFactory\n def g... | [
"0.7148206",
"0.62851584",
"0.6281688",
"0.621456",
"0.62108934",
"0.61389947",
"0.6075141",
"0.6068203",
"0.5948151",
"0.5902537",
"0.588408",
"0.5855225",
"0.58526117",
"0.5841167",
"0.5793296",
"0.5699817",
"0.56922257",
"0.5691657",
"0.56577003",
"0.56499517",
"0.56398493... | 0.0 | -1 |
Get a valid profiler token. The returned token is the first one generated by the scanner. Usually used to get a valid token when its associated request does not matter. Returns None if no token. | def token(self):
if not self.requests:
return None
return self.requests[0].token | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_token(self):\n if not self.is_valid():\n logger.warn(\"TokenWall form data is not valid.\")\n return None\n \n tt = self.cleaned_data['token']\n logger.debug(\"Looking for token '%s'\"%tt)\n return Token.objects.get(value=tt)",
"def token(self) -> Opti... | [
"0.6692761",
"0.66523546",
"0.65318984",
"0.64988965",
"0.6435164",
"0.6415043",
"0.64110565",
"0.64110565",
"0.6363242",
"0.63546586",
"0.6322918",
"0.6320829",
"0.6257245",
"0.62358737",
"0.6229628",
"0.6218761",
"0.6213761",
"0.619603",
"0.6188469",
"0.6138024",
"0.6134907... | 0.7117313 | 0 |
Initialize a data frame. | def __init__(self, header=None, rows=None, fromfile=None, delimiter=','):
if fromfile:
rs = Csv(fromfile,delimiter=delimiter).getRows()
self.header=rs[0]
self.data = [] #a list of dictionaries
for r in rs[1:]:
acc= dict()
for h in self.header:
acc[h]=r[self.header.index(h)]
self.data.ap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, df):\n self.data = df",
"def __init__(self, df):\n self.df = df",
"def __init__(self, dataFrame):\n self.dataFrame = dataFrame",
"def __init__(self):\n\n self.active_df = pd.DataFrame([], columns=['txt_name', 'missing_data_days'])",
"def compile_dataframe_defa... | [
"0.75453025",
"0.72874",
"0.7204559",
"0.7147761",
"0.7001648",
"0.69984347",
"0.6981776",
"0.69805706",
"0.69677985",
"0.6932145",
"0.67962825",
"0.6739545",
"0.6727906",
"0.6693584",
"0.66743135",
"0.66560656",
"0.6649449",
"0.6635931",
"0.66358566",
"0.6607201",
"0.6587733... | 0.0 | -1 |
Return the values of fieldname without repetitions. | def uniqField(self, fieldname):
retval = list(set(self.getField(fieldname)))
retval.sort()
return retval | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _field_names(self):\n return [self._sanitize_field_name(field_name)\n for field_name in self._all_fields]",
"def give_field(self,\r\n fieldname):\r\n\r\n return [a_temp for a_temp in self.default_dict['field']\r\n if self.default_dict['field'][a_t... | [
"0.6538446",
"0.6469777",
"0.6386878",
"0.632244",
"0.62570447",
"0.61468",
"0.60670495",
"0.6012402",
"0.5968854",
"0.59179586",
"0.5876543",
"0.58687055",
"0.5850973",
"0.58311003",
"0.582402",
"0.5812662",
"0.57811105",
"0.57788193",
"0.5775718",
"0.5764108",
"0.574689",
... | 0.6975132 | 0 |
Gets the pipeline name | def name(self) -> str:
return self._model.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pipeline_name(self) -> typing.Optional[str]:\n return self._values.get(\"pipeline_name\")",
"def unique_pipeline_name(self):\n return self._unique_pipeline_name",
"def pipeline_stack_name(self) -> str:\n return self._values.get(\"pipeline_stack_name\")",
"def get_pipename(self):\n ... | [
"0.873063",
"0.83483547",
"0.80125856",
"0.7505462",
"0.7210236",
"0.72053933",
"0.7029275",
"0.6845817",
"0.6823633",
"0.6770451",
"0.6770451",
"0.67413425",
"0.67270154",
"0.67270154",
"0.6669689",
"0.6628194",
"0.6623239",
"0.6587401",
"0.65745944",
"0.65745944",
"0.657459... | 0.0 | -1 |
Gets the pipeline configuration | def config(self) -> PipelineConfiguration:
return self._config | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def innerPipelineConfig(self):\n return dict(self._innerPipelineConfig)",
"def get_config(self):\n return self.config",
"def get_configs_from_pipeline_file():\n pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()\n with tf.gfile.GFile(FLAGS.pipeline_config_path, 'r') as f:\n text_format... | [
"0.7355015",
"0.7287683",
"0.7193988",
"0.7096481",
"0.6980323",
"0.6980323",
"0.69613886",
"0.69613886",
"0.69613886",
"0.691556",
"0.68985987",
"0.68962705",
"0.6876026",
"0.68680847",
"0.68553656",
"0.6852279",
"0.6852279",
"0.6845794",
"0.68381774",
"0.68196905",
"0.68196... | 0.8675036 | 0 |
Creates and updates the vocab of the pipeline. | def create_vocab(
self,
instance_datasets: Iterable[InstanceDataset],
config: Optional[VocabularyConfiguration] = None,
) -> Vocabulary:
# The transformers feature comes with its own vocab, no need to create anything if it is the only feature
if self.config.features.configure... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_vocab(vocab_path='ORBvoc-synth.txt'):\n total_time = 10 # seconds\n num_frames = 20\n speed = 3.0\n vocab_builder = VocabularyBuilder()\n for seed in tqdm(range(100), total=100):\n image_builder = DemoImageBuilder(\n mode=ImageMode.MONOCULAR, seed=seed,\n len... | [
"0.63968766",
"0.62892616",
"0.62852716",
"0.62663436",
"0.62200564",
"0.6186499",
"0.61160433",
"0.60784763",
"0.5955692",
"0.59366024",
"0.5934377",
"0.5905164",
"0.58839726",
"0.58839726",
"0.5844991",
"0.58401084",
"0.5831726",
"0.5829532",
"0.58119136",
"0.58077466",
"0.... | 0.5779162 | 21 |
Given a text message, try each registered module for an answer. Sync & Multisync first If no module answered, try every known ListenModule | def module_answer(self, msg):
if self.mute:
return
# First we look if a SyncModule or a MultiSyncModule matches
sync = self._modules.sync_answer(msg)
if sync is not None:
return sync
# Else we try listen modules
return self._modules.listen_answer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listen_answer(self, msg):\n result = []\n for module in self.listen:\n ret = module.do_answer(msg)\n if ret is not None:\n result.append(ret)\n return result",
"def sync_answer(self, msg):\n for module in self.synchronous + self.multisync:\n ... | [
"0.6806259",
"0.62682265",
"0.53694475",
"0.53562963",
"0.525517",
"0.52376944",
"0.5231438",
"0.52137244",
"0.5082328",
"0.5066513",
"0.5048198",
"0.50383705",
"0.49853644",
"0.4977672",
"0.4957682",
"0.49494138",
"0.49402237",
"0.4932302",
"0.49027973",
"0.48628023",
"0.484... | 0.6568612 | 1 |
Get current device of the model. | def device(self):
return next(self.parameters()).device | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_device(model):\n p = next(model.parameters())\n return p.device",
"def device(self):\n hw = self.hw()\n if hw: return hw.device()",
"def get_device(self):\n return self.parent.get_device()",
"def get_device(self):\n raise NotImplementedError()",
"def device(self):\... | [
"0.8451629",
"0.8336302",
"0.8156139",
"0.79795",
"0.7907886",
"0.7892091",
"0.7839723",
"0.77778757",
"0.7704541",
"0.7697506",
"0.76079154",
"0.7539509",
"0.7539212",
"0.750548",
"0.7503331",
"0.74997234",
"0.7478831",
"0.74150723",
"0.7412623",
"0.7334912",
"0.733162",
"... | 0.78706473 | 9 |
Return global np.ma with south hemisphere masked | def SH_unmasked(res='4x5', mask2D=False):
# Create a dummy array of ones, with all locations masked
m = np.ma.array(np.ones(get_dims4res(res)), mask=True)
if res == '4x5':
lats = np.arange(-89, 0, 1)
if res == '2x2.5':
lats = np.arange(-90, 0, 1)
print('CHECK (SH) mask for non 4x... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mediterranean_sea_unmasked(res='0.25x0.3125'):\n # West South corner (south Jordan) =\n lowerlat = 34\n lowerlon = -6.5\n # East North corner (~Ukraine)\n higherlat = 47\n higherlon = 38\n # Get a mask for lat and lon range, then combine\n mask1 = lat2lat_2D_unmasked(res=res, lowerl... | [
"0.63388294",
"0.61048293",
"0.6068145",
"0.5969097",
"0.59386396",
"0.57656807",
"0.56518656",
"0.562968",
"0.5526954",
"0.5524211",
"0.54857373",
"0.5482209",
"0.5481902",
"0.54814094",
"0.54199237",
"0.5408624",
"0.53933185",
"0.53055495",
"0.52989125",
"0.5290547",
"0.528... | 0.5184544 | 28 |
Index Router Function. Returns str HTML content to be displayed. | def index():
folders = [
{
'filename': 'img/plexiglass.jpg',
'title': 'Plexiglass'
},
{
'filename': 'img/watercolor.jpg',
'title': 'Watercolor'
},
{
'filename': 'img/acry... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self):\n\t\treturn render_template('index.html')",
"def index():\n\n\treturn(render_template('index.html'))",
"def index():\r\n return render_template('index.html')",
"def index():\n return render_template('index.html')",
"def index():\n return render_template('index.... | [
"0.78963804",
"0.7895551",
"0.7890983",
"0.7857184",
"0.7810676",
"0.7810676",
"0.77791834",
"0.77791834",
"0.777063",
"0.7756342",
"0.77466923",
"0.77228546",
"0.7715286",
"0.7691639",
"0.7691639",
"0.7691639",
"0.7691639",
"0.7691639",
"0.7691639",
"0.7691639",
"0.7691639",... | 0.0 | -1 |
Initializes the weights of a layer based on type. | def _init_weights(layer):
if isinstance(layer, (nn.Conv2d, nn.Linear)):
torch.nn.init.xavier_uniform_(layer.weight)
try:
# Some layers may not have biases, so catch the exception and pass.
layer.bias.data.fill_(0.0)
except AttributeError:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(layer):\r\n layer_name = layer.__class__.__name__\r\n if layer_name.find(\"Conv\") != -1:\r\n layer.weight.data.normal_(0.0, 0.02)\r\n elif layer_name.find(\"BatchNorm\") != -1:\r\n layer.weight.data.normal_(1.0, 0.02)\r\n layer.bias.data.fill_(0)",
"def init_weight... | [
"0.8026719",
"0.79981583",
"0.7717767",
"0.76808214",
"0.7620303",
"0.7523248",
"0.74638075",
"0.73835725",
"0.72546434",
"0.7249309",
"0.7193085",
"0.7190829",
"0.71420956",
"0.71228194",
"0.7099279",
"0.70919275",
"0.7089649",
"0.7089649",
"0.7089649",
"0.70615983",
"0.7061... | 0.72523284 | 9 |
Adds command line args for configuring the pipeline. Adds options for selecting the model, shaves and inference threads. | def add_pipeline_args(parser, model_list):
parser.add_argument('-m',
'--model',
type=str,
choices=list(model_list.keys()),
help="The model to run")
parser.add_argument('-sh',
'--shaves',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_args(args):\n global DATA_PATH\n global IMAGES_FILE\n global WORKING_DIR\n global OUTPUT_DIR\n global OUTPUT_FILE_NAME\n global OUTPUT_FILE\n global LOAD_INDEXES\n global INDEXES_DIR\n global MODEL\n global JOIN_MODELS\n global MODEL1\n global MODEL2\n global ALL_TOGE... | [
"0.681615",
"0.6795085",
"0.66913223",
"0.6621237",
"0.65925",
"0.6497877",
"0.64701736",
"0.6451968",
"0.64506847",
"0.6420163",
"0.6394575",
"0.6344974",
"0.6336227",
"0.6319977",
"0.6267847",
"0.6255978",
"0.62495655",
"0.624629",
"0.61646086",
"0.61518407",
"0.6144076",
... | 0.74329317 | 0 |
Test initialization of the linked_list. | def test_linked_list_init():
from linked_list import Linked_List
assert type(Linked_List) == type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testInit(self):\n\n self.assertEqual(\n [],\n self.node.desc\n )",
"def test_create_instance_of_list(empty_list):\n assert isinstance(empty_list, LinkedList)",
"def test_lined_list_create_with_non_iterable():\n from linked_list import Linked_List\n new_linked_li... | [
"0.6970318",
"0.69134146",
"0.6891661",
"0.66955554",
"0.6654959",
"0.6651865",
"0.6616754",
"0.65155065",
"0.6509969",
"0.6471623",
"0.64585274",
"0.6457724",
"0.6410828",
"0.63922036",
"0.6371115",
"0.63643837",
"0.62999535",
"0.62957716",
"0.6295157",
"0.62817955",
"0.6256... | 0.79517245 | 0 |
Covered area in degree squared | def covered_area(MW_exclusion=10,ra_range=(-180,180),dec_range=(-90,90),
MCpoints=1e6):
# Area in steradians without accounting for MW exclusion
area_sr = ((np.sin(dec_range[1] * _d2r)
- np.sin(dec_range[0] * _d2r))
* (ra_range[1] - ra_range[0]) * _d2r)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(self):\n return 0.5*np.abs(np.dot(self.x,np.roll(self.y,1))-np.dot(self.y,np.roll(self.x,1)))",
"def area(self):\n return math.pi * self._r ** 2",
"def area(self):\n return math.pi * self.radius ** 2",
"def area(self):\n return math.pi * self.radius ** 2",
"def compute_... | [
"0.7428111",
"0.7292231",
"0.72435004",
"0.72435004",
"0.72343475",
"0.7223233",
"0.7222014",
"0.7202572",
"0.71741915",
"0.7150283",
"0.71409106",
"0.71362054",
"0.7131154",
"0.7125499",
"0.7081024",
"0.7062185",
"0.70130146",
"0.70014006",
"0.6998557",
"0.696581",
"0.695973... | 0.0 | -1 |
Internal method used to build dictionaries of transaction simulations where the Transaction is of type `ttype`. | def _buildTransDict(self, fromdt, todt, ttype):
totalsDict = self._buildTotalsDict(fromdt, todt)
sortedTotsList = dictToSortedList(totalsDict)
return dict([(k,v) for k,v in totalsDict.iteritems() if type(k) == ttype]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _buildTotalsDict(self, fromdt, todt):\r\n pairs = [(t, t.effectForPeriod(fromdt, todt)) for t in self.transactions]\r\n return dict(pairs)",
"def __create_ttable(self):\n # Currently assume equiprobable distribution\n # Indexed by previous interval and current interval\n ttable = {... | [
"0.609022",
"0.54209185",
"0.54155606",
"0.539557",
"0.5393548",
"0.53923815",
"0.5360385",
"0.52636176",
"0.5234778",
"0.52265805",
"0.5220168",
"0.5216405",
"0.51883924",
"0.51666945",
"0.51582545",
"0.514276",
"0.514204",
"0.5125532",
"0.51095134",
"0.5099296",
"0.5094789"... | 0.69015527 | 0 |
Return the current active device. | def device():
return G.DEVICE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current(self):\n with driver.get_active_context() as ac:\n devnum = ac.devnum\n if devnum is not None:\n return self[devnum]",
"def _get_current_device() -> Device | None:\n if task_runtime.has_environment():\n return task_runtime.get_current_devi... | [
"0.7714562",
"0.7410933",
"0.73916423",
"0.7334869",
"0.7249466",
"0.7243964",
"0.7031362",
"0.7031362",
"0.7031362",
"0.7031362",
"0.7031362",
"0.7030778",
"0.6990392",
"0.69769025",
"0.6895579",
"0.68638945",
"0.6838373",
"0.6825193",
"0.67697656",
"0.6695019",
"0.66706926"... | 0.67566764 | 19 |
Get the content from the clipboard. | def get_clipboard(*args, **kwargs):
return G.DEVICE.get_clipboard(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clipboard(self, text = None):\n if text == None:\n response = self._fetch_json('/api/clipboard')\n return response['content']\n else:\n postdata = codecs.encode(json.dumps({ 'content': text }), 'utf-8')\n self._urlopen('/api/clipboard', postdata).read()... | [
"0.80227715",
"0.7796126",
"0.77837545",
"0.7616083",
"0.7047286",
"0.69048816",
"0.68784064",
"0.6874578",
"0.67571247",
"0.67247057",
"0.6711732",
"0.6607787",
"0.6553334",
"0.647371",
"0.64348483",
"0.64073515",
"0.6318127",
"0.6308883",
"0.6262955",
"0.6262429",
"0.620850... | 0.72688305 | 4 |
Return a list of serialized widget values for each widget with a value. | def get_widget_states(self) -> List[WidgetStateProto]:
with self._lock:
if self._disconnected:
return []
return self._state.get_widget_states() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_list(self):\n return list(self.widget_dict.values())",
"def storeListWidgetValues(self):\n\n\t\twidget = self.sender()\n\t\tcategory, attr = self.getWidgetMeta(widget)\n\t\titems = []\n\t\tfor i in range(widget.count()):\n\t\t\titems.append(widget.item(i).text())\n\t\tself.storeValue(category, at... | [
"0.7447618",
"0.6931331",
"0.67679846",
"0.6166125",
"0.60800654",
"0.6026928",
"0.5929822",
"0.588867",
"0.58174974",
"0.5807192",
"0.5799962",
"0.57959455",
"0.575508",
"0.57238525",
"0.57167",
"0.5664999",
"0.5663227",
"0.56457156",
"0.55709183",
"0.5566127",
"0.55654615",... | 0.51561767 | 79 |
Takes URL and replaces all unallowed Unix and Windows filename characters so that some semblance of the URL can be used as part of a filename | def url_to_filename(base_url: str):
# Cuts fluff like 'http://' ~and 'www'~
base_url = prune_url(base_url, cut_chars=["https://", "http://", "www."])
# Covers both Windows and Unix
forbidden_ascii = ["/", "\\", "\|", ":", "?", "'", '"', "?", "*", ">", "<"]
for ascii_char in forbidden_ascii:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_filename(url):\n valid_chars = \"-_() %s%s\" % (string.ascii_letters, string.digits)\n nodot = url.replace('.','_').replace(':','_')\n filename = ''.join([c for c in nodot if c in valid_chars])\n return filename",
"def fix_filename(urlTitle):\n fixed = urlTitle.replace('//', '/')\n... | [
"0.83347106",
"0.7839066",
"0.75418764",
"0.7240267",
"0.7062264",
"0.69229084",
"0.68914294",
"0.6880469",
"0.686369",
"0.6797314",
"0.67877764",
"0.6773474",
"0.67089236",
"0.6708351",
"0.6689056",
"0.66651857",
"0.66530824",
"0.66175187",
"0.65951604",
"0.6555656",
"0.6525... | 0.7760686 | 2 |
Function that generates the next datetime based off a specified interval | def gen_next_time(intervals, start_time=[6, 0, 0], end_time=[23, 0, 0]):
now = datetime.now()
year = now.year
month = now.month
day = now.day
starttime, endtime = gen_start_end_times(
start_time=start_time, end_time=end_time
)
next_datetime = starttime
while next_datetime < en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _next_interval(self):\n return self.interval_generator()",
"def get_next_due_date() -> ScheduleGenerator:\n while True:\n time_since_last_schedule = (datetime.now() - start) % interval\n yield datetime.now() + (interval - time_since_last_schedule)",
"def next_interval(se... | [
"0.6949061",
"0.68775696",
"0.68406105",
"0.6799111",
"0.66572905",
"0.658244",
"0.6447201",
"0.63404876",
"0.6311907",
"0.62149584",
"0.59926677",
"0.5970144",
"0.5924112",
"0.5897577",
"0.58800316",
"0.58800316",
"0.5871106",
"0.58478767",
"0.5842628",
"0.5842628",
"0.58426... | 0.7114648 | 0 |
Return the validator to use for the service. | def _didcomm_or_service_discriminant(value, validators):
if value["type"] == "did-communication" or value["type"] == "IndyAgent":
yield validators[0]
else:
yield validators[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_validator(self):\n return self.get_validator_class()(**self.get_validator_kwargs())",
"def validator(self):\n return self._validator",
"def _get_validator(self):\n validator_class = self.validator_class or AssertionValidator\n if validator_class:\n return validato... | [
"0.83286095",
"0.8068167",
"0.7720579",
"0.7717133",
"0.76148796",
"0.7607157",
"0.734905",
"0.7277509",
"0.7127977",
"0.6878687",
"0.68391997",
"0.6793146",
"0.6780335",
"0.6724271",
"0.6078543",
"0.60016465",
"0.599462",
"0.59542185",
"0.5917628",
"0.5877514",
"0.58341134",... | 0.0 | -1 |
Return the DID representation of id. | def did(self):
return DID(self._id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_id(self):\n return unicode(self.id)",
"def get_id(self):\n return str(self._id)",
"def get_id(self):\n return str(self._id)",
"def id(self):\n return str(self.get_data(\"id\"))",
"def device_id(self) -> str:\n return self._device_info[\"ID\"]",
"def id(self) -> ... | [
"0.6278697",
"0.627063",
"0.627063",
"0.62181634",
"0.61371815",
"0.61219764",
"0.61033314",
"0.60461867",
"0.5999089",
"0.59933424",
"0.5989486",
"0.5973551",
"0.59645516",
"0.59632915",
"0.59632915",
"0.59632915",
"0.59632915",
"0.59632915",
"0.59632915",
"0.59632915",
"0.5... | 0.6383667 | 0 |
Some WSGI servers (such as Gunicorn) expect keys in the environ object to be strings OpenTelemetry should adhere to this convention. | def test_only_strings_in_environ(self):
nonstring_keys = set()
def assert_environ():
for key in request.environ:
if not isinstance(key, str):
nonstring_keys.add(key)
return "hi"
self.app.route("/assert_environ")(assert_environ)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sanitizeEnv(self, environ):\n reqUri = None\n if environ.has_key('REQUEST_URI'):\n reqUri = environ['REQUEST_URI'].split('?', 1)\n\n # Ensure QUERY_STRING exists\n if not environ.has_key('QUERY_STRING') or not environ['QUERY_STRING']:\n if reqUri is not None a... | [
"0.6688401",
"0.6273869",
"0.62618315",
"0.62259954",
"0.6158437",
"0.6025436",
"0.6011828",
"0.5992219",
"0.59692",
"0.5967772",
"0.591006",
"0.58687747",
"0.5852233",
"0.58498675",
"0.584034",
"0.5831962",
"0.5831579",
"0.5829904",
"0.5829904",
"0.5829904",
"0.5813999",
"... | 0.7008 | 0 |
Identity of who performed the action. | def actor(self):
return self.properties.get("actor", IdentitySet()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identity(self) -> str:\n return self.requester.uuid",
"def getId(self):\n return self.getUserName()",
"def getId(self):\n return self.getUserName()",
"def get_identifier(self, request):\n return request.user.username",
"def get_identifier(self, request):\r\n return re... | [
"0.7720623",
"0.71750814",
"0.71750814",
"0.71743715",
"0.71566933",
"0.70721316",
"0.70059305",
"0.6952107",
"0.68875146",
"0.685892",
"0.68200153",
"0.68200153",
"0.68200153",
"0.68031067",
"0.67985034",
"0.67954284",
"0.6751557",
"0.6750807",
"0.66944045",
"0.6672961",
"0.... | 0.6567567 | 26 |
Called if any of the forms on order page is invalid. Returns a response with an invalid form in the context | def form_invalid(self, *args, **kwargs):
context = self.get_context_data()
context.update(kwargs)
return self.render_to_response(context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_invalid(self, form, formsets):\n return self.render_to_response(\n self.get_context_data(form=form, formsets=formsets)\n )",
"def form_invalid(self, form, cruiseday_form, participant_form, document_form, equipment_form, invoice_form):\r\n\t\tprint(cruiseday_form)\r\n\t\tprint(do... | [
"0.72602737",
"0.70988643",
"0.70661545",
"0.70661545",
"0.704857",
"0.704857",
"0.7035174",
"0.7035174",
"0.6954674",
"0.6954674",
"0.69059867",
"0.69059867",
"0.68956095",
"0.6879545",
"0.6876056",
"0.6867586",
"0.6810781",
"0.6770727",
"0.67685056",
"0.67685056",
"0.675457... | 0.68518597 | 16 |
Called if any of the forms on order page is invalid. Returns a response with an invalid form in the context | def form_invalid(self, *args, **kwargs):
context = self.get_context_data()
context.update(kwargs)
return self.render_to_response(context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_invalid(self, form, formsets):\n return self.render_to_response(\n self.get_context_data(form=form, formsets=formsets)\n )",
"def form_invalid(self, form, cruiseday_form, participant_form, document_form, equipment_form, invoice_form):\r\n\t\tprint(cruiseday_form)\r\n\t\tprint(do... | [
"0.72602737",
"0.70988643",
"0.70661545",
"0.70661545",
"0.704857",
"0.704857",
"0.7035174",
"0.7035174",
"0.6954674",
"0.6954674",
"0.69059867",
"0.69059867",
"0.68956095",
"0.6879545",
"0.6876056",
"0.6867586",
"0.6810781",
"0.6770727",
"0.67685056",
"0.67685056",
"0.675457... | 0.68518597 | 17 |
Saves the current model and related training parameters into a subdirectory of the checkpoint directory. The name of the subdirectory is the current local time in Y_M_D_H_M_S format. | def save(self, experiment_dir):
date_time = time.strftime('%Y_%m_%d_%H_%M_%S', time.localtime())
if self.eval_results is not None:
# print(self.eval_results)
assert isinstance(self.eval_results, dict)
# present the dict in str form
# res_str = ''.join(''.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _save_model(self, checkpoint_dir):\n # Check whether the specified path exists or not\n isExist = os.path.exists(checkpoint_dir)\n\n if not isExist:\n # Create a new directory because it does not exist\n os.makedirs(checkpoint_dir)\n\n filename = self._get_chec... | [
"0.7772865",
"0.75772816",
"0.74129313",
"0.73504025",
"0.73283714",
"0.73215157",
"0.7287586",
"0.72064364",
"0.716338",
"0.71589",
"0.71524733",
"0.71479976",
"0.71416426",
"0.7122152",
"0.7120878",
"0.71105283",
"0.70840317",
"0.7036548",
"0.7012764",
"0.7010026",
"0.69982... | 0.69610554 | 27 |
Given the path to an experiment directory, returns the path to the last saved checkpoint's subdirectory. | def get_latest_checkpoint(cls, experiment_path):
checkpoints_path = os.path.join(experiment_path, cls.CHECKPOINT_DIR_NAME)
all_times = sorted(os.listdir(checkpoints_path), reverse=True)
return os.path.join(checkpoints_path, all_times[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def experiment_dir(experiment_name: str) -> Path: # pragma: no cover\n return EXPERIMENTS_DIR / experiment_name",
"def get_oldest_checkpoint(cls, experiment_path):\n checkpoints_path = os.path.join(experiment_path, cls.CHECKPOINT_DIR_NAME)\n all_times = sorted(os.listdir(checkpoints_path))\n ... | [
"0.6881703",
"0.66292095",
"0.64991474",
"0.64617556",
"0.63589907",
"0.6310636",
"0.6304054",
"0.62818956",
"0.6262603",
"0.6257698",
"0.6183101",
"0.6099616",
"0.6068731",
"0.6050396",
"0.60418594",
"0.6037561",
"0.60329854",
"0.6017309",
"0.6014778",
"0.5986841",
"0.596052... | 0.71267474 | 0 |
Given the path to an experiment directory, returns the path to the last saved checkpoint's subdirectory. | def get_oldest_checkpoint(cls, experiment_path):
checkpoints_path = os.path.join(experiment_path, cls.CHECKPOINT_DIR_NAME)
all_times = sorted(os.listdir(checkpoints_path))
return os.path.join(checkpoints_path, all_times[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_latest_checkpoint(cls, experiment_path):\n checkpoints_path = os.path.join(experiment_path, cls.CHECKPOINT_DIR_NAME)\n all_times = sorted(os.listdir(checkpoints_path), reverse=True)\n return os.path.join(checkpoints_path, all_times[0])",
"def experiment_dir(experiment_name: str) -> P... | [
"0.71267474",
"0.6881703",
"0.64991474",
"0.64617556",
"0.63589907",
"0.6310636",
"0.6304054",
"0.62818956",
"0.6262603",
"0.6257698",
"0.6183101",
"0.6099616",
"0.6068731",
"0.6050396",
"0.60418594",
"0.6037561",
"0.60329854",
"0.6017309",
"0.6014778",
"0.5986841",
"0.596052... | 0.66292095 | 2 |
Find string literals in string >>> find_strings('"foo" + `bar` + 123, \\\\\\'foo \\\\"b\\\\\\\\"ar\\\\\\'') [(0, 4), (8, 12), (32, 37)] >>> find_strings('boo\\\\"foo"bar') [(8, 12)] | def find_strings(input):
string_ranges = []
def count_backslashes(input, from_pos):
num_backslashes = 0
i = from_pos
while i >= 0:
if input[i] == '\\':
num_backslashes += 1
i -= 1
else:
break
return num_bac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findall(expression: Union[Compiled,str], string: str) -> List[str]:\r\n if isinstance(expression, str):\r\n expression = compile(expression)\r\n return expression.findall(string)",
"def _escaped_find(regex, s, start, in_regex):\n\n while True:\n pos = s.find('/', start)\n ... | [
"0.5484719",
"0.54587287",
"0.5373907",
"0.5346643",
"0.53095156",
"0.52646345",
"0.524318",
"0.51790506",
"0.5166563",
"0.51491684",
"0.51380724",
"0.51289153",
"0.5125964",
"0.5125101",
"0.50212926",
"0.50024825",
"0.499475",
"0.49935907",
"0.4987572",
"0.49783546",
"0.4954... | 0.7025417 | 0 |
convert an sqlite database table into a dict of namedtuples useful for tables where each row has a unique primary key. | def get_dict_from_table(sqlite_connection, table_name, key_col_name="id"):
the_list = get_list_from_table(sqlite_connection, table_name)
the_dict = {row._asdict()[key_col_name]: row for row in the_list}
assert len(the_dict) == len(the_list), (
f"In {table_name}, {key_col_name} is not unique: "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def PostgresTableToDict(sqldef, conn):\n df = pd.read_sql(sqldef, con=conn)\n return dict(zip(df.iloc[:, 0], df.iloc[:, 1]))",
"def table_to_dict(self, tab):\n dict = {}\n for colname in tab.colnames:\n dict[colname] = tab[colname].data\n return dict",
"def sqlite3_dict_fa... | [
"0.6845732",
"0.6812117",
"0.6674669",
"0.64347184",
"0.6252721",
"0.6133439",
"0.60872746",
"0.60872746",
"0.6073354",
"0.5925526",
"0.5907436",
"0.5906844",
"0.5902475",
"0.5901657",
"0.5901657",
"0.5901657",
"0.5901657",
"0.5882997",
"0.58407205",
"0.5839645",
"0.5834679",... | 0.76837677 | 0 |
Return a shorter list of strings containing only the strings with more than four characters. Use manual accumulation. | def longwords(strings):
# write your code here
shorter_lst=[]
for i in strings:
if len(i)>4:
shorter_lst.append(i)
return shorter_lst | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def long_words(words):\n words_longer_than_four = []\n for word in words:\n if len(word) > 4:\n words_longer_than_four.append(word)\n return words_longer_than_four",
"def longwords_Fil(strings):\n # write your code here\n return list(filter(lambda x:len(x)>4,strings))",
"def ha... | [
"0.7475672",
"0.71557635",
"0.6872116",
"0.67482513",
"0.6724769",
"0.6197392",
"0.619354",
"0.6074557",
"0.6049995",
"0.60496676",
"0.6044455",
"0.6024239",
"0.5944487",
"0.5891092",
"0.58185077",
"0.5773572",
"0.57616436",
"0.5707529",
"0.55948776",
"0.551067",
"0.5509694",... | 0.6733188 | 4 |
Add a rectangular plane specified by its center location, dimensions, and where its +z points to | def add_rectangular_plane(center_loc=(0, 0, 0), point_to=(0, 0, 1), size=(2, 2), name=None):
center_loc = np.array(center_loc)
point_to = np.array(point_to)
size = np.append(np.array(size), 0)
bpy.ops.mesh.primitive_plane_add(location=center_loc)
plane_obj = bpy.context.object
if name is not ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xzplane(draw, r, y, shift = np.array([1000, 1000, 0, 0]), scale = 300):\n extent = 2.8\n pln = np.array(\n [\n [-extent,y,0],\n [extent,y,0],\n [extent,y,extent*2],\n [-extent,y,extent*2]\n ]\n )\n pln = np.dot(pl... | [
"0.6824476",
"0.64902735",
"0.6440693",
"0.6408356",
"0.6295862",
"0.6286816",
"0.6252741",
"0.6226775",
"0.6180176",
"0.60652083",
"0.5995266",
"0.5964892",
"0.59334034",
"0.5874825",
"0.5867324",
"0.5833849",
"0.5782385",
"0.5781417",
"0.5748697",
"0.5744772",
"0.5717561",
... | 0.7188262 | 0 |
Initialize the bearing vectors (since constant) to avoid redundant computations. | def _init_bearings(self):
# Calculate for low frequency
iterable = (-65+x*0.5078125 for x in range(256))
bearings = np.fromiter(iterable, float)
self.low_freq_brgs = np.expand_dims(bearings, 0)
# Calculate for high frequency
iterable = (-35+x*0.2734375 for x in range(256... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_bearing(self, bearing):\n q0, q1, q2, q3 = self.q\n v_head = np.array([-2*q2**2 - 2*q3**2 + 1, 2*q0*q3 + 2*q1*q2])\n v_bearing = np.array([np.cos(bearing), np.sin(bearing)])\n y = np.vstack(v_bearing) - np.vstack(v_head)\n\n H = np.zeros((2, 11), dtype=float)\n ... | [
"0.6250811",
"0.6070412",
"0.5965874",
"0.5881705",
"0.5868202",
"0.58242244",
"0.565673",
"0.5636962",
"0.56158495",
"0.56111014",
"0.56101334",
"0.5609809",
"0.55726767",
"0.555374",
"0.5529649",
"0.5513659",
"0.5499461",
"0.54960275",
"0.5495799",
"0.5495221",
"0.54906803"... | 0.6214733 | 1 |
Writes the world to a JSON file | def writef(self, fileName):
f = open(fileName, "w")
json.dump(self.writed(self.__world), f)
f.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self):\n self.json_o.write()",
"def write_json(toWrite):\n with open('clubs.json', 'w+') as outfile:\n json.dump(toWrite, outfile)",
"def _write_json(self):\n with open(self._file_path, 'w') as f:\n json.dump(self._content, f, indent=4, separators=None,\n ... | [
"0.7511854",
"0.747414",
"0.73970777",
"0.73342586",
"0.7298056",
"0.72890896",
"0.72564584",
"0.72564584",
"0.7062422",
"0.6953053",
"0.69267815",
"0.69182485",
"0.68651974",
"0.6852846",
"0.684462",
"0.68246865",
"0.6806423",
"0.6775899",
"0.67359936",
"0.67151654",
"0.6713... | 0.79763687 | 0 |
Unimodal Normal Distribution Xover | def _undx(self, parents):
child = np.empty(self.n_gene+1)
ALPHA = 0.5
BETA = 0.35 / (self.n_gene**0.5)
d1 = np.linalg.norm(
parents[1, :self.n_gene] - parents[0, :self.n_gene]
)
d2 = np.linalg.norm(
(
parents[2, :self.n_gene] - par... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal_distr(x, mu, sigma, s=1):\n \n return s * 1/(sigma * torch.sqrt(torch.tensor(2 * np.pi))) * torch.exp((-1/2) * ((x - mu) / sigma) ** 2)",
"def forward(self, x):\n mean_x = self.mean_module(x)\n covar_x = self.covar_module(x)\n return gpytorch.distributions.MultivariateNormal... | [
"0.67460644",
"0.64881796",
"0.6450783",
"0.6395072",
"0.63283765",
"0.63119096",
"0.6280778",
"0.6278982",
"0.6273944",
"0.6259504",
"0.6253413",
"0.62286955",
"0.621928",
"0.6212633",
"0.6192057",
"0.6170947",
"0.61674905",
"0.6163825",
"0.61584765",
"0.61584735",
"0.615746... | 0.0 | -1 |
Extended Normal Distribution Xover | def _endx(self, parents):
ALPHA = (1.-2*0.35**2)**0.5/2.
BETA = 0.35/(self.n_gene-1)**0.5
child = np.empty(self.n_gene+1)
t1 = (parents[1, :self.n_gene]-parents[0, :self.n_gene]) / 2.
t2 = np.random.normal(scale=ALPHA) * (
parents[1, :self.n_gene] - parents[0, :self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal(x, mean, dispersion):\n return np.exp(\n -1 * squared_norm(x - mean) / (2 * dispersion)\n ) / (\n np.sqrt(2 * np.pi * dispersion)\n )",
"def normal_distr(x, mu, sigma, s=1):\n \n return s * 1/(sigma * torch.sqrt(torch.tensor(2 * np.pi))) * torch.exp((-1/2) * ((x - mu) / si... | [
"0.6543876",
"0.6405083",
"0.6281506",
"0.62714857",
"0.6196955",
"0.61467355",
"0.61448807",
"0.61420953",
"0.6125064",
"0.61160773",
"0.60905457",
"0.60653836",
"0.60330653",
"0.6031834",
"0.6025222",
"0.6019222",
"0.59990495",
"0.5983751",
"0.5978937",
"0.59766275",
"0.596... | 0.0 | -1 |
Make sure that the given daemon version is supported by this client version. Raises ~ipfshttpclient.exceptions.VersionMismatch | def assert_version(version, minimum=VERSION_MINIMUM, maximum=VERSION_MAXIMUM, blacklist=VERSION_BLACKLIST):
# Convert version strings to integer tuples
version = list(map(int, version.split('-', 1)[0].split('.')))
minimum = list(map(int, minimum.split('-', 1)[0].split('.')))
maximum = list(map(int, maximum.split('-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkVersion(self, clientName, edamVersionMajor, edamVersionMinor):\r\n pass",
"def check_version(client):\n version_number = get_version(client)\n logger.debug('Detected Elasticsearch version %s', \".\".join(map(str, version_number)))\n if version_number >= version_max or version_number < versio... | [
"0.67901623",
"0.66498035",
"0.65723395",
"0.63598377",
"0.6297187",
"0.62750983",
"0.6081847",
"0.6074037",
"0.60369295",
"0.6035478",
"0.6022502",
"0.59998983",
"0.59788525",
"0.5960451",
"0.59274733",
"0.591768",
"0.5895658",
"0.5853749",
"0.5823079",
"0.5760084",
"0.57425... | 0.5326224 | 97 |
Serialize Python dict to JSONformatted, UTF8 encoded string | def serialize_json(json_data):
return json.dumps(json_data).encode("utf-8") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_json_encoding_utf_8(json_dict=dict):\n # type: (dict)->str\n return json.dumps(json_dict, encoding='utf-8', ensure_ascii=False)",
"def dict_json_beauty(json_dict=dict, encode='utf-8'):\n # type: (dict, str)->str\n return json.dumps(json_dict, encoding=encode, ensure_ascii=Fal... | [
"0.8253838",
"0.7425534",
"0.732482",
"0.73152417",
"0.72705114",
"0.7255237",
"0.7230397",
"0.7221871",
"0.7065979",
"0.70288384",
"0.70216715",
"0.7021396",
"0.7010264",
"0.69948506",
"0.6928967",
"0.6897936",
"0.6871163",
"0.6855899",
"0.6822239",
"0.6821984",
"0.67897165"... | 0.72256917 | 7 |
Get the reference direction used by the station beamformer. Returns an ITRF vector in meters (numpy array of 3 floats). `time` Time at which to evaluate the direction | def getRefDelay (self, time):
return self._response.getRefDelay(time) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_thrust_direction(self,\n time: float) -> np.array:\n # Interpolate with time\n angle = self.thrust_angle_interpolator.interpolate(time)\n # Set thrust in vertical frame and transpose it\n thrust_direction_vertical_frame = np.array([[0,... | [
"0.71722996",
"0.64853907",
"0.6369485",
"0.5953635",
"0.56715614",
"0.56229794",
"0.56226885",
"0.56027997",
"0.555818",
"0.5547291",
"0.55158806",
"0.5499014",
"0.5464293",
"0.54409623",
"0.543087",
"0.5396751",
"0.53784037",
"0.5376448",
"0.5376448",
"0.5346049",
"0.533588... | 0.0 | -1 |
Get the reference direction used by the analog tile beamformer (relevant for HBA observations only). Returns an ITRF vector in meters (numpy array of 3 floats). `time` Time at which to evaluate the direction | def getRefTile (self, time):
return self._response.getRefTile(time) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_thrust_direction(self,\n time: float) -> np.array:\n # Interpolate with time\n angle = self.thrust_angle_interpolator.interpolate(time)\n # Set thrust in vertical frame and transpose it\n thrust_direction_vertical_frame = np.array([[0,... | [
"0.7199168",
"0.63275665",
"0.5952491",
"0.58113533",
"0.57395005",
"0.56504023",
"0.5535569",
"0.5495872",
"0.54790986",
"0.54790986",
"0.53758746",
"0.53674",
"0.5367112",
"0.53602695",
"0.5313361",
"0.53046227",
"0.52930903",
"0.5292836",
"0.52850133",
"0.5271077",
"0.5260... | 0.48176783 | 51 |
Get the direction of interest. Returns an ITRF vector in meters (numpy array of 3 floats). `time` Time at which to evaluate the direction | def getDirection (self, time):
return self._response.getDirection(time) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_thrust_direction(self,\n time: float) -> np.array:\n # Interpolate with time\n angle = self.thrust_angle_interpolator.interpolate(time)\n # Set thrust in vertical frame and transpose it\n thrust_direction_vertical_frame = np.array([[0,... | [
"0.6915754",
"0.6342904",
"0.5855677",
"0.5660039",
"0.5655967",
"0.56508183",
"0.5629019",
"0.5599158",
"0.5576857",
"0.5567662",
"0.55007684",
"0.5442576",
"0.5392102",
"0.53449655",
"0.53391",
"0.5335497",
"0.5335497",
"0.5318738",
"0.5289481",
"0.5235796",
"0.5232867",
... | 0.6409939 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.