query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Generate the array of price changes. | def _getPriceChangeArray(self):
prices = self.price_array[1:]
prev_prices = self.price_array[:-1]
raw_price_changes = prices / prev_prices
expense_array = np.array(
[self.stock_dict[ticker].expense_ratio for ticker in self.tickers], dtype=np.float64)
expense_array = n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def price_history(self) -> np.ndarray:\n nb_transactions = len(self.game.transactions)\n nb_goods = self.game.configuration.nb_goods\n result = np.zeros((nb_transactions + 1, nb_goods), dtype=np.float32)\n\n temp_game = Game(self.game.configuration, self.game.initialization)\n\n ... | [
"0.66110533",
"0.66072136",
"0.6545294",
"0.61039895",
"0.5988195",
"0.5960361",
"0.5951982",
"0.5944508",
"0.5913564",
"0.58012235",
"0.58002996",
"0.57225096",
"0.5713424",
"0.57093674",
"0.5703792",
"0.56665474",
"0.5522286",
"0.55150926",
"0.54229176",
"0.54132736",
"0.54... | 0.77094185 | 0 |
Parses a json settings file and merges in missing defaults. | def load_settings(user_settings_file: IO[AnyStr], use_default_values: bool = True) -> Json:
default_settings = load_default_settings()
user_settings = load_settings_simple(user_settings_file)
return typing.cast(Json, _merge_settings(default_settings, user_settings, use_default_values)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_json_settings(file: str):\n with open(file) as f:\n return json.load(f)",
"def json_config_settings_source(settings: BaseSettings) -> Dict[str, Any]:\n full_path = Path(config_dir) / config_name\n logger.debug(f\"Parsing file: {full_path}\")\n if fileio.file_exists(str(fu... | [
"0.71374434",
"0.7061503",
"0.69584143",
"0.69001013",
"0.6724808",
"0.65126544",
"0.6474971",
"0.64652",
"0.64467615",
"0.64318335",
"0.6358839",
"0.6333143",
"0.6325857",
"0.6324122",
"0.63009304",
"0.6262618",
"0.6207379",
"0.6193889",
"0.6193376",
"0.6137778",
"0.60944533... | 0.72829187 | 0 |
Raises a value error if duplicates have been counted. | def _raise_if_duplicates(counts: Dict[str, int]) -> None:
duplicates: List[str] = []
for nickname, count in counts.items():
if count > 1:
duplicates.append(nickname)
if len(duplicates) > 0:
# TODO This is not always nickname
raise ValueError(f'\'nickname\' not unique {dup... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_value_error(self):\n with self.assertRaises(ValueError):\n Band.count(\n column=Band.name, distinct=[Band.name, Band.popularity]\n ).run_sync()",
"def validate_availability(self, value):\n cnt = Counter()\n if value:\n for i in value:\... | [
"0.70410717",
"0.6357471",
"0.605737",
"0.60037196",
"0.6002928",
"0.5907917",
"0.5853888",
"0.58534443",
"0.58284265",
"0.58045846",
"0.57278585",
"0.5720412",
"0.5718681",
"0.5674157",
"0.56520355",
"0.56154764",
"0.5604806",
"0.55942357",
"0.55827755",
"0.5576378",
"0.5554... | 0.6930402 | 1 |
Parses an engine options file into a dictionary. | def load_engine_options_simple(engine_options_file: IO[AnyStr]) -> engine.ConfigMapping:
options: engine.ConfigMapping = {}
name_counts: Dict[str, int] = {}
for line_in_file in engine_options_file.read().splitlines():
line = typing.cast(str, line_in_file.strip())
if not line or line.startswi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_options(self):\n options = dict()\n while True:\n line = self.rfile.readline().decode(\"utf8\").strip()\n if not line:\n break\n self.log.debug(\"Got line: %s\", line)\n if \":\" not in line:\n self.log.debug(\"Invalid ... | [
"0.7345696",
"0.6754468",
"0.65925574",
"0.6516578",
"0.63679355",
"0.6275019",
"0.6238644",
"0.62379575",
"0.62147844",
"0.6081465",
"0.6051997",
"0.6026707",
"0.601588",
"0.60051244",
"0.6001563",
"0.5991739",
"0.5986586",
"0.5982635",
"0.5954915",
"0.58947027",
"0.586558",... | 0.74689823 | 0 |
Parses an engine options file and merges in missing defaults. | def load_engine_options(
default_options: List[engine.Option],
options_file: IO[AnyStr],
exclude_default_values: bool = True) -> engine.ConfigMapping:
def is_empty(value: engine.ConfigValue):
return value is None or value == '<empty>'
engine_options: engine.ConfigMapping = {}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_engine_options_simple(engine_options_file: IO[AnyStr]) -> engine.ConfigMapping:\n options: engine.ConfigMapping = {}\n name_counts: Dict[str, int] = {}\n for line_in_file in engine_options_file.read().splitlines():\n line = typing.cast(str, line_in_file.strip())\n if not line or lin... | [
"0.68988574",
"0.6230676",
"0.6218802",
"0.6173075",
"0.6170455",
"0.6135077",
"0.61264294",
"0.60763556",
"0.59360474",
"0.5916492",
"0.5889376",
"0.5873683",
"0.5790578",
"0.573215",
"0.5720919",
"0.5708603",
"0.57029176",
"0.56948304",
"0.5682351",
"0.5680957",
"0.566325",... | 0.7057122 | 0 |
Save timezoneaware values for created and updated fields. | def save(self, *args, **kwargs):
if self.pk is None:
self.created = timezone.now()
self.updated = timezone.now()
super(Base, self).save(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, *args, **kwargs):\n if self.pk is None:\n self.created = timezone.now()\n self.updated = timezone.now()\n super(Base, self).save(*args, **kwargs)",
"def save(self, *args, **kwargs):\n if not self.id:\n self.create_date = timezone.now()\n sel... | [
"0.6898697",
"0.63491416",
"0.6327028",
"0.6312949",
"0.6275868",
"0.61563116",
"0.61563116",
"0.6146063",
"0.6146063",
"0.61329794",
"0.61329794",
"0.6125347",
"0.61214924",
"0.61214924",
"0.6013914",
"0.6012528",
"0.59893817",
"0.5989289",
"0.5966557",
"0.59067565",
"0.5903... | 0.69218004 | 0 |
Adds indent, quotes specified elements, joins them with ',' and surrounds with parentheses. | def commajoin(array, elements_to_quote, indent=0):
result = " " * indent + "("
for i in elements_to_quote:
if array[i] == '':
array[i] = "NULL"
else:
array[i] = "'" + str(array[i]) + "'"
j = 0
for i in array:
result += str(i)
if j != len(array) - 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _format_item_list(items, pad=\"'\", sep=', ', end_sep=' and '):\n result = ''\n items = [pad + item + pad for item in items]\n if items:\n if len(items) != 1:\n result = sep.join(items[:-1]) + end_sep + items[-1]\n else:\n result = items[0]\n return result",
"d... | [
"0.6104393",
"0.6081047",
"0.5986766",
"0.59865344",
"0.5851034",
"0.57388306",
"0.5737991",
"0.5690729",
"0.56882364",
"0.5627679",
"0.56094444",
"0.5571577",
"0.55558723",
"0.5547043",
"0.55461544",
"0.5525962",
"0.54631674",
"0.5434451",
"0.54077697",
"0.54077697",
"0.5362... | 0.68266034 | 0 |
simply converts all csv files in mock data into insert statements | def write_test_data(sql):
for fname in sorted(glob.glob("mock_data/*.csv")):
print(fname)
with open(fname, 'r', encoding='utf8') as csvfile:
reader = csv.reader(csvfile, delimiter=",", quoting=csv.QUOTE_MINIMAL)
i = 0
for row in reader:
if i == 0:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_data(data_type, data, db_cursor, database):\n for each_file in data:\n with open(f'{DATA_PATH}{each_file}.csv') as csv_file:\n csv_reader = csv.reader(csv_file, delimiter=',')\n line_count = 0\n for row in csv_reader:\n # do not process the heade... | [
"0.6758338",
"0.6746043",
"0.67334425",
"0.6713657",
"0.66608614",
"0.6618824",
"0.65960056",
"0.65747595",
"0.6549408",
"0.65186286",
"0.65053517",
"0.6415094",
"0.6390163",
"0.6388048",
"0.63780886",
"0.6363483",
"0.6359099",
"0.6326339",
"0.6316207",
"0.6316161",
"0.63077"... | 0.77306116 | 0 |
PATCH /workers/ Changes the status of this worker. | def patch(self, identifier):
data = binary_status_schema(g.payload)
if data.get('status') == 'ACTIVE':
current_app.config['APPLICATION'].enable_worker(identifier)
elif data.get('status') == 'DEACTIVATED':
current_app.config['APPLICATION'].disable_worker(identifier)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch(self, id):\n try:\n task = update_status(get_db(), id, Status[api.payload[\"status\"]])\n if not task:\n api.abort(404, \"Invalid Task\")\n return task_to_dict(task)\n except ValueError:\n api.abort(422, \"Invalid Status\")",
"def... | [
"0.55095226",
"0.55028725",
"0.54557097",
"0.54305637",
"0.5403861",
"0.53791434",
"0.5377578",
"0.5347136",
"0.533915",
"0.533581",
"0.53261644",
"0.53202647",
"0.52790004",
"0.5251339",
"0.5215275",
"0.5204497",
"0.5191661",
"0.5185492",
"0.5157756",
"0.5133342",
"0.5130274... | 0.74830425 | 0 |
set a proffesional looking matplotlib style | def set_style(usetex=False):
plt.rc('text', usetex=usetex)
plt.rc('font', family='Serif')
mpl.rcParams['figure.figsize'] = [10, 7]
mpl.rcParams['font.size'] = 17
mpl.rcParams['savefig.dpi'] = 150
mpl.rcParams['xtick.minor.visible'] = True
mpl.rcParams['ytick.minor.visible'] = True
mpl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customize_mpl():\r\n print(\"Setting custom matplotlib visual style\")\r\n\r\n rcParams['figure.figsize'] = (10, 6)\r\n rcParams['figure.dpi'] = 150\r\n rcParams['axes.color_cycle'] = dark2_colors\r\n rcParams['lines.linewidth'] = 2\r\n rcParams['axes.grid'] = True\r\n rcParams['axes.facec... | [
"0.75982976",
"0.718391",
"0.7182594",
"0.7110354",
"0.70964205",
"0.6949332",
"0.6936319",
"0.67766124",
"0.67148894",
"0.6619341",
"0.6582537",
"0.657382",
"0.6467556",
"0.64657557",
"0.64460784",
"0.64151937",
"0.6413506",
"0.6411621",
"0.63958895",
"0.6392753",
"0.6353010... | 0.7470834 | 1 |
Get the cached binary distribution archive that was previously built for the given package (name, version) (and optionally URL). If no archive has been cached yet, a new binary distribution archive is created and added to the cache. | def get_binary_dist(package, version, directory, url=None, python='/usr/bin/python', prefix='/usr'):
tag = hashlib.sha1(str(version + url).encode()).hexdigest() if url else version
cache_file = os.path.join(binary_index, '%s:%s:%s.tar.gz' % (package, tag, get_python_version()))
if not os.path.isfile(cach... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cache(name):\n\n return get_component(CachingPackage.COMPONENT_NAME).get_cache(name)",
"def cabal_get(name, unpack_to, version=None):\n pkg = name\n if version is not None:\n pkg += \"==\"\n pkg += version\n\n return run([\"cabal\", \"get\", pkg, \"-d\", unpack_to])",
"def existing_archive(... | [
"0.62168354",
"0.60056436",
"0.58326787",
"0.5793394",
"0.5715711",
"0.567902",
"0.56164545",
"0.5613404",
"0.55722487",
"0.5547017",
"0.55175894",
"0.5502366",
"0.54943293",
"0.54713947",
"0.5448375",
"0.54424584",
"0.54364425",
"0.54203945",
"0.5413666",
"0.54098874",
"0.53... | 0.7490097 | 0 |
Transform a binary distribution archive created with ``python setup.py bdist_dumb format=tar`` into a form that can be cached for future use. This comes down to making the pathnames inside the archive relative to the `prefix` that the binary distribution was built for. | def transform_binary_dist(archive_path, prefix='/usr'):
# Copy the tar archive file by file so we can rewrite the pathnames.
logger.debug("Transforming binary distribution: %s.", archive_path)
logger.debug("Using environment prefix: %s.", prefix)
archive = tarfile.open(archive_path, 'r')
for me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gz_tar(full_prefix):\n tarfile = os.path.join(outputdir, full_prefix + '.tar')\n try:\n with open(tarfile, 'rb') as f_in, gzip.open(tarfile + '.gz', 'wb') as f_out:\n shutil.copyfileobj(f_in, f_out)\n os.remove(tarfile)\n except Exception as e:\n log.error(\"Tarfile {0}... | [
"0.6624995",
"0.5973443",
"0.59267676",
"0.58510005",
"0.5808216",
"0.5689753",
"0.56756777",
"0.5619002",
"0.5613805",
"0.55668515",
"0.5519208",
"0.54786164",
"0.54553145",
"0.5450021",
"0.5443351",
"0.5413397",
"0.5370573",
"0.5354789",
"0.53475803",
"0.53347725",
"0.53303... | 0.7719703 | 0 |
Install a binary distribution created with ``python setup.py bdist`` into the given prefix (a directory like ``/usr``, ``/usr/local`` or a virtual environment). | def install_binary_dist(members, prefix, python='/usr/bin/python', enable_workarounds=True):
# TODO This is quite slow for modules like Django. Speed it up! Two choices:
# 1. Run the external tar program to unpack the archive. This will
# slightly complicate the fixing up of hashbangs.
# 2. Us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install(self, spec, prefix):\n make(\"install\", parallel=False)",
"def install(self, args=None, target=\"install\"):\n args = args if args else []\n str_args = \" \".join(args)\n if \"DESTDIR=\" not in str_args:\n args.insert(0, \"DESTDIR={}\".format(unix_path(self._co... | [
"0.6706299",
"0.65126616",
"0.6295004",
"0.6238352",
"0.60443175",
"0.60068166",
"0.59957397",
"0.5921789",
"0.57315",
"0.5648719",
"0.56375676",
"0.55756116",
"0.5550347",
"0.55466676",
"0.5510487",
"0.5481524",
"0.54365534",
"0.54067636",
"0.53959805",
"0.5365939",
"0.53503... | 0.6652997 | 1 |
Rewrite the hashbang in an executable script so that the Python program inside the virtual environment is used instead of a system wide Python. | def fix_hashbang(python, contents):
# Separate the first line in the file from the remainder of the contents
# while preserving the end of line sequence (CR+LF or just an LF) and
# without having to split all lines in the file (there's no point).
lines = contents.splitlines()
hashbang = lines[0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_shebang(self, handle, interpreter):\n if detect_python_script(handle):\n lines = handle.readlines()\n lines[0] = b'#!' + interpreter.encode('ascii') + b'\\n'\n handle = BytesIO(b''.join(lines))\n handle.seek(0)\n return handle",
"def process_sh... | [
"0.732829",
"0.6517055",
"0.64587206",
"0.6419364",
"0.6301114",
"0.5835952",
"0.57975733",
"0.56519705",
"0.5598901",
"0.5556552",
"0.55436015",
"0.55386496",
"0.5365093",
"0.53436875",
"0.5277366",
"0.52546036",
"0.5249833",
"0.524669",
"0.5241603",
"0.52317417",
"0.5179354... | 0.66236895 | 1 |
The version of the package that ``pip`` wants to install based on the command line options that were given to ``pip`` (a string). Based on | def version(self):
return self.pip_requirement.installed_version | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_pip_versioned_package_string(\n library_name: str, version_string: str\n) -> str:\n return '%s==%s' % (library_name, version_string)",
"def get_version():\n\n version_string = version_from_versioneer()\n\n if not version_string:\n version_string = version_from_pip()\n\n return vers... | [
"0.66763216",
"0.6673236",
"0.63909316",
"0.6285159",
"0.62627167",
"0.622569",
"0.62129605",
"0.62005633",
"0.61937195",
"0.6155948",
"0.611179",
"0.6058138",
"0.6058138",
"0.6058138",
"0.6058138",
"0.6058138",
"0.6058138",
"0.6058138",
"0.6058138",
"0.6058138",
"0.6058138",... | 0.674038 | 0 |
``True`` when the requirement is already installed, ``False`` otherwise. | def is_installed(self):
return bool(self.pip_requirement.satisfied_by) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_installed(self):\n return not self.dont_install",
"def already_installed(lib_spec, options, working_set=None):\n if 'path' in options:\n return False\n\n if not working_set:\n working_set=pkg_resources.WorkingSet(sys.path)\n\n try:\n working_set.require(lib_spec)\n ... | [
"0.77823555",
"0.7527283",
"0.7521783",
"0.7446945",
"0.7324295",
"0.72457904",
"0.721714",
"0.71614337",
"0.706286",
"0.70098406",
"0.69969386",
"0.69896317",
"0.69786394",
"0.69777703",
"0.6964472",
"0.6922492",
"0.69222534",
"0.6917151",
"0.69150466",
"0.69119006",
"0.6896... | 0.79604423 | 0 |
``True`` when the requirement is a transitive dependency (a dependency of a dependency) or ``False`` when the requirement is a direct dependency (specified on pip's command line or in a ``requirements.txt`` file). Based on | def is_transitive(self):
return isinstance(self.pip_requirement.comes_from, InstallRequirement) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_dependency(self, dep):\r\n return True",
"def _sufficient_deps(cls, deps):\n if cls.MODEL_PACKAGE is None:\n return True\n else:\n for d in deps.conda:\n if cls.MODEL_PACKAGE in d:\n return True\n for d in deps.pip:\n ... | [
"0.7150804",
"0.67961425",
"0.67164946",
"0.65914494",
"0.6496702",
"0.6477763",
"0.633333",
"0.63137054",
"0.62766606",
"0.62700015",
"0.6266488",
"0.62340945",
"0.61870563",
"0.61679566",
"0.6163255",
"0.6157765",
"0.6050587",
"0.6031543",
"0.60234386",
"0.6016165",
"0.5978... | 0.7746789 | 0 |
Create a temporary working directory and a virtual environment where pipaccel can be tested in isolation (starting with an empty download cache, source index and binary index and no installed modules) and make sure pip and pipaccel use the directory. Also creates the directories for the download cache, the source index... | def setUp(self):
coloredlogs.install(level=logging.DEBUG)
# Create a temporary working directory.
self.working_directory = tempfile.mkdtemp()
# Create a temporary build directory.
self.build_directory = os.path.join(self.working_directory, 'build')
# Create a tempor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n coloredlogs.install(level=logging.DEBUG)\n # Create a temporary working directory.\n self.working_directory = tempfile.mkdtemp()\n # Create a temporary build directory.\n self.build_directory = os.path.join(self.working_directory, 'build')\n # Create a t... | [
"0.76585984",
"0.6998828",
"0.6592483",
"0.65521127",
"0.65169436",
"0.648992",
"0.632207",
"0.62966186",
"0.6259255",
"0.61760193",
"0.6119715",
"0.6043009",
"0.60395974",
"0.60066956",
"0.59853506",
"0.59688634",
"0.595255",
"0.5901899",
"0.5901053",
"0.589884",
"0.5891566"... | 0.7686593 | 0 |
A very basic test of the functions that make up the pipaccel command using the `virtualenv` package as a test case. | def runTest(self):
# We will test the downloading, conversion to binary distribution and
# installation of the virtualenv package (we simply need a package we
# know is available from PyPI).
arguments = ['install', '--ignore-installed', 'virtualenv==1.8.4']
# First we do a s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runTest(self):\n # We will test the downloading, conversion to binary distribution and\n # installation of the virtualenv package (we simply need a package we\n # know is available from PyPI).\n arguments = ['install', '--ignore-installed', 'virtualenv==1.8.4']\n # First we d... | [
"0.75798845",
"0.69819945",
"0.6818097",
"0.6713533",
"0.6589174",
"0.6525606",
"0.6503367",
"0.63632447",
"0.63099754",
"0.622459",
"0.6204702",
"0.6194493",
"0.6139652",
"0.61071426",
"0.6083854",
"0.5994085",
"0.5992309",
"0.59918314",
"0.5952341",
"0.59369195",
"0.586638"... | 0.74043363 | 1 |
Create a temporary txt file from HDF5. | def hdf2txt_tmp(fname):
print 'converting HDF5 -> temporary ASCII ...',
data, fin = readh5(fname)
f = tf.NamedTemporaryFile(suffix='') # create temp file
np.savetxt(f, data, fmt='%f')
f.seek(0)
closeh5(fin)
print 'done'
return f | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_as_hdf5(self, filename):",
"def temporary(cls):\n fh, path = tempfile.mkstemp(suffix='.hdf5')\n os.close(fh)\n self = cls(path, 'w')\n self.path = path\n return self",
"def test_create():\n\n with tempfile.TemporaryDirectory() as td:\n fp = os.path.join(td,... | [
"0.6588873",
"0.65184367",
"0.6387805",
"0.6336854",
"0.6114972",
"0.59868824",
"0.592905",
"0.5881204",
"0.5869554",
"0.5852435",
"0.58333004",
"0.5813109",
"0.58126175",
"0.5812096",
"0.5809681",
"0.57816786",
"0.57685274",
"0.57606965",
"0.57593733",
"0.57477915",
"0.57401... | 0.7862914 | 0 |
Takes a dataframe of processed eviction data and predictions from an ARIMAX model at the month level. Returns a dataframe grouped by ZIP with a column containing the average percentage of total evictions each ZIP represented | def top_down_forecast_data_processing(original_df,predictions_by_month):
transformed_df=original_df.groupby('Month_Year').sum().reset_index()\
[['Month_Year','Eviction_Notice']]
percentage_of_month_df = pd.merge(original_df[['Month_Year','Address_Zipcode',\
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_down_forecast(original_df,predictions_by_month,months_ahead):\n\n group_by_zip_df = top_down_forecast_data_processing(original_df,predictions_by_month)\n\n zip_perc_df= pd.DataFrame(np.random.randn(1, 4), columns=['zip_predicted','zip_code','perc_of_month','month_year'])\n\n for month in range(mon... | [
"0.6544387",
"0.58413523",
"0.57256114",
"0.56348085",
"0.555309",
"0.54977405",
"0.5485508",
"0.54725814",
"0.5401345",
"0.5389973",
"0.536069",
"0.5329506",
"0.5328788",
"0.5302536",
"0.52628785",
"0.5251212",
"0.5242129",
"0.522812",
"0.52199835",
"0.5200968",
"0.5185783",... | 0.739867 | 0 |
Invoke an action on a DHCP driver instance. | def call_driver(self, action, network):
if self.conf.use_namespaces:
namespace = NS_PREFIX + network.id
else:
namespace = None
try:
# the Driver expects something that is duck typed similar to
# the base models.
driver = self.dhcp_drive... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_action(host, details, action):\n if details:\n pprint(cs.get_device_details(host))\n if action:\n pprint(cs.device_action(host, action))",
"def device_action(self, client, action):\r\n client.deviceAction(action)",
"def _RunDHCPCD(self, **kwargs):\n del kwargs\n clea... | [
"0.61030775",
"0.5921867",
"0.58629996",
"0.5762756",
"0.57204163",
"0.56761485",
"0.56761485",
"0.55990696",
"0.55990696",
"0.5535578",
"0.55226314",
"0.54966766",
"0.54925567",
"0.5439608",
"0.541157",
"0.54060113",
"0.5376972",
"0.537439",
"0.53660226",
"0.5343927",
"0.529... | 0.7318727 | 0 |
Sync the local DHCP state with Quantum. | def sync_state(self):
LOG.info(_('Synchronizing state'))
known_networks = set(self.cache.get_network_ids())
try:
active_networks = set(self.plugin_rpc.get_active_networks())
for deleted_id in known_networks - active_networks:
self.disable_dhcp_helper(dele... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sync_experiment_state_with_ddb(self):\n if self.local_mode:\n self.sync_thread.sync_experiment_state_with_ddb()",
"def update(self):\n self._state = get_local_ip()",
"def sync():\n sync_ssda()",
"def update(self):\n try:\n if not self._sysinfo:\n ... | [
"0.6180898",
"0.5961581",
"0.56596506",
"0.5563325",
"0.55320233",
"0.5489496",
"0.54843223",
"0.5393621",
"0.5317044",
"0.5298483",
"0.52749354",
"0.5256482",
"0.5226604",
"0.5218777",
"0.51281685",
"0.5090927",
"0.5090464",
"0.50808954",
"0.5073649",
"0.5064125",
"0.5057595... | 0.6583717 | 0 |
Enable DHCP for a network that meets enabling criteria. | def enable_dhcp_helper(self, network_id):
try:
network = self.plugin_rpc.get_network_info(network_id)
except:
self.needs_resync = True
LOG.exception(_('Network %s RPC info call failed.') % network_id)
return
if not network.admin_state_up:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dhcp_agent_network_add(self, dhcp_net_info):\n self.turn_on_dhcp_check()",
"def enable_network_management(self):\n self._request({\"enable-network-management\": True})",
"def elAddNetworkConfigurationWithDhcp(self, device):\n commandSection = self.sectionByName(\"command\")\n # ... | [
"0.6613713",
"0.64811337",
"0.6424179",
"0.6270945",
"0.6147416",
"0.61341375",
"0.603933",
"0.5958222",
"0.59445256",
"0.5920509",
"0.5902045",
"0.5895537",
"0.58745736",
"0.57734",
"0.5736621",
"0.57331413",
"0.5694706",
"0.5690121",
"0.5680276",
"0.5655933",
"0.56160223",
... | 0.75427896 | 0 |
Disable DHCP for a network known to the agent. | def disable_dhcp_helper(self, network_id):
network = self.cache.get_network_by_id(network_id)
if network:
if self.call_driver('disable', network):
self.cache.remove(network) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dhcp_agent_network_remove(self, dhcp_net_info):\n self.turn_on_dhcp_check()",
"def network_delete_end(self, payload):\n self.disable_dhcp_helper(payload['network_id'])",
"def _disable_wifi_ap(self):\n call(['systemctl', 'disable', 'hostapd', ])\n call(['systemctl', 'disable', 'd... | [
"0.7135386",
"0.6868477",
"0.64515764",
"0.62737286",
"0.62714326",
"0.6229779",
"0.6223586",
"0.6125738",
"0.61127055",
"0.6056309",
"0.59756565",
"0.5961324",
"0.59271187",
"0.5900384",
"0.5843378",
"0.57802856",
"0.57735544",
"0.5729633",
"0.5697703",
"0.56655335",
"0.5631... | 0.7986895 | 0 |
Refresh or disable DHCP for a network depending on the current state of the network. | def refresh_dhcp_helper(self, network_id):
old_network = self.cache.get_network_by_id(network_id)
if not old_network:
# DHCP current not running for network.
return self.enable_dhcp_helper(network_id)
try:
network = self.plugin_rpc.get_network_info(network_id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def network_update_end(self, payload):\n network_id = payload['network']['id']\n if payload['network']['admin_state_up']:\n self.enable_dhcp_helper(network_id)\n else:\n self.disable_dhcp_helper(network_id)",
"def disable_dhcp_helper(self, network_id):\n network ... | [
"0.70645887",
"0.7003579",
"0.6516991",
"0.6359894",
"0.6336317",
"0.61639994",
"0.60851556",
"0.607324",
"0.59917974",
"0.5893061",
"0.57851523",
"0.5669228",
"0.56041586",
"0.5593157",
"0.5579951",
"0.54653764",
"0.54648304",
"0.5416313",
"0.5412252",
"0.53830546",
"0.53794... | 0.733629 | 0 |
Handle the network.create.end notification event. | def network_create_end(self, payload):
network_id = payload['network']['id']
self.enable_dhcp_helper(network_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_graph_end(self, network: Network):\n pass",
"def onMessageEnd(self):",
"def network_create_event(self, network_info):\n net = network_info['network']\n net_id = net['id']\n net_name = net.get('name')\n network_db_elem = self.get_network(net_id)\n # Check if t... | [
"0.6248566",
"0.6031988",
"0.57522935",
"0.57338864",
"0.5701586",
"0.5675204",
"0.5653594",
"0.5636173",
"0.5629332",
"0.5538093",
"0.54424596",
"0.5430942",
"0.5419787",
"0.53785735",
"0.53761613",
"0.53417826",
"0.53303516",
"0.5320978",
"0.531378",
"0.530669",
"0.52717966... | 0.6849954 | 0 |
Handle the network.update.end notification event. | def network_update_end(self, payload):
network_id = payload['network']['id']
if payload['network']['admin_state_up']:
self.enable_dhcp_helper(network_id)
else:
self.disable_dhcp_helper(network_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_end(self, status, objective):\n pass # pragma: no cover",
"def send_finish_event(self):\n self.status['type'] = '__end__'\n self._send()",
"def end(update: Update, context: CallbackContext) -> int:\n update.callback_query.answer()\n\n text = \"See you around!\"\n updat... | [
"0.64979863",
"0.63618815",
"0.6354132",
"0.6308048",
"0.6289232",
"0.61400086",
"0.6041612",
"0.60274327",
"0.59674954",
"0.5949109",
"0.5926635",
"0.58869374",
"0.58779126",
"0.5860421",
"0.5796766",
"0.5758815",
"0.57569045",
"0.57188445",
"0.5713383",
"0.5688551",
"0.5639... | 0.6571846 | 0 |
Handle the network.delete.end notification event. | def network_delete_end(self, payload):
self.disable_dhcp_helper(payload['network_id']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_IN_DELETE(self, event):",
"def _notify_delete(self, cuds_object):",
"def on_deleted(self, event):\n\n # the absolute path of the event file/folder\n abs_path = event.src_path\n # replace the root path with a '.' to build a relative path to be sent to server\n relative_ev... | [
"0.6687941",
"0.65360117",
"0.6504362",
"0.6332553",
"0.6319839",
"0.6128922",
"0.6042391",
"0.6031273",
"0.6013475",
"0.6010431",
"0.596033",
"0.59602207",
"0.59489894",
"0.58846825",
"0.58623254",
"0.58432305",
"0.5838188",
"0.58338237",
"0.58286065",
"0.5809571",
"0.579758... | 0.68294984 | 0 |
Handle the subnet.update.end notification event. | def subnet_update_end(self, payload):
network_id = payload['subnet']['network_id']
self.refresh_dhcp_helper(network_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_subnet_postcommit(self, context):\n if self.rpc_handler is None:\n return\n subnet = self._get_subnet_info(context._subnet)\n if subnet is not None:\n try:\n self.rpc_handler.update_subnet(subnet)\n except:\n pass",
"d... | [
"0.66729087",
"0.6600842",
"0.62174314",
"0.6109604",
"0.6024752",
"0.5942195",
"0.5750984",
"0.57237357",
"0.5659294",
"0.5652078",
"0.56508094",
"0.55938303",
"0.55554795",
"0.55497646",
"0.55028933",
"0.5502632",
"0.5420597",
"0.5417562",
"0.5396377",
"0.53416765",
"0.5335... | 0.7799576 | 0 |
Handle the subnet.delete.end notification event. | def subnet_delete_end(self, payload):
subnet_id = payload['subnet_id']
network = self.cache.get_network_by_subnet_id(subnet_id)
if network:
self.refresh_dhcp_helper(network.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_subnet_postcommit(self, context):\n if self.rpc_handler is None:\n return\n try:\n self.rpc_handler.delete_subnet({str(context._subnet.get('id', '')): {}})\n except:\n pass",
"def delete_subnet_postcommit(self, mech_context):\n LOG.debug(\"d... | [
"0.6993552",
"0.6756371",
"0.67003113",
"0.6559159",
"0.647308",
"0.6463808",
"0.6403783",
"0.63142115",
"0.6309298",
"0.62003213",
"0.57914406",
"0.5777481",
"0.57660466",
"0.57313883",
"0.57229215",
"0.565757",
"0.5645164",
"0.55317897",
"0.55291295",
"0.5499232",
"0.548507... | 0.7865546 | 0 |
Handle the port.update.end notification event. | def port_update_end(self, payload):
port = DictModel(payload['port'])
network = self.cache.get_network_by_id(port.network_id)
if network:
self.cache.put_port(port)
self.call_driver('reload_allocations', network) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_finish_event(self):\n self.status['type'] = '__end__'\n self._send()",
"def onMessageEnd(self):",
"def end(update: Update, context: CallbackContext) -> int:\n update.callback_query.answer()\n\n text = \"See you around!\"\n update.callback_query.edit_message_text(text=text)\n\n ... | [
"0.6465052",
"0.6250917",
"0.6206949",
"0.6200631",
"0.6087534",
"0.60749346",
"0.60135967",
"0.59975713",
"0.5883709",
"0.58819026",
"0.58666104",
"0.5856382",
"0.58052033",
"0.57543814",
"0.5744977",
"0.5744686",
"0.57377493",
"0.57021797",
"0.56638414",
"0.5663316",
"0.566... | 0.65497047 | 0 |
Handle the port.delete.end notification event. | def port_delete_end(self, payload):
port = self.cache.get_port_by_id(payload['port_id'])
if port:
network = self.cache.get_network_by_id(port.network_id)
self.cache.remove_port(port)
self.call_driver('reload_allocations', network) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_IN_DELETE(self, event):",
"def delete_port_postcommit(self, context):\n if self.rpc_handler is None:\n return\n port = self._get_port_info(context)\n if port is not None:\n try:\n self.rpc_handler.delete_port(port)\n except:\n ... | [
"0.6525613",
"0.65228605",
"0.646454",
"0.6217715",
"0.62165207",
"0.6130076",
"0.6126507",
"0.6012117",
"0.5925986",
"0.58993256",
"0.5834277",
"0.5791649",
"0.57853687",
"0.57846904",
"0.5774742",
"0.5691563",
"0.5691563",
"0.56881493",
"0.56836855",
"0.5662047",
"0.5659632... | 0.6916865 | 0 |
Make a remote process call to retrieve the active networks. | def get_active_networks(self):
return self.call(self.context,
self.make_msg('get_active_networks', host=self.host),
topic=self.topic) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_networks():\n return get_networks()",
"def list_net(self):\n _url = \"http://\" + self.host_ip + \":9696/v2.0/networks\"\n _headers = {'Content-type': 'application/json',\n 'x-auth-token': self.project_info[\"token_project\"]}\n _body = None\n\n response... | [
"0.657749",
"0.65077436",
"0.638325",
"0.6311575",
"0.61095214",
"0.5842249",
"0.57740545",
"0.5771512",
"0.5732876",
"0.5730552",
"0.57152635",
"0.571397",
"0.57076454",
"0.57016504",
"0.56785256",
"0.56415784",
"0.5635792",
"0.5630904",
"0.5617051",
"0.55758715",
"0.5521408... | 0.6694506 | 0 |
Make a remote process call to release the dhcp port. | def release_dhcp_port(self, network_id, device_id):
return self.call(self.context,
self.make_msg('release_dhcp_port',
network_id=network_id,
device_id=device_id,
host=sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def release_dhcp_port(self, network_id, device_id):\n LOG.debug(\"release_dhcp_port: %s %s\", network_id, device_id)",
"def dhcp_release(ifname):\n\n logging.debug('Releasing %s...', ifname)\n\n try:\n subprocess.call(['dhcpcd', '--release', ifname])\n except OSError, err:\n if err.... | [
"0.705921",
"0.6589862",
"0.580546",
"0.55769974",
"0.55496395",
"0.5542536",
"0.5490024",
"0.5460197",
"0.54363143",
"0.53853947",
"0.53727317",
"0.5369885",
"0.53608006",
"0.5334013",
"0.5265669",
"0.5128569",
"0.51262695",
"0.51248026",
"0.50996053",
"0.5078857",
"0.506425... | 0.6612475 | 1 |
Make a remote process call to release a fixed_ip on the port. | def release_port_fixed_ip(self, network_id, device_id, subnet_id):
return self.call(self.context,
self.make_msg('release_port_fixed_ip',
network_id=network_id,
subnet_id=subnet_id,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remote_kill():",
"def ReleasePort(self, *args, **kwargs):\n # type: (*Any, **Any) -> None\n payload = { \"Arg1\": self }\n for i in range(len(args)): payload['Arg%s' % (i + 2)] = args[i]\n for item in kwargs.items(): payload[item[0]] = item[1]\n return self._execute('releas... | [
"0.5751554",
"0.56354207",
"0.5619003",
"0.54908806",
"0.54209656",
"0.5399607",
"0.5373213",
"0.53657866",
"0.5338972",
"0.5337617",
"0.5322124",
"0.53005093",
"0.525492",
"0.51884073",
"0.5165239",
"0.5156112",
"0.51426136",
"0.51397544",
"0.51306945",
"0.511095",
"0.510230... | 0.6276679 | 0 |
Make a remote process call to update the ip lease expiration. | def update_lease_expiration(self, network_id, ip_address, lease_remaining):
self.cast(self.context,
self.make_msg('update_lease_expiration',
network_id=network_id,
ip_address=ip_address,
lease_remai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, *args):\n\n gmtexpires = None\n (name, ip, expires) = args[:3]\n\n for arg in args:\n if arg.lower().startswith('expires='):\n gmtexpires = arg[8:]\n\n if gmtexpires is None:\n if len(args) == 3:\n gmtexpires = expires... | [
"0.5781035",
"0.5655976",
"0.5412396",
"0.5290201",
"0.5213446",
"0.51987845",
"0.5019132",
"0.50062484",
"0.49905106",
"0.49797148",
"0.4976283",
"0.49701196",
"0.49448273",
"0.4910099",
"0.49022925",
"0.48599997",
"0.4854406",
"0.4850345",
"0.4835414",
"0.48195204",
"0.4783... | 0.63969594 | 0 |
Return interface(device) name for use by the DHCP process. | def get_interface_name(self, network, port=None):
if not port:
device_id = self.get_device_id(network)
port = self.plugin.get_dhcp_port(network.id, device_id)
return self.driver.get_device_name(port) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_interface_name():\n interface_name = ''\n interfaces = psutil.net_if_addrs()\n for name, details in interfaces.items():\n for detail in details:\n if detail.family == socket.AF_INET:\n ip_address = ipaddress.ip_address(detail.address)\n if not (ip_ad... | [
"0.7754688",
"0.7292888",
"0.72684246",
"0.7240329",
"0.72280574",
"0.71967864",
"0.7171746",
"0.7142047",
"0.701453",
"0.69190764",
"0.68561924",
"0.68412864",
"0.67124903",
"0.6670526",
"0.6562061",
"0.65597874",
"0.6453947",
"0.6371652",
"0.6349215",
"0.63410044",
"0.63398... | 0.73330253 | 1 |
Return a unique DHCP device ID for this host on the network. | def get_device_id(self, network):
# There could be more than one dhcp server per network, so create
# a device id that combines host and network ids
host_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, socket.gethostname())
return 'dhcp%s-%s' % (host_uuid, network.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_id(self):\n return self.unique_id",
"def device_id(self) -> str:\n return self._device_info[\"ID\"]",
"def get_device_id(self) -> str:\n return Config.get('device_id')",
"def device_id(self) -> Optional[str]:\n return self.relay(\"device_id\")",
"def device_id(self):\... | [
"0.73077106",
"0.7298454",
"0.72520554",
"0.71881825",
"0.7102662",
"0.7056606",
"0.704042",
"0.6955741",
"0.6934329",
"0.69141144",
"0.6878838",
"0.6839864",
"0.68147016",
"0.67973",
"0.6795465",
"0.6704469",
"0.6691843",
"0.6679224",
"0.66670865",
"0.66638803",
"0.6633019",... | 0.8490437 | 0 |
Destroy the device used for the network's DHCP on this host. | def destroy(self, network, device_name):
if self.conf.use_namespaces:
namespace = NS_PREFIX + network.id
else:
namespace = None
self.driver.unplug(device_name, namespace=namespace)
self.plugin.release_dhcp_port(network.id,
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy(self, context=None):\n self.dbapi.destroy_nic(self.uuid)\n self.obj_reset_changes()",
"def destroy_node(self):\n driver = self.driver\n driver.ex_detach_floating_ip_from_node(self.node, self.floating_ip)\n driver.destroy_node(self.node)\n sleep(15)\n f... | [
"0.63705355",
"0.6200864",
"0.6193805",
"0.6192019",
"0.61369485",
"0.6060995",
"0.60351926",
"0.59916675",
"0.59413284",
"0.5918379",
"0.5916078",
"0.5872993",
"0.5829491",
"0.58259064",
"0.5774636",
"0.5741544",
"0.5731216",
"0.57206935",
"0.57002115",
"0.5697077",
"0.56899... | 0.7568489 | 0 |
Validate value against a regular expression and return if valid. | def _validate_field(self, value, regex):
match = re.match(regex, value)
if match:
return value
raise ValueError(_("Value %s does not match regex: %s") %
(value, regex)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validator_regex(self, field, value):\n try:\n re.compile(value)\n except re.error:\n self._error(field, \"{} is not a valid regex\".format(value))",
"def string_validate_regular_expression(cls, value):\n if value is None:\n return value\n\n if not... | [
"0.7598519",
"0.75967777",
"0.75010866",
"0.7477238",
"0.7303168",
"0.7277673",
"0.7156195",
"0.687343",
"0.68461555",
"0.6806273",
"0.660515",
"0.65665877",
"0.64467674",
"0.64461094",
"0.63882786",
"0.6347836",
"0.63040394",
"0.6208035",
"0.6126982",
"0.6108813",
"0.6094763... | 0.7598315 | 1 |
Spawn a green thread to run the lease relay unix socket server. | def start(self):
listener = eventlet.listen(cfg.CONF.dhcp_lease_relay_socket,
family=socket.AF_UNIX)
eventlet.spawn(eventlet.serve, listener, self._handler) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n server = TCPServer((self.host, self.port), TCPHandler)\n server.lymphocytes_getter = self.lymphocytes_getter\n\n #runs forever - so make this thread daemon\n server.serve_forever()",
"def main():\n # Clear the terminal before a new run\n os.system('cls') \n\n... | [
"0.718199",
"0.6661798",
"0.6513136",
"0.64684916",
"0.637286",
"0.6361127",
"0.6353088",
"0.63464284",
"0.6327527",
"0.63006586",
"0.6287364",
"0.62497455",
"0.62400097",
"0.6211207",
"0.62012124",
"0.62009555",
"0.6200558",
"0.61990255",
"0.6187328",
"0.6142365",
"0.6077814... | 0.698998 | 1 |
Implements the Active Learning Scheme as seen in class. Returns a list of the first 10 chosen vectors in X_test | def ActiveLearning(X_train, X_test, lam=1, sigma2=1):
X = np.copy(X_train)
D = np.copy(X_test)
selected = []
n_features = X.shape[1]
I = np.identity(n_features)
# I[-1, -1] = 0
for i in xrange(10):
sigma02_max = float('-Inf')
idx_max = None
for idx in range(l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_impl_variational(in_train, in_test, labels):\n X_train = []\n X_test = []\n for lab in labels:\n for datum in in_train[lab]:\n X_train.append([datum, lab])\n for datum in in_test[lab]:\n X_test.append([datum, lab])\n Variationer_learn(X_train, 500, 1, 0.01, X_... | [
"0.6407244",
"0.6252256",
"0.61563945",
"0.6147052",
"0.6129238",
"0.61026",
"0.60756004",
"0.6071751",
"0.60336673",
"0.602746",
"0.60267353",
"0.60159856",
"0.5990562",
"0.59761053",
"0.59511435",
"0.5943814",
"0.59321856",
"0.5868017",
"0.58638775",
"0.5863876",
"0.5857149... | 0.6903305 | 0 |
Gets the filename of a track based off the headers of a url | def get_track_filename(self, url = None):
track_file = urllib.urlopen(url)
headers = track_file.info()
track_file.close()
return wget.filename_from_headers(headers) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_url_filename(url, headers=None, strip=[]):\n filename = get_url_disposition_filename(url, headers)\n if filename:\n return filename\n return get_url_straight_filename(url, strip=[])",
"def get_file_name(url: str):\n filename = os.path.basename(url)\n fname, extension = os.path.split... | [
"0.7299136",
"0.710809",
"0.68631077",
"0.684902",
"0.6672016",
"0.6661408",
"0.6651063",
"0.6625067",
"0.6586317",
"0.6574036",
"0.65387857",
"0.6461432",
"0.64488965",
"0.6422117",
"0.6405276",
"0.6404342",
"0.6381905",
"0.63627076",
"0.63227975",
"0.63170123",
"0.63093925"... | 0.80735415 | 0 |
Moves all tracks in the current folder to the ~/Music/ folder | def move_tracks_to_music_folder(self):
home = os.path.expanduser("~")
dest = home + "/Music/"
for each_file, artist in self.past_songs_db_data:
sub_folder = artist + "/" if artist != "" else ""
# possible race condition
if not os.path.exists(dest + sub_folder... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _do_move(self, artist, album, song):\n try:\n move_to = \"{0}{1}/{2}/\".format(self.dupe_dir, \n artist, album)\n if not os.path.exists(move_to):\n os.makedirs(move_to)\n \n shutil.move(song['pa... | [
"0.6169354",
"0.60723484",
"0.6025653",
"0.59947664",
"0.5966635",
"0.59113675",
"0.58590925",
"0.57916886",
"0.57881904",
"0.57249045",
"0.57191676",
"0.5678596",
"0.5565063",
"0.5562512",
"0.5485806",
"0.54774505",
"0.54692006",
"0.5413971",
"0.54099286",
"0.5391516",
"0.53... | 0.8270894 | 0 |
Download a track pointed at by the url given | def download_track(self, track = None, url = None):
# check that track doesn't exist
if url == None or track == None:
return
print "Retrieving the name of the track."
filename = self.get_track_filename(url)
print "Filename found: " + filename
if (fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_song(url, filename):\n page = requests.get(url, headers=HEADERS)\n if page.status_code == 200: # OK\n with open(filename, 'w') as outf:\n outf.write(page.text)\n else:\n print(f'download failed with status code {page.status_code}!')",
"def download_track(trackpath)... | [
"0.7309085",
"0.7252067",
"0.6934912",
"0.6847038",
"0.6825551",
"0.68067807",
"0.6724556",
"0.6714492",
"0.6657802",
"0.66412157",
"0.65748054",
"0.65468055",
"0.6545219",
"0.65393245",
"0.65367454",
"0.65257233",
"0.6506926",
"0.6446718",
"0.6434038",
"0.6421497",
"0.640676... | 0.7958018 | 0 |
Downloads the first songs from tracks/q= | def download_free_tracks_by_search(self, query='trapstep', limit=10):
tracks = self.client.get('tracks/', q=query, limit=limit)
for track in tracks:
if track.downloadable:
url = track.download_url + self.client_str
# print out some useful data
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_8tracks_songs(self):\n logging.info('getting tracks from 8tracks')\n API_KEY = '7fe2e057bb81abf2248a06ecab027b8dc09e01d3' \n self.info_var.set('\\n\\n Now playing 8Tracks Songs: \\n')\n\n api = Api(api_key=API_KEY)\n mixes = api.get_mixes(num_results=1)\n tr... | [
"0.6338008",
"0.62776303",
"0.62629706",
"0.6250336",
"0.61471456",
"0.6128437",
"0.60963446",
"0.60775757",
"0.6053801",
"0.6050617",
"0.6031621",
"0.6012589",
"0.6011378",
"0.6003287",
"0.5957437",
"0.5933667",
"0.5861777",
"0.5846252",
"0.5837947",
"0.58110344",
"0.5805988... | 0.67752016 | 0 |
Convert all .wav files to .mp3 files in the current folder | def all_wav_to_mp3(self):
for each_file, artist in self.past_songs_db_data:
self.convert_wav_to_mp3(each_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mp3_to_wav(show_progress=True):\n\n # Define a devnull var to supress subprocess output\n devnull = open(os.devnull, 'w')\n\n # Get a list of the filepath for each of the mp3 files in each subdirectory of data/fma_small\n file_list = glob.glob('./../data/fma_small/*/*.mp3')\n\n # Get the number ... | [
"0.74014467",
"0.7148263",
"0.6751976",
"0.6705585",
"0.66649914",
"0.6631666",
"0.6620781",
"0.6530281",
"0.65300494",
"0.6521014",
"0.65070164",
"0.64703506",
"0.6462281",
"0.63890207",
"0.6369542",
"0.6361365",
"0.63011235",
"0.62873816",
"0.62860155",
"0.61241585",
"0.612... | 0.8493313 | 0 |
Remove all leftover songs that could not be moved over because we already had a copy of it somehow | def delete_leftovers(self):
for each_file, artist in self.past_songs_db_data:
if os.path.isfile(each_file):
os.remove(each_file)
print "Deleted " + each_file
for each_file in os.listdir("."):
if each_file.endswith(".jpg"):
os.remo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move(self):\n for artist in self.audio_dict:\n for album in self.audio_dict[artist]:\n for songlist in self.audio_dict[artist][album]:\n if len(self.audio_dict[artist][album][songlist]) > 1:\n \n # track the song that... | [
"0.7379587",
"0.6529362",
"0.63871706",
"0.6352371",
"0.6054021",
"0.60165644",
"0.595798",
"0.5925949",
"0.58864945",
"0.58732814",
"0.58706284",
"0.58316857",
"0.58295476",
"0.57719314",
"0.573926",
"0.5734612",
"0.5715898",
"0.5702195",
"0.56977755",
"0.5672036",
"0.563202... | 0.66432697 | 1 |
Last minute cleaning up such as moving songs to ~/Music/ | def cleanup(self):
self.all_wav_to_mp3()
self.past_songs_db.close()
self.move_tracks_to_music_folder( )
self.delete_leftovers()
print "Cleanup finished" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_cleanup(self):\n self.past_songs_db.close()",
"def update():\n\tglobal songList\n\tglobal songs\n\tsongList=os.listdir(\"./music/\")\n\tsongs=['```']\n\tfor song in songList:\n\t\tif len(songs[-1])>1800:\n\t\t\tsongs[-1]+='```'\n\t\t\tsongs.append('```')\n\t\tif '.mp3' in song:\n\t\t\tsongs[-1]+=s... | [
"0.6738972",
"0.63275284",
"0.60766363",
"0.601346",
"0.5995643",
"0.59815437",
"0.5894408",
"0.5746696",
"0.57395715",
"0.5724052",
"0.5710683",
"0.5706564",
"0.56509155",
"0.5629594",
"0.5569479",
"0.55685073",
"0.55458707",
"0.55235755",
"0.5510457",
"0.5507455",
"0.550616... | 0.642854 | 1 |
Define a DDP process for SQuAD metric. | def _squad_score_ddp(rank, world_size, pred, targets, exact_match, f1):
os.environ["MASTER_ADDR"] = "localhost"
os.environ["MASTER_PORT"] = "12355"
dist.init_process_group("gloo", rank=rank, world_size=world_size)
squad_metric = SQuAD()
squad_metric.update(pred, targets)
metrics_score = squad_me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dunning_process_no(self, dunning_process_no):\n\n self._dunning_process_no = dunning_process_no",
"def dworker(self):\n\t\t\"\"\" {pid:{subkey:subvalue}} \"\"\"\n\t\t\"\"\" line colors in use: black, blue, red\"\"\"\n\t\t\"\"\" fill colors in use: cyan, yellow, orange, red\"\"\"\n\t\tif self.pslist:... | [
"0.5505989",
"0.5426503",
"0.53447145",
"0.53441024",
"0.53260225",
"0.49359587",
"0.4927588",
"0.49224964",
"0.49179453",
"0.49071914",
"0.49071893",
"0.49060753",
"0.4902909",
"0.48797745",
"0.48461652",
"0.48392186",
"0.47885707",
"0.4779368",
"0.4768873",
"0.47611788",
"0... | 0.56313103 | 0 |
Perform MUSIC at frequency freqs[idx] | def music(idx, n_music=200):
f = freqs[idx]
Rxx = np.dot(X[:, idx], X[:, idx].H)
lam, V = eig_sorted(Rxx)
En = V[:, 1:] # Noise subspace for one source
theta_range = np.linspace(0, 2*np.pi, n_music)
P_music = np.zeros(n_music)
for i in range(n_music):
sv = ma.steering_vector(theta_r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyze2(ys, freqs, ts):",
"def update_frequencies():\n pass",
"def setfreqs(self, freqs):\n self.fm_freq, self.hfm_freq, self.sv_freq = freqs[0], freqs[1], freqs[2]",
"def freq_at_octave(freq_at_zero, target_octave):\n target_frequency = 0\n\n if target_octave<0:\n b = (target_oct... | [
"0.60125726",
"0.59969664",
"0.56162065",
"0.55160475",
"0.54664046",
"0.54283315",
"0.531813",
"0.53076774",
"0.52961713",
"0.5284241",
"0.52565277",
"0.51878655",
"0.51857436",
"0.5162814",
"0.51619595",
"0.5161843",
"0.51594913",
"0.5150779",
"0.5132257",
"0.5115299",
"0.5... | 0.6406316 | 0 |
Center the ava on the screen. | def center_ava(self):
self.rect.midbottom = self.screen_rect.midbottom
self.x = float(self.rect.x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def center_mario(self):\n self.rect.midbottom = self.screen_rect.midbottom\n self.x, self.y = float(self.rect.x), float(self.rect.y)",
"def center(self):\n self.root.update_idletasks()\n w = self.root.winfo_screenwidth()\n h = self.root.winfo_screenheight()\n size = tupl... | [
"0.7571731",
"0.7510738",
"0.7266956",
"0.72459733",
"0.7204455",
"0.70775634",
"0.70301646",
"0.68635684",
"0.68635684",
"0.6860699",
"0.6833622",
"0.6829853",
"0.6808482",
"0.6786134",
"0.67701036",
"0.6770095",
"0.6681063",
"0.66643727",
"0.66643727",
"0.66412467",
"0.6638... | 0.8325066 | 0 |
Calculate received signal power received from another transmitter according to Friis transmission formula (free space). This can be substituted with a more accurate formula later on. CALCULATION IS DONE FROM THE RECEIVER PERSPECTIVE. i.e. The object calling the function. | def calculate_signal_power(self, sender, freq_range):
distance = np.sqrt(
np.power(self.x - sender.x, 2) + np.power(self.y - sender.y, 2))
avg_frequency = np.average(freq_range) * 1e6
wavelength = settings.speed_of_light / avg_frequency
received_signal_power = (
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calcPower(self, inputs):\n if self.getAtt('available', inputs):\n possible_charge_rate = self.getAtt('possible_charge_rate', inputs)\n Vm = self.getAtt('Vm', inputs)\n P = possible_charge_rate * Vm\n if not self.stayConnected:\n P = P * self.cal... | [
"0.61260206",
"0.5782018",
"0.57050014",
"0.56360364",
"0.5605495",
"0.55946743",
"0.55897003",
"0.55162644",
"0.55079454",
"0.5502509",
"0.54827815",
"0.54756224",
"0.5474993",
"0.5459773",
"0.54442394",
"0.54292107",
"0.5421081",
"0.5417615",
"0.5400089",
"0.5396992",
"0.53... | 0.71575606 | 0 |
Calculate the received power from each possible base_station to determine who we can communicate with. Can also be used to refresh the list if a nreaby station switches frequency and thus turns invisible. | def update_base_stations_in_range(self, base_station_list):
self.base_stations_in_range = []
for station in base_station_list:
# Don't compare a base station with itself
if station != self:
for freq_range in station.currently_used_frequencies:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def power_list():",
"def kick_all_passengers(self):\n\n changed_lines = self.__stations_dict.keys()\n for line in changed_lines:\n if line in self.__bus_dict:\n self.__message_sender.send_line(line, update_passengers=True)\n self.__stations_dict = {}",
"def open_a... | [
"0.5736611",
"0.5622538",
"0.56059015",
"0.54758173",
"0.5434806",
"0.5361476",
"0.5348425",
"0.5299765",
"0.5280472",
"0.52715003",
"0.52699375",
"0.5267048",
"0.52638125",
"0.5251505",
"0.5237092",
"0.5202273",
"0.51876175",
"0.51876175",
"0.5160817",
"0.515068",
"0.5136238... | 0.6616486 | 0 |
add a line to a SVG group | def addToGroup(self, frontorback, drawing, svggroup, **extra):
super(byA_FB_SideLine, self).addToGroup(drawing, svggroup, **extra) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_svg_line(points_list, parent, style):\n line_attribs = {'style': simplestyle.formatStyle(style),\n inkex.addNS('label', 'inkscape'): 'line',\n 'd': to_path_string(points_list, False)}\n\n inkex.etree.SubElement(parent, inkex.addNS('path', 'svg'), line_attribs)",... | [
"0.6765925",
"0.6018009",
"0.5968184",
"0.5929282",
"0.59292215",
"0.58818865",
"0.5871255",
"0.58446777",
"0.58432126",
"0.5815739",
"0.5812686",
"0.57987815",
"0.57962376",
"0.57535255",
"0.575127",
"0.57409406",
"0.571864",
"0.56766874",
"0.56713814",
"0.5660027",
"0.56500... | 0.7344968 | 0 |
Fetches new github commits | async def fetch_commits(self):
for repo in self.config['repos'].split(','):
since = datetime.min
async for msg in self.channel.history(limit=None):
if not msg.embeds:
continue
e = msg.embeds[0]
if e.title == 'github comm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch():\n project = get_project(require=True)\n resp = request('post', '/api/v0/projects/{id}/fetch/'.format(id=project.id))\n data = resp.json()\n commits = data.get('commits', ())\n if commits:\n for commit in commits:\n success('Fetched: {ref} ({identifier})'.format(ref=com... | [
"0.75750375",
"0.74212277",
"0.69381",
"0.64448285",
"0.6438989",
"0.64219135",
"0.64179325",
"0.6414816",
"0.64099866",
"0.6344521",
"0.6343075",
"0.6340277",
"0.6335508",
"0.63086504",
"0.6268753",
"0.6132046",
"0.6079412",
"0.60743535",
"0.5987012",
"0.59716344",
"0.595498... | 0.7687702 | 0 |
Return True if the number it was passed is an odd number. Return False if the number it was passed is an even number. | def is_odd(number):
return number % 2 != 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_odd(number: int) -> bool:\n return number % 2 != 0",
"def is_odd(number):\n return (number%2)==1",
"def is_odd(n):\n if n % 2:\n return True\n else:\n return False",
"def is_odd(x):\n return x % 2 != 0",
"def isOdd (n):\n if type(n) != int:\n return False\n ... | [
"0.8910139",
"0.88778764",
"0.86567736",
"0.85502493",
"0.84932417",
"0.8464938",
"0.84520775",
"0.8422581",
"0.83795774",
"0.835107",
"0.8337976",
"0.83243823",
"0.8289874",
"0.8273915",
"0.8243354",
"0.82220197",
"0.8118846",
"0.8059153",
"0.79635155",
"0.7933069",
"0.79226... | 0.8937428 | 0 |
>>> do_duration(8000) '0 day, 2 hours, 0 minutes, 0 seconds' | def do_duration(seconds):
m, s = divmod(seconds, 60)
h, m = divmod(m, 60)
d, h = divmod(h, 24)
tokens = []
tokens.append(one_many(d, '{d} day'))
tokens.append(one_many(h, '{h} hour'))
tokens.append(one_many(m, '{d} minute'))
tokens.append(one_many(s, '{d} second'))
template = ', '.jo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def say_duration(duration):\r\n result = []\r\n for d in ['day', 'hour', 'minute', 'second']:\r\n if duration[d] == 1:\r\n result.append(\"{0} {1}\".format(duration[d], d))\r\n if duration[d] > 1:\r\n result.append(\"{0} {1}s\".format(duration[d], d))\r\n if result:\r\n... | [
"0.79546064",
"0.785983",
"0.74646884",
"0.7433196",
"0.72565824",
"0.7216425",
"0.7124735",
"0.7037477",
"0.6948589",
"0.6943271",
"0.67773587",
"0.6773942",
"0.6714449",
"0.6675341",
"0.66656",
"0.6648351",
"0.6636749",
"0.6618495",
"0.6604794",
"0.66005135",
"0.6571271",
... | 0.7955701 | 0 |
>>> one_many(1, '{d} day') '{d} day' >>> one_many(2, '{d} day') '{d} days' | def one_many(number, str_duration):
return str_duration + 's' if number > 1 else str_duration | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_many1(self):\n\n xs = t.Many1(t.Exactly(\"x\"))\n self.assertEqual(writePython(xs),\n dd(\"\"\"\n def _G_many1_1():\n _G_exactly_2, lastError = self.exactly('x')\n self.considerEr... | [
"0.57898444",
"0.5183852",
"0.49592152",
"0.4934458",
"0.49110043",
"0.4846958",
"0.4706555",
"0.4673666",
"0.45450735",
"0.45241177",
"0.45239285",
"0.44858345",
"0.4443756",
"0.44393557",
"0.44370747",
"0.44303963",
"0.44048327",
"0.44039005",
"0.4373759",
"0.43677723",
"0.... | 0.6458752 | 0 |
move to nav item | def move_to_nav(self,num=2):
self.move_to_element("xpath->//ul[@id='headerNav']/li[%s]" % num) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_menu_item(self, name):\n from modules.pages.contact_us_page import ContactUsPage\n menu_pages = {UIC.MENU_PLATFORM: PlatformPage,\n UIC.MENU_SOLUTIONS: SolutionsPage,\n UIC.MENU_ABOUT_US: AboutUsPage,\n UIC.MENU_CONTACT_US: Conta... | [
"0.63784087",
"0.623346",
"0.6048475",
"0.5944718",
"0.5752141",
"0.57504153",
"0.5703136",
"0.569433",
"0.5674312",
"0.56644297",
"0.56479615",
"0.5613031",
"0.56083614",
"0.5589197",
"0.55327857",
"0.5519775",
"0.5515736",
"0.54966897",
"0.54966897",
"0.54966897",
"0.549668... | 0.7308112 | 0 |
click and get nav item | def click_nav(self,num=2):
self.click("xpath->//ul[@id='headerNav']/li[%s]" % num) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sidebar_click(sidebar_item):\n #print('sidebar_click')\n sidebar = driver.find_element_by_class_name('m-menu__nav')\n return click_on(sidebar_item, scope=sidebar)",
"def get_menu_item(menu_item_name):\n\n pass",
"def getMenuItem(self, event):\n return self.GetMenuBar().FindItemById(event.Get... | [
"0.6431703",
"0.6209024",
"0.60301465",
"0.588942",
"0.5877723",
"0.58067155",
"0.57894486",
"0.57894486",
"0.5783159",
"0.56954354",
"0.5683426",
"0.56516695",
"0.5601901",
"0.55922246",
"0.5554369",
"0.55407244",
"0.549524",
"0.5475049",
"0.5438124",
"0.5397154",
"0.5391862... | 0.6951613 | 0 |
Constructs the parent path of the folder where the files of this class are held | def _get_parent_path(self):
return os.path.join(os.getcwd(), "src", "data", "genes") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_dir(self):\n parent = os.path.dirname(self.dirn)\n if self.is_subdir:\n parent = os.path.basename(parent)\n else:\n if self.platform is not None and parent.endswith(self.platform):\n parent = parent[:-len(self.platform)].rstrip(os.sep)\n ... | [
"0.7516042",
"0.7425503",
"0.7233814",
"0.7187311",
"0.708849",
"0.70793384",
"0.6989474",
"0.6972251",
"0.6928673",
"0.68959326",
"0.68793297",
"0.6850787",
"0.68455803",
"0.6822468",
"0.68000185",
"0.67682356",
"0.6768187",
"0.6763842",
"0.67598325",
"0.67461765",
"0.673264... | 0.81032115 | 0 |
Constructs and returns the gene file paths | def _get_gene_file_path(self):
return os.path.join(os.getcwd(), "src", "data", "genes", "genes.txt") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genome_paths(self, ext=\"fasta\"):\n return [\n os.path.join(self.path, genome)\n for genome in os.listdir(self.path)\n if genome.endswith(ext)\n ]",
"def setup_filepaths():\n if organism == 'cerevisiae':\n biogridpath = os.path.join('..', 'data', \n ... | [
"0.6801986",
"0.6463004",
"0.63174415",
"0.6131427",
"0.6107057",
"0.59613675",
"0.59605056",
"0.5920906",
"0.58928406",
"0.5882822",
"0.58670783",
"0.5866723",
"0.58401537",
"0.58361024",
"0.5833032",
"0.5823612",
"0.58002096",
"0.5796087",
"0.5743622",
"0.5667002",
"0.56579... | 0.75735086 | 0 |
Loads the genes into the class gene_ids | def _load_genes(self):
with open(self.gene_file_path, 'r') as gene_file:
csv_reader = csv.reader(gene_file, delimiter=',')
for gene in csv_reader:
yield (gene[self.GENE_NAME_IDX], gene[self.GENE_ID_IDX]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_gene_ids(self, genes_list):\n orig_num_genes = len(self.genes)\n\n for g in list(set(genes_list)):\n if not self.genes.has_id(g):\n new_gene = GenePro(id=g, pdb_file_type=self.pdb_file_type, root_dir=self.genes_dir)\n if self.model:\n ... | [
"0.66729474",
"0.66438574",
"0.66160977",
"0.6368416",
"0.6222823",
"0.616151",
"0.60341156",
"0.5939436",
"0.5897515",
"0.5890509",
"0.58519554",
"0.58203644",
"0.57946724",
"0.57890147",
"0.57806593",
"0.5742939",
"0.57355374",
"0.5728091",
"0.57230425",
"0.571332",
"0.5696... | 0.7522899 | 0 |
Builds the file path to the organisms file of the given gene name and ID | def _get_organisms_file_path(self, gene_name, gene_id):
return os.path.join(os.getcwd(), "src", "data", "organisms", "{}_{}.txt".format(gene_name, gene_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_gene_file_path(self):\n return os.path.join(os.getcwd(), \"src\", \"data\", \"genes\", \"genes.txt\")",
"def get_organisms_genes(self):\n path = os.path.join(self.parent_path, \"organisms_genes.txt\")\n with open(path, \"w\") as freqs:\n freqs.write(\"Organism,Genes\\n\")... | [
"0.5999423",
"0.59490174",
"0.5756022",
"0.56829166",
"0.56753504",
"0.5670816",
"0.5629179",
"0.56172353",
"0.56054807",
"0.55734795",
"0.55691856",
"0.5535874",
"0.54451907",
"0.54241616",
"0.53895986",
"0.53739434",
"0.5357763",
"0.53570634",
"0.5334147",
"0.5289614",
"0.5... | 0.8304314 | 0 |
Responsible for loading all the organisms curated for the list of genes of interest. Builds and returns two maps one mapping each organism to its genes and one mapping each gene to its organisms | def _load_orgs_and_genes(self):
organisms = {}
genes = {}
for gene in self.gene_ids:
org_file_path = self._get_organisms_file_path(gene[self.GENE_NAME_IDX], gene[self.GENE_ID_IDX])
with open(org_file_path, "r") as orgs:
org = orgs.read().splitlines()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_organisms_genes(self):\n path = os.path.join(self.parent_path, \"organisms_genes.txt\")\n with open(path, \"w\") as freqs:\n freqs.write(\"Organism,Genes\\n\")\n for org, data in self.organisms.items():\n genes = \"\"\n for gene in data.get(... | [
"0.7257849",
"0.6969675",
"0.65355396",
"0.59686047",
"0.59212977",
"0.5901838",
"0.5866191",
"0.5773964",
"0.5670796",
"0.5636288",
"0.56034166",
"0.55489737",
"0.5502659",
"0.54966867",
"0.54793173",
"0.5463934",
"0.54597753",
"0.5455461",
"0.5452701",
"0.54415894",
"0.5440... | 0.8302835 | 0 |
Builds a file containing the gene frequencies of each organism | def get_gene_frequencies(self):
path = os.path.join(self.parent_path, "gene_frequencies.txt")
with open(path, "w") as freqs:
freqs.write("Organism,Gene Frequency\n")
for org, data in self.organisms.items():
freqs.write("{},{}\n".format(org, data.get(self.FREQ_KEY)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_organisms_genes(self):\n path = os.path.join(self.parent_path, \"organisms_genes.txt\")\n with open(path, \"w\") as freqs:\n freqs.write(\"Organism,Genes\\n\")\n for org, data in self.organisms.items():\n genes = \"\"\n for gene in data.get(... | [
"0.6712296",
"0.629522",
"0.6098355",
"0.60669476",
"0.599409",
"0.5991727",
"0.59792763",
"0.5972482",
"0.59362316",
"0.59301496",
"0.5923917",
"0.5902305",
"0.587066",
"0.5810633",
"0.5787571",
"0.57831913",
"0.57830215",
"0.57779163",
"0.57060593",
"0.5686999",
"0.56859577... | 0.8010384 | 0 |
Builds a file containing which organisms a gene appears in | def get_genes_organisms(self):
path = os.path.join(self.parent_path, "genes_organisms.txt")
with open(path, "w") as f:
f.write("Gene,Organisms\n")
for gene in self.genes.keys():
f.write("{},{}".format(gene, "/".join(self.genes.get(gene).keys()) + "\n")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_organisms_genes(self):\n path = os.path.join(self.parent_path, \"organisms_genes.txt\")\n with open(path, \"w\") as freqs:\n freqs.write(\"Organism,Genes\\n\")\n for org, data in self.organisms.items():\n genes = \"\"\n for gene in data.get(... | [
"0.794365",
"0.67426956",
"0.66816664",
"0.6313496",
"0.6175617",
"0.6159461",
"0.60158247",
"0.5918782",
"0.59116703",
"0.5909354",
"0.58925825",
"0.58855027",
"0.5876534",
"0.5863022",
"0.5852412",
"0.5731719",
"0.5703419",
"0.565085",
"0.56269586",
"0.56260884",
"0.5610541... | 0.7951638 | 0 |
Builds a file containing the genes exhibited by each organism | def get_organisms_genes(self):
path = os.path.join(self.parent_path, "organisms_genes.txt")
with open(path, "w") as freqs:
freqs.write("Organism,Genes\n")
for org, data in self.organisms.items():
genes = ""
for gene in data.get(self.GENE_IDS_KEY):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_genes_organisms(self):\n path = os.path.join(self.parent_path, \"genes_organisms.txt\")\n with open(path, \"w\") as f:\n f.write(\"Gene,Organisms\\n\")\n for gene in self.genes.keys():\n f.write(\"{},{}\".format(gene, \"/\".join(self.genes.get(gene).keys()... | [
"0.6994183",
"0.62892514",
"0.61515087",
"0.606735",
"0.6034793",
"0.6006025",
"0.6001628",
"0.58848614",
"0.5883449",
"0.5781529",
"0.5773816",
"0.57700855",
"0.5767919",
"0.57626975",
"0.5721481",
"0.57126635",
"0.57104987",
"0.57042205",
"0.5698435",
"0.56948847",
"0.56536... | 0.7444359 | 0 |
Returns the split organism name as (genus, species) | def _parse_organism_name(self, org):
split_org = org.split()
return split_org[0], split_org[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _format_organism_info(self, org, info):\n species_idx = 1\n split_org = self._parse_organism_name(org)\n return \",\".join(info.replace(\";\", \"\").split()) + \",{}\\n\".format(split_org[species_idx])",
"def get_species_name(fasta):\n name = fasta.description\n if ',' in name:\n ... | [
"0.646665",
"0.6447309",
"0.6158343",
"0.6056546",
"0.60517704",
"0.60313845",
"0.59915733",
"0.58163685",
"0.58135873",
"0.5806952",
"0.5765122",
"0.57254785",
"0.5696996",
"0.56775403",
"0.5658982",
"0.5649861",
"0.5647005",
"0.5640148",
"0.56336176",
"0.56233454",
"0.56070... | 0.6820799 | 0 |
Creates a nicely formatted string to add to organisms.txt | def _format_organism_info(self, org, info):
species_idx = 1
split_org = self._parse_organism_name(org)
return ",".join(info.replace(";", "").split()) + ",{}\n".format(split_org[species_idx]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_formatted_string(self):\n string = NALSyntax.StatementSyntax.Start.value + \\\n self.get_subject_term().get_formatted_string()\n\n string += \" \" + self.get_copula_string() + \" \"\n\n string += self.get_predicate_term().get_formatted_string() + \\\n NALSyntax.... | [
"0.5992396",
"0.59910434",
"0.5967836",
"0.59130067",
"0.58954525",
"0.5876477",
"0.585665",
"0.5854676",
"0.5846432",
"0.5830909",
"0.5823335",
"0.5782792",
"0.57779396",
"0.5777004",
"0.5766911",
"0.5761065",
"0.5758965",
"0.5752614",
"0.5749041",
"0.5735354",
"0.57322717",... | 0.67078245 | 0 |
Viterbi derivation using the MaxTimes semiring. | def viterbi_derivation(forest, tsort, omega=lambda e: e.weight, generations=10, node_values=None, edge_values=None):
root = tsort.root()
if node_values is None:
node_values = compute_values(forest, tsort, semiring=MaxTimes, omega=omega, infinity=generations)
d = sample_one(forest, root,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deriv(self, t: float, endBehavior: str = 'halt') -> Vector:\n return self.deriv_state(t,endBehavior)",
"def derv(self, t, y):\n x = y[0];\n xc = y[1];\n n = y[2];\n\n Bhat = self.G * (1.0 - n) * self.alpha0(t) * (1 - 0.4 * x) * (1 - 0.4 * xc);\n\n dydt = np.zeros(3)\... | [
"0.58219033",
"0.56157297",
"0.5590959",
"0.55673176",
"0.5501021",
"0.54774886",
"0.545786",
"0.543763",
"0.54316425",
"0.5418838",
"0.54103255",
"0.53980565",
"0.53941154",
"0.5382634",
"0.5382634",
"0.53287655",
"0.5307189",
"0.5275985",
"0.52446187",
"0.5242827",
"0.52337... | 0.5901211 | 0 |
care for if speaker id is b the lines will be returned from the last to the first | def getLines(self):
f = open(self.__father.getpath() + self.__father.getidFile() + ".TRN", "r")
lines = f.readlines()
subUnitLines = []
if self.__speakerId == "A":
for line in lines:
if self.__speakerId == line.split("-")[-2]:
subUnitLines... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def speaker_sequence(self, speaker_id, n):\n seq = []\n for i in range(n):\n seq.append(speaker_id)\n speaker_id = self.after(speaker_id)\n return seq",
"def transcript_lines(transcript_text):\n lines = []\n for line in transcript_text.splitlines():\n if li... | [
"0.5758805",
"0.5695762",
"0.52602303",
"0.5214662",
"0.52095467",
"0.51924115",
"0.5182535",
"0.4993569",
"0.4979",
"0.49647054",
"0.49508744",
"0.49474433",
"0.49418852",
"0.49197292",
"0.48420635",
"0.48403987",
"0.48385614",
"0.4829934",
"0.4820813",
"0.48027512",
"0.4756... | 0.59322 | 0 |
This opens a native dialog where the user can select the file to open. It is possible to set the initial folder and only show files with specified file extensions. If no path is returned (eg. dialog is canceled), a ValueError is raised. | def open_file_dialog(self, title, initial_directory=None, file_types=None, multiselect=False):
return self._impl.open_file_dialog(title, initial_directory, file_types, multiselect) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fileDialog(*args, application: bool=True, defaultFileName: AnyStr=\"\", directoryMask:\n AnyStr=\"\", mode: int=0, title: AnyStr=\"\", **kwargs)->AnyStr:\n pass",
"def ask_file(message=\"Select file for open.\", title=None):\n return dialog(\"ask_file\", message=message, title=title)",
... | [
"0.76149505",
"0.75887764",
"0.7514204",
"0.7512995",
"0.7493741",
"0.74327594",
"0.7362546",
"0.7331848",
"0.7299773",
"0.72536474",
"0.72374344",
"0.71717244",
"0.7113339",
"0.7035079",
"0.7017773",
"0.701149",
"0.6960194",
"0.69411033",
"0.6916474",
"0.68990165",
"0.688893... | 0.7920909 | 0 |
Parse a Card Object from it's string representation | def from_string(string):
if len(string) == 2:
value = string[0]
elif len(string) == 3:
value = string[:2]
else:
raise ValueError(f"cannot parse card from {repr(string)} invalid length")
suit = string[-1]
if (value not in STRING_TO_VALUE_MAPP... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_card_representation(cards_string):\n cards_string = cards_string.split()\n cards = list()\n for card in cards_string:\n if len(card) != 2:\n raise Exception(\"The card should be represented by 2 characters,\"\n \" got '%s'\" % cards_string)\n n... | [
"0.74304885",
"0.65599",
"0.6112448",
"0.6071192",
"0.59783554",
"0.5888686",
"0.58846676",
"0.58517516",
"0.58509004",
"0.58192426",
"0.5787652",
"0.5740318",
"0.57373387",
"0.570132",
"0.56658304",
"0.5659433",
"0.5654869",
"0.5651489",
"0.5650546",
"0.5644746",
"0.56178224... | 0.68890905 | 1 |
Sorts the list using selection sort algorithm and draws rectangles representing items in the list as they are being sorted | def selection_sort(master, canvas, user_list):
for i in range(len(user_list)):
low = find_min(i, user_list)
canvas.delete(user_list[i].object)
canvas.delete(user_list[low].object)
user_list[i], user_list[low] = user_list[low], user_list[i]
user_list[i].iteration = i
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_sorting(self):\n if self.sorting:\n return None\n self.sorting = True\n\n passes = 0\n while self.sorting:\n swap_done = False\n for i in range(len(self.sort_list)-passes-1):\n if not self.sorting:\n break\n ... | [
"0.7300899",
"0.6371467",
"0.62282383",
"0.6223536",
"0.60836124",
"0.5974031",
"0.59525186",
"0.5950724",
"0.594177",
"0.5894374",
"0.58508456",
"0.5846683",
"0.5834884",
"0.57782805",
"0.56923485",
"0.56752694",
"0.56744236",
"0.5661119",
"0.5657958",
"0.56299466",
"0.55952... | 0.72284585 | 1 |
Generate a presigned URL to share an S3 object | def create_presigned_url(bucket_name, object_name, expiration=3600):
# Generate a presigned URL for the S3 object
s3_client = boto3.client('s3')
try:
response = s3_client.generate_presigned_url('get_object',
Params={'Bucket': bucket_name,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_presigned_url(bucket_name, object_name):\n\n logger = logging.getLogger(\"SimpleReplayLogger\")\n\n s3_client = boto3.client('s3')\n try:\n response = s3_client.generate_presigned_url('get_object',\n Params={'Bucket': bucket_name,\n ... | [
"0.7818953",
"0.7756839",
"0.7680877",
"0.7658545",
"0.7651632",
"0.76490694",
"0.7647379",
"0.7646296",
"0.7609004",
"0.75697136",
"0.7361706",
"0.7353515",
"0.73297143",
"0.73094666",
"0.7162048",
"0.7113277",
"0.70949465",
"0.70596546",
"0.70513654",
"0.7022255",
"0.700629... | 0.7818621 | 1 |
functions for locating See more button | def more_locator(_driver):
try:
return _driver.find_element_by_xpath("//*[contains(text(), 'See more…')]")
except NoSuchElementException:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_more(self):\r\n delay = WebDriverWait(driver, 5)\r\n try:\r\n ReadMore = delay.until(EC.element_to_be_clickable((By.XPATH, \".//div[@id='see_more_pager']//a[.= 'Lihat Hasil Selanjutnya'] \")))\r\n ReadMore.click()\r\n except:\r\n try:\r\n ... | [
"0.6972957",
"0.6555716",
"0.6488462",
"0.6173499",
"0.59232634",
"0.5862868",
"0.57194096",
"0.5612491",
"0.5565677",
"0.55015326",
"0.5480151",
"0.5463297",
"0.545471",
"0.53935736",
"0.536783",
"0.5345891",
"0.5345891",
"0.5345747",
"0.5338047",
"0.53297263",
"0.5320559",
... | 0.6985485 | 0 |
functions for locating view previous comments button | def get_view_previous_locator(_driver):
try:
return _driver.find_element_by_xpath("[//*contains(text(), 'View previous comments…')]") # click on the all likes button
except NoSuchElementException:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_newerButton_clicked(self):\n self.emit(SIGNAL(\"RT_PREVIOUS_PAGE\"))\n self.recordings_table.previous_page()",
"def goToPrevLink():\n if wikiPageStackTrace[-2].getUrl() != \"\":\n oldpage = wikiPageStackTrace[-2]\n print(\"going back to \", oldpage.getUrl())\n titleSt... | [
"0.63999635",
"0.6229458",
"0.6188741",
"0.61624897",
"0.6152052",
"0.61115634",
"0.61050904",
"0.6056724",
"0.6038701",
"0.60287166",
"0.6002199",
"0.59552276",
"0.59492135",
"0.5937468",
"0.5932675",
"0.5875313",
"0.58588034",
"0.57771254",
"0.57758397",
"0.57466596",
"0.56... | 0.8138847 | 0 |
functions to get all likes from a profile | def get_profile_like(_driver, _list, _url_list):
_profile_likes = {} # the dictionary that will be returned
_profile_likes_link = {} # the dictionary that will be returned
_iterator = 0 ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_likes_list(self, username):\n api = self.api\n api.searchUsername(username) \n result = api.LastJson\n username_id = result['user']['pk'] #Gets the user ID\n user_posts = api.getUserFeed(username_id) # gets the user feed\n result = api.LastJ... | [
"0.74523973",
"0.71441996",
"0.70038176",
"0.69108814",
"0.65068454",
"0.6474756",
"0.6470523",
"0.6401759",
"0.6154338",
"0.60858333",
"0.6062518",
"0.60425067",
"0.6031918",
"0.6021784",
"0.6018701",
"0.6011559",
"0.5982903",
"0.59462446",
"0.59377456",
"0.5909088",
"0.5864... | 0.74887204 | 0 |
Obtain an already existing role by name. | def get_role(self, name):
role = Role.query.filter_by(name=name).first()
return role | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_role(self, name):\n return self.get_session.query(self.role_model).filter_by(name=name).one_or_none()",
"def add_role(self, name: str) -> Role:\n role = self.find_role(name)\n if role is None:\n try:\n role = self.role_model()\n role.name = n... | [
"0.7971437",
"0.7701981",
"0.7430029",
"0.703435",
"0.70338243",
"0.69480044",
"0.69093156",
"0.6837286",
"0.681024",
"0.6779084",
"0.6697857",
"0.66930133",
"0.6656174",
"0.6632345",
"0.66156006",
"0.65896815",
"0.6546114",
"0.64989406",
"0.6493643",
"0.6383804",
"0.63724315... | 0.8464865 | 0 |
Obtain an already existing work_role by name. | def get_by_name(self, wk_name):
work_role = WorkRole.query.filter_by(name=wk_name).first()
return work_role | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_role(self, name):\n role = Role.query.filter_by(name=name).first()\n\n return role",
"def find_role(self, name):\n return self.get_session.query(self.role_model).filter_by(name=name).one_or_none()",
"def getRole(self, desired=None):\n strDes = str(desired)\n logging.d... | [
"0.7431634",
"0.6837368",
"0.67848325",
"0.6762558",
"0.660631",
"0.62866944",
"0.62622374",
"0.62396514",
"0.6143732",
"0.6113006",
"0.6096055",
"0.6083803",
"0.6011852",
"0.6007633",
"0.6004311",
"0.5992287",
"0.59689313",
"0.59653145",
"0.59629005",
"0.59433794",
"0.588360... | 0.84311515 | 0 |
Returns a uniform random choice weighted by the given key. By default, returns a uniform random choice. Setting a key function allows you to make values more or less probable of being selected. key must be a function that takes a value as an input and produces a number. | def weighted_choice(*values, **kwargs):
key = kwargs.get('key', lambda x: 1.0)
if len(values) == 1:
values = values[0]
if len(values) == 0:
raise TypeError('weighted_choice expected 1 arguments, got 0')
weights = [key(v) for v in values]
s = sum(weights)
r = random.random() * s
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weighted_choice(self, probabilities, key):\n\n total = sum(x[0] for x in probabilities)\n choice = total * self._random(key)\n\n for probability, option in probabilities:\n choice -= probability\n if choice <= 0:\n return option",
"def produce(self,ke... | [
"0.73207504",
"0.7023441",
"0.6776325",
"0.64262414",
"0.62520885",
"0.622769",
"0.62076044",
"0.6154212",
"0.5923212",
"0.59212774",
"0.5869574",
"0.5830715",
"0.58210284",
"0.5804789",
"0.56895596",
"0.56779647",
"0.56489563",
"0.5636762",
"0.56251335",
"0.5617317",
"0.5609... | 0.7385043 | 0 |
Set the nested named attribute on the given object to the specified value by a `.` separated name. set_nested_attr(x, 'y.z', v) is equivalent to setattr(getattr(x, 'y'), 'z', v) x.y.z = v. | def set_nested_attr(__obj: object, __name: str, __value: Any):
pre, _, post = __name.rpartition('.')
return setattr(get_nested_attr(__obj, pre) if pre else __obj, post, __value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setattr_nested(obj, attributes, value):\n pre, _, post = attributes.rpartition(\".\")\n setattr(getattr_nested(obj, pre) if pre else obj, post, value)",
"def set_attribute(obj, path, value):\n names = path.split('.')\n if len(names) > 1:\n set_attribute(getattr(obj, names[0]), '.'.join(nam... | [
"0.7939716",
"0.7406594",
"0.67989147",
"0.6734785",
"0.630299",
"0.6169416",
"0.6052236",
"0.60253316",
"0.59769595",
"0.5970289",
"0.59285486",
"0.59023386",
"0.58718103",
"0.5871102",
"0.5867811",
"0.579595",
"0.5765958",
"0.57328546",
"0.57027525",
"0.5693478",
"0.5652854... | 0.8307797 | 0 |
Determine whether a given object has an attribute with a `.` separated name. | def has_nested_attr(__obj: object, __name: str) -> bool:
pre, _, post = __name.rpartition('.')
if pre:
if has_nested_attr(__obj, pre):
return has_nested_attr(get_nested_attr(__obj, pre), post)
else:
return False
else:
return hasattr(__obj, post) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasAttribute(self, p_str, p_str_1=None): # real signature unknown; restored from __doc__ with multiple overloads\n return False",
"def has_attr_with_name(self, name):\n for attr in self:\n if attr.name == name:\n return True\n\n return False",
"def checkattr(n... | [
"0.66628057",
"0.65822",
"0.6533159",
"0.6528582",
"0.65005475",
"0.650034",
"0.6358487",
"0.6358487",
"0.6206753",
"0.613546",
"0.61350113",
"0.6089718",
"0.6087438",
"0.6077114",
"0.6077114",
"0.59296495",
"0.59146595",
"0.58616424",
"0.58221674",
"0.58221674",
"0.5815346",... | 0.6836234 | 0 |
Advect covariant xwind on Dgrid using contravariant xwind on cell corners. Named xtp_u in the original Fortran code. In the Fortran, dt is folded in to ub_contra and called "courant". | def advect_u_along_x(
u: FloatField,
ub_contra: FloatField,
rdx: FloatFieldIJ,
dx: FloatFieldIJ,
dxa: FloatFieldIJ,
dt: float,
):
# Could try merging this with xppm version.
from __externals__ import iord
bl, br = get_bl_br(u, dx, dxa)
b0 = bl + br
cfl = ub_contra * dt * rd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upwind_x(self, func, u):\n f_dx = np.zeros_like(func)\n roll_left = np.roll(func, -1, axis=1)\n roll_right = np.roll(func, 1, axis=1)\n f1 = (func - roll_right) / self.dx\n f2 = (roll_left - func) / self.dx\n f_dx[np.where(u >= 0)] = f1[np.where(u >= 0)]\n f_dx[... | [
"0.5812223",
"0.5578057",
"0.54327404",
"0.5389594",
"0.5371789",
"0.5341696",
"0.5303356",
"0.53026146",
"0.5282954",
"0.5260006",
"0.523463",
"0.5228892",
"0.522116",
"0.522116",
"0.5175521",
"0.51724285",
"0.51552135",
"0.51455253",
"0.51426756",
"0.5137509",
"0.5133099",
... | 0.6606841 | 0 |
Estimates total number of combinations. This does not account for the permutations of "forced" characters, so the real number of combinations will be higher than this estimate. | def estimateCombinations(self):
# Note: We use floating point, not exact arithmetic.
allCharsCount = 0.0
combinations = 1.0
# Count combinations for the forced characters.
for chars in self.categories:
combinations *= len(chars)
allCharsCount += len(char... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_permutations(self) -> int:\n perms = math.factorial(len(self._word))\n for v in self._char_counts.values():\n if v > 1:\n perms /= math.factorial(v)\n return perms",
"def calulate_total_permutations(value):\n if len(value) == len(set(value)):\n ... | [
"0.7253553",
"0.66454095",
"0.6605841",
"0.6605841",
"0.6418367",
"0.63323903",
"0.6286042",
"0.626837",
"0.61481637",
"0.61261785",
"0.61043525",
"0.6093982",
"0.6053244",
"0.6052588",
"0.60336816",
"0.6016115",
"0.59903944",
"0.5989238",
"0.5986413",
"0.59780264",
"0.594201... | 0.7635501 | 0 |
Gets the user's avatar url If they don't have an avatar set, the default avatar is returned | def get_user_avatar(user: Union[discord.User, discord.Member]) -> str:
return user.avatar_url if user.avatar_url is not None else user.default_avatar_url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def avatar_url(self):\n if self.avatar and hasattr(self.avatar, 'url'):\n return self.avatar.url\n else:\n return '/static/defaults/!default_user_avatar/user.gif'",
"def avatar_url(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"avatar_url\")",
"def ... | [
"0.8292266",
"0.80095345",
"0.7952628",
"0.7803622",
"0.7747004",
"0.76800925",
"0.76762736",
"0.7574685",
"0.75729907",
"0.753483",
"0.7381511",
"0.7338893",
"0.72537446",
"0.72216076",
"0.7147984",
"0.7058666",
"0.70262045",
"0.697657",
"0.69477373",
"0.6854028",
"0.6850498... | 0.8577179 | 0 |
Returns a formatted string for a given VoiceRegion | def get_region_string(region: discord.VoiceRegion) -> str:
regions = {"us-west": EMOJI[":flag_us:"]+"US West",
"us-east": EMOJI[":flag_us:"]+"US East",
"us-central": EMOJI[":flag_us:"]+"US Central",
"us-south": EMOJI[":flag_us:"]+"US South",
"eu-west": EMO... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def region_str(self):\n return \"%s:%s-%s\" % (self.seqid, self.start, self.end)",
"def __repr__(self: RcnRegion) -> str:\n return f\"RcnRegion.{self.name}\"",
"def __str__(self):\n return \"Region: \" + self.name + \" with parent \" + self.parent + \" and self code \" + self.FHIRCode",
... | [
"0.7035844",
"0.66859514",
"0.6469942",
"0.5972443",
"0.59704596",
"0.59704596",
"0.59704596",
"0.59704596",
"0.59704596",
"0.59704596",
"0.59587413",
"0.5879044",
"0.58671993",
"0.5835131",
"0.5792081",
"0.57604825",
"0.57604825",
"0.57604825",
"0.57604825",
"0.57604825",
"0... | 0.7548803 | 0 |
Checks if the current command context is limited to lite mode. If the guild is in the lite_guilds list, the context is in lite mode. If the guild is in private message, and the message author is in at least ONE guild that is not in lite_guilds, then context is not lite | def is_lite_mode(ctx: commands.Context) -> bool:
if is_private(ctx.message.channel):
for g in ctx.bot.get_user_guilds(ctx.message.author.id):
if g.id not in config.lite_servers:
return False
else:
return ctx.message.guild in config.lite_servers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guild_only():\n\n async def check(ctx):\n if ctx.guild: # In a server\n return True\n await ctx.send('This command is only available in servers!')\n return False\n\n return commands.check(check)",
"def is_democraciv_guild():\n\n def check(ctx):\n if not isinst... | [
"0.5691053",
"0.5537149",
"0.53771347",
"0.5297926",
"0.5295333",
"0.527921",
"0.52316976",
"0.51805806",
"0.51805806",
"0.51479936",
"0.51479936",
"0.51479936",
"0.5136715",
"0.5086459",
"0.50851494",
"0.50851494",
"0.50851494",
"0.50693166",
"0.50535107",
"0.50369704",
"0.4... | 0.74545246 | 0 |
generates the hits.csv file | def generateHits(self, cont):
hitf = self.outdir + "/hits.csv"
old = os.dup(1)
sys.stdout.flush()
os.close(1)
os.open(hitf, os.O_WRONLY | os.O_CREAT)
cont.printallHits()
sys.stdout.flush()
os.close(1)
os.dup(old)
os.close(old)
line... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_file(self, results):\n with open(self.outputFilename, \"w\") as csvFile:\n csvWriter = csv.writer(csvFile, delimiter=',') \n title_row = ('asset_id', 'component_id', 'latitude', 'longitude', 'installation_date', 'commissioning_date', 'street_name', 'cabinet_id', 'nominal... | [
"0.67682934",
"0.66243416",
"0.6588335",
"0.6579417",
"0.6573188",
"0.655248",
"0.6531506",
"0.649992",
"0.6460926",
"0.64463776",
"0.64165014",
"0.6397637",
"0.6396447",
"0.6391759",
"0.6360784",
"0.6323576",
"0.630485",
"0.6303919",
"0.6269347",
"0.6267382",
"0.62662333",
... | 0.72992617 | 0 |
generates the tracks_soln.csv file | def generateSolution(self, cont):
solnf = self.outdir + "/tracks_soln.csv"
old = os.dup(1)
sys.stdout.flush()
os.close(1)
os.open(solnf, os.O_WRONLY | os.O_CREAT)
cont.printallSolutions(yetkin=self.yetkin)
sys.stdout.flush()
os.close(1)
os.dup(old)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_as_csv(self, DBNs):\n with open(\"output.csv\", \"w\") as outfile:\n # create the headers\n for i in range(0, 5):\n outfile.write(self._headers[i] + \",\") # delimits header names\n\n # moves to next line\n outfile.write(self._headers[5] + ... | [
"0.6413816",
"0.6202554",
"0.61280864",
"0.60623825",
"0.6045779",
"0.60358655",
"0.60163105",
"0.5974259",
"0.5932496",
"0.59315294",
"0.5917941",
"0.5906362",
"0.58827895",
"0.5874377",
"0.58609545",
"0.5804449",
"0.5797106",
"0.57886565",
"0.577884",
"0.5775092",
"0.577278... | 0.6703463 | 0 |
Reads the pyslice.ini file. | def read_config(self, min_sections, max_sections, req_sections_list):
# Can we find pyslice.ini?
pyslice_ini = Path.cwd() / input_file
if not os.access(pyslice_ini, os.F_OK | os.R_OK):
raise ConfigFileNotFoundError(
f"{input_file} was not found or not readable ***"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_ini_file (path):\n # TODO write a code to read data from ini-file to dictionary\n\n\n pass",
"def read_settings(self):\n config = ConfigParser.SafeConfigParser()\n config.read(os.path.dirname(os.path.realpath(__file__)) + '/linode.ini')\n\n # Cache related\n ... | [
"0.68838066",
"0.5825334",
"0.5796054",
"0.5694025",
"0.56902796",
"0.56393313",
"0.5617711",
"0.5588793",
"0.5566551",
"0.5517896",
"0.5480258",
"0.54781944",
"0.54656595",
"0.546321",
"0.5453065",
"0.5446662",
"0.5444972",
"0.54166657",
"0.54001963",
"0.53971964",
"0.538356... | 0.681543 | 1 |
Show homepage with map | def homepage():
return render_template("home_map.html") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home():\n m = Map() # Create map html\n return render_template('index.html') # pulls map html using jinja2",
"def map_page():\n m = Map() # Create map html\n return render_template('index.html') # pulls map html using jinja2",
"def index():\n\n return render_template('index.html', title='Fin... | [
"0.8233349",
"0.7650102",
"0.74863607",
"0.71886957",
"0.7183427",
"0.70794034",
"0.69313073",
"0.67315274",
"0.6701228",
"0.6691717",
"0.6683785",
"0.6635678",
"0.6629475",
"0.66146296",
"0.66142416",
"0.6591016",
"0.657642",
"0.65759116",
"0.65759116",
"0.654038",
"0.653809... | 0.8362454 | 0 |
JSON information about artpieces. | def return_pieces():
artpieces = Artpiece.query.all()
art = [] # list of all the artpieces
# going through each row returned from the query
for ap in artpieces:
info = {}
names = []
artists = ap.artists #retrieve instance attribute
for artist in artists:
na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_art_info(self):\n pass",
"def json(self):\n if self.valid:\n return {\n 'articleID': self._id,\n 'ticker_symbol': self.ticker,\n 'published_date': self.pub_date,\n 'author_name': self.author,\n 'title... | [
"0.58331066",
"0.5729847",
"0.5689649",
"0.5680672",
"0.5643192",
"0.55842716",
"0.5492196",
"0.5448909",
"0.54035735",
"0.53987575",
"0.53871316",
"0.5363308",
"0.5358226",
"0.5332384",
"0.52659905",
"0.52439654",
"0.52317476",
"0.5211706",
"0.5207297",
"0.52043325",
"0.5193... | 0.71255416 | 0 |
Populate the timing stimulus dictionary from and input file. | def parse_stimulus(stimulus, infile):
assert isinstance(stimulus, dict)
# Get timing information from file, being sure to ignore whitespace
timing = ''
with open(infile) as f:
for line in f:
timing += line.replace(' ', '').strip()
# Split input into a list and convert the one a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_file(self):\n file_time = ''\n num_dir = 0\n num_freq = 0\n freq_w_band = 0.0\n freq_0 = 0.0\n start_dir = 0.0\n\n dspec_matrix = []\n\n # Extract the file time from the file name\n input_file_name = self._stream_handle.name\n\n match ... | [
"0.6077571",
"0.6002726",
"0.59120965",
"0.58933383",
"0.5866309",
"0.5783808",
"0.5738685",
"0.5733202",
"0.57041675",
"0.5686597",
"0.56748617",
"0.5671476",
"0.5664493",
"0.5632346",
"0.56183684",
"0.5618066",
"0.5594966",
"0.55831385",
"0.5580403",
"0.5569692",
"0.5538701... | 0.6104276 | 0 |
Return a SQLAlchemy session. | def get_session():
return scoped_session(sessionmaker(autocommit=False, autoflush=False, bind=engine)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_session():\n session = scoped_session(sessionmaker(bind=engine))\n return session",
"def get_session(self):\n # Create the session\n kwargs = self._get_database_specific_session_args()\n session_factory = orm.sessionmaker(\n bind=self._engine, expire_on_commit=False,... | [
"0.8613249",
"0.8455852",
"0.82382464",
"0.81438994",
"0.80603933",
"0.8053609",
"0.7956509",
"0.7910294",
"0.7899938",
"0.7893864",
"0.7799984",
"0.7765756",
"0.7758646",
"0.7723484",
"0.7690281",
"0.76200527",
"0.76080185",
"0.7596541",
"0.75943327",
"0.7565893",
"0.755834"... | 0.8555524 | 1 |
Initialize. It is assumed that the concatenation of the event streams in persistent_event_store and transient_event_queue contain all events in which this repository has an interest. | def __init__(self, transient_event_queue, persistent_event_store, mutator, **kwargs):
super().__init__(**kwargs)
self._transient_event_queue = transient_event_queue
self._persistent_event_store = persistent_event_store
self._mutator = mutator
self._tracking_aggregate_ids = defaul... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, event_queue, connection_options):\n super(GerritEventsStream, self).__init__()\n self._event_queue = event_queue\n self._connection_options = connection_options\n self._running = True",
"def __init__(self):\n self.event_list = []\n self._subscribers = ... | [
"0.65101635",
"0.6472584",
"0.63085324",
"0.61220205",
"0.60210586",
"0.60031444",
"0.5962241",
"0.59133726",
"0.5910087",
"0.59036",
"0.5888597",
"0.58803743",
"0.58543456",
"0.58367807",
"0.5748189",
"0.5720812",
"0.57003045",
"0.5646513",
"0.5646513",
"0.56442",
"0.564108"... | 0.6756937 | 0 |
Register an aggregate with this repository. Once an aggregate is registered with the repository, the aggregate is retrievable from the repository via _aggregate_with_id(), _aggregates_with_ids(), and _extant_aggregate_ids() | def _register(self, aggregate_root_entity):
if not isinstance(aggregate_root_entity, self._aggregate_root_entity_class()):
raise TypeError("{!r} is not of type {} therefore cannot be store in a {}"
.format(aggregate_root_entity, self._aggregate_root_entity_class().__name_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_aggregation(\n self,\n f: dd.Aggregation,\n name: str,\n parameters: List[Tuple[str, type]],\n return_type: type,\n replace: bool = False,\n ):\n self._register_callable(\n f,\n name,\n aggregation=True,\n ... | [
"0.6493154",
"0.6390233",
"0.5721717",
"0.5695466",
"0.5640757",
"0.5489287",
"0.5478946",
"0.5319596",
"0.5287735",
"0.5268721",
"0.52365905",
"0.5200469",
"0.5123038",
"0.5114808",
"0.51092464",
"0.50671554",
"0.5062453",
"0.49744803",
"0.4961004",
"0.4954799",
"0.49456868"... | 0.65265906 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.