query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Reads the index from the cache file and sets self.index.
def load_index_from_cache(self): cache = open(self.cache_path_index, 'r') json_index = cache.read() self.index = json.loads(json_index)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _populate_index(self):\n os.makedirs(self.cache_dir, exist_ok=True)\n local_files = glob('{}/*'.format(self.cache_dir))\n for file in local_files:\n self._add_to_index(os.path.basename(file), os.path.getsize(file))", "def _load_index(self):\n try:\n with open(self._index_path,...
[ "0.7139627", "0.69223547", "0.69004935", "0.68209773", "0.66870165", "0.64805925", "0.6415881", "0.64003915", "0.63989496", "0.6365108", "0.6176035", "0.61550426", "0.6151214", "0.6092105", "0.6086096", "0.6045057", "0.6004933", "0.5955538", "0.5945302", "0.59057784", "0.5904...
0.8064955
0
Writes data in JSON format to a file.
def write_to_cache(self, data, filename): json_data = self.json_format_dict(data, True) cache = open(filename, 'w') cache.write(json_data) cache.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_to_file(path, data):\n with open(path, 'w') as outfile:\n json.dump(data, outfile)", "def write_json_to_file(json_data: list, filename: str) -> None:\n print('Saving json data to ' + filename + '... ', end='', flush=True)\n with open(filename, 'w') as fd:\n json.dump(obj=json_dat...
[ "0.849282", "0.8377509", "0.8297732", "0.8280737", "0.827182", "0.82699716", "0.8235861", "0.82339245", "0.8230249", "0.82286847", "0.81587243", "0.8154781", "0.8146111", "0.81199956", "0.80673647", "0.80673647", "0.8034602", "0.8018826", "0.80057424", "0.7997035", "0.7979663...
0.0
-1
Escapes any characters that would be invalid in an ansible group name.
def to_safe(self, word): return re.sub("[^A-Za-z0-9\-]", "_", word)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Escape(name):\n return re.sub(r'[^\\w#-]', '_', name)", "def validate_group_name(self, key, value):\n if len(value.split(':')) != 2:\n raise AssertionError('group_name {} is not prefixed'.format(value))\n return value", "def escape_env_var(varname: str) -> str:\n varletters = l...
[ "0.68663985", "0.59834987", "0.58701265", "0.57611465", "0.5732694", "0.571592", "0.5629738", "0.55753237", "0.5558366", "0.5516642", "0.55165267", "0.54932815", "0.5471602", "0.5458619", "0.5414491", "0.5395632", "0.5392031", "0.5369823", "0.5364962", "0.5322491", "0.5320037...
0.507992
40
Converts a dict to a JSON object and dumps it as a formatted string.
def json_format_dict(self, data, pretty=False): if pretty: return json.dumps(data, sort_keys=True, indent=2) else: return json.dumps(data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dict_to_beautified_json(d):\n return jsbeautifier.beautify(json.dumps(d))", "def format_dictionary(dct, indent=4):\n return json.dumps(dct, indent=indent, sort_keys=True)", "def serialize_dict(d):\n txt = '{'\n for k in d:\n txt += f'\"{k}\":'\n if isinstance(d[k], dict):\n ...
[ "0.78440636", "0.7770831", "0.77035886", "0.76633406", "0.76391345", "0.75981855", "0.74306023", "0.73690313", "0.72739345", "0.7262992", "0.71151763", "0.7112965", "0.70745146", "0.7053805", "0.70487416", "0.69528365", "0.69198143", "0.68998283", "0.687098", "0.6843199", "0....
0.6903701
17
Find the regular expression pattern s in dictionary.
def findPattern(self,s): # pat = re.compile('^'+s+'$') pat = re.compile(s) results = {} for k in self.__clidRep.keys(): if pat.match(str(k)) or pat.match(self.__clidRep[k]): results[k] = self.__clidRep[k] return results
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_by_pattern(self):\n while True: \n word = input(\"Enter a regular expression ex: \\d\\d\\w+. Press Q to \"\n \"quit to the main screen: \")\n if word.upper() in [\"Q\", \"QUIT\", \"EXIT\"]:\n return self.dict_list\n self.find...
[ "0.6469642", "0.63880825", "0.63732696", "0.6253539", "0.6212993", "0.61480343", "0.60889447", "0.5976892", "0.594639", "0.5908699", "0.5843748", "0.57777935", "0.5762092", "0.5741424", "0.5741424", "0.57190794", "0.57145727", "0.56568784", "0.56494045", "0.5643466", "0.56325...
0.8029055
0
Given a search path, find file with requested name
def search_file(filename, search_path, pathsep=os.pathsep): for path in string.split(search_path, pathsep): candidate = os.path.join(path, filename) if os.path.exists(candidate): return os.path.abspath(candidate) return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_file(filename, search_path):\n file_path = None\n for path in search_path:\n if exists(join(path, filename)):\n file_path = path\n break\n if file_path:\n return abspath(join(file_path, filename))\n return None", "def search_file(file_name, search_path):...
[ "0.8472018", "0.8468676", "0.74209857", "0.73401636", "0.7264667", "0.7243582", "0.7174533", "0.7158519", "0.71515274", "0.7147575", "0.7137017", "0.7124741", "0.7076667", "0.7051659", "0.7040611", "0.70287484", "0.7003733", "0.6992684", "0.69870466", "0.6972921", "0.6929907"...
0.82500744
3
Given a search path, find file with requested name
def search_files(filename, search_path, pathsep=os.pathsep): clidFiles = [] for path in search_path.split(pathsep): candidate = os.path.join(path, filename) if os.path.exists(candidate): clidFiles.append(os.path.abspath(candidate)) return clidFiles
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_file(filename, search_path):\n file_path = None\n for path in search_path:\n if exists(join(path, filename)):\n file_path = path\n break\n if file_path:\n return abspath(join(file_path, filename))\n return None", "def search_file(file_name, search_path):...
[ "0.8472018", "0.8468676", "0.82500744", "0.82500744", "0.74209857", "0.73401636", "0.7243582", "0.7174533", "0.7158519", "0.71515274", "0.7147575", "0.7137017", "0.7124741", "0.7076667", "0.7051659", "0.7040611", "0.70287484", "0.7003733", "0.6992684", "0.69870466", "0.697292...
0.7264667
6
Initialise l'objet obstacle_p5 ... Attributs
def __init__(self, min_y, pos_x, largeur=util.LARGEUR_OBSTACLE, hauteur=util.HAUTEUR_CHEMIN, couleur=util.COULEUR): super().__init__(min_y, pos_x) self.couleur = couleur
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, obstacles, kin):\n self.obstacles = obstacles\n self.kin = kin", "def __init__(self, map_obstacle, main_graph):\n\n self.map_obstacle = map_obstacle\n self.main_graph = main_graph\n\n self.sight_range = self.calculate_sight_range()\n\n self.top_left_y ...
[ "0.6919958", "0.67913294", "0.66773707", "0.6674021", "0.66672844", "0.66664445", "0.63685834", "0.61859477", "0.6173325", "0.6171573", "0.6170712", "0.6126762", "0.6121096", "0.6113945", "0.6069578", "0.60572624", "0.6047675", "0.60424685", "0.60299546", "0.60263705", "0.595...
0.0
-1
Affiche l'obstacle dans p5
def display(self): stroke(51) fill(self.couleur) rect(self.pos_x, 0, self.largeur, self.min_y) rect(self.pos_x, self.min_y + self.hauteur, self.largeur, util.SCREEN_Y-(self.min_y + self.hauteur))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _find_obstacle(self, obstacle_type='*traffic_light*'): \r\n obst = list()\r\n \r\n _actors = self._world.get_actors()\r\n _obstacles = _actors.filter(obstacle_type)\r\n\r\n\r\n for _obstacle in _obstacles:\r\n trigger = _obstacle.trigger_volume\r\n\r\n ...
[ "0.7072175", "0.6498728", "0.6498728", "0.63785666", "0.6300901", "0.6247819", "0.62116295", "0.61690885", "0.61390996", "0.6137549", "0.6134672", "0.6131543", "0.6084553", "0.60696137", "0.60562235", "0.6054418", "0.6048327", "0.60114115", "0.5970737", "0.5942358", "0.593836...
0.0
-1
coverts devices to json string into
def devicelist_to_json(self): devices_json = json.dumps(self.device_list) print(devices_json)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def devices_json():\n return [\n {\n \"macAddress\": \"84:F3:EB:21:90:C4\",\n \"lastData\": {\n \"dateutc\": 1546889640000,\n \"baromrelin\": 30.09,\n \"baromabsin\": 24.61,\n \"tempinf\": 68.9,\n \"humidityi...
[ "0.74697614", "0.6751789", "0.65418833", "0.6319735", "0.61290795", "0.6120263", "0.60992014", "0.60623235", "0.60572946", "0.6028789", "0.5987714", "0.5979106", "0.597772", "0.5972768", "0.59643567", "0.59492177", "0.5925081", "0.5899812", "0.5844271", "0.58301526", "0.58090...
0.72180307
1
Handle / requests. Returns
def _landsatlive() -> Tuple[str, str, str]: return ( "OK", "text/html", landsatlive(app.host, os.environ.get("MAPBOX_ACCESS_TOKEN", "")), )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle(self):\n\t\ttry:\n\t\t\trequest_line = self.rfile.readline().decode(\"ascii\")\n\t\t\tassert request_line.endswith(\"\\r\\n\"), \"Request line must end in CRLF\"\n\t\t\tparts = request_line.strip().split()\n\t\t\tassert len(parts)==3, \"Invalid request line\"\n\t\t\thost, path, content_length = parts\n\...
[ "0.71166205", "0.6959937", "0.6894376", "0.681187", "0.67898226", "0.67180943", "0.6713536", "0.66871476", "0.6659518", "0.6651545", "0.6644158", "0.6640832", "0.66320163", "0.6627404", "0.6624958", "0.66239345", "0.65919656", "0.656528", "0.65539557", "0.6548875", "0.6547806...
0.0
-1
Handle / requests. Returns
def _timeserie() -> Tuple[str, str, str]: return ( "OK", "text/html", timeserie(app.host, os.environ.get("MAPBOX_ACCESS_TOKEN", "")), )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle(self):\n\t\ttry:\n\t\t\trequest_line = self.rfile.readline().decode(\"ascii\")\n\t\t\tassert request_line.endswith(\"\\r\\n\"), \"Request line must end in CRLF\"\n\t\t\tparts = request_line.strip().split()\n\t\t\tassert len(parts)==3, \"Invalid request line\"\n\t\t\thost, path, content_length = parts\n\...
[ "0.71166205", "0.6959937", "0.6894376", "0.681187", "0.67898226", "0.67180943", "0.6713536", "0.66871476", "0.6659518", "0.6651545", "0.6644158", "0.6640832", "0.66320163", "0.6627404", "0.6624958", "0.66239345", "0.65919656", "0.656528", "0.65539557", "0.6548875", "0.6547806...
0.0
-1
returns an integer that respresents base_depth for specified date
def base_depth_for_date(resort_name, date): resort_table = resort_table_dict[resort_name] new_date = str(date) base_depth_to_return = None query = "SELECT base_depth FROM %s WHERE status_date = to_date(%s::text, 'YYYYMMDD')" %(resort_table, date) connection = get_connection() if connection is not None: try: for row in get_select_query_results(connection, query): base_depth_to_return = row except Exception as e: print(e, file=sys.stderr) connection.close() return json.dumps(base_depth_to_return)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base_depth_average_for_date(resort_name, date):\n\n resort_table = resort_table_dict[resort_name]\n\n date_month = int(date[4:6])\n date_day = int(date[6:8])\n query = \"SELECT base_depth FROM %s WHERE CAST(EXTRACT(MONTH FROM status_date) AS INTEGER) = %d AND CAST(EXTRACT(DAY FROM status_date) AS I...
[ "0.6894696", "0.61948436", "0.61282104", "0.6101949", "0.59978324", "0.57817864", "0.57461077", "0.57212085", "0.56724894", "0.5652006", "0.5621178", "0.56116706", "0.558995", "0.5588037", "0.5577575", "0.55354685", "0.5507787", "0.54877305", "0.54871655", "0.54178995", "0.54...
0.7155536
0
returns average of base depth across all years on specific date
def base_depth_average_for_date(resort_name, date): resort_table = resort_table_dict[resort_name] date_month = int(date[4:6]) date_day = int(date[6:8]) query = "SELECT base_depth FROM %s WHERE CAST(EXTRACT(MONTH FROM status_date) AS INTEGER) = %d AND CAST(EXTRACT(DAY FROM status_date) AS INTEGER) = %d" %(resort_table, date_month, date_day) connection = get_connection() total = 0 counter = 0 for row in get_select_query_results(connection, query): counter += 1 total += int(row[0]) if (counter != 0): base_depth_to_return = int(total/counter) else: base_depth_to_return = 0 return json.dumps(base_depth_to_return)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def avg(year):\r\n df = ouvrir_fichier()\r\n df = df.loc[df[\"year\"].isin([year])]\r\n df = df[(\r\n df[\r\n \"emissions\"\r\n ] == 'Emissions (thousand metric tons of carbon dioxide)'\r\n )]\r\n print(df)\r\n mean_value = df.mean()['value']\r\n resultat =...
[ "0.64000183", "0.61367154", "0.6118295", "0.6117146", "0.61015445", "0.6100895", "0.60893524", "0.60777545", "0.6077354", "0.6042014", "0.59638566", "0.5926371", "0.59044516", "0.5842373", "0.5823526", "0.5815007", "0.58064413", "0.57317835", "0.5730693", "0.5663666", "0.5653...
0.7233447
0
returns an integer that respresents snowfall for specified date
def snowfall_for_date(resort_name, date): resort_table = resort_table_dict[resort_name] new_date = str(date) query = "SELECT snowfall FROM %s WHERE status_date = to_date(%s::text, 'YYYYMMDD')" %(resort_table, new_date) connection = get_connection() snowfall_to_return = None if connection is not None: try: for row in get_select_query_results(connection, query): snowfall_to_return = row except Exception as e: print(e, file=sys.stderr) connection.close() return json.dumps(snowfall_to_return)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def snowfall_average_for_date(resort_name, date):\n resort_table = resort_table_dict[resort_name]\n\n date_month = int(date[4:6])\n date_day = int(date[6:8])\n query = \"SELECT snowfall FROM %s WHERE CAST(EXTRACT(MONTH FROM status_date) AS INTEGER) = %d AND CAST(EXTRACT(DAY FROM status_date) AS INTEGER...
[ "0.6893038", "0.64524025", "0.60528755", "0.59827864", "0.5980479", "0.5921568", "0.59064895", "0.5859596", "0.58405465", "0.5770899", "0.57282346", "0.5643557", "0.564349", "0.5636407", "0.5635899", "0.56255555", "0.5624808", "0.560323", "0.559807", "0.55762964", "0.5552987"...
0.63302463
2
returns int that is avg snowfall on this date over all years
def snowfall_average_for_date(resort_name, date): resort_table = resort_table_dict[resort_name] date_month = int(date[4:6]) date_day = int(date[6:8]) query = "SELECT snowfall FROM %s WHERE CAST(EXTRACT(MONTH FROM status_date) AS INTEGER) = %d AND CAST(EXTRACT(DAY FROM status_date) AS INTEGER) = %d" %(resort_table, date_month, date_day) connection = get_connection() total = 0 counter = 0 for row in get_select_query_results(connection, query): counter += 1 total += int(row[0]) if (counter != 0): snowfall_to_return = int(total/counter) else: snowfall_to_return = 0 return json.dumps(snowfall_to_return)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def five_years_avg_dividend(self) -> float:\n return self._five_years_avg_dividend", "def max_drawdown_cal_year(self) -> float:\n return float(self.tsdf.groupby([self.tsdf.index.year]).apply(\n lambda x: (x / x.expanding(min_periods=1).max()).min() - 1).min())", "def av(self, data):\n ...
[ "0.6527509", "0.63874155", "0.6387261", "0.63743424", "0.62814784", "0.61865", "0.6170374", "0.6097223", "0.6072147", "0.6064186", "0.6035137", "0.6027913", "0.6025581", "0.6023191", "0.5905982", "0.5880306", "0.58751917", "0.5872359", "0.5859398", "0.5838657", "0.5838657", ...
0.69543517
0
returns a date that had the highest snowfall during specified year
def highest_snowfall_for_year(resort_name, year): resort_table = resort_table_dict[resort_name] year = int(year) query = "SELECT snowfall FROM %s WHERE CAST(EXTRACT(YEAR FROM status_date) AS INTEGER) = %d" %(resort_table, year) connection = get_connection() snowfall_list = [] if connection is not None: try: for row in get_select_query_results(connection, query): snowfall_list.append(row) except Exception as e: print(e, file=sys.stderr) connection.close() snowfall_list.sort(reverse=True) """ need to think about making our own sorter so we can break ties effectively """ highest_snowfall = snowfall_list[0] return json.dumps(highest_snowfall)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maxyear():\n\n return datetime.MAXYEAR", "def latest_season_before(date):\n\tif date.month < 9:\n\t\treturn date.year - 1\n\treturn date.year", "def max_drawdown_cal_year(self) -> float:\n return float(self.tsdf.groupby([self.tsdf.index.year]).apply(\n lambda x: (x / x.expanding(min_pe...
[ "0.71644264", "0.70825464", "0.69648576", "0.66781336", "0.64653206", "0.6443147", "0.6366688", "0.6256422", "0.5998703", "0.5982007", "0.5957845", "0.58945405", "0.58911014", "0.5854378", "0.5853436", "0.5780126", "0.57732373", "0.5755967", "0.57521063", "0.57442605", "0.574...
0.75053
0
returns list of snowfall for each date in the period
def snowfall_for_period(resort_name, start_date, end_date): #yyyymmdd start_date_year = int(start_date[0:4]) start_date_month = int(start_date[4:6]) start_date_day = int(start_date[6:8]) end_date_year = int(end_date[0:4]) end_date_month = int(end_date[4:6]) end_date_day = int(end_date[6:8]) resort_table = resort_table_dict[resort_name] query = "SELECT status_date FROM %s" %(resort_table) connection = get_connection() period_date_list = [] snowfall_list = [] if connection is not None: try: for row in get_select_query_results(connection, query): #yyyymmdd row_year = int(row[0].strftime('%Y')) row_month = int(row[0].strftime('%m')) row_day = int(row[0].strftime('%d')) if row_year < start_date_year or row_year > end_date_year: continue if start_date_year == row_year: if start_date_month > row_month: continue if start_date_year == row_year: if start_date_month == row_month: if start_date_day > row_day: continue if end_date_year == row_year: if end_date_month < row_month: continue if end_date_year == row_year: if end_date_month == row_month: if end_date_day < row_day: continue date_to_append = (row[0].strftime('%Y') + row[0].strftime('%m') + row[0].strftime('%d')) period_date_list.append(date_to_append) except Exception as e: print(e, file=sys.stderr) for date in period_date_list: snowfall_to_add = snowfall_for_date(resort_name, date) snowfall_list.append(snowfall_to_add) return json.dumps(snowfall_list)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def snowfall_for_date(resort_name, date):\n\n resort_table = resort_table_dict[resort_name]\n\n new_date = str(date)\n\n query = \"SELECT snowfall FROM %s WHERE status_date = to_date(%s::text, 'YYYYMMDD')\" %(resort_table, new_date)\n connection = get_connection()\n snowfall_to_return = None\n\n\n ...
[ "0.63649917", "0.6109526", "0.6082759", "0.5757297", "0.5724909", "0.5718514", "0.56843966", "0.5634992", "0.56042325", "0.5594472", "0.5592005", "0.5579007", "0.54786044", "0.5469435", "0.5457135", "0.54524297", "0.54033566", "0.53840905", "0.532132", "0.53100914", "0.530515...
0.7388031
0
returns list of base_depth for each date in the period
def base_depth_for_period(resort_name, start_date, end_date): start_date_year = int(start_date[0:4]) start_date_month = int(start_date[4:6]) start_date_day = int(start_date[6:8]) end_date_year = int(end_date[0:4]) end_date_month = int(end_date[4:6]) end_date_day = int(end_date[6:8]) resort_table = resort_table_dict[resort_name] query = "SELECT status_date FROM %s" %(resort_table) connection = get_connection() period_date_list = [] base_depth_list = [] if connection is not None: try: for row in get_select_query_results(connection, query): row_year = int(row[0].strftime('%Y')) row_month = int(row[0].strftime('%m')) row_day = int(row[0].strftime('%d')) if row_year < start_date_year or row_year > end_date_year: continue if start_date_year == row_year: if start_date_month > row_month: continue if start_date_year == row_year: if start_date_month == row_month: if start_date_day > row_day: continue if end_date_year == row_year: if end_date_month < row_month: continue if end_date_year == row_year: if end_date_month == row_month: if end_date_day < row_day: continue date_to_add = (row[0].strftime('%Y') + row[0].strftime('%m') + row[0].strftime('%d')) period_date_list.append(date_to_add) except Exception as e: print(e, file=sys.stderr) for date in period_date_list: base_depth_for_list = base_depth_for_date(resort_name, date) base_depth_list.append(base_depth_for_list) return json.dumps(base_depth_list)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base_depth_for_date(resort_name, date):\n\n resort_table = resort_table_dict[resort_name]\n\n new_date = str(date)\n base_depth_to_return = None\n query = \"SELECT base_depth FROM %s WHERE status_date = to_date(%s::text, 'YYYYMMDD')\" %(resort_table, date)\n\n connection = get_connection()\n\n ...
[ "0.6518969", "0.60030866", "0.5712574", "0.54644364", "0.5354301", "0.5350619", "0.53494644", "0.53494644", "0.53139776", "0.52619964", "0.5192515", "0.51612735", "0.5154456", "0.5154456", "0.5072636", "0.50671273", "0.50522", "0.5036785", "0.5036785", "0.50244904", "0.501594...
0.73825467
0
backward pass. eph is an array of intermediate hidden states
def backward(eph, epdlogp): dW2 = np.dot(eph.T, epdlogp).ravel() # which means dh = np.outer(epdlogp, model['W2']) dh[eph<0] = 0 dW1 = np.dot(dh.T, epx) return {'W1':dW1, 'W2':dW2}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backward(self, dout):\n \n ########################\n # PUT YOUR CODE HERE #\n #######################\n for l in range(len(self.layers)-1,-1,-1):\n act_dout = self.activations[l].backward(dout)\n dout = self.layers[l].backward(act_dout)\n ########################\n # END OF YOU...
[ "0.703109", "0.67157567", "0.67157567", "0.66931474", "0.6591735", "0.64688903", "0.6465388", "0.64553505", "0.6454823", "0.64328384", "0.6418475", "0.64137405", "0.63989747", "0.63957125", "0.63787854", "0.6372957", "0.6321831", "0.6318423", "0.6315816", "0.62921983", "0.629...
0.67079365
3
Computes the precision for the specified values of k
def accuracy(output, target, topk=(1,)): maxk = max(topk) batch_size = target.size(0) _, pred = output.topk(maxk, 1, True, True) pred = pred.t() correct = pred.eq(target.view(1, -1).expand_as(pred)) res = [] for k in topk: correct_k = correct[:k].reshape(-1).float().sum(0, keepdim=True) res.append(correct_k.mul_(100.0 / batch_size)) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den", "def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\...
[ "0.76427615", "0.74189496", "0.7418079", "0.72710466", "0.72456723", "0.72446615", "0.7237539", "0.72213703", "0.7210107", "0.7058935", "0.6852219", "0.6786084", "0.67836976", "0.6768417", "0.67273885", "0.67181736", "0.67181736", "0.67181736", "0.67181736", "0.67181736", "0....
0.0
-1
Initialize the XebiaLabs Dockerfile template rendering engine.
def __init__(self, commandline_args): self.commit = commandline_args['commit'] self.registry = commandline_args['registry'] self.version = commandline_args['xl_version'] self.image_version = image_version(commandline_args['xl_version'], commandline_args['suffix'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_dockerfile(self):\n logger.info(\"Rendering Dockerfile...\")\n\n if self._params.get('redhat'):\n self._inject_redhat_defaults()\n\n self.image['pkg_manager'] = self._params.get('package_manager', 'yum')\n self.image.process_defaults()\n\n template_file = os...
[ "0.6266898", "0.61707485", "0.60554713", "0.6041114", "0.5997289", "0.5965682", "0.5915773", "0.58780557", "0.5839286", "0.5742166", "0.5708636", "0.57059795", "0.5701016", "0.57000333", "0.5665014", "0.5663685", "0.56482303", "0.5645206", "0.557813", "0.5574021", "0.5569913"...
0.0
-1
Downloads the olivetti faces dataset and saves it in the output_filepath directory.
def main(output_filepath): logger = logging.getLogger(__name__) logger.info('Downloading Olivetti faces...') olivetti_faces = fetch_olivetti_faces() data = pd.DataFrame(data=np.apply_along_axis(exposure.equalize_hist, 1, olivetti_faces.data)) labels = pd.DataFrame(data=olivetti_faces.target) logger.info('Splitting dataset into training and testing sets...') train_data, test_data, train_labels, test_labels = train_test_split( data, labels, test_size=0.2, random_state=0) train_data.to_csv(os.path.join(output_filepath, 'face_data_train.csv'), index=False) train_labels.to_csv(os.path.join(output_filepath, 'labels_train.csv'), index=False) test_data.to_csv(os.path.join(output_filepath, 'face_data_test.csv'), index=False) test_labels.to_csv(os.path.join(output_filepath, 'labels_test.csv'), index=False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maybe_download():\n\n print(\"Downloading Inception 5h Model ...\")\n download.maybe_download_and_extract(url=data_url, download_dir=data_dir)", "def download_glove ():\n # Get the URL ...\n print(\"Downloading https://nlp.stanford.edu/data/glove.6B.zip ...\")\n res = requests.get(\"https://nlp.stan...
[ "0.59466165", "0.58815235", "0.58095616", "0.5797585", "0.57857496", "0.57724977", "0.5553984", "0.55409586", "0.5527344", "0.5513376", "0.54741013", "0.5404894", "0.539826", "0.53865135", "0.5356633", "0.5356331", "0.53492486", "0.53430045", "0.5337607", "0.5328182", "0.5300...
0.7823156
0
Fused elementwise_add/mul and activation layers This function computes an elementwise_add/mul cooperated with an activation.
def fused_elemwise_activation(x, y, functor_list, axis=-1, scale=0.0, save_intermediate_out=True): if isinstance(functor_list, str): functor_list = functor_list.split(',') if not isinstance(functor_list, list) or len(functor_list) != 2: raise ValueError( 'functor_list should be a list of str, and the length should be 2.') helper = LayerHelper('fused_elemwise_activation', **locals()) out = helper.create_variable_for_type_inference(dtype=x.dtype) intermediate_out = helper.create_variable_for_type_inference(dtype=x.dtype) helper.append_op( type='fused_elemwise_activation', inputs={'X': x, 'Y': y}, outputs={'Out': out, 'IntermediateOut': intermediate_out}, attrs={ 'axis': axis, 'scale': scale, 'save_intermediate_out': save_intermediate_out, 'functor_list': functor_list }) return out
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(self, inputs):\n\n x = tf.matmul(inputs, self.w) + self.b\n x = self.activation(x)\n\n return x", "def _forward(z: np.array, W: np.array, b: np.array,\n activation: str) -> np.array:\n a = np.dot(z, W) + b\n if activation == 'sigmoid':\n return sigmoid(a)\n elif acti...
[ "0.6785041", "0.66848034", "0.66607964", "0.65622807", "0.6544377", "0.6528224", "0.64593065", "0.6396585", "0.6381647", "0.63695455", "0.6353182", "0.63472384", "0.631924", "0.6301697", "0.62578636", "0.6245912", "0.62452966", "0.6238974", "0.62210476", "0.62139124", "0.6186...
0.64662856
6
Perform 12 OT for Bob and return Alice's input list m_c without revealing c.
def Bob_OT(c, l, n=100): # Error handling. if c != 0 and c != 1: raise Exception("Input argument c must be either 0 or 1.") if l > n: raise Exception("Input argument l cannot be greater than n.") # (Step 1) # Bob runs 1-2 ROT. s_c = Bob_ROT(c, l, n) # (Step 3) # Bob receives (m0 XOR s0) and (m1 XOR s1) from Alice. with CQCConnection("Bob") as Bob: data0 = Bob.recvClassical() xor_0 = list(data0) data1 = Bob.recvClassical() xor_1 = list(data1) # Bob computes m_c. if c == 0: xor_c = xor_0 else: xor_c = xor_1 m_c = [] for i in range(l): m_c.append((s_c[i] + xor_c[i]) %2) print("Bob outputs m_c.") return m_c
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tickets(people):\n people= [100, 50, 25]", "def getMutation(AA,Codon):\r\n temp_mutationlist = []\r\n '''create a list of possible triplets within hamming distance 1 '''\r\n for item in INI.genetic_code.keys():\r\n isvalid = INI.isvalidtriplet(item,Codon)\r\n ''' Hamming distance 1,...
[ "0.50222504", "0.4935165", "0.48622358", "0.48220435", "0.47618267", "0.47593555", "0.47593555", "0.4643787", "0.46382758", "0.46354654", "0.4608568", "0.46082112", "0.45961824", "0.45707282", "0.45663276", "0.45569414", "0.4548844", "0.4518503", "0.44995117", "0.44929427", "...
0.6884154
0
Checks input arguments and returns fake response
def get(url, **_): # Checks input parameters assert '/configuration/%s' % dummy_id in url # Returns fake response response = requests.Response() response._content = response_json response.status_code = 200 return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_request():\n return make_response(\"ok\")", "def user_should_get_an_ok_response():\n assert web_app.validate_reponse()", "def test_request_response():\n response = get_todos()\n assert response is not None", "def test_hello_without_name(self, app_mock):\n\n # Call /api/hello using...
[ "0.6560607", "0.6365594", "0.6298639", "0.6253448", "0.6136158", "0.6133897", "0.6101555", "0.6081323", "0.60518533", "0.6043781", "0.60400105", "0.6023464", "0.6015783", "0.6011232", "0.5990983", "0.59831387", "0.59758544", "0.5946442", "0.593897", "0.5929033", "0.59249437",...
0.0
-1
Checks input arguments and returns fake response
def post(url, data=None, **_): # Checks input parameters assert '/configuration' in url if has_src: stream = data.fields['datafile'][1] stream.seek(0) assert stream.read() == file_content else: assert 'datafile' not in data.fields excepted = deepcopy(client._configuration_parameters) excepted['app']['reset'] = True excepted['app']['reload'] = True excepted['env']['apyfal_version'] = apyfal.__version__ assert json.loads(data.fields['parameters']) == excepted # Returns fake response response = requests.Response() response._content = response_json response.status_code = 200 return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_request():\n return make_response(\"ok\")", "def user_should_get_an_ok_response():\n assert web_app.validate_reponse()", "def test_request_response():\n response = get_todos()\n assert response is not None", "def test_hello_without_name(self, app_mock):\n\n # Call /api/hello using...
[ "0.6560607", "0.6365594", "0.6298639", "0.6253448", "0.6136158", "0.6133897", "0.6101555", "0.6081323", "0.60518533", "0.6043781", "0.60400105", "0.6023464", "0.6015783", "0.6011232", "0.5990983", "0.59831387", "0.59758544", "0.5946442", "0.593897", "0.5929033", "0.59249437",...
0.0
-1
Checks input arguments and returns fake response
def get(request_url, **_): # Checks input parameters assert '/configuration' in request_url # Returns fake response response = requests.Response() response._content = response_json return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_request():\n return make_response(\"ok\")", "def user_should_get_an_ok_response():\n assert web_app.validate_reponse()", "def test_request_response():\n response = get_todos()\n assert response is not None", "def test_hello_without_name(self, app_mock):\n\n # Call /api/hello using...
[ "0.6560607", "0.6365594", "0.6298639", "0.6253448", "0.6136158", "0.6133897", "0.6101555", "0.6081323", "0.60518533", "0.6043781", "0.60400105", "0.6023464", "0.6015783", "0.6011232", "0.5990983", "0.59831387", "0.59758544", "0.5946442", "0.593897", "0.5929033", "0.59249437",...
0.0
-1
Checks input arguments and returns fake response
def get(url, **_): # Checks input parameters assert '/stop' in url # Returns fake response response = requests.Response() response._content = response_json return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_request():\n return make_response(\"ok\")", "def user_should_get_an_ok_response():\n assert web_app.validate_reponse()", "def test_request_response():\n response = get_todos()\n assert response is not None", "def test_hello_without_name(self, app_mock):\n\n # Call /api/hello using...
[ "0.6560607", "0.6365594", "0.6298639", "0.6253448", "0.6136158", "0.6133897", "0.6101555", "0.6081323", "0.60518533", "0.6043781", "0.60400105", "0.6023464", "0.6015783", "0.6011232", "0.5990983", "0.59831387", "0.59758544", "0.5946442", "0.593897", "0.5929033", "0.59249437",...
0.0
-1
Checks input arguments and returns fake response
def get(url, **_): response = requests.Response() response.status_code = 200 if ('/process/%s' % dummy_id) in url: # Simulate processing not completed if processed_retry[0] < 2: response._content = response_json_not_ready processed_retry[0] += 1 else: response._content = response_json elif url == datafileresult: response.raw = io.BytesIO(file_content) response.raw.seek(0) else: raise ValueError('Unexpected url: %s' % url) return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_request():\n return make_response(\"ok\")", "def user_should_get_an_ok_response():\n assert web_app.validate_reponse()", "def test_request_response():\n response = get_todos()\n assert response is not None", "def test_hello_without_name(self, app_mock):\n\n # Call /api/hello using...
[ "0.6560607", "0.6365594", "0.6298639", "0.6253448", "0.6136158", "0.6133897", "0.6101555", "0.6081323", "0.60518533", "0.6043781", "0.60400105", "0.6023464", "0.6015783", "0.6011232", "0.5990983", "0.59831387", "0.59758544", "0.5946442", "0.593897", "0.5929033", "0.59249437",...
0.0
-1
Checks input arguments and returns fake response
def post(url, data=None, **_): # Checks input parameters assert '/process' in url if has_src: stream = data.fields['datafile'][1] stream.seek(0) assert stream.read() == file_content else: assert 'datafile' not in data.fields assert data.fields['configuration'] == dummy_url assert json.loads(data.fields['parameters']) == ( client._process_parameters) # Returns fake response response = requests.Response() response._content = response_json response.status_code = 200 return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_request():\n return make_response(\"ok\")", "def user_should_get_an_ok_response():\n assert web_app.validate_reponse()", "def test_request_response():\n response = get_todos()\n assert response is not None", "def test_hello_without_name(self, app_mock):\n\n # Call /api/hello using...
[ "0.6560607", "0.6365594", "0.6298639", "0.6253448", "0.6136158", "0.6133897", "0.6101555", "0.6081323", "0.60518533", "0.6043781", "0.60400105", "0.6023464", "0.6015783", "0.6011232", "0.5990983", "0.59831387", "0.59758544", "0.5946442", "0.593897", "0.5929033", "0.59249437",...
0.0
-1
Checks input arguments and returns fake response
def delete(url, data=None, **_): # Checks input parameters assert '/process/%s' % dummy_id in url in url
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_request():\n return make_response(\"ok\")", "def user_should_get_an_ok_response():\n assert web_app.validate_reponse()", "def test_request_response():\n response = get_todos()\n assert response is not None", "def test_hello_without_name(self, app_mock):\n\n # Call /api/hello using...
[ "0.6560607", "0.6365594", "0.6298639", "0.6253448", "0.6136158", "0.6133897", "0.6101555", "0.6081323", "0.60518533", "0.6043781", "0.60400105", "0.6023464", "0.6015783", "0.6011232", "0.5990983", "0.59831387", "0.59758544", "0.5946442", "0.593897", "0.5929033", "0.59249437",...
0.0
-1
Start a daemon with given daemon class.
def run(self, name: str, daemon_class: object, **kwargs) -> None: if name in self._running_daemons: raise AlreadyRunningDaemon( 'Daemon with name "{0}" already running'.format(name) ) logger.info(self, 'Starting daemon with name "{0}" and class "{1}" ...' .format(name, daemon_class)) daemon = daemon_class(name=name, kwargs=kwargs, daemon=True) daemon.start() self._running_daemons[name] = daemon
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_daemon(self, *args, **kwargs):\n pass", "def daemon(self):\n obj = self.subparsers.add_parser(\"daemon\", help=\"Daemon scripts\")\n obj.add_argument(\n \"daemon_type\",\n # default=\"all\",\n # const=\"all\",\n nargs=1,\n choi...
[ "0.73497087", "0.70751816", "0.66535014", "0.62650317", "0.6090769", "0.6031981", "0.5863433", "0.5808442", "0.5699542", "0.56858295", "0.56858295", "0.56858295", "0.56858295", "0.56688225", "0.5592923", "0.558033", "0.54989725", "0.5492751", "0.5471203", "0.54689485", "0.543...
0.77797806
0
Stop daemon with his name and wait for him. Where name is given name when daemon started with run method.
def stop(self, name: str) -> None: if name in self._running_daemons: logger.info(self, 'Stopping daemon with name "{0}" ...' .format(name)) self._running_daemons[name].stop() self._running_daemons[name].join() del self._running_daemons[name] logger.info(self, 'Stopping daemon with name "{0}": OK' .format(name))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop(name):\n __salt__[\"file.touch\"](\"{}/down\".format(_service_path(name)))\n cmd = \"svc -d {}\".format(_service_path(name))\n return not __salt__[\"cmd.retcode\"](cmd, python_shell=False)", "def stop(self):\n \n\n if os.path.isfile(self.pidfilename):\n\n with open(self...
[ "0.6745563", "0.6272498", "0.61989063", "0.61097825", "0.61078", "0.61078", "0.61078", "0.61078", "0.61078", "0.61078", "0.6076316", "0.60686696", "0.5986718", "0.59339917", "0.59136623", "0.58186764", "0.5801948", "0.5795598", "0.57658505", "0.5718274", "0.56732404", "0.56...
0.8205817
0
Stop all started daemons and wait for them.
def stop_all(self) -> None: logger.info(self, 'Stopping all daemons') for name, daemon in self._running_daemons.items(): logger.info(self, 'Stopping daemon "{0}" ...'.format(name)) daemon.stop() for name, daemon in self._running_daemons.items(): logger.info( self, 'Stopping daemon "{0}" waiting confirmation'.format(name), ) daemon.join() logger.info(self, 'Stopping daemon "{0}" OK'.format(name)) self._running_daemons = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stopdaemons(self):\n # TODO: we may want to improve this if we had the PIDs from the\n # specific EMANE daemons that we\"ve started\n cmd = [\"killall\", \"-q\", \"emane\"]\n stop_emane_on_host = False\n if emane.VERSION > emane.EMANE091:\n for node in self.g...
[ "0.6984014", "0.6787286", "0.6787142", "0.67022586", "0.66824", "0.66690004", "0.66061735", "0.6547983", "0.64799696", "0.64767784", "0.6424291", "0.6407507", "0.64050364", "0.63752985", "0.63732857", "0.6344195", "0.6343308", "0.63306564", "0.63221437", "0.6291567", "0.62800...
0.75923276
0
Add callback to self._daemon_execute_callbacks. See service_actions function to their usages.
def append_thread_callback(self, callback: collections.Callable) -> None: self._daemon_execute_callbacks.append(callback)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_post_exec_callback(action_logger):\n logging.debug(\"Adding %s to post execution callback\", action_logger)\n __post_exec_callbacks.append(action_logger)", "def add_done_callback(self, callback):\n with self._done_condition:\n if self._state in [PENDING, RUNNING]:\n ...
[ "0.595641", "0.57329416", "0.5647649", "0.56453633", "0.56191623", "0.55979604", "0.5584443", "0.5554504", "0.5554059", "0.5503657", "0.55009544", "0.5450373", "0.54332", "0.5432897", "0.5395858", "0.53488904", "0.53168035", "0.53141373", "0.53129905", "0.53031254", "0.528276...
0.71937627
0
Override (and call super if needed) to execute actions when server finish it's job.
def _after_serve_actions(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_done(self):\n pass", "def _finished(self) -> None:", "def action_done(self):", "def on_finish(self):\n pass", "def finish(self):\n pass", "def finish(self):\n pass", "def finish(self):", "def finish(self):", "def finished(self):\n\t\telog(\"finished\")", "de...
[ "0.69335014", "0.67695177", "0.6727767", "0.67259187", "0.66190356", "0.66190356", "0.6559876", "0.6559876", "0.6558329", "0.65446657", "0.651298", "0.64880097", "0.6475922", "0.64282835", "0.64253885", "0.6419166", "0.64123946", "0.6380179", "0.637515", "0.6371133", "0.63532...
0.6718268
4
Place here code who have to be executed in Daemon.
def run(self) -> None: raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def daemonize(self):\n raise NotImplementedError()", "def postRun(self):\n pass", "def run(self):\n\t\t\n\t\tpass", "def run(self):\r\n pass", "def on_run(self):\r\n\r\n\t\tpass", "def run(self):\n pass", "def run(self):\n pass", "def run(self):\n pass", "d...
[ "0.70369405", "0.69512874", "0.6877563", "0.68728536", "0.68709666", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.6860057", "0.68293357"...
0.0
-1
Place here code who stop your daemon
def stop(self) -> None: raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def daemonControlStop (self):\n self.stop()", "def stop():", "def stop():", "def stop():", "def stop():", "def stop() -> None:", "def _stop(self):\n\n if self._daemon_id:\n pyro_proxy_name = 'PySwitchLib.' + self._daemon_id\n uri = None\n\n try:\n ...
[ "0.8209891", "0.7617903", "0.7617903", "0.7617903", "0.7617903", "0.7484269", "0.74468565", "0.7427765", "0.74194515", "0.735742", "0.7213389", "0.7157245", "0.7151083", "0.71393114", "0.71393114", "0.713881", "0.71239346", "0.7106208", "0.7101017", "0.70925385", "0.7086577",...
0.0
-1
Place here the logic who permit to execute a callback in your daemon. To get an exemple of that, take a look at socketserver.BaseServerservice_actions and how we use it in tracim.lib.daemons.TracimSocketServerMixinservice_actions .
def append_thread_callback(self, callback: collections.Callable) -> None: raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_callback(self, *args, **kwargs):\n pass", "def runCallback(self, callback=\"help\"):\n self.initialize()\n\n # run the start callback\n tools.run_callback(\"start\", {'request': self._request})\n\n config = self._request.getConfig()\n data = self._request.get...
[ "0.61480016", "0.6066873", "0.5986107", "0.5986107", "0.5986107", "0.58790046", "0.58790046", "0.5869151", "0.58683604", "0.58638734", "0.584408", "0.57616746", "0.5756446", "0.575161", "0.57416856", "0.5701535", "0.56993234", "0.56893677", "0.5688993", "0.5670947", "0.567094...
0.0
-1
To see origin radical server start method, refer to radicale.__main__.run
def run(self): self._server = self._get_server() self._server.serve_forever()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n return run_server(**parse_server_args())", "def server():", "def server():", "def start():\n\n start_server()", "def main():\n lgs = LifeGenServer()\n lgs.listening()", "def run():\n server = current_server()\n server._auto_stop = True\n return start()", "def main():\...
[ "0.7265003", "0.7243618", "0.7243618", "0.70818865", "0.7028635", "0.69132644", "0.6839666", "0.6825683", "0.681672", "0.6768261", "0.6730405", "0.6678762", "0.6678762", "0.6678762", "0.6678762", "0.6663593", "0.6642349", "0.657283", "0.65676385", "0.65592045", "0.65030617", ...
0.6443563
26
Give the callback to running server through tracim.lib.daemons.TracimSocketServerMixinappend_thread_callback
def append_thread_callback(self, callback: collections.Callable) -> None: self._server.append_thread_callback(callback)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append_thread_callback(self, callback: collections.Callable) -> None:\n raise NotImplementedError()", "def append_thread_callback(self, callback: collections.Callable) -> None:\n raise NotImplementedError()", "def append_thread_callback(self, callback: collections.Callable) -> None:\n ...
[ "0.69699574", "0.69699574", "0.6759113", "0.650974", "0.6113602", "0.6105394", "0.6034728", "0.5840231", "0.58131206", "0.5809989", "0.58065826", "0.57807076", "0.5766478", "0.57587993", "0.57118356", "0.57069206", "0.5706047", "0.5696736", "0.5682783", "0.56253636", "0.56038...
0.7782145
0
Setup configuration dictionary from default, command line and configuration file.
def _initConfig(self): from tg import config as tg_config # Set config defaults config = DEFAULT_CONFIG.copy() temp_verbose = config["verbose"] # Configuration file overrides defaults default_config_file = os.path.abspath(DEFAULT_CONFIG_FILE) config_file = tg_config.get('wsgidav.config_path', default_config_file) fileConf = self._readConfigFile(config_file, temp_verbose) config.update(fileConf) if not useLxml and config["verbose"] >= 1: print( "WARNING: Could not import lxml: using xml instead (slower). Consider installing lxml from http://codespeak.net/lxml/.") from wsgidav.dir_browser import WsgiDavDirBrowser from tracim.lib.webdav.tracim_http_authenticator import TracimHTTPAuthenticator from wsgidav.error_printer import ErrorPrinter from tracim.lib.webdav.utils import TracimWsgiDavDebugFilter config['middleware_stack'] = [ WsgiDavDirBrowser, TracimHTTPAuthenticator, ErrorPrinter, TracimWsgiDavDebugFilter, ] config['provider_mapping'] = { config['root_path']: Provider( # TODO: Test to Re enabme archived and deleted show_archived=False, # config['show_archived'], show_deleted=False, # config['show_deleted'], show_history=False, # config['show_history'], manage_locks=config['manager_locks'] ) } config['domaincontroller'] = TracimDomainController(presetdomain=None, presetserver=None) return config
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_config(self, args=None):\n self.config_parse(args=args)", "def _set_config():\n\n\tdebug_msg = \"load default config yaml file\"\n\tlogger.debug(debug_msg)\n\n\tconfig_file_parser(paths.CONFIG_FILE, override_options=True)", "def setup_config(args):\n # Set the default configuration file\n ...
[ "0.74864733", "0.73788", "0.72554004", "0.7032301", "0.69752103", "0.680831", "0.6783307", "0.6707568", "0.6688659", "0.66088086", "0.66088086", "0.66088086", "0.659005", "0.65800065", "0.65319824", "0.6522549", "0.6519806", "0.65005475", "0.6498203", "0.6494329", "0.6458113"...
0.5951583
100
Read configuration file options into a dictionary.
def _readConfigFile(self, config_file, verbose): if not os.path.exists(config_file): raise RuntimeError("Couldn't open configuration file '%s'." % config_file) try: import imp conf = {} configmodule = imp.load_source("configuration_module", config_file) for k, v in vars(configmodule).items(): if k.startswith("__"): continue elif isfunction(v): continue conf[k] = v except Exception as e: exceptioninfo = traceback.format_exception_only(sys.exc_type, sys.exc_value) # @UndefinedVariable exceptiontext = "" for einfo in exceptioninfo: exceptiontext += einfo + "\n" print("Failed to read configuration file: " + config_file + "\nDue to " + exceptiontext, file=sys.stderr) raise return conf
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_options(self,options_file):\n config=ConfigParser.ConfigParser()\n config.read(options_file)\n return config", "def get_options(self):\n options = dict()\n while True:\n line = self.rfile.readline().decode(\"utf8\").strip()\n if not line:\n ...
[ "0.752643", "0.7390634", "0.6979872", "0.6950356", "0.6929618", "0.69171613", "0.6908236", "0.69044363", "0.6872603", "0.68331844", "0.6820686", "0.6786975", "0.675589", "0.67299527", "0.669033", "0.66791064", "0.6634677", "0.6587671", "0.6573179", "0.65618944", "0.6558374", ...
0.0
-1
Place here the logic who permit to execute a callback in your daemon. To get an exemple of that, take a look at socketserver.BaseServerservice_actions and how we use it in tracim.lib.daemons.TracimSocketServerMixinservice_actions .
def append_thread_callback(self, callback: collections.Callable) -> None: raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_callback(self, *args, **kwargs):\n pass", "def runCallback(self, callback=\"help\"):\n self.initialize()\n\n # run the start callback\n tools.run_callback(\"start\", {'request': self._request})\n\n config = self._request.getConfig()\n data = self._request.get...
[ "0.61473083", "0.60644734", "0.59864354", "0.59864354", "0.59864354", "0.58798265", "0.58798265", "0.58690506", "0.58685577", "0.5863799", "0.5844272", "0.57613087", "0.57569206", "0.5749366", "0.57412654", "0.57007855", "0.5698948", "0.5689918", "0.56894755", "0.56721413", "...
0.0
-1
Validate if price amount does not have too many decimal places. Price amount can't have more decimal places than currency allow to. Works only with decimal created from a string.
def validate_price_precision(value: Optional["Decimal"], currency: str = None): # check no needed when there is no value if not value: return currency_fraction = get_currency_fraction(currency or settings.DEFAULT_CURRENCY) value = value.normalize() if abs(value.as_tuple().exponent) > currency_fraction: raise ValidationError( f"Value cannot have more than {currency_fraction} decimal places." )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_price(price):\n try:\n price = float(price)\n except ValueError:\n raise ValueError('Please provide valid price')\n if price < 1:\n raise ValueError('Price should be positive number')\n return price", "def monetary_amount_valid(record, field_name='price', min=1, max...
[ "0.7102188", "0.6969148", "0.67373794", "0.66555464", "0.6602999", "0.65736985", "0.64711094", "0.64241284", "0.64125", "0.6275703", "0.61710167", "0.6137798", "0.6098253", "0.6075076", "0.6048671", "0.6011906", "0.5996882", "0.5977033", "0.5968822", "0.5943398", "0.5926788",...
0.79515773
0
Convert unsigned integer to signed integer
def _sign(val, length): if val & (1 << (length - 1)): return val - (1 << length) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hex_to_signed(source):\n if not isinstance(source, str):\n raise ValueError(\"string type required\")\n if 0 == len(source):\n raise ValueError(\"string is empty\")\n sign_bit_mask = 1 << (len(source)*4-1)\n other_bits_mask = sign_bit_mask - 1\n value = int(source, 16)\n return ...
[ "0.68929464", "0.6784579", "0.6784022", "0.6670777", "0.66213256", "0.6587066", "0.65621823", "0.64496046", "0.63200676", "0.6298704", "0.6244321", "0.6162956", "0.61544305", "0.6007191", "0.5979453", "0.59719074", "0.5969299", "0.59667593", "0.594946", "0.58942324", "0.58913...
0.5409037
68
Used for Pascals conversion
def get_digp1(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGP1, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate( t, P ): \n assert t.shape[0]==P.n # Dimension match \n if P.type=='AH_polytope':\n return pp.AH_polytope(t=t+P.t,T=P.T,P=P.P)\n elif P.type=='zonotope':\n return pp.zonotope(x=t+P.x,G=P.G)\n elif P.type==\"H_polytope\":\n return pp.H_polytope(H=P.H,h=P.h+np.dot...
[ "0.5746834", "0.56467426", "0.5606455", "0.55982906", "0.5580379", "0.55670595", "0.55477345", "0.55038863", "0.546426", "0.5375387", "0.53611434", "0.5353585", "0.53360903", "0.53228235", "0.53204024", "0.5287861", "0.5272878", "0.5272488", "0.5270376", "0.52341413", "0.5225...
0.0
-1
Used for Pascals conversion
def get_digp2(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGP2, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] # Unsigned > Signed integer val = _sign(val, 16) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate( t, P ): \n assert t.shape[0]==P.n # Dimension match \n if P.type=='AH_polytope':\n return pp.AH_polytope(t=t+P.t,T=P.T,P=P.P)\n elif P.type=='zonotope':\n return pp.zonotope(x=t+P.x,G=P.G)\n elif P.type==\"H_polytope\":\n return pp.H_polytope(H=P.H,h=P.h+np.dot...
[ "0.5746834", "0.56467426", "0.5606455", "0.55982906", "0.5580379", "0.55670595", "0.55477345", "0.55038863", "0.546426", "0.5375387", "0.53611434", "0.5353585", "0.53360903", "0.53228235", "0.53204024", "0.5287861", "0.5272878", "0.5272488", "0.5270376", "0.52341413", "0.5225...
0.0
-1
Used for Pascals conversion
def get_digp3(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGP3, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] # Unsigned > Signed integer val = _sign(val, 16) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate( t, P ): \n assert t.shape[0]==P.n # Dimension match \n if P.type=='AH_polytope':\n return pp.AH_polytope(t=t+P.t,T=P.T,P=P.P)\n elif P.type=='zonotope':\n return pp.zonotope(x=t+P.x,G=P.G)\n elif P.type==\"H_polytope\":\n return pp.H_polytope(H=P.H,h=P.h+np.dot...
[ "0.5746834", "0.56467426", "0.5606455", "0.55982906", "0.5580379", "0.55670595", "0.55477345", "0.55038863", "0.546426", "0.5375387", "0.53611434", "0.5353585", "0.53360903", "0.53228235", "0.53204024", "0.5287861", "0.5272878", "0.5272488", "0.5270376", "0.52341413", "0.5225...
0.0
-1
Used for Pascals conversion
def get_digp4(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGP4, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] # Unsigned > Signed integer val = _sign(val, 16) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate( t, P ): \n assert t.shape[0]==P.n # Dimension match \n if P.type=='AH_polytope':\n return pp.AH_polytope(t=t+P.t,T=P.T,P=P.P)\n elif P.type=='zonotope':\n return pp.zonotope(x=t+P.x,G=P.G)\n elif P.type==\"H_polytope\":\n return pp.H_polytope(H=P.H,h=P.h+np.dot...
[ "0.5746834", "0.56467426", "0.5606455", "0.55982906", "0.5580379", "0.55670595", "0.55477345", "0.55038863", "0.546426", "0.5375387", "0.53611434", "0.5353585", "0.53360903", "0.53228235", "0.53204024", "0.5287861", "0.5272878", "0.5272488", "0.5270376", "0.52341413", "0.5225...
0.0
-1
Used for Pascals conversion
def get_digp5(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGP5, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] # Unsigned > Signed integer val = _sign(val, 16) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate( t, P ): \n assert t.shape[0]==P.n # Dimension match \n if P.type=='AH_polytope':\n return pp.AH_polytope(t=t+P.t,T=P.T,P=P.P)\n elif P.type=='zonotope':\n return pp.zonotope(x=t+P.x,G=P.G)\n elif P.type==\"H_polytope\":\n return pp.H_polytope(H=P.H,h=P.h+np.dot...
[ "0.5746834", "0.56467426", "0.5606455", "0.55982906", "0.5580379", "0.55670595", "0.55477345", "0.55038863", "0.546426", "0.5375387", "0.53611434", "0.5353585", "0.53360903", "0.53228235", "0.53204024", "0.5287861", "0.5272878", "0.5272488", "0.5270376", "0.52341413", "0.5225...
0.0
-1
Used for Pascals conversion
def get_digp6(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGP6, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] # Unsigned > Signed integer val = _sign(val, 16) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate( t, P ): \n assert t.shape[0]==P.n # Dimension match \n if P.type=='AH_polytope':\n return pp.AH_polytope(t=t+P.t,T=P.T,P=P.P)\n elif P.type=='zonotope':\n return pp.zonotope(x=t+P.x,G=P.G)\n elif P.type==\"H_polytope\":\n return pp.H_polytope(H=P.H,h=P.h+np.dot...
[ "0.5746834", "0.56467426", "0.5606455", "0.55982906", "0.5580379", "0.55670595", "0.55477345", "0.55038863", "0.546426", "0.5375387", "0.53611434", "0.5353585", "0.53360903", "0.53228235", "0.53204024", "0.5287861", "0.5272878", "0.5272488", "0.5270376", "0.52341413", "0.5225...
0.0
-1
Used for Pascals conversion
def get_digp7(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGP7, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] # Unsigned > Signed integer val = _sign(val, 16) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate( t, P ): \n assert t.shape[0]==P.n # Dimension match \n if P.type=='AH_polytope':\n return pp.AH_polytope(t=t+P.t,T=P.T,P=P.P)\n elif P.type=='zonotope':\n return pp.zonotope(x=t+P.x,G=P.G)\n elif P.type==\"H_polytope\":\n return pp.H_polytope(H=P.H,h=P.h+np.dot...
[ "0.5746834", "0.56467426", "0.5606455", "0.55982906", "0.5580379", "0.55670595", "0.55477345", "0.55038863", "0.546426", "0.5375387", "0.53611434", "0.5353585", "0.53360903", "0.53228235", "0.53204024", "0.5287861", "0.5272878", "0.5272488", "0.5270376", "0.52341413", "0.5225...
0.0
-1
Used for Pascals conversion
def get_digp8(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGP8, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] # Unsigned > Signed integer val = _sign(val, 16) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate( t, P ): \n assert t.shape[0]==P.n # Dimension match \n if P.type=='AH_polytope':\n return pp.AH_polytope(t=t+P.t,T=P.T,P=P.P)\n elif P.type=='zonotope':\n return pp.zonotope(x=t+P.x,G=P.G)\n elif P.type==\"H_polytope\":\n return pp.H_polytope(H=P.H,h=P.h+np.dot...
[ "0.5746834", "0.56467426", "0.5606455", "0.55982906", "0.5580379", "0.55670595", "0.55477345", "0.55038863", "0.546426", "0.5375387", "0.53611434", "0.5353585", "0.53360903", "0.53228235", "0.53204024", "0.5287861", "0.5272878", "0.5272488", "0.5270376", "0.52341413", "0.5225...
0.0
-1
Used for Pascals conversion
def get_digp9(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGP9, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] # Unsigned > Signed integer val = _sign(val, 16) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate( t, P ): \n assert t.shape[0]==P.n # Dimension match \n if P.type=='AH_polytope':\n return pp.AH_polytope(t=t+P.t,T=P.T,P=P.P)\n elif P.type=='zonotope':\n return pp.zonotope(x=t+P.x,G=P.G)\n elif P.type==\"H_polytope\":\n return pp.H_polytope(H=P.H,h=P.h+np.dot...
[ "0.5746834", "0.56467426", "0.5606455", "0.55982906", "0.5580379", "0.55670595", "0.55477345", "0.55038863", "0.546426", "0.5375387", "0.53611434", "0.5353585", "0.53360903", "0.53228235", "0.53204024", "0.5287861", "0.5272878", "0.5272488", "0.5270376", "0.52341413", "0.5225...
0.0
-1
Used for Celcius conversion
def get_digt1(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGT1, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toCelcius (x):\r\n\r\n\tc = x-32\r\n\tc = 5*c/9\r\n\treturn c", "def convert_f_to_c(temp_in_farenheit): ## ##\n celsiustemp = round((temp_in_farenheit - 32) * 5/9, 1) ##\n return celsiustemp ...
[ "0.7335546", "0.73061866", "0.7164362", "0.71419686", "0.70893985", "0.7044183", "0.69620115", "0.69535786", "0.693041", "0.68804646", "0.686146", "0.6860047", "0.6839268", "0.67844945", "0.6779255", "0.67736447", "0.6747232", "0.67196256", "0.6672907", "0.66488284", "0.66381...
0.0
-1
Used for Celcius conversion
def get_digt2(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGT2, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] # Unsigned > Signed integer val = _sign(val, 16) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toCelcius (x):\r\n\r\n\tc = x-32\r\n\tc = 5*c/9\r\n\treturn c", "def convert_f_to_c(temp_in_farenheit): ## ##\n celsiustemp = round((temp_in_farenheit - 32) * 5/9, 1) ##\n return celsiustemp ...
[ "0.7335546", "0.73061866", "0.7164362", "0.71419686", "0.70893985", "0.7044183", "0.69620115", "0.69535786", "0.693041", "0.68804646", "0.686146", "0.6860047", "0.6839268", "0.67844945", "0.6779255", "0.67736447", "0.6747232", "0.67196256", "0.6672907", "0.66488284", "0.66381...
0.0
-1
Used for Celcius conversion
def get_digt3(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_DIGT3, 2, addrsize=16 ) val = 0 val = val << 8 | byte_list[0] val = val << 8 | byte_list[1] # Unsigned > Signed integer val = _sign(val, 16) return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toCelcius (x):\r\n\r\n\tc = x-32\r\n\tc = 5*c/9\r\n\treturn c", "def convert_f_to_c(temp_in_farenheit): ## ##\n celsiustemp = round((temp_in_farenheit - 32) * 5/9, 1) ##\n return celsiustemp ...
[ "0.7335546", "0.73061866", "0.7164362", "0.71419686", "0.70893985", "0.7044183", "0.69620115", "0.69535786", "0.693041", "0.68804646", "0.686146", "0.6860047", "0.6839268", "0.67844945", "0.6779255", "0.67736447", "0.6747232", "0.67196256", "0.6672907", "0.66488284", "0.66381...
0.0
-1
Part 2 of Pressure
def get_pressurelsb(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_PRESSURELSB, 1, addrsize=8 ) val = 0 val = val << 8 | byte_list[0] return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def p2(self):\n return tuple(self.rect[2:])", "def getPhase(phase):", "def photometric_calibration():\n pass", "def PTS(self):", "def spreading_pressure(self, pressure):\n raise NotImplementedError", "def getVaporPressures(self,T):\n\t\treturn self.getPureVaporPressures(T) * self.get...
[ "0.5984865", "0.59421945", "0.5936604", "0.5930005", "0.5815522", "0.5792464", "0.57799864", "0.568365", "0.56691325", "0.5646131", "0.5614897", "0.56123614", "0.55965215", "0.5547216", "0.5510213", "0.5506101", "0.5501234", "0.5500006", "0.5470516", "0.54686475", "0.54603857...
0.0
-1
Part 1 of Pressure
def get_pressuremsb(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_PRESSUREMSB, 1, addrsize=8 ) val = 0 val = val << 8 | byte_list[0] return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def p1(self):\n return tuple(self.rect[:2])", "def p1(self):\n return self.lerp(1)", "def PTS(self):", "def getPhase(phase):", "def spreading_pressure(self, pressure):\n raise NotImplementedError", "def read_ch1_pressure(self):\n sensor = self.ch1_index + 1\n return sel...
[ "0.6027038", "0.6018289", "0.59194505", "0.5911894", "0.5866803", "0.5788144", "0.577886", "0.57712543", "0.5757554", "0.57493764", "0.5744791", "0.5744586", "0.5732459", "0.5689398", "0.5647965", "0.5624728", "0.56099045", "0.56039447", "0.55945814", "0.5576898", "0.55756456...
0.0
-1
Part 3 of Pressure
def get_pressurexlsb(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_PRESSUREXLSB, 1, addrsize=8 ) val = 0 val = val << 8 | byte_list[0] return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getPhase(phase):", "def getVaporPressures(self,T):\n\t\treturn self.getPureVaporPressures(T) * self.getMoleFractions()", "def read_ch3_pressure(self):\n sensor = self.ch3_index + 1\n return self.vgc.read_sensor(sensor)", "def __getRawPressure(self):\n p1 = self.read_byte_data(self.ad...
[ "0.59975135", "0.59529", "0.5795284", "0.577653", "0.57378757", "0.5698315", "0.5670824", "0.56199133", "0.56060827", "0.55923486", "0.5576982", "0.55640346", "0.5563621", "0.5557266", "0.55572647", "0.5529377", "0.55281675", "0.5523671", "0.5519779", "0.5508091", "0.550534",...
0.0
-1
Part 2 of temperature
def get_templsb(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_TEMPLSB, 1, addrsize=8 ) val = 0 val = val << 8 | byte_list[0] return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def temperature() -> float:", "def get_temperature(self): # This function implements the equations needed to convert the digital data to degrees celsius\n C_1, C_2, C_3, C_4, C_5, C_6=self.calibration_constants()\n self.digital_temp_data() \n dT = self.tempadc-(C_5*(2**8))\n te...
[ "0.75022674", "0.6949752", "0.68851936", "0.6819981", "0.6716974", "0.6714212", "0.66895014", "0.658674", "0.65440947", "0.65424365", "0.6501381", "0.6489448", "0.6445262", "0.64296085", "0.63779724", "0.63462263", "0.62889814", "0.62828195", "0.626543", "0.62536913", "0.6239...
0.0
-1
Part 1 of temperature
def get_tempmsb(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_TEMPMSB, 1, addrsize=8 ) val = 0 val = val << 8 | byte_list[0] return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def temperature() -> float:", "def tempAir(sample):\n sample *= 1.0\n sample /= 1000\n celsius = (sample - 0.5) * 100\n return round(celsius,2)", "def temperature(self):\n return self.read_short(65) / 340.0 + 36.53", "def temp(self):\n\t\ttemp_out = self.read16(MPU9250_ADDRESS, TEMP_DATA)\...
[ "0.75057805", "0.71406305", "0.70477206", "0.68433243", "0.6789365", "0.6610033", "0.6600349", "0.6574159", "0.64763486", "0.6449983", "0.63744015", "0.6371595", "0.63461995", "0.634101", "0.6339197", "0.62867576", "0.62532115", "0.62517107", "0.62048805", "0.6199405", "0.617...
0.0
-1
Final part of temperature
def get_tempxlsb(self): byte_list = self.i2c.readfrom_mem( self.device_address, self.REGISTER_TEMPXLSB, 1, addrsize=8 ) val = 0 val = val << 8 | byte_list[0] return val
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def temperature() -> float:", "def temp(self):\n\t\ttemp_out = self.read16(MPU9250_ADDRESS, TEMP_DATA)\n\t\ttemp = temp_out / 333.87 + 21.0 # these are from the datasheets\n\t\treturn temp", "def temperature(self):\n return self.read_short(65) / 340.0 + 36.53", "def temperature(self):\r\n self...
[ "0.78644717", "0.7040451", "0.70314455", "0.6976013", "0.6931202", "0.69023395", "0.6838886", "0.6777305", "0.67651105", "0.67256445", "0.66897446", "0.6620118", "0.6585936", "0.65752214", "0.6567868", "0.6545582", "0.6541894", "0.6535391", "0.65285856", "0.6524216", "0.65185...
0.0
-1
Reads the atmospheric pressure
def pressure_ashpa(self): hpa = None # Variable declaration raw_comp1 = None # Variable declaration raw_comp2 = None # Variable declaration raw_comp3 = None # Variable declaration raw_pressure = None # Variable declaration raw_temperature = None # Variable declaration value_d_p1 = None # Variable declaration value_d_p2 = None # Variable declaration value_d_p3 = None # Variable declaration value_d_p4 = None # Variable declaration value_d_p5 = None # Variable declaration value_d_p6 = None # Variable declaration value_d_p7 = None # Variable declaration value_d_p8 = None # Variable declaration value_d_p9 = None # Variable declaration value_lsb = None # Variable declaration value_msb = None # Variable declaration value_xlsb = None # Variable declaration value_msb = self.get_pressuremsb() value_lsb = self.get_pressurelsb() value_xlsb = self.get_pressurexlsb() value_d_p1 = self.get_digp1() value_d_p2 = self.get_digp2() value_d_p3 = self.get_digp3() value_d_p4 = self.get_digp4() value_d_p5 = self.get_digp5() value_d_p6 = self.get_digp6() value_d_p7 = self.get_digp7() value_d_p8 = self.get_digp8() value_d_p9 = self.get_digp9() raw_temperature = self.temperature_ascelsius() raw_temperature = (raw_temperature*5120.0) raw_pressure = ((value_msb << 12)+(value_lsb << 4)+(value_xlsb >> 4)) raw_comp1 = ((raw_temperature/2)-64000.0) raw_comp2 = ((raw_comp1*raw_comp1*value_d_p6)/32768.0) raw_comp2 = (raw_comp2+(raw_comp1*value_d_p5*2.0)) raw_comp2 = ((raw_comp2/4.0)+(value_d_p4*65536.0)) raw_comp3 = (value_d_p3*raw_comp1*raw_comp1) raw_comp1 = (((raw_comp3/524288.0)+(value_d_p2*raw_comp1))/524288.0) raw_comp1 = ((1.0+(raw_comp1/32768.0))*value_d_p1) hpa = (1048576.0-raw_pressure) hpa = ((hpa-(raw_comp2/4096.0))*(6250.0/raw_comp1)) raw_comp1 = ((value_d_p9*hpa*hpa)/2147483648.0) raw_comp2 = ((hpa*value_d_p8)/32768.0) hpa = (hpa+((raw_comp1+raw_comp2+value_d_p7)/16.0)) hpa = (hpa/100.0) return hpa
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def READ_PRESSURE_SENSOR():\n return 15.246", "def read_pressure(self):\n pRaw = self._read_multiple_bytes_as_array(self.BME280_PRESS_MSB, 3)\n\n return float(self._compensate_pressure((pRaw[0] << 12) + (pRaw[1] << 4) + (pRaw[2] >> 4)))", "def read_pressure(self):\n self._force_read(Fal...
[ "0.74346906", "0.71479714", "0.7144106", "0.6846375", "0.6817508", "0.6734783", "0.6672526", "0.6588971", "0.64872605", "0.6470143", "0.64621484", "0.6445108", "0.63821894", "0.63638276", "0.6348568", "0.62918764", "0.62351376", "0.6234648", "0.61907625", "0.6124125", "0.6048...
0.6077152
20
Reads the atmospheric pressure
def pressure_asraw(self): output = None # Variable declaration value_lsb = None # Variable declaration value_msb = None # Variable declaration value_xlsb = None # Variable declaration value_msb = self.get_pressuremsb() value_lsb = self.get_pressurelsb() value_xlsb = self.get_pressurexlsb() output = ((value_msb << 12)+(value_lsb << 4)+(value_xlsb >> 4)) return output
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def READ_PRESSURE_SENSOR():\n return 15.246", "def read_pressure(self):\n pRaw = self._read_multiple_bytes_as_array(self.BME280_PRESS_MSB, 3)\n\n return float(self._compensate_pressure((pRaw[0] << 12) + (pRaw[1] << 4) + (pRaw[2] >> 4)))", "def read_pressure(self):\n self._force_read(Fal...
[ "0.74346906", "0.71479714", "0.7144106", "0.6846375", "0.6817508", "0.6734783", "0.6672526", "0.6588971", "0.64872605", "0.6470143", "0.64621484", "0.6445108", "0.63821894", "0.63638276", "0.6348568", "0.62918764", "0.62351376", "0.6234648", "0.61907625", "0.6124125", "0.6077...
0.5565741
66
Function to handle the initialization of the class. Creates a [x,y] sample for each timestep std sequenceLenght
def __init__(self, std, sequenceLength, device): #create data steps from 2 to 10 with the given sequence length xTimeSteps = np.linspace(2, 10, sequenceLength + 1) #create numpy array with sin(x) input yNp = np.zeros((2, sequenceLength + 1)) yNp[1,:] = np.sin(xTimeSteps) + np.random.normal(0, std, xTimeSteps.size) yNp[0,:] = xTimeSteps #yNp.resize((sequenceLength + 1, 1)) #yInput = Variable(torch.Tensor(Yt[:, :-1]).type(dtype), requires_grad = False).to(device) self.yInput = torch.tensor(yNp[:, :-1], dtype=torch.float, device=device, requires_grad=False) # create the target or ground truth data #yTarget = Variable(torch.Tensor(Yt[:, 1:]).type(dtype), requires_grad = False).to(device) self.yTarget = torch.tensor(yNp[:, 1:], dtype=torch.float, device=device, requires_grad=False) # Normalizes values self.yInput = self.yInput / torch.max(self.yInput) self.yTarget = self.yTarget / torch.max(self.yTarget)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _init_sample(self):\n self.timestamps = np.zeros(5)\n self.data = np.zeros((5, 12))", "def __init__(self, samples):\n self.samples = samples", "def setUp(self):\n shape = RNG.integers(5, 50)\n periods = self.periods = RNG.normal() * 3\n freq = periods / shape\n ...
[ "0.7491473", "0.6757173", "0.6536982", "0.645627", "0.6443957", "0.63328993", "0.63073266", "0.63073266", "0.6270523", "0.622384", "0.6216968", "0.6200106", "0.61991644", "0.61531895", "0.6119851", "0.6113955", "0.6103908", "0.6098615", "0.609861", "0.60970324", "0.6093548", ...
0.67708
1
Function that retrieves a sample from the sequence at index position index (input, target)
def __getitem__(self, index): #current input in the sequence at t x = self.yInput[:, index] #input = x[t] not like that to create a matrix and not a vector #current target value at t target = self.yTarget[:, index] return (x, target)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getitem__(self, index):\n return self.data_source.get_sample(index)", "def get_item(self, index, rng=None):\n if index is None:\n rng = kwarray.ensure_rng(rng)\n index = rng.randint(0, self.n_samples)\n\n if index < self.n_positives:\n sample = self.get...
[ "0.7177392", "0.6993439", "0.6574442", "0.6479869", "0.6433116", "0.639488", "0.63798004", "0.6367376", "0.63340366", "0.62953746", "0.6275092", "0.622632", "0.6221444", "0.620183", "0.61413056", "0.61234695", "0.60797495", "0.60285115", "0.6003341", "0.600036", "0.5991213", ...
0.61867076
14
Function that retrieves the length of the dataset, by calling len() on the input size
def __len__(self): return self.yInput.shape[1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __len__(self):\n\t\treturn min(len(self.dataset), self.opt.max_dataset_size)", "def __len__(self):\n return self.dataset.shape[0]", "def __len__(self):\n return self._dataset.size(dirs=self._dirs)", "def __len__(self):\n if not self.opt.union:\n return min(len(self.dataset...
[ "0.8217852", "0.80500615", "0.80106336", "0.7973031", "0.7865418", "0.7808488", "0.77789485", "0.77380437", "0.77380145", "0.76801974", "0.7626708", "0.7614121", "0.7594042", "0.7547416", "0.75451", "0.75428635", "0.7542736", "0.75397843", "0.7538644", "0.75285465", "0.752854...
0.0
-1
Function to handle the initialization of the class. Calls pandas to read from csv and generates the input and gt matrices datase(train_loader, val_loader) = get_dataloaders(dataset, batch_size=batch_size, test_percentage=0.2, normalize=normalize)t_name normalize
def __init__(self, dataset_name, device): dataFrame = pandas.read_csv(dataset_name) Y = dataFrame.values[:,1:] Yt = Y.transpose() #create the input time series for the model, with one unit of delay, is no model parameter, no grad needed #yInput = Variable(torch.Tensor(Yt[:, :-1]).type(dtype), requires_grad = False).to(device) self.yInput = torch.tensor(Yt[:, :-1], dtype=torch.float, device=device, requires_grad=False) # create the target or ground truth data #yTarget = Variable(torch.Tensor(Yt[:, 1:]).type(dtype), requires_grad = False).to(device) self.yTarget = torch.tensor(Yt[:, 1:], dtype=torch.float, device=device, requires_grad=False) # Normalizes values self.yInput = self.yInput / torch.max(self.yInput) self.yTarget = self.yTarget / torch.max(self.yTarget)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n print ('Initializing Data reader object...')\n data_Train_Images, data_Train_Labels, data_Test_Image, data_Test_Labels = self.readDataFromFile()\n test_10k_x, test_10k_y, training_55k_x, training_55k_y, validation_5k_x, validation_5k_y = self.dataTransform(\n d...
[ "0.7242687", "0.6937509", "0.69276804", "0.6882521", "0.6867684", "0.6830345", "0.6817077", "0.6798946", "0.67403924", "0.6737431", "0.6725287", "0.67230064", "0.66903865", "0.664605", "0.6631148", "0.6628094", "0.6617975", "0.65961725", "0.65749186", "0.65646493", "0.6559803...
0.6179124
90
Function that retrieves a sample from the sequence at index position index (input, target)
def __getitem__(self, index): #current input in the sequence at t x = self.yInput[:, index] #input = x[t] not like that to create a matrix and not a vector #current target value at t target = self.yTarget[:, index] return (x, target)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getitem__(self, index):\n return self.data_source.get_sample(index)", "def get_item(self, index, rng=None):\n if index is None:\n rng = kwarray.ensure_rng(rng)\n index = rng.randint(0, self.n_samples)\n\n if index < self.n_positives:\n sample = self.get...
[ "0.7175901", "0.69925886", "0.6573201", "0.6478542", "0.64330244", "0.63936025", "0.6378319", "0.6366167", "0.6333262", "0.6294942", "0.62753564", "0.62244225", "0.6220145", "0.6200444", "0.61401314", "0.61223245", "0.60786855", "0.60272735", "0.6001422", "0.6001254", "0.5992...
0.61865616
15
Function that retrieves the length of the dataset, by calling len() on the input size
def __len__(self): return self.yInput.shape[1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __len__(self):\n\t\treturn min(len(self.dataset), self.opt.max_dataset_size)", "def __len__(self):\n return self.dataset.shape[0]", "def __len__(self):\n return self._dataset.size(dirs=self._dirs)", "def __len__(self):\n if not self.opt.union:\n return min(len(self.dataset...
[ "0.8218616", "0.8050646", "0.8010462", "0.7973392", "0.7862939", "0.7809265", "0.7778281", "0.77387667", "0.77377516", "0.7679941", "0.76261914", "0.76114035", "0.75940055", "0.75465757", "0.7545617", "0.75418496", "0.7541782", "0.7539271", "0.7537385", "0.75279963", "0.75279...
0.0
-1
Creates the matrices for the Elman model, in this case W1 and V contextConcatInputLayerSize hiddenLayerSize outputLayerSize
def __init__(self, contextConcatInputLayerSize, hiddenLayerSize, outputLayerSize, device): super(ElmanNet, self).__init__() self.hidden_layer_size = hiddenLayerSize # Initializes the W1 matrix W1 = torch.zeros((contextConcatInputLayerSize, hiddenLayerSize), dtype=torch.float, device=device) self.W1 = Parameter(W1, requires_grad=True) #randomly init W1 parameter matrix with mean 0 and std 0.4 nn.init.normal_(self.W1, 0.0, 0.4) # Initializes the V matrix V = torch.zeros((hiddenLayerSize, outputLayerSize), dtype=torch.float, device=device) self.V = Parameter(V, requires_grad=True) # randomly init V parameter matrix with mean 0 and std 0.3 nn.init.normal_(self.V, 0.0, 0.3)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_variables(self):\n self.create_weight_variable(self.input_size + [self.hidden_size[0]], name=\"W1\")\n\n self.create_bias_variable((1, self.hidden_size[0]), name=\"b1\")\n\n for i in range(self.n_hidden-1):\n self.create_weight_variable([self.hidden_size[i], self.hidden_s...
[ "0.60445243", "0.5994819", "0.59890795", "0.5960874", "0.59296095", "0.59175307", "0.59017277", "0.58717036", "0.5868812", "0.5800571", "0.56979", "0.56773806", "0.5673088", "0.56546074", "0.56416607", "0.5627796", "0.5624328", "0.55904293", "0.55746734", "0.5568759", "0.5557...
0.73267615
0
Function that retrieves the size of the hidden layer
def get_hidden_layer_size(self): return self.hidden_layer_size
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def layer_size(self, layer_id): # -> int:\n ...", "def hidden_size(self):\n return self._internal.get_hidden_size()", "def get_final_emb_size(self):\n size = self.n_layers * 1 * 2 * self.hidden_size\n return size", "def get_size(self):\n return self._surf.get_size()", "de...
[ "0.7838551", "0.7757203", "0.765589", "0.7248255", "0.72339445", "0.72339445", "0.71614826", "0.71602", "0.71266425", "0.7090172", "0.70477694", "0.70440054", "0.6969208", "0.69381", "0.69150704", "0.687971", "0.68564427", "0.6826497", "0.6812965", "0.6804558", "0.67893684", ...
0.88835496
0
Model forward pass input, current input in t contextState, previous output in (t 1) the sequence of hidden states
def forward(self, x, contextState): #concatenate input and context state #x = x.t() xAndContext = torch.cat((x, contextState), 1) #calculate next context state (hidden output for current t) with tanh(xAndContext * W1) contextState = torch.tanh(xAndContext.mm(self.W1)) # Calculates final output output = contextState.mm(self.V) return (output, contextState)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, prev_state, obs_t):\r\n # Use your network to compute qvalues for given state\r\n #print(state_t.shape)\r\n h = self.conv(obs_t)\r\n\r\n h = h.view(h.size(0), -1)\r\n\r\n new_state = h_new, c_new = self.lstm(h, prev_state)\r\n advantage = self.adv(h_new)\...
[ "0.70666903", "0.6960144", "0.6944148", "0.6924527", "0.68692386", "0.68370396", "0.68172926", "0.6813111", "0.68120724", "0.68052375", "0.67952406", "0.6781737", "0.67794245", "0.6764326", "0.6733078", "0.6679583", "0.66273844", "0.6616958", "0.65847284", "0.657578", "0.6555...
0.7525371
0
Container for elongation data.
def __init__(self, xs, ys, gauge_length, sample_width, sample_thickness, name=None): assert len(xs) == len(ys) self.xs = np.array(xs) self.ys = np.array(ys) self.gauge_length = gauge_length # m self.sample_width = sample_width # m self.sample_thickness = sample_thickness # m self.name = name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_econt_info(self, out_log):\n f = open_general(out_log)\n tmptxt = f.readlines()\n f.close()\n econt = {}\n itmp = search_string('[read_energy] number of energy points', tmptxt)\n if itmp>=0: econt['Nepts'] = int(tmptxt.pop(itmp).split()[-1])\n itmp = search...
[ "0.6156227", "0.61490273", "0.61462486", "0.61462486", "0.61188924", "0.610022", "0.6069271", "0.60254556", "0.6005331", "0.5923507", "0.5913841", "0.5896293", "0.5894834", "0.5858231", "0.5852582", "0.5809138", "0.58050984", "0.57585675", "0.5753052", "0.5728322", "0.5717573...
0.0
-1
Check if two Elongation objects are equivalent.
def __eq__(self, other): return isinstance(other, Elongation)\ and len(self.xs) == len(other.xs)\ and all(self.xs == other.xs) and all(self.ys == other.ys)\ and self.gauge_length == other.gauge_length\ and self.sample_width == other.sample_width\ and self.sample_thickness == other.sample_thickness\ and self.name == other.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def areEquivalent(*args):\n return _libsbml.Unit_areEquivalent(*args)", "def equivalent(self, other):\n return id(self) == id(other)", "def almost_equals(self, other):\n if self.__class__ is other.__class__ and len(self) == len(other):\n for a, b in zip(self, other):\n ...
[ "0.7179371", "0.71698356", "0.70256376", "0.69242305", "0.6891672", "0.6889412", "0.6868289", "0.6853487", "0.6802602", "0.6787559", "0.6784947", "0.6781069", "0.6712332", "0.6677166", "0.6673854", "0.6671227", "0.66428155", "0.66405296", "0.66279215", "0.66225433", "0.660195...
0.7408706
0
Make a copy of the Elongation object.
def copy(self): return self.__class__( self.xs.copy(), self.ys.copy(), self.gauge_length, self.sample_width, self.sample_thickness, self.name )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy(self):\n pass", "def copy(self):\n pass", "def copy(self):\n pass", "def copy(self):", "def __copy__(self):\n return self.copy()", "def clone(self):", "def copy(self):\n return super().copy()", "def copy(self):\n new = self\n return new", "d...
[ "0.7279409", "0.7279409", "0.7279409", "0.7275442", "0.7176021", "0.7167291", "0.70861775", "0.7036117", "0.6934563", "0.68953186", "0.68953186", "0.6894523", "0.68539256", "0.68517977", "0.68517977", "0.68517977", "0.68517977", "0.6851715", "0.68349373", "0.6827231", "0.6825...
0.0
-1
Write Elongation object to file.
def write(self, file_name, style=None): write_elongation(self, file_name, style=style)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self, fname):\n pass", "def to_file(self, outfile):\n\n with open(outfile, \"w\") as outf:\n outf.write(self.to_string())", "def to_file(self, file_io):\n pickle.dump(self.__object, file_io)", "def _toFile(self):\n pass", "def write_to_file_obj(self, dir...
[ "0.6802061", "0.6758464", "0.675378", "0.67382544", "0.66403794", "0.6622912", "0.6622912", "0.64878297", "0.6469059", "0.6464132", "0.6459846", "0.6459846", "0.643951", "0.64394855", "0.64362407", "0.6430054", "0.640776", "0.640776", "0.6386145", "0.636254", "0.63562787", ...
0.629775
23
Determine the max strain and coordinate stress.
def max(self): max_i = np.nanargmax(self.ys) return self.xs[max_i], self.ys[max_i]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getOptimalSolution(self):\n max_index = np.argmax(self.Ws)\n self.Wmax = self.Ws[max_index]\n self.Emax = self.subsets[max_index]\n return (self.Wmax, self.Emax)", "def get_max_temp(self):\n self.max_temp = self.domain[1] * 2", "def compute_max(self):\r\n self.x_ma...
[ "0.6495796", "0.64202225", "0.63209385", "0.6316286", "0.61016685", "0.6059084", "0.5994311", "0.59907156", "0.59859866", "0.59722424", "0.579429", "0.5782969", "0.57759356", "0.5775804", "0.5771878", "0.5771878", "0.5771878", "0.5771878", "0.5771878", "0.5771878", "0.5767426...
0.5477594
76
Generate a smoothed version of the Elongation.
def smoothed(self, box_pts=True): elong = self.copy() elong.ys = smooth_curve(self.ys, box_pts) return elong
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _smooth(self):\n self.te = self._spline(self.rho_in, self.te_in, self.rho)\n self.ne = self._spline(self.rho_in, self.ne_in, self.rho)\n self.ti = self._spline(self.rho_in, self.ti_in, self.rho)\n self.vt = self._spline(self.rho_in, self.vt_in, self.rho)\n for i in range(self...
[ "0.6047224", "0.5958558", "0.5911852", "0.58532757", "0.58519554", "0.5808192", "0.5806572", "0.5766009", "0.57573235", "0.565053", "0.56344795", "0.5537342", "0.55034465", "0.5393578", "0.5387983", "0.538715", "0.53834933", "0.5319106", "0.5317269", "0.5313368", "0.53031206"...
0.6461423
0
Crop the Elongation by xvalue.
def cropped(self, start=None, end=None, shifted=True): start_i, end_i, i = None, None, 0 if start is not None: for i, val in enumerate(self.xs): if val > start: start_i = i break if end is not None: for i, val in enumerate(self.xs[i:], start=i): if val > end: end_i = i + 1 break return self.cropped_index(start_i, end_i, shifted)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def x_nondim(self, x):\n x[0:4] /= self.r_scale\n return x", "def clip(self, x):\n return self.min_value if x<self.min_value else self.max_value if x > self.max_value else x", "def crop(self, coords):\n pass", "def _to_clips_value(cls, x):\n return x", "def crop(X,size_crop...
[ "0.573946", "0.5665958", "0.5590724", "0.54764163", "0.5454353", "0.5426002", "0.53672546", "0.53549814", "0.5343494", "0.5310976", "0.52714664", "0.52611035", "0.52568567", "0.5256345", "0.52544415", "0.5244893", "0.52251136", "0.5216486", "0.52083147", "0.5207739", "0.52072...
0.0
-1
Crop the Elongation by index.
def cropped_index(self, start_i=None, end_i=None, shifted=True): xs = self.xs[start_i:end_i] ys = self.ys[start_i:end_i] if shifted: xs = xs - xs[0] return self.__class__(xs, ys, self.gauge_length, self.sample_width, self.sample_thickness, self.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def crop(self, N):\n self.data = self.data[:,:N]", "def crop(self):\n return np.array([f.crop() for f in self])", "def crop(self, timerange):\n\n begin = self.bisect(timerange.begin())\n end = self.bisect(timerange.end(), begin)\n return self.slice(begin, end)", "def conver...
[ "0.61602694", "0.5879224", "0.5870638", "0.581509", "0.56682354", "0.56376", "0.56352115", "0.5629972", "0.5623761", "0.55894375", "0.5587319", "0.5582777", "0.55521005", "0.5534629", "0.5528097", "0.55064076", "0.5488465", "0.54711306", "0.5463051", "0.54613936", "0.5452928"...
0.60998905
1
Remove the slack at the beginning and postbreak at the end.
def cleaned(self, start_threshold=0.01, end_threshold=0.25, shifted=True): start_i, end_i = None, None max_i = np.nanargmax(self.ys) max_y = self.ys[max_i] if start_threshold is not None: # includes the value before threshold is met for i, y in enumerate(self.ys[1:]): if y > max_y*start_threshold: start_i = i break if end_threshold is not None: for i, y in enumerate(self.ys[max_i:], start=max_i): if y < max_y*end_threshold: end_i = i break return self.cropped_index(start_i, end_i, shifted)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def postprocess(self, segment):\n match = re.search(r\"replace\\s+(.*)$\", segment.text[0])\n if match:\n replaces = self.get_replace_tuples(match.group(1))\n else:\n replaces = None\n match = re.search(r\"kill (.*)\", segment.text[0])\n if match:\n ...
[ "0.58476883", "0.56460965", "0.56165975", "0.560779", "0.544831", "0.5426954", "0.5406294", "0.53741", "0.5362865", "0.5357857", "0.5321594", "0.52899224", "0.523012", "0.52105147", "0.520266", "0.52006954", "0.52006954", "0.5196065", "0.5187309", "0.51801246", "0.5164424", ...
0.0
-1
Determine the Young's modulus of the Elongation. Modulus is calculated as the peak of the derivative of the stress strain curve.
def youngs_modulus(self, x_limit=None): if x_limit is not None: raise NotImplementedError('Limits on x not yet implemented, see youngs_modulus_array().') return max(self.youngs_modulus_array)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def YoungModulus(material):\n if material == \"mild\":\n return 200e9\n else:\n if material == \"al\":\n return 69e9\n else:\n raise ValueError(\"Invalid material `\"+material+\"'\")", "def _calc_young_modulus(dataset: np.ndarray) -> YoungModulus:\n segment_x_l...
[ "0.75485635", "0.74274933", "0.6333822", "0.602804", "0.5853094", "0.58021337", "0.5751449", "0.5742924", "0.56657714", "0.5579836", "0.5565335", "0.55258816", "0.5520236", "0.5520098", "0.5503216", "0.54897547", "0.54739076", "0.54691815", "0.5460389", "0.5448125", "0.542998...
0.6033121
3
Determine the Young's modulus at all points on the Elongation.
def youngs_modulus_array(self): return self.derivative()/self.cross_section # N/ΔL · L₀/A
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _calc_young_modulus(dataset: np.ndarray) -> YoungModulus:\n segment_x_length: int = len(dataset) // 10\n max_derivative_index = np.argmax([\n dataset[i + segment_x_length][1] - dataset[i][1]\n for i in range(len(dataset) - segment_x_length)\n ])\n first_point = dataset[max_derivative_...
[ "0.7059646", "0.6897585", "0.6263803", "0.60188216", "0.59787786", "0.5938402", "0.577813", "0.56868947", "0.566972", "0.5625801", "0.5616607", "0.56156415", "0.5604152", "0.5557132", "0.55388206", "0.551272", "0.5507561", "0.5487953", "0.54699624", "0.54653394", "0.54428107"...
0.5960591
5
Finds the location of peaks in the Elongation. Utilizes scipy.signal.find_peaks and the parameters therein.
def peaks(self, **kwargs): peaks, properties = self.peak_indices(**kwargs) return self.xs[peaks], properties
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def findPeaks(self, fit_peaks_image):\n self.pf_iterations += 1\n \n # Use pre-specified peak locations if available, e.g. bead calibration.\n if self.peak_locations is not None:\n return [self.peak_locations, self.peak_locations_type, True]\n \n # Otherwise...
[ "0.718893", "0.7016462", "0.698052", "0.6924211", "0.69004714", "0.6852957", "0.68114007", "0.6793125", "0.67206746", "0.67030543", "0.66194785", "0.66007024", "0.6594533", "0.657449", "0.6565826", "0.65598375", "0.6540172", "0.6534202", "0.6523988", "0.6502559", "0.64995164"...
0.63839376
29
Finds the location of peaks in the Elongation. Utilizes scipy.signal.find_peaks and the parameters therein.
def peak_indices(self, **kwargs): kwarg_defaults = { 'width': 5, # ensure small spikes are ignored } kwarg_defaults.update(kwargs) return signal.find_peaks(self.ys, **kwarg_defaults)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def findPeaks(self, fit_peaks_image):\n self.pf_iterations += 1\n \n # Use pre-specified peak locations if available, e.g. bead calibration.\n if self.peak_locations is not None:\n return [self.peak_locations, self.peak_locations_type, True]\n \n # Otherwise...
[ "0.71901786", "0.70173657", "0.69808173", "0.6902003", "0.68538964", "0.681282", "0.6794285", "0.6722501", "0.6702924", "0.6620355", "0.6602124", "0.65959084", "0.6575203", "0.6567033", "0.6560493", "0.6540637", "0.6535634", "0.65247184", "0.6502571", "0.65000653", "0.6450707...
0.69242066
3
Determine the strain index of break. Break is defined herein as the last peak in the stress/strain curve.
def break_index(self, **kwargs): return self.peak_indices(**kwargs)[0][-1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getBreakIndices(self):\n for i in self.raw.index[:-1]:\n if self.raw['stress'][i+1] > self.raw['stress'][i] and \\\n self.raw['stress'][i+2] < self.raw['stress'][i+1]:\n brkIdx1 = i+1 # brkIdx1: start of the first unloading\n break\n if...
[ "0.63903123", "0.5647532", "0.5634", "0.54937726", "0.544508", "0.5438141", "0.54027975", "0.53570503", "0.5290587", "0.5280061", "0.5275725", "0.5270513", "0.5268599", "0.52369666", "0.52302957", "0.52163225", "0.5215555", "0.5207446", "0.52039963", "0.51773316", "0.5164221"...
0.6041352
1
Determine the location and force at yield. Yield is defined herein as the first peak in the stress/strain curve.
def yield_index(self, **kwargs): return self.peak_indices(**kwargs)[0][0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_yield(self, t, y):\n return", "def get_force(self):\n # @todo: Probably need to check the state of the landing gear for this (e.g. are they on the track?).\n # Note: you can get the state of the landing gear by going through self.sim \n return 0.0", "def energy_yield(self):\...
[ "0.5626149", "0.5517339", "0.5487714", "0.5388038", "0.5280926", "0.51820517", "0.5138369", "0.513607", "0.5019332", "0.49964803", "0.4984524", "0.49721935", "0.4953098", "0.4916287", "0.4898057", "0.48384228", "0.48028523", "0.4796409", "0.47815487", "0.47543624", "0.475132"...
0.47223315
21
Write Elongation object to file.
def write_elongation(elongation, file_name, style=None): style = file_name.split('.')[-1] if style is None else style if style == 'csv': write_csv(elongation, file_name) elif style == 'prn': raise NotImplementedError() else: raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self, fname):\n pass", "def to_file(self, outfile):\n\n with open(outfile, \"w\") as outf:\n outf.write(self.to_string())", "def to_file(self, file_io):\n pickle.dump(self.__object, file_io)", "def _toFile(self):\n pass", "def write_to_file_obj(self, dir...
[ "0.6802061", "0.6758464", "0.675378", "0.67382544", "0.66403794", "0.6622912", "0.6622912", "0.64878297", "0.6469059", "0.6464132", "0.6459846", "0.6459846", "0.643951", "0.64394855", "0.64362407", "0.6430054", "0.640776", "0.640776", "0.6386145", "0.636254", "0.63562787", ...
0.59036034
67
Write Elongation object to a csv file.
def write_csv(elongation, file_name): e = elongation with open(file_name, 'w') as f: f.write(f"""\ Break Load, {e.break_load()} Break Strength, {e.break_strength()} Break Elongation, {e.break_elongation()} Yield Load, {e.yield_load()} Yield Strength, {e.yield_strength()} Yield Elongation, {e.yield_elongation()} Gauge Length, {e.gauge_length} Sample Width, {e.sample_width} Sample Thickness, {e.sample_thickness} Points %, N""") for x, y in zip(e.xs, e.ys): f.write(f'\n{x:>8.4f}, {y:>8.4f}')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_csv_file(self):\r\n # Create a new csv-file\r\n with open(self.fname, 'w') as f:\r\n writer = csv.writer(f, dialect='excel')\r\n writer.writerow(['set_time',\r\n 'read_time_P_ac',\r\n 'read_time_P_bat',\r\n ...
[ "0.71679187", "0.7032536", "0.70268303", "0.69770074", "0.6973022", "0.693288", "0.6858325", "0.68417126", "0.6832732", "0.68016165", "0.67204237", "0.6718283", "0.671795", "0.67077386", "0.6678489", "0.66233027", "0.6594838", "0.65919703", "0.65797895", "0.6558252", "0.65327...
0.7691217
0
Read an iterable of elongation files.
def read_elongations(file_names): return list(itertools.chain(*(read_elongation(f) for f in file_names)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iter__(self):\r\n example = []\r\n for line in open(self.fullpath):\r\n if line != '\\n':\r\n example.append(line.rstrip()) # remove newline\r\n else:\r\n yield example\r\n example = []", "def read_files(self):\n for f ...
[ "0.6163643", "0.61128104", "0.609269", "0.6008233", "0.59725094", "0.59578764", "0.59578764", "0.59162337", "0.5894706", "0.5822738", "0.58118016", "0.57776636", "0.5761199", "0.5705911", "0.5697656", "0.5660844", "0.56368", "0.5615509", "0.56117857", "0.5606222", "0.5591424"...
0.64478576
0
Read an elongation file.
def read_elongation(file_name): extension = file_name.split('.')[-1] if extension == 'prn': return read_prn(file_name) elif extension == 'csv': return read_csv(file_name) else: raise NotImplementedError(f'Reading {extension} files is not yet implemented.')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_eeg(eeg_file):\r\n pass", "def read_file(self):\n try:\n with open(self.file_name, 'r') as ach_file:\n file_contents = ach_file.read().replace('\\n', '').replace('\\r', '')\n\n self._parse_ach_file(file_contents)\n except FileNotFoundError as err:\n...
[ "0.7496126", "0.644162", "0.6383731", "0.6383731", "0.6325809", "0.62894577", "0.614153", "0.611948", "0.6031712", "0.59734565", "0.59291553", "0.5924931", "0.59140784", "0.5913085", "0.5905164", "0.58807915", "0.58618003", "0.5857386", "0.58544934", "0.58161914", "0.5775309"...
0.6182179
6
Read a prn file.
def read_prn(file_name): with open(file_name) as f: f = MyIter(f) try: assert next(f).strip() == 'prn:13|' assert next(f).strip() == 'subtype = MT2500' assert next(f).strip() == 'Doc={MT2500:14|' assert next(f).strip() == 'Film={12.1|' film_data = {} for line in f: if '}' in line: break key, value = read_key_value(line) film_data[key] = value assert next(f).strip() == 'Test_Info={2|' test_info = {} for line in f: if '}' in line: break key, value = read_key_value(line) test_info[key] = value assert next(f).strip() == 'Test_Data=(' test_data = [] for i, line in enumerate(f): if line.strip() != '{6|': break test_data.append({}) for line in f: if '[' in line: break key, value = read_key_value(line) test_data[i][key] = try_to_num(value) xs, ys = [], [] for line in f: if ']' in line: break x, y = line.split(',') xs.append(x) ys.append(y) test_data[i]['xs'] = np.array(xs, dtype='float') test_data[i]['ys'] = np.array(ys, dtype='float') assert int(test_data[i]['Number_Of_Points']) == len(xs) assert next(f).strip()[0] == '}' # may have a comma assert 'Test_Results=(' == next(f).strip() test_results = [] for i, line in enumerate(f): if line.strip() != '{6|': break test_results.append({}) for line in f: if '}' in line: break key, value = read_key_value(line) test_results[i][key] = try_to_num(value) assert next(f).strip()[0] == '}' # may include comma except AssertionError as e: print(f._index, f._line) raise data_remove = ['Number_Of_Points'] results_swaps = [ ('TestDate', 'date'), ('Length_Cnvrsn', 'length_conversion'), ('Force_Cnvrsn', 'force_conversion'), ('LoadCell_Capacity', 'loadcell_capacity'), ('LoadCell_CpctyUnit', 'loadcell_capacity_unit'), ('LoadCell_BitsOfReso', 'loadcell_bits_of_resolution'), ('Slack_time', 'slack_time'), ('BreakStrength', 'break_strength'), ('BreakElongation', 'break_elongation'), ('BreakPctElongation', 'break_percent_elongation'), ('YieldStrength1', 'yield_strength'), ('YieldLoad1', 'yield_load'), ('SampleThickness', 'thickness'), ('BreakLoad', 'break_load'), ] results_remove = ['Analysis'] data_swaps = [ ('X_unit', 'x_units'), ('Y_unit', 'y_units'), ('Crosshead_speed', 'crosshead_speed'), ('Sample_Thkness', 'sample_thickness'), ('Sample_Width', 'sample_width'), ('Grip_Separation', 'gauge_length'), ('Start_Threshhold', 'start_threshhold'), ('Stop_Threshhold', 'stop_threshhold'), ] elongations = [] assert len(test_data) == len(test_results) for data, results in zip(test_data, test_results): for original, to in data_swaps: data[to] = data.pop(original) for original, to in results_swaps: results[to] = results.pop(original) for key in data_remove: data.pop(key) for key in results_remove: results.pop(key) if data['x_units'] == 'Secs.': data['x_units'] = 's' if data['y_units'] == 'Newtons': data['y_units'] = 'N' if results['date']: results['date'] = datetime.strptime(results['date'], '%d %b, %Y') xs = data['xs']*float(data['crosshead_speed']) elongations.append( Elongation( xs, data['ys'], float(data['gauge_length']) / 1e3, # mm → m float(data['sample_width']) / 1e3, # mm → m float(data['sample_thickness']) / 1e3, # mm → m None ) ) return elongations
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_from_file(self, filename: str) -> None:", "def read(self, filename):\n pass", "def read(self, filename):\n pass", "def read_file(path_to_file):\n 8", "def read(self, filename):\n raise NotImplementedError", "def readFromFile(filename):\n raise NotImplementedError", ...
[ "0.65455025", "0.6430564", "0.6430564", "0.624641", "0.6233345", "0.62033165", "0.61368966", "0.6100024", "0.59324074", "0.5905313", "0.5895797", "0.58900416", "0.58810663", "0.58738136", "0.5845799", "0.5845455", "0.5841567", "0.5840595", "0.5822792", "0.5817336", "0.5806271...
0.5728313
35
Read a csv file.
def read_csv(file_name): data = {} with open(file_name) as f: f = MyIter(f) try: for line in f: if not line.strip(): continue if line == 'Points\n': break key, val = read_key_value(line, separator=',') key = key.lower().replace(' ', '_') data[key] = val x_units, y_units = next(f).split(',') data['x_units'], data['y_units'] = x_units.strip(), y_units.strip() xs, ys = [], [] for line in f: x, y = line.split(',') xs.append(float(x.strip())) ys.append(float(y.strip())) except Exception as e: print(f'Error on line {f._index}') print(f._line) raise e elong = Elongation( np.array(xs), np.array(ys), float(data['gauge_length']), float(data['sample_width']), float(data['sample_thickness']) ) return [elong]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_csv_file(self):\n pass", "def read_csv():", "def loadCSV(input_file):", "def read_csv(csv_file):\r\n with open(csv_file, \"r\") as files:\r\n data = csv.reader(files)\r\n return list(data)", "def read_csv(path, number_of_header_lines=0):\n # if not os.path.isfile(pat...
[ "0.83613193", "0.8282847", "0.77628237", "0.7730202", "0.7710265", "0.769839", "0.768177", "0.76365346", "0.753083", "0.75235194", "0.7501306", "0.7462209", "0.74538755", "0.741859", "0.7387481", "0.737309", "0.7369766", "0.7364989", "0.7337134", "0.73298657", "0.7316357", ...
0.0
-1
Forward fuction of ClsHead class.
def forward(self, x): return self.simple_test(x)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def head(self, *args):\n pass", "def __init__(self, head):\n self.head = head", "def __init__(self, head):\n self.head = head", "def __init__(self, head):\n self.head = head", "def __init__(self, head):\n self.head = head", "def __init__(self, head=None):\r\n self.he...
[ "0.67668414", "0.6452582", "0.6452582", "0.6452582", "0.6452582", "0.643687", "0.62694556", "0.6251108", "0.611663", "0.60741985", "0.6048684", "0.60116285", "0.5931471", "0.5905993", "0.58793", "0.58793", "0.58793", "0.58793", "0.58793", "0.58793", "0.58793", "0.58793", ...
0.0
-1
Forward_train fuction of ClsHead class.
def forward_train(self, cls_score, gt_label): if self._do_squeeze: cls_score = cls_score.unsqueeze(0).squeeze() return super().forward_train(cls_score, gt_label)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward_train(self, *args, **kwargs):\n pass", "def forward_train(self, *args, **kwargs):\n raise NotImplementedError('This interface should not be used in current training schedule. Please use `train_step` for training.')", "def forward_train(self, preds_T: torch.Tensor) -> torch.Tensor:\n ...
[ "0.7940236", "0.7152561", "0.71032774", "0.6996284", "0.6941457", "0.69091916", "0.68456066", "0.6841095", "0.6632498", "0.6481093", "0.64249223", "0.63951194", "0.63951194", "0.63951194", "0.63951194", "0.63951194", "0.6381541", "0.63725805", "0.6367713", "0.6350402", "0.634...
0.58546853
76
Multilayer Perceptron is sensitive to feature scaling, so it is highly recommended to scale your data. For example, scale each attribute on the input vector X to [0, 1] or [1, +1], or standardize it to have mean 0 and variance 1. Note that you must apply the same scaling to the test set for meaningful results.
def scale_data(data_matrix): scaler = StandardScaler() # Don't cheat - fit only on training data scaler.fit(data_matrix) X_train = scaler.transform(data_matrix) return X_train
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train_perceptron(train_exs: List[SentimentExample], feat_extractor: FeatureExtractor) -> PerceptronClassifier:\n raise Exception(\"Must be implemented\")", "def train_perceptron(train_exs: List[SentimentExample], feat_extractor: FeatureExtractor) -> PerceptronClassifier:\n raise Exception(\"Must be imp...
[ "0.66160285", "0.66160285", "0.6479322", "0.6373529", "0.6332721", "0.6278016", "0.62647", "0.62536883", "0.6185974", "0.6184712", "0.6036722", "0.6031992", "0.5954827", "0.5831484", "0.5821886", "0.58213013", "0.57672703", "0.57202554", "0.5689846", "0.5683262", "0.5657926",...
0.5182711
84