query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Load from JSON compatible format. | def __json_decode__(cls, value: Dict[str, Any]) -> "BaseDiscriminator":
return cls.from_config(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_json(self):\n\n self.load_json_str(self.get_json_str())",
"def load(self):\n with io.open(self.filename, encoding='utf-8') as f:\n self.load_from_dict(json.loads(f.read()))",
"def load_from_json(self, json_fp: str):\n # TODO:\n pass",
"def _load_json(self, kind... | [
"0.8049846",
"0.77013475",
"0.74174666",
"0.7406429",
"0.71775204",
"0.71255094",
"0.71053725",
"0.71049905",
"0.7072629",
"0.7061254",
"0.7052197",
"0.7041943",
"0.7013994",
"0.6999872",
"0.6999652",
"0.69852495",
"0.6983238",
"0.69818085",
"0.6940367",
"0.69184947",
"0.6871... | 0.0 | -1 |
Gets the time's string representation. | def __str__(self):
return str(self.date) + " " + str(self.time_of_day) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_time() -> str:\n return strftime(\"%H:%M:%S\")",
"def _time_str(self):\n try:\n if not self._time:\n raise ValueError\n format_ = '%a, %d %b %Y %H:%M:%S'\n return datetime.fromtimestamp(float(self._time)).strftime(format_)\n except ValueErr... | [
"0.8195837",
"0.79449576",
"0.7916762",
"0.7908522",
"0.7828017",
"0.7764987",
"0.77443826",
"0.7721839",
"0.77108437",
"0.7672309",
"0.7598441",
"0.7576887",
"0.75741833",
"0.7518744",
"0.74774283",
"0.7431244",
"0.73107463",
"0.7296751",
"0.72737324",
"0.7268088",
"0.718042... | 0.6514299 | 92 |
Finds out if two 'DateTime' instances are equal. | def __eq__(self, Other):
return self.date == Other.date and self.time_of_day == Other.time_of_day | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, t):\n if not isinstance(t, DateTime):\n return False\n return (self._micros, self._tz) == (t._micros, t._tz)",
"def compare_datetime(self_datetime, other_datetime):\n # pylint: disable=superfluous-parens\n if (isinstance(self_datetime and other_datetime, (datetime,... | [
"0.7574963",
"0.7486285",
"0.73469615",
"0.71358323",
"0.7102583",
"0.7069769",
"0.6915766",
"0.6913998",
"0.6893281",
"0.68712014",
"0.67430377",
"0.6737902",
"0.66964835",
"0.6637913",
"0.65955794",
"0.6516567",
"0.6467195",
"0.6431144",
"0.64010376",
"0.6383123",
"0.633340... | 0.68383235 | 10 |
Finds out if two 'DateTime' instances are not equal. | def __ne__(self, Other):
return self.date != Other.date or self.time_of_day != Other.time_of_day | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def almost_same_datetime(dt1, dt2, allowed_delta=timedelta(minutes=1)):\r\n return abs(dt1 - dt2) < allowed_delta",
"def compare_datetime(self_datetime, other_datetime):\n # pylint: disable=superfluous-parens\n if (isinstance(self_datetime and other_datetime, (datetime, type(None)))):\n return (\n ... | [
"0.7060995",
"0.7005772",
"0.69751614",
"0.67829657",
"0.67326754",
"0.67311144",
"0.66667795",
"0.66145265",
"0.6613488",
"0.6596073",
"0.6548462",
"0.64864844",
"0.6370382",
"0.6360114",
"0.6351058",
"0.625587",
"0.61844254",
"0.61789215",
"0.6171636",
"0.6166754",
"0.61339... | 0.70775914 | 0 |
Finds out if this 'DateTime' instance is greater than or equal to the given 'DateTime' instance. | def __ge__(self, Other):
return not self < Other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __gt__(self, other):\n if self.date > other.date:\n return True\n else:\n return False",
"def __gt__(self, other):\n return self.to_seconds() > other.to_seconds()",
"def __gt__(self, other):\n return self.to_seconds() > other.to_seconds()",
"def is_after(... | [
"0.72755605",
"0.716751",
"0.716751",
"0.6825432",
"0.66495645",
"0.6626132",
"0.65438795",
"0.6435386",
"0.6390202",
"0.63804585",
"0.63540584",
"0.63472325",
"0.6277743",
"0.6254085",
"0.62447333",
"0.6224724",
"0.62006646",
"0.6164806",
"0.6164806",
"0.6158685",
"0.6129429... | 0.0 | -1 |
Gets this timestamp's date. | def date(self):
return self.date_value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_date(self):\n return self.date",
"def get_date(self):\n return self.date",
"def get_date(self):\n return self.date",
"def get_date(self):\n return self.date",
"def _date(self) -> datetime:\n return self.__date",
"def date(self):\n return self._date",
"d... | [
"0.7927242",
"0.7927242",
"0.7927242",
"0.7927242",
"0.76219946",
"0.7481876",
"0.7481876",
"0.7481876",
"0.7479247",
"0.7413321",
"0.735938",
"0.7345253",
"0.73387563",
"0.7326376",
"0.7319995",
"0.72933936",
"0.7208753",
"0.71970916",
"0.7171507",
"0.7161353",
"0.70131135",... | 0.7022817 | 20 |
Gets this timestamp's time of day. | def time_of_day(self):
return self.time_of_day_value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def day_ts(self):\n return self.raw() // (60 * 24)",
"def get_time_of_the_day(self, ts):\n h, m, s = ts.hour, ts.minute, ts.second\n # Convert the hours, minutes, and seconds to seconds: referenced to 0 AM\n t = int(h) * 3600 + int(m) * 60 + int(s)\n if t >= 0:\n ret... | [
"0.7439932",
"0.74265647",
"0.69092965",
"0.6888736",
"0.68819934",
"0.6868406",
"0.68665147",
"0.68561435",
"0.68515694",
"0.684759",
"0.684759",
"0.684759",
"0.6750747",
"0.6740334",
"0.67259836",
"0.67207116",
"0.671258",
"0.671258",
"0.671258",
"0.67064935",
"0.67064935",... | 0.8198794 | 0 |
Gets the terminal columns size. | def terminal_size(self):
try:
_, columns = os.popen("stty size", "r").read().split()
return min(int(columns) - 10, 100)
except ValueError:
return self.default_terminal_size | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def columns(self):\n return get_terminal_size()[1]",
"def terminalWidth():\n return shutil.get_terminal_size().columns",
"def terminal_width():\n return shutil.get_terminal_size().columns",
"def columns(self):\n return int(ShellCommandOutput('tput cols'))",
"def termsize(self):\n try... | [
"0.8785557",
"0.84571654",
"0.83374625",
"0.777216",
"0.7632491",
"0.7619383",
"0.7613431",
"0.7613431",
"0.7584913",
"0.7541525",
"0.75300723",
"0.74066603",
"0.73375237",
"0.7320377",
"0.7304348",
"0.72760767",
"0.72512454",
"0.7232911",
"0.7211451",
"0.71938956",
"0.719232... | 0.7834119 | 3 |
Dodaj rec u trie. | def add(self, word, page, val):
currnode = self.root
for letter in word:
if letter not in currnode.children:
currnode.children[letter] = TrieNode()
currnode = currnode.children[letter]
if currnode is not self.root:
currnode.pages.add(page, va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traversal_test_trie():\n from trie import Trie\n trie = Trie()\n trie.insert('alpha')\n trie.insert('alpaca')\n trie.insert('boy')\n return trie",
"def __init__(self):\n self.d = {}\n self.root = TrieNode()",
"def __init__(self):\n self.root = TrieNode()\n self... | [
"0.67697203",
"0.6569115",
"0.6549657",
"0.64013875",
"0.63839906",
"0.63817024",
"0.63809896",
"0.6332669",
"0.63097703",
"0.6286225",
"0.6282874",
"0.62820023",
"0.6279016",
"0.6273746",
"0.6273746",
"0.6273746",
"0.6273746",
"0.6271161",
"0.6261837",
"0.62104523",
"0.62012... | 0.54784966 | 80 |
Extracts IPO data to a pandas Dataframe and saves it to specified path as a csv file | def extract_ipo_data_to_dataframe(output_path: str):
ipo_guiden_url = "https://www.affarsvarlden.se/ipo-guiden/screener"
driver = web_scraper.get_chrome_driver_for_url(url=ipo_guiden_url)
# Removes pop up
import time
time.sleep(2)
web_scraper.remove_ad(chrome_driver=driver)
# Scroll to get r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_csv(self, path):\n for table in ['datasets', 'dataruns', 'hyperpartitions', 'classifiers']:\n df = pd.read_sql('SELECT * FROM %s' % table, self.session.bind)\n df.to_csv(os.path.join(path, '%s.csv' % table), index=False)",
"def info2csv(df, csv_path):\n df.to_csv(csv_path, ... | [
"0.6840877",
"0.67457867",
"0.646313",
"0.637817",
"0.6377898",
"0.63628334",
"0.6341153",
"0.62978643",
"0.62882537",
"0.62629896",
"0.6224393",
"0.62167746",
"0.6200531",
"0.61713105",
"0.6161895",
"0.6100351",
"0.6091226",
"0.608358",
"0.6077793",
"0.6070303",
"0.60672134"... | 0.6539481 | 2 |
Return if the device is on. | def is_on(self) -> bool:
raise NotImplementedError("Device subclass needs to implement this.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_on(self):\n return self._device.is_on",
"def is_on(self):\n return self._device.is_on",
"def is_on(self):\n return self._device.is_on",
"def is_on(self) -> bool:\n return self._device.is_on",
"def is_on(self):\n return self._device.state",
"def is_on(self) -> boo... | [
"0.90544605",
"0.90544605",
"0.90544605",
"0.89779156",
"0.8846996",
"0.81471056",
"0.81471056",
"0.81411195",
"0.8101262",
"0.80237883",
"0.7998118",
"0.7977133",
"0.7955842",
"0.78938735",
"0.7890516",
"0.7878891",
"0.78744787",
"0.78288925",
"0.7805855",
"0.7805855",
"0.78... | 0.8219473 | 5 |
Creates json file and writes given dict to it | def create_json_file(self,file_name):
with open('saves/' + file_name + '.json', 'w') as fp:
json.dump(self.options, fp, indent=4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_json(dict_to_write, path, file_name):\n with open(path + \"/\" + file_name + \".json\", \"w\") as fp:\n json.dump(dict_to_write, fp)\n return None",
"def save_to_json(dict, file):\n with open(file, 'w') as f:\n json.dump(dict, f, indent=2)\n return file",
"def store(my_dict,... | [
"0.8052829",
"0.792586",
"0.78987247",
"0.78939533",
"0.78021395",
"0.77958584",
"0.7777442",
"0.772789",
"0.7705852",
"0.76111275",
"0.7522913",
"0.7510726",
"0.75095475",
"0.7500985",
"0.749655",
"0.74922687",
"0.7479037",
"0.7462201",
"0.7421586",
"0.73762804",
"0.7351369"... | 0.7059823 | 67 |
Get the name of the account set in the process' environment. | def account_from_env(cls):
return os.getenv("OIO_ACCOUNT", "myaccount") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_name(self) -> str:\n return pulumi.get(self, \"account_name\")",
"def account_name(self) -> str:\n return pulumi.get(self, \"account_name\")",
"def account_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"account_name\")",
"def account_name(self) -> pulumi.Input[s... | [
"0.7500614",
"0.7500614",
"0.6961114",
"0.6961114",
"0.6961114",
"0.6924666",
"0.6914403",
"0.6914403",
"0.68147266",
"0.6794162",
"0.6794162",
"0.6737554",
"0.6737554",
"0.673424",
"0.6720754",
"0.67134804",
"0.66795635",
"0.663156",
"0.6616375",
"0.65609187",
"0.65512997",
... | 0.72896904 | 2 |
Assert that files are installed in GAC_MSIL. | def assert_assembly_files_are_installed(assembly_source_files, microsoft_assembly_source_files):
for assembly_file in assembly_source_files:
assert is_file_in_subdirectory("%s.dll"% assembly_file, WINDOWS_ASSEMBLY_GAC_MSIL_PATH + assembly_file), \
"%s file not found in directory %s" % (assembly_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_mmelemental_imported():\n import sys\n\n assert \"mmelemental\" in sys.modules",
"def test_check():\n for f in cfg.required_files:\n assert os.path.isfile(f)",
"def test_network_lic_file_present(self):\n\n str_matlab_bin_path = self.host.check_output(\"readlink -f $(which matlab... | [
"0.5879728",
"0.5766973",
"0.5738156",
"0.5738147",
"0.569487",
"0.56844616",
"0.5623787",
"0.5610653",
"0.5580728",
"0.5538616",
"0.5493665",
"0.54421926",
"0.53928185",
"0.53919005",
"0.53829306",
"0.5343697",
"0.53233",
"0.53141606",
"0.5281856",
"0.5258395",
"0.5239167",
... | 0.66300887 | 0 |
Use the 'bin count' function in numpy to calculate the unique values in every column of a dataframe clocked at about 34x faster than pandas_value_counts (df.apply(pd.value_counts)) | def numpy_value_counts_bin_count(arr, weights=None):
if isinstance(arr, pd.DataFrame):
arr = arr.values
elif not isinstance(arr, np.ndarray):
raise Exception('The provided parameter for arr is not a dataframe or numpy array')
if len(arr.shape) == 1:
# its a ONE D array, lets make it ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom_numpy_count(df, weights=None):\n val = df.values\n un = np.unique(val.reshape(-1))\n if weights:\n pass\n r = {u: np.einsum('i, ij->j', weights, (val == u)) if weights is not None else np.einsum('ij->j', (val == u).astype(int)) for u in un}\n return pd.DataFrame(r).transpose()",
... | [
"0.66994005",
"0.6697422",
"0.6677125",
"0.6585333",
"0.6514379",
"0.64696807",
"0.6364872",
"0.62600523",
"0.6246666",
"0.6239951",
"0.6160835",
"0.61516106",
"0.61402774",
"0.60592717",
"0.60538626",
"0.6040024",
"0.6024756",
"0.59998935",
"0.59828293",
"0.5966383",
"0.5845... | 0.6685012 | 2 |
find a notebook, given its fully qualified name and an optional path This turns "foo.bar" into "foo/bar.ipynb" and tries turning "Foo_Bar" into "Foo Bar" if Foo_Bar does not exist. | def find_notebook(fullname, path=None):
name = fullname.rsplit(".", 1)[-1]
if not path:
path = [""]
for d in path:
nb_path = os.path.join(d, name + ".ipynb")
if os.path.isfile(nb_path):
return nb_path
# let import Notebook_Name find "Notebook Name.ipynb"
n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _resolve_nb_path(self, nb_path):\n if nb_path is None and self._notebook is not None:\n nb_path = self._notebook\n\n elif nb_path is None and glob(\"*.ipynb\"):\n notebooks = glob(\"*.ipynb\")\n assert len(notebooks) == 1, \"nb_path not specified and > 1 notebook ... | [
"0.7191861",
"0.6188864",
"0.6052213",
"0.58972746",
"0.5611016",
"0.55624646",
"0.54965943",
"0.54194707",
"0.54043365",
"0.5306842",
"0.52780384",
"0.5267952",
"0.5224945",
"0.51331246",
"0.51177615",
"0.50909376",
"0.50849307",
"0.50610876",
"0.504978",
"0.50256366",
"0.50... | 0.815862 | 0 |
Function returning preferred keyboard layouts for the given locale. | def get_locale_keyboards(locale):
parts = parse_langcode(locale)
if "language" not in parts:
raise InvalidLocaleSpec("'%s' is not a valid locale" % locale)
return langtable.list_keyboards(languageId=parts["language"],
territoryId=parts.get("territory", ""),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_layout(keymap_c: str):\n lines = get_keymap(keymap_c)\n lines = remove_excess_white_space(lines)\n layout_strs = get_layouts_strs(lines)\n return get_layout_keys(layout_strs)",
"def get_available_layouts(self):\n\n return self._layout_infos.iterkeys()",
"def get_keyboard(self, name... | [
"0.60228944",
"0.5637982",
"0.55843544",
"0.5231292",
"0.5200092",
"0.51659167",
"0.4992071",
"0.4957695",
"0.4894653",
"0.48928568",
"0.48863006",
"0.47528282",
"0.47521296",
"0.4738308",
"0.46856064",
"0.46499667",
"0.46469063",
"0.46232203",
"0.46160245",
"0.4595352",
"0.4... | 0.6866152 | 0 |
Function returning preferred timezones for the given locale. | def get_locale_timezones(locale):
parts = parse_langcode(locale)
if "language" not in parts:
raise InvalidLocaleSpec("'%s' is not a valid locale" % locale)
return langtable.list_timezones(languageId=parts["language"],
territoryId=parts.get("territory", ""),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_timezone_list():\n return pytz.country_timezones('US')",
"def Timezones():\n return sorted(list(PytzCache._zmap.values()))",
"def get_timezones() -> set[str]:\n return available_timezones() - UNAVAILABLE_TIMEZONES",
"def time_zones(self) -> localedata.LocaleDataDict:\n return self._da... | [
"0.72454035",
"0.6603862",
"0.65251845",
"0.6270924",
"0.5843416",
"0.58044297",
"0.57158774",
"0.5713681",
"0.5672513",
"0.5667701",
"0.5554293",
"0.55500525",
"0.5534162",
"0.5358738",
"0.5318892",
"0.53160745",
"0.5300022",
"0.52912754",
"0.52506125",
"0.5232472",
"0.52239... | 0.72785544 | 0 |
Function returning preferred scripts (writing systems) for the given locale. | def get_locale_scripts(locale):
parts = parse_langcode(locale)
if "language" not in parts:
raise InvalidLocaleSpec("'%s' is not a valid locale" % locale)
return langtable.list_scripts(languageId=parts["language"],
territoryId=parts.get("territory", ""),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_language_script(script):\n languages_scripts = {\n 'arab': ('ara', 'per'),\n 'cyrl': ('bel', 'chu', 'mac', 'rus', 'srp', 'ukr'),\n 'grek': ('grc', 'gre'),\n 'hani': ('chi', 'jpn'),\n 'hebr': ('heb', 'lad', 'yid'),\n 'jpan': ('jpn', ),\n 'kore': ('kor', ),... | [
"0.6649128",
"0.5827049",
"0.57364774",
"0.5626669",
"0.55779046",
"0.53860724",
"0.5307141",
"0.53032994",
"0.5285117",
"0.5285105",
"0.5262619",
"0.52498895",
"0.5218934",
"0.5216045",
"0.52101284",
"0.52076274",
"0.5197666",
"0.5140851",
"0.5096763",
"0.5073295",
"0.506578... | 0.67950034 | 0 |
Shifts in direction provided by ``Direction`` enum. | def shift(self, direction):
try:
if direction == Direction.UP:
return self.shift_up()
elif direction == Direction.DOWN:
return self.shift_down()
elif direction == Direction.RIGHT:
return self.shift_right()
elif direc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift(self, direction):\n direct, pos = tuple(direction)\n\n board = {'L': self.rows, 'R': self.rows, 'D': self.cols, 'U': self.cols}[direct]\n board[int(pos)].shift(direction=self.direct[direct])",
"def move(self, direction):\n pass",
"def shiftDir(self, direction, n):\n ... | [
"0.774642",
"0.692398",
"0.6842757",
"0.6679597",
"0.66020656",
"0.65728146",
"0.6467691",
"0.64622736",
"0.64192796",
"0.63760555",
"0.63722444",
"0.63722444",
"0.6337595",
"0.6268015",
"0.62238383",
"0.62154263",
"0.61994225",
"0.6179677",
"0.6145385",
"0.6136167",
"0.61124... | 0.7574775 | 1 |
Returns torch.utils.data.DataLoader for custom dataset. | def get_loader(data, json, batch_size, shuffle, num_workers):
dataset = FinNumDataset(data, json)
data_loader = torch.utils.data.DataLoader(dataset=dataset,
batch_size=batch_size,
shuffle=shuffle,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _custom_data_loader(self) -> DataLoader:\n dataloaders = DataLoader(self.dataset, batch_size=1)\n return dataloaders",
"def train_dataloader(self) -> DataLoader:\n return self._custom_data_loader()",
"def train_dataloader(self) -> torch.utils.data.DataLoader: \n return t... | [
"0.8505352",
"0.8326725",
"0.8071331",
"0.7819584",
"0.77159154",
"0.76418966",
"0.76353604",
"0.7556762",
"0.75347596",
"0.7510609",
"0.74715674",
"0.7392785",
"0.7373236",
"0.7307978",
"0.72721577",
"0.72398967",
"0.7218902",
"0.71938694",
"0.7193575",
"0.7192087",
"0.71672... | 0.7682115 | 5 |
At the end of the web request, this makes sure to close the database connection. If you don't, the database could run out of memory! | def teardown_request(exception):
try:
g.conn.close()
except Exception as e:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_request():\n db.close()",
"def close(self):\r\n self.conn.close()\r\n gc.collect()",
"def cleanup(_):\n self.db.close()",
"def close(self): \n self.connection.close()",
"def after_request(response):\n g.db.close()\n return response",
"def after_reque... | [
"0.7949118",
"0.77439415",
"0.75642663",
"0.7458906",
"0.74517614",
"0.74517614",
"0.74517614",
"0.74517614",
"0.74517614",
"0.74517614",
"0.74517614",
"0.74517614",
"0.74517614",
"0.74517614",
"0.74517614",
"0.73605776",
"0.7334557",
"0.7334557",
"0.7332123",
"0.73318386",
"... | 0.0 | -1 |
Return a manifest for this sample. | def get_manifest(self):
url = f'samples/{self.uuid}/manifest'
return self.knex.get(url) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_manifest(self):\r\n if os.path.exists(self.manifestfile):\r\n return Manifest(json.loads(file(self.manifestfile).read()))\r\n return Manifest({})",
"def get_manifest(self):\n return self.manifest",
"def manifest(self) -> pulumi.Output[Optional[Mapping[str, Any]]]:\n ... | [
"0.7615293",
"0.75619924",
"0.7228468",
"0.69406515",
"0.67661595",
"0.6721726",
"0.67200625",
"0.6517161",
"0.65150267",
"0.65150267",
"0.6418849",
"0.64011556",
"0.632388",
"0.6211856",
"0.61604166",
"0.61489534",
"0.60881954",
"0.6037556",
"0.59305507",
"0.58315796",
"0.58... | 0.814788 | 0 |
Returns the canvas size in pixels. | def getCanvasSize():
return canvas.winfo_width(), canvas.winfo_height() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSize(self):\n return self.screen.get_size()",
"def canvas_size(self):\r\n width = height = 0\r\n for image in self.images:\r\n x = image.x + image.absolute_width\r\n y = image.y + image.absolute_height\r\n if width < x:\r\n width = x\r\n... | [
"0.76065636",
"0.7291654",
"0.72000766",
"0.71854603",
"0.71594596",
"0.7155651",
"0.7155651",
"0.7099896",
"0.70850754",
"0.70767885",
"0.7060285",
"0.7034011",
"0.7029985",
"0.7029985",
"0.7029985",
"0.7029985",
"0.7029985",
"0.7029985",
"0.7029985",
"0.69946253",
"0.698392... | 0.8923893 | 0 |
Make a get request to the API URI passed in | def get(self, endpoint_uri, **kwargs):
self.logger.debug("Calling base get with kwargs: {}".format(kwargs))
if self.config['use_https']:
url = 'https://'
else:
url = 'http://'
url = url + self.config['hostname'] + endpoint_uri
headers = {
'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get(self, url, **queryparams):\n url = urljoin(self.base_url, url)\n if len(queryparams):\n url += '?' + urlencode(queryparams)\n try:\n r = self._make_request(**dict(\n method='GET',\n url=url,\n auth=self.auth,\n ... | [
"0.7712504",
"0.7646339",
"0.7477385",
"0.7469656",
"0.7444595",
"0.74294853",
"0.74167407",
"0.7398451",
"0.7386533",
"0.73546827",
"0.73546827",
"0.7321575",
"0.73018205",
"0.7279567",
"0.7253399",
"0.7243657",
"0.7241146",
"0.7240172",
"0.7224812",
"0.7203245",
"0.71988714... | 0.0 | -1 |
Set up an Arlo media player. | async def async_setup_platform(hass, _config, async_add_entities, _discovery_info=None):
arlo = hass.data.get(COMPONENT_DATA)
if not arlo:
return
players = []
for camera in arlo.cameras:
if camera.has_capability(MEDIA_PLAYER_KEY):
name = "{0}".format(camera.name)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OnPlay(self):\r\n # check if there is a file to play, otherwise open a\r\n # Tk.FileDialog to select a file\r\n print(\"1-1\")\r\n\r\n\r\n self.Media = self.Instance.media_new(self.youtube_url)\r\n self.player.set_media(self.Media)\r\n\r\n # set the window id where to ... | [
"0.6124019",
"0.6033745",
"0.57720435",
"0.5672428",
"0.5659317",
"0.56030464",
"0.55808127",
"0.5578291",
"0.5571156",
"0.5568045",
"0.5557043",
"0.55538464",
"0.55161655",
"0.5514134",
"0.55140793",
"0.5498919",
"0.54745305",
"0.54496276",
"0.5445883",
"0.54299134",
"0.5420... | 0.642649 | 0 |
Initialize an Arlo media player. | def __init__(self, name, device):
self._name = name
self._unique_id = device.entity_id
self._device = device
self._name = name
self._volume = None
self._muted = None
self._state = None
self._shuffle = None
self._position = 0
self._track_id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_video(self):\n\n assert self.container is None\n\n retry = 3\n while self.container is None and 0 < retry:\n retry -= 1\n try:\n self.container = av.open(self.tello.get_video_stream())\n except av.AVError as ave:\n print(a... | [
"0.63464123",
"0.6276088",
"0.6197421",
"0.60042477",
"0.5966629",
"0.5964369",
"0.59573257",
"0.5955853",
"0.5942402",
"0.59255",
"0.59211975",
"0.588976",
"0.58767784",
"0.58719885",
"0.5865433",
"0.5840495",
"0.5824255",
"0.581618",
"0.58082753",
"0.57726705",
"0.57574016"... | 0.659764 | 0 |
Boolean if volume is currently muted. | def is_volume_muted(self):
return self._muted | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_volume_muted(self):\n return self._isMuted",
"def is_volume_muted(self):\n return self._state.get(\"mute\", None)",
"def is_volume_muted(self) -> bool:\n return int(self._state.get(\"playback_mute\", 0)) == 1",
"def is_volume_muted(self):\n return self._mute",
"def muted(... | [
"0.8895486",
"0.885142",
"0.8814543",
"0.8788216",
"0.82374",
"0.8191111",
"0.7936918",
"0.7865406",
"0.77063185",
"0.76781267",
"0.6825295",
"0.67568815",
"0.65654856",
"0.65410423",
"0.64554507",
"0.6447409",
"0.64051235",
"0.63987285",
"0.63623446",
"0.636172",
"0.63581014... | 0.88772947 | 3 |
Return the device class of the media player. | def device_class(self):
return DEVICE_CLASS_SPEAKER | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\n return SENSOR_TYPES[self.sensor][3].get(\"device_class\")",
"def device_class(self):\r\n return self._device_class",
"def device_class(self):\n return self._device_class",
"def device_class(self):\n return self._device_class",
"def device_class(self):\n... | [
"0.7867225",
"0.78525764",
"0.78241426",
"0.78241426",
"0.78241426",
"0.78241426",
"0.78241426",
"0.7787847",
"0.76760966",
"0.76649296",
"0.7664825",
"0.7664825",
"0.7664825",
"0.7626044",
"0.7612436",
"0.7612436",
"0.759167",
"0.7555783",
"0.7555783",
"0.75409365",
"0.74500... | 0.6858363 | 42 |
Return the device state attributes. | def extra_state_attributes(self):
return {
ATTR_ATTRIBUTION: COMPONENT_ATTRIBUTION,
"brand": COMPONENT_BRAND,
"friendly_name": self._name,
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\r\n return self._attributes",
"def device_state_attributes(self):\n return self._attrs",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self... | [
"0.93173087",
"0.9245708",
"0.92207897",
"0.92147964",
"0.92147964",
"0.9210798",
"0.9210798",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
... | 0.0 | -1 |
Return the score of the game if R is the next to move. R looks for low scores | def scoreR(self) :
if self.leafR() :
return self.leafScore(), self
else :
games = self.R()
min_g = games[0]
min_score = min_g.scoreL()
for g in games[1:] :
score = g.scoreL()
if score[0] < min_score[0] :
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_move_score(game, player):\n if game.is_loser(player):\n return float(\"-inf\")\n\n if game.is_winner(player):\n return float(\"inf\")\n\n return float(len(game.get_legal_moves(player)))",
"def get_score(self) -> int:\n return self.rstate.score()",
"def check_score(self, m... | [
"0.71845496",
"0.70455074",
"0.7044914",
"0.70207614",
"0.7008354",
"0.69949126",
"0.69718325",
"0.6961224",
"0.69367784",
"0.6910868",
"0.6904701",
"0.6903983",
"0.6901333",
"0.68918365",
"0.68903387",
"0.68803644",
"0.6870168",
"0.6866687",
"0.68577814",
"0.6853682",
"0.684... | 0.72899574 | 0 |
Find the play for R that minimizes the score under the worst circumstances, where L always works to maximize the score. Use the builtin leafScore by default, or you can supply your own scoring function to implement your own heuristic. | def bestAtDepthR(self,depth=0,scoreFunc=None) :
scoreFunc = scoreFunc if scoreFunc != None else lambda g : g.leafScore()
min_score = ACG.inf
min_R = None
for g in self.R() :
if depth > 0 :
g = g.bestAtDepthL(depth=depth-1,scoreFunc=scoreFunc)
score... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scoreL(self) :\n if self.leafL() :\n #\n # Here L has no possible moves. Return\n # the leaf score at the current leaf.\n #\n return self.leafScore(), self\n else :\n games = self.L()\n max_g = games[0]\n max... | [
"0.79685",
"0.79079926",
"0.7275948",
"0.7230208",
"0.69229084",
"0.6835073",
"0.6829577",
"0.6817073",
"0.6812812",
"0.67829514",
"0.676703",
"0.6740729",
"0.66527176",
"0.66354036",
"0.6618874",
"0.65562576",
"0.65390605",
"0.64303815",
"0.6429865",
"0.64100903",
"0.6386772... | 0.6973812 | 4 |
returns a tuple of tuples ((x_min, x_max), (y_min, y_max)) | def get_bounds(self):
occupied_locations = self.board.keys()
min_x = min(p[0] for p in occupied_locations)
max_x = max(p[0] for p in occupied_locations)
min_y = min(p[1] for p in occupied_locations)
max_y = max(p[1] for p in occupied_locations)
return ((min_x, max_x), (min_y, max_y)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rect(coords : Tuple[int, int]) -> Tuple[int, int, int, int]:\n min_x = min([x for x, _ in coords])\n max_x = max([x for x, _ in coords])\n min_y = min([y for _, y in coords])\n max_y = max([y for _, y in coords])\n\n return (min_x, max_x, min_y, max_y)",
"def bounding_box(coords):\n min_x =... | [
"0.7711794",
"0.762906",
"0.74494684",
"0.7411606",
"0.73266345",
"0.72336084",
"0.71397084",
"0.7088061",
"0.7053181",
"0.69964576",
"0.6976291",
"0.6956182",
"0.6947641",
"0.6894108",
"0.6877525",
"0.68425024",
"0.6816192",
"0.6793504",
"0.6792052",
"0.6750146",
"0.6742665"... | 0.7093196 | 7 |
Lookup the 'all' and 'all_count' views from the metadata or construct defaults. | def get_views(view_args, model_type):
# XXX Why pop?
metadata = view_args.pop('metadata')
all_view = metadata.get('views', {}).get('all')
if not all_view:
all_view= '%s/all'%model_type
all_count_view = metadata.get('views', {}).get('all_count')
if not all_count_view:
all_count_vi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_views(context, data_dict):\n # noinspection PyUnresolvedReferences\n frc = _get_or_bust(data_dict, 'frc')\n\n lc = ckanapi.LocalCKAN(context=context)\n\n cube_results = lc.action.package_search(\n q=(\n 'type:cube AND frc:{frc}'\n ).format(\n frc=frc\... | [
"0.5791284",
"0.5705834",
"0.5399181",
"0.53550243",
"0.5300899",
"0.5277965",
"0.5185668",
"0.51750314",
"0.514737",
"0.5087578",
"0.50462204",
"0.49970847",
"0.4987755",
"0.49721837",
"0.49630272",
"0.48864326",
"0.48848885",
"0.48412365",
"0.48411632",
"0.4757586",
"0.4751... | 0.6535335 | 0 |
Test output file name generation. | def test_generate_filename():
params = dict(id='TEST', db='nucleotide', rettype='gbwithparts')
filename = core._generate_filename(params, 'foo')
assert filename == 'foo.gbk'
params['rettype'] = 'fasta'
filename = core._generate_filename(params, 'foo')
assert filename == 'foo.fa'
params['r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_option_format_file_name():\n\toutput_name = format_file_name(test_file, 'test_output.h5m')\n\tassert (output_name == 'test_output.h5m') == True",
"def test_default_format_file_name():\n\toutput_name = format_file_name(test_file)\n\tassert (output_name == test_file[:-4] + \"_no_grave.h5m\") == True",
"... | [
"0.78613776",
"0.7624457",
"0.75298786",
"0.74659026",
"0.73473567",
"0.71891046",
"0.7065759",
"0.7055048",
"0.70221645",
"0.7004536",
"0.6996478",
"0.69264466",
"0.6919238",
"0.68895936",
"0.6889224",
"0.6877088",
"0.6842153",
"0.6781788",
"0.67543066",
"0.67513514",
"0.674... | 0.6747972 | 20 |
Test that there is a value of the right child in the small tree. | def test_small_tree_has_root_value(small_tree):
assert small_tree.root.right.value == 11 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_small_tree_has_right_child_child(small_tree):\n assert small_tree.root.right.right.value == 27",
"def test_tree_with_one_node_has_correct_value(one_t):\n assert one_t.root.value == 10",
"def test_root_value(small_tree):\n assert small_tree.root.value == 3",
"def test_val_root_filled_tree(de... | [
"0.8579176",
"0.69598657",
"0.69145495",
"0.6835501",
"0.6834478",
"0.67782515",
"0.66623455",
"0.66231143",
"0.66171",
"0.65439016",
"0.65047574",
"0.6443494",
"0.6417503",
"0.63988703",
"0.63982207",
"0.63054246",
"0.62891006",
"0.6267407",
"0.6237089",
"0.6206176",
"0.6206... | 0.7728338 | 1 |
Test that there is a right child of the small tree. | def test_small_tree_has_right_child_child(small_tree):
assert small_tree.root.right.right.value == 27 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_right_sided_tree_with_two_nodes_root_has_child(empty_t):\n empty_t.insert(10)\n empty_t.insert(15)\n assert empty_t.root.right\n assert not empty_t.root.left",
"def is_right_child(self):\n if self.parent == None:\n return False\n\n return self.parent.right == self",
... | [
"0.7641996",
"0.74434966",
"0.717954",
"0.7019246",
"0.6967774",
"0.69477737",
"0.6912281",
"0.68781763",
"0.6797199",
"0.6698184",
"0.6681731",
"0.66418415",
"0.66311455",
"0.6553698",
"0.65529317",
"0.64987636",
"0.6466696",
"0.64635324",
"0.64635324",
"0.64625084",
"0.6458... | 0.8620883 | 0 |
Test typical get request. | def test_get_tag(self):
self.seed_static_data()
params = {'id': 1, 'event_id': 1}
response = self.app.get('/api/v1/tag', headers=self.user1_headers, data=params)
data = json.loads(response.data)
self.assertEqual(data['id'], 1)
self.assertEqual(data['event_id'], 1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get(self):\n return self.doRequest(self.url, method=\"GET\", body=self.input)",
"def test_get(self):\n url, port = self.server.address\n\n #couple of basic GETs\n r = self.client.get(\"http://{0}:{1}/\".format(url, port))\n self.assertEqual(200, r.status_code)\n ... | [
"0.86652255",
"0.84824306",
"0.825025",
"0.80968267",
"0.80968267",
"0.8014361",
"0.7964762",
"0.7964762",
"0.7894122",
"0.7894122",
"0.7794559",
"0.77163506",
"0.7657678",
"0.75957924",
"0.75957924",
"0.7545281",
"0.7529781",
"0.750443",
"0.7470404",
"0.7466768",
"0.74493724... | 0.0 | -1 |
Check a non event admin can't get a tag. | def test_get_event_admin(self):
self.seed_static_data()
params = {'id': 1, 'event_id': 1}
response = self.app.get('/api/v1/tag', headers=self.user3_headers, data=params)
self.assertEqual(response.status_code, 403) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_event_admin_correct_event(self):\n self.seed_static_data()\n params = {'id': 1, 'event_id': 1}\n response = self.app.get('/api/v1/tag', headers=self.user2_headers, data=params)\n self.assertEqual(response.status_code, 403)",
"def tag_check():\n\n async def check(ctx):\... | [
"0.6792293",
"0.6601816",
"0.63957447",
"0.61967623",
"0.60017455",
"0.59642684",
"0.5937236",
"0.59371203",
"0.58762646",
"0.584405",
"0.5807968",
"0.5800025",
"0.574361",
"0.5712198",
"0.5655928",
"0.56186956",
"0.560578",
"0.5597567",
"0.5597526",
"0.55895686",
"0.5562843"... | 0.6555421 | 2 |
retruns list of numbers which is relatively prime to N | def GenerateCoprimes(N):
if N <= 0:
print("N <= 0 @GenerateCoprimes in ModulesFactorization")
sys.exit()
Coprimes = list() # Nまでの数と互いに素な数のリスト
for num in range(1,N+1):
if math.gcd(N,num) == 1:
Coprimes.append(num)
return Coprimes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNPrime(num):\n prime_numbers = []\n for i in range(num):\n if isPrime(i + 1):\n prime_numbers.append(i)\n return prime_numbers",
"def primes(n):\n return [i for i in xrange(1, n + 1) if mr_prime(i)]",
"def primes_less(n):\n test_nums = list(range(3, int(floor(sqrt(n)... | [
"0.7746709",
"0.7742901",
"0.76955163",
"0.7626955",
"0.7600571",
"0.7584221",
"0.75523394",
"0.754826",
"0.7538675",
"0.7526856",
"0.7490697",
"0.7485215",
"0.74690527",
"0.7384667",
"0.7366019",
"0.73563635",
"0.7326023",
"0.7314516",
"0.7314516",
"0.7311255",
"0.72974086",... | 0.0 | -1 |
Get a list of RPMs to blacklist | def getRpmBlacklist():
global index
enabledRpms = set()
for stream in enabledStreams.values():
enabledRpms = enabledRpms.union(stream.get_rpm_artifacts())
allRpms = set()
for name in index.get_module_names():
module = index.get_module(name)
for stream in module.get_all_strea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blacklist(self) -> List[str]:\n return self.raw_config.get(\"blacklist\", [])",
"def blacklist_remove():\n db = unitdata.kv()\n blacklist = db.get(BLACKLIST_KEY, [])\n for device in get_devices():\n try:\n blacklist.remove(device)\n except ValueError:\n rai... | [
"0.65307343",
"0.63255924",
"0.62569094",
"0.616089",
"0.60532945",
"0.5996806",
"0.5904636",
"0.58727056",
"0.58684236",
"0.58534366",
"0.58209705",
"0.57830745",
"0.5761726",
"0.5739948",
"0.57301134",
"0.5706825",
"0.569636",
"0.5680605",
"0.56762797",
"0.5670396",
"0.5670... | 0.81101996 | 0 |
Insert data into an empty linked list. | def test_insert_head_empty_list_1(test_linkedlist):
test_linkedlist.insert_head('A')
assert test_linkedlist.head.data == 'A' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self, data):\n if self.head == None:\n self.head = Node(data)\n else:\n curr = self.head\n while curr.link != None:\n curr = curr.link\n curr.link = Node(data)",
"def insert_append(self, data):\n node = Node(data)\n ... | [
"0.81877583",
"0.8069094",
"0.7965457",
"0.79628056",
"0.781661",
"0.78147596",
"0.7563759",
"0.7527882",
"0.7454431",
"0.74378484",
"0.73897225",
"0.73817277",
"0.73462945",
"0.7345649",
"0.7281895",
"0.727968",
"0.72706497",
"0.72510695",
"0.7246597",
"0.71781087",
"0.71492... | 0.70314413 | 30 |
Insert head element to a single element linked list and check whether header node has expected data. | def test_insert_head_one_element_list_1(test_linkedlist):
test_linkedlist.insert_head('A')
test_linkedlist.insert_head('B')
assert test_linkedlist.head.data == 'B' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_insert_head_empty_list_1(test_linkedlist):\n test_linkedlist.insert_head('A')\n assert test_linkedlist.head.data == 'A'",
"def test_insert_head_empty_list_2(test_linkedlist):\n test_linkedlist.insert_head('A')\n assert test_linkedlist.head.next is None",
"def test_insert_head_one_element_l... | [
"0.7000382",
"0.6920265",
"0.68926394",
"0.6658777",
"0.664612",
"0.6491131",
"0.6382923",
"0.63249904",
"0.6275315",
"0.62428296",
"0.61293507",
"0.6121938",
"0.6120845",
"0.6103657",
"0.60847497",
"0.5946656",
"0.5900113",
"0.5896753",
"0.5894562",
"0.5886943",
"0.5839833",... | 0.7153454 | 0 |
Insert head element to a single element linked list and check whether header node.next points to second element | def test_insert_head_one_element_list_2(test_linkedlist):
test_linkedlist.insert_head('A')
test_linkedlist.insert_head('B')
assert test_linkedlist.head.next.data == 'A' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_insert_head_empty_list_2(test_linkedlist):\n test_linkedlist.insert_head('A')\n assert test_linkedlist.head.next is None",
"def test_insert_head_one_element_list_1(test_linkedlist):\n test_linkedlist.insert_head('A')\n test_linkedlist.insert_head('B')\n assert test_linkedlist.head.data ==... | [
"0.68290764",
"0.6784454",
"0.67691284",
"0.6407408",
"0.6398689",
"0.634001",
"0.6122741",
"0.6031908",
"0.6015013",
"0.5961826",
"0.5920558",
"0.5915399",
"0.59067553",
"0.5889279",
"0.5888695",
"0.58771574",
"0.5876606",
"0.5869111",
"0.58359754",
"0.5826269",
"0.5800353",... | 0.6998045 | 0 |
Insert head element to a two element linked list and check whether header node has expected data. | def test_insert_head_for_two_element_list_1(test_linkedlist):
test_linkedlist.insert_head('A')
test_linkedlist.insert_head('B')
test_linkedlist.insert_head('C')
assert test_linkedlist.head.data == 'C' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_insert_head_one_element_list_2(test_linkedlist):\n test_linkedlist.insert_head('A')\n test_linkedlist.insert_head('B')\n assert test_linkedlist.head.next.data == 'A'",
"def test_insert_head_empty_list_2(test_linkedlist):\n test_linkedlist.insert_head('A')\n assert test_linkedlist.head.nex... | [
"0.71093637",
"0.6993354",
"0.69920653",
"0.6874157",
"0.6395523",
"0.6193493",
"0.6157132",
"0.610049",
"0.59965223",
"0.5888415",
"0.58738816",
"0.5845826",
"0.58392084",
"0.5838037",
"0.57361645",
"0.5719376",
"0.5718986",
"0.56913036",
"0.5687391",
"0.56646043",
"0.564347... | 0.71451944 | 0 |
Insert last element to an empty element linked list and check whether header node has expected data | def test_insert_end_for_empty_list(test_linkedlist):
test_linkedlist.insert_end('A')
assert test_linkedlist.head.data == 'A' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insertAtEnd(self, e):\n # self.insertBeforeHeader(e) # this is not true since the head will be changed\n \n if self.is_empty(): # if this is the first insert method call,\n print(\"As you do not have any start node yet, the given element will be a start node.\")\n self._first_insert(e)\... | [
"0.6620652",
"0.65475994",
"0.6387041",
"0.63748395",
"0.63285327",
"0.63142574",
"0.6290541",
"0.625654",
"0.6144856",
"0.6062653",
"0.6061434",
"0.6054086",
"0.60341364",
"0.5983253",
"0.5946131",
"0.59438145",
"0.5936144",
"0.592606",
"0.5887565",
"0.58757454",
"0.587368",... | 0.7035622 | 0 |
Insert last element to a single element linked list and check whether the last node has expected data | def test_insert_end_for_one_element_list(test_linkedlist):
test_linkedlist.insert_end('A')
test_linkedlist.insert_end('B')
assert test_linkedlist.head.data == 'A' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_insert_end_for_empty_list(test_linkedlist):\n test_linkedlist.insert_end('A')\n assert test_linkedlist.head.data == 'A'",
"def test_insert_end(self):\n sll = SinglyLinkedList()\n a = Node('a')\n b = Node('b')\n c = Node('c')\n sll.insert_beg(a)\n sll.inser... | [
"0.72178334",
"0.69149065",
"0.69074094",
"0.6875248",
"0.6817494",
"0.6682206",
"0.65892625",
"0.6489145",
"0.6454365",
"0.64060044",
"0.6381768",
"0.6363875",
"0.6361612",
"0.6344563",
"0.6337286",
"0.63229567",
"0.63185537",
"0.6296967",
"0.62793654",
"0.62726855",
"0.6232... | 0.7321098 | 0 |
Test to set the name | def test_set_attr(self):
self.my_city.name = "Denver"
self.assertEqual(self.my_city.name, "Denver") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, name):\n\t\tself.name_ = name",
"def set_name(self, newname=\"\"):\n self.name = newname",
"def set_name(self,name):\r\n self._name = __name",
"def test_set_name_method(self) -> None:\n\n given = self.test_name\n expected = given\n\n self.helper.set_name(... | [
"0.802927",
"0.79900384",
"0.7861012",
"0.78303534",
"0.78269035",
"0.77964073",
"0.77105695",
"0.7707535",
"0.7706618",
"0.7706618",
"0.7706618",
"0.7706618",
"0.7667307",
"0.76595765",
"0.76595765",
"0.76169777",
"0.76024616",
"0.76024616",
"0.76024616",
"0.76024616",
"0.76... | 0.0 | -1 |
ORG / Organization Registry | def org():
settings = current.deployment_settings
ADMIN = current.session.s3.system_roles.ADMIN
SECTORS = "Clusters" if settings.get_ui_label_cluster() \
else "Sectors"
stats = lambda i: settings.has_module("stats")
return M(c="org")(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def atlas_organizations():\n pass",
"def organizations(self):\n self.elements('organizations')",
"def test_get_organization(self):\n pass",
"def test_retrieve_l_organization(self):\n pass",
"def org():\n\n sysroles = current.auth.get_system_roles()\n\n ADMIN = sysroles... | [
"0.67622626",
"0.64280254",
"0.6281099",
"0.6248272",
"0.61873627",
"0.6182633",
"0.6163306",
"0.60936064",
"0.60586184",
"0.60250324",
"0.5994845",
"0.5978774",
"0.5963733",
"0.5891216",
"0.5847455",
"0.5847007",
"0.58193946",
"0.57460207",
"0.5737204",
"0.5737204",
"0.57372... | 0.6491232 | 1 |
Set the buffer's index. | def ring_idx(self, idx: int):
if not (isinstance(idx, int) or not 0 <= idx < len(self._buffer)):
raise pyrado.ValueErr(given=idx, ge_constraint="0 (int)", l_constraint=len(self._buffer))
self._ring_idx = idx | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __setitem__(self, index, value):\n self.buffer[index] = value",
"def set_index(self, index):\n self.index = index",
"def set_at_index(self, index: int, value: object) -> None:\n self.data[index] = value",
"def index(self, index):\n\n self._index = index",
"def _set_index(self):\... | [
"0.7110891",
"0.71106434",
"0.6945637",
"0.6888288",
"0.67648816",
"0.6623153",
"0.6582871",
"0.656028",
"0.648553",
"0.64569163",
"0.6440463",
"0.64095294",
"0.6348192",
"0.6330599",
"0.6319663",
"0.6257496",
"0.6217406",
"0.6190503",
"0.61772704",
"0.6151941",
"0.6133701",
... | 0.6359728 | 12 |
Format an exception as a string. Limits the length of the traceback to 3. | def exception_to_string(excp: Exception) -> str:
stack = traceback.extract_stack()[:-3] + traceback.extract_tb(
excp.__traceback__
) # add limit=??
pretty = traceback.format_list(stack)
return "".join(pretty) + f"\n {excp.__class__} {excp}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatException(self, exc_info):\n traces = traceback.format_exception(*exc_info)\n return \"\\n\".join(traces)",
"def FormatException(message):\n message = ('Exception Type: %s\\n'\n 'Details: %s\\n'\n 'Message: %s\\n') % (sys.exc_type, traceback.format_exc(), message)... | [
"0.7624566",
"0.7558915",
"0.75474006",
"0.7497152",
"0.7445153",
"0.7413449",
"0.7396047",
"0.7388955",
"0.7309555",
"0.727759",
"0.7244538",
"0.7222153",
"0.7207482",
"0.7099169",
"0.70663077",
"0.7035034",
"0.6965173",
"0.6932354",
"0.68746436",
"0.6867291",
"0.68640524",
... | 0.7062025 | 15 |
The Constructor Method for the Accelerometer Class | def __init__(self):
Phidget.__init__(self)
self.__IRCodeDelegate = None;
self.__IRLearnDelegate = None;
self.__IRRawDataDelegate = None;
self.__onIRCodeHandler = None;
self.__onIRLearnHandler = None;
self.__onIRRawDataHandler = None;
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n\n\n self.dtype = np.dtype([\n ('fault_flags', np.uint32),\n ('raw_x', np.int16),\n ('raw_y', np.int16),\n ('raw_z', np.int16),\n ('accel_x', np.float32),\n ('accel_y', np.float32),\n ... | [
"0.67325115",
"0.6627993",
"0.66174006",
"0.6615042",
"0.6574191",
"0.65632313",
"0.65572006",
"0.65463364",
"0.6523182",
"0.6486957",
"0.64627373",
"0.64199865",
"0.6381732",
"0.6368715",
"0.6354001",
"0.63309085",
"0.62914526",
"0.6278993",
"0.6259358",
"0.6253952",
"0.6252... | 0.0 | -1 |
Gets the last code the was learned. | def getLastLearnedCode(self):
codePtr = (c_ubyte * IR_MAX_CODE_DATA_LENGTH)()
dataLength = c_int(IR_MAX_CODE_DATA_LENGTH)
codeInfo = CPhidgetIR_CodeInfo()
try:
result = PhidgetLibrary.getDll().CPhidgetIR_getLastLearnedCode(self.handle, codePtr, byref(dataLength... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLastCode(self):\r\n codePtr = (c_ubyte * IR_MAX_CODE_DATA_LENGTH)(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)\r\n dataLength = c_int(IR_MAX_CODE_DATA_LENGTH)\r\n bitCount = c_int()\r\n \r\n try:\r\n result = PhidgetLibrary.getDll().CPhidgetIR_getLastCode(self.handle, codeP... | [
"0.70882255",
"0.6817966",
"0.65252477",
"0.6414747",
"0.6414747",
"0.6414747",
"0.6414747",
"0.6366159",
"0.6299188",
"0.6299188",
"0.6299188",
"0.6299188",
"0.6193091",
"0.61307126",
"0.6107682",
"0.60453266",
"0.6043935",
"0.59798914",
"0.5971125",
"0.5961705",
"0.59294826... | 0.8201471 | 0 |
This function checks whether a number if odd or even | def check_odd_even(number, odd=True):
if odd:
if number % 2 == 1:
print(f"Correct, number {number} is odd")
else:
print(f"wrong, number {number} is not odd")
else:
if number % 2 == 1:
print(f"Correct, number {number} is even")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_odd(number):\r\n return number % 2 != 0",
"def is_odd(number):\n return (number%2)==1",
"def is_odd(number: int) -> bool:\n return number % 2 != 0",
"def __odd_or_even(number):\n if(number % 2) == 0:\n return 0\n else:\n return 1",
"def is_odd(x):\n return x % 2 != 0"... | [
"0.89699316",
"0.8898966",
"0.88266414",
"0.8702352",
"0.8698093",
"0.8655987",
"0.86295116",
"0.8573111",
"0.8547807",
"0.8542004",
"0.85138875",
"0.84909666",
"0.84850013",
"0.84608066",
"0.84457254",
"0.84421366",
"0.8373561",
"0.8367002",
"0.83280456",
"0.8320662",
"0.827... | 0.8148552 | 23 |
Yield successive nsized chunks from lst. | def chunks(lst, n):
for i in range(0, len(lst), n):
yield lst[i:i + n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(self, lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"def chunks(lst: list, n: int):\n for i in range(0, len(lst), n):\n yield lst[i : i + n]",
"def chunks(lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"de... | [
"0.83071756",
"0.81939614",
"0.81910837",
"0.81910837",
"0.8190213",
"0.81267184",
"0.81218547",
"0.81218547",
"0.80773693",
"0.80526286",
"0.80526286",
"0.80526286",
"0.80526286",
"0.80526286",
"0.80042696",
"0.7871678",
"0.7845623",
"0.7828392",
"0.7827006",
"0.78138447",
"... | 0.80533457 | 24 |
Creates and saves a superuser with the given parameters. | def create_superuser(self, email, password=None):
user = self.create_user(email, password=password)
user.is_admin = True
user.save(using=self._db)
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createsuperuser():\n\n email = prompt('User E-Mail')\n email_confirm = prompt('Confirm E-Mail')\n\n if not email == email_confirm:\n sys.exit('\\nCould not create user: E-Mail did not match')\n\n if not EMAIL_REGEX.match(email):\n sys.exit('\\nCould not create user: Invalid E-Mail add... | [
"0.76421744",
"0.75859475",
"0.7515691",
"0.7462415",
"0.7452859",
"0.742045",
"0.73830366",
"0.7375057",
"0.73690206",
"0.73686683",
"0.73630387",
"0.7348849",
"0.7334004",
"0.730272",
"0.73019826",
"0.72855103",
"0.7282453",
"0.7273817",
"0.72719747",
"0.7266118",
"0.726204... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
return "<Twilio.Oauth.V1.TokenInstance>" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.76010835",
"0.7571921",
"0.7230172",
"0.7216933",
"0.7194604",
"0.71428955",
"0.714158",
"0.71369046",
"0.7134454",
"0.7134454",
"0.7131177",
"0.7104331",
"0.70761895",
"0.70686626",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70685405",
"0.70311874",
"0.701... | 0.0 | -1 |
Provide a friendly representation | def __repr__(self) -> str:
return "<Twilio.Oauth.V1.TokenList>" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_representation(self) -> str:\n raise NotImplementedError()",
"def __str__(self):\n return self.make_flat()",
"def __str__(self):\n return self.format()",
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n \n ... | [
"0.7601743",
"0.75718004",
"0.72295034",
"0.7216429",
"0.71937954",
"0.71428096",
"0.7140594",
"0.7136909",
"0.7135249",
"0.7135249",
"0.7130013",
"0.7103256",
"0.7075",
"0.70674646",
"0.70674646",
"0.70674646",
"0.70674646",
"0.70674646",
"0.70671123",
"0.70313466",
"0.70191... | 0.0 | -1 |
Write a warning message to stderr. | def warning(self, message, *, preprocessor=None):
console.warning(message) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warn(msg):\n sys.stderr.write(str(msg))\n sys.stderr.write(\"\\n\")",
"def warn(msg):\n print(msg, file=sys.stderr)",
"def warn(msg):\n print(msg, file=sys.stderr)",
"def warn(msg):\n print(msg, file=sys.stderr)",
"def warn(msg):\n print(msg, file=sys.stderr)",
"def warn(msg):\n ... | [
"0.7870333",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",
"0.78408474",... | 0.6436404 | 67 |
String representation of Node object or inheriting class. | def __str__(self):
return str(self.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n s = \"--\\n\"\n for node in self:\n s += node.__str__() + \"\\n\"\n return s + \"--\"",
"def __repr__(self):\n\n return f\"<Node {self.data}>\"",
"def __str__(self) -> str:\n return 'Node({})'.format(self.yaml_node)",
"def __repr__(self):\n ... | [
"0.77331734",
"0.7652458",
"0.7638021",
"0.759565",
"0.75588655",
"0.75499874",
"0.7525615",
"0.7520207",
"0.75025684",
"0.7499907",
"0.7499907",
"0.748745",
"0.7410888",
"0.73790246",
"0.7330727",
"0.73020655",
"0.7258886",
"0.7190272",
"0.71691245",
"0.7133538",
"0.7128342"... | 0.0 | -1 |
Representation of Node object or inheriting class when inspected. | def __repr__(self):
return str(self.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return 'Node({!r})'.format(self.data)",
"def __repr__(self):\n\n return f\"<Node {self.data}>\"",
"def node_type(self):\n return self._node_type",
"def get_node_type(self):\n return self.node_type",
"def node(self):\n return Node(self)",
"def tree(... | [
"0.7123788",
"0.70227534",
"0.68973327",
"0.6856256",
"0.68377054",
"0.67214316",
"0.6642786",
"0.6611929",
"0.65653694",
"0.6522132",
"0.65069085",
"0.65069085",
"0.6506687",
"0.64657015",
"0.6461232",
"0.6448232",
"0.63595486",
"0.63595444",
"0.6359388",
"0.6340873",
"0.630... | 0.0 | -1 |
Returns hexencoded SHA512 hash for the given data. | def _hash_content(data):
return hashlib.sha512(str(data).encode('utf-8')).hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sha512(data):\r\n return hashlib.sha512(data).hexdigest()",
"def _hash(data):\n return hashlib.sha512(data).hexdigest()",
"def hash_sha512(*indata):\n hasher = hashlib.sha512()\n for data in indata:\n if isinstance(data, str):\n hasher.update(data.encode(\"utf-8\"))\n ... | [
"0.8828686",
"0.86973995",
"0.7896582",
"0.76218396",
"0.7582233",
"0.74668616",
"0.7320151",
"0.71159804",
"0.7114915",
"0.6844553",
"0.6821521",
"0.6798221",
"0.67327076",
"0.66272634",
"0.6615002",
"0.65569",
"0.65120775",
"0.6504787",
"0.6442338",
"0.6394066",
"0.6332879"... | 0.7969169 | 2 |
Evaluate the population with respect to input data X and expected output. | def _evaluate(self, X, Y):
# evaluate all networks
#
# evaluations = torch.zeros(self.population_size, device=self.device)
evaluations = torch.zeros(self.population_size, device=self.device)
for i in range(self.population_size):
selected_pheno = self.population[i].cp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self, X):\n\n raise NotImplementedError(\"not implemented!\")",
"def evaluate(self, X):\n\n\t\tpass",
"def evaluate(self, dataset):\n return self.model.evaluate(dataset.X_val, dataset.y_val)",
"def evaluate(population, context=None):\n for individual in population:\n indi... | [
"0.7122433",
"0.68909365",
"0.65685827",
"0.6454497",
"0.6450034",
"0.64358103",
"0.63450545",
"0.63008964",
"0.62551874",
"0.6255135",
"0.6235048",
"0.62307996",
"0.61885816",
"0.61829305",
"0.61514705",
"0.6123133",
"0.61000067",
"0.6092697",
"0.6065284",
"0.6055261",
"0.60... | 0.71402115 | 0 |
Given the list of parents and an index on where to place the new individual, creates a new individual | def _produce_child(self, parents, method="uniform_swap"):
crossover_binary_op = None
if method == "uniform_swap":
crossover_binary_op = self._uniform_swap
elif method == "single_swap":
crossover_binary_op = self._single_swap
elif method == "arithmetic":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plates_to_parent(self, index, plates):\n raise NotImplementedError()",
"def set_parent(self, index):\n self.add_parent(self[index])",
"def plates_from_parent(self, index, plates):\n raise NotImplementedError()",
"def create_individual(self):\n pass",
"def plates_to_parent(se... | [
"0.6309031",
"0.61675406",
"0.59882504",
"0.56271535",
"0.55889696",
"0.5584923",
"0.5576614",
"0.5532694",
"0.55218256",
"0.54842454",
"0.5444961",
"0.5444678",
"0.5422788",
"0.541323",
"0.5402656",
"0.5402029",
"0.5355109",
"0.53489935",
"0.5334691",
"0.53193784",
"0.531016... | 0.0 | -1 |
Returns a dict of reasonable random parameters that can be used to do parameter search. | def random_parameters():
res = dict()
res["population_size"] = random.randrange(2, 21)
res["mutation_prob"] = random.choice([0.02, 0.05, 0.10, 0.20, 0.30, 0.40, 0.50])
res["crossover"] = random.choice([True, False])
res["selection"] = random.choice([True, False])
res["sig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_params(self, randomize=True):\n pass",
"def set_rand_params(self) -> Dict:\n new_params: Dict = self.gen_params()\n self.set_params(new_params)\n return new_params",
"def random():\n pars = dict(\n scale=10**np.random.uniform(1, 3),\n gamma=np.random.un... | [
"0.70701885",
"0.706165",
"0.7013774",
"0.6762008",
"0.6735659",
"0.6637217",
"0.6519411",
"0.6440548",
"0.63888425",
"0.6324186",
"0.63205343",
"0.63086057",
"0.62929904",
"0.6286846",
"0.6242564",
"0.6231981",
"0.6220546",
"0.6217865",
"0.6199372",
"0.61903065",
"0.6187879"... | 0.8022944 | 0 |
using scipy.stats.multivariate_normal and scipy.stats.norm.logpdf | def var_extra(X, m, C):
return multivariate_normal(m, C).logpdf(X) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def likelihood_bivariate_normal(X, mu, cov):\n \n dist = multivariate_normal(mu, cov)\n P = dist.pdf(X)\n return P",
"def _log_multivariate_normal_density_full(X, means, covars, min_covar=1):\n # n_samples = 1 #\n n_samples, n_dim = X.shape\n nmix = len(means)\n log_prob = np.empty((n_sam... | [
"0.7157555",
"0.68779457",
"0.67325884",
"0.66602916",
"0.66465247",
"0.6633968",
"0.65824074",
"0.65715814",
"0.65288293",
"0.65078455",
"0.64698696",
"0.645318",
"0.6447839",
"0.6406545",
"0.6385113",
"0.6371188",
"0.6333469",
"0.6324321",
"0.6319994",
"0.63143253",
"0.6278... | 0.64493066 | 12 |
Return min and max values. | def high_and_low(numbers: str) -> str:
return f'{min(map(int, numbers.split()))} {max(map(int, numbers.split()))}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_max(xs):\n return min(xs), max(xs)",
"def get_max_and_min(self):\n max_x = float('-inf')\n min_x = float('inf')\n max_y = float('-inf')\n min_y = float('inf')\n max_z = float('-inf')\n min_z = float('inf')\n ans = max_x, max_y, max_z, min_x, min_y, min_... | [
"0.8033154",
"0.78591096",
"0.7818719",
"0.77079254",
"0.76304585",
"0.75011563",
"0.7481534",
"0.74667835",
"0.74421066",
"0.7440306",
"0.740863",
"0.7367874",
"0.7318964",
"0.7301685",
"0.72624475",
"0.7226793",
"0.7180699",
"0.7172398",
"0.7167464",
"0.71605885",
"0.714825... | 0.0 | -1 |
Return min and max values. | def high_and_low_classic(numbers: str) -> str:
min_num = max_num = int(numbers[0])
for number in map(int, numbers.split()): # type: int
if number < min_num:
min_num = number
if number > max_num:
max_num = number
return f'{min_num} {max_num}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_max(xs):\n return min(xs), max(xs)",
"def get_max_and_min(self):\n max_x = float('-inf')\n min_x = float('inf')\n max_y = float('-inf')\n min_y = float('inf')\n max_z = float('-inf')\n min_z = float('inf')\n ans = max_x, max_y, max_z, min_x, min_y, min_... | [
"0.8031845",
"0.7859441",
"0.7818016",
"0.77063936",
"0.76289624",
"0.75001776",
"0.74813735",
"0.74675804",
"0.7440563",
"0.7438437",
"0.74092746",
"0.73663896",
"0.7317468",
"0.7301293",
"0.7261678",
"0.72272754",
"0.7179676",
"0.7172163",
"0.7167929",
"0.71588",
"0.7147334... | 0.0 | -1 |
max subarray containing ith element | def helper(nums, i):
if i == 0:
return nums[0]
if helper(nums, i-1) > 0:
return helper(nums, i-1) + nums[i]
else:
return nums[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maxSubArray(self, nums) -> int:\n maxsub = -10000000\n i = 0\n solutions = self.create_matrix(nums)\n if len(nums)==1:\n return nums[0]\n while i <= len(nums) -1:\n j=i\n while j <= len(nums)-1:\n sum_ij = solutions[i][j]\n if sum_ij > maxsub:\n maxsub = sum... | [
"0.74525464",
"0.742486",
"0.72699606",
"0.7112033",
"0.7101944",
"0.70947534",
"0.6958306",
"0.6906481",
"0.6848971",
"0.68423826",
"0.68038774",
"0.6778717",
"0.6761434",
"0.6750676",
"0.6740532",
"0.6711446",
"0.6711446",
"0.6711446",
"0.6679008",
"0.6660688",
"0.6648468",... | 0.0 | -1 |
Compute softmax values for each sets of scores in x. | def softmax(x):
return np.exp(x) / np.sum(np.exp(x), axis=1, keepdims=True) | {
"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.7796294",
"0.7760558",
"0.7759004",
"0.77567077",
"0.76577055",
"0.76577055",
"0.76577055",
"0.76577055",
"0.7585655",
"0.743143",
"0.7407772",
"0.73941606",
"0.7358175",
"0.73174125",
"0.72689486",
"0.72623265",
"0.72614294",
"0.7256868",
"0.723019",
"0.7214918",
"0.72017... | 0.0 | -1 |
Convert the given URL into a legal URL by escaping unsafe characters according to RFC3986. Also, ASCII tabs and newlines are removed | def safe_url_string(url, encoding='utf8', path_encoding='utf8'):
# Python3's urlsplit() chokes on bytes input with non-ASCII chars,
# so let's decode (to Unicode) using page encoding:
# - it is assumed that a raw bytes input comes from a document
# encoded with the supplied encoding (or UTF8 by de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_url(url):\r\n s = url\r\n url = url.encode('utf8')\r\n url = ''.join([urllib.quote(c) if ord(c) >= 127 else c for c in url])\r\n return url",
"def make_url_safe(self, url):\n return url.replace(' ', '%20')\\\n .replace('(', '%28')\\\n .replace(')', '... | [
"0.76104623",
"0.76068425",
"0.732039",
"0.7172684",
"0.6942655",
"0.69398767",
"0.6825457",
"0.68161464",
"0.67821115",
"0.6776483",
"0.6742143",
"0.66165555",
"0.66121686",
"0.6591953",
"0.655551",
"0.6525111",
"0.65196186",
"0.64948666",
"0.64945096",
"0.647686",
"0.647326... | 0.66540754 | 11 |
Clean URL arguments leaving only those passed in the parameterlist keeping order >>> import w3lib.url >>> w3lib.url.url_query_cleaner("product.html?id=200&foo=bar&name=wired", ('id',)) 'product.html?id=200' >>> w3lib.url.url_query_cleaner("product.html?id=200&foo=bar&name=wired", ['id', 'name']) 'product.html?id=200&na... | def url_query_cleaner(url, parameterlist=(), sep='&', kvsep='=', remove=False, unique=True, keep_fragments=False):
if isinstance(parameterlist, (six.text_type, bytes)):
parameterlist = [parameterlist]
url, fragment = urldefrag(url)
base, _, query = url.partition('?')
seen = set()
querylist ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_remove_with_multiple_removes(self):\n rendered_result = self._render_tag(\n tag='{% querystring \"remove\" \"foo\" \"bar\" \"baz=1\" %}',\n query_str='foo=foo&bar=bar&foo=&baz=1&qux=qux')\n\n self.assertTrue(rendered_result.startswith('?'))\n self.assertEqual(Que... | [
"0.60887784",
"0.59742236",
"0.586768",
"0.5849657",
"0.5837156",
"0.57429856",
"0.5674179",
"0.56159896",
"0.55954355",
"0.5503327",
"0.54211736",
"0.5406335",
"0.5371822",
"0.53556895",
"0.5342783",
"0.5247226",
"0.52447885",
"0.5231707",
"0.5206317",
"0.5175111",
"0.514468... | 0.80487144 | 0 |
Checks if a and b are in given distance d | def in_distance(a, b, d):
return distance(a, b) <= d | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(self, a, b):\n if not (a in self and b in self):\n raise RuntimeError(\n \"Can only compute distance for values within \"\n \"the space, not {} and {}.\".format(a, b)\n )\n return 1 if a != b else 0",
"def dwithin(a, b, distance, **kw... | [
"0.7185901",
"0.7166674",
"0.6720538",
"0.6656798",
"0.6656798",
"0.6601606",
"0.6598739",
"0.65757394",
"0.65753025",
"0.65734214",
"0.65687853",
"0.6567245",
"0.6496106",
"0.6494706",
"0.6463152",
"0.6428333",
"0.64235395",
"0.64084",
"0.63912725",
"0.63847333",
"0.63520175... | 0.88950545 | 0 |
Build a grid of side 'box' centered in coordinates (x0,y0). | def _grid_around_star(self, x0, y0, data):
lenx, leny = data.shape
xmin, xmax = max(x0 - self._box / 2, 0), min(x0 + self._box / 2 + 1, lenx - 1)
ymin, ymax = max(y0 - self._box / 2, 0), min(y0 + self._box / 2 + 1, leny - 1)
return np.mgrid[int(xmin) : int(xmax), int(ymin) : int(ymax)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(x: Bounds, y: Bounds, grid_spacing):\n # Calculate grid bounds\n x0, y0 = Grid.bounding_box(x, y, grid_spacing)\n # print(f\"Grid.create: bounding box: x: {x0} y: {y0}\" )\n\n # Generate vectors of grid centers\n # Cell center offset\n cell_center_offset = grid_... | [
"0.68889046",
"0.66959006",
"0.6675402",
"0.6625472",
"0.65224016",
"0.65156347",
"0.64650273",
"0.6447261",
"0.6428468",
"0.64268714",
"0.6423173",
"0.6399049",
"0.6390738",
"0.638039",
"0.6375674",
"0.6367894",
"0.6358506",
"0.63347507",
"0.6316539",
"0.6271705",
"0.6253496... | 0.6431293 | 8 |
The POST on `/institution` should create an institution | def test_create(self, mock_decorator):
response = self.client.post(
'/api/bce_institutions/0802145Y',
content_type='application/json',
headers={'Authorization': 'Bearer token'},
data=json.dumps({
'is_institution': True
}))
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(uai, is_institution=True):\n institution = BceInstitution(\n uai=uai,\n is_institution=is_institution)\n\n return institution.save()",
"def test_perform_create(self):\n\n response = self.client.post(reverse('action-list'), data=self.data)\n self.assert... | [
"0.6681688",
"0.6539136",
"0.64875925",
"0.6482373",
"0.6411193",
"0.6297357",
"0.59500855",
"0.58625144",
"0.578303",
"0.5740273",
"0.56996286",
"0.56490153",
"0.5545814",
"0.55356705",
"0.549819",
"0.5479565",
"0.54430705",
"0.5442307",
"0.54372895",
"0.54182273",
"0.538496... | 0.6618002 | 1 |
The PUT on `/institution` should not update an institution's status if an error accured when deleting the institution | def test_update_false_failed(self, mock_decorator, mock_request):
BceInstitutionRepository.create(uai='0802145Z', is_institution=True)
headers = {'Authorization': 'Bearer token'}
response = self.client.put(
'/api/bce_institutions/0802145Z',
content_type='application/json'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def institution(institution):\n\n try:\n logging.info(f\"Process a request for an institution resource\\nurl: {request.url}\")\n\n params = dict({\"institution_id\": institution})\n logging.info(f\"Parameters: {params}\")\n\n if not valid_institution_params(params):\n logg... | [
"0.61864084",
"0.6164646",
"0.58117944",
"0.55678725",
"0.5484426",
"0.5433848",
"0.53900045",
"0.5374685",
"0.5373604",
"0.5356047",
"0.5295021",
"0.5220352",
"0.5209009",
"0.5200172",
"0.51999074",
"0.5190467",
"0.5157771",
"0.5155514",
"0.51446044",
"0.51443547",
"0.511867... | 0.5944247 | 2 |
Overwrite the network's weights with a specified list of tensors or change weights along directions with a step size. | def set_weights(net, weights, directions=None, step=None):
if directions is None:
# You cannot specify a step length without a direction.
for (p, w) in zip(net.parameters(), weights):
p.data.copy_(w.type(type(p.data)))
else:
assert step is not None, 'If a direction is specifi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_weights(self, weights):\n tuples = []\n for layer in self.layers:\n num_param = len(layer.weights)\n layer_weights = weights[:num_param]\n for sw, w in zip(layer.weights, layer_weights):\n tuples.append((sw, w))\n weights = weights[num_param:]\n K.batch_set_value(tuples)... | [
"0.70630175",
"0.67701286",
"0.6765941",
"0.6713401",
"0.6688865",
"0.6647569",
"0.66165936",
"0.65347296",
"0.6495384",
"0.6468586",
"0.6456321",
"0.63830173",
"0.63485736",
"0.63249886",
"0.6295442",
"0.62903076",
"0.62822104",
"0.62651116",
"0.62480175",
"0.62394434",
"0.6... | 0.71305776 | 0 |
Produce a direction from 'states' to 'states2'. | def get_diff_states(states, states2):
return [v2 - v for (k, v), (k2, v2) in zip(states.items(), states2.items())] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_target_direction(net, net2, dir_type='states'):\n\n assert (net2 is not None)\n # direction between net2 and net\n if dir_type == 'weights':\n w = get_weights(net)\n w2 = get_weights(net2)\n direction = get_diff_weights(w, w2)\n elif dir_type == 'states':\n s = ne... | [
"0.60298765",
"0.56508666",
"0.5566195",
"0.5565897",
"0.55477893",
"0.54129285",
"0.5381549",
"0.53516096",
"0.5290752",
"0.5271821",
"0.51909465",
"0.51732534",
"0.51598144",
"0.515476",
"0.5151006",
"0.51224947",
"0.5095679",
"0.50913215",
"0.5063281",
"0.50172645",
"0.501... | 0.56152266 | 2 |
Set bias and bn parameters in directions to zero | def ignore_biasbn(directions):
for d in directions:
if d.dim() <= 1:
d.fill_(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_bn(bn):\n bn.bias.data.fill_(0.)\n bn.weight.data.fill_(1.)",
"def init_bn(bn):\n bn.bias.data.fill_(0.)\n bn.weight.data.fill_(1.)",
"def init_bn(bn):\n bn.bias.data.fill_(0.)\n bn.weight.data.fill_(1.)",
"def init_bn(bn):\n bn.bias.data.fill_(0.0)\n bn.weight.data.fill_(1.0... | [
"0.77833873",
"0.77833873",
"0.77833873",
"0.7729467",
"0.73508996",
"0.7334153",
"0.7175856",
"0.7175856",
"0.71022403",
"0.7068382",
"0.69517934",
"0.6918207",
"0.6874045",
"0.68622303",
"0.68622303",
"0.68622303",
"0.6830006",
"0.6819566",
"0.6809465",
"0.67975795",
"0.674... | 0.694256 | 11 |
Setup a random (normalized) direction with the same dimension as the weights or states. | def create_random_direction(net, dir_type='weights', ignore='biasbn', norm='filter'):
# random direction
if dir_type == 'weights':
weights = get_weights(net) # a list of parameters.
direction = get_random_weights(weights)
normalize_directions_for_weights(direction, weights, norm, ignore... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_direction(self):\n\n self.mu = 2. * np.random.rand(1)[0] - 1.",
"def setRandDirection(self):\n phi = 2*math.pi*random.random()\n u = 2*random.random() - 1\n v = math.sqrt(1-u*u)*math.cos(phi)\n w = math.sqrt(1-u*u)*math.sin(phi)\n self.direction = (u,v,w)"... | [
"0.7573059",
"0.74795043",
"0.7203547",
"0.66930014",
"0.6545947",
"0.6285585",
"0.62221056",
"0.6202065",
"0.6187849",
"0.6156173",
"0.6156173",
"0.61295575",
"0.61139953",
"0.60598457",
"0.6046723",
"0.6045034",
"0.6041626",
"0.6033324",
"0.60133344",
"0.59864545",
"0.59550... | 0.6744277 | 3 |
Given a json filename, return the corresponding python object. | def get_json(filename) :
result = json.load(open(filename,'r'))
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_JSON(cls, filename):\n with open(os.path.expanduser(filename), encoding='utf-8') as f:\n return json.load(f, object_hook=class_hook)",
"def load_from_json_file(filename):\n with open(filename, 'r') as jFile:\n fString = jFile.read()\n fObj = json.loads(fString)\n re... | [
"0.80472356",
"0.7941216",
"0.793458",
"0.783264",
"0.7675068",
"0.7587168",
"0.75325394",
"0.74979377",
"0.748882",
"0.74805737",
"0.7463445",
"0.74467254",
"0.7425693",
"0.7413434",
"0.7390653",
"0.7386579",
"0.7386579",
"0.7386579",
"0.73783886",
"0.73633784",
"0.73633254"... | 0.7294987 | 26 |
Fits a MinMaxScaler to development data or applies scaler to OOT data. Also creates an "Average Rank" column representing the average of all scaled column values. This should be applied on Massey ranks to create a single signal. | def fnScaleFeatures(x_features, scaler=None, save=False):
base_path = os.path.dirname(os.getcwd())
# ToDo - Allow ability to read in path to Pickle
# Read Feature Data Dictionary
# ToDo - clean up and remove the 2
feature_list = pd.read_csv('{}/mmml/mmml/feature_list2.csv'.format(base_path))
co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def own_MinMaxColumnScaler(df, columns):\n for col in columns:\n new_col_name = col + '_scld'\n col_min = df[col].min()\n col_max = df[col].max()\n df[new_col_name] = (df[col] - col_min) / (col_max - col_min)",
"def normalize(self, df):\n return (df - df.mean()) / (df.max() ... | [
"0.5770062",
"0.56782955",
"0.56147903",
"0.56083876",
"0.55161643",
"0.54930794",
"0.54681605",
"0.54584557",
"0.54358935",
"0.54310757",
"0.5401743",
"0.5384266",
"0.5370906",
"0.5360498",
"0.53282046",
"0.532685",
"0.53093976",
"0.5301164",
"0.530092",
"0.5299703",
"0.5293... | 0.0 | -1 |
Set the learning rate for the optimizer. The method allows setting individual learning rates for the optimizer parameter groups as well as setting even learning rate for all parameters. | def set_lr(self, lr: Union[float, List[float]]):
self._check_train_ready()
param_groups = self.optimizer.param_groups
if isinstance(lr, (list, tuple)):
lrs = list(lr)
if len(lrs) != len(param_groups):
raise ValueError(f"Expected lrs length {len(param_group... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_learning_rate(optimizer, lr):\n for param_group in optimizer.param_groups:\n param_group['lr'] = lr",
"def set_learning_rate(optimizer, lr):\n for param_group in optimizer.param_groups:\n param_group['lr'] = lr",
"def adjust_learning_rate(self, optimizer, epoch, args):\n lr =... | [
"0.84381807",
"0.84381807",
"0.79256344",
"0.79106045",
"0.79106045",
"0.79106045",
"0.7835213",
"0.783462",
"0.78325456",
"0.78214085",
"0.7805656",
"0.77687013",
"0.7746446",
"0.77453303",
"0.77390945",
"0.7730638",
"0.7725753",
"0.77195853",
"0.77195853",
"0.77195853",
"0.... | 0.0 | -1 |
Get the learning rate from the optimizer. It could be a single value or a list of values in the case of multiple parameter groups. | def get_lr(self) -> Union[float, List[float]]:
self._check_train_ready()
lrs = []
for param_group in self.optimizer.param_groups:
lrs.append(param_group['lr'])
if len(lrs) == 1:
return lrs[0]
return lrs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(optimizer, batch):\n lr = learning_rate\n for i in range(len(steps)):\n scale = scales[i] if i < len(scales) else 1\n if batch >= steps[i]:\n lr = lr * scale\n if batch == steps[i]:\n break\n else:\n break\n for ... | [
"0.73941463",
"0.7334019",
"0.7251728",
"0.72500265",
"0.72344977",
"0.71991146",
"0.71951616",
"0.7191687",
"0.7142387",
"0.7111884",
"0.70479566",
"0.699817",
"0.69968563",
"0.6980459",
"0.6967404",
"0.6956034",
"0.6931315",
"0.6905979",
"0.6896167",
"0.68917185",
"0.689171... | 0.6898177 | 18 |
Make a prediction with the given input. The prediction process consists of the input tensor transferring to the model device, forward pass of the nn_module in eval mode and application of the prediction_transform to the raw prediction output. | def predict(self, input):
self._check_predict_ready()
with torch.no_grad():
self.eval()
input = deep_to(input, self.device)
prediction = self.nn_module(input)
prediction = self.prediction_transform(prediction)
return prediction | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, input):\n\n with torch.no_grad():\n input_tensor = self.preprocess_input(input)\n p_labels, p_probs = self.predict_on_batch(input_tensor)\n predictions = np.stack((p_labels, p_probs), axis=1)\n\n return predictions",
"def predict(cls, input):\n clf ... | [
"0.72369206",
"0.70280635",
"0.69705504",
"0.6882179",
"0.6841684",
"0.6813821",
"0.678869",
"0.65115666",
"0.65115666",
"0.65031374",
"0.6496032",
"0.6488619",
"0.6483028",
"0.6481794",
"0.6461958",
"0.64542216",
"0.64486",
"0.63823557",
"0.6380704",
"0.63725114",
"0.6371604... | 0.8179348 | 0 |
Test good IP address value but invalid username in the JSON. Verify that the correct exception is generated. | def test_site_with_good_ipaddress_and_bad_userid(self):
args = self.get_args()
config = self.create_empty_config_file()
config['config'][0]['site']['username'] = ''
config['config'][0]['site']['ip_address'] = '172.31.216.100'
config['config'][0]['site']['local'] = 'True'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_register_with_invalid_username(self):\n self.response = self.client.post(\n \"/api/users/\",\n {\"user\": {\n \"username\": \"&*@#$\",\n \"email\": 'kakecom@gmail.com',\n \"password\": \"irquoa12345678\",\n ... | [
"0.7006392",
"0.6932512",
"0.6899381",
"0.68273884",
"0.67896706",
"0.67825305",
"0.6685398",
"0.6628995",
"0.6566174",
"0.6500617",
"0.64743435",
"0.6448112",
"0.64479417",
"0.6442424",
"0.6408166",
"0.6395684",
"0.6390587",
"0.63865155",
"0.63843244",
"0.63840735",
"0.63690... | 0.0 | -1 |
Pad the list of word indexes into 2D LongTensor | def pad_collate_fn(batch):
length = [len(sentence) for sentence in batch]
return pad_sequence([torch.LongTensor(s) for s in batch], batch_first=True), torch.LongTensor(length) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad_packed_loc_tensors_with_docidxs(tensor: torch.FloatTensor,\n docidx_tensor: torch.LongTensor,\n num_cand: int,\n num_path: int, num_loc: int,\n track_l... | [
"0.6416445",
"0.6384599",
"0.6330144",
"0.6329812",
"0.62912333",
"0.6268383",
"0.6264366",
"0.6256124",
"0.61932456",
"0.61226124",
"0.61226124",
"0.61164695",
"0.6044575",
"0.6039593",
"0.6025685",
"0.60167325",
"0.60122204",
"0.59547096",
"0.59527856",
"0.59167624",
"0.591... | 0.6331113 | 2 |
Generate string from datetime object. | def format_datetime(date_time):
return date_time.strftime("%Y-%m-%d %H:%M:%S") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_datetime_to_string(dt):\n\treturn '{0}-{1}-{2}'.format(dt.year, dt.month, dt.day)",
"def convert_datetime_to_string(dt):\n\treturn '{0}-{1}-{2}'.format(dt.year, dt.month, dt.day)",
"def datetime_to_str(obj):\n return obj.strftime(\"%Y-%m-%d %H:%M:%S\")",
"def date2str(datetime_object):\n ... | [
"0.7885655",
"0.7885655",
"0.76614475",
"0.7659508",
"0.75692374",
"0.7458083",
"0.7418672",
"0.72611195",
"0.7260455",
"0.72175515",
"0.72057724",
"0.7152438",
"0.7138391",
"0.70583403",
"0.7017343",
"0.70044017",
"0.69785815",
"0.69494975",
"0.69296825",
"0.69287217",
"0.69... | 0.0 | -1 |
Merge nested right dict into left nested dict recursively. | def merge_dict(lhs, rhs, override=True):
if not isinstance(lhs, dict) or not isinstance(rhs, dict):
if override:
return rhs
else:
return lhs
for key, value in rhs.items():
if key not in lhs:
lhs[key] = rhs[key]
else:
lhs[key] = mer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_recursive_merge(self):\n dict_1 = {\n 'key': {\n 'deep_key_1': 'original_value_1',\n 'deep_key_2': 'original_value_2'\n }\n }\n dict_2 = {\n 'key': {\n 'deep_key_2': 'new_value_2',\n 'deep_key... | [
"0.72850406",
"0.70178735",
"0.6922518",
"0.6841134",
"0.68263894",
"0.68198365",
"0.6808425",
"0.6798862",
"0.67184794",
"0.6704432",
"0.66804326",
"0.6653708",
"0.6621682",
"0.6607646",
"0.65745974",
"0.6569284",
"0.65582377",
"0.652749",
"0.65273535",
"0.64916474",
"0.6491... | 0.6938452 | 2 |
Returns True if there are duplicate in list, false otherwise | def has_duplicates(list) :
copy = list[:]
copy.sort()
for item in range(len(list)-1):
if copy[item] == copy[item + 1]:
return True;
return False; | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_duplicates(list):\n for i in list:\n if list.count(i) > 1:\n return True\n else:\n return False",
"def has_duplicates(L):\r\n unique = []\r\n for e in L:\r\n if e in unique:\r\n return True\r\n unique.append(e)\r\n return False",
... | [
"0.84518766",
"0.82295084",
"0.8025166",
"0.8007515",
"0.7981002",
"0.79309684",
"0.7747296",
"0.7730481",
"0.771165",
"0.75825065",
"0.74685645",
"0.7462053",
"0.7460879",
"0.7451206",
"0.7368277",
"0.7247897",
"0.7171966",
"0.7130865",
"0.7117366",
"0.7059141",
"0.7022133",... | 0.80837643 | 2 |
Reduces a list of genotypes to distinct genotypes given ploidy | def collapse_genotypes(pL,gL):
if len(gL) < 2:
return gL
else:
uniqueL = [] # list of unique genotypes relative to ploidy
for g in gL:
s = ''
for i in xrange(len(pL)):
s += ''.join(sorted(g[0:pL[i]]))
g = g[pL[i]:]
if s ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_genotype(ploidy):\n return [\"\".join(comb) for comb in cwr(\"ACGT-\", ploidy)]",
"def purify(l):\n return set([item.replace('B-', '').replace('I-', '') for item in l])",
"def remove_duplicates(self, propositions):\r\n propositions_copy = list(propositions)\r\n uniques = []\r\n ... | [
"0.6803628",
"0.55451757",
"0.5401281",
"0.53964216",
"0.5384058",
"0.53527087",
"0.5346865",
"0.52951",
"0.52865404",
"0.5263895",
"0.5255671",
"0.5248324",
"0.52449715",
"0.523073",
"0.5202335",
"0.5185486",
"0.51750034",
"0.5166553",
"0.51247567",
"0.5120886",
"0.5101648",... | 0.7633764 | 0 |
Get account asset information. | async def get_user_account(self):
uri = "/v3/spot/assets"
success, error = await self.request("GET", uri, auth=True)
return success, error | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_asset_details(self):\n\t\tif self._session:\n\t\t\tresults = self._session.get_asset_details()\n\t\t\tif results.get('success'):\n\t\t\t\treturn results.get('assetDetail', {})\n\n\t\treturn {}",
"def getAssetInfo(self):\n return self._AssetInfo",
"def asset_info(self, asset_id):\n respons... | [
"0.7429606",
"0.7401501",
"0.7243802",
"0.722088",
"0.71087193",
"0.7101562",
"0.6901645",
"0.6899573",
"0.68298274",
"0.6810045",
"0.67111224",
"0.6535242",
"0.6509664",
"0.6497271",
"0.6461157",
"0.64144397",
"0.63877004",
"0.638052",
"0.63755345",
"0.63709587",
"0.63575983... | 0.7496198 | 0 |
check if the stack is empty | def isEmpty(self):
if self.top == -1:
return True
return False | {
"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):\r\n return len(self.stack) == 0",
"def empty(self):\r\n return self.stack == []",
"def empty(self) -> bool:\n if len(self.stack)==0:\n ... | [
"0.899054",
"0.89378405",
"0.8896436",
"0.88488156",
"0.8803647",
"0.8801893",
"0.8801893",
"0.8755084",
"0.8730939",
"0.86257416",
"0.8616184",
"0.8564391",
"0.8551106",
"0.84926367",
"0.84474415",
"0.84409744",
"0.84366745",
"0.84080905",
"0.8403395",
"0.8403395",
"0.839545... | 0.7673615 | 35 |
Main method to convert infix expression to postfix expression | def infix_to_postfix(self, exp):
try:
for i in exp:
#if the character is an operand output it
if self.is_operand(i):
self.postfix.append(i)
#if the character is '(' push it
elif i is '(':
self.p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infix_to_postfix(input_str): # postfix requires that all operators proceed after the two operands that they work on\n\n \"\"\"Input argument: a string containing an infix expression where tokens are \n space separated. Tokens are either operators + - * / ** << >> or numbers (integers or floats)\n Re... | [
"0.83583",
"0.8116467",
"0.8104854",
"0.8094464",
"0.80649686",
"0.80585086",
"0.8023016",
"0.7784465",
"0.7780311",
"0.7726206",
"0.7704624",
"0.76936716",
"0.7660222",
"0.7614875",
"0.75796753",
"0.75611275",
"0.7486621",
"0.74753785",
"0.7403091",
"0.73770356",
"0.736011",... | 0.8077742 | 4 |
Returns a string representation of this Solver object. String representation of this Solver object. | def __str__(self):
return self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n _str = \"Variables:\\n\"\n for variable in self.variables:\n _str += \" {}\\n\".format(str(variable))\n _str += \"\\nConstraints:\\n\"\n for constraint in self.constraints:\n _str += \" {}\\n\".format(str(constraint))\n return _str... | [
"0.73139703",
"0.72417116",
"0.7171263",
"0.7147165",
"0.69939476",
"0.6970453",
"0.69356996",
"0.69356996",
"0.69356996",
"0.69356996",
"0.69356996",
"0.69076264",
"0.68720555",
"0.68416953",
"0.68148965",
"0.6810901",
"0.68090653",
"0.68089163",
"0.6751696",
"0.6708536",
"0... | 0.0 | -1 |
Optionally restricts the returned purchases to a given user, by filtering against a `username` query parameter in the URL. | def get_queryset(self):
queryset = Goods.objects.all().order_by('id')
isclass = self.request.query_params.get('is_class', None)
isclick = self.request.query_params.get('is_click', None)
if isclass is not None and isclick is not None:
queryset = queryset.filter(is_class=isclas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n username = self.kwargs.get('username', None)\n filters = {}\n if username:\n filters['user__username'] = username\n return super(PhotosListView, self).get_queryset().filter(**filters)",
"def filter_queryset(self, request, queryset, view):\n ... | [
"0.59691316",
"0.59666115",
"0.5933636",
"0.5911969",
"0.59060764",
"0.5664847",
"0.5654243",
"0.5545357",
"0.55417883",
"0.55104214",
"0.55045646",
"0.5494846",
"0.54883754",
"0.5484133",
"0.547296",
"0.54719406",
"0.54517895",
"0.54165924",
"0.54078025",
"0.53811634",
"0.53... | 0.0 | -1 |
Initializes a bank account. | def __init__(self, bank_account_no: str, bank_name: str,
bank_balance: float, budget_manager: BudgetManager):
self.bank_account_no = bank_account_no
self.bank_name = bank_name
self.bank_balance = bank_balance
self.transactions = []
self.budget_manager = budget_ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.__account_number = self.__generate_acct_number()\n self.__account_pin = self.__generate_pin()\n self.card_number = BankAccount.BIN + self.__account_number \\\n + self.__calculate_checksum(BankAccount.BIN + self.__account_number)\n self.__balance = 0... | [
"0.74330753",
"0.7418163",
"0.71338934",
"0.68308854",
"0.6822508",
"0.6773144",
"0.66065884",
"0.6591546",
"0.6561337",
"0.6539208",
"0.6516019",
"0.6513716",
"0.64234877",
"0.64219314",
"0.6420932",
"0.63918215",
"0.6345676",
"0.6317964",
"0.6303646",
"0.6286144",
"0.628228... | 0.69641596 | 3 |
Returns a list of transactions for the given budget category. | def get_transactions_by_budget(self, category: BudgetCategory) -> list:
return [transaction
for transaction in self.transactions
if transaction.budget_category == category] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_transactions_by_category(id, start=None, end=None):\n transactions = None\n \n if start is not None and end is not None:\n transactions = get_db().execute('SELECT * FROM transactions WHERE category_id = ? AND days >= ? AND days <= ? ORDER BY days ASC', (id,start, end)).fetchall()\n elif ... | [
"0.6806576",
"0.6658334",
"0.65594226",
"0.6545171",
"0.6276733",
"0.6153951",
"0.6099856",
"0.60981506",
"0.6073485",
"0.56966245",
"0.56923014",
"0.56610286",
"0.56480473",
"0.5619715",
"0.56023616",
"0.55917746",
"0.55726683",
"0.54196036",
"0.5411472",
"0.53702503",
"0.53... | 0.90207845 | 0 |
Returns a list of budgets. | def get_budgets(self) -> list:
return self.budget_manager.get_budgets() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_budgets(self) -> list:\n return list(self.budgets.values())",
"def view_budgets(self) -> None:\n Menu.prompt_view_budgets()\n for budget in self.user.budget_manager:\n print(f\"{budget}\\n\")",
"def get_period_budgets(cls, now):\n limits_dict = {}\n strateg... | [
"0.85214865",
"0.7412498",
"0.64458525",
"0.63256943",
"0.62178475",
"0.61472815",
"0.60853624",
"0.6020937",
"0.6002316",
"0.5954649",
"0.59180295",
"0.5860765",
"0.58439565",
"0.57929516",
"0.57694215",
"0.57481736",
"0.5706999",
"0.56716955",
"0.562081",
"0.55899936",
"0.5... | 0.8720392 | 0 |
Creates and returns a test bank account. | def load_test_account() -> BankAccount:
budget_manager = BudgetCreator.load_test_budget_manager()
return TroublemakerBankAccount('123123', 'HSBC', 1000, budget_manager) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def example_bank_account():\n \n return BankAccount(\"Test User\", 1000.0)",
"def account():\n\n bank_test = Bank.objects.create(name='R-Bank')\n company_test = Company.objects.create(name='Tre Belarus', country='Belarus')\n account = Account.objects.create(iban_number='TEEdddddddfs', swift_code='... | [
"0.8158701",
"0.77940786",
"0.7747473",
"0.76212186",
"0.7560084",
"0.7495021",
"0.7118138",
"0.7009641",
"0.6978692",
"0.6969263",
"0.6830469",
"0.67025876",
"0.6648418",
"0.6598755",
"0.6555226",
"0.6548302",
"0.6513743",
"0.6461734",
"0.63989663",
"0.63898635",
"0.6336258"... | 0.7865632 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.