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 |
|---|---|---|---|---|---|---|
Save a figure to disk and show it, as specified. | def _save_and_show(fig, ax, save, show, close, filename, file_format, dpi, axis_off):
# save the figure if specified
if save:
# create the save folder if it doesn't already exist
if not os.path.exists(settings.imgs_folder):
os.makedirs(settings.imgs_folder)
path_filename = os... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_figure(self, data):\n\n\t\tsizes = np.shape(data)\n\t\tfig = plt.figure()\n\t\tfig.set_size_inches(1, 1. * sizes[0]/sizes[1], forward = False)\n\t\tax = plt.Axes(fig, [0., 0., 1., 1.])\n\t\tax.set_axis_off()\n\t\tfig.add_axes(ax)\n\t\tax.imshow(data, \"gray\")\n\n\t\t#plt.show()\n\t\tself.plotfile = os.pa... | [
"0.7545989",
"0.7404616",
"0.7276903",
"0.7264389",
"0.7253806",
"0.7204502",
"0.7117697",
"0.7089065",
"0.70879453",
"0.6997609",
"0.69750476",
"0.69484115",
"0.6928568",
"0.69277704",
"0.69088435",
"0.6907034",
"0.6889658",
"0.687075",
"0.68699616",
"0.68635744",
"0.6845537... | 0.79608107 | 0 |
Remove all html tags except VALID_TAGS | def sanitize_html(value, valid_tags=VALID_TAGS, base_url=None):
rjs = r'[\s]*(&#x.{1,7})?'.join(list('javascript:'))
rvb = r'[\s]*(&#x.{1,7})?'.join(list('vbscript:'))
re_scripts = re.compile('(%s)|(%s)' % (rjs, rvb), re.IGNORECASE)
validTags = valid_tags.split()
validAttrs = 'href src width height'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_html_tags_fun(self):\n cleaner = re.compile('<.*?>')\n cleaned_text = re.sub(cleaner, '', self.doc)\n cleaned_text = re.sub('[\\n\\t]', '', cleaned_text)\n self.doc = cleaned_text",
"def remove_html_tags(self,text):\n #https://medium.com/@jorlugaqui/how-to-strip-html... | [
"0.80991",
"0.7934685",
"0.788275",
"0.7880725",
"0.7735695",
"0.7696251",
"0.7674675",
"0.76295716",
"0.7626717",
"0.7626717",
"0.76037115",
"0.75711447",
"0.75340337",
"0.750945",
"0.74977124",
"0.7478196",
"0.7470483",
"0.74700135",
"0.74632484",
"0.74576306",
"0.74258095"... | 0.678778 | 55 |
Gets datetime object for the last ISO Weekday (1=Monday, 7=Sunday). If in_future is True, the Weekday is not the last, but the next. If today is Weekday, return today. If in_future, return the next Weekday. from_date should be date | def get_last_weekday(weekday_iso_number, in_future=False, from_date=None):
if from_date:
if isinstance(from_date, datetime):
from_date = from_date.date()
if not isinstance(from_date, date):
raise ValueError("from_date should be date or at least datetime")
date = from... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_week_end(x: Optional[Date] = None) -> Date:\n asof = x or get_today()\n return asof + TimeDelta(days=6 - (asof.isoweekday() - 1) % 7)",
"def get_next_weekend():\n d = datetime.date.today()\n # day 5 for saturday\n t = datetime.timedelta((7 + 5 - d.weekday()) % 7)\n return (d + t).strfti... | [
"0.6838765",
"0.6674522",
"0.6436715",
"0.6337307",
"0.6235023",
"0.61124575",
"0.6085213",
"0.60333157",
"0.602676",
"0.5980866",
"0.5947579",
"0.58969814",
"0.5860065",
"0.5855712",
"0.5847769",
"0.57928956",
"0.5788888",
"0.57433766",
"0.57213783",
"0.5711183",
"0.56476843... | 0.7408591 | 0 |
reset the ghost's position | def reset(self):
if self.num == 1:
self.rect.centerx = 320
elif self.num == 2:
self.rect.centerx = 341
elif self.num == 3:
self.rect.centerx = 362
elif self.num == 4:
self.rect.centerx = 383
self.rect.centery = 371
self.cent... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_position(self):\n self.set_position(copy.deepcopy(self.ab_pos))",
"def reset_position(self):\n self.rect.left, self.rect.top = self.start_pos",
"def reset(self):\n self._x = 0\n self._y = 0",
"def reset_position(self, x, y):\n\t\tself.grid[x][y] = self.terminal",
"def ... | [
"0.772894",
"0.7670996",
"0.7556254",
"0.74782014",
"0.74073654",
"0.73297566",
"0.72479105",
"0.7186992",
"0.708037",
"0.70788723",
"0.7049241",
"0.7049241",
"0.7049241",
"0.70469874",
"0.70327777",
"0.695923",
"0.6922835",
"0.69180924",
"0.6862595",
"0.68297565",
"0.6817692... | 0.694173 | 16 |
List all the word tokens (consecutive letters) in a text. Normalize to lowercase. | def tokens(text) -> Tuple[Word]:
return tuple(re.findall('[a-z]+', text.lower())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenized_text(text: Text):\n words = nltk.word_tokenize(text)\n return (w.lower().strip() for w in words if ONLY_LETTER_WORDS.match(w))",
"def tokenize(text):\n regex = re.compile(r'\\W+')\n tokens = regex.split(text.lower())\n tokens = [token for token in tokens if token]\n return tokens",
"def tok... | [
"0.7776427",
"0.7751869",
"0.77143323",
"0.76600504",
"0.7569799",
"0.75222003",
"0.7504484",
"0.7455228",
"0.7378311",
"0.735748",
"0.7333103",
"0.7323229",
"0.7296924",
"0.72923833",
"0.728016",
"0.7278022",
"0.72666997",
"0.7256132",
"0.72432864",
"0.72373444",
"0.7208869"... | 0.7657296 | 4 |
Returns whether the stack is empty. | def empty(self) -> bool:
return len(self._deque) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return len(self.the_stack) == 0",
"def is_empty(self):\n return len(self.stack) == 0",
"def empty(self) -> bool:\n return len(self.stack) == 0",
"def isEmpty(self):\n return len(self.stack) == 0",
"def empty(self):\n return len(self.stack) == 0",
"... | [
"0.9207349",
"0.9127756",
"0.90184367",
"0.8999902",
"0.8948574",
"0.8948574",
"0.89155793",
"0.8903433",
"0.888211",
"0.88793427",
"0.88675356",
"0.8796078",
"0.8768976",
"0.8748719",
"0.87394613",
"0.8728192",
"0.87192214",
"0.87091523",
"0.87091523",
"0.8544101",
"0.850963... | 0.0 | -1 |
Compute softmax values for each sets of scores in x. | def softmax(x):
e_x = np.exp(x - np.max(x))
return e_x / e_x.sum(axis=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.77967143",
"0.7760368",
"0.77593094",
"0.77576",
"0.7658573",
"0.7658573",
"0.7658573",
"0.7658573",
"0.75868976",
"0.74326617",
"0.7409158",
"0.7394746",
"0.73594135",
"0.7318695",
"0.72697663",
"0.7263475",
"0.7262598",
"0.72583216",
"0.72309154",
"0.7216199",
"0.7202549... | 0.70625734 | 64 |
The camera model that is being estimated. | def model(self) -> CameraModel:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model(self) -> Optional[CameraModel]:\n return self._model",
"def camera(self):\n return self.__camera",
"def camera(self):\n return self._camera",
"def camera(self):\n return self._camera",
"def model(self):\n return self._fit_model()",
"def model(self) -> str:\n ... | [
"0.79260623",
"0.74764115",
"0.73364526",
"0.73364526",
"0.6952383",
"0.6867031",
"0.68443316",
"0.67584926",
"0.6721372",
"0.64187163",
"0.62378514",
"0.62213457",
"0.6214705",
"0.61895865",
"0.61835915",
"0.6157273",
"0.6138539",
"0.6099903",
"0.60937935",
"0.60879797",
"0.... | 0.77257127 | 1 |
This method resets all of the data attributes to their default values to prepare for another estimation. This should reset | def reset(self) -> None:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_variables(self) -> None:\n self.attributs = {}\n self.data = []",
"def reset(self):\n self.data = self._defaults",
"def reset_attributes(self):\n\n self.ell = None\n self.ell_jacobian = None\n self.ell_hessian = None\n\n self.ell_hyperparam = None\n ... | [
"0.80588657",
"0.7970079",
"0.7903631",
"0.7783163",
"0.7770899",
"0.753923",
"0.753923",
"0.7520766",
"0.74688065",
"0.7423499",
"0.7332162",
"0.7235851",
"0.7212679",
"0.7204364",
"0.72017276",
"0.7132342",
"0.7127791",
"0.7122191",
"0.7107686",
"0.70992786",
"0.7086643",
... | 0.0 | -1 |
The camera model that is being estimated. | def model(self) -> Optional[CameraModel]:
return self._model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model(self) -> CameraModel:\n pass",
"def camera(self):\n return self.__camera",
"def camera(self):\n return self._camera",
"def camera(self):\n return self._camera",
"def model(self):\n return self._fit_model()",
"def model(self) -> str:\n return self.camera... | [
"0.77257127",
"0.74764115",
"0.73364526",
"0.73364526",
"0.6952383",
"0.6867031",
"0.68443316",
"0.67584926",
"0.6721372",
"0.64187163",
"0.62378514",
"0.62213457",
"0.6214705",
"0.61895865",
"0.61835915",
"0.6157273",
"0.6138539",
"0.6099903",
"0.60937935",
"0.60879797",
"0.... | 0.79260623 | 0 |
This method resets all of the data attributes to their default values to prepare for another estimation. Specifically | def reset(self) -> None:
self._successful = False
self._measurement_covariance = None
self._measurements = None
self._base_frame_directions = None
self._temperatures = None
self._postfit_covariance = None
self._postfit_residuals = None
self._jacobian = Non... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_variables(self) -> None:\n self.attributs = {}\n self.data = []",
"def reset(self):\n self.data = self._defaults",
"def reset_attributes(self):\n\n self.ell = None\n self.ell_jacobian = None\n self.ell_hessian = None\n\n self.ell_hyperparam = None\n ... | [
"0.79754144",
"0.79214996",
"0.78313404",
"0.7725813",
"0.7719314",
"0.75083137",
"0.75083137",
"0.74383634",
"0.73930585",
"0.7305101",
"0.72537726",
"0.72296035",
"0.72004664",
"0.70817393",
"0.70606184",
"0.705712",
"0.70289713",
"0.70230514",
"0.6998695",
"0.69968593",
"0... | 0.6946719 | 21 |
This initializes the square | def __init__(self, size=0, position=(0, 0)):
if type(size) is not int:
raise TypeError("size must be an integer")
elif size < 0:
raise ValueError("size must be >= 0")
self.__size = size
self.position = position | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_init(self):\n s1 = Square(4)\n self.assertEqual(s1.width, 4)\n self.assertEqual(s1.height, 4)\n self.assertEqual(s1.id, 1)\n self.assertEqual(s1.x, 0)\n self.assertEqual(s1.y, 0)\n\n s2 = Square(5, 2, 3, 47)\n self.assertEqual(s2.width, 5)\n s... | [
"0.74535334",
"0.745232",
"0.7342518",
"0.6968469",
"0.6937706",
"0.684544",
"0.68079424",
"0.6802398",
"0.6774159",
"0.6708567",
"0.66987455",
"0.66955936",
"0.6673333",
"0.6673333",
"0.66683125",
"0.66683125",
"0.66683125",
"0.66565704",
"0.6650032",
"0.6644192",
"0.661985"... | 0.0 | -1 |
Return the area(size size) of a square | def area(self):
return self.__size ** 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(width, height):\n return width * height",
"def square_area(side):\n return side**2",
"def calculatearea(self):\r\n return self.width * self.height",
"def area(self):\n return(self.__width * self.__height)",
"def area_rect(w, h):\n return w * h",
"def rectangle_area(width :... | [
"0.8182927",
"0.81252414",
"0.7913619",
"0.7866532",
"0.7862297",
"0.7848814",
"0.7831296",
"0.7811189",
"0.7795346",
"0.7786807",
"0.7786807",
"0.7786807",
"0.7785627",
"0.77822345",
"0.7774954",
"0.7758684",
"0.7758684",
"0.7758684",
"0.7758684",
"0.7757035",
"0.7757035",
... | 0.77657896 | 15 |
Getter for the Job Id | def id(self):
return self.job_proto.id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def job_id(self) -> JobId:\r\n return self._job_id",
"def job_id(self):\n return self._job_id",
"def job_id(self):\n return self._properties.get(\"jobReference\", {}).get(\"jobId\")",
"def job_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"job_id\")",
"def get_job_i... | [
"0.8894397",
"0.8798448",
"0.87849766",
"0.8665213",
"0.8453696",
"0.8350305",
"0.8346305",
"0.8166768",
"0.80654514",
"0.8012826",
"0.7759749",
"0.76312304",
"0.7569441",
"0.74377596",
"0.72411567",
"0.7205265",
"0.7156337",
"0.7149942",
"0.71012866",
"0.7089596",
"0.7080340... | 0.826953 | 7 |
Getter for the Job status from Feast Core | def status(self):
return self.job_proto.status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_status(self):\n url = \"data_request?id=jobstatus&job=%d&plugin=zwave\" % self.id\n return self.vera.get(url)",
"def get_status(self):\n\t\treturn call_sdk_function('PrlJob_GetStatus', self.handle)",
"def get_job_status(self):\n if self.worker_thread is None:\n return No... | [
"0.7979315",
"0.7937717",
"0.76614046",
"0.75040907",
"0.74977624",
"0.7473792",
"0.740396",
"0.7395935",
"0.73944193",
"0.7391302",
"0.7374433",
"0.73627555",
"0.72702134",
"0.7256556",
"0.716484",
"0.7150821",
"0.7150821",
"0.7150821",
"0.7147055",
"0.7138457",
"0.7137159",... | 0.7978775 | 1 |
Recursively removes word from trie if in trie; returns None | def remove_word(self, word, root, depth = 0):
found = False
if depth == len(word):
if root.get_end():
root.set_end(False)
self.size -= 1
return True # Returns true if word is found
return False ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_remove_word_that_branches_from_root_by_itself(empty_trie):\n empty_trie.insert(\"tool\")\n empty_trie.remove(\"tool\")\n assert empty_trie.contains(\"tool\") is False",
"def remove(self, word: str) -> None:\n if not isinstance(word, str):\n raise TypeError('Parameter must be o... | [
"0.78564495",
"0.72305524",
"0.7164224",
"0.70014435",
"0.69322914",
"0.68611884",
"0.6847436",
"0.6746477",
"0.66457784",
"0.6353039",
"0.6186139",
"0.61622524",
"0.61253744",
"0.60941166",
"0.60920715",
"0.60832626",
"0.6035036",
"0.60286176",
"0.5999774",
"0.5988026",
"0.5... | 0.7412209 | 1 |
Return a base91encoded 64bit random number. | def generate_anki_guid() -> str:
def base62(num: int, extra: str = "") -> str:
s = string
table = s.ascii_letters + s.digits + extra
buf = ""
while num:
num, i = divmod(num, len(table))
buf = table[i] + buf
return buf
_base91_extra_chars = "!#$%&... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _guid64():\n return _base91(random.randint(0, 2**64 - 1))",
"def _get_encode_random(self):\n return os.urandom(16).encode('hex')",
"def generate_random_num():\n return (long(hexlify(urandom(7)), 16) >> 3) * 2**(-53)",
"def _get_random_number_code(self):\r\n return \"str(random.randint... | [
"0.77352643",
"0.7316971",
"0.71774006",
"0.7129758",
"0.6993098",
"0.6973568",
"0.69401836",
"0.68998146",
"0.6864818",
"0.6826883",
"0.67604953",
"0.67201126",
"0.67196727",
"0.6715996",
"0.6657979",
"0.66409975",
"0.6575479",
"0.6558472",
"0.6552138",
"0.6543859",
"0.65230... | 0.6959499 | 6 |
Return the path to the template as a relative (dir, file_name) pair. The directory returned is relative to the directory containing the class definition of the given object. The method returns None for this directory if the directory is unknown without first searching the search directories. | def _find_relative(self, spec):
if spec.template_rel_path is not None:
return os.path.split(spec.template_rel_path)
# Otherwise, determine the file name separately.
locator = self.loader._make_locator()
# We do not use the ternary operator for Python 2.4 support.
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find(self, spec):\n if spec.template_path is not None:\n return spec.template_path\n\n dir_path, file_name = self._find_relative(spec)\n\n locator = self.loader._make_locator()\n\n if dir_path is None:\n # Then we need to search for the path.\n path... | [
"0.7180067",
"0.6704596",
"0.66606236",
"0.66447985",
"0.65688497",
"0.6493499",
"0.6178345",
"0.6173296",
"0.60943234",
"0.6075135",
"0.602551",
"0.6019594",
"0.59989077",
"0.5996445",
"0.5996016",
"0.5984834",
"0.59594285",
"0.59428775",
"0.59135187",
"0.59083396",
"0.59032... | 0.70226675 | 1 |
Find and return the path to the template associated to the instance. | def _find(self, spec):
if spec.template_path is not None:
return spec.template_path
dir_path, file_name = self._find_relative(spec)
locator = self.loader._make_locator()
if dir_path is None:
# Then we need to search for the path.
path = locator.find... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_template_path(self):\n raise NotImplementedError()",
"def template_path(self) -> str:\n return self._values.get(\"template_path\")",
"def template_path(self):\n return self.get_config(\"templates\")",
"def get_template(self):\n return self.template",
"def template(self):... | [
"0.74730694",
"0.74193347",
"0.70183444",
"0.69326943",
"0.6718481",
"0.6592982",
"0.6592982",
"0.6592982",
"0.6519515",
"0.6473962",
"0.6464478",
"0.6439285",
"0.64231586",
"0.6410536",
"0.64015484",
"0.6385929",
"0.6358505",
"0.6356889",
"0.633227",
"0.6314111",
"0.6309127"... | 0.71018195 | 2 |
Test error when attempting to create API factory for an invalid client type. | def test_invalid_factory_type():
os.environ[config.FLOWSERV_CLIENT] = 'UNKNOWN'
with pytest.raises(ValueError):
ClientAPI()
del os.environ[config.FLOWSERV_CLIENT] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_init_wrong_ap_type(self):\n ap_wrong = object()\n with self.assertRaises(ValueError):\n client = ClientInfo(\"cc:cc:cc:cc:cc:cc\",\n ip=\"3.3.3.3\", ap_info=ap_wrong)",
"def test_new_invalid(self) -> None:\n with pytest.raises(TypeError) as ... | [
"0.69391495",
"0.68601847",
"0.6746282",
"0.67272127",
"0.67176956",
"0.67175037",
"0.66710645",
"0.6638155",
"0.6628238",
"0.6617953",
"0.661221",
"0.65804964",
"0.6516946",
"0.64984167",
"0.64822453",
"0.6452124",
"0.6437996",
"0.6436262",
"0.6429203",
"0.6413452",
"0.63929... | 0.8007469 | 0 |
provides the camera matrix M (i.e. x^c = M X^c), the transformation from point in P^3 referred to camera frame to point in P^2 in camera projection | def m_c(self) -> np.ndarray:
assert self._k is not None, "camera must be calibrated"
return forge_projective_matrix(self._k) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def camera_matrix(e, p, t):\n # Translates all points such that the camera is centered at the origin.\n T = np.array([[1, 0, 0, -e[0]],\n [0, 1, 0, -e[1]],\n [0, 0, 1, -e[2]],\n [0, 0, 0, 1]])\n\n # Set up orthonormal basis.\n w = e - p\n w = w ... | [
"0.7256274",
"0.70871395",
"0.6994927",
"0.69835013",
"0.69117266",
"0.6773532",
"0.674597",
"0.6648728",
"0.6632696",
"0.65054613",
"0.64635754",
"0.6440868",
"0.63798",
"0.6355571",
"0.634022",
"0.6330482",
"0.6316968",
"0.62489635",
"0.62460315",
"0.6226705",
"0.6222615",
... | 0.6122984 | 28 |
provides the camera matrix M_b^c (i.e. x^c = M_b^c X^b), the transformation from point in P^3 referred to base frame to point in P^2 in camera projection | def m(self) -> np.ndarray:
assert self._k is not None and self._r is not None and self._t is not None, "camera must be calibrated"
return forge_projective_matrix(self._k, r=self._r, t=self._t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def camera_matrix(e, p, t):\n # Translates all points such that the camera is centered at the origin.\n T = np.array([[1, 0, 0, -e[0]],\n [0, 1, 0, -e[1]],\n [0, 0, 1, -e[2]],\n [0, 0, 0, 1]])\n\n # Set up orthonormal basis.\n w = e - p\n w = w ... | [
"0.68832904",
"0.6750133",
"0.6474367",
"0.64701056",
"0.6435402",
"0.63885725",
"0.63062394",
"0.62824",
"0.6246142",
"0.62410533",
"0.6234209",
"0.6226183",
"0.60885346",
"0.6057115",
"0.6051529",
"0.6043527",
"0.60265434",
"0.59762734",
"0.5975145",
"0.5964083",
"0.5936472... | 0.6169244 | 12 |
Get the default consumer config | def _get_consumer_config(address, conf_settings): # pragma: no cover
conf = {
"bootstrap.servers": address,
"api.version.request": False,
"broker.version.fallback": "0.10.2",
}
conf = _get_managed_kafka_config(conf)
conf.update(conf_settings)
return conf | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_config(self):\n return config.read(pathlib.Path(__file__).parent / \"ext.conf\")",
"def get_default_config():\n # pylint: disable=cyclic-import\n from raylab.agents.sac import DEFAULT_CONFIG\n\n return DEFAULT_CONFIG",
"def get_default_config():\n return _config_s... | [
"0.7078121",
"0.6796178",
"0.6772411",
"0.67210525",
"0.6652234",
"0.65617293",
"0.65590113",
"0.65111214",
"0.65024203",
"0.6457461",
"0.6444173",
"0.63891965",
"0.6359412",
"0.6356911",
"0.63504785",
"0.63404644",
"0.63314986",
"0.63127875",
"0.6306833",
"0.62854",
"0.62744... | 0.7130338 | 0 |
Show an index page. | def index_page():
return redirect("/application-form")
# Alternately, we could make this a Jinja template in `templates/`
# and return that result of rendering this, like:
#
# return render_template("index.html") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_index_page():\n\n return render_template('index.html')",
"def index():\n return render_template(\"index.html\",\n title='Index')",
"def index():\n return render_template('pages/index.html', isNav=True)",
"def index():\n return render_template('index.html')",... | [
"0.8531908",
"0.80338854",
"0.7943412",
"0.77842605",
"0.77842605",
"0.7766452",
"0.7744886",
"0.76850814",
"0.76816297",
"0.7678797",
"0.7672546",
"0.7672546",
"0.7667954",
"0.7667954",
"0.7667954",
"0.7657335",
"0.76573086",
"0.7628134",
"0.76141024",
"0.76105523",
"0.75957... | 0.0 | -1 |
Convert time in a string to seconds. | def time2secs( s ):
t = s.split( ':' )
nf = len( t )
if nf == 1:
# Seconds only!
secs = int( t[0] )
elif nf == 2:
# Minutes & seconds!
secs = int( t[1] ) + int( t[0] ) * 60
elif nf == 3:
# Hours, minutes & seconds!
secs = int( t[2] ) + int( t[1] ) * 60 + int( t[0] ) * ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_time_to_second(time):\n time_split = time.split(':')\n hour = int(time_split[0])\n minute = int(time_split[1])\n second = int(time_split[2])\n return 3600*hour + 60*minute + second",
"def str2seconds(strtime):\n\n result = 0\n\n for i in re.... | [
"0.797319",
"0.78274924",
"0.77157664",
"0.76667124",
"0.76639163",
"0.76205784",
"0.755717",
"0.755717",
"0.75558764",
"0.7422413",
"0.73433584",
"0.73073024",
"0.7292301",
"0.72452503",
"0.721432",
"0.7090023",
"0.70739645",
"0.7045374",
"0.7011424",
"0.6995678",
"0.699072"... | 0.79416764 | 1 |
Returns the density value of a Multinoulli distribution | def calculateMultinoulli(x, *series):
series= series[0]
return series.ix[x]/float(series.sum()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density(self, arg):\n return self.gb2_density(np.exp(arg)) * np.exp(arg)",
"def log_density_gaussian(x: torch.Tensor, mu: torch.Tensor, logvar: torch.Tensor):\n norm = -0.5 * (math.log(2 * math.pi) + logvar)\n log_density = norm - 0.5 * ((x - mu) ** 2 * torch.exp(-logvar))\n return log_densit... | [
"0.6501384",
"0.633093",
"0.62715757",
"0.62302136",
"0.61322474",
"0.6119733",
"0.6118581",
"0.6113948",
"0.61121255",
"0.60883564",
"0.6077783",
"0.6074413",
"0.6025707",
"0.6023237",
"0.5998085",
"0.59950674",
"0.59786624",
"0.59681886",
"0.59656066",
"0.59400666",
"0.5936... | 0.67914516 | 0 |
Plots a confusion matrix. | def plot_confusion_matrix(cm, class_names, sentiment):
##plotting unnormalized confusion matrix
plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues)
plt.title('confusion matrix of ' + sentiment + ' classification')
#uncomment for actual labels
# tick_marks = np.arange(len(class_names))
# plt.xticks(tick_m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(self):\r\n interp = ClassificationInterpretation.from_learner(self.learn)\r\n interp.plot_confusion_matrix()",
"def plot_confusion_matrix(cm, classes=None, title='Confusion matrix'):\n if classes is not None:\n sns.heatmap(cm, xticklabels=classes, yticklabels=cla... | [
"0.82883036",
"0.8057375",
"0.8022995",
"0.7959058",
"0.7953848",
"0.7933933",
"0.79080147",
"0.7894345",
"0.7859723",
"0.7843164",
"0.7830489",
"0.78277344",
"0.78086394",
"0.7807704",
"0.7802325",
"0.7792034",
"0.7786378",
"0.77674615",
"0.7762487",
"0.77535874",
"0.7750218... | 0.79712653 | 3 |
Provide helpful representation when printed. | def __repr__(self):
return "<User name=%s email=%s>" % (self.name, self.email) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def nice_output(self):\n return self.des",
"def nice_output(self):\n return self.des",
"def __str__(self):\n return self.printable()",
"def _printable(self):\n toPrint = \"Qubit ID: \" + str(self.qubit_id) +... | [
"0.7529561",
"0.7511525",
"0.7511525",
"0.74975544",
"0.7394847",
"0.72965956",
"0.7293301",
"0.7226869",
"0.7225389",
"0.7205555",
"0.71771973",
"0.71743053",
"0.7146052",
"0.7134735",
"0.71325094",
"0.71289283",
"0.7126178",
"0.71148866",
"0.7109676",
"0.7082562",
"0.707800... | 0.0 | -1 |
Provide helpful representation when printed. | def __repr__(self):
return "<Trip location=%s>" % (self.location) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def nice_output(self):\n return self.des",
"def nice_output(self):\n return self.des",
"def __str__(self):\n return self.printable()",
"def _printable(self):\n toPrint = \"Qubit ID: \" + str(self.qubit_id) +... | [
"0.7529561",
"0.7511525",
"0.7511525",
"0.74975544",
"0.7394847",
"0.72965956",
"0.7293301",
"0.7226869",
"0.7225389",
"0.7205555",
"0.71771973",
"0.71743053",
"0.7146052",
"0.7134735",
"0.71325094",
"0.71289283",
"0.7126178",
"0.71148866",
"0.7109676",
"0.7082562",
"0.707800... | 0.0 | -1 |
Provide helpful representation when printed. | def __repr__(self):
return "<Entry location=%s>" % (self.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def nice_output(self):\n return self.des",
"def nice_output(self):\n return self.des",
"def __str__(self):\n return self.printable()",
"def _printable(self):\n toPrint = \"Qubit ID: \" + str(self.qubit_id) +... | [
"0.75307065",
"0.7511816",
"0.7511816",
"0.7498544",
"0.7394554",
"0.7297524",
"0.72948885",
"0.7227466",
"0.72259456",
"0.7205487",
"0.717849",
"0.7175764",
"0.71467614",
"0.7134615",
"0.7133312",
"0.71315",
"0.7127727",
"0.7116536",
"0.71106595",
"0.70844287",
"0.7078006",
... | 0.0 | -1 |
Provide helpful representation when printed. | def __repr__(self):
return "<Category name=%s>" % (self.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def nice_output(self):\n return self.des",
"def nice_output(self):\n return self.des",
"def __str__(self):\n return self.printable()",
"def _printable(self):\n toPrint = \"Qubit ID: \" + str(self.qubit_id) +... | [
"0.7529561",
"0.7511525",
"0.7511525",
"0.74975544",
"0.7394847",
"0.72965956",
"0.7293301",
"0.7226869",
"0.7225389",
"0.7205555",
"0.71771973",
"0.71743053",
"0.7146052",
"0.7134735",
"0.71325094",
"0.71289283",
"0.7126178",
"0.71148866",
"0.7109676",
"0.7082562",
"0.707800... | 0.0 | -1 |
Provide helpful representation when printed. | def __repr__(self):
return "<Trip=%s shared with user=%s>" % (self.trip.name, self.user.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def nice_output(self):\n return self.des",
"def nice_output(self):\n return self.des",
"def __str__(self):\n return self.printable()",
"def _printable(self):\n toPrint = \"Qubit ID: \" + str(self.qubit_id) +... | [
"0.7529561",
"0.7511525",
"0.7511525",
"0.74975544",
"0.7394847",
"0.72965956",
"0.7293301",
"0.7226869",
"0.7225389",
"0.7205555",
"0.71771973",
"0.71743053",
"0.7146052",
"0.7134735",
"0.71325094",
"0.71289283",
"0.7126178",
"0.71148866",
"0.7109676",
"0.7082562",
"0.707800... | 0.0 | -1 |
Provide helpful representation when printed. | def __repr__(self):
return "<%s requested to be friends with %s and the status is %s>" % (self.requester.name, self.accepter.name, self.accepted) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def nice_output(self):\n return self.des",
"def nice_output(self):\n return self.des",
"def __str__(self):\n return self.printable()",
"def _printable(self):\n toPrint = \"Qubit ID: \" + str(self.qubit_id) +... | [
"0.7529561",
"0.7511525",
"0.7511525",
"0.74975544",
"0.7394847",
"0.72965956",
"0.7293301",
"0.7226869",
"0.7225389",
"0.7205555",
"0.71771973",
"0.71743053",
"0.7146052",
"0.7134735",
"0.71325094",
"0.71289283",
"0.7126178",
"0.71148866",
"0.7109676",
"0.7082562",
"0.707800... | 0.0 | -1 |
Evaluate the fitness of a state vector. | def evaluate(self, state):
fitness = 0
for i in range(1, len(state)):
if state[i] != state[i - 1]:
fitness += 1
return fitness | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self, state):\n\n fitness = np.sum(state)\n self.num_evals += 1\n #print(self.num_evals)\n return fitness",
"def evaluate(self, state):\n\n if len(state) != len(self.weights):\n raise Exception(\"\"\"The state array must be the same size as the\"\"\"\n ... | [
"0.8012917",
"0.74508816",
"0.7194993",
"0.6744618",
"0.65376604",
"0.65175664",
"0.6379756",
"0.6377531",
"0.63079077",
"0.62446994",
"0.62412494",
"0.6225087",
"0.62198865",
"0.62149936",
"0.6121375",
"0.6110914",
"0.6110755",
"0.61076415",
"0.60918206",
"0.6062703",
"0.600... | 0.75113136 | 1 |
Return the problem type. Returns | def get_prob_type(self):
return self.prob_type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def problem_type(self):\n return self._problem_type",
"def get_problem_type():\n problem_type = input(\"What type of problem do you want?\")\n return problem_type",
"def getprobtype(self): # 3\n res,resargs = self.__obj.getprobtype()\n if res != 0:\n result,msg = self.__getlasterr... | [
"0.9160186",
"0.7815036",
"0.73731285",
"0.72935814",
"0.6773175",
"0.67403567",
"0.6690188",
"0.6674199",
"0.6661264",
"0.6547367",
"0.65317446",
"0.65317446",
"0.65317446",
"0.65317446",
"0.65317446",
"0.65317446",
"0.65317446",
"0.65317446",
"0.65317446",
"0.65317446",
"0.... | 0.0 | -1 |
Data is expected to be in order by date and hour (otherwise use sort on those two columns before hand). This replaces the NaN with the value, of the same feature, from the preceeding observation. | def ffill_nans(df):
return df.fillna(method='ffill', axis=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _impute_border_hours(self, temp):\n temp = temp.dropna()\n last_day = temp.index.max()\n first_day = temp.index.min()\n for hour in range(1, 4):\n new_hour = first_day - pd.DateOffset(hours=hour)\n # Get closest hour\n best = new_hour + pd.DateOffset... | [
"0.6238114",
"0.5930863",
"0.5655169",
"0.56405604",
"0.5583812",
"0.5441467",
"0.5418563",
"0.53677136",
"0.5338042",
"0.53334886",
"0.5324758",
"0.527275",
"0.5242246",
"0.52042073",
"0.5203237",
"0.5187879",
"0.51851505",
"0.51743656",
"0.51482105",
"0.5098091",
"0.5094744... | 0.51533633 | 18 |
given a list of interests, produce a vector whose ith element is 1 if unique_interests[i] is in the list, 0 otherwise | def make_user_interest_vector(user_interests):
return [1 if interest in user_interests else 0
for interest in restaurant_list] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_scientists_who_like(target_interest):\n return [user_id for user_id, user_interest in interests if user_interest == target_interest]",
"def __call__(self, it):\n entries = np.zeros(len(self.subsets))\n arr = np.array(it)\n for count, subset in enumerate(self.subsets):\n ... | [
"0.58162695",
"0.57084155",
"0.553205",
"0.54441607",
"0.5354761",
"0.5301404",
"0.5242172",
"0.522334",
"0.51655567",
"0.51454437",
"0.51351553",
"0.5115838",
"0.50991243",
"0.5085717",
"0.50820386",
"0.5065581",
"0.50136983",
"0.49883407",
"0.49648532",
"0.49625477",
"0.495... | 0.78756875 | 0 |
Yield successive nsized chunks from l. | def split_list(l, n):
for i in xrange(0, len(l), n):
yield l[i:i + n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]",
"def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def get_chunks(self, ... | [
"0.8037606",
"0.7922978",
"0.79210585",
"0.78825927",
"0.78753805",
"0.7813621",
"0.7763579",
"0.77534133",
"0.7742161",
"0.7729807",
"0.7726926",
"0.7723026",
"0.77007324",
"0.7687473",
"0.7687473",
"0.7662126",
"0.76550704",
"0.76538754",
"0.76538754",
"0.76439047",
"0.7643... | 0.0 | -1 |
Check Label file for the compression type. | def is_lossy(label):
val = getkey(from_=label, keyword='INST_CMPRS_TYPE').decode().strip()
if val == 'LOSSY':
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _file_can_be_compressed(filename):\n content_type = ''\n with open(filename, 'rb') as f:\n content_type = _get_content_type(f)\n return content_type in TEXT_TYPES",
"def check_compression(ctype, clevel, olevel):\n repository = Repository(archiver.repository_path, exclusive=True)\n ... | [
"0.61536145",
"0.6104271",
"0.6028362",
"0.5915304",
"0.566257",
"0.566257",
"0.5618967",
"0.55271715",
"0.55238616",
"0.54872984",
"0.5485315",
"0.5475698",
"0.5444148",
"0.54130983",
"0.5395448",
"0.52835786",
"0.5279148",
"0.52784103",
"0.52374476",
"0.5233833",
"0.5226278... | 0.48622942 | 82 |
Determine if the command should be run. | def is_runnable(self, force):
if force:
return True
else:
weekday = datetime.datetime.now().weekday()
if weekday == settings.LOAD_DAY:
return True
else:
logger.info(
'Today is %s. This command only runs o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_command_ancillary(args):\n # pylint: disable=bad-continuation\n if (\n # skip the parent check and only\n # determine if the parameter is present\n is_valid_executes(args, skip=True)\n ):\n return True\n return False",
"def is_valid_command(args):\n if args.comma... | [
"0.75077385",
"0.74455243",
"0.7324312",
"0.73188907",
"0.719609",
"0.7100293",
"0.70227396",
"0.7010096",
"0.69712514",
"0.68999755",
"0.6875882",
"0.6863991",
"0.68367815",
"0.68101025",
"0.6802171",
"0.6767907",
"0.67454386",
"0.67171776",
"0.67075706",
"0.67023826",
"0.66... | 0.0 | -1 |
Creates an instance of this model from a dictionary | def from_dictionary(cls,
dictionary):
if dictionary is None:
return None
# Extract variables from the dictionary
all_endpoints_reachable = dictionary.get('allEndpointsReachable')
auto_register_target = dictionary.get('autoRegisterTarget')
auto... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction... | [
"0.8317533",
"0.81689686",
"0.81689686",
"0.81188685",
"0.808892",
"0.7977596",
"0.7949056",
"0.79225504",
"0.78983366",
"0.7893884",
"0.7887517",
"0.7882494",
"0.7881197",
"0.7876339",
"0.78581846",
"0.78387725",
"0.78037786",
"0.78037786",
"0.78037786",
"0.78037786",
"0.780... | 0.0 | -1 |
Mostly for the description text for each company. Take the text, strip of extra white space, kill nonalphanumeric characters, strip any resulting whitespace, return cleaned text | def strip_clean_stem_description(text, stemmer):
# no damn hyphens!
text = text.strip().replace("-"," ")
kill_nonalpha = re.compile("[\W]+")
# need to get rid of any stray "s" from killing apostrophes
text = kill_nonalpha.sub(" ", text).replace(" s ", " ").strip()
reduce_whitespace = re.compil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_cleaning(self, text): # pylint: disable=no-self-use\n text = text.encode(\"ascii\", \"ignore\").decode(\"ascii\", \"ignore\")\n text = re.sub(r'[^\\x00-\\x7F]', '', text)\n text = text.replace(\"\\n\", \"\")\n text = text.replace(\"\\'\", \"'\")\n text = text.replace(\"... | [
"0.79752713",
"0.7823272",
"0.77730495",
"0.76722336",
"0.76722336",
"0.76722336",
"0.76722336",
"0.76722336",
"0.76722336",
"0.74200845",
"0.721478",
"0.71442825",
"0.71266997",
"0.7125729",
"0.7072146",
"0.7036413",
"0.7026497",
"0.70100945",
"0.69828326",
"0.69694954",
"0.... | 0.69893366 | 18 |
Returns the name of the model | def get_name(self):
modelTree = self.model.find(xmlns + 'Model')
return modelTree.attrib['name'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_name(self) -> str:\n return self._model_name",
"def name(self) -> str: # pragma: no cover\n return self.model.__name__",
"def get_model_name(self) -> str:\n raise NotImplementedError",
"def name(self) -> str:\n return self._model.name",
"def get_model_name(self) -> st... | [
"0.9077247",
"0.8916257",
"0.88578737",
"0.8837768",
"0.86760336",
"0.8594305",
"0.85306764",
"0.8471391",
"0.83710957",
"0.83444494",
"0.83044755",
"0.81630605",
"0.80993557",
"0.8074138",
"0.80380595",
"0.7990968",
"0.7884208",
"0.7802405",
"0.7797321",
"0.7772501",
"0.7690... | 0.84826887 | 7 |
Returns a list of all variable metabolites, compartments and global quantities in the model. By default, returns the internal string representation, e.g. CN=Root,Model=Kummer calcium model,Vector=Compartments[compartment],Vector=Metabolites[a],Reference=ParticleNumber. Running pretty=True will parse the string and retu... | def get_variables(self, pretty=False):
output = []
#Get the model XML tree
model = self.model.find(xmlns + 'Model')
#Get list of metabolites
metabolites = model.find(xmlns + 'ListOfMetabolites')
for metabolite in metabolites:
name = metabolit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variable_names(self):\n\n status, stdout, stderr = self.__xcall__(['--print-variables'])\n\n if status != 0:\n raise RuntimeError(\"error querying --print-variables for package `%s': %s\" % (self.name, stderr))\n\n return stdout.strip().split()",
"def variables(model: Model) -> AbstractSet[str]... | [
"0.55102617",
"0.55067605",
"0.550463",
"0.5411136",
"0.5308223",
"0.5295979",
"0.52675784",
"0.52090466",
"0.5188525",
"0.5186908",
"0.5174155",
"0.5164439",
"0.5131951",
"0.508222",
"0.5059991",
"0.50463784",
"0.50463784",
"0.50463784",
"0.50246525",
"0.50185287",
"0.501402... | 0.7089826 | 0 |
Extends base method to build Gaussian distribution. | def initialize(self, env_spaces, share_memory=False,
global_B=1, env_ranks=None):
super().initialize(env_spaces, share_memory,
global_B=global_B, env_ranks=env_ranks)
assert len(env_spaces.action.shape) == 1
assert len(np.unique(env_spaces.action.hig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gaussian_distribution(self, x: ndarray, mu: float, sigma: float) -> ndarray:\n return 1 / (np.sqrt(2 * np.pi) * sigma) * np.exp(\n -np.power(\n (x - mu) / sigma, 2) / 2)",
"def makeGaussian(height, width, sigma=3, center=None):\n x = np.arange(0, width, 1, float)\n ... | [
"0.7869431",
"0.71547395",
"0.70590705",
"0.6987415",
"0.6839315",
"0.6738969",
"0.67169774",
"0.670978",
"0.6672611",
"0.6664034",
"0.66502035",
"0.6649308",
"0.6631346",
"0.6621101",
"0.66138494",
"0.66138494",
"0.6595928",
"0.65891653",
"0.658836",
"0.65771896",
"0.6572279... | 0.0 | -1 |
Compute policy's action distribution from inputs, and sample an action. Calls the model to produce mean, log_std, and value estimate. Moves inputs to device and returns outputs back to CPU, for the sampler. (no grad) | def step(self, observation, prev_action, prev_reward):
model_inputs = buffer_to((observation, prev_action, prev_reward),
device=self.device)
mu, log_std, value = self.model(*model_inputs)
dist_info = DistInfoStd(mean=mu, log_std=log_std)
action = self.dis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_action(self, obs, explore_prob):\n del explore_prob\n img = np.expand_dims(obs, 0)\n\n def objective_fn(samples):\n feed_dict = {self._state_ph: img, self._action_ph: samples}\n if self._include_timestep:\n feed_dict[self._step_ph] = self._timestep\n q_values = self._sess.... | [
"0.6781642",
"0.67316216",
"0.6616817",
"0.6566162",
"0.6564566",
"0.6461039",
"0.6407673",
"0.63524276",
"0.6335394",
"0.62274265",
"0.6224984",
"0.62144256",
"0.61862516",
"0.6139336",
"0.6074051",
"0.6060686",
"0.60396695",
"0.6005963",
"0.59967095",
"0.59950674",
"0.59873... | 0.621063 | 12 |
Compute policy's action distribution from inputs, and sample an action. Calls the model to produce mean, log_std, value estimate, and next recurrent state. Moves inputs to device and returns outputs back to CPU, for the sampler. Advances the recurrent state of the agent. (no grad) | def step(self, observation, prev_action, prev_reward):
agent_inputs = buffer_to((observation, prev_action, prev_reward),
device=self.device)
mu, log_std, value, rnn_state = self.model(*agent_inputs, self.prev_rnn_state)
dist_info = DistInfoStd(mean=mu, log_std=lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_action(self, obs, explore_prob):\n del explore_prob\n img = np.expand_dims(obs, 0)\n\n def objective_fn(samples):\n feed_dict = {self._state_ph: img, self._action_ph: samples}\n if self._include_timestep:\n feed_dict[self._step_ph] = self._timestep\n q_values = self._sess.... | [
"0.6783748",
"0.67403287",
"0.66699374",
"0.6656579",
"0.6608575",
"0.6552389",
"0.64320886",
"0.6410225",
"0.63930863",
"0.6344672",
"0.6343782",
"0.6332864",
"0.63217664",
"0.6298843",
"0.62863237",
"0.628039",
"0.6267779",
"0.62299633",
"0.6228783",
"0.62004095",
"0.617544... | 0.6312931 | 13 |
Compute the value estimate for the environment state using the currently held recurrent state, without advancing the recurrent state, e.g. for the bootstrap value V(s_{T+1}), in the sampler. (no grad) | def value(self, observation, prev_action, prev_reward):
agent_inputs = buffer_to((observation, prev_action, prev_reward),
device=self.device)
_mu, _log_std, value, _rnn_state = self.model(*agent_inputs, self.prev_rnn_state)
return value.to("cpu") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value_iteration(self):\n #Create a utility function of the environment shape\n gamma = 0.9\n epsilon = 0.01\n iteration = 0\n\n #create a utility function that matches the size of the number of states\n u = np.zeros(self.env.observation_space.n, dtype=float)\n\n ... | [
"0.67880297",
"0.6584124",
"0.6583936",
"0.64015716",
"0.62653023",
"0.6231752",
"0.6174343",
"0.6108784",
"0.6106184",
"0.6102996",
"0.60876197",
"0.6087169",
"0.60804063",
"0.6069745",
"0.6012716",
"0.60105777",
"0.5980969",
"0.59763813",
"0.5963678",
"0.59612346",
"0.59568... | 0.56189704 | 64 |
Return the key for this experiment's notes. | def key_for_experiment(experiment):
return "_gae_bingo_notes:%s" % experiment.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key(self) -> str:\n return pulumi.get(self, \"key\")",
"def key(self) -> str:\n return pulumi.get(self, \"key\")",
"def key(self) -> str:\n return pulumi.get(self, \"key\")",
"def key(self) -> str:\n return pulumi.get(self, \"key\")",
"def key(self) -> str:\n return p... | [
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"0.7344994",
"... | 0.8063581 | 0 |
Returns the command line parser. | def cmd_line_parser():
usage = "usage: %prog [options]\n"
opt_parser = OptionParser(usage=usage)
opt_parser.add_option("--ai", action="store", dest="alternative_input",
help="an alternative input file (works only with load_from_pickle)")
opt_parser.add_option("--dl", action="st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_parser():\n\n parser = parser.ArgumentParser()\n return parser",
"def get_parser(self):\n parser = ArgumentParser()\n parser.add_argument(\n \"-c\", default='', dest='cmd',\n help=(\"just like python -c or sh -c (pass in a command)\"))\n parser.add... | [
"0.86417437",
"0.82492447",
"0.7812851",
"0.78048086",
"0.7747385",
"0.7708767",
"0.7684778",
"0.76764417",
"0.76672405",
"0.76368827",
"0.76358366",
"0.76358366",
"0.76234126",
"0.75705457",
"0.7503757",
"0.75023043",
"0.74550796",
"0.7454367",
"0.74395573",
"0.7431589",
"0.... | 0.7205358 | 33 |
Given number of homozygous dominant, heterozygous, and recessive parents in a population, return the probability of two randomly selected parents producing a dominant child | def prob_dom_offspring(AA, Aa, aa):
total = AA + Aa + aa
# probability of choosing both homozygous recessive parents ,
# followed by recessive offspring probability
P_aaaa = (aa / total) * ((aa - 1) / (total - 1))
P_aa_aaaa = 1
# probability of choosing one homozygous recessive and one
# het... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def selection(probs):\n # pick 2 parents out of this distribution\n t = [i for i in range(len(probs))]\n draw = choice(t, 2, p=probs, replace=False)\n return draw",
"def stochastic_universal_selection(self, fitness, num_parents):\n\n fitness_sum = numpy.sum(fitness)\n if fitness_sum == ... | [
"0.69079775",
"0.6861657",
"0.6755661",
"0.6599582",
"0.6594344",
"0.6459393",
"0.64419204",
"0.6349386",
"0.6328433",
"0.62635946",
"0.6263308",
"0.6233012",
"0.61846685",
"0.6179733",
"0.6178044",
"0.6172119",
"0.61516386",
"0.6148058",
"0.61347187",
"0.61295307",
"0.612721... | 0.6113784 | 21 |
provides both the maximum drawdown and the maximum drawdown duration. The former is the aforementioned largest peaktotrough drop, latter is defined as the number of periods over which this drop occurs. | def create_drawdowns(equity_curve):
hwm = [0]
eq_idx = equity_curve.index
drawdown = pd.Series(index = eq_idx)
duration = pd.Series(index = eq_idx)
for t in range(1, len(eq_idx)):
cur_hwm = max(hwm[t-1], equity_curve[t])
hwm.append(cur_hwm)
drawdown[t] = hwm[t] - equity_curv... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_max_draw_down(ts_vals):\r\n MDD = 0\r\n DD = 0\r\n peak = -99999\r\n for value in ts_vals:\r\n if (value > peak):\r\n peak = value\r\n else:\r\n DD = (peak - value) / peak\r\n if (DD > MDD):\r\n MDD = DD\r\n return MDD",
"def lifetime_m... | [
"0.7653134",
"0.71487314",
"0.6538466",
"0.6263678",
"0.60450226",
"0.60228133",
"0.5996158",
"0.5928913",
"0.5921158",
"0.59128356",
"0.58735746",
"0.5871584",
"0.5871162",
"0.58609414",
"0.58609414",
"0.58609414",
"0.58609414",
"0.583573",
"0.58341116",
"0.5809282",
"0.5805... | 0.5626268 | 37 |
Generate a random string of fixed length | def randomString(stringLength=5):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))",
"def generate_random_string(length=6):\n n = int(length / 2 + 1)\n x = binascii.hexlify(os.urandom(n))\n s = x[:length]\n return s.decode(\"utf-8\")",... | [
"0.8680464",
"0.8573714",
"0.85486245",
"0.85297275",
"0.85209286",
"0.84331024",
"0.8432044",
"0.84157014",
"0.84120053",
"0.8389201",
"0.8345882",
"0.8343962",
"0.83406156",
"0.83348686",
"0.83240855",
"0.82986933",
"0.82911193",
"0.8281826",
"0.82818025",
"0.82811046",
"0.... | 0.0 | -1 |
``ElasticSearch`` 'close' terminates the TCP socket with the ElasticSearch server | def test_close(self, fake_Session):
fake_resp = MagicMock()
fake_session = MagicMock()
fake_session.post.return_value = fake_resp
fake_Session.return_value = fake_session
es = elasticsearch.ElasticSearch(server='8.8.8.8',
user='alice',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Close(self):\n self._elastic_db.bulk_index(self._index_name, self._doc_type, self._data)\n self._data = []\n sys.stdout.write(u'. [DONE]\\n')\n sys.stdout.write(u'ElasticSearch index name: {0:s}\\n'.format(\n self._index_name))\n sys.stdout.flush()",
"def close(self):\n self.context[... | [
"0.70336276",
"0.69795156",
"0.6864338",
"0.68620807",
"0.68620807",
"0.68620807",
"0.68620807",
"0.68620807",
"0.68620807",
"0.68367183",
"0.6807043",
"0.6794845",
"0.675841",
"0.6689728",
"0.6539972",
"0.65364474",
"0.65360487",
"0.65179473",
"0.65101755",
"0.6499446",
"0.6... | 0.6176613 | 47 |
Loads a Dictionary from a JSON file. | def from_JSON(cls, filename):
with open(os.path.expanduser(filename), encoding='utf-8') as f:
return json.load(f, object_hook=class_hook) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_dict_from_json(filename):\n with open(filename, 'r') as f:\n loaded_dict = json.load(f)\n\n return loaded_dict",
"def load_json(filename: str) -> Dict:\n \n with open(filename, 'r') as json_file:\n return json.load(json_file)",
"def load_json(self, filename):\n with op... | [
"0.828783",
"0.818121",
"0.815204",
"0.8121382",
"0.8085387",
"0.7891839",
"0.7890699",
"0.7828557",
"0.76821506",
"0.7662741",
"0.7570108",
"0.75566816",
"0.75473505",
"0.7547173",
"0.7541553",
"0.7529886",
"0.75074774",
"0.74732345",
"0.74709004",
"0.7454136",
"0.74520767",... | 0.70727473 | 62 |
Converts a dict to a sorting key function. | def sort_key(alpha):
if not isinstance(alpha, dict):
# alpha *should* be a dict, but if passed a list or a string, treat it
# as an ordering
try:
alpha = {k: v for v, k in enumerate(alpha)}
except TypeError:
# alpha isn't iterable, and is therefore useless as ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort(self, key_func):\n pass",
"def functools_cmp_to_key():\n # make a key function using cmp_to_keY(). \n # It means convert cmp function to key literally\n get_key = functools.cmp_to_key(compare_obj)\n def get_key_wrapper(o):\n \"\"\"wrapper function for get_key to allow for print... | [
"0.66415715",
"0.6104064",
"0.60553557",
"0.6031137",
"0.58840287",
"0.576856",
"0.57596457",
"0.5759305",
"0.57573587",
"0.57319915",
"0.5729034",
"0.56467324",
"0.55881965",
"0.55768776",
"0.5571685",
"0.5557849",
"0.5546556",
"0.55318254",
"0.55251825",
"0.550939",
"0.5509... | 0.56522214 | 11 |
test_invalid_password Test login with the wrong password | def test_invalid_login(self):
self.assertRaises(
session.AuthenticationError,
lambda: self.session.authenticate('test@test.com', 'wrongsecret')
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_password(self):\n pass",
"def test_invalid_password(self):\n self.signup('Bo', 'Theo', 'Bo_theo5@example.com', 'Bo1995', 'Bo1995')\n rv = self.login('Bo_theo5@example.com', 'Bo1905')\n self.assertIn(b'Invalid password! Please try again', rv.data)",
"def test_invalid... | [
"0.9022401",
"0.87935483",
"0.8524166",
"0.8415897",
"0.84155333",
"0.838379",
"0.83535945",
"0.8333854",
"0.8316761",
"0.82596475",
"0.8248431",
"0.8243449",
"0.8194633",
"0.81748724",
"0.8117586",
"0.8116172",
"0.81153",
"0.8114346",
"0.81086767",
"0.8088245",
"0.80763793",... | 0.76167214 | 54 |
Draw a list of point and a line segment between to adjacent points. | def draw_point_path(pnt_path: List[Point], color: C3F, point_size: float) -> None:
n = len(pnt_path)
if n > 0:
if n > 1:
vertices = [coord for pnt in pnt_path for coord in pnt.coords()]
pyglet.graphics.draw(
n,
pyglet.gl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_line_list_points(draw_object, list_points, list_point_coords, close=True):\n if close:\n list_points.append(list_points[0])\n\n width_line = 4\n\n point_start = list_points[0: -1]\n point_end = list_points[1:]\n\n for crrt_start, crrt_end in zip(point_start, point_end):\n x1 =... | [
"0.70439583",
"0.68065643",
"0.6768773",
"0.6756516",
"0.6738987",
"0.6687386",
"0.66784614",
"0.6613389",
"0.65902597",
"0.6558266",
"0.65560997",
"0.6554803",
"0.6543044",
"0.65322334",
"0.6525505",
"0.6522953",
"0.6519987",
"0.6481517",
"0.64627725",
"0.6431737",
"0.642727... | 0.63028044 | 33 |
Reshape given data into image format. | def _reshape(self, data):
batch_size, height, width, n_channels = data.shape
if self._grid_height:
grid_height = self._grid_height
else:
grid_height = int(math.floor(math.sqrt(batch_size)))
grid_width = int(math.ceil(batch_size/grid_height))
if n_channels == 1:
data = np.tile(dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _reshape(self, data):\n\n\t\td = np.zeros((32,32,3))\n\t\td_r = data[0:1024].reshape(32,32)\n\t\td_g = data[1024:2048].reshape(32,32)\n\t\td_b = data[2048:].reshape(32,32)\n\n\t\tfor h in range(32):\n\t\t for w in range(32):\n\t\t for c in range(3):\n\n\t\t if c == 0 : d[h,w,c] = d_r[h,w]\... | [
"0.76210296",
"0.75900626",
"0.70545965",
"0.69068485",
"0.68846065",
"0.68622166",
"0.6855061",
"0.6613506",
"0.6565965",
"0.6403932",
"0.6379637",
"0.63594073",
"0.6342385",
"0.62839055",
"0.62780356",
"0.6273087",
"0.62568533",
"0.6220142",
"0.61945105",
"0.6145745",
"0.61... | 0.6807435 | 7 |
View function for home page of site. | def index(request):
num_blogs = Blog.objects.all().count()
num_authors = BlogAuthor.objects.all().count()
num_unique_authors = Blog.objects.distinct().count()
num_comments = Comment.objects.all().count()
return render(request, 'index.html', context={'num_blogs' : num_blogs, 'num_authors' : num_autho... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(request):\n\treturn render(request, \"compta/home.html\")",
"def home_page(request):\r\n return render(request, 'ez_main/home_page.html')",
"def home(request):\r\n return render(request, 'home.html')",
"def homepage(request):\n\treturn render(request, 'core/homepage.html')",
"def homepage(req... | [
"0.8493426",
"0.84268916",
"0.83415145",
"0.83306193",
"0.82976943",
"0.8295291",
"0.8276345",
"0.82545686",
"0.82155704",
"0.8132563",
"0.81246215",
"0.81224865",
"0.8121264",
"0.81049734",
"0.8098485",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0... | 0.0 | -1 |
Returns create_condition response json. | def create_condition(self, url_data, service_id, service_version):
request_dict = {k: v[0] for k, v in url_data}
create_condition = {
u"type": "REQUEST",
u"comment": "",
u"name": "condition",
u"version": service_version,
u"service_id": service... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_condition(self) -> dict:\n url = self.base_url + \"/condition\"\n condition = self._session.get(url).json()\n keys = [\"bandwidth\", \"latency\", \"jitter\", \"loss\"]\n result = {k: v for (k, v) in condition.items() if k in keys}\n return result",
"def get_attributes(s... | [
"0.5847554",
"0.5801164",
"0.57961017",
"0.57333744",
"0.5637778",
"0.54738986",
"0.540615",
"0.53955156",
"0.53332907",
"0.53264594",
"0.5162942",
"0.5160861",
"0.514165",
"0.50501394",
"0.50371593",
"0.5026761",
"0.5023248",
"0.49916404",
"0.49806654",
"0.49672177",
"0.4967... | 0.6098732 | 0 |
Set line edit's placeholder text | def setPlaceholderText(self, text: str):
if text:
self.new_name.setPlaceholderText(text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_new_talk_placeholder_text(self):\r\n self.newTalkWidget.talkDetailsWidget.titleLineEdit.setPlaceholderText(\"\")\r\n self.newTalkWidget.talkDetailsWidget.presenterLineEdit.setPlaceholderText(\"\")\r\n self.newTalkWidget.talkDetailsWidget.categoryLineEdit.setPlaceholderText(\"\")\r\n... | [
"0.6929956",
"0.6578382",
"0.64586073",
"0.64154404",
"0.62986743",
"0.60900784",
"0.60811985",
"0.59905887",
"0.59521675",
"0.5879797",
"0.5821092",
"0.5812464",
"0.57975197",
"0.5792803",
"0.57827544",
"0.57554907",
"0.5734902",
"0.5717878",
"0.56934536",
"0.56692445",
"0.5... | 0.71683925 | 0 |
Set dialog title and description | def setText(self, title: str, description: str):
self.title.setText(title)
self.description.setText(description) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_title(self, title):\n self.dlg.txt_layer.setText(title)",
"def ask_dialog(self, title=\"\", vars=[], help=\"\"):\n\t\tpass",
"def set_title(self, title):\n\t\tpass",
"def set_title(self, title):\r\n self.title = title",
"def set_title(self, title):\n self.widget.SetTitle(title)... | [
"0.751952",
"0.67342395",
"0.6544441",
"0.6540817",
"0.6500626",
"0.64731616",
"0.6382659",
"0.63705266",
"0.6309479",
"0.62906516",
"0.62901556",
"0.62878317",
"0.6284614",
"0.62809855",
"0.6238528",
"0.62382936",
"0.62286764",
"0.61891836",
"0.6180743",
"0.6172923",
"0.6170... | 0.6645893 | 2 |
Return True if ``other`` has same attributes with same values. | def __eq__(self, other):
if isinstance(other, self.__class__):
if self._slots_ == other._slots_:
self_other = [
numpy.all(
getattr(self, s, None) == getattr(other, s, None))
for s in self._slots_]
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n\t\treturn all((getattr(self, attr, None) == getattr(other, attr, None) for attr in self.attrs))",
"def __eq__(self, other):\n return np.all([\n self.__getattribute__(name) == other.__getattribute__(name)\n for name in self._fields\n ])",
"def __eq_... | [
"0.82193214",
"0.8099852",
"0.8026138",
"0.7856913",
"0.78468555",
"0.7796422",
"0.7787191",
"0.7784008",
"0.7775097",
"0.7728548",
"0.7699241",
"0.76797575",
"0.7584505",
"0.7553364",
"0.7547945",
"0.7544183",
"0.7537709",
"0.75361085",
"0.75361085",
"0.75282156",
"0.7516436... | 0.7522212 | 20 |
Populates a list of needed variables for this calculator | def buildVariables(self, model):
# Inputs
self._addModelVariable(model, 'xtal_frequency_hz', int, ModelVariableFormat.DECIMAL, units='Hz', desc='EFR32 crystal clock frequency.')
self._addModelVariable(model, 'rx_xtal_error_ppm', int, ModelVariableFormat.DECIMAL, units='ppm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_vars(self):\n pass",
"def fetch_variables(self):\r\n fgraph = self.fgraph\r\n self.inputs = fgraph.inputs\r\n self.outputs = fgraph.outputs\r\n\r\n # list(fgraph.variables)\r\n # We need to include the not used inputs in our variables,\r\n # otherwis... | [
"0.7176193",
"0.6256424",
"0.6223415",
"0.62104774",
"0.6112347",
"0.60836583",
"0.6034646",
"0.59578925",
"0.59563446",
"0.5936524",
"0.59179926",
"0.59065187",
"0.5860849",
"0.5857573",
"0.5855904",
"0.5846698",
"0.58406526",
"0.583259",
"0.58040106",
"0.57965654",
"0.57699... | 0.5545835 | 36 |
Retrieve whether user is in an organization or not | def get_is_org_user(carto_sql_client):
resp = carto_sql_client.send('SHOW search_path')
paths = resp['rows'][0]['search_path'].split(',')
# if 'public' is first element, user is not in an org
return bool(paths[0] != 'public') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_organization(self):\n return self.user_id is None",
"def allowed_organization_access_use(user, org):\n try:\n up = user.get_profile()\n except AttributeError:\n return False\n\n if user.has_perm(\"vnswww.organization_use_any\"):\n return True\n elif user.has_perm(\"... | [
"0.78197694",
"0.7162456",
"0.7055514",
"0.68854463",
"0.684502",
"0.6616765",
"0.6533737",
"0.65211344",
"0.6481495",
"0.6481495",
"0.64273506",
"0.6380555",
"0.6343691",
"0.6324792",
"0.6285467",
"0.62657815",
"0.62388426",
"0.6172747",
"0.6170405",
"0.6143318",
"0.6132338"... | 0.706464 | 2 |
Transform a DataFrame row into a commaseparated list for use in a SQL query. | def format_row(rowvals, dtypes, colnames):
mapped_vals = []
for colnum, val in enumerate(rowvals):
pgtype = dtype_to_pgtype(dtypes[colnum], colnames[colnum])
mapped_vals.append(numpy_val_to_pg_val(val, pgtype))
return ','.join(mapped_vals) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_list(df: pandas.DataFrame, row=-1) -> list:\n if df is None:\n return []\n if row >= 0:\n rec = []\n for col in range(0, 13):\n rec.append(df.iat[row, col])\n return rec\n recs = []\n for row in range(df.shape[0]):\n recs.append(as_list(df, row=row))... | [
"0.69917864",
"0.6468991",
"0.61137706",
"0.6027913",
"0.58024186",
"0.5794945",
"0.5694396",
"0.5681889",
"0.5664474",
"0.5652714",
"0.551987",
"0.5497426",
"0.5494418",
"0.54830676",
"0.5454618",
"0.5441398",
"0.543419",
"0.5428884",
"0.5417282",
"0.5407113",
"0.54053783",
... | 0.51937395 | 43 |
Create a pandas DataFrame from a CARTO table | def df_from_table(query, carto_sql_client, index=None):
resp = carto_sql_client.send(query)
schema = transform_schema(resp['fields'])
if index:
return pd.DataFrame(resp['rows']).set_index('cartodb_id').astype(schema)
else:
return pd.DataFrame(resp['rows']).astype(schema) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_data(table):\n engine = create_engine(myDB, encoding='latin1') \n conn = engine.connect()\n select = conn.execute('select * from ' + table)\n\n df = pd.DataFrame(select.fetchall()) \n df.columns = select.keys()\n\n conn.close()\n return df",
"def as_DataFrame (self):\n return... | [
"0.69399226",
"0.67963624",
"0.6595991",
"0.6583717",
"0.6479602",
"0.647382",
"0.64655834",
"0.6395341",
"0.63669527",
"0.63526434",
"0.63388586",
"0.6329872",
"0.62770593",
"0.6274831",
"0.62717134",
"0.6266277",
"0.6263397",
"0.62623143",
"0.62573934",
"0.6248814",
"0.6242... | 0.70858014 | 0 |
Test that the method raises a ``NotImplementedError``. | def test__generate_details_raises_error(self):
# Setup
base_property = BaseSingleTableProperty()
# Run and Assert
with pytest.raises(NotImplementedError):
base_property._generate_details(None, None, None, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_call(self):\r\n with self.assertRaises(NotImplementedError):\r\n self.est1(1)",
"def test_raises_when_unimplemented_method_called(self, method):\n\n class API(platform.PlatformAPI):\n pass\n\n name, impl = method\n params = platform.parameters(impl)\n\n ... | [
"0.76624906",
"0.7614408",
"0.75895524",
"0.75844467",
"0.7247601",
"0.7215502",
"0.7196659",
"0.71661717",
"0.7052914",
"0.69454384",
"0.69113064",
"0.6869098",
"0.6847947",
"0.68190426",
"0.6787314",
"0.6754166",
"0.67203015",
"0.66544306",
"0.664891",
"0.6631463",
"0.65769... | 0.66359955 | 19 |
Test that the method raises a ``NotImplementedError``. | def test_get_visualization_raises_error(self):
# Setup
base_property = BaseSingleTableProperty()
# Run and Assert
with pytest.raises(NotImplementedError):
base_property.get_visualization() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_call(self):\r\n with self.assertRaises(NotImplementedError):\r\n self.est1(1)",
"def test_raises_when_unimplemented_method_called(self, method):\n\n class API(platform.PlatformAPI):\n pass\n\n name, impl = method\n params = platform.parameters(impl)\n\n ... | [
"0.766276",
"0.7614343",
"0.75883573",
"0.7583699",
"0.7247408",
"0.7215283",
"0.71960723",
"0.7165447",
"0.7051322",
"0.69450915",
"0.6911649",
"0.68684",
"0.6847539",
"0.68181175",
"0.67869806",
"0.6754221",
"0.6719409",
"0.66546166",
"0.66481906",
"0.6634858",
"0.6631064",... | 0.6313671 | 34 |
Get the number of cells | def getNumberOfCells(self):
LIB.mnt_grid_getNumberOfCells.argtypes = [POINTER(c_void_p),
POINTER(c_size_t)]
n = c_size_t()
ier = LIB.mnt_grid_getNumberOfCells(self.obj, byref(n))
if ier:
error_handler(FILE, 'getNumberOfCells',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Ncells(self):\n return len(self.cells)",
"def get_cellcount(self):\n self.cellcount += 1\n return self.cellcount - 1",
"def GetNumberOfCells(self):\n return self.GetNumberOfElements(ArrayAssociation.CELL)",
"def ncells(self):\n return self.izone.size",
"def num_cells(... | [
"0.8460799",
"0.8397765",
"0.8392263",
"0.8345085",
"0.8248682",
"0.7961413",
"0.7961413",
"0.7961413",
"0.7961413",
"0.7941904",
"0.7938945",
"0.76323766",
"0.75593317",
"0.75321",
"0.74471474",
"0.7446045",
"0.7414359",
"0.7298542",
"0.72592",
"0.7252347",
"0.72063804",
"... | 0.7964273 | 5 |
Convert a list of integertokens to a string. | def tokens_to_string(self, tokens):
# Create a list of the individual words.
words = [self.index_to_word[token]
for token in tokens
if token != 0]
# Concatenate the words to a single string
# with space between all the words.
text = " ".join(wo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_int_list(L):\n return str(L).replace(\" \", \"\")",
"def int_to_string(ints, inv_vocab):\n\n l = [inv_vocab[i] for i in ints]\n return l",
"def int_to_string(ints, inv_vocab):\n \n l = [inv_vocab[i] for i in ints]\n return l",
"def numList2String(l):\n\treturn ''.join(map(chr, l)... | [
"0.71779174",
"0.7142868",
"0.71329564",
"0.68319064",
"0.68072665",
"0.65842557",
"0.6562694",
"0.65264475",
"0.6521917",
"0.65020406",
"0.6455253",
"0.64400226",
"0.6326894",
"0.6298138",
"0.62807775",
"0.62620515",
"0.6162813",
"0.6128112",
"0.6116177",
"0.61079895",
"0.60... | 0.55584365 | 50 |
Find recursively 'filename' in 'root' and returns a list with paths of found files if these files are in a directory 'directory'. Ignore VCS dirs. The 'directory' is filtered to minimize the number of walked directories. | def find_files(root, directory, filename):
path_list = []
walker = os.walk(root, followlinks=True)
for root, dirs, files in walker:
remove_vcs_dirs(dirs)
#if dirs containt 'directory', don't walk others
if directory in dirs: dirs[:] = [directory]
if root.endswith(os.path.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_files_in_tree(root_dir, no_ext=True, no_dup=True, ignore=[]):\n\n if (type(root_dir) is not list) and len(root_dir):\n root_dir = [root_dir]\n\n file_list = []\n\n if len(root_dir):\n for d in root_dir:\n for root, dirs, files in os.walk(d):\n for f in file... | [
"0.70568657",
"0.6872416",
"0.6868999",
"0.68451357",
"0.6841968",
"0.68370813",
"0.6829136",
"0.6826562",
"0.6807789",
"0.67726743",
"0.67715204",
"0.6758782",
"0.67522115",
"0.6746691",
"0.6703868",
"0.6702614",
"0.6674918",
"0.6665943",
"0.66584975",
"0.6657",
"0.6657",
... | 0.8404236 | 0 |
Generate a random string of fixed length | def randomString(stringLength=27):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))",
"def generate_random_string(length=6):\n n = int(length / 2 + 1)\n x = binascii.hexlify(os.urandom(n))\n s = x[:length]\n return s.decode(\"utf-8\")",... | [
"0.8680464",
"0.8573714",
"0.85486245",
"0.85297275",
"0.85209286",
"0.84331024",
"0.8432044",
"0.84157014",
"0.84120053",
"0.8389201",
"0.8345882",
"0.8343962",
"0.83406156",
"0.83348686",
"0.83240855",
"0.82986933",
"0.82911193",
"0.8281826",
"0.82818025",
"0.82811046",
"0.... | 0.0 | -1 |
Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. | def which(cmd, mode=os.F_OK | os.X_OK, path=None):
# Check that a given file can be accessed with the correct mode.
# Additionally check that `file` is not a directory, as on Windows
# directories pass the os.access check.
def _access_check(fn, mode):
return os.path.exists(f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def which(cmd, mode=os.F_OK | os.X_OK, path=None):\n # Check that a given file can be accessed with the correct mode.\n # Additionally check that `file` is not a directory, as on Windows\n # directories pass the os.access check.\n def _access_check(fn, mode):\n ... | [
"0.77106726",
"0.7460819",
"0.727641",
"0.6943331",
"0.6540709",
"0.639578",
"0.60801244",
"0.59047854",
"0.5880955",
"0.5878199",
"0.57527226",
"0.5732597",
"0.5709009",
"0.5672643",
"0.5576627",
"0.5575957",
"0.55535084",
"0.5497285",
"0.5452454",
"0.5445605",
"0.5425212",
... | 0.7453694 | 2 |
Test Markdown renderer renders expected style. | def test_style(fixture_file, options, tmp_path):
file_path = tmp_path / "test_markdown.md"
cases = read_fixture_file(Path(__file__).parent / "data" / fixture_file)
for case in cases:
line, title, text, expected = case
file_path.write_bytes(text.encode())
assert mdformat._cli.run([str... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rendered(mock_markdown):\n post = models.Post(content=\"# Foo\")\n\n content = post.rendered\n\n assert content == mock_markdown.return_value\n assert mock_markdown.call_args[0] == (post.content,)\n assert mock_markdown.call_args[1] == {\"output_format\": \"html5\"}",
"def test_link(self)... | [
"0.71631175",
"0.6581456",
"0.649757",
"0.63943833",
"0.62752986",
"0.621016",
"0.6196329",
"0.6175368",
"0.61751425",
"0.6174841",
"0.6112963",
"0.61047953",
"0.60978454",
"0.60492015",
"0.6025187",
"0.5965509",
"0.5951807",
"0.59515566",
"0.5932",
"0.59136903",
"0.5911833",... | 0.7610977 | 0 |
translate seconds into days, hour, minutes | def dhm_from_seconds(self,s):
#print s
days, remainder = divmod(s, 86400)
hours, remainder = divmod(remainder, 3600)
minutes, remainder = divmod(remainder, 60)
return (days, hours, minutes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_from_seconds(s):\n days = s // (24 * 3600) #Het aantal dagen\n time = s % (24 * 3600)\n hours = time // 3600\n time %= 3600\n minutes = time // 60\n time %= 60\n seconds = time\n return [days, hours, minutes, seconds]",
"def convert_to_day_hour_min_sec(seconds):\n minutes,... | [
"0.7842761",
"0.7810068",
"0.77627087",
"0.77392244",
"0.7711251",
"0.7542416",
"0.751465",
"0.7510563",
"0.74377435",
"0.7407318",
"0.73136085",
"0.72281665",
"0.7199605",
"0.7185332",
"0.7144816",
"0.71097434",
"0.710441",
"0.6993191",
"0.6991949",
"0.6989826",
"0.6972651",... | 0.71585286 | 14 |
change a time stamp into a string expressed in local time zone | def ts2str(self,ts):
dttime = datetime.datetime.fromtimestamp(ts)
return self.format_datetime(dttime) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_timestamp_local(self, timestamp):\n return timestamp.in_tz(self.cfg.get('tz', pendulum.now().tz)).to_rfc1123_string()",
"def local_time():\n return datetime.datetime.now().isoformat()[:len('2017-01-24T10:44:00')]",
"def localtime(stamp):\n return stamp - utc_offset",
"def transform_ti... | [
"0.7462704",
"0.7045552",
"0.7001616",
"0.6845749",
"0.6826492",
"0.682228",
"0.67737126",
"0.67328984",
"0.67328984",
"0.67132336",
"0.67036563",
"0.6681958",
"0.6643947",
"0.6608841",
"0.6586036",
"0.6560171",
"0.654287",
"0.6505855",
"0.650477",
"0.6482451",
"0.6437684",
... | 0.6146419 | 52 |
change a time stamp into a string expressed in local time zone | def ts2date(self,ts):
dttime = datetime.datetime.fromtimestamp(ts)
return datetime.datetime.strftime(dttime, "%Y/%m/%d") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_timestamp_local(self, timestamp):\n return timestamp.in_tz(self.cfg.get('tz', pendulum.now().tz)).to_rfc1123_string()",
"def local_time():\n return datetime.datetime.now().isoformat()[:len('2017-01-24T10:44:00')]",
"def localtime(stamp):\n return stamp - utc_offset",
"def transform_ti... | [
"0.7462668",
"0.70445293",
"0.70015144",
"0.68451107",
"0.68265367",
"0.6822051",
"0.67734",
"0.6732164",
"0.6732164",
"0.6712871",
"0.670275",
"0.66812855",
"0.664445",
"0.66085255",
"0.6586375",
"0.65602195",
"0.6542742",
"0.6506033",
"0.65048665",
"0.6481591",
"0.64366674"... | 0.0 | -1 |
Get the day from the sale date column. | def get_day(x):
return x["SALE DATE"].day | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_date_day(date):\n cut_date = date.split('-')\n return cut_date[2]",
"def get_day_of_data(self, column_name, day):\n self.check_for_column(column_name)\n dt = pd.Timestamp(day)\n column = self.data[column_name]\n return column[column.index.date == dt.date()]",
"... | [
"0.7099967",
"0.67865145",
"0.67388654",
"0.6637701",
"0.6593773",
"0.6503442",
"0.6503442",
"0.6503442",
"0.6497169",
"0.64560586",
"0.6399319",
"0.63866055",
"0.63775015",
"0.63751966",
"0.6169005",
"0.61464",
"0.61237496",
"0.6115945",
"0.6098365",
"0.60908437",
"0.6090843... | 0.8017868 | 0 |
Get the month from the sale date column. | def get_month(x):
return x["SALE DATE"].month | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_month(date):\n return date.month",
"def MONTH(date):\n return _make_datetime(date).month",
"def month(self, month: str):\n return get_from_list(self.months, \"month\", month)",
"def month(self):\n return gocept.month.Month(self.calendar_month, self.calendar_year)",
"def getMonth(... | [
"0.7623379",
"0.7445859",
"0.71880466",
"0.7110971",
"0.70447725",
"0.70014364",
"0.7000133",
"0.7000133",
"0.6973821",
"0.67945063",
"0.6705182",
"0.6686901",
"0.6676211",
"0.6674587",
"0.6636349",
"0.662717",
"0.6582133",
"0.65525264",
"0.65525264",
"0.6461384",
"0.6440292"... | 0.8233812 | 0 |
Get the suburb name from the filepath. | def get_suburb(filepath):
suburb = filepath.split("/")
suburb = suburb[1].split(".")
suburb = suburb[0]
return suburb | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def basename(file_path):\n return os.path.basename(file_path)",
"def get_basename(absolute_file_path):\r\n return absolute_file_path.split('/')[-1]",
"def basename(path):\r\n return split(path)[1]",
"def get_file_name(path):\n return os.path.basename(path)",
"def getBaseName(filepath):\n ret... | [
"0.6990239",
"0.685241",
"0.6833657",
"0.6816237",
"0.6815064",
"0.6763192",
"0.6752987",
"0.6724582",
"0.67233443",
"0.6698443",
"0.66768783",
"0.6650156",
"0.6643222",
"0.6616175",
"0.6610948",
"0.6580101",
"0.6567623",
"0.6547671",
"0.65435994",
"0.65331745",
"0.65103894",... | 0.8640637 | 0 |
Return the current topic | def get_last_topic(self):
try:
session = self.persistence.get_session()
topic = session.query(Topic).order_by(desc(Topic.id)).limit(1).one()
return topic
except NoResultFound:
raise TopicNotFound | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_topic(self):\n return self.topic",
"def topic(self):\n return self.config.get('topic', f'{NAMESPACE}/{self.id}')",
"def topic(self):\n return self._topic_name",
"def topic(self) -> str:\n return self._topic",
"def topic(self) -> Optional[pulumi.Input[str]]:\n retu... | [
"0.85695064",
"0.8382625",
"0.8238626",
"0.8050251",
"0.7738083",
"0.7227863",
"0.7205325",
"0.71723133",
"0.7049478",
"0.70172226",
"0.7017079",
"0.6926241",
"0.68880856",
"0.6856335",
"0.68480825",
"0.6803568",
"0.6732376",
"0.6700446",
"0.6690693",
"0.6656934",
"0.6642729"... | 0.63354766 | 27 |
Generate a neatly formatted full name. | def get_formatted_name(first, last):
full_name = first + ' ' + last
return full_name.title() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_name(self):\n\t\tself.full_name = self.first + \" \" + self.last",
"def full_name(self) -> str:\r\n\t\tname = f'{self.last_name} {self.first_name}'\r\n\t\tif self.middle_name:\r\n\t\t\tname += ' ' + self.middle_name\r\n\t\treturn name",
"def get_formatted_name(first, last):\n full_name = f'{first... | [
"0.84015906",
"0.8262383",
"0.8231049",
"0.8229208",
"0.8199836",
"0.8191048",
"0.8168978",
"0.81436765",
"0.8132338",
"0.81308675",
"0.80716896",
"0.80716896",
"0.80716896",
"0.80230886",
"0.80207074",
"0.8016316",
"0.79988605",
"0.79969",
"0.79969",
"0.79969",
"0.7982722",
... | 0.8123386 | 10 |
Checks a user's basic auth credentials against the current Django auth backend. Should return either ``True`` if allowed, ``False`` if not or an ``HttpResponse`` if you need something custom. | def is_authenticated(self, request, **kwargs):
logging.debug(request.META)
if not request.META.get('HTTP_AUTHORIZATION'):
logging.error('HTTP_AUTHORIZATION not found')
return self._unauthorized()
try:
logging.debug('start split')
(auth_type, data)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def basic_auth_required(view_func):\n # http://djangosnippets.org/snippets/448/\n def _auth(request, *args, **kwargs):\n if 'HTTP_AUTHORIZATION' in request.META:\n auth = request.META['HTTP_AUTHORIZATION'].split()\n if len(auth) == 2:\n if auth[0].lower() == \"basi... | [
"0.7252976",
"0.7207687",
"0.71281356",
"0.6948306",
"0.68977356",
"0.68314534",
"0.6736415",
"0.67135644",
"0.6707379",
"0.6700119",
"0.6652531",
"0.6652531",
"0.66314095",
"0.6627163",
"0.6623933",
"0.6583207",
"0.6567645",
"0.6558159",
"0.6548465",
"0.6547641",
"0.653522",... | 0.69937193 | 3 |
Return True if the requirement line is a package requirement; that is, it is not blank, a comment, or editable. | def is_requirement(line):
# Remove whitespace at the start/end of the line
line = line.strip()
# Skip blank lines, comments, and editable installs
return not (
line == '' or
line.startswith('-r') or
line.startswith('#') or
line.startswith('-e') or
line.startswith... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_requirement(line):\n # Remove whitespace at the start/end of the line\n line = line.strip()\n\n # Skip blank lines, comments, and editable installs\n return not (\n line == '' or\n line.startswith('-r') or\n line.startswith('#') or\n line.startswith('-e') or\n ... | [
"0.7957071",
"0.64934194",
"0.6398391",
"0.63928205",
"0.62537825",
"0.6213889",
"0.62059164",
"0.6171744",
"0.61621577",
"0.6081275",
"0.5831421",
"0.5821479",
"0.5817559",
"0.578217",
"0.57806146",
"0.5717121",
"0.5712663",
"0.56851083",
"0.56717706",
"0.566894",
"0.566661"... | 0.7916717 | 1 |
Load all requirements from the specified requirements files. Returns a list of requirement strings. | def load_requirements(*requirements_paths):
requirements = set()
for path in requirements_paths:
requirements.update(
line.strip() for line in open(path).readlines()
if is_requirement(line)
)
return list(requirements) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_requirements():\r\n reqs_path = os.path.join('.', 'requirements.txt')\r\n with open(reqs_path, 'r') as f:\r\n requirements = [line.rstrip() for line in f]\r\n return requirements",
"def read_requirements():\n reqs_path = path.join('.', 'requirements.txt')\n with open(reqs_path, 'r'... | [
"0.7582263",
"0.7565342",
"0.75109774",
"0.73286325",
"0.73281264",
"0.7311684",
"0.72988176",
"0.7227055",
"0.7204267",
"0.7184996",
"0.7161611",
"0.7120689",
"0.71018726",
"0.69983006",
"0.6898905",
"0.6884614",
"0.68212044",
"0.6820119",
"0.68146497",
"0.68112516",
"0.6810... | 0.84467876 | 0 |
Tests an unsuccessful login | def test_unsuccessful_login():
driver = webdriver.Chrome()
driver.get('https://cmput404group10.herokuapp.com')
username = driver.find_element_by_id("username")
username.send_keys("yar")
password = driver.find_element_by_name("password")
password.send_keys("jessica123")
driver.find_element... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_login_form_but_failed_authentication(self):\n\n\n\t\tpass",
"def test_incorrect_login(self):\n response = self.client.post(\n '/users/login',\n data=dict(username=\"dsadsa\", password=\"dsadsadsa\"),\n follow_redirects=True\n )\n self.assertIn(... | [
"0.8404613",
"0.82679164",
"0.81691",
"0.80981475",
"0.8083164",
"0.8001371",
"0.79903114",
"0.79408526",
"0.7924319",
"0.7919805",
"0.7915334",
"0.7806307",
"0.77732605",
"0.7761769",
"0.77546346",
"0.7732514",
"0.7730991",
"0.7729949",
"0.771217",
"0.7667166",
"0.7661879",
... | 0.7842347 | 11 |
Tests deleting a post | def test_delete_post():
driver = webdriver.Chrome()
driver.get('https://cmput404group10.herokuapp.com')
username = driver.find_element_by_id("username")
username.send_keys("ronWeasley")
password = driver.find_element_by_name("password")
password.send_keys("ualberta123")
driver.find_eleme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_deleting_patient_posts(self):\n\n data = {\"post\": 1}\n result = self.client.post(\"/delete-post\", data=data)\n post = Post.query.get(1)\n\n self.assertEqual(result.status_code, 200)\n self.assertIsNone(post)",
"def test_deleting_post(self):\n\n delete_post(1)... | [
"0.8800499",
"0.87892336",
"0.865717",
"0.8653803",
"0.8653803",
"0.84282",
"0.83408046",
"0.83061415",
"0.82390285",
"0.8236631",
"0.8118731",
"0.80998206",
"0.78312385",
"0.7815045",
"0.77962565",
"0.7726053",
"0.7716385",
"0.76551014",
"0.7642258",
"0.7528506",
"0.7437472"... | 0.7114503 | 40 |
Returns static market information for a single market. | def get_market_info(self, market_id, lite=True, coupon_links=False,
locale=None):
req = BFExchangeFactory.create("ns1:GetMarketReq")
req.marketId = market_id
req.includeCouponLinks = coupon_links
if locale:
req.locale = locale
rsp = self._soapc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMarket(self):\n return self.market",
"def market(self):\n return self._market",
"def get_market_summary(self, market):\n return self.__call__('market', 'getmarketsummary', \n {'marketname': market})",
"def market_info(self, symbol):\n r = requests... | [
"0.75639194",
"0.72164845",
"0.70976853",
"0.68394953",
"0.6710445",
"0.65770084",
"0.652126",
"0.6493488",
"0.6480897",
"0.63707626",
"0.62435764",
"0.62218904",
"0.61551166",
"0.6138358",
"0.6091097",
"0.5940581",
"0.58305347",
"0.57989115",
"0.57946306",
"0.57896745",
"0.5... | 0.64072204 | 9 |
Returns market information for a single market. | def get_market_info_lite(self, market_id):
req = BFExchangeFactory.create("ns1:GetMarketInfoReq")
req.marketId = market_id
rsp = self._soapcall(BFExchangeService.getMarketInfo, req)
if rsp.errorCode != GetMarketErrorEnum.OK:
error_code = rsp.errorCode
if error_cod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMarket(self):\n return self.market",
"def get_market_summary(self, market):\n return self.__call__('market', 'getmarketsummary', \n {'marketname': market})",
"def market(self):\n return self._market",
"def market_info(self, symbol):\n r = requests... | [
"0.7883191",
"0.76719874",
"0.76139176",
"0.7175095",
"0.7074238",
"0.700636",
"0.6907682",
"0.6878815",
"0.6846933",
"0.68167675",
"0.67315394",
"0.6684786",
"0.6671593",
"0.664682",
"0.6629393",
"0.632728",
"0.62256783",
"0.61730814",
"0.61708426",
"0.6165593",
"0.6162323",... | 0.7240732 | 3 |
Returns a copy of the tensor as a NumPy array. | def to_numpy(tensor):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def numpy(self) -> np.ndarray:\n return self.tensor.numpy()",
"def _torch_to_numpy(tensor):\n return tensor.detach().cpu().numpy()",
"def numpy(self):\n value = self._value()\n if not tf.executing_eagerly():\n raise NotImplementedError(\n 'DeferredTensor.numpy() is only supported ... | [
"0.8079986",
"0.7348697",
"0.7328044",
"0.731265",
"0.7241246",
"0.7180614",
"0.7153821",
"0.7123341",
"0.7026259",
"0.6966754",
"0.6933695",
"0.692109",
"0.6806377",
"0.68060404",
"0.6805726",
"0.6782151",
"0.6775523",
"0.67725813",
"0.67236024",
"0.6712941",
"0.66941494",
... | 0.80124706 | 1 |
Concatenate tensors along an axis. | def concatenate(tensors, axis=0):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat(vars, axis=-1):\n return concatenate(vars, axis)",
"def concatenate(tensors, axis=-1):\n if axis < 0:\n rank = ndim(tensors[0])\n if rank:\n axis %= rank\n else:\n axis = 0\n\n if py_all([is_sparse(x) for x in tensors]):\n return sparse_ops.sp... | [
"0.7916419",
"0.7753448",
"0.73998785",
"0.7392846",
"0.7392666",
"0.7300282",
"0.728972",
"0.71900487",
"0.683842",
"0.6699146",
"0.6602763",
"0.6602763",
"0.6505644",
"0.647676",
"0.63733715",
"0.6367537",
"0.63618064",
"0.63406265",
"0.63133556",
"0.63019747",
"0.6247032",... | 0.8547923 | 0 |
Permute the dimensions of a tensor. | def transpose(tensor):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permute(ts: Tensor, axes) -> Tensor:\n permute_op = PermuteOp(axes)\n return permute_op(ts, None)",
"def permute(x, order=None):\n ndims = len(x.shape)\n if order is None:\n raise ValueError(\"Permute: Order must be specified.\")\n\n if order.__class__ == list or order.__class__ == tupl... | [
"0.7045494",
"0.6413222",
"0.63722193",
"0.6207168",
"0.6008015",
"0.5993456",
"0.59567845",
"0.5949393",
"0.5919779",
"0.59066916",
"0.58466125",
"0.5818962",
"0.57936406",
"0.5735378",
"0.5708504",
"0.5705515",
"0.57035106",
"0.56945837",
"0.5686066",
"0.5681428",
"0.566245... | 0.58808047 | 10 |
Return evenly spaced values within a given interval. | def arange(start=0, stop=None, step=None):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evenly_spaced_BDs_OLD(BDs, n):\n BDs = BDs.iloc[:,0].tolist()\n BD_min = min(BDs)\n BD_max = max(BDs)\n return np.linspace(BD_min, BD_max, n)",
"def evenly_spaced(self, a: Real, b: Real, n: int) -> Iter:\n return Iter(_evenly_spaced(a, b, n))",
"def buildIntervalSegs(array, interval: int... | [
"0.6087949",
"0.6031341",
"0.59018815",
"0.5850515",
"0.58354056",
"0.5812694",
"0.57009476",
"0.5671983",
"0.5635459",
"0.5617989",
"0.55989116",
"0.5578975",
"0.5566444",
"0.55558944",
"0.5549609",
"0.554292",
"0.55411255",
"0.5535019",
"0.55296195",
"0.5520334",
"0.5492284... | 0.50392246 | 78 |
Return a new tensor of given shape and type, filled with ones. | def ones(shape, dtype=None):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ones(shape, dtype=np.float32, constant=False):\n return Tensor(np.ones(shape, dtype), constant=constant)",
"def ones(shape, **kwargs):\n return Tensor(np.ones(shape), **kwargs)",
"def ones(shape, dtype=None):\r\n if not isinstance(shape, (list, tuple, TensorVariable)):\r\n shape = [shap... | [
"0.7632132",
"0.75716394",
"0.74962425",
"0.7330009",
"0.7263312",
"0.7079013",
"0.6904904",
"0.6858719",
"0.68140256",
"0.6791529",
"0.67487186",
"0.67139584",
"0.6672417",
"0.6672417",
"0.66505086",
"0.6614411",
"0.6598185",
"0.65375",
"0.6535233",
"0.6494656",
"0.64692634"... | 0.67820764 | 10 |
Return a new tensor of given shape and type, filled with zeros. | def zeros(shape, dtype=None):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zeros(*shape, **kwargs):\n return Tensor(np.zeros(shape), **kwargs)",
"def zeros(shape, dtype=np.float32, constant=False):\n return Tensor(np.zeros(shape, dtype), constant=constant)",
"def zeros(shape, dtype=None):\r\n if not isinstance(shape, (list, tuple, TensorVariable)):\r\n shape =... | [
"0.83107257",
"0.8286282",
"0.80385953",
"0.7741452",
"0.7723195",
"0.765372",
"0.7520479",
"0.74470264",
"0.73485595",
"0.72926056",
"0.72850055",
"0.72850055",
"0.72203296",
"0.72203296",
"0.7185919",
"0.7166474",
"0.7152052",
"0.7136418",
"0.70172834",
"0.70153034",
"0.696... | 0.74001 | 8 |
Return at tensor of zeros with the same shape and type as a given tensor. | def zeros_like(tensor):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zeros(*shape, **kwargs):\n return Tensor(np.zeros(shape), **kwargs)",
"def zeros(shape, dtype=np.float32, constant=False):\n return Tensor(np.zeros(shape, dtype), constant=constant)",
"def zeros_like(other, dtype=None, constant=False):\n if isinstance(other, Tensor):\n other = other.dat... | [
"0.7772456",
"0.74444044",
"0.7396298",
"0.7376385",
"0.69926286",
"0.6973811",
"0.6971716",
"0.6799612",
"0.6686496",
"0.66119266",
"0.65825045",
"0.6580343",
"0.6564902",
"0.6563797",
"0.65531063",
"0.6507446",
"0.64821196",
"0.64479804",
"0.6446543",
"0.643533",
"0.6388131... | 0.8143485 | 0 |
Return a 2D tensor with the elements of `diagonal` on the diagonal and zeros elsewhere. | def diag(diagnoal):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_diagonal(matrix):\n\tdegree_vector = tf.reduce_sum(matrix, 1)\n\tdiagonal = tf.diag(degree_vector, name = 'diagonal')\n\treturn diagonal",
"def diag(diag_elements):\n return tf.diag(tf.reshape(diag_elements, [-1]))",
"def zero_diag(mat):\n\n return replace_diag(mat, np.zeros(mat.shape[0]))",
"def... | [
"0.70121324",
"0.6776347",
"0.66817087",
"0.6601001",
"0.64016086",
"0.629016",
"0.62706244",
"0.6255501",
"0.62478614",
"0.6233163",
"0.6201846",
"0.61673576",
"0.61654633",
"0.61594933",
"0.61390704",
"0.61347073",
"0.6129613",
"0.6113068",
"0.60876036",
"0.60803705",
"0.60... | 0.5564546 | 63 |
Returns sum of the elements on the diagonal of the tensor. | def trace(tensor):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dim_zero_sum(x: Tensor) ->Tensor:\n return torch.sum(x, dim=0)",
"def diagonalSum(M):\n diogonalSum = []\n print(M)\n for i in xrange(0, M.shape[0]):\n diogonalSum += M[i][i]\n print(i)\n \n #print(diogonalSum)\n return diogonalSum",
"def sum(tensor, axis=None):\n ... | [
"0.68653387",
"0.6781425",
"0.67768186",
"0.6765838",
"0.67585963",
"0.675496",
"0.6724569",
"0.6460306",
"0.6415547",
"0.62510717",
"0.6223163",
"0.6213312",
"0.6131057",
"0.5982322",
"0.5975124",
"0.58852196",
"0.58803123",
"0.5859169",
"0.58548987",
"0.5851395",
"0.5813601... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.