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 |
|---|---|---|---|---|---|---|
Downloads a DataFrame from S3 and reads it into the Python session in chunks of a specified number of rows. Because chunking is accomplished via splitting on rows, only textfiles (CSVs/PSVs) and compressed textfiles are currently supported. Support for reading Avro files in chunks may be added at a later date. Storage ... | def read_df_in_chunks(path, bucket=None, chunk_size=10000, names=None,
show_progressbar=True, *args, **kwargs):
row_chunkable_filetypes = ['csv', 'csv.gz', 'csv.zip', 'csv.bz2', 'csv.xz',
'psv', 'psv.gz', 'psv.zip', 'psv.bz2', 'psv.xz']
path = s3_path_utils.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data(nrows=10000):\n # Add Client() here\n client = storage.Client()\n path = \"gs://{}/{}\".format(BUCKET_NAME, PATH_INSIDE_BUCKET)\n df = pd.read_csv(path, nrows=nrows)\n return df",
"def loader():\n bucket = data_load_variables[\"bucket\"]\n\n if data_load_variables[\"use_lite_dat... | [
"0.66728437",
"0.6541085",
"0.6426574",
"0.6325412",
"0.62184006",
"0.6172549",
"0.5999784",
"0.59290934",
"0.590246",
"0.5821518",
"0.57744074",
"0.5767516",
"0.57289773",
"0.56701624",
"0.56288046",
"0.56096536",
"0.56096536",
"0.5603918",
"0.5596685",
"0.5566609",
"0.55571... | 0.7858778 | 0 |
Downloads an object from S3 and reads it into the Python session, without following the rules of the normal reading function. Storage format is determined by file extension, or as specified if the object is missing one. Although this tool aims to enforce good practice, sometimes it is necessary to work with other parti... | def read_badpractice(path, bucket=None, filetype=None, show_progressbar=True,
*args, **kwargs):
logging.warning('You are using rivet\'s read function that allows for '
'files stored with inadvisible S3 paths. It is highly '
'recommended that you use the s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def read(self, size=-1):\n # read the object using the bucket and path already determined in\n # __init__, and using the connection object\n try:\n # get the file size first\n file_size = await self._getsize()\n if size== -1:\n range_start ... | [
"0.6974762",
"0.6887182",
"0.68074703",
"0.67614645",
"0.6708966",
"0.6641525",
"0.6594565",
"0.6586844",
"0.657112",
"0.6537609",
"0.65304816",
"0.6520043",
"0.65084004",
"0.6484894",
"0.6416716",
"0.637241",
"0.6319603",
"0.6318049",
"0.6296156",
"0.6291751",
"0.6275881",
... | 0.70082784 | 0 |
View to show the picks for a game, and also results if the game has been played | def gameView(request, game_id): # checked for rwc23
game = get_object_or_404(Game, id = game_id)
if game.finished:
picks = Prediction.objects.all().filter(game = game).order_by('-points')
else:
picks = Prediction.objects.all().filter(game = game).order_by('playerRound__player__usern... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_game():\n try:\n # get selections for player and computer\n user_pick = utils.get_user_selection(user_selection.get())\n computer_pick = utils.get_computer_selection()\n\n # determine winner\n winner = utils.determine_winner(user_pick, computer_pick, \"pvc\")\n\n ... | [
"0.6486285",
"0.6444398",
"0.62381375",
"0.62360513",
"0.6171727",
"0.6127635",
"0.5985238",
"0.5969339",
"0.5853339",
"0.5823116",
"0.58102643",
"0.5803611",
"0.58030194",
"0.57957804",
"0.5775308",
"0.57633215",
"0.56850046",
"0.5647475",
"0.5647298",
"0.5642673",
"0.563117... | 0.78624046 | 0 |
Predict each model for each time series. | def predict(self, y_hat_df):
check_is_fitted(self, 'fitted_models_')
y_hat_df = deepcopy(y_hat_df[['unique_id', 'ds']])
forecasts = []
uids = []
dss = []
name_models = []
for ts, name_model in product(y_hat_df.groupby('unique_id'), self.models.keys()):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, x):\n pred = x\n for m in self.models:\n pred = m.predict(pred)\n\n return pred",
"def predict(self):\n for track in self.tracks:\n track.predict(self.kf)",
"def predict(self):\n for track in self.tracks:\n track.predict(self... | [
"0.6809185",
"0.6652926",
"0.6652926",
"0.6652926",
"0.6640654",
"0.66131073",
"0.65753675",
"0.65301317",
"0.6467212",
"0.6430554",
"0.63903624",
"0.63630515",
"0.63587016",
"0.63484156",
"0.62766874",
"0.62713253",
"0.62486386",
"0.6203103",
"0.6182772",
"0.6181542",
"0.615... | 0.6932472 | 0 |
Sets the class_id of this GetClientServicesRequest. | def class_id(self, class_id):
self._class_id = class_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_id(self, class_id: str):\n if class_id is None:\n raise ValueError(\"Invalid value for `class_id`, must not be `None`\") # noqa: E501\n\n self._class_id = class_id",
"def class_id(self, class_id: str):\n if class_id is None:\n raise ValueError(\"Invalid value... | [
"0.5522708",
"0.5522708",
"0.5262296",
"0.52294993",
"0.51738864",
"0.51738864",
"0.51738864",
"0.51738864",
"0.50850874",
"0.50732744",
"0.50732744",
"0.50635326",
"0.5053926",
"0.49692458",
"0.49688458",
"0.48526374",
"0.48207814",
"0.480033",
"0.47680432",
"0.4764646",
"0.... | 0.6370695 | 0 |
Sets the program_ids of this GetClientServicesRequest. | def program_ids(self, program_ids):
self._program_ids = program_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_programs(self, programs):\n self._programs = programs",
"def application_ids(self, application_ids):\n if self.local_vars_configuration.client_side_validation and application_ids is None: # noqa: E501\n raise ValueError(\"Invalid value for `application_ids`, must not be `None`\"... | [
"0.65697634",
"0.5701064",
"0.55671847",
"0.5427769",
"0.5159628",
"0.50792575",
"0.494092",
"0.49401915",
"0.4853027",
"0.47550094",
"0.4721279",
"0.46906424",
"0.46805996",
"0.4618688",
"0.46014485",
"0.45832828",
"0.4565461",
"0.45653728",
"0.45621896",
"0.4556268",
"0.454... | 0.7337204 | 0 |
Sets the session_type_id of this GetClientServicesRequest. | def session_type_id(self, session_type_id):
self._session_type_id = session_type_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id_type(self, id_type):\n\n self._id_type = id_type",
"def signer_id_type(self, signer_id_type):\n\n self._signer_id_type = signer_id_type",
"def get_session_type(self) -> Type[ba.Session]:\n return self._sessiontype",
"def session_id(self, session_id):\n\n self._session_id = ... | [
"0.5589316",
"0.54592955",
"0.5114753",
"0.4957994",
"0.49286443",
"0.49169874",
"0.48739457",
"0.4855537",
"0.48445565",
"0.4842576",
"0.48375493",
"0.47843897",
"0.47843897",
"0.47673792",
"0.47615606",
"0.47533724",
"0.47532278",
"0.47207233",
"0.47207233",
"0.47207233",
"... | 0.7233781 | 0 |
Sets the location_ids of this GetClientServicesRequest. | def location_ids(self, location_ids):
self._location_ids = location_ids | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_location(self, location_set):",
"def get_locations_by_ids(self, id_list):",
"def service_ids(self, service_ids):\n\n self._service_ids = service_ids",
"def set_remote_locations(locations: list[RemoteLocation]) -> dict:\n return {\n \"method\": \"Target.setRemoteLocations\",\n ... | [
"0.57418907",
"0.57344407",
"0.5555597",
"0.5519896",
"0.5397673",
"0.53806937",
"0.5330854",
"0.5321174",
"0.5190039",
"0.5190039",
"0.513368",
"0.5106447",
"0.5101441",
"0.509129",
"0.5086377",
"0.5033168",
"0.5030239",
"0.50084466",
"0.50084466",
"0.49938148",
"0.49781018"... | 0.74470794 | 0 |
Sets the visit_count of this GetClientServicesRequest. | def visit_count(self, visit_count):
self._visit_count = visit_count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_count(self, request_count):\n\n self._request_count = request_count",
"def set_city_count(self, city_count):\n self.city_count = city_count",
"def set_count(self, count):\n self._count = count",
"def count(self, count: int):\n\n self._count = count",
"def updateVisit... | [
"0.608174",
"0.5842999",
"0.56502795",
"0.55906713",
"0.55700123",
"0.55493486",
"0.55493486",
"0.55493486",
"0.55493486",
"0.5548173",
"0.55150986",
"0.54957044",
"0.54957044",
"0.5489625",
"0.5472022",
"0.5438496",
"0.53750515",
"0.5366077",
"0.53258246",
"0.53239393",
"0.5... | 0.73123235 | 0 |
Sets the show_active_only of this GetClientServicesRequest. | def show_active_only(self, show_active_only):
self._show_active_only = show_active_only | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_active_only_state(self):\n\n active_only = Manager().get_profile_setting(\n INI.ACTIVE_ONLY,\n Section.FILEVIEWER\n )\n\n if active_only is None:\n # if no profile loaded, set it unchecked and disable it\n self._filter.onlyShowActive=False\n... | [
"0.5462911",
"0.537993",
"0.5264773",
"0.5194219",
"0.4962172",
"0.4951283",
"0.49243477",
"0.47912592",
"0.47729063",
"0.47601193",
"0.47451887",
"0.47364",
"0.47260186",
"0.46072614",
"0.46072614",
"0.46072614",
"0.46072614",
"0.46054858",
"0.46054858",
"0.46054858",
"0.460... | 0.7724161 | 0 |
item_container.container.addItems(c, items) Method to add some items in a container. container container where the items must be added. items list of items to add | def addItems(c, items):
container.containersToSave[c['id_item_container']] = item.inventory.addItems(
item.inventory.fromStr(c['items']),
items
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addItems(*args):",
"def add_items(self, items):\n for item in items:\n self.add(item)",
"def add_items(self, items):\n for item in items:\n self.addItem(item)\n # end for item in items",
"def addItem(*args):",
"def addItem(*args):",
"def addItem(*args):",
... | [
"0.75052994",
"0.72471",
"0.72145003",
"0.7053937",
"0.7053937",
"0.7053937",
"0.70407724",
"0.6827371",
"0.67924154",
"0.67397046",
"0.6720768",
"0.6654524",
"0.6576309",
"0.6555629",
"0.65088266",
"0.64679843",
"0.64527196",
"0.63178164",
"0.6263566",
"0.6246374",
"0.62345"... | 0.83999854 | 0 |
item_container.container.removeItems(c, items) Method to remove some items from a container. Items not in the container will be ignored. container container the items must be removed from. items list of items to remove | def removeItems(c, items):
container.containersToSave[c['id_item_container']] = item.inventory.removeItems(
item.inventory.fromStr(c['items']),
items
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, items):\n if isinstance(items, Container):\n items = items.items\n for item in items:\n # return an error if the container does not have (enough of) an item.\n if item not in self.items:\n raise ValueError(f'Item: \"{item}\" not present... | [
"0.8272521",
"0.7013731",
"0.7013731",
"0.69073004",
"0.68082404",
"0.6741926",
"0.6699986",
"0.6629548",
"0.6578865",
"0.6563704",
"0.6494382",
"0.6463047",
"0.6347765",
"0.62701964",
"0.6259242",
"0.62457925",
"0.62277347",
"0.61104727",
"0.60941845",
"0.6081759",
"0.607397... | 0.85066277 | 0 |
Returns the available types as an dict with ids as keys and labels as values dict the types | def getTypes():
query = "\
SELECT\
id_item_container_type,\
label\
FROM\
item_container_type\
"
return {t['id_item_container_type']: t['label'] for t in Model.fetchAllRows(query)} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type_classes(self) -> Dict[str, int]:\n return {\n \"bg\": 0,\n \"neutrophil\": 1,\n \"epithelial\": 2,\n \"lymphocyte\": 3,\n \"plasma\": 4,\n \"eosinophil\": 5,\n \"connective\": 6,\n }",
"def _types(cls):\n r... | [
"0.6908189",
"0.6790196",
"0.6617115",
"0.6503104",
"0.646393",
"0.64094627",
"0.64004934",
"0.6395867",
"0.6389643",
"0.6347591",
"0.6330365",
"0.63063776",
"0.62719506",
"0.62636626",
"0.62531626",
"0.61778224",
"0.6164937",
"0.60915416",
"0.6069235",
"0.60596836",
"0.60127... | 0.7151935 | 0 |
Initializes all the plugins associated to the given BluetoothManager by scanning all the modules under the ``_plugins`` folder in the manager's package. | def scan_plugins(manager) -> List[BaseBluetoothPlugin]:
plugins = {}
base_dir = os.path.dirname(inspect.getfile(manager.__class__))
module = inspect.getmodule(manager.__class__)
assert module is not None
package = module.__package__
assert package is not None
for _, mod_name, _ in pkgutil.w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_plugins(self):\n logger.debug('Initializing plugins')\n plugins = self._pm.hook.plugins(loop=self._loop)\n if plugins:\n for plugin in plugins:\n name = plugin.__name__\n registry_name = plugin.__registry__ or plugin.__name__\n ... | [
"0.69076097",
"0.6703308",
"0.6619715",
"0.6602184",
"0.65932983",
"0.6429818",
"0.6414216",
"0.6371512",
"0.6307473",
"0.6241721",
"0.62148124",
"0.61753124",
"0.61732095",
"0.6081475",
"0.6077873",
"0.6068396",
"0.6050153",
"0.60294104",
"0.6023388",
"0.6018179",
"0.5994782... | 0.75432616 | 0 |
Return value of export/build_type element, or 'unknown' if unspecified. | def get_build_type(self):
build_type_exports = self.export.findall('build_type')
if len(build_type_exports) == 1:
return build_type_exports[0].text
raise InvalidPackage('Only one <build_type> element is permitted.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_type(self) -> pulumi.Output['outputs.BuildTypeResponse']:\n return pulumi.get(self, \"build_type\")",
"def build_type(self) -> Optional[pulumi.Input['BuildTypeArgs']]:\n return pulumi.get(self, \"build_type\")",
"def build_type(self):\n return self._build_type",
"def install_ty... | [
"0.7352328",
"0.70165646",
"0.65191185",
"0.58197224",
"0.57911414",
"0.57129866",
"0.5704754",
"0.5666214",
"0.5620049",
"0.5585133",
"0.5489426",
"0.54383916",
"0.5413988",
"0.54042166",
"0.540054",
"0.5383679",
"0.5371303",
"0.5369884",
"0.53466386",
"0.5339047",
"0.533531... | 0.8254514 | 0 |
Given a time units string (one of ``VALID_TIME_UNITS``), return a function that converts from the time units to hours. | def build_convert_to_hours(time_units):
if time_units not in VALID_TIME_UNITS:
raise ValueError('Time units must be one of', VALID_TIME_UNITS)
if time_units == 'min':
return lambda x: x/60
elif time_units == 'h':
return lambda x: x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hours(duration):\n if not duration:\n return 0\n try:\n h, m, s = duration_parts(duration)\n return h\n except (ValueError, TypeError):\n return 0",
"def hours(input=None):\n return get(input).hours",
"def to_hours(self, timesteps, to_label=False):\n out = tim... | [
"0.6261804",
"0.60468644",
"0.58977234",
"0.58977234",
"0.58977234",
"0.58977234",
"0.5757926",
"0.5731297",
"0.565108",
"0.5632827",
"0.550144",
"0.5429626",
"0.5423557",
"0.5398271",
"0.53578603",
"0.53249365",
"0.530017",
"0.52656287",
"0.52480775",
"0.5216525",
"0.5207281... | 0.86979634 | 0 |
Read a timesheet CSV located at the given path (string or Path object) and return its corresponding timesheet data frame. The timesheet must contain at least the columns | def read_timesheet(path, date_format=DATE_FORMAT, input_time_units='h'):
f = pd.read_csv(path, parse_dates=['date'],
date_parser=lambda x: parse_date(x, DATE_FORMAT))
f = f.sort_values('date')
# Convert to hours
convert_to_hours = build_convert_to_hours(input_time_units)
f['duration'] = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_from_csv(path):\n if not os.path.exists(path):\n return None\n if not path.endswith('.csv'):\n return None\n\n with open(path, 'r') as file:\n data = pd.read_csv(file, header=0)\n\n return data",
"def data_input(path, complete=False, nrows=10000):\n\n if complete:\n ... | [
"0.71178305",
"0.69232684",
"0.6913197",
"0.68513256",
"0.6836317",
"0.68285",
"0.68168944",
"0.6776056",
"0.6776056",
"0.674714",
"0.6701854",
"0.6684249",
"0.66649246",
"0.66456085",
"0.6610662",
"0.65876967",
"0.6559977",
"0.6510703",
"0.6465663",
"0.64553505",
"0.6440743"... | 0.7565435 | 0 |
Slice the given timesheet by the given dates then aggregate total duration by project. If a Pandas frequency string is given (e.g. 'W' for calendar week), then resample by that frequency and then aggregate duration by project. | def agg_by_project(timesheet, date1=None, date2=None, freq=None):
f = slice_by_dates(timesheet, date1, date2)
if freq is not None:
f = f.groupby('project').apply(
lambda x: x.set_index('date')[['duration']].resample(freq
).sum().fillna(0)).reset_index()
f = f[['date', 'proje... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_weekly_project_durations(self, week=0):\n\n # get the start and end of the desired week\n now = dt.datetime.now()\n monday = now.date() - dt.timedelta(days=now.weekday() + 7*week)\n nextmonday = monday + dt.timedelta(days=7)\n\n # get all jobs and associated projects for ... | [
"0.5803487",
"0.53007376",
"0.52275944",
"0.514798",
"0.5122413",
"0.5098749",
"0.50665396",
"0.50392324",
"0.49668342",
"0.49042743",
"0.4856052",
"0.48428363",
"0.48268938",
"0.48228472",
"0.4812551",
"0.48122728",
"0.48058018",
"0.48009118",
"0.4796322",
"0.47727683",
"0.4... | 0.79581463 | 0 |
Return a biller with the given hourly rate, base fee, and billing frequency (Pandas frequency string such as 'W' for weekly billing). | def build_linear_biller(rate, base_fee=0, freq=None, name=None):
biller = build_piecewise_linear_biller(base_fee=base_fee,
bins=[np.inf], rates=[rate], freq=freq, name=name)
biller.kind = 'linear'
return biller | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_piecewise_linear_biller(bins, rates, base_fee=0, freq=None, \n name=None):\n def biller(x):\n return base_fee + np.dot(decompose(x, bins), rates)\n \n biller.name = name\n biller.kind = 'piecewise_linear'\n biller.base_fee = base_fee\n biller.bins = bins\n biller.rates = rate... | [
"0.6260751",
"0.58777833",
"0.55927515",
"0.5212543",
"0.52068144",
"0.5198272",
"0.5138589",
"0.513412",
"0.510255",
"0.50956446",
"0.507523",
"0.49918726",
"0.49787036",
"0.49625123",
"0.49590212",
"0.49446824",
"0.4925839",
"0.4923609",
"0.4899026",
"0.4878266",
"0.4874411... | 0.6170355 | 1 |
Return a biller that charges at the given billing frequency (Pandas frequency string such as 'W' for weekly billing) the given base fee plus the given hourly rates for the given chunks of times listed in ``bins``. The returned function also contains some metadata as shown in the examples below. | def build_piecewise_linear_biller(bins, rates, base_fee=0, freq=None,
name=None):
def biller(x):
return base_fee + np.dot(decompose(x, bins), rates)
biller.name = name
biller.kind = 'piecewise_linear'
biller.base_fee = base_fee
biller.bins = bins
biller.rates = rates
biller.f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_boft(self, min_freq=0.06, max_freq=0.66, bank=8, *args, **kwargs):\n # First generate the wavelets\n target_hz = self.sampling_freq\n freqs = np.geomspace(min_freq, max_freq, bank)\n wavs, hzs = [], []\n for i, f in enumerate(freqs):\n wav = np.real(wavelet... | [
"0.572282",
"0.56580895",
"0.5612946",
"0.55726224",
"0.5466148",
"0.53851527",
"0.53010106",
"0.5291584",
"0.52074647",
"0.5160717",
"0.5111584",
"0.5102427",
"0.5091724",
"0.50911677",
"0.5023355",
"0.49881926",
"0.49369228",
"0.49258468",
"0.4923135",
"0.49152645",
"0.4895... | 0.67060536 | 0 |
Slice the given timesheet to the given dates and compute the cost of the total duration according to the given biller. Return a new data frame with the columns | def compute_costs(timesheet, biller, date1=None, date2=None):
# Slice
f = slice_by_dates(timesheet, date1, date2)
# Resample and add start/end dates
if biller.freq is not None:
freq = biller.freq
f = timesheet.set_index('date')[['duration']].resample(freq).sum()
f = f.reset_in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(df):\n\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n\n # TO DO: display total travel time\n\n total_travel_time_in_sec = df['Trip Duration'].sum()\n total_travel_time_in_years = total_travel_time_in_sec // (60 * 60 * 24 *365)\n\n modulus1_in_se... | [
"0.5420765",
"0.52628446",
"0.5231023",
"0.5228011",
"0.5189745",
"0.51770985",
"0.5134056",
"0.512989",
"0.51105154",
"0.509332",
"0.5061016",
"0.5042811",
"0.50405407",
"0.50273407",
"0.5016018",
"0.5002579",
"0.49959078",
"0.49840474",
"0.49649462",
"0.49557012",
"0.494969... | 0.7957459 | 0 |
Get all the links which contains the terms in the query string. | def get_links(query_terms):
# the set of links all of which contains all the terms in the query string
final_links = None
for term in query_terms:
# get all links containing the term and put in a set
links = Set(index_data.get(term))
#print("\n\nQuery Term: %s" % term)
#prin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_search_terms(self):\n params = self.request.QUERY_PARAMS.get(\"search\", \"\")\n return params.replace(\",\", \" \").split()",
"def get_link_list_from_request(request):\n\tquery = request.POST.get('link_list','')\n #Clear all whitespaces from textarea\n whitespace = re.compile... | [
"0.63138103",
"0.5904104",
"0.5852937",
"0.5807481",
"0.5730787",
"0.57060105",
"0.5687286",
"0.56718355",
"0.56654716",
"0.56627077",
"0.56557786",
"0.5637811",
"0.56316245",
"0.5624569",
"0.55659574",
"0.5563996",
"0.55506504",
"0.55103076",
"0.54641414",
"0.54641414",
"0.5... | 0.78262174 | 0 |
Takes an OrderdDict and print topN entries which are also in links | def print_scores(ranked_list, links, topN=10):
n = topN
for url, score in ranked_list.items():
try:
_ = links.index(url)
print("Score: %f \t URL: %s" %(score, url))
n -= 1
if n <= 0:
break
except:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printTopN(dict, N):\n sorted_list = sorted(dict, key=dict.get, reverse=True)[0:N]\n for key in sorted_list:\n print key",
"def printTopN(dict, N): \n sorted_list = sorted(dict, key=dict.get, reverse=True)[0:N]\n for key in sorted_list:\n print key, dict[key]",
"def printWds(webDic... | [
"0.71876514",
"0.71814525",
"0.67083323",
"0.6375259",
"0.6161285",
"0.61418617",
"0.60165405",
"0.59833926",
"0.5964511",
"0.5936669",
"0.5845796",
"0.5801664",
"0.57862645",
"0.5785097",
"0.5751324",
"0.5741853",
"0.5718509",
"0.57066536",
"0.5682047",
"0.5667853",
"0.56630... | 0.7184276 | 1 |
Normalize the scores so that their sum is equal to 1. | def normalize_scores(scores):
#print(scores)
keys = scores.keys()
sum = 0.0
for k in keys:
#print("%06f\t" % scores.get(k)),
sum += scores.get(k)
if sum == 1.0:
return scores
new_scores = {}
for k in keys:
new_scores[k] = scores.get(k)/float(sum)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _normalize_scores(scores):\n # sort scores in an ascending order\n sorted_scores,sorted_idx = scores.view(-1).sort(descending=False)\n # compute cumulative sum\n scores_cumsum_temp = sorted_scores.cumsum(dim=0)\n scores_cumsum = torch.zeros(scores_cumsum_temp.shape,device=scores.device)\n sco... | [
"0.74918175",
"0.7454994",
"0.720968",
"0.7121583",
"0.7120734",
"0.7120734",
"0.7120734",
"0.7120734",
"0.7076782",
"0.7054241",
"0.704555",
"0.6979672",
"0.69594705",
"0.68780386",
"0.68752915",
"0.676268",
"0.67078686",
"0.6686128",
"0.6655981",
"0.6649961",
"0.6636474",
... | 0.7530338 | 0 |
Use the link_data to build a graph of the links. | def build_graph(link_data, links):
graph = {}
# add all data for links
for l in links:
#print("Adding "+l)
#print(link_data.get(l))
graph[l] = list(link_data.get(l))
# add all links that point to links
for slink in link_data:
for l in links:
# the links ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_data(self, link_data):\n\n self._link_data = link_data",
"def _construct_links_of_interest(self):\n if self.opts.selected_links:\n links, num_links = self.parse_selected_links(\n self.opts.selected_links)\n elif (self.opts.selected_terms or\n ... | [
"0.67576975",
"0.6382552",
"0.63130176",
"0.6165348",
"0.61349326",
"0.61341596",
"0.6105265",
"0.61042356",
"0.6083389",
"0.6053501",
"0.60106546",
"0.59745044",
"0.5957152",
"0.59487885",
"0.59434456",
"0.5938365",
"0.5919377",
"0.5886399",
"0.5836766",
"0.5820698",
"0.5751... | 0.81153923 | 0 |
1. Clean and Stem the query terms 2. Get all the links which contain the query terms 3. Rank the links | def search(index_data, link_data, stop_word_list, search_string):
topN = 5
query_terms = sanitize(search_strings, stop_word_list)
print(query_terms)
# get all links which contain all the query terms
links = get_links(query_terms)
print("\nURLs containing all of the query terms (%d):" % len(li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rank_links(tf_idf_table, query_terms, links):\n \n tf = {}\n for w in query_terms:\n f = query_terms.count(w)\n tf[w] = f\n\n q_tf_idf = {}\n for term in tf:\n # if the query term is found in files\n if tf_idf_table.has_key(term):\n q_tf_idf[term] = tf.get(... | [
"0.7181304",
"0.6636821",
"0.63339156",
"0.61892945",
"0.6076396",
"0.60726655",
"0.6062578",
"0.59790075",
"0.5920215",
"0.59061956",
"0.5897159",
"0.582469",
"0.57995164",
"0.57971716",
"0.57965773",
"0.5793038",
"0.5759325",
"0.57115865",
"0.5695039",
"0.5693666",
"0.56936... | 0.7379879 | 0 |
Method to initialize apscheduler | def initialize_scheduler(self):
scheduler = BackgroundScheduler()
scheduler.add_job(self.do, 'interval', minutes=1)
scheduler.start()
self.do() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_scheduler(self):\n self._sched = BackgroundScheduler()\n self._sched.add_job(self._check_rain, trigger='cron', minute='*/5')\n self._sched.start()",
"def __init__(self):\n try:\n self.scheduler = ap_scheduler\n except Exception as e:\n logger_obj... | [
"0.7957172",
"0.7594884",
"0.7511692",
"0.7477816",
"0.74715924",
"0.74572617",
"0.71291786",
"0.7065361",
"0.7037644",
"0.6962178",
"0.6906121",
"0.68748313",
"0.6815364",
"0.67771685",
"0.6687212",
"0.66796535",
"0.65879136",
"0.654168",
"0.6524913",
"0.6480765",
"0.6468428... | 0.8041467 | 1 |
Run splunk forwarder installer command into the Minion from Master VM | def install_splunk_forwarder(self, vm_ip):
installer_agent_script_path = get_config(KEY_SPLUNK_CLIENT, "INSTALLER_AGENT_SCRIPT_PATH")
forwarder_password = get_config(KEY_SPLUNK_CLIENT, "SPLUNK_FORWARDER_ADMIN_PASSWORD")
deployserver_ip = get_config(KEY_SPLUNK_SERVER, "SPLUNK_DEPLOYMENT_SERVER_IP... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup():\n sudo(\"minv_setup.sh\")",
"def start():\n _with_deploy_env(['./bin/paster serve src/remix/oerpub/rhaptoslabs/production.ini --daemon'])",
"def _deploy_salt_minion(name, session, vm_):\n # Get bootstrap values\n vm_[\"ssh_host\"] = get_vm_ip(name, session)\n vm_[\"user\"] = vm_.get... | [
"0.6222536",
"0.60974014",
"0.60171455",
"0.6011704",
"0.59238446",
"0.5716464",
"0.56887865",
"0.5670773",
"0.566714",
"0.56595016",
"0.5616387",
"0.560836",
"0.5604633",
"0.5585775",
"0.5582042",
"0.5581331",
"0.55654734",
"0.55537415",
"0.54911685",
"0.5457932",
"0.5426314... | 0.70511585 | 0 |
Inserting rates and dates to the newly created table | def insert_rates(from_date, to_date, currency='USD'):
usd_rates = stock_rates.get_rates_avg_time(currency, from_date, to_date)
dates_and_rates = []
if(from_date > to_date):
raise Exception("WRONG DATES!")
cur_date = from_date
prev_date = cur_date
while(cur_date <= to_date):
a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setupStockTable(self):\n # Get the date\n # NOTE: This is probably un\n date = datetime.date()\n dateStr = date.month() + \"/\" + date.day() + \"/\" + date.year()\n\n stocks = (\"INTC\", \"AAPL\", \"GOOG\", \"YHOO\", \"SYK\", \"VZ\")\n\n for stock in stocks:\n ... | [
"0.61343575",
"0.6123335",
"0.61066633",
"0.6075451",
"0.6061285",
"0.60402375",
"0.6029454",
"0.5991088",
"0.58913183",
"0.5886485",
"0.58729666",
"0.58441836",
"0.5844153",
"0.5805589",
"0.5797626",
"0.5750882",
"0.5691402",
"0.56908834",
"0.56895894",
"0.5689397",
"0.56741... | 0.67542034 | 0 |
Tries to interpret input string as integer using builtin 'int' function. If it cannot, returns 0 | def iint(string):
try:
return int(string.strip())
except:
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def try_parse_int(string):\n try:\n return int(string)\n except Exception:\n return 0",
"def isInt(string):\n try: int(string)\n except ValueError: return 0\n else: return 1",
"def safe_int(str):\n if not str:\n return None\n try:\n return int(st... | [
"0.80312204",
"0.7848705",
"0.7839539",
"0.782504",
"0.78221554",
"0.7686668",
"0.76742756",
"0.76690674",
"0.7662569",
"0.7593066",
"0.7570453",
"0.75683933",
"0.75320405",
"0.75298035",
"0.752495",
"0.75006413",
"0.7491465",
"0.7488313",
"0.7460139",
"0.74568146",
"0.743222... | 0.8007138 | 1 |
Tries to interpret input string as floating point number using builtin 'float' function. If it cannot, returns 0 | def ffloat(string):
try:
return float(string.strip())
except:
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_float(str):\n if not str:\n return None\n try:\n return float(str)\n except ValueError:\n return 0",
"def _string_to_float(s):\n try:\n f = float(s)\n return f\n except ValueError:\n return None",
"def getFloat(string):\n... | [
"0.8145945",
"0.8102162",
"0.8009787",
"0.79480493",
"0.79008293",
"0.7862446",
"0.7795297",
"0.7766864",
"0.77175397",
"0.76914877",
"0.7667921",
"0.76142657",
"0.76022065",
"0.7584897",
"0.7571275",
"0.75635827",
"0.75227284",
"0.7517158",
"0.7496485",
"0.7442123",
"0.73938... | 0.86317307 | 0 |
Parses a list of links to indexes of player profiles from baseballreference.com | def parsePlayerIndex(args):
paths = []
soup = BeautifulSoup(requests.get("{domain}/players/".format(domain=args.domain[0])).text, "html.parser")
lettersTags = soup.select("tr td.xx_large_text.bold_text a[href]")
[paths.append(tag.get("href")) for tag in lettersTags]
if args.verbose: print("Found {... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enumerate_profiles(inhandle, page):\n html = inhandle.read()\n soup = BeautifulSoup(html, 'html.parser')\n \n urls = [ node.find('a')['href'] for node in soup.findAll('h1', {'class':'entry-title'})]\n return urls",
"def scrape_current_players(positions):\n for i in range(len(positions)):\n fo... | [
"0.6236785",
"0.587219",
"0.58413637",
"0.5763051",
"0.56556505",
"0.5590501",
"0.55621475",
"0.55408365",
"0.553419",
"0.548778",
"0.54780644",
"0.54684424",
"0.5394937",
"0.53815866",
"0.5376896",
"0.537112",
"0.5365228",
"0.5355885",
"0.5338214",
"0.53354514",
"0.5322115",... | 0.67107975 | 0 |
Wrapped class to discord command | def _class_wrapper(command_class):
WebBot().register_command(command_class)
return command_class | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _command_wrapper(self, cls):\n def command_send(func, args):\n self._con.send(func(*args))\n result = self._recv()\n if len(result) == 0: # Reconnect if no results were received\n self._con.connect()\n self._recv()\n return c... | [
"0.7562426",
"0.7042787",
"0.69226664",
"0.6812637",
"0.67565507",
"0.67257255",
"0.67180055",
"0.670669",
"0.6653923",
"0.66468155",
"0.66315484",
"0.6607924",
"0.6569482",
"0.65539545",
"0.6519804",
"0.63825166",
"0.6361826",
"0.6355893",
"0.63510215",
"0.6340448",
"0.63389... | 0.74096316 | 1 |
Ensures if no goal key provided, post does not succeed. | def test_add_without_goal_key(self):
response = self.post_course_goal(goal_key=None)
assert len(CourseGoal.objects.filter(user=self.user, course_key=self.course.id)) == 0
self.assertContains(
response=response,
text='Please provide a valid goal key from following options.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_course_goal(self, valid=True, goal_key='certify'):\n goal_key = goal_key if valid else 'invalid'\n post_data = {\n 'course_key': self.course.id,\n 'user': self.user.username,\n }\n if goal_key:\n post_data['goal_key'] = goal_key\n\n respo... | [
"0.6564465",
"0.6121909",
"0.5725046",
"0.5489121",
"0.53874815",
"0.5302626",
"0.5294027",
"0.5260889",
"0.5253121",
"0.5223237",
"0.5181556",
"0.51760256",
"0.5159911",
"0.5113137",
"0.50921947",
"0.50844765",
"0.5067082",
"0.50541437",
"0.50505304",
"0.5047581",
"0.5044246... | 0.7140397 | 0 |
Sends a post request to set a course goal and returns the response. | def post_course_goal(self, valid=True, goal_key='certify'):
goal_key = goal_key if valid else 'invalid'
post_data = {
'course_key': self.course.id,
'user': self.user.username,
}
if goal_key:
post_data['goal_key'] = goal_key
response = self.cli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_course_goal(self, goal_id, course_name):\n self.db_cursor.execute(\n \"\"\"INSERT INTO CourseGoals (course_name, goal_id) VALUES (%s, %s)\"\"\",\n (course_name, goal_id))\n self.db_connection.commit()",
"def _create_course_with_given_location(self, course_key):\r\n ... | [
"0.6237392",
"0.56966054",
"0.56538135",
"0.56219506",
"0.5567754",
"0.5495521",
"0.53622055",
"0.53243774",
"0.5261642",
"0.51768947",
"0.51763827",
"0.51703197",
"0.5152597",
"0.512967",
"0.5124778",
"0.50764954",
"0.5063759",
"0.5056604",
"0.5046163",
"0.503813",
"0.503811... | 0.71777016 | 0 |
defines/displays the HandsontableDemoTable's spreadsheet, and loads/saves the data. | def spreadsheet_demo(request):
context = RequestContext(request)
search_term = request.GET.get('q') or ''
context['search_term'] = search_term or ''
table_cols = []
#
# very simple (and unnecessary) automatic column definitions
# manually defining the "table_cols" array is usually better
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __update_table(self):\n\n headlines = [\"\", ]\n headlines += range(1, + 1)\n headlines = [\" \"] + [str(x) for x in range(1, self.find_table_length() + 1)]\n self.__main_display_table.config(columns=headlines)\n\n for headline in headlines:\n self.__main_display_t... | [
"0.59914243",
"0.5855488",
"0.57265836",
"0.56227475",
"0.56114644",
"0.560301",
"0.5514179",
"0.54524493",
"0.5393159",
"0.53743225",
"0.5364472",
"0.5307299",
"0.5299479",
"0.52313066",
"0.5190084",
"0.5172421",
"0.5159925",
"0.51204914",
"0.5118278",
"0.5114456",
"0.509627... | 0.680281 | 0 |
Function to add noise to computed displacements. | def _addNoise(self):
self.dispNoise = self.dispRaw.copy()
self.dispNoise[:, 0] += self.sigmaEast * numpy.random.randn(self.numStations)
self.dispNoise[:, 1] += self.sigmaNorth * numpy.random.randn(self.numStations)
self.dispNoise[:, 2] += self.sigmaUp * numpy.random.randn(self.numStations)
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_noise(self):\n self.noise = np.random.poisson(lam=self.lam, size=self.image.shape)\n self.image += self.noise\n return",
"def add_noise(self):\n self.noise = np.random.poisson(lam=self.lam, size=self.im.shape)\n self.im += self.noise\n return",
"def noiseReduct... | [
"0.7346863",
"0.73364323",
"0.6962062",
"0.69417346",
"0.6785421",
"0.66143906",
"0.6522641",
"0.64694124",
"0.6469024",
"0.64301807",
"0.6414008",
"0.6387352",
"0.6387352",
"0.6382268",
"0.6361213",
"0.6329149",
"0.63185555",
"0.63116646",
"0.62970203",
"0.6281833",
"0.62209... | 0.77753025 | 0 |
Function to write VTK output file with noisy data and uncertainties. | def _writeVTKOutput(self):
sigma = numpy.ones((self.numStations, 3), dtype=numpy.float64)
sigma[:, 0] *= self.sigmaEast
sigma[:, 1] *= self.sigmaNorth
sigma[:, 2] *= self.sigmaUp
vtkHead = "# vtk DataFile Version 2.0\n" + \
"Synthetic GPS stations\n" + \
"ASCII\n" + \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeMeshVTP(self, outFile):\n # setup colors\n Colors = vtk.vtkFloatArray()\n #Colors.SetNumberOfComponents(3)\n Colors.SetNumberOfTuples(self.Npts)\n Colors.SetName(self.label) #can change to any string\n\n #points\n vtkPts = vtk.vtkPoints()\n\n #build ... | [
"0.6181256",
"0.60731375",
"0.604484",
"0.5964876",
"0.59515595",
"0.59307873",
"0.59143895",
"0.5879308",
"0.5833394",
"0.58281827",
"0.56651473",
"0.5646674",
"0.5646674",
"0.5636192",
"0.55498344",
"0.54766077",
"0.53818953",
"0.5370567",
"0.53543353",
"0.5322395",
"0.5265... | 0.69099677 | 0 |
This function removes the concatenation done by the concatenateFunction below on a string. Useful just for output purposes INPUT string a string which could have been some words being concatenated during the parsing process OUTPUT The same string without the concatenation i.e. without "_" of whatever the concatenation ... | def cleanConcatFunction(string, concat_symbol='_'):
return string.replace(concat_symbol, ' ') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_characters(input_string):\n\n allowed_characters = re.compile(\"[^a-zA-Z0-9_-]\")\n subbed_string = allowed_characters.sub(\"_\", input_string)\n\n string_to_shorten = re.compile(\"__+\")\n shortened_string = string_to_shorten.sub(\"_\", subbed_string)\n\n return shortened_string",
"def ... | [
"0.653593",
"0.6316806",
"0.6280432",
"0.6274362",
"0.6015656",
"0.5968117",
"0.59020895",
"0.58400863",
"0.5839648",
"0.5826309",
"0.57960254",
"0.5792228",
"0.57763314",
"0.5707373",
"0.5698845",
"0.56784046",
"0.56413144",
"0.5629006",
"0.56285655",
"0.5620721",
"0.561187"... | 0.7436505 | 0 |
This function is used to find whether there are in the string words that signal a particular name structure and returning both the structure and the adjusted string. If the particular name structure is not found then it is returned as a null, with the arab_string left untouched. INPUT arab_string The arabic string take... | def isolateNextWordDictKeys(arab_string, dict_keys):
extraction, before = '', ''
for prefix in dict_keys:
if prefix in arab_string:
arab_string_prefcorr = arab_string.replace(prefix, prefix[:-1]+'~').split(' ')
nameparts_pref = [1 if '~' in x else 0 for x in arab_string_pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_up_letter_a(query):\n key_words = ['line', 'route', 'bus']\n alphabet = ['b','c','d','e','f']\n num_chars = set('1234567890')\n special_cases = {\n 'dash':['dash'],\n 'nite':['nite'],\n 'one':['one'],\n 'link': ['link'], \n 'sounder':['sounder south', 'sound... | [
"0.5502802",
"0.5494281",
"0.53723246",
"0.5327867",
"0.52147365",
"0.51977557",
"0.5041407",
"0.49769938",
"0.49247393",
"0.4921425",
"0.49056858",
"0.48596206",
"0.4859447",
"0.48323047",
"0.48002437",
"0.47960705",
"0.47572154",
"0.47166967",
"0.47142044",
"0.47114736",
"0... | 0.7134072 | 0 |
Test if the formatting function returns the expected format. | def _test_output_formatting_func(self, sample: Any):
try:
if not type(sample) == iter:
self._formatting_func_return_types(format=sample)
return True
except Exception:
raise ValueError(
f"formatting_func must return {self._formatting_fun... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_is_entry_formatted(self):\n\n valid_formats = test_case_data.get('valid_formats')\n for i, valid_entry in enumerate(test_case_data.get('valid_entries')):\n entry = [value.strip() for value in valid_entry.split(',')]\n format_fields = valid_formats[i].split(',')\n ... | [
"0.6874805",
"0.68185186",
"0.6475756",
"0.64038515",
"0.63263196",
"0.6320641",
"0.6295214",
"0.6260196",
"0.62480706",
"0.6208293",
"0.61877877",
"0.6143484",
"0.61367035",
"0.61304516",
"0.60836923",
"0.60626906",
"0.5995982",
"0.5972424",
"0.59446394",
"0.5940874",
"0.590... | 0.756892 | 0 |
Define a task configuration for text classification. It takes default values for `text` and `label` using datasets Fields and Questions or a custom `formatting_func` as Callable. See Examples underneath for more details. | def for_text_classification(
cls,
formatting_func: Callable[[Dict[str, Any]], Union[None, str, List[str], Iterator[str]]] = None,
text: Optional[TextField] = None,
label: Optional[
Union[
RatingQuestion,
LabelQuestion,
RankingQu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_text_task(self):\n args = BASE_ARGS.copy()\n args.update(TEXT_ARGS)\n valid, test = testing_utils.train_model(args)\n self.assertLessEqual(\n valid['ppl'], 1.5, 'failed to train image_seq2seq on text task'\n )",
"def __init__(self, text_field, label_field, i... | [
"0.5934084",
"0.5724462",
"0.5574958",
"0.5572758",
"0.5390726",
"0.52457625",
"0.52252996",
"0.5208123",
"0.51948917",
"0.51803094",
"0.5114592",
"0.5097679",
"0.50764954",
"0.5075256",
"0.50482696",
"0.50352633",
"0.5032635",
"0.50311404",
"0.50221634",
"0.5015627",
"0.5013... | 0.7055858 | 0 |
! Function checks mbed serial port in Windows registry entries tid TargetID Returns None if port is not found. In normal circumstances it should never return None This goes through a whole new loop, but this assures that even if serial port (COM) is not detected, we still get the rest of info like mount point etc. | def _com_port(self, tid):
winreg.Enum = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
r'SYSTEM\CurrentControlSet\Enum')
usb_devs = winreg.OpenKey(winreg.Enum, 'USB')
logger.debug("_com_port usb_devs %r",
list(self.iter_keys_as_str(usb_devs)))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_serial_port(target):\n found = False\n detail = \"\"\n ser_ports = [tuple(port) for port in list(serial.tools.list_ports.comports())]\n for port in ser_ports:\n if target == port[0]:\n found = True\n if 'USB VID:PID=0403:6001' in port[2] and target == port[0]:\... | [
"0.6947311",
"0.6274355",
"0.6084173",
"0.58881885",
"0.5873965",
"0.5850178",
"0.58487296",
"0.5692545",
"0.56794196",
"0.5678281",
"0.564351",
"0.563512",
"0.5585246",
"0.55425686",
"0.55035055",
"0.54775393",
"0.5459275",
"0.5451576",
"0.5447472",
"0.54399544",
"0.5439953"... | 0.7150289 | 0 |
! Function returns if the mountpoint exists mountpoint Path of mountpoint Returns True if mountpoint exists, otherwise False This uses a Windows subcommand to avoid throwing a Python error box when the device is in an ejected state. | def _mount_point_exists(self, mountpoint):
cmd = ['dir', mountpoint]
logger.debug('running command: %s' % (' '.join(cmd)))
stdout, stderr, retval = self._run_cli_process(cmd)
if not retval:
logger.debug("mountpoint %s ready" % mountpoint)
else:
logger.deb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_mountpoint(path: str) -> bool:\n mtpt = subprocess.run([\"mountpoint\", path], check=False, capture_output=True)\n return mtpt.returncode == 0",
"def check_already_mounted(devpath, mountpoint):\n mounts = Mounter().read_mounts()\n for m in mounts:\n if devpath == m.device and mountpoint... | [
"0.7915238",
"0.7606054",
"0.7584361",
"0.7067466",
"0.6938742",
"0.68514806",
"0.6802525",
"0.6770125",
"0.66948426",
"0.66906554",
"0.65935236",
"0.65843415",
"0.657996",
"0.6422529",
"0.6376028",
"0.63482285",
"0.6274651",
"0.6170984",
"0.6170984",
"0.6137184",
"0.61274403... | 0.8080602 | 0 |
! Function filters devices' mount points for valid TargetID Returns [(, ), ..] TargetID should be a hex string with 1048 chars | def get_mbeds(self):
mbeds = []
for mbed in self.get_mbed_devices():
mountpoint = re.match('.*\\\\(.:)$', mbed[0]).group(1)
logger.debug('Registry mountpoint %s', mountpoint)
if self._mount_point_exists(mountpoint):
# TargetID is a hex string with 10-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mbed_devices(self):\n upper_ven = [ven.upper() for ven in self.usb_vendor_list]\n mounts_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SYSTEM\\MountedDevices')\n for point, label, _ in self.iter_vals(mounts_key):\n printable_label = label.decode('utf-16le', 'ignore')\n ... | [
"0.6025476",
"0.5796013",
"0.57631946",
"0.57285166",
"0.5726447",
"0.5698348",
"0.5698098",
"0.5433151",
"0.54126495",
"0.53860116",
"0.536499",
"0.5351264",
"0.5344143",
"0.5317073",
"0.5311343",
"0.52771974",
"0.52599555",
"0.52402437",
"0.5232099",
"0.52077824",
"0.520168... | 0.5877243 | 1 |
Returns the GramSchmidt orthogonalization of a basis. | def gram_schmidt(basis):
orthog = np.array([None for _ in basis])
mu = np.array([[None for _ in basis] for _ in basis])
orthog[0] = basis[0]
for i in range(1, len(basis)):
for j in range(i):
mu[i][j] = np.dot(basis[i], orthog[j])/sq_norm(orthog[j])
orthog[i] = basis[i]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orthogonal_component(self, basis: Vector) -> Vector:\n return self - self.parallel_component(basis)",
"def as_homogenous_transformation(self):\n r3 = self.orientation.normalize().unit_quaternion_as_r3_rotation_matrix()\n return matrix.sqr((r3[0],r3[1],r3[2],self.translation[0],\n ... | [
"0.6558102",
"0.5786281",
"0.57692736",
"0.5737058",
"0.56813425",
"0.5560548",
"0.5488191",
"0.5464964",
"0.5458864",
"0.53365046",
"0.53198373",
"0.53031",
"0.5286599",
"0.5259574",
"0.5221253",
"0.52201205",
"0.51764774",
"0.5171264",
"0.5152199",
"0.51308274",
"0.5091211"... | 0.7551228 | 0 |
Returns an LLLreduced basis. | def lll(basis, delta=.75):
orthog = gram_schmidt(basis)
mu = get_mus(basis, orthog)
k = 1
while k < len(basis):
for j in range(k - 1, -1, -1):
# Size condition
if np.abs(mu[k][j]) > .5:
basis[k] = basis[k] - np.rint(mu[k, j]) * basis[j]
ort... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lll(basis, delta=.75):\n orthog = gram_schmidt(basis)\n mu = get_mus(basis, orthog)\n k = 1\n while k < len(basis):\n for j in range(k - 1, -1, -1):\n # Size condition\n if np.abs(mu[k][j]) > .5:\n basis[k] = basis[k] - np.... | [
"0.6088242",
"0.5603393",
"0.55973816",
"0.55534863",
"0.54981947",
"0.5453062",
"0.54469985",
"0.54325265",
"0.5411515",
"0.5392617",
"0.5347899",
"0.5345974",
"0.53293407",
"0.5326715",
"0.5310972",
"0.52872187",
"0.5283247",
"0.52804685",
"0.5273278",
"0.5272898",
"0.52615... | 0.6045903 | 1 |
Returns an LLLreduced basis. | def lll(basis, delta=.75):
orthog = gram_schmidt(basis)
mu = get_mus(basis, orthog)
k = 1
while k < len(basis):
for j in range(k - 1, -1, -1):
# Size condition
if np.abs(mu[k][j]) > .5:
basis[k] = basis[k] - np.rint(mu[k, j]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lll(basis, delta=.75):\n orthog = gram_schmidt(basis)\n mu = get_mus(basis, orthog)\n k = 1\n while k < len(basis):\n for j in range(k - 1, -1, -1):\n # Size condition\n if np.abs(mu[k][j]) > .5:\n basis[k] = basis[k] - np.rint(mu[k, j]) * basis[j]\n ... | [
"0.6045903",
"0.5603393",
"0.55973816",
"0.55534863",
"0.54981947",
"0.5453062",
"0.54469985",
"0.54325265",
"0.5411515",
"0.5392617",
"0.5347899",
"0.5345974",
"0.53293407",
"0.5326715",
"0.5310972",
"0.52872187",
"0.5283247",
"0.52804685",
"0.5273278",
"0.5272898",
"0.52615... | 0.6088242 | 0 |
Test the `model` on the `batch`, return the decoded textual tokens and the Seq2SeqOutput. | def decode_batch(
batch: Batch,
model: Seq2Seq,
vocab: Vocab,
criterion=None,
*,
pack_seq=True,
show_cover_loss=False
) -> Tuple[List[List[str]], Seq2SeqOutput]:
if not pack_seq:
input_lengths = None
else:
input_lengths = batch.input_lengths
with torch.no_grad():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_batch(batch: Batch, model: Seq2Seq, vocab: Vocab, criterion=None, *, pack_seq=True,\n show_cover_loss=False) -> Tuple[List[List[str]], Seq2SeqOutput]:\n if not pack_seq:\n input_lengths = None\n else:\n input_lengths = batch.input_lengths\n with torch.no_grad():\n input_tenso... | [
"0.7244397",
"0.6625542",
"0.61642754",
"0.6108666",
"0.6038354",
"0.6008881",
"0.5928245",
"0.5921694",
"0.58876944",
"0.58759373",
"0.5862399",
"0.5862399",
"0.58540314",
"0.58071756",
"0.579755",
"0.5755968",
"0.57550913",
"0.5715045",
"0.5712757",
"0.5697481",
"0.5682049"... | 0.7166712 | 1 |
Adds all ec2 particles as parents to the route53 particle. | def set_parents(self):
route53 = self.pcf_field.get_particles(flavor="route53_record")
route53_record_pcf_name = route53.get("pcf_name", self.name)
ec2_particles = self.pcf_field.get_particles(flavor="ec2_instance")
self.pcf_field.particles["route53_record"][route53_record_pcf_name].par... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setupParticles(self):\n\n for ss in self.pargs['species']:\n\n # Make sure we are setting up particles, not walls (so we check for id existence)\n if 'id' in ss and 'wall' not in ss:\n if not self.rank:\n logging.info('Setting up particles for group{id}'.format(**ss))\n\n ra... | [
"0.61152035",
"0.6037008",
"0.5660988",
"0.55194426",
"0.54729265",
"0.54009485",
"0.53308225",
"0.53292173",
"0.5237541",
"0.52201533",
"0.5209852",
"0.51716703",
"0.51640767",
"0.5156777",
"0.5104819",
"0.50954765",
"0.50922084",
"0.50906056",
"0.5086624",
"0.5083679",
"0.5... | 0.7317881 | 0 |
Write placeholder file with error traceback for a failed plot | def handle_failed_plot(htmlfile, header, qatype):
import sys
import traceback
lines = traceback.format_exception(*sys.exc_info())
msg = f'ERROR generating {htmlfile}\n' + ''.join(lines)
print(msg)
print('Proceeding with making other plots')
pc = write_placeholder_html(
htmlfile, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_plot_error(self, script_runner: ScriptRunner, tmp_path: Path) -> None:\n outfile = tmp_path.joinpath(\"projection.png\")\n logfile = tmp_path.joinpath(\"plot.log\")\n result = script_runner.run(\n \"qaa\",\n \"plot\",\n \"-i\",\n \"test.csv\... | [
"0.6591125",
"0.63694155",
"0.6219213",
"0.6144143",
"0.6135497",
"0.6114212",
"0.61114365",
"0.599357",
"0.58829033",
"0.5861188",
"0.5828181",
"0.5810068",
"0.5792821",
"0.5768972",
"0.5742196",
"0.5707608",
"0.5700804",
"0.5673913",
"0.5639948",
"0.5639244",
"0.56257504",
... | 0.7199973 | 0 |
Inject the datadir with resources for the specific test function. If the test function is declared in a class then datadir is ClassName/FunctionName otherwise it is only FunctionName. | def test_datadir(request, datadir):
function_name = request.function.__name__
if not request.cls:
return datadir / function_name
class_name = request.cls.__name__
return datadir / "{0}/{1}".format(class_name, function_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_data_directory(test_directory):\n return os.path.join(test_directory, \"test_data\")",
"def test_data_dir(self):\n return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')",
"def data_dir():\n return os.path.join(os.path.dirname(__file__), 'test', 'data')",
"def datadir()... | [
"0.638936",
"0.6324544",
"0.630491",
"0.62768674",
"0.62342775",
"0.6139688",
"0.60816765",
"0.6000286",
"0.59875137",
"0.59366053",
"0.59187216",
"0.59109604",
"0.5751206",
"0.57498294",
"0.573671",
"0.56661105",
"0.5636069",
"0.56197006",
"0.5591264",
"0.55592066",
"0.55461... | 0.7119152 | 0 |
Mock convert_to_date function by enforcing the timezone to UTC. | def convert_to_date_mock(request, mocker):
module_under_test = request.node.fspath.purebasename.replace("test_", "")
def _convert_to_date_utc(*args, **kwargs):
from dateutil import tz
from awsbatch.utils import convert_to_date
# executes convert_to_date but overrides arguments so that... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dt_obj_to_date(settings):\n # Set the TIME_ZONE in the settings.\n settings.TIME_ZONE = \"America/New_York\"\n\n # A datetime that refers to 20:00 on January 1, 2018 in New York.\n datetime_2018_01_01_2000_ny = make_aware(\n datetime(year=2018, month=1, day=1, hour=20, minute=0, second=... | [
"0.66539854",
"0.66451216",
"0.6521353",
"0.6421473",
"0.63335186",
"0.6320076",
"0.6309445",
"0.62066513",
"0.61313474",
"0.60946304",
"0.60893184",
"0.6073775",
"0.60714597",
"0.606727",
"0.59488356",
"0.5944669",
"0.593583",
"0.5926346",
"0.5866422",
"0.5855977",
"0.580631... | 0.77788293 | 0 |
Create a function to easily mock boto3 clients. To mock a boto3 service simply pass the name of the service to mock and the mocked requests, where mocked_requests is an object containing the method to mock, the response to return and the expected params for the boto3 method that gets called. The function makes use of b... | def boto3_stubber(mocker, boto3_stubber_path):
__tracebackhide__ = True
created_stubbers = []
mocked_clients = {}
mocked_client_factory = mocker.patch(boto3_stubber_path, autospec=True)
# use **kwargs to skip parameters passed to the boto3.client other than the "service"
# e.g. boto3.client("ec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_s3_boto_returns() -> callable:\n\n def client(aws_res, aws_access_key_id=None, aws_secret_access_key=None):\n return BotoMockReturns()\n\n return client",
"def test_create_aws_clients(self, mock_session_constructor):\n mock_session = Mock(name=\"mock-boto3-session\")\n mock_session.cl... | [
"0.71789426",
"0.6988649",
"0.6870784",
"0.6612907",
"0.6551662",
"0.6539705",
"0.6499572",
"0.64352554",
"0.6249192",
"0.6236705",
"0.61655885",
"0.6154003",
"0.61370367",
"0.61270624",
"0.6124877",
"0.6110236",
"0.60382575",
"0.60242254",
"0.59798104",
"0.5970338",
"0.59626... | 0.77995694 | 0 |
Mock AWSBatchCliConfig object with a default mock. | def awsbatchcliconfig_mock(request, mocker):
module_under_test = request.node.fspath.purebasename.replace("test_", "")
mock = mocker.patch("awsbatch." + module_under_test + ".AWSBatchCliConfig", autospec=True)
for key, value in DEFAULT_AWSBATCHCLICONFIG_MOCK_CONFIG.items():
setattr(mock.return_value... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_config(temp_dir):\n get_config_mock = Mock()\n config = base_config()\n config['skills']['priority_skills'] = ['foobar']\n config['data_dir'] = str(temp_dir)\n config['server']['metrics'] = False\n config['enclosure'] = {}\n\n get_config_mock.return_value = config\n return get_conf... | [
"0.6471726",
"0.6430745",
"0.6312138",
"0.6127427",
"0.60928434",
"0.60719085",
"0.60572356",
"0.60341793",
"0.60202825",
"0.6009339",
"0.60029703",
"0.6001319",
"0.5980355",
"0.59687495",
"0.59255785",
"0.59233177",
"0.59164524",
"0.5870401",
"0.5860858",
"0.585796",
"0.5851... | 0.7780925 | 0 |
determines whether a building has a heating system installed or not | def has_heating_system(bpr):
if bpr.hvac['type_hs'] in {'T1', 'T2', 'T3', 'T4'}:
return True
elif bpr.hvac['type_hs'] in {'T0'}:
return False
else:
raise | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_system(self) -> bool:",
"def is_schrodinger_installed(env):\n return (\n env.get('PHENIX_SCHRODINGER', False)\n and env.get(\"SCHRODINGER\", False)\n and os.path.exists(env[\"SCHRODINGER\"])\n )",
"def is_to_be_built_or_is_installed(self, shutit_module_obj):\n\t\tshutit_global.shutit_globa... | [
"0.66437906",
"0.6479731",
"0.6423521",
"0.63806885",
"0.615593",
"0.6150311",
"0.6102878",
"0.60701764",
"0.60650265",
"0.60527444",
"0.60174936",
"0.6010887",
"0.60033476",
"0.59946805",
"0.5971249",
"0.5884356",
"0.5868055",
"0.58558154",
"0.5851581",
"0.5818157",
"0.58049... | 0.6952637 | 0 |
determines whether a building has a cooling system installed or not | def has_cooling_system(bpr):
if bpr.hvac['type_cs'] in {'T1', 'T2', 'T3'}:
return True
elif bpr.hvac['type_cs'] in {'T0'}:
return False
else:
raise | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_to_be_built_or_is_installed(self, shutit_module_obj):\n\t\tshutit_global.shutit_global_object.yield_to_draw()\n\t\tcfg = self.cfg\n\t\tif cfg[shutit_module_obj.module_id]['shutit.core.module.build']:\n\t\t\treturn True\n\t\treturn self.is_installed(shutit_module_obj)",
"def __bool__(self):\n return... | [
"0.6498939",
"0.6334094",
"0.6314803",
"0.6210496",
"0.6150791",
"0.60830295",
"0.6026727",
"0.6025066",
"0.5978753",
"0.5978484",
"0.5965441",
"0.59564024",
"0.5954954",
"0.586624",
"0.5849295",
"0.5799269",
"0.5765042",
"0.57600635",
"0.5757374",
"0.57419705",
"0.57255745",... | 0.71541977 | 0 |
determines whether a building's heating system is ac or not | def heating_system_is_ac(bpr):
if bpr.hvac['type_hs'] in {'T3'}: # central ac
return True
elif bpr.hvac['type_hs'] in {'T0', 'T1', 'T2', 'T4'}:
return False
else:
print('Error: Unknown heating system')
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_building_eye(self):\r\n pass",
"def cooling_system_is_ac(bpr):\n\n if bpr.hvac['type_cs'] in {'T2', 'T3'}: # mini-split ac and central ac\n return True\n elif bpr.hvac['type_cs'] in {'T0', 'T1'}:\n return False\n else:\n print('Error: Unknown cooling system')\n ... | [
"0.6569889",
"0.6557159",
"0.6150436",
"0.6105359",
"0.61021197",
"0.6030584",
"0.5999053",
"0.58855844",
"0.58206296",
"0.5806526",
"0.5806343",
"0.5796101",
"0.57949114",
"0.5777591",
"0.5751004",
"0.5728166",
"0.5694908",
"0.56943315",
"0.56822884",
"0.5672295",
"0.5649619... | 0.70759267 | 0 |
Determine the most compact set of units for a quantity given in SI units. Also, choose which units of equal dimensions to choose while keeping the number near 1. | def unit_string(value, units, prefu={'M', 'L', 'J', 'C', 'V', 'N', 'W', 'Pa'}):
if units == unity or not value:
return value, "", ""
SIunits = list(units)
derived = dict((pu, 0) for pu in prefu if sum(abs(t) for t in unitquant[pu].units) > 1)
while derived:
(improvement, d, sign) =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_saturation_mixing_ratio_dimensions():\n p = 998. * units.mbar\n temp = 20 * units.celsius\n assert str(saturation_mixing_ratio(p, temp).units) == 'dimensionless'",
"def limited_optimal_SC(U, S, size = 1, redundancy = 1):\n S_length = len(S)\n S_class = S.__class__\n S = sorted(S, key =... | [
"0.5797679",
"0.5738901",
"0.5628715",
"0.55874956",
"0.55798566",
"0.55630475",
"0.5454984",
"0.54325986",
"0.5369834",
"0.5353563",
"0.53342295",
"0.5327652",
"0.5311191",
"0.5302189",
"0.5294104",
"0.5280978",
"0.52780586",
"0.5275293",
"0.525059",
"0.5249777",
"0.5214434"... | 0.6231865 | 0 |
adds chemistry mark up to bracketed text and turns text following _ into subscript | def latex_name(name):
name = name + '_' #protects against .split('_') failing
if name.startswith('['): #format leading [] as concentration
head, tail = name[1:].rsplit(']', 1)
head = r'[\ce{%s}]' % head
else:
if '[' in name: # turn internal [] into marked-up subscripts
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def c_text(text):\n return \"C {}\".format(text.replace(\"_\", \" \"))",
"def c_text(text):\n if text:\n if '_' in text:\n text = text.replace(\"_\", \" \")\n return 'C {}'.format(escape(text))",
"def sub(string, subscript):\n return string + \"<sub>\" + subscript + \"</sub>\"",
... | [
"0.6515891",
"0.6280639",
"0.62265366",
"0.6211329",
"0.5983687",
"0.5851196",
"0.57489425",
"0.57472974",
"0.56578785",
"0.56461334",
"0.5576803",
"0.5546965",
"0.5514159",
"0.5496377",
"0.5482179",
"0.5426905",
"0.5415635",
"0.5408027",
"0.5408027",
"0.5407943",
"0.53962034... | 0.6319925 | 1 |
Verifies AudioUtilities.GetAllSessions() is reliable | def test_getallsessions_reliability(self):
for _ in range(100):
sessions = AudioUtilities.GetAllSessions()
assert len(sessions) > 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_session_unicode(self):\n with captured_output() as (out, err):\n sessions = AudioUtilities.GetAllSessions()\n print(\"sessions: %s\" % sessions)\n for session in sessions:\n print(\"session: %s\" % session)\n print(\"session.Process: %s... | [
"0.6660475",
"0.58789617",
"0.58319485",
"0.58016133",
"0.5662469",
"0.54611784",
"0.54528046",
"0.5441697",
"0.5364614",
"0.53240484",
"0.53230804",
"0.5305665",
"0.53041375",
"0.5298128",
"0.52978593",
"0.5278724",
"0.5273857",
"0.52692544",
"0.5252016",
"0.52457505",
"0.52... | 0.8514844 | 0 |
Removes any anonymous functions that are nested inside other anonymous functions and replaces them with their generated function names | def remove_lambda_nesting(self):
#Iterate through each pair of functions
#if one is present in another, replace its body with its name
for f in self.func_dict:
for g in self.func_dict:
if f == g: continue #Don't want to replace a function with itself!
self.func_dict[f] = self.func_dict[f].replace(self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def js_minify2(js):\n log.debug(\"Obfuscating Javascript variables names inside functions.\")\n # if eval() or with{} is used on JS is not too Safe to Obfuscate stuff.\n is_ok = \"eval(\" not in js and \"with{\" not in js and \"with {\" not in js\n return slim_func_names(slim_params(js)) if is_ok else ... | [
"0.648757",
"0.6213205",
"0.6018396",
"0.5916446",
"0.58156914",
"0.57666296",
"0.5710715",
"0.5604765",
"0.55612296",
"0.5507619",
"0.5499895",
"0.5399931",
"0.53618693",
"0.5332593",
"0.532855",
"0.5327338",
"0.5318895",
"0.52616566",
"0.52031004",
"0.5190378",
"0.51753527"... | 0.77969486 | 0 |
Replaces the context dependent Lithp keyword `self` with the generated name of the function in the C++ code | def replace_self_with_func_names(self):
for name in self.func_dict:
self.func_dict[name] = self.func_dict[name].replace('self', name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_Name(self, node):\n if isinstance(node.ctx, gast.Param) and node.id != \"self\":\n node.id += '_new'\n\n return node",
"def my_name(self):\n# different block has different namespace\n# local namesapce for a function is created when the function is called, \n# is deleted when th... | [
"0.59982324",
"0.5961978",
"0.59401125",
"0.5846354",
"0.5821911",
"0.58042526",
"0.58042526",
"0.58042526",
"0.58042526",
"0.57864064",
"0.57705665",
"0.57258326",
"0.5696907",
"0.5696202",
"0.5696202",
"0.5696202",
"0.5696202",
"0.5696202",
"0.5696202",
"0.5696202",
"0.5696... | 0.63227475 | 0 |
Creates function declarations with parameter types and return types. Higher order functions are supported. Function declarations are also used as function signatures. | def make_func_declarations(self):
for name in self.func_dict:
body = Lexer(self.func_dict[name]).get_tokens()
i = body.index('\\') + 1 #Start of parameters
j = body.match_paren(i)
param_tokens = body[i + 1: j] #Stuff inside parentheses
# print "param list:", param_tokens
params = self.split_par... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_function_definition(self, spec, decl, param_decls, body):\n declaration = self._build_declarations(spec, [dict(decl=decl, init=None)])[0]\n\n # Adding \"list\" to type.\n spec.name = [spec.name]\n return ast.FuncDef(spec, declaration, param_decls, body)",
"def make_function... | [
"0.6594739",
"0.65306395",
"0.64215755",
"0.63276184",
"0.6239802",
"0.6235193",
"0.6168966",
"0.61457175",
"0.61066973",
"0.61028636",
"0.6060046",
"0.6017785",
"0.590887",
"0.584038",
"0.5814787",
"0.5772271",
"0.5721078",
"0.5718508",
"0.5675119",
"0.56572306",
"0.5655964"... | 0.7639808 | 0 |
Takes params without surrounding parentheses and splits them into a list. `params` is a Tokens object | def split_params(self, params):
index = 0
acc = ''
ret = [] #return value (is ret a bad name?)
while index < len(params):
if params[index] == ',': #End of a parameter
ret.append(acc)
acc = ''
elif params[index] == '(': #start of a type that is a function
end = params.match_paren(index)
whi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _split_parameters(self, parameters):\n if not parameters:\n return []\n return [parameter.strip() for parameter in parameters.split(', ')]",
"def _parse_params(self, params):\r\n if params[0] == \":\":\r\n params = [params[1:]]\r\n else:\r\n params... | [
"0.7318879",
"0.65878826",
"0.6532124",
"0.6359012",
"0.63565",
"0.628192",
"0.6200408",
"0.6143472",
"0.60085636",
"0.5958489",
"0.59024674",
"0.58554566",
"0.58478713",
"0.58243763",
"0.5819168",
"0.5817609",
"0.57682514",
"0.57305366",
"0.5723642",
"0.56711",
"0.56641",
... | 0.78720284 | 0 |
Converts a string that is a name and a string that constitutes a type that may be simple (e.g. int, double) or a function (e.g. (int,int)>int) into its C++ definition. `name` may be an empty string. convert_type('x', 'int') => 'int x' convert_type('x', '(int,double)>bool') => bool (x)(int,double) | def convert_type(self, name, type):
# print 'Called with name = %s and type = %s' %(name, type)
name = ''.join(name.split())
type = ''.join(type.split())
if re.match(r'\w+', type): #It's a concrete type
return self.TYPES_DICT.get(type,type) + ' ' + name
arrow = type.rfind('->')
assert arrow != -1, "If... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str_to_type(name_type):\n if name_type == 'float' or name_type == 'Float':\n return float\n if name_type == 'bool':\n return bool\n if name_type == 'int':\n return lambda x: int(float(x))\n if name_type == 'list':\n return ast.literal_eval\n if name_type == 'date':\n ... | [
"0.724843",
"0.6358202",
"0.60223573",
"0.6019122",
"0.59391856",
"0.59133995",
"0.5895926",
"0.5723027",
"0.5650539",
"0.5623648",
"0.56058836",
"0.5577051",
"0.55124867",
"0.5473153",
"0.546907",
"0.5458522",
"0.5451502",
"0.54493433",
"0.5405672",
"0.5402961",
"0.5366508",... | 0.7208166 | 1 |
Extracts bodies of lambda functions (as opposed to their headers). These bodies will then be translated to a series of function calls. | def make_func_bodies(self):
for name in self.func_dict:
tok = Lexer(self.func_dict[name]).get_tokens()
end = tok.match_paren(0)
header_end = tok.match_paren(2)
if tok[header_end+2] == '(': #Function returns another function
start = body.match_paren(header_end+2)+3
else: #Function returns a concret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_cpp_func_bodies(self):\n\t\tfor name, body in self.func_bodies.iteritems():\n\t\t\tt = Lexer(body).get_tokens()\t\t\t\n\t\t\tS = [] #Stack\n\t\t\tx = 0\n\t\t\twhile x < len(t):\n\t\t\t\tif t[x] == '(': #function call begins\n\t\t\t\t\tx += 1\n\t\t\t\t\tS.append(self.FUNCS_DICT.get(t[x], t[x]) + '(')\n\t\t... | [
"0.5970339",
"0.57579714",
"0.5603299",
"0.5595842",
"0.5576972",
"0.557278",
"0.54508555",
"0.5244098",
"0.51589644",
"0.51544106",
"0.51487875",
"0.5145433",
"0.5137901",
"0.5126679",
"0.5111359",
"0.51065105",
"0.5073124",
"0.5066296",
"0.498407",
"0.4982213",
"0.49675852"... | 0.62874913 | 0 |
Finds the outermost function call which will go in the main method This adds the function int main() to func_dict and func_declarations. | def make_main_function(self):
self.main = self.tokens.get_joined()
for func in self.func_dict:
self.main = self.main.replace(self.func_dict[func], func) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_code():\n pass",
"def call_chain_to_next_log_calls_fn(cls):\n curr_frame = sys._getframe(2) # caller-of-caller's frame\n\n call_list = []\n prev_indent_level = -1\n\n found = False\n found_enabled = False\n hit_bottom = False # break both loops: reache... | [
"0.5653428",
"0.56431276",
"0.5617302",
"0.5558125",
"0.5531647",
"0.54793715",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
"0.542951",
... | 0.662496 | 0 |
Use the extracted Lithp function bodies and convert them to C style function calls. i.e. (f a b) => f(a,b) | def make_cpp_func_bodies(self):
for name, body in self.func_bodies.iteritems():
t = Lexer(body).get_tokens()
S = [] #Stack
x = 0
while x < len(t):
if t[x] == '(': #function call begins
x += 1
S.append(self.FUNCS_DICT.get(t[x], t[x]) + '(')
elif t[x] == ')': #function call ends
ac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cython_c2py_conv_function_pointer(t_, ts):\n t = t_[1]\n argnames = []\n argdecls = []\n argbodys = []\n argrtns = []\n for n, argt in t[1][2]:\n argnames.append(n)\n decl, body, rtn = ts.cython_py2c(n, argt, proxy_name=\"c_\" + n)\n ar... | [
"0.62955445",
"0.6149002",
"0.61377984",
"0.58625335",
"0.5812451",
"0.5701246",
"0.5591155",
"0.558048",
"0.5512143",
"0.55078083",
"0.55044824",
"0.5494417",
"0.5475925",
"0.5453971",
"0.5426847",
"0.5404683",
"0.54044217",
"0.5385849",
"0.5326321",
"0.53102404",
"0.5283622... | 0.65886545 | 0 |
Converts the Lithp atom given as a string into its corresponding C++ atom. Right now this doesn't do anything... | def convert_atom(self, atom):
return atom | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def atom(token):\n if REGEX_INTEGER.match(token):\n return int(token)\n else:\n return token",
"def _eval_atom(self, vars, word):\n if word == \"null\":\n return None\n elif word == \"true\":\n return True\n elif word == \"false\":\n return False\n elif word.startsw... | [
"0.56072026",
"0.5580228",
"0.5545642",
"0.55160236",
"0.5515207",
"0.5508885",
"0.5454122",
"0.5442079",
"0.5442079",
"0.5370866",
"0.53228533",
"0.5314551",
"0.51500463",
"0.5054988",
"0.50102276",
"0.49764416",
"0.49750704",
"0.495674",
"0.4956634",
"0.4945429",
"0.4919357... | 0.6524072 | 0 |
Return converted C++ code as a string | def get_cpp(self):
return self.converted | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fortran_c_wrapper(self) -> str:\n return ''",
"def ccode(self):\n from devito.ir.iet.visitors import CGen\n return CGen().visit(self)",
"def _compile(self, filename, source):\n \n if source and source[-1] != '\\n':\n source = source + '\\n'\n code = __bu... | [
"0.65639573",
"0.64526314",
"0.644458",
"0.64160323",
"0.63064027",
"0.62218493",
"0.6220663",
"0.61773986",
"0.61729866",
"0.61630183",
"0.6146629",
"0.6141982",
"0.61186457",
"0.61044747",
"0.6082754",
"0.60820997",
"0.60719126",
"0.6055396",
"0.60531914",
"0.6030124",
"0.5... | 0.6832832 | 0 |
Return the position with max Density | def get_max_density(self):
max_density = str(self.density.index(min(self.density)) + 1)
print(max_density)
return max_density | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_max_density_index(self, disturbed_car):\n return self.cars.get_max_density_index(disturbed_car)",
"def __FindMaxGradientValueOnNormal(self, magnitude, orientation, p1, p2):\n # Create the output variable.\n maxPoint = (0, 0)\n\n # Get integer coordinates on the straight line b... | [
"0.71303064",
"0.67850804",
"0.6763631",
"0.67602",
"0.6744851",
"0.67433864",
"0.6743282",
"0.6679849",
"0.6645099",
"0.6623529",
"0.6609793",
"0.65876126",
"0.65859926",
"0.65777016",
"0.6545563",
"0.6538954",
"0.6536151",
"0.65309983",
"0.6521032",
"0.6517958",
"0.65128976... | 0.79490525 | 0 |
Encodes all the tx queries using pandas df operations | def encode_txs(self, fee=3000):
if len(self.df) == 0:
self.update_unique_tokens()
# TODO: Something more like this (not using apply)
"""
self.df["encoded_out"] = self.contract.functions.quoteExactInputSingle(
self.WETH, self.df["address"], fee, sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize_and_encode_pandas(dataframe,stopindex=1e9,max_length=128):\n encoded_tweets = []\n token_type_ids = []\n attention_mask = []\n labels_6_types = []\n labels_4_types = []\n interaction_types = []\n \n counter = 0\n for i in range(len(dataframe)):\n try:\n #to... | [
"0.5627541",
"0.55950433",
"0.5581169",
"0.55755097",
"0.5559585",
"0.55198216",
"0.54713374",
"0.54534435",
"0.5395155",
"0.5389053",
"0.53796464",
"0.53513604",
"0.53248686",
"0.531389",
"0.5303571",
"0.5282318",
"0.5278682",
"0.5276844",
"0.5256127",
"0.5253625",
"0.524962... | 0.71973723 | 0 |
if Session has expired or was deleted then appropriate response is returned. Otherwise the measurement is updated. TODO Sean check me out Erors in measurement must be handled with an alert and return to home. This is done by conditions of the response on the front end | def updateMeasurement(self, auth):
auth = parseSession(auth)
try:
# TODO Sean check me out: implementing authentication
session = self.sessionManager.getSession(auth['sessionId'], auth['username'])
except AuthenticationError as e:
# TODO Sean check me out: dea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_updated_stats(request):\n\t# read current values in chart\n\tlog_file = open('./load_charts/static/load_charts/uptime_log', 'r')\n\tuptime_values = ast.literal_eval(log_file.read())\n\tlog_file.close()\n\t#defines current oldest entry\n\toldest_record = datetime.datetime.strptime(uptime_values[-1][\"date\"... | [
"0.5572117",
"0.5531126",
"0.55142665",
"0.5512829",
"0.5486714",
"0.5482698",
"0.5454137",
"0.5449564",
"0.54358476",
"0.5415202",
"0.5399",
"0.5394926",
"0.539055",
"0.5368139",
"0.5364002",
"0.5353066",
"0.53266233",
"0.53075415",
"0.52746856",
"0.52423775",
"0.52232254",
... | 0.5867913 | 0 |
Checks if we are able to set the value that the parameter framework just returned to us. valuePreviouslyGotten the value we are trying to set valueToSet the value we are trying to set | def checkConsistency(self, valuePreviouslyGotten):
(success, errorMsg) = pfw.set(self._paramPath, valuePreviouslyGotten)
return valuePreviouslyGotten, success | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_set(self, value):\r\n return value",
"def trySetValue(self, input):\r\n if (self.isInputValid(input)):\r\n self.value = input\r\n return True\r\n else:\r\n return False",
"def isSetValue(self):\n return _libsbml.Parameter_isSetValue(self)",
... | [
"0.64778054",
"0.6440434",
"0.64297444",
"0.6346078",
"0.6338097",
"0.6312978",
"0.62864494",
"0.6254582",
"0.62217575",
"0.62066925",
"0.61121804",
"0.60919106",
"0.6051976",
"0.6047704",
"0.59978104",
"0.5978213",
"0.5972221",
"0.59664565",
"0.5966167",
"0.59653634",
"0.595... | 0.6596981 | 0 |
Checks that the second get value is strictly equivalent to the consistency set. This ensures that the parameterframework behaves as expected. valuePreviouslySet the value we had previously set | def checkBijectivity(self, valuePreviouslySet):
secondGet = pfw.get(self._paramPath)
if secondGet != valuePreviouslySet:
return secondGet, False
return secondGet, True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkConsistency(self, valuePreviouslyGotten):\n (success, errorMsg) = pfw.set(self._paramPath, valuePreviouslyGotten)\n\n return valuePreviouslyGotten, success",
"def checkSanity(self, valuePreviouslySet):\n firstGet = self._pfwClient.get(self._paramPath)\n\n try:\n re... | [
"0.7477176",
"0.651279",
"0.5838733",
"0.56298923",
"0.5567816",
"0.54301494",
"0.538235",
"0.5373442",
"0.5373442",
"0.5250654",
"0.5224899",
"0.5218009",
"0.5213785",
"0.5118277",
"0.5107878",
"0.50986534",
"0.50747293",
"0.50688815",
"0.5025534",
"0.5005229",
"0.49713558",... | 0.6985362 | 1 |
Returns dropdown page element for choosing templates. | def dropdown(self):
return self._root.element(class_name="multiselect-dropdown") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Dropdown(page, data):\n if page == \"book\":\n ph = \"Select a book from the collection\"\n if page == \"word\":\n ph = \"Select a word from the vocabulary\"\n\n return html.Div(id=\"ddbox\", children=[\n dcc.Dropdown(\n id='dropdown',\n options=[{\"label\": ... | [
"0.6800725",
"0.6339797",
"0.62296826",
"0.6148889",
"0.60649514",
"0.58460546",
"0.57834",
"0.5764724",
"0.57562983",
"0.5701695",
"0.56715167",
"0.5668717",
"0.5661735",
"0.5524655",
"0.55033135",
"0.54877126",
"0.5453054",
"0.5424079",
"0.54164624",
"0.53297246",
"0.531124... | 0.64181226 | 1 |
Clicks on dropdown element if it is not expanded. | def expand_dropdown(self):
if not self.is_dropdown_expanded:
self.dropdown.click() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_dropdown_expanded(self):\n return self.dropdown.element(class_name=\"dropdown-focus\").exists",
"def IsDropDownClicked(self):\r\n\r\n return self.is_dropdown_clicked",
"def the_user_field_should_expand_down_to_list_further_details(driver):\n assert wait_on_element(driver, 7, xpaths.users.er... | [
"0.77870166",
"0.619643",
"0.59683394",
"0.5911439",
"0.5839412",
"0.5725947",
"0.5679876",
"0.55769306",
"0.55308056",
"0.5527501",
"0.5495442",
"0.5473458",
"0.53603333",
"0.5352361",
"0.5345433",
"0.52731925",
"0.52198166",
"0.5174138",
"0.5162587",
"0.51445085",
"0.513834... | 0.8540769 | 0 |
Returns whether dropdown element is expanded. | def is_dropdown_expanded(self):
return self.dropdown.element(class_name="dropdown-focus").exists | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsExpanded(self):\r\n\r\n return not self.IsCollapsed()",
"def IsExpanded(self):\r\n\r\n return not self._isCollapsed",
"def HasDropDown(self):\r\n\r\n return self.dropdown",
"def is_expanded(self):\n\n return self.__is_expanded",
"def IsExpanded(self, item):\r\n\r\n ... | [
"0.71424997",
"0.71345896",
"0.71137094",
"0.70648",
"0.704289",
"0.70375353",
"0.6994464",
"0.6856183",
"0.65215063",
"0.6370616",
"0.63463837",
"0.6310765",
"0.6308568",
"0.6189189",
"0.5864731",
"0.56593674",
"0.5579323",
"0.5540679",
"0.5485048",
"0.54817736",
"0.5465277"... | 0.89884114 | 0 |
Write the supplied IP addresses to a CSV file. | def write_ips_to_csv(connections, ip_file_filename):
with open(ip_file_filename, "w") as f:
f.write("x,y,hostname\n")
f.write("".join("{},{},{}\n".format(x, y, hostname)
for (x, y), hostname
in sorted(iteritems(connections)))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_csv(list_of_emails):\n import csv\n # use newline='' to prevent double-spaced rows\n with open('emails.csv', 'w', newline='') as outFile:\n outWriter = csv.writer(outFile)\n charNum = outWriter.writerow(['email'])\n for i in list_of_emails:\n charNum = outWrite... | [
"0.69401044",
"0.63939035",
"0.63592255",
"0.6307352",
"0.6273204",
"0.6256143",
"0.6201166",
"0.6170871",
"0.6170709",
"0.6147365",
"0.60999984",
"0.60767174",
"0.6063329",
"0.6062681",
"0.60278547",
"0.6019238",
"0.6013284",
"0.60085934",
"0.60003746",
"0.5991572",
"0.59797... | 0.77636445 | 0 |
Print the current machine info in a humanreadable form and wait for the user to press enter. | def print_info(machine_name, connections, width, height, ip_file_filename):
t = Terminal()
to_print = OrderedDict()
to_print["Hostname"] = t.bright(connections[(0, 0)])
to_print["Width"] = width
to_print["Height"] = height
if len(connections) > 1:
to_print["Num boards"] = len(connecti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_vm_info(virtual_machine):\n summary = virtual_machine.summary\n print(summary.runtime.host)\n print(\"Name : \", summary.config.name)\n print(\"Template : \", summary.config.template)\n print(\"Path : \", summary.config.vmPathName)\n print(\"Guest : \", summary.config... | [
"0.6140777",
"0.60982597",
"0.6040435",
"0.6020286",
"0.57407635",
"0.5702743",
"0.56378186",
"0.56206167",
"0.56160134",
"0.55948544",
"0.55657953",
"0.5564567",
"0.55235934",
"0.55108917",
"0.55020666",
"0.54926175",
"0.5479378",
"0.54682016",
"0.5451473",
"0.5446665",
"0.5... | 0.6434142 | 0 |
Test no thing name key available. | def test_thingname_nokey(self, mock):
self.assertRaises(
KeyError,
lf.lambda_handler, event=self.lambdaevent_nokey, context=None)
mock.client.return_value.update_thing_shadow.assert_not_called() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_missingKey(self):\n self.assertIsNone(self.users.key(\"mystery domain\", \"mystery user\"))",
"def test_key_none(self):\n try:\n AlphaVantage()\n self.fail(msg='A None api key must raise an error')\n except ValueError:\n self.assertTrue(True)",
"de... | [
"0.698572",
"0.6831279",
"0.6831279",
"0.6786943",
"0.67669964",
"0.6745843",
"0.66267097",
"0.6604502",
"0.6559034",
"0.6519484",
"0.6499918",
"0.64904934",
"0.64747417",
"0.6471414",
"0.6449227",
"0.6429795",
"0.6416516",
"0.6403706",
"0.6365251",
"0.6365029",
"0.63479316",... | 0.69909036 | 0 |
Regenerates the UIDs of the execution element and its children | def regenerate_uids(self, with_children=True):
self.uid = str(uuid.uuid4())
if with_children:
for field, value in ((field, getattr(self, field)) for field in dir(self)
if not callable(getattr(self, field))):
if isinstance(value, list):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUniqueId(self, idsOfElementaryExpressions):\n for e in self.children:\n e.setUniqueId(idsOfElementaryExpressions)",
"def uids(self):\n if not self.is_root:\n return None\n if self._uids is None:\n self.arbor._build_attr(\"_uids\", self)\n return... | [
"0.5937076",
"0.53455657",
"0.5317809",
"0.5230731",
"0.5203779",
"0.5185881",
"0.51220363",
"0.5100649",
"0.49799705",
"0.49329397",
"0.49243703",
"0.49007082",
"0.47932217",
"0.47899932",
"0.47899634",
"0.47685874",
"0.4754042",
"0.47475097",
"0.4729647",
"0.47226804",
"0.4... | 0.67760074 | 0 |
Fetch mails from IMAP | def fetchmail(self):
mails = []
if self.security == 'SSL/TLS':
imap = IMAP4_SSL(self.host, self.port)
else:
imap = IMAP4(self.host, self.port)
if self.security == 'STARTTLS':
imap.starttls()
imap.login(self.username, self.passwd)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_messages_from_imap(host, port, username, password):\n\n with imaplib.IMAP4(host, port=port) as client:\n client.starttls()\n client.login(username, password)\n client.select(\"INBOX\", readonly=False)\n\n client.create(\"Archives\")\n client.create(\"Archives/Crashre... | [
"0.73195887",
"0.7277285",
"0.7145151",
"0.70267844",
"0.69976425",
"0.67971104",
"0.67875034",
"0.6691696",
"0.66308916",
"0.6604588",
"0.6578661",
"0.6575177",
"0.65625006",
"0.6550842",
"0.64471036",
"0.6437559",
"0.6415776",
"0.6413485",
"0.63730913",
"0.63375306",
"0.626... | 0.8034604 | 0 |
Return lower, upper, letter and password of a policy line | def parse_policy_line(line):
match = policy_pattern.match(line)
lower = int(match.group('min'))
upper = int(match.group('max'))
assert upper >= lower
letter = match.group('letter')
assert len(letter) == 1
password = match.group('password')
assert len(password) >= 1
return lower, uppe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_line(line):\n num1 = int(line.split(\"-\")[0])\n num2 = int(line.split(\"-\")[1].split(\" \")[0])\n character = line.split(\" \")[1].split(\":\")[0]\n password = line.split(\" \")[2]\n # print(f\"{line} :: ({num1}, {num2}, {character}, {password})\")\n return num1, num2, character, pass... | [
"0.58005756",
"0.573791",
"0.5734827",
"0.5455728",
"0.54067826",
"0.53923476",
"0.5390218",
"0.5356016",
"0.5319545",
"0.5317894",
"0.53030205",
"0.52765197",
"0.52632725",
"0.5253155",
"0.5236983",
"0.5231482",
"0.5206266",
"0.5185986",
"0.5162681",
"0.51547647",
"0.511443"... | 0.77721965 | 0 |
Returns whether a password is valid Each policy actually describes two positions in the password Exactly one of these positions must contain the given letter. valid_password(1, 3, "a", "abcde") == True valid_password(1, 3, "b", "cdefg") == False valid_password(2, 9, "c", "ccccccccc") == False | def valid_password(lower, upper, letter, password):
# Note the -1 to turn 1 indexing into 0 indexing
matches = [idx for idx in (lower, upper) if password[idx - 1] == letter]
return len(matches) == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid_password_v1(password):\n letter_count = sum([x == password[\"letter\"] for x in list(password[\"password\"])])\n return password[\"low\"] <= letter_count <= password[\"high\"]",
"def valid_password(password):\n val = True\n\n if len(password) < 8:\n val = False\n return val... | [
"0.79252726",
"0.7824308",
"0.7759457",
"0.7746773",
"0.77271616",
"0.7685118",
"0.7660412",
"0.7639942",
"0.7581784",
"0.75088835",
"0.7507734",
"0.7464349",
"0.7456752",
"0.73747814",
"0.7365335",
"0.7202525",
"0.71280706",
"0.7126687",
"0.7121084",
"0.71059006",
"0.7095532... | 0.8354784 | 0 |
Queries Bittrex with given method and args encodes and sends with optional [args] to Poloniex api raises 'bittrex.BittrexError' if an api key or secret is missing (and the command is 'private') or if the is not valid returns decoded json api message | def __call__(self, group, command, args={}):
from requests.exceptions import ReadTimeout, ConnectionError
base_url = 'https://bittrex.com/Api/v2.0/'
if command in PRIVATE_COMMANDS:
if not self.api_key or not self.api_secret:
raise BittrexError("Key and Secret needed... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api( self, method, argc, **kwargs ):\n url = self.btce_url + argc + '/'\n body = urllib.urlencode(kwargs)\n sign = self.hash_hmac( body )\n headers = dict( Sign = sign, Uid = self.uid )\n if method == 'POST':\n response = requests.post( url,\n ... | [
"0.6684204",
"0.66214025",
"0.6616828",
"0.6486827",
"0.6112508",
"0.59843874",
"0.5954192",
"0.5880676",
"0.58299065",
"0.5829775",
"0.5719852",
"0.57148695",
"0.5698861",
"0.5681453",
"0.56810856",
"0.5675231",
"0.5654866",
"0.55678356",
"0.55587965",
"0.5548095",
"0.553229... | 0.7309803 | 0 |
Used to get all markets available at Bittrex along with other meta data. pub/markets/getmarkets | def get_markets(self):
return self.__call__('markets', 'getmarkets') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_markets(self):\n self.logger.debug(\"Fetching markets.\")\n return self._api_query(\"markets\")['markets']",
"async def get_markets(self):\n uri = \"/v3/markets\"\n success, error = await self.request(\"GET\", uri)\n return success, error",
"def get_markets(self):\n\n... | [
"0.8317416",
"0.8151409",
"0.792638",
"0.7697898",
"0.7647581",
"0.7561636",
"0.73547643",
"0.7277391",
"0.7191202",
"0.71305126",
"0.70602417",
"0.70485884",
"0.692237",
"0.68992245",
"0.6502548",
"0.64942217",
"0.64183265",
"0.6388632",
"0.6352252",
"0.6340843",
"0.61206806... | 0.8461556 | 0 |
Used to get the open and available trading markets at Bittrex along with other meta data. pub/markets/getmarketsummaries | def get_market_summaries(self):
return self.__call__('markets', 'getmarketsummaries') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_markets(self):\n\n #\n\n result = self.api_query('info')\n detail = []\n for key, value in result['pairs'].items():\n IsActive = False\n if value['hidden'] ==0:\n IsActive = True\n dict_result = {'MarketCurrency':key.split('_')[0],... | [
"0.7477604",
"0.7235826",
"0.72262084",
"0.7191521",
"0.7086227",
"0.7022103",
"0.70103407",
"0.6925226",
"0.6755432",
"0.67393535",
"0.67139506",
"0.6685825",
"0.6542078",
"0.65267015",
"0.65210545",
"0.6468673",
"0.642256",
"0.6406097",
"0.6368896",
"0.6364338",
"0.63615125... | 0.80854136 | 0 |
Used to get all availables currencies at Bittrex along with other meta data. pub/currencies/getcurrencies | def get_currencies(self):
return self.__call__('currencies', 'getcurrencies') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_currencies(self) -> list:\n return self.client.currencies.get_all()",
"def getCurrencies():",
"def get_currencies():\n url = '{}/v1/finance/currencies'.format(BASE_URL)\n return _make_request(url, 'currencies')",
"def get_all_currencies(self):\r\n method = self.public_endpoints['c... | [
"0.7930582",
"0.7913514",
"0.79112595",
"0.7894975",
"0.7833289",
"0.76905906",
"0.7688807",
"0.76033473",
"0.7433894",
"0.7351989",
"0.73067665",
"0.7241836",
"0.72394526",
"0.72257173",
"0.7163165",
"0.70707184",
"0.6993645",
"0.6972227",
"0.69704664",
"0.68293923",
"0.6783... | 0.7936461 | 0 |
Used to get information about all availables currencies status at Bittrex along with other meta data. pub/currencies/getwallethealth | def get_wallet_health(self):
return self.__call__('currencies', 'getwallethealth') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getActiveCurrencies():",
"def get_all_currencies(self):\r\n method = self.public_endpoints['currency_info']['method']\r\n url = self.base_url + self.public_endpoints['currency_info']['url']\r\n req = requests.request(method, url)\r\n res = req.json()\r\n\r\n if res... | [
"0.6905696",
"0.6717737",
"0.6550938",
"0.64926434",
"0.6398675",
"0.63449377",
"0.6332943",
"0.6249389",
"0.6174259",
"0.6133271",
"0.61027545",
"0.5969534",
"0.5955778",
"0.5893453",
"0.58650607",
"0.5858562",
"0.58157396",
"0.5813328",
"0.57970494",
"0.5777831",
"0.5765226... | 0.7239202 | 0 |
Used to get information about a given market orderbook pub/currencies/getmarketorderbook | def get_market_orderbook(self, market):
return self.__call__('market', 'getmarketorderbook',
{'marketname': market}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_order_book(self, market_symbol, depth=25):\n return self.get(f'markets/{market_symbol}/orderbook', {\n 'depth': depth\n })",
"def order_book_fetch(self, symbol):\n pass",
"def order_book_fetch(self, symbol):\n orderbook = self.orderbooks[symbol]\n asks =... | [
"0.712581",
"0.6950905",
"0.69503224",
"0.69088215",
"0.6729262",
"0.6705451",
"0.6657156",
"0.6610654",
"0.65552616",
"0.6527463",
"0.65201735",
"0.63974524",
"0.6383133",
"0.6247417",
"0.6216998",
"0.61266255",
"0.6091026",
"0.60708475",
"0.5947076",
"0.5898792",
"0.5897702... | 0.77289665 | 0 |
Used to data chart information about a given market in a given period. pub/market/GetTicks?marketName=&tickInterval= | def get_ticks(self, market, period):
return self.__call__('market', 'GetTicks',
{'marketName': market,
'tickInterval': period}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMarketPrices(market, interval):\n try:\n tf = {3600: '3600Min',\n 60: '60Min',\n 30: '30Min',\n 5: '5Min',\n 1: '1Min'}\n history = API.getmarkethistory(MARKET)\n df = pd.DataFrame(history)\n df.index = pd.to_datetime(df['Ti... | [
"0.6584673",
"0.651394",
"0.6379039",
"0.61642545",
"0.61048055",
"0.6016945",
"0.5991142",
"0.5906822",
"0.5856959",
"0.58346575",
"0.5821181",
"0.57321936",
"0.57287145",
"0.5681902",
"0.5641825",
"0.5610472",
"0.55893475",
"0.5562441",
"0.5554676",
"0.554891",
"0.55472004"... | 0.8056762 | 0 |
Returns information about a specific order (by UUID) | def get_order(self, uuid):
return self.__call__('orders', 'getorder',
{'orderid': uuid}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, uuid=None):\n if not uuid:\n orders = db.session.query(Order).all()\n return [f.to_dict() for f in orders], 200\n order = db.session.query(Order).filter_by(uuid=uuid).first()\n if not order:\n return \"\", 404\n return order.to_dict(), 200"... | [
"0.6896327",
"0.6593787",
"0.64989513",
"0.64282393",
"0.63794655",
"0.6343696",
"0.63210213",
"0.6166453",
"0.6134483",
"0.61270696",
"0.6063174",
"0.6058017",
"0.60522664",
"0.604968",
"0.6037674",
"0.6002506",
"0.598996",
"0.5977059",
"0.59713364",
"0.59284264",
"0.5910420... | 0.7355431 | 0 |
Returns all of your currently open orders if market == None, else returns all of your currently open orders in the given market. | def get_open_orders(self, market=None):
if market:
return self.__call__('market', 'getopenorders',
{'marketname': market})
return self.__call__('orders', 'getopenorders') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_open_orders(self, market):\n #{'success': True, 'message': '', 'result': [{'Uuid': None, 'OrderUuid': '7f43f22f-586b-46d8-a4b2-f457cfeb2aac', 'Exchange': 'BTC-GEO', 'OrderType': 'LIMIT_SELL', 'Quantity': 2.03478908, 'QuantityRemaining': 2.03478908, 'Limit': 0.00097503, 'CommissionPaid': 0.0, 'Price'... | [
"0.78444576",
"0.75895965",
"0.7122419",
"0.68591815",
"0.6755302",
"0.67259955",
"0.67002684",
"0.6696888",
"0.66246897",
"0.6512141",
"0.64739656",
"0.6430595",
"0.6429118",
"0.64276385",
"0.63172084",
"0.6304569",
"0.629277",
"0.6254021",
"0.617908",
"0.61248755",
"0.61218... | 0.85335296 | 0 |
Returns all of your order history | def get_order_history(self):
return self.__call__('orders', 'getorderhistory') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orders_history(self): \n return(self._d_orders['history'])",
"def history_orders(self, **params):\n return self._get('historyOrders', signed=True, params=params)",
"def getOrderHistory(self):\n return self.__orderhistory",
"def all_past_orders(self):\n\n print \"~~~~ Ge... | [
"0.8399567",
"0.81821483",
"0.8118748",
"0.7880035",
"0.78735346",
"0.7436433",
"0.73921925",
"0.7389471",
"0.7348019",
"0.7312672",
"0.72526604",
"0.72409135",
"0.7208534",
"0.7179031",
"0.71553856",
"0.71553856",
"0.71284884",
"0.71139264",
"0.710734",
"0.7099884",
"0.70522... | 0.8657043 | 0 |
Returns all of your currently balance if market == None, else returns your balance for a given currency. | def get_balance(self, currency=None):
if currency:
return self.__call__('balance', 'getbalance',
{'currencyname': currency})
return self.__call__('balance', 'getbalances') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getBalance(self, currency=''):\n\n if self.app.getExchange() == 'binance':\n if self.mode == 'live':\n model = BAuthAPI(self.app.getAPIKey(), self.app.getAPISecret())\n df = model.getAccount()\n if isinstance(df, pd.DataFrame):\n ... | [
"0.733943",
"0.6545897",
"0.63034666",
"0.6260548",
"0.61887413",
"0.61624026",
"0.6112946",
"0.60920215",
"0.60637045",
"0.6033717",
"0.600507",
"0.5777831",
"0.57706255",
"0.5751666",
"0.5742167",
"0.57148796",
"0.5702011",
"0.56838405",
"0.5623454",
"0.55944496",
"0.556595... | 0.7379573 | 0 |
Cancel an order by given uuid | def cancel(self, uuid):
return self.__call__('market', 'tradecancel',
{'orderId': uuid}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel(self, uuid):\n\n result = self.api_query('CancelOrder', {'order_id': uuid})\n return result",
"def cancelOrder(self, order_number):\n pass",
"def cancel_order(self, walletId, orderId):\n return",
"def do_cancel(order):\r\n self.gox.cancel(order.oid)",
"def ... | [
"0.8338571",
"0.7503885",
"0.7244776",
"0.7240588",
"0.71295667",
"0.69735295",
"0.6838463",
"0.6813877",
"0.6776363",
"0.6764805",
"0.66287905",
"0.6622425",
"0.6573275",
"0.65631783",
"0.6499989",
"0.6492561",
"0.64770985",
"0.6467546",
"0.6462787",
"0.64479405",
"0.6424197... | 0.8016279 | 1 |
Withdraws a specific amount of a certain currency to the specified address | def withdraw(self, currency, amount, address):
return self.__call__('balance', 'withdrawcurrency',
{"currencyname": currency,
"quantity": amount,
"address": address}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def withdraw(self, currency, amount, address):\n pass",
"def withdraw(self, currency, amount, address):\n return self.api_query('withdraw', {\"currency\": currency, \"amount\": amount, \"address\": address})",
"def cryptocurrency_withdrawal_request(self, walletId, currency, amount, address):\n ... | [
"0.8090461",
"0.8013947",
"0.77737606",
"0.74657977",
"0.726108",
"0.7154421",
"0.7145477",
"0.7067104",
"0.69020915",
"0.6725222",
"0.6725222",
"0.669851",
"0.6677111",
"0.6652555",
"0.6628528",
"0.65988225",
"0.658951",
"0.65880585",
"0.65798885",
"0.65767086",
"0.6565949",... | 0.8341117 | 0 |
Returns your complete withdrawal history if currency == None, else returns your withdrawal history for a given currency | def get_withdrawal_history(self, currency=None):
if not currency:
currency = ""
return self.__call__('balance', "getwithdrawalhistory",
{"currencyname": currency}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_deposit_history(self, currency=None):\n if not currency:\n currency = \"\"\n return self.__call__('balance', \"getdeposithistory\", \n {\"currencyname\": currency})",
"def get_coin_history(self, coin=None, end_date=None, start_date=None):\n if c... | [
"0.67818457",
"0.5721749",
"0.5604714",
"0.56041265",
"0.55907834",
"0.5565109",
"0.5544113",
"0.5542593",
"0.5531582",
"0.5524429",
"0.54912204",
"0.5479813",
"0.5479813",
"0.5442047",
"0.5435135",
"0.5426052",
"0.5363998",
"0.53193957",
"0.5295522",
"0.52901953",
"0.5261412... | 0.77151823 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.