query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Initialises and plots figure.
def __init__(self, dat, frame, box_size, centre, label=False, **kwargs): super().__init__(dat, frame, box_size, centre) # initialise superclass self.label = label # write labels self.draw()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _setup_plot(x: float, y: float) -> plt.figure:\n LOG.debug(\"Initializing plot.\")\n plt.ion()\n fig = plt.figure(figsize=(x, y), num=\"GlacierFlowModel\")\n fig.patch.set_facecolor(\"black\")\n return fig", "def init_plot(self):\n self.dpi = 100\n self.fig = ...
[ "0.8165424", "0.80349463", "0.7848055", "0.78003544", "0.7565268", "0.7397783", "0.73798895", "0.73665226", "0.7346693", "0.7346693", "0.72906274", "0.7215201", "0.7176519", "0.7152798", "0.7118978", "0.711853", "0.70984125", "0.70891875", "0.7084235", "0.7079322", "0.7056446...
0.0
-1
Return a data frame of the national data from DB
def get_national_data(): cursor = nat_data_coll.find({}) df = pd.DataFrame(list(cursor)) if df.empty: app.logger.error("While getting national data: no data") return df
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_training_data(db_conn):\n return pd.read_sql('''select * from churn_model.churn_data;''', db_conn)", "def get_data_from_db(district):\n data_frames = get_athena_dataframes()\n df_result = copy.copy(data_frames['new_covid_case_summary'])\n df_result = df_result[df_result['district'] == distric...
[ "0.6886437", "0.68392974", "0.65418774", "0.6428618", "0.64219284", "0.63483167", "0.6343392", "0.63210285", "0.6295442", "0.62778383", "0.6276814", "0.6259273", "0.6251587", "0.62510675", "0.6220884", "0.61942714", "0.6188152", "0.616154", "0.61417145", "0.61352104", "0.6128...
0.81864965
0
Return the lastest update dt
def get_latest_vax_update(): try: response = requests.get(URL_VAX_LATEST_UPDATE).json() datestr = response[VAX_LATEST_UPDATE_KEY] date_dt = dt.datetime.strptime(datestr, VAX_DATE_FMT) latest_update = format_datetime(datetime=date_dt, format='short') except Exception as e: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dt_last_update(self):\n return self.last_update", "def last_updated(self):\n try:\n return max(self.station_usage, key=lambda x: x.last_update).dt_last_update\n except ValueError:\n return datetime.fromtimestamp(0)", "def get_max_update_dt():\r\n from .utils impo...
[ "0.8446951", "0.7976908", "0.78584146", "0.77756345", "0.77756345", "0.7673669", "0.7602683", "0.7531638", "0.7518687", "0.7509574", "0.74276304", "0.74276304", "0.7343766", "0.73329526", "0.73329526", "0.72906864", "0.71832895", "0.7171193", "0.7168959", "0.71663624", "0.716...
0.6561779
55
Return age series data
def get_age_chart_data(area=None): chart_data = {} vax_group = { '$group': { '_id': { VAX_AGE_KEY: f'${VAX_AGE_KEY}', VAX_AREA_KEY: f'${VAX_AREA_KEY}' }, f'{VAX_FIRST_DOSE_KEY}': {'$sum': f'${VAX_FIRST_DOSE_KEY}'}, f'{VAX_SE...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_age_arr(self,renew=False):\n\t\tdset = dispDBase.dispASDF(self.attrs['age_h5'])\n\t\tminlat = self.attrs['minlat']\n\t\tmaxlat = self.attrs['maxlat']\n\t\tminlon = self.attrs['minlon']\n\t\tmaxlon = self.attrs['maxlon']\n\t\tdset.set_poly(self.poly_lst,minlon,minlat,maxlon,maxlat)\n\t\tdset.read_age_mdl()\...
[ "0.64114213", "0.618613", "0.616429", "0.61433864", "0.6130676", "0.6123146", "0.61175466", "0.6096876", "0.60724354", "0.60158587", "0.60004425", "0.5989038", "0.59494954", "0.59395665", "0.59190667", "0.5887153", "0.5885844", "0.5885844", "0.58516365", "0.58385915", "0.5820...
0.5762611
24
Perform a binary replacement of `data`, where the placeholder `a` is replaced with `b` and the remaining string is padded with null characters. All input arguments are expected to be bytes objects.
def binary_replace(data, a, b): def replace(match): occurances = match.group().count(a) padding = (len(a) - len(b)) * occurances if padding < 0: raise PaddingError(a, b, padding) return match.group().replace(a, b) + b'\0' * padding pat = re.compile(re.escape(a) + b'(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pad(data):\r\n bytes_to_pad = AES.block_size - len(data) % AES.block_size\r\n return data + (bytes_to_pad * chr(bytes_to_pad))", "def bytes_replace(byte_str, start_idx, stop_idx, replacement):\n return byte_str[:start_idx] + replacement + byte_str[stop_idx:]", "def _encode_2xbase64pad(data: str) -...
[ "0.5869874", "0.5849949", "0.5737761", "0.57068115", "0.56833", "0.5596595", "0.5591158", "0.5551726", "0.55198526", "0.5502848", "0.54943526", "0.547476", "0.54689944", "0.5462715", "0.54509956", "0.5445963", "0.54321665", "0.54192936", "0.5399902", "0.5396519", "0.53488976"...
0.8314301
0
Check and convert `site_offsets` init argument.
def _clean_site_offsets(site_offsets, atoms_coord, basis_vectors): if atoms_coord is not None and site_offsets is not None: raise ValueError( "atoms_coord is deprecated and replaced by site_offsets, " "so both cannot be specified at the same time." ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def site_offsets(self):\n return self._site_offsets", "def tz_elev_check(sam_sys_inputs, site_sys_inputs, meta):\n\n if meta is not None:\n if sam_sys_inputs is not None:\n if 'elevation' in sam_sys_inputs:\n meta['elevation'] = sam_sys_inputs['elevation...
[ "0.5653634", "0.53476065", "0.45936745", "0.4576884", "0.45762986", "0.45543274", "0.4521744", "0.45160174", "0.45101506", "0.44517305", "0.4442139", "0.44192183", "0.44152343", "0.4373471", "0.43726715", "0.43548915", "0.4345398", "0.4316795", "0.4276277", "0.42429334", "0.4...
0.73232734
0
Basis vectors of the lattice
def basis_vectors(self): return self._basis_vectors
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getBasis(self) -> 'matrix':\n return array(list(BernBasis(self.domain, self.n, idx) for idx in range(self.n + 1)))", "def basis_coords(self) -> CoordT:\n return self._basis_coords", "def basis(self) -> List['MultiVector']:\n if not self.isBlade():\n raise ValueError(\"self...
[ "0.6884664", "0.6670687", "0.6502387", "0.628976", "0.6271342", "0.6264069", "0.6183431", "0.61664057", "0.6091154", "0.6021911", "0.60020655", "0.60016984", "0.5977769", "0.59710395", "0.59359485", "0.5921588", "0.58593", "0.5837047", "0.57807696", "0.57796866", "0.5772684",...
0.7609373
0
Array of bools such that `pbc[d]` indicates whether dimension d has periodic boundaries.
def pbc(self): return self._pbc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_pbc(self):\n s = \" - using 2D periodic boundaries -\"\n print_text(s, cls=self)\n\n xmin = MPI.min(mpi_comm_world(), self.mesh.coordinates()[:,0].min())\n xmax = MPI.max(mpi_comm_world(), self.mesh.coordinates()[:,0].max())\n ymin = MPI.min(mpi_comm_world(), self.mesh.coordinates()[...
[ "0.58790064", "0.58369774", "0.5674652", "0.5664401", "0.56558657", "0.559547", "0.54852986", "0.54446566", "0.541548", "0.53274745", "0.52814186", "0.52750707", "0.52554464", "0.52425224", "0.5239316", "0.52116627", "0.51781845", "0.514822", "0.5139264", "0.51081055", "0.510...
0.0
-1
Return the id for a site at the given basis coordinates. When passed a rank2 array where each row is a coordinate vector, returns an array of the corresponding ids. Throws an `InvalidSiteError` if any of the coords do not correspond to a site.
def id_from_basis_coords(self, basis_coords: CoordT) -> Union[int, Array]: key = _np.asarray(basis_coords) return self._get_id_from_dict(self._basis_coord_to_site, key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def site_indexes_to_coords(results, site_coords):\n coords = []\n for i in range(0,len(results)):\n cursites = results[i]['coveringsites']\n if len(cursites) > 0: #clean out empty end stages\n tmpcoords = []\n for ind in cursites:\n tmpcoords.append(site_coo...
[ "0.5391141", "0.52724075", "0.52389765", "0.5192579", "0.5048827", "0.50342643", "0.5015809", "0.49250597", "0.49026462", "0.48445013", "0.48388156", "0.479459", "0.47827926", "0.4778414", "0.47684547", "0.47463205", "0.4727981", "0.47188333", "0.46985224", "0.4698169", "0.46...
0.74172574
0
Create a stub post, if a post with the correct identifier does not exist
def get_or_new_post(m, wp, doc): post = find_post(wp, doc.identifier) if post: action = lambda post: EditPost(post.id, post) else: prt(f"Creating new post; could not find identifier '{doc.identifier}' ") action = lambda post: NewPost(post) post = WordPressPost() set_cu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_api_can_create_a_post(self):\n self.assertEqual(self.response.status_code, status.HTTP_201_CREATED)", "def test_new_post(api_client):\n json = {\n \"id\": 101,\n \"title\": \"foo\",\n \"body\": \"bar\",\n \"userId\": 1\n }\n r = api_client.post(path=f\"/posts/...
[ "0.6802805", "0.6736859", "0.6693078", "0.65548867", "0.65287054", "0.64742184", "0.6473444", "0.6459562", "0.64013517", "0.6393187", "0.63754255", "0.63508445", "0.6340396", "0.6334573", "0.6283092", "0.6277655", "0.62738675", "0.62559503", "0.62327397", "0.6227199", "0.6197...
0.5880782
38
Returns the transport associated with the event, or null if none is associated with it.
def transport(self): return self._transport
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transport(self) -> Optional[pulumi.Input['TransportArgs']]:\n return pulumi.get(self, \"transport\")", "def transport(self) -> pulumi.Output['outputs.TransportResponse']:\n return pulumi.get(self, \"transport\")", "def get_transport(self, flags):\n flags &= ~(ChannelCaps.BROADCAST)\n ...
[ "0.7113056", "0.6461195", "0.6440732", "0.619373", "0.5872184", "0.58541936", "0.5811868", "0.5694498", "0.55785733", "0.5536447", "0.55221313", "0.5511284", "0.54775083", "0.54313666", "0.54306674", "0.5427474", "0.5425727", "0.5395104", "0.5395104", "0.53844386", "0.5381913...
0.6583517
1
Returns the sender link associated with the event, or null if none is associated with it. This is essentially an alias for link(), that does an additional check on the type of the link.
def sender(self): l = self.link if l and l.is_sender: return l else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sender(self):\n key, alt = ('Sender', 'From') if not self.resent else \\\n ('Resent-Sender', 'Resent-From')\n value = self.get(key) or self.get(alt)\n _, addr = getaddresses([value])[0]\n return addr", "def sender(self) -> Address:\n return self._sender", ...
[ "0.5926456", "0.5907537", "0.5778467", "0.5668911", "0.56163144", "0.55737144", "0.5532229", "0.5525576", "0.54612625", "0.54320294", "0.54320294", "0.54201865", "0.54201865", "0.54201865", "0.5361323", "0.5342368", "0.53402346", "0.5330421", "0.5330421", "0.53029555", "0.530...
0.7997179
0
Check we can retrieve a unique list of projects
def test_get_projects(self): for project in ['TEST', 'NEWTEST', 'MYPROJECT']: self.db.insert_single_result(generate_mock_result(project=project)) projects = self.db.get_projects() self.assertItemsEqual(['MYPROJECT', 'NEWTEST', 'TEST'], projects)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_project_list_with_projects(self):\n # Add two test projects.\n projects = [\n add_project(title='1', description='1'),\n add_project(title='2', description='2'),\n ]\n\n result = get_project_list()\n result_projects = result['projects'].object_l...
[ "0.7332803", "0.7310287", "0.72395116", "0.7219439", "0.7137291", "0.7137291", "0.705742", "0.69817793", "0.6796832", "0.6774688", "0.6737229", "0.6720519", "0.67000616", "0.66912615", "0.6656339", "0.6624325", "0.65918165", "0.6584042", "0.64911824", "0.6480834", "0.6460082"...
0.73381776
0
Add an edge between nodes. Deprecated. By default, map to a positional parameter of the child.
def add_edge(self, parent_name, child_name, param_name=None): if param_name is None: param_name = len(self.get_parents(child_name)) if not isinstance(param_name, (int, str)): raise ValueError('Unrecognized type for `param_name` {}. Must be either an ' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_edge(self, parent, child):\n self.add_edge( Edge(parent,child) )", "def add_edge(self, position):\n raise NotImplementedError()", "def add_edge(self, v1, v2):\n pass # TODO", "def add_edge(self, parent, child):\r\n log.debug('add_edge({}, {})'.format(parent, child))\r\n ...
[ "0.75431025", "0.7463236", "0.7413803", "0.734758", "0.70870316", "0.70541734", "0.6981928", "0.69372463", "0.69370043", "0.69139636", "0.69087076", "0.6885734", "0.6860861", "0.68601066", "0.6859478", "0.685888", "0.6795263", "0.67912936", "0.6781493", "0.67543393", "0.67510...
0.67257106
22
Return a list of nodes.
def nodes(self): return self.source_net.nodes()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_node_list(self):\n return []", "def get_node_list(self):\n return [[node] for node in self.graph.nodes]", "def nodes(self): \n return [n for n in self.iternodes()]", "def get_nodes(self) -> List[Node]:\n\t\treturn sorted(self.nodes, key=lambda x: x.name.lower())", "def list_nod...
[ "0.85231763", "0.8507924", "0.8333512", "0.83014715", "0.8279748", "0.826221", "0.82186586", "0.82186586", "0.8093327", "0.8047809", "0.80355066", "0.8034427", "0.802992", "0.8018956", "0.8017733", "0.8017733", "0.8017733", "0.8016068", "0.80014855", "0.79752815", "0.79532367...
0.73179907
60
Return a copy of the graph.
def copy(self): kopy = self.__class__() # Copy the source net kopy.source_net = nx.DiGraph(self.source_net) return kopy
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_copy_of_graph(self):\r\n return deepcopy(self)", "def get_graph(self):\n return copy.deepcopy(self.graph)", "def copy_graph(g):\n return copy.deepcopy(g)", "def duplicate(self):\n\t\treturn Graph(self.vertices[:], self.edges[:])", "def clone(self):\n cloned = Graph()\n ...
[ "0.91283524", "0.87397766", "0.8628676", "0.83492124", "0.8310748", "0.82642657", "0.8087248", "0.8075825", "0.802742", "0.8003448", "0.79457957", "0.7888639", "0.7887874", "0.78454834", "0.764223", "0.7562911", "0.7439816", "0.74277425", "0.7425305", "0.7334041", "0.7325527"...
0.74153745
19
Return a copy of the graph.
def __copy__(self, *args, **kwargs): return self.copy()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_copy_of_graph(self):\r\n return deepcopy(self)", "def get_graph(self):\n return copy.deepcopy(self.graph)", "def copy_graph(g):\n return copy.deepcopy(g)", "def duplicate(self):\n\t\treturn Graph(self.vertices[:], self.edges[:])", "def clone(self):\n cloned = Graph()\n ...
[ "0.91283524", "0.87397766", "0.8628676", "0.83492124", "0.8310748", "0.82642657", "0.8087248", "0.8075825", "0.802742", "0.8003448", "0.79457957", "0.7888639", "0.7887874", "0.78454834", "0.764223", "0.7562911", "0.7439816", "0.74277425", "0.7425305", "0.74153745", "0.7334041...
0.0
-1
Return a random color as c4d.Vector
def get_random_color(): def get_random_value(): """ Return a random value between 0.0 and 1.0 """ return randint(0, 255) / 256.0 return Vector(get_random_value(), get_random_value(), get_random_value())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def randcolor():\r\n r = random(0.0, 1.0)\r\n g = random(0.0, 1.0)\r\n b = random(0.0, 1.0)\r\n return vec(r, g, b) # A color is a three-element vec\r", "def get_random_color():\n\n def get_random_value():\n \"\"\" Return a random value between 0.0 and 1.0 \"\"\"\n return randi...
[ "0.83026356", "0.81792206", "0.7439888", "0.7107803", "0.70549285", "0.7053493", "0.70376676", "0.7015442", "0.69945", "0.69569045", "0.6873321", "0.6841347", "0.6841197", "0.6791249", "0.6758189", "0.67249537", "0.6690875", "0.65709573", "0.65383506", "0.65089667", "0.636048...
0.8255743
1
Assembles a matrix corresponding to the weights of in the finite difference computation of derivatives, i.e. assembles the weight matrix W, giving the difference matrix d
def assemble_finite_difference_weight_matrix(zN, N, FD_schemes ): imax = zN - 1 Wz = np.zeros([N, zN, zN]) # includes zeroeth order derivative container (not used) # i.e. Wz...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _adj(w):\r\n return (w[:d * d] - w[d * d:]).reshape([d, d])", "def d_dweight(self, ):\n return self.gen_df_dw(self.params, self.output_shape)(self.current_input)", "def derivativeW(self, w, x, y, z):\n wa = np.asarray(w)\n xa = np.asarray(x)\n ya = np.asarray(y)\n ...
[ "0.6822254", "0.65278727", "0.64393884", "0.641949", "0.6382295", "0.62855864", "0.61403316", "0.6075786", "0.6074896", "0.5997027", "0.591983", "0.5916137", "0.5913973", "0.5903878", "0.5892924", "0.5862172", "0.58556783", "0.58556783", "0.5844465", "0.58414865", "0.58125484...
0.6332932
5
Assembles a matrix corresponding to the weights of in the finite difference computation of derivatives, i.e. assembles the weight matrix W, giving the difference matrix d
def assemble_finite_difference_weight_matrix_const_dn_const_LTE(zN, FD_scheme_const_dn, dn = 1, LTE = 6 ): imax = zN - 1 W_dn_LTE = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _adj(w):\r\n return (w[:d * d] - w[d * d:]).reshape([d, d])", "def d_dweight(self, ):\n return self.gen_df_dw(self.params, self.output_shape)(self.current_input)", "def derivativeW(self, w, x, y, z):\n wa = np.asarray(w)\n xa = np.asarray(x)\n ya = np.asarray(y)\n ...
[ "0.68232304", "0.6529865", "0.64405715", "0.6419605", "0.6383439", "0.6332138", "0.6332138", "0.6285765", "0.6140332", "0.6077071", "0.60757023", "0.5996077", "0.5919566", "0.5915475", "0.5913692", "0.5903766", "0.5893145", "0.5863132", "0.5844487", "0.5840893", "0.58129954",...
0.5855871
18
Discard matches below `min_score`, sort on (score, match_name_type) descending, and select top `nmax`.
def sorted_matches(name_matches: Set[NameMatch], nmax: int = None, min_score: float = None) \ -> List[NameMatch]: if not name_matches: return [] name_matches = list(name_matches) match_scores = np.asarray([nm.key_length for nm in name_matches]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def top_matches(prefs, person, n=5, similarity=sim_pearson):\n scores = [(similarity(prefs, person, other), other)\n for other in prefs if other != person]\n\n scores.sort()\n scores.reverse()\n return scores[0:n]", "def get_top_n_motif_scores(score_list,top_n):\r\n\treturn score_list.ar...
[ "0.5883284", "0.58706653", "0.58542955", "0.5768085", "0.5740543", "0.5625058", "0.5564037", "0.55411166", "0.55157804", "0.54998666", "0.5466702", "0.5457045", "0.5438906", "0.54326135", "0.54303557", "0.5416156", "0.540828", "0.5363973", "0.5356563", "0.53549236", "0.535325...
0.73927987
0
Returns a gaussian function with the given parameters
def gaussian(height, center_x, center_y, width_x, width_y): width_x = float(width_x) width_y = float(width_y) return lambda x,y: height*np.exp( -(((center_x-x)/width_x)**2+((center_y-y)/width_y)**2)/2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gaussian(x, *parameters):\n position, sigma, amplitude, background = parameters\n return amplitude * np.exp(-(x - position)**2 / (2.0 * sigma**2)) + background", "def gaussian(pars, x):\n A, b, mu, sigma = pars\n # return b + A/(np.sqrt(2*np.pi)*sigma**2) \\\n return b + A \\\n * np.exp...
[ "0.7936006", "0.78110605", "0.7589353", "0.749031", "0.74657845", "0.7387422", "0.73763347", "0.7243705", "0.7227015", "0.72231114", "0.713038", "0.7127564", "0.7118518", "0.70896465", "0.7083726", "0.70708406", "0.70604295", "0.70323956", "0.70142984", "0.69931597", "0.69804...
0.7267818
9
Look from position (x,y) in the direction defined by (dx,dy). Return True if the first chair in sight is occupied. Return False if the first chair is empty, or no chairs are visible in this direction.
def see_occupant(self, x, y, dx, dy): if dx == 0 and dy == 0: # Makes looping easier return False x += dx y += dy while 0 <= x < self.width and 0 <= y < self.height: if self.grid[y][x] == '#': return True if self.grid[y][x] ==...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isLineAt(self, x, y, dx, dy):\n\n initialValue = self.board[x][y]\n #checks a cell to see if there is a piece there\n if initialValue != 0:\n #loops though 3 times in a certain direction to see\n #if there is a winning configuration\n for i in range(3):\n ...
[ "0.60788995", "0.5822892", "0.5587551", "0.556409", "0.54469025", "0.5383648", "0.53429055", "0.5207643", "0.52026254", "0.51429045", "0.51328987", "0.5130302", "0.5126825", "0.5033044", "0.50291485", "0.50119525", "0.4987362", "0.49185446", "0.49041864", "0.48995894", "0.489...
0.6520595
0
Convert a list of bool to a single value
def to_number(bool_list): return sum((n << j) for (j, n) in enumerate(bool_list))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __convert_boolean_list(boolean_list):\n return ['0' if b else '1' for b in boolean_list]", "def boollist(lst):\n return (', '.join(map(lambda x: str(bool(x)), lst))).lower()", "def convertToBooleanArray(booleanArray: typing.List[bool]) -> typing.List[bool]:\n ...", "def bool_to_python(se...
[ "0.7855491", "0.7108884", "0.6946556", "0.6858573", "0.67675644", "0.6728061", "0.6686547", "0.66590184", "0.66462404", "0.6633411", "0.65395117", "0.653932", "0.65049887", "0.6457218", "0.6426625", "0.640753", "0.639419", "0.6383443", "0.6378258", "0.6374054", "0.63717806", ...
0.63047886
23
Converts a 2D numpy to ctypes 2D array.
def double2ArrayToPointer(arr): # Init needed data types ARR_DIMX = DOUBLE * arr.shape[1] ARR_DIMY = PDOUBLE * arr.shape[0] # Init pointer arr_ptr = ARR_DIMY() # Fill the 2D ctypes array with values for i, row in enumerate(arr): arr_ptr[i] = ARR_DIMX() for j, val in enume...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cpointer_to_ndarray(ptr, size, dtype, shape):\n buf = np.core.multiarray.int_asbuffer(\n ctypes.addressof(ptr.contents), np.dtype(dtype).itemsize * size)\n arr = np.ndarray(shape, dtype=dtype, buffer=buf)\n return arr", "def ctypes2numpy(cptr, length, dtype=numpy.float32):\n #assert isinst...
[ "0.71070045", "0.6746391", "0.6664525", "0.6608782", "0.65839666", "0.642262", "0.6410514", "0.6390241", "0.61955816", "0.61464095", "0.61131567", "0.61083305", "0.6078876", "0.6078432", "0.6060988", "0.60061264", "0.5995612", "0.59630895", "0.594945", "0.59213054", "0.590544...
0.73640525
0
Like coerce(), but sort beforehand
def pretty(self, c): sorted_c = c[:] sorted_c.sort() return self.coerce(sorted_c)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def custom_sort(arr):\n pass", "def listas(a):\r\n\ta = set(a)\r\n\ta = list(a)\r\n\ta.sort()\r\n\treturn a", "def sorted(x) -> List:\n pass", "def smart_sort_helper(version):\n def _safe_cast_to_int(obj):\n try:\n return int(obj)\n except ValueError:\n return obj\n...
[ "0.5767407", "0.57485425", "0.5675997", "0.5675378", "0.55743676", "0.5559211", "0.5556941", "0.5537403", "0.5528478", "0.5526936", "0.5525594", "0.55214083", "0.54564404", "0.5414938", "0.540281", "0.5388932", "0.5382493", "0.5371694", "0.5358036", "0.5346869", "0.5343559", ...
0.5445273
13
Generates the apparent magnitude given the absolute magnitude, obtained from the "box", and the distance modulus and Kcorrection.
def calc_magnitude(box,octant): # Read the Mi(z=2) magnitudes for the box. miz2 = FH.read_file(box)['Miz2'][:] # Read the index for each QSO in the octant, and get the Mi(z=2). data = FH.read_file(octant) zz = data['Z'] dmod = data['DMOD'] miz2 = miz2[data['INDX']] # Now convert to app...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_apparent_magnitude(self, k_correction):\n app_mag = k_correction.apparent_magnitude(self.get(\"abs_mag\"),\n self.get(\"zcos\"), self.get(\"col\"))\n self.add(\"app_mag\", app_mag)", "def calc_mag(self):\n mag = np.sum(self.box)\n return...
[ "0.7153759", "0.59057885", "0.58869356", "0.58586174", "0.57724667", "0.56967825", "0.56420904", "0.56206065", "0.56028056", "0.55499846", "0.5531777", "0.54926676", "0.5463174", "0.54548866", "0.543441", "0.54181653", "0.539727", "0.5391811", "0.5351055", "0.5321673", "0.527...
0.7302161
0
Add access settings to a particular catalog.
def add_catalog_access_settings(self, catalog_name, access_settings_list=None): catalog_resource = self.get_catalog(name=catalog_name) acl = Acl(self.client, catalog_resource) return acl.add_access_settings(access_settings_list)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_catalog_access_control_settings(self, catalog_name): # NOQA\n catalog_resource = self.get_catalog(name=catalog_name)\n access_control_settings = self.client.get_linked_resource(\n catalog_resource, RelationType.DOWN,\n EntityType.CONTROL_ACCESS_PARAMS.value)\n re...
[ "0.6200109", "0.57195157", "0.5661263", "0.5465355", "0.532896", "0.53126085", "0.52985173", "0.52795595", "0.52358484", "0.5233088", "0.51438046", "0.50811875", "0.50405604", "0.50044286", "0.49678737", "0.49398255", "0.49036318", "0.48997602", "0.48858935", "0.488316", "0.4...
0.8109954
0
Given an input n, returns a blur box for use in the Blurred Image function
def make_matrix(n): #number that makes up the matrix depending on value of n num = 1/n**2 #creates a blur box as a dictionary blur_box = {'height': n, 'width': n, 'pixels': [num]*n**2 } return blur_box
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blurred(image, n):\n #access the relvant blur box and then correlates with new image\n blur_box = make_matrix(n)\n new_image = correlate(image, blur_box)\n return round_and_clip_image(new_image)", "def get_blur_kernel(n):\n return [1/n**2] * n**2", "def blur_image(im, n, ny=None) :\n g = ...
[ "0.82010895", "0.7980327", "0.75081325", "0.6806305", "0.6806305", "0.6752011", "0.6747158", "0.67161787", "0.66547805", "0.6617956", "0.6592397", "0.6580389", "0.6520559", "0.64896345", "0.637956", "0.6253989", "0.6160278", "0.6149496", "0.6134034", "0.61317945", "0.6063957"...
0.6473981
14
Return a new image representing the result of applying a box blur (with kernel size n) to the given input image. This process should not mutate the input image; rather, it should create a separate structure to represent the output.
def blurred(image, n): #access the relvant blur box and then correlates with new image blur_box = make_matrix(n) new_image = correlate(image, blur_box) return round_and_clip_image(new_image)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def box_blur(img: np.ndarray, kernel_size: int = 3):\n imgtype = img.dtype\n h,w,c = img.shape\n\n #Get a valid kernel size\n kernel_size = valid_kernel(h,w,kernel_size)\n \n #Box Filter Blur \n blurred = cv2.boxFilter(img,-1,(kernel_size,kernel_size))\n\n return blurred.astype(imgtype)", ...
[ "0.76910836", "0.75478095", "0.75478095", "0.73857564", "0.73681253", "0.7362225", "0.71233815", "0.70079935", "0.68240386", "0.6781728", "0.676984", "0.66808856", "0.6679911", "0.66526335", "0.6623625", "0.6614473", "0.65793705", "0.6482541", "0.6437887", "0.6435246", "0.630...
0.7499072
3
Impletments a filter which detects the edges of an image with the Sobel Operator. Does not modify the input image; rather, it returns a new image.
def edges(image): #store image width and height and initialize new image image_width = image['width'] image_height = image['height'] new_image = {'height': image['height'], 'width': image['width'], 'pixels': len(image['pixels'])*[0]} #sobel operator kernels kernel_x = {'height': 3, 'width':...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enhance_edges(image):\n working_image = image.copy()\n working_image = cv2.cvtColor(working_image, cv2.COLOR_BGR2GRAY)\n # Blur away fine details.\n working_image = cv2.GaussianBlur(working_image, (5, 5), 0)\n return working_image", "def Sobel(img):\n # use cv2.sobel() function to detect ed...
[ "0.67897797", "0.660491", "0.64391863", "0.6432953", "0.6343295", "0.626602", "0.61910576", "0.61701506", "0.609278", "0.60581076", "0.58708286", "0.5818929", "0.5808175", "0.57913136", "0.5790745", "0.5778436", "0.57703227", "0.5761067", "0.5751927", "0.5742951", "0.5656635"...
0.73230726
0
Return True is the queue is empty, False otherwise DO NOT CHANGE THIS METHOD IN ANY WAY
def is_empty(self) -> bool: return self.da.is_empty()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_empty(self):\n return self.queue == []", "def empty(self) -> bool: \n if(self.queue is not None and len(self.queue) > 0):\n print(\"len > 0\" )\n return False\n else:\n print(\"len = 0\" )\n return True", "def empty(self):\r\n retur...
[ "0.90910554", "0.9083377", "0.9009696", "0.9003945", "0.8962284", "0.8946012", "0.8946012", "0.8927383", "0.89148104", "0.8890049", "0.8854263", "0.88234407", "0.8774281", "0.8774281", "0.8748472", "0.8739179", "0.87071687", "0.8691504", "0.86670285", "0.85889953", "0.8561825...
0.0
-1
Produces a mapping between ontology term IDs and a list of other IDs which include the key ID and all the IDs of every ontology term that that term is a subclass of. This means that this can be used to obtain the explicity list of terms that a single term has the "isa" or "partof" relationship to, for example, in order...
def _get_inherited_dict(self): subclass_dict = {} for term in self.terms(): subclass_dict[term.id] = [t.id for t in self[term.id].superclasses(with_self=True)] return(subclass_dict)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_equivalent_objective_id_terms(self):\n return # osid.search.terms.IdTerm", "def get_objective_id_terms(self):\n return # osid.search.terms.IdTerm", "def get_objective_id_terms(self):\n return # osid.search.terms.IdTerm", "def get_objective_id_terms(self):\n return # os...
[ "0.6793444", "0.6553513", "0.6553513", "0.6553513", "0.6542288", "0.652891", "0.63730437", "0.62459666", "0.6094188", "0.60905963", "0.60905963", "0.6090336", "0.6073338", "0.6039588", "0.5986151", "0.5981637", "0.59762853", "0.59762853", "0.595897", "0.5865504", "0.5854817",...
0.62317055
8
Create a dictionary of the depths of each term in the ontology. This is used in calculating the graphbased information content of each term. This value is not the same as the number of recursive parents for a given term, because a single term can have two or more parents in a DAG. In other words, multiple paths can exi...
def _get_term_depth_dictionary(self): # Find the root term(s) of the ontology. root_term_ids = [] for term in self.terms(): # Check if this term has no inherited terms (is a root), discounting terms that are obsolete. inherited_terms = [t for t in term.superclasses(with_self=False)] if (len(inherited_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_depths(self):\n graph = self._graph\n depth_cache = dict()\n\n for n in graph.topological_iter():\n preds = graph.predecessors(n)\n if not preds:\n depth_cache[n.op.key] = 0\n else:\n depth_cache[n.op.key] = 1 + max(depth_...
[ "0.6773493", "0.67210656", "0.64212126", "0.6402159", "0.62709516", "0.60107076", "0.5971531", "0.5907933", "0.5787346", "0.5741427", "0.5737693", "0.57322115", "0.5727437", "0.5693506", "0.56920993", "0.5669622", "0.5666358", "0.5666358", "0.5635992", "0.5609989", "0.5606822...
0.8296504
0
This function tests that if the user can successfully update a ticket's information using the update form
def test_ticketSuccess(self, *_): # open logout page self.open(base_url + '/logout') # open login page self.open(base_url + '/login') # fill email and password self.type("#email", test_user.email) self.type("#password", test_user.password) # click enter bu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_user_update_request(self):\n pass", "def test_update(self):\n self.client.force_authenticate(user=self.admin)\n\n data = {\n 'retreat': reverse(\n 'retreat:retreat-detail', args=[self.retreat.id]\n ),\n 'user': reverse('user-detail', a...
[ "0.6843329", "0.68161744", "0.67473364", "0.66146576", "0.6594605", "0.65748537", "0.6572917", "0.6566418", "0.65478927", "0.6547371", "0.6525273", "0.6521285", "0.6505501", "0.6477165", "0.64549017", "0.6449349", "0.6444416", "0.64331156", "0.6431134", "0.64195704", "0.64143...
0.7620536
0
Yield successive nsized chunks from lst.
def chunks(lst, n): for i in range(0, len(lst), n): yield lst[i:i + n]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chunks(self, lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]", "def chunks(lst: list, n: int):\n for i in range(0, len(lst), n):\n yield lst[i : i + n]", "def chunks(lst, n):\n for i in range(0, len(lst), n):\n yield lst[i : i + n]", "...
[ "0.83071756", "0.81939614", "0.8190213", "0.81267184", "0.81218547", "0.81218547", "0.80773693", "0.80533457", "0.80533457", "0.80533457", "0.80533457", "0.80533457", "0.80533457", "0.80533457", "0.80533457", "0.80533457", "0.80533457", "0.80533457", "0.80533457", "0.80533457",...
0.81910837
2
Yield successive nsized chunks from lst.
def chunks(lst, n): for i in range(0, len(lst), n): yield lst[i:i + n]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chunks(self, lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]", "def chunks(lst: list, n: int):\n for i in range(0, len(lst), n):\n yield lst[i : i + n]", "def chunks(lst, n):\n for i in range(0, len(lst), n):\n yield lst[i : i + n]", "...
[ "0.8307071", "0.8193703", "0.81899244", "0.81263477", "0.81215096", "0.81215096", "0.80769324", "0.80529666", "0.80529666", "0.80529666", "0.80529666", "0.80529666", "0.80529666", "0.80529666", "0.80529666", "0.80529666", "0.80529666", "0.80529666", "0.80529666", "0.80529666", ...
0.8190772
3
Tests TopicViewSet fans functionality
def test_is_liked_topic_viewset(self): topic = TopicFactory(author=self.user) self.client.post(reverse('api:topics-like', kwargs={'topic_id': topic.id})) response = self.client.get(reverse('api:topics-fans', kwargs={'topic_id': topic.id})) self.assertEqual(response.status_code, status.H...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_topic_viewset_list(self):\n TopicFactory()\n TopicFactory(title='Test Title2',\n body='Test body',\n description='Test description',\n section=Topic.CONVERSATION)\n TopicFactory(title='Test Title3',\n body...
[ "0.694206", "0.68580484", "0.64791423", "0.64463466", "0.6374887", "0.6151836", "0.61428785", "0.6107565", "0.6031373", "0.60071194", "0.59806544", "0.59261924", "0.59203273", "0.5896649", "0.5868944", "0.58324516", "0.5731397", "0.5714358", "0.56958115", "0.5689915", "0.5685...
0.70022416
0
Get all posts of particular topic
def test_get_posts_by_topic(self): data = {'topic': self.topic.id} response = self.client.get(reverse('api:posts-list'), data) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(len(response.data.get('results')), 2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def posts_per_topic_all(request, pk):\n #update is_expired in all posts\n update_posts_expiration()\n #get all posts with a certain topic\n posts = Post.objects.filter(topic=pk)\n serializer = ViewPostSerializer(posts, many=True)\n return Response(serializer.data)", "def post_list(request, topi...
[ "0.7457398", "0.6992406", "0.6771073", "0.66584057", "0.66479665", "0.6629952", "0.6589824", "0.6586306", "0.6565213", "0.6547313", "0.6545665", "0.6483233", "0.6476145", "0.6471575", "0.6406389", "0.64007306", "0.6250633", "0.62493956", "0.6233608", "0.6230638", "0.62274015"...
0.73801446
1
Tests that user can edit post
def test_patch_post_by_user(self): data = { 'body': 'Edited post body' } response = self.client.patch(reverse('api:posts-detail', kwargs={'pk': self.post1.id}), data) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(data['body'], response.d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_has_perm_post_edit(self):\n self.context['request'].user = User.objects.get(pk=47963)\n allowed = has_perm(self.context, 'forums_forum.post_edit_forum',\n self.forum_1)\n eq_(allowed, True)\n allowed = has_perm(self.context, 'forums_forum.post_edit_for...
[ "0.7734945", "0.75737554", "0.7448606", "0.7413112", "0.7413038", "0.7387953", "0.72288173", "0.7119684", "0.7010333", "0.6923481", "0.6900643", "0.6874698", "0.685873", "0.685873", "0.685873", "0.6849603", "0.68403", "0.68403", "0.6797233", "0.6793174", "0.677719", "0.6767...
0.6792393
20
Test user try to delete comment
def test_delete_comment(self): response = self.client.delete(reverse('api:comments-detail', kwargs={'pk': self.comment1.id})) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertTrue(Comment.objects.all().exists())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_user_can_delete_their_comment(self):\n token = self.create_user(VALID_USER_DATA)\n response = self.create_article(VALID_ARTICLE, token)\n response = self.create_comment(\n token=token,\n parentId=0,\n slug=response.data['article']['slug']\n )\n ...
[ "0.85320395", "0.83407843", "0.8307819", "0.8248985", "0.8231272", "0.82162666", "0.8089606", "0.803833", "0.7789582", "0.77567405", "0.7588929", "0.7530914", "0.7426693", "0.7386352", "0.7369416", "0.73184013", "0.7287286", "0.7287286", "0.727201", "0.7242696", "0.72425616",...
0.8392161
1
Tests IsTeamOwnerRankPermission, only team owners can edit and create ranks
def test_is_team_owner_rank_permission(self): weak = RankFactory(name='weak soul', team=self.team) middle = RankFactory(name='middle soul', team=self.team) non_owner = AnotherUserFactory() params = {'pk': weak.id} edited_weak_name_name = 'small weak soul' edited_middle_n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_func(self):\n member_to_view = self.get_object()\n is_self = self.request.user.rfid == member_to_view.rfid\n view_others = self.request.user.has_permission(\"core.view_member\")\n return view_others or is_self", "def test_get_roles_rank(self):\n contrib_as = self.make_...
[ "0.615803", "0.6138243", "0.61050636", "0.60081613", "0.5986552", "0.59577364", "0.5939279", "0.58789945", "0.5871701", "0.58376783", "0.583037", "0.57774323", "0.57717377", "0.5768536", "0.5750079", "0.57436097", "0.57031596", "0.5682355", "0.5663512", "0.56352276", "0.56249...
0.80870533
0
Tests that users with team cannot create them
def test_cannot_create_new_team(self): data = { 'name': 'Griffons', 'description': 'Only strong souls can be joined us.' } response = self.client.post(reverse('api:teams-list'), data) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_not_creator_cannot_update(self):\n\n logged_user = utils.create_user_and_authenticate(self)\n self.group.users.add(logged_user)\n expected_url = reverse('my_groups_view')\n\n utils.test_cannot_access(self, self.url,\n expected_url=expected_url,\n...
[ "0.7378879", "0.73211503", "0.7231395", "0.7184021", "0.7179846", "0.71428245", "0.7140611", "0.7078009", "0.7052199", "0.7039831", "0.70244503", "0.70189637", "0.6984162", "0.69734704", "0.6966104", "0.6956472", "0.692271", "0.68743354", "0.68567616", "0.68492806", "0.682016...
0.7826658
0
Tests that team owners can edit team data
def test_owners_can_edit_team_data(self): data = { 'description': 'Edited description', 'name': 'Edited Name' } response = self.client.patch(reverse('api:teams-detail', kwargs={'pk': self.team.id}), data) self.assertEqual(response.status_code, status.HTTP_200_OK)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_team(self):\n pass", "def test_assign_managing_team(self):\n pass", "def test_is_team_owner_rank_permission(self):\n\n weak = RankFactory(name='weak soul', team=self.team)\n middle = RankFactory(name='middle soul', team=self.team)\n non_owner = AnotherUserFact...
[ "0.79741186", "0.7550529", "0.74650097", "0.74523747", "0.7271356", "0.71286154", "0.7111324", "0.7088815", "0.6984165", "0.6976406", "0.6792993", "0.6786817", "0.676375", "0.67552793", "0.6743613", "0.6716284", "0.6629992", "0.66184694", "0.66177344", "0.66161466", "0.660666...
0.84916514
0
Returns the transformation between the right camera to the base, for applying direct twist vectors using the baxter API.
def cam_to_body(self, vector): cam2hand = generate_frame_transform(self._cam2hand_t[0:3,:],self._cam2hand_R[0:3,0:3],False) # Possibly GRASP specific function? hand_pose = baxter.get_right_arm_pose() (t,R) = get_t_R(hand_pose) hand2body = generate_frame_transform(t[0:3,:],R[0:3,0...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def camera_to_object_transform(self):\n # form the full object to camera transform\n T_stp_camera = self.stp_to_camera_transform()\n T_obj_stp = self.object_to_stp_transform()\n T_obj_camera = T_stp_camera.dot(T_obj_stp)\n return T_obj_camera", "def getTransformation(self):\n ...
[ "0.66652256", "0.6578117", "0.65453345", "0.6537211", "0.63499635", "0.6301437", "0.6284384", "0.62253904", "0.6204346", "0.6171926", "0.61414176", "0.6124054", "0.60958767", "0.60895497", "0.5948501", "0.58918583", "0.58689046", "0.5855292", "0.5852516", "0.58439815", "0.584...
0.60885674
14
Given a 6x1 twist vector, sets the corresponding joint velocities using the PyKDL package.
def set_hand_vel(self,vel): # Calculate joint velocities to achieve desired velocity joint_vels=np.dot(self._kin.jacobian_pseudo_inverse(),vel) joints=dict(zip(self._arm.joint_names(),(joint_vels))) self._arm.set_joint_velocities(joints)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setJointVelocity(self, jointVelocity):\n for i in range(7):\n self.jointvelocity[i] = jointVelocity[i].item()", "def set_joint_velocities(self, velocities):\n self._command_msg.names = velocities.keys()\n self._command_msg.velocity = velocities.values()\n se...
[ "0.73319125", "0.63303417", "0.6176155", "0.6152593", "0.6143792", "0.5955172", "0.5811874", "0.57677925", "0.57410127", "0.57277566", "0.5704744", "0.56971526", "0.56834733", "0.566836", "0.5665224", "0.56561047", "0.5648981", "0.5645842", "0.5643067", "0.56258285", "0.56224...
0.59459955
6
Representation of the element.
def __repr__(self): return ( f"<Element: {self.name}, symbol: {self.symbol}, " f"atomic number: {self.atomic_number}, mass: {self.mass.to('amu')}>" )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _repr_(self):\n return repr(self.element())", "def __str__(self):\n return str(self.element)", "def element(self):\n return self._element", "def represent(self, elt):\n raise NotImplementedError", "def element(self):\n return self._element", "def element(self):\n...
[ "0.76590717", "0.75735146", "0.7459662", "0.73872757", "0.72737676", "0.72737676", "0.72737676", "0.7263382", "0.7263382", "0.7263382", "0.7263382", "0.7230217", "0.7152036", "0.71489364", "0.7146158", "0.71456826", "0.70398426", "0.6967275", "0.6967275", "0.6967275", "0.6967...
0.7791092
0
Search for an element by its mass. Look up an element from a list of known elements by mass. If given mass is an int or a float, it will be convert to a unyt quantity (u.amu). Return None if no match found.
def element_by_mass(mass, exact=True, verbose=False): if isinstance(mass, str): # Convert to float if a string is provided mass_trimmed = np.round(float(sub(r"[a-z -]", "", mass.lower()))) if str(mass_trimmed) != mass and verbose: msg1 = ( f"Letters and spaces are...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mass(elem):\n return mass[get_num(elem)]", "def test_get_mass(self):\n self.assertEqual(get_element_mass(1), (1.00782503224, 1)) # test input by integer\n self.assertEqual(get_element_mass('Si'), (27.97692653465, 14)) # test string input and most common isotope\n self.assertEqua...
[ "0.65952975", "0.61839396", "0.5806123", "0.58044016", "0.56657106", "0.5591758", "0.5590795", "0.5538004", "0.55129415", "0.5512886", "0.5437091", "0.5405241", "0.5385231", "0.53475", "0.53409576", "0.53156203", "0.53015524", "0.51771265", "0.50979733", "0.50402725", "0.4998...
0.82174575
0
Convert a mask to a rgb image according to the labels dict
def categorical2mask(X, labels): X_shape = X.shape[0:2] if type(X_shape) == tuple: X_shape = list(X_shape) Y = np.zeros(X_shape + [3], dtype="uint8") for i, key in enumerate(labels): print(X.shape,Y.shape) Y[...,0] = np.where(X==i, labels[key][0], Y[...,0]) Y[...,1] = np....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def label_to_mask(labels):\n # get the image size\n h, w = labels.shape\n\n # build a color to label map\n idx_to_color = {}\n for label in class_info:\n idx_to_color[class_info[label].id] = class_info[label].color\n\n # generate label matrix\n mask = np.zeros((h, w, 3), dtype=np.uint8)...
[ "0.7702495", "0.7671501", "0.7365367", "0.7188306", "0.71841663", "0.7088308", "0.7077394", "0.7077394", "0.70386785", "0.6837946", "0.6692847", "0.6604547", "0.6584995", "0.6571877", "0.65430796", "0.64758235", "0.646484", "0.6419489", "0.6372687", "0.6316512", "0.6297067", ...
0.5754892
62
Pass a certain rgb mask (3channels) to an image of ordinal classes
def mask2categorical(Mask: tf.Tensor, labels: dict) -> tf.Tensor: assert type(labels) == dict, "labels variable should be a dictionary" X = Mask if X.dtype == "float32": X = tf.cast(X*255, dtype="uint8") Y = tf.zeros(X.shape[0:2] , dtype="float32") for i, key in enumerate(labels): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decode_labels(mask, num_classes=41):\n h, w = mask.shape\n outputs = np.zeros((h, w, 3), dtype=np.uint8)\n\n img = Image.new('RGB',(len(mask[0]), len(mask)))\n pixels = img.load()\n for j_, j in enumerate(mask):\n for k_, k in enumerate(j):\n if k < num_classes:\n ...
[ "0.65879583", "0.61727345", "0.6111306", "0.6098174", "0.5944716", "0.59053606", "0.58990884", "0.5843593", "0.5837626", "0.58103865", "0.5810231", "0.5808097", "0.58054405", "0.5794795", "0.57915926", "0.5777005", "0.5774854", "0.57744765", "0.5734905", "0.5733344", "0.57252...
0.0
-1
Return a dict with the corresponding rgb mask values of the labels
def parse_labelfile(path): with open(path, "r") as FILE: lines = FILE.readlines() labels = {x.split(":")[0]: x.split(":")[1] for x in lines[1:]} for key in labels: labels[key] = np.array(labels[key].split(",")).astype("uint8") return labels
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def label_to_mask(labels):\n # get the image size\n h, w = labels.shape\n\n # build a color to label map\n idx_to_color = {}\n for label in class_info:\n idx_to_color[class_info[label].id] = class_info[label].color\n\n # generate label matrix\n mask = np.zeros((h, w, 3), dtype=np.uint8)...
[ "0.72288805", "0.71445686", "0.709488", "0.6996079", "0.6984343", "0.68994325", "0.68738806", "0.6864378", "0.68482333", "0.67945206", "0.67945206", "0.6779943", "0.6623313", "0.6619617", "0.65561354", "0.64924824", "0.64924824", "0.64558804", "0.64429176", "0.6305649", "0.62...
0.5623944
88
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`.
def plot_confusion_matrix(y_true, y_pred, classes, normalize=True, title=None, cmap=plt.cm.Blues): if not title: if normalize: title = 'Normalized confusion matrix' else: title = 'Confusion matrix, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n...
[ "0.8194862", "0.80949175", "0.8029915", "0.8019153", "0.79941195", "0.7991258", "0.7980955", "0.7976606", "0.79610753", "0.79590565", "0.79378676", "0.7934962", "0.7934504", "0.79313844", "0.7926313", "0.7924577", "0.79241234", "0.7923211", "0.7923023", "0.7921931", "0.791787...
0.0
-1
Calculate the precision of a given predicted mask
def mask_precision(Y, Y_pred): cm = confusion_matrix(Y.reshape(-1), Y_pred.reshape(-1)) return precision(cm)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def precision(y_true, y_pred):\n true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))\n predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1)))\n precision = true_positives / (predicted_positives + K.epsilon())\n return precision", "def getPrecision(y_true...
[ "0.7338014", "0.72834307", "0.7271064", "0.7262598", "0.7258438", "0.7258438", "0.7258438", "0.7258438", "0.7258438", "0.7258438", "0.72414917", "0.7231114", "0.7231114", "0.7231114", "0.7231114", "0.7231114", "0.7231114", "0.7231114", "0.7231114", "0.7231114", "0.7231114", ...
0.6957219
47
Render the homepage template on the / route
def homepage(): return render_template("home/a_homepage.html", title="Welcome")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def homepage():\n return render_template(\"home/index.html\")", "def home():\n return render_template('homepage.html')", "def homepage():\n return render_template('homepage.html')", "def homepage():\n return render_template(\"home/index.html\", title=\"Welcome\")", "def render_home():\r\n\treturn...
[ "0.8596693", "0.8568932", "0.8526821", "0.8473926", "0.8473321", "0.84519774", "0.84239286", "0.84239286", "0.8420498", "0.8387553", "0.8311804", "0.82661605", "0.82661605", "0.82661605", "0.82661605", "0.82661605", "0.82661605", "0.8263859", "0.8259376", "0.82504493", "0.825...
0.820045
41
Get the duration of the track in float
def get_duration_track(artist, track): track_infos = get_infos(artist, track) if track_infos == None : return None return int(track_infos['track']['duration']) / 60000
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def duration_in_seconds(self):\n \"Should not set track length\"\n return self.duration / float(self.samplerate)", "def audio_duration(self) -> float:\n\n for track in self.mi.tracks:\n if track.track_type == \"Audio\":\n return track.duration / 1000.0\n\n ra...
[ "0.81641173", "0.7841679", "0.7752638", "0.77459544", "0.76901", "0.7673066", "0.766263", "0.763964", "0.75768965", "0.75657904", "0.7545778", "0.7545778", "0.7527824", "0.75171906", "0.7434581", "0.73973155", "0.7385887", "0.7376997", "0.73500794", "0.7347129", "0.7338351", ...
0.77265435
4
Receive a list of words and return a list containing only the words that respect certain conditions.
def checkWords(line): words = [] parts = re.sub('[^a-zA-Z0-9@ ]', '', line) parts = parts.lower() parts = parts.split(' ') for w in parts: if w is not '' and len(w) > 4 and len(w) < 15 and w not in commonWords: # if w is not '': words.append(w) return words
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def known(words: list[str]) -> list[str]:\n return [z for z in list(set(words)) if z in self.words]", "def stopword_filter(words):\n new_words = []\n for w in words:\n if w in stopwords.words(\"german\"): continue\n else: new_words += [w]\n return new_words", "def search_all(s...
[ "0.7568741", "0.73001444", "0.7207502", "0.7194505", "0.71264136", "0.7104559", "0.6989905", "0.6936214", "0.6912774", "0.68394643", "0.67528915", "0.67265177", "0.6720937", "0.6719891", "0.6701053", "0.6670727", "0.66525424", "0.6633776", "0.6619338", "0.66111636", "0.656213...
0.62747097
51
Build a Convolutional Neural Network model with two convolutional layers and two hidden layers. This model is set to use 32 feature detectors in each convolutional layer and 128 nodes in the first hidden layer.
def buildModel(self, img_shape = 20, num_categories = 10): # Add first convolutional layer and max pooling self.model.add(Conv2D(32, # Number of features detectors (filters) (3, # 3 Row (conv. matr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_cnn(self):\n model = Sequential()\n model.add(Conv2D(24, (1, 3), activation = 'relu', input_shape = (1, grid_size*grid_size+2, 1)))\n model.add(Conv2D(24, (1, 3), activation = 'relu', input_shape = (1, grid_size*grid_size+2, 1)))\n model.add(Flatten())\n model.add(Dense...
[ "0.748952", "0.7481394", "0.7361032", "0.7347617", "0.7200099", "0.7159509", "0.71335566", "0.71289945", "0.71104205", "0.71062636", "0.7080533", "0.7080406", "0.7063285", "0.7055912", "0.70427436", "0.70072216", "0.6984358", "0.6976245", "0.6963191", "0.69495296", "0.6938339...
0.6824348
40
Checks if it is possible to add an edge due to a separator given the current set of minimal separators.
def is_it_possible(e, s, e_to_seps): for u in e: num = 0 seps = set() # Count the edges that need to be added and the number of separators that can be involved in their addition for w in s: if w < u: uw = (w, u) else: uw = (u,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addSeparatorFeature(self):\n \n # graphical separators\n dNS = {\"pc\":PageXml.NS_PAGE_XML}\n someNode = self.lNode[0]\n ndPage = someNode.node.xpath(\"ancestor::pc:Page\", namespaces=dNS)[0]\n lNdSep = ndPage.xpath(\".//pc:SeparatorRegion\", namespaces=dNS)\n l...
[ "0.6078529", "0.5920741", "0.5816994", "0.55449444", "0.55283064", "0.5493502", "0.5433992", "0.53511405", "0.5345978", "0.5343595", "0.5334871", "0.5332041", "0.532623", "0.5296178", "0.5285672", "0.5283695", "0.5228905", "0.52245796", "0.52238023", "0.52150625", "0.52077854...
0.5949925
1
Create a local dataset (defaults defined in CreateDatasetRequest)
def create_dataset(request: CreateDatasetRequest) -> CreateDatasetResponse: assert isinstance(request, CreateDatasetRequest) create_privacy_group_if_not_exists( privacy_group_id=str(request.privacy_group_id), privacy_group_name=request.privacy_group_name, description...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_dataset():\n\n dataset_id = \"{}.airflow\".format(client.project)\n dataset = bigquery.Dataset(dataset_id)\n dataset.location = \"US\"\n dataset = client.create_dataset(dataset, exists_ok=True)\n print(\"Created dataset {}.{}\".format(client.project, dataset.dataset_id))\n return datas...
[ "0.7631532", "0.7442517", "0.7167946", "0.7135166", "0.7088684", "0.7037595", "0.69732356", "0.6917876", "0.6906633", "0.6902586", "0.68716615", "0.6868962", "0.6721543", "0.669875", "0.66289973", "0.6626205", "0.66108525", "0.6610211", "0.6576459", "0.6542797", "0.64971083",...
0.640791
24
Returns [idx of sigma1, idx of sigma2, ...]
def size_indices(self, tol=1e-8): sigs = np.array(np.round(self.diameters / tol), dtype=int) sigset = set(sigs) return [sigs == s for s in sorted(sigset)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mixture_index(self):\n mixture_with_index = [(i, np.sum(row)) for i, row in enumerate(self.mu)]\n return list(zip(*sorted(mixture_with_index, key=lambda k: k[1]))[0])", "def mainIndices(self):\n return self.i1, self.i2", "def feature_to_index(feature, dims):\n p = 0\n for j, k in...
[ "0.62955844", "0.62316006", "0.6103472", "0.60251874", "0.5943839", "0.5927912", "0.59064287", "0.5862819", "0.58316654", "0.5813732", "0.58019394", "0.57863903", "0.57801497", "0.5767498", "0.57605594", "0.57071775", "0.57005745", "0.5671596", "0.5660145", "0.5640544", "0.56...
0.0
-1
Returns the distance between two packings, with the particles paired up in the most efficient way, and also with centerofmass accounted for.
def dist(self, other, tol=1e-8, maxt=1000000): tree = self.dist_tree(other, tol=tol) tree.expand(maxt) return sqrt(tree.current_best().distance_squared * self.L * other.L)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distance_pbc(cls, atom_1, atom_2):\n\t\tif atom_1.box_dim is None or atom_2.box_dim is None:\n\t\t\traise Exception(\"simulation box size has not been specified\")\n\t\tif atom_1.box_dim != atom_2.box_dim:\n\t\t\traise Exception(\"simulation box size does not match\")\n\t\t\n\t\t[lx,ly,lz] = [atom_2.box_dim[0]...
[ "0.653388", "0.627615", "0.6237876", "0.6218548", "0.6196422", "0.6145412", "0.6134934", "0.6129977", "0.6118243", "0.61099815", "0.6101325", "0.60917014", "0.6079494", "0.6078224", "0.6068382", "0.6062689", "0.6051432", "0.6049281", "0.6020393", "0.6020393", "0.6003134", "...
0.0
-1
Returns the distance between two packings, assuming particle 1 of packing 1 goes with particle 2 of packing 2. Distance is calculated as
def paired_dists(self, other, match_com=True): assert self.ndim == other.ndim if match_com: dists1 = (self.rs[..., np.newaxis] - self.rs.T[np.newaxis, ...]) dists2 = (other.rs[..., np.newaxis] - other.rs.T[np.newaxis, ...]) rij_minus_sij = np.rollaxis(dists1 - dists2,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dist(gene1, gene2):\n return abs(len(gene1.goal) - len(gene2.goal))", "def calculate_distance(asteroid_1: Asteroid, asteroid_2: Asteroid) -> float:\n dy = asteroid_2.y - asteroid_1.y\n dx = asteroid_2.x - asteroid_1.x\n return math.sqrt(dy * dy + dx * dx)", "def _get_dist(self, p1, p2):...
[ "0.70944", "0.6856438", "0.6679388", "0.6632208", "0.6620017", "0.6605011", "0.66041946", "0.6596996", "0.65936697", "0.656512", "0.65543693", "0.65396076", "0.65349287", "0.65310967", "0.65233094", "0.6521315", "0.65201974", "0.65177643", "0.6516459", "0.64812803", "0.647324...
0.0
-1
Designed for use with plot_disks, this will plot a line between neighboring particles.
def plot_contacts(self, ax=None, tol=0, reshape=True, **kw): import matplotlib as mpl import numpy as np if ax is None: ax = mpl.pyplot.gca() kw.setdefault('color', 'k') kw.setdefault('alpha', 0.4) adj, diffs = self.neighbors(tol=tol) for i, (adjro...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plt_connecting_lines():\n\n for i in range(0, Molecule.connection_count):\n tmp1 = Molecule.right_endpt[Molecule.left_connection[i] - 1]\n tmp2 = Molecule.left_endpt[Molecule.right_connection[i] - 1]\n tmp3 = Molecule.energy[Molecule.left_connection[i] - 1]\n tmp4 = Molecule.ener...
[ "0.6939495", "0.66631365", "0.6645477", "0.6644744", "0.6639424", "0.6476751", "0.6406868", "0.6110826", "0.61031973", "0.606958", "0.60689676", "0.60041225", "0.5995607", "0.5974186", "0.5965269", "0.595901", "0.5945159", "0.59184873", "0.58942336", "0.58547455", "0.5842692"...
0.0
-1
Get the maximum charge that can go through this bridge. For now, it's determined only by current strength of the bridge, so let's say it equals to it. Might change in the future if needed to
def max_charge(self): return self.strength
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strength_longest_bridge():\n # first again filter all the Nonetype out\n bridges = [ b for b in all_bridges if b != None ]\n\n # the find the strength of the longest bridge\n # in this case the first longest to be found is also the\n # the strongest out of all the longest\n\n return max(bridg...
[ "0.67670107", "0.6749399", "0.6736035", "0.6724029", "0.66988444", "0.6685048", "0.6685048", "0.6615228", "0.6493889", "0.6444233", "0.6444233", "0.6439436", "0.63890606", "0.63855755", "0.6384605", "0.6360672", "0.63175637", "0.63120985", "0.6311538", "0.6307517", "0.6306496...
0.83065325
0
Indicates if the request context is a normal user.
def _is_user_context(context): if not context: return False if context.is_admin: return False if not context.user_id or not context.project_id: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_user_context(context):\n if not context or not isinstance(context, RequestContext):\n return False\n if context.is_admin:\n return False\n return True", "def is_regular_user(user):\n return user.is_authenticated()", "def is_user_context(context):\n if not context:\n r...
[ "0.7632277", "0.74472946", "0.6977175", "0.6977175", "0.6977175", "0.68780714", "0.673595", "0.6617593", "0.6616803", "0.6615392", "0.6606159", "0.6588011", "0.6531366", "0.64678705", "0.64584976", "0.6383593", "0.6357672", "0.6351535", "0.63481635", "0.63026196", "0.6299073"...
0.70615214
3
Query helper that accounts for context's `read_deleted` field.
def model_query(context, *args, **kwargs): session = kwargs.get('session') or context.session read_deleted = kwargs.get('read_deleted') or context.read_deleted project_only = kwargs.get('project_only') query = session.query(*args) if read_deleted == 'no': query = query.filter_by(deleted=Fa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def model_query(context, *args, **kwargs):\n session = kwargs.get('session') or get_session()\n read_deleted = kwargs.get('read_deleted') or context.read_deleted\n project_only = kwargs.get('project_only')\n\n query = session.query(*args)\n\n if read_deleted == 'no':\n query = query.filter_by...
[ "0.6613225", "0.6613225", "0.6242648", "0.62392414", "0.6230362", "0.58661956", "0.5761054", "0.5659555", "0.5637472", "0.55814755", "0.55604327", "0.5552125", "0.54741687", "0.53852934", "0.53211725", "0.53011674", "0.52753043", "0.5223493", "0.51596826", "0.51596826", "0.51...
0.6627549
1
Split the dataset with train_percentage
def split_dataset(dataset, train_percentage, feature_headers, target_header): train_x, test_x, train_y, test_y = train_test_split(dataset[feature_headers], dataset[target_header], train_size=train_percentage, random_state=42) return train_x, test_x, t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_train_test_by_percentage(dataset, train_percentage=0.8):\n train_length = int(len(dataset) * train_percentage)\n return torch.utils.data.random_split(dataset, (train_length, len(dataset) - train_length))", "def split_dataset(dataset, train_percentage, valid_percentage):\n\n # Split dataset int...
[ "0.8460871", "0.8151334", "0.7983524", "0.7791796", "0.769264", "0.7603226", "0.7581921", "0.7538712", "0.7538712", "0.7535976", "0.7356462", "0.7356462", "0.72785723", "0.72672325", "0.7246208", "0.7207059", "0.71712476", "0.7159764", "0.7064658", "0.7043388", "0.7031485", ...
0.76440144
5
Relative position between dendrites and soma in um. Return ====== array([YCoord_um, XCoord_um, ZCoord_um])
def rel_position_um(soma, d): return soma['wParamsNum'][26:29] - d['wParamsNum'][26:29]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_pos(self):\n return (self.x/3, 3**0.5*self.y/3, self.r/3)", "def normalized_position(self) -> Tuple[float, float]:\n x, y = self.relative_position\n return x / self.region.rect.width, y / self.region.rect.height", "def normalized_position(self) -> Tuple[float, float]:\n x, y...
[ "0.6343135", "0.63423085", "0.63423085", "0.63204896", "0.6308772", "0.6278963", "0.6278963", "0.6276378", "0.6165193", "0.6164037", "0.6128618", "0.61267066", "0.60742646", "0.6070838", "0.60514605", "0.6044558", "0.60352135", "0.6005397", "0.59944916", "0.5953402", "0.59468...
0.59259254
23
Euclidean distance between two points.
def get_distance(point_a, point_b): return np.sqrt(np.sum((point_a - point_b) ** 2, 1))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def euclidean_distance(point1, point2):\n\n return math.sqrt(sum([(x - y) ** 2 for x, y in zip(point1, point2)]))", "def euclidean_distance(point1, point2):\n return np.linalg.norm(np.array(point1) - np.array(point2))", "def euclidean_distance(point_one, point_two):\n return np.linalg.norm(point_one-p...
[ "0.84279233", "0.83612895", "0.8324174", "0.83092695", "0.8306929", "0.82199126", "0.8209069", "0.82086724", "0.8176723", "0.805556", "0.80503225", "0.8045459", "0.80258095", "0.7958847", "0.7943932", "0.79337907", "0.79223317", "0.78885055", "0.7877786", "0.78511626", "0.784...
0.7393954
63
u""" Get all extensions for this namespace and list of names.
def get_plugins(namespace, names=None): return list(get_manager(namespace, names))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_extensions(self, **_params):\r\n return self.get(self.extensions_path, params=_params)", "def extensions(self):\n return list(self._list(extension.Extension, paginated=False))", "def get_loaded_extensions():\n raise NotImplementedError()", "def extensions(self):\n return self...
[ "0.7566908", "0.74838465", "0.6972722", "0.68742275", "0.6800446", "0.67200387", "0.66352564", "0.66352564", "0.65340126", "0.6526291", "0.6514756", "0.6481636", "0.64711696", "0.6468788", "0.6432234", "0.6419003", "0.6414312", "0.6414007", "0.63917214", "0.63796395", "0.6370...
0.5782523
69
Places command_ingest in LOW_POWER_MODE. Returns True if successful, False if any errors are encountered.
def enter_low_power_mode(self) -> bool: try: self.processes["dispatch"].pause() return True except: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enter_low_power(self):\n line = self.connection.low_power()\n\n if 'OK' in lines:\n return 0\n\n return -1", "def is_on(self):\n return self._mower_status in [\n STATUS_EXECUTING_START, STATUS_OK_CHARGING,\n STATUS_OK_CUTTING, STATUS_OK_LEAVING, ST...
[ "0.5297581", "0.5287378", "0.52519447", "0.52513766", "0.52461445", "0.52139765", "0.51793355", "0.5143588", "0.5114623", "0.5071907", "0.5066475", "0.50342077", "0.5032523", "0.5026463", "0.50034076", "0.499211", "0.49915951", "0.49424443", "0.49336016", "0.49222907", "0.487...
0.58172834
0
Checks whether the zero slices in a 3D array match the expected zero slices and returns a new array without these slices.
def check_remove_zero_slices_in_array_3d(array_3d, are_zero_slices): if array_3d.ndim != 3: raise ValueError('`array_3d.ndim` is not equal to 3.') found_zero_slices = numpy.logical_not(array_3d.any(axis=(0, 1))) numpy.testing.assert_equal(found_zero_slices, are_zero_sl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trim_zeros(array):\n multislice = []\n for i in range(array.ndim):\n sum_axes = tuple(j for j in range(array.ndim) if j is not i)\n edges = np.where(np.sum(array, axis=sum_axes) > 0)\n if edges[0].size == 0:\n return np.array([], dtype=array.dtype)\n low = edges[0][...
[ "0.6692145", "0.63150406", "0.6215566", "0.61284727", "0.6106762", "0.6048676", "0.601307", "0.6011342", "0.60047805", "0.58518505", "0.5827224", "0.57863855", "0.57075846", "0.56781584", "0.56365705", "0.56201607", "0.56102204", "0.5590342", "0.5579016", "0.5557445", "0.5552...
0.81692624
0
Removes from the list the strings that do not end with the given extensions and sorts the list.
def clean_sort_list_strings(list_strings, extension): list_strings_extension = [string for string in list_strings if string.endswith(extension)] list_strings_extension.sort() return list_strings_extension
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_files_by_extension(\n files: list ,\n extensions: list\n):\n filtered_files = []\n for file in files:\n file_ext = os.path.splitext(file)[-1].lower()\n file_ext = _remove_dot_from_extension(file_ext)\n for extension in extensions:\n ext = _remove_dot_from_exte...
[ "0.6479178", "0.6164787", "0.6079694", "0.60749", "0.5847315", "0.5784591", "0.5708977", "0.57061476", "0.56991494", "0.5587988", "0.5481527", "0.5451059", "0.54468375", "0.54457825", "0.54275537", "0.5423418", "0.5416281", "0.54107827", "0.54012305", "0.5357687", "0.53487265...
0.85101557
0
Converts the RGB image to YCbCr. The conversion is ITUT T.871. This means that, if the pixels of the RGB image span the range [|0, 255|], the pixels of the luminance channel and the pixels of the chrominance channels span the range [|0, 255|]. Note that the OpenCV function `cvtColor` with the code `CV_BGR2YCrCb` also i...
def rgb_to_ycbcr(rgb_uint8): if rgb_uint8.dtype != numpy.uint8: raise TypeError('`rgb_uint8.dtype` is not equal to `numpy.uint8`.') # If the check below did not exist, `rgb_to_ycbcr` would # not crash if `rgb_uint8` is nD, n >= 4. if rgb_uint8.ndim != 3: raise ValueError('`rgb_uint8...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rgb_to_ycbcr(image: torch.Tensor) -> torch.Tensor:\n r: torch.Tensor = image[..., 0, :, :]\n g: torch.Tensor = image[..., 1, :, :]\n b: torch.Tensor = image[..., 2, :, :]\n\n delta: float = 0.5\n y: torch.Tensor = 0.299 * r + 0.587 * g + 0.114 * b\n cb: torch.Tensor = (b - y) * 0.564 + delta\...
[ "0.78094345", "0.75680757", "0.755392", "0.7528003", "0.73284644", "0.7030954", "0.687871", "0.668969", "0.6686089", "0.6482549", "0.63427246", "0.62998706", "0.6210206", "0.6197732", "0.61735976", "0.6092661", "0.609149", "0.6088076", "0.60875773", "0.607067", "0.5933575", ...
0.7163767
5
Saves the array as an image. `scipy.misc.imsave` is deprecated in Scipy 1.0.0. `scipy.misc.imsave` will be removed in Scipy 1.2.0. `save_image` replaces `scipy.misc.imsave`.
def save_image(path, array_uint8, coefficient_enlargement=None): if array_uint8.dtype != numpy.uint8: raise TypeError('`array_uint8.dtype` is not equal to `numpy.uint8`.') if coefficient_enlargement is None: enlarged_array_uint8 = array_uint8 else: enlarged_array_uint8 = numpy.repeat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_img(img: np.ndarray, path: str) -> None:\n\n img_obj = Image.fromarray(img)\n img_obj.save(path)", "def save_npimg(array: np.ndarray, path: str) -> None:\r\n img = Image.fromarray(array.squeeze())\r\n img.save(path)", "def save_image(filename, imagearr, is_srgb=True):\n\n if not filenam...
[ "0.78571033", "0.7624886", "0.7451188", "0.73956984", "0.7382525", "0.738077", "0.72770494", "0.72729355", "0.7267532", "0.7096555", "0.7052723", "0.7051773", "0.70220864", "0.7021269", "0.6976793", "0.6959763", "0.69561404", "0.6941007", "0.6846687", "0.68463564", "0.675915"...
0.6311029
56
Converts the YCbCr image to RGB. The conversion is ITUT T.871.
def ycbcr_to_rgb(ycbcr_uint8): if ycbcr_uint8.dtype != numpy.uint8: raise TypeError('`ycbcr_uint8.dtype` is not equal to `numpy.uint8`.') # If the check below did not exist, `ycbcr_to_rgb` would # not crash if `ycbcr_uint8` is nD, n >= 4. if ycbcr_uint8.ndim != 3: raise ValueError('...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ycbcr_to_rgb(image: torch.Tensor) -> torch.Tensor:\n y: torch.Tensor = image[..., 0, :, :]\n cb: torch.Tensor = image[..., 1, :, :]\n cr: torch.Tensor = image[..., 2, :, :]\n\n delta: float = 0.5\n cb_shifted: torch.Tensor = cb - delta\n cr_shifted: torch.Tensor = cr - delta\n\n r: torch.T...
[ "0.77444136", "0.76769894", "0.73401916", "0.71062464", "0.7070147", "0.70596", "0.6944698", "0.69078076", "0.66413015", "0.6619534", "0.6560954", "0.6547986", "0.64988935", "0.64386934", "0.6425217", "0.6347239", "0.62959737", "0.6295694", "0.62851655", "0.6251744", "0.62030...
0.6577191
10
Open a previouslysaved experiment. Open a dialog to prompt for a filename for an experiment which was previously saved. Open the experiment, and display it in a SequenceFrame.
def openExperiment(self): ext = _EXTS_EXPERIMENT[0] wildcard = 'Transport experiment (*.%s)|*.%s' % (ext, ext) dialog = wx.FileDialog(self, "Open Experiment", c.getExperimentFolder(), '', wildcard, wx.FD_OPEN) if dialog.ShowModal() == wx.ID_OK: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def openPremade(self):\n dialog = PremadeFrame(self)\n if dialog.ShowModal() == wx.ID_OK:\n newClass = dialog.selectedClass\n newFrame = newClass(self)\n self.frames.append(newFrame)\n self.names.append(newFrame.experimentName)\n newFrame.Show()\...
[ "0.6468138", "0.6125841", "0.5972066", "0.5933653", "0.5896018", "0.589336", "0.5882668", "0.58740795", "0.58511794", "0.58285046", "0.5811348", "0.5771192", "0.5738167", "0.5720675", "0.5715454", "0.5707681", "0.5703787", "0.5677005", "0.5669043", "0.5650177", "0.5618125", ...
0.77013963
0
Change the name of an experiment.
def renameExperiment(self, frame, newName): ext = _EXTS_EXPERIMENT[0] if newName.endswith(ext): newName = newName[:-len(ext)-1] try: index = self.frames.index(frame) log.info('Renaming experiment %s to %s.', self.names[index], newName) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_experiment_name(self, experiment_name):\n self.experiment_name = experiment_name", "def rename_experiment(self, experiment_id, new_name):\n return self.dbclient.update_by_id(Tables.EXPERIMENTS, experiment_id, {\n ExperimentAttr.NAME: new_name\n })", "def new_name(self,ne...
[ "0.8206918", "0.8002558", "0.74658984", "0.73921", "0.727186", "0.727186", "0.70670086", "0.70483166", "0.7046488", "0.7046488", "0.7031965", "0.69231975", "0.68221", "0.68111914", "0.67919624", "0.6774932", "0.67730606", "0.67730606", "0.67730606", "0.67730606", "0.67730606"...
0.7626478
2
Show the user configuration dialog.
def _onUserSettings(self, event): dialog = sc.UserSettingsDialog(self) if dialog.ShowModal() == wx.ID_OK: dialog.saveSettings() dialog.Destroy() sel = self.userbox.GetSelection() usernames = ['None'] + c.getUserNames() self.userbox.SetItems(usernames)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def _show_config_form(\n self,\n ):\n return self.async_show_form(\n step_id=\"user\",\n data_schema=vol.Schema(\n {\n vol.Required(CONF_DEVICEID): str,\n }\n ),\n errors=self._errors,\n )", ...
[ "0.76772326", "0.7655226", "0.713029", "0.7107903", "0.70994544", "0.6945371", "0.689641", "0.68398136", "0.6621222", "0.659133", "0.651788", "0.64852476", "0.6473106", "0.64095956", "0.63115", "0.6273439", "0.6253923", "0.62493896", "0.62303984", "0.6176222", "0.6168772", ...
0.6148722
22
Removes all recommendations from the database
def reset_recommendations(): db.session.remove() db.drop_all() init_db() return make_response('', status.HTTP_204_NO_CONTENT)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_ratings_table(self):\r\n\r\n sql_command = \"\"\"\r\n DELETE FROM UserRecommendations;\r\n \"\"\"\r\n self.controller.execute(sql_command)\r\n self.connection.commit()", "def delete_all_reviews(self):\n load.loader.clear_data_for_ho...
[ "0.73191863", "0.67053014", "0.6514639", "0.6489817", "0.63834697", "0.63396305", "0.6242839", "0.6239246", "0.6221812", "0.61776245", "0.6131691", "0.61165917", "0.60970336", "0.60768145", "0.6039662", "0.60251474", "0.6016871", "0.5994206", "0.5973697", "0.5973697", "0.5961...
0.757977
0
Give the x coordinate of the object
def findX(self): return self.x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_x(self):\n return self.posX", "def _get_x(self):\n return self.position.x", "def get_x_position(self):\n return self.rect.x", "def get_x(self):\n return self.coords[0]", "def x(self):\r\n return self.position.x", "def x(self):\n return _libsbml.Point_x(self)"...
[ "0.82629186", "0.8027334", "0.79966784", "0.78956234", "0.7882497", "0.78790677", "0.7839603", "0.78284395", "0.7779938", "0.7752688", "0.7600369", "0.7530174", "0.7438476", "0.74250567", "0.73865944", "0.7334305", "0.73174757", "0.7311192", "0.7299492", "0.7269495", "0.72627...
0.6468984
98
Give the y coordinate of the object
def findY(self): return self.y
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def y(self):\r\n return self.position.y", "def get_y_position(self): \n return self.rect.y", "def get_y(self):\n return self.posY", "def _get_y(self):\n return self.position.y", "def y(self):\n return self.coords[1]", "def getY(self):\r\n\t\treturn self._y", "def g...
[ "0.8289287", "0.81347865", "0.80239856", "0.8017191", "0.8008685", "0.7969141", "0.7967276", "0.79561543", "0.79561543", "0.794459", "0.79089", "0.790256", "0.7901379", "0.7855472", "0.78219247", "0.7796985", "0.7789049", "0.773426", "0.7619302", "0.7593018", "0.7507437", "...
0.74903697
23
Assure that byte string references are actually dottedname references.
def test_dotted_named_entities_not_dotted(): class NonDottedNameEntity(Entity): # `Property` is a real class, but this string is not a full # reference, so it can't be resolved and is therefore considered # invalid. foo = fields.EntityField('Property') with pytest.raises(ValueEr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _verify_name(name):\n if isinstance(name, str):\n name = name.encode(\"utf-8\")\n\n if not isinstance(name, bytes):\n raise TypeError(\n \"Name {!r} is not a string or byte string\".format(name)\n )\n\n if b\".\" in name:\n raise V...
[ "0.6383189", "0.59847933", "0.5886285", "0.5858706", "0.58326423", "0.56777585", "0.56613165", "0.557525", "0.5562001", "0.5547353", "0.5401761", "0.53765035", "0.5292258", "0.5268842", "0.52302635", "0.51929784", "0.51878154", "0.518005", "0.5174827", "0.51606005", "0.516027...
0.5423771
10
Removes columns with more than a percentage of NaN values
def remove_columns(df, threshold, log=False): if log: sectionTimer = Timer(log=f"removing columns with more than {threshold * 100}% of nans") # removes columns with many nans non_nan_values = int(df.shape[0] * (1 - threshold)) df_clean = df.dropna(thresh=non_nan_values, axis=1) dropped_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drop_high_nan(df, threshold=0.5):\n n_nans = df.isnull().sum()\n freq_nans = n_nans/float(len(df)) #in percentage\n to_drop = (freq_nans > threshold).values\n columns_drop = df.columns.values[to_drop].tolist()\n return df.drop(columns_drop, axis=1)", "def remove_null_cols(df, thresh=0.08):\n ...
[ "0.759025", "0.74982655", "0.74677205", "0.7368993", "0.72184753", "0.7173892", "0.69822055", "0.69781756", "0.69317186", "0.69123566", "0.68844146", "0.6767795", "0.66592455", "0.6640098", "0.63589495", "0.6330928", "0.63005036", "0.6287378", "0.6282502", "0.62737983", "0.62...
0.65622526
14
Removes rows with more than a percentage of NaN values
def remove_rows(df, threshold, log=False): if log: section_timer = Timer(log=f"removing rows with more than {threshold * 100}% of NaNs") non_nan_values = int(df.shape[1] * (1 - threshold)) df_clean = df.dropna(thresh=non_nan_values, axis=0) if log: section_timer.end_timer(log=f"removed {df.shape[0] - ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drop_nan(df, perc=20):\n check = check_nan(df, show_plot=False)\n return df.drop(check[check.percentage > perc].index.values, axis=1)", "def drop_high_nan(df, threshold=0.5):\n n_nans = df.isnull().sum()\n freq_nans = n_nans/float(len(df)) #in percentage\n to_drop = (freq_nans > threshold).va...
[ "0.74495536", "0.71701294", "0.7037434", "0.68191296", "0.6812606", "0.6687144", "0.6539966", "0.65008706", "0.6410269", "0.6326754", "0.63249964", "0.632466", "0.632466", "0.6318603", "0.6286389", "0.62536466", "0.6249018", "0.6203476", "0.6194353", "0.6174042", "0.6153469",...
0.64462656
8
Called when a user is saved to ensure that the user has a profile >>> user = User.objects.create(username='test', email='foo.com') >>> user.get_profile()
def create_user_profile_callback(sender, instance, created, **kwargs): try: instance.get_profile() except UserProfile.DoesNotExist: UserProfile.objects.create(user=instance)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_profile_on_user_created(self):\n user = User.objects.create_user(\n 'auto_tester', 'auto_tester@example.com', 'auto_tester')\n profile = user.get_profile()\n ok_(profile is not None)\n eq_(False, profile.username_changes)", "def save_user_profile(instance, *...
[ "0.7563473", "0.7538982", "0.74813694", "0.74813694", "0.7401588", "0.73609984", "0.7342244", "0.7339719", "0.73298883", "0.7300008", "0.729897", "0.72857565", "0.7285552", "0.7276722", "0.72620964", "0.7209369", "0.7202303", "0.72006625", "0.7193051", "0.7191322", "0.7182862...
0.75670576
0
Creates a runtime environment from a given configuration block. As the structure of an environment is a bit complicates, this is the time to
def create_environment(config): if not config.get('verify_cert'): ssl._create_default_https_context = ssl._create_unverified_context # Connect to vCenter Server service_instance = SmartConnect(host=config.get("host"), user=config.get("username"), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_environment(cls, full_config):\n\n config = full_config['template']['devops_settings']\n environment = cls.create(config['env_name'])\n\n # create groups and drivers\n groups = config['groups']\n environment.add_groups(groups)\n\n # create address pools\n ...
[ "0.68658125", "0.6727081", "0.6108912", "0.5849166", "0.57864475", "0.568876", "0.56822664", "0.56173056", "0.5602291", "0.55731046", "0.5559364", "0.5544826", "0.55369717", "0.5536891", "0.55214137", "0.551213", "0.5495139", "0.54895777", "0.5463578", "0.546074", "0.5453091"...
0.5761449
5
This function returns a geopandas.GeoDataFrame of Census cartographic files.
def get_geocen_df(quality = str(), year = str(), area_type = str()): try: url = f"https://raw.githubusercontent.com/uscensusbureau/citysdk/master/v2/GeoJSON/{quality}/{year}/{area_type}.json" df = gpd.read_file(url) return df except Exception as err: print(f'An error occured. All...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_california_gps():\n data_file = POOCH.fetch(\"california-gps.csv.xz\")\n data = pd.read_csv(data_file, compression=\"xz\")\n return data", "def _load_county_geometry() -> geopandas.GeoDataFrame:\n\tfilename = shapefiles_folder / \"cb_2016_us_county_500k\"\n\ttable = read_geometry(filename)\n\n...
[ "0.6832814", "0.6532611", "0.6293799", "0.6203937", "0.60543555", "0.59094113", "0.58942777", "0.58816785", "0.5812878", "0.58124274", "0.57805127", "0.5750591", "0.573446", "0.5673162", "0.5670161", "0.56692976", "0.56374586", "0.5619743", "0.5615491", "0.56092465", "0.55871...
0.5527261
24
Initialize all of the device's attributes.
def _initialize_data(self): self.unique_id = 123 self.gas_valve_open = False self.buffer_valve_open = False self.pump_valve_open = False self.operatingmode = 0 self.sample_pressure_high_limit = 100 self.sample_pressure_low_limit = 10 self.sample_pressur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initAttributes(self):\n CCSDS.DU.DataUnit.initAttributes(self)\n self.dataFieldHeaderFlag = 0\n self.setPacketLength()", "def doInitializeDevice(self):\n super().doInitializeDevice()", "def init_attrs(self):\n raise NotImplementedError", "def initialize_devices(self):\n if n...
[ "0.7620945", "0.7278083", "0.69964105", "0.68729836", "0.6836984", "0.6807749", "0.67740756", "0.6723671", "0.67173356", "0.66833377", "0.66395026", "0.65606105", "0.65479326", "0.64856035", "0.6483863", "0.6443094", "0.63954884", "0.6370202", "0.63119245", "0.6282396", "0.62...
0.61178464
33
Process the given path url to determine the scheme.
def parse_file_uri(path): p = urlparse.urlparse(path) if p.scheme in ["https", "http"]: return True, path elif p.scheme == "file": # url to path name, i.e: convert %20 to space path = urllib.url2pathname(p.path) return False, os.path.abspath(os.path.join(p.netloc, path)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetSchemeFromUrl(url):\n return __ParseUrl(url)[0]", "def extract_scheme(url):\n return urlsplit(url, \"http\").scheme", "def _urlparse_splitscheme(url):\r\n # The scheme is valid only if it contains these characters.\r\n scheme_chars = \\\r\n \"abcdefghijklmnopqrstuvwxyz0123456789+-.\"\r\n\r\n s...
[ "0.72814435", "0.7062279", "0.6585608", "0.65649164", "0.6485467", "0.6460558", "0.6267896", "0.6144681", "0.60696983", "0.6048615", "0.60457754", "0.6036878", "0.59956837", "0.59841686", "0.59690565", "0.5832897", "0.5792033", "0.57674426", "0.57235557", "0.57179797", "0.568...
0.5582725
30
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`.
def plot_confusion_matrix(cm, classes, normalize=False, title='Confusion Matrix', cmap=plt.cm.Blues): if normalize: cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] print("Normalized confusion matrix") else: print('Confusion Matrix, without normalization') plt.imshow(cm, inte...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n...
[ "0.81949747", "0.80953693", "0.80294114", "0.8019143", "0.79937863", "0.79912597", "0.7980661", "0.79754096", "0.7960909", "0.79568285", "0.79377204", "0.79348296", "0.7934468", "0.79314184", "0.79262596", "0.792439", "0.79241437", "0.79229194", "0.7922838", "0.7922132", "0.7...
0.79003334
27
Return evaluation metrics for given model on given train and test sets.
def evaluate_test(model, history, class_labels, train_X, test_X, train_y, test_y): train_loss, train_acc = model.evaluate(train_X, train_y, verbose=0) test_loss, test_acc = model.evaluate(test_X, test_y, verbose=0) print('Accuracy \n Train: %.3f, Test: %.3f' % (train_acc, test_acc)) print('Loss \n Train...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate_model(model, testset):\n\n # Sort data by top level label to ease inspection\n testset = testset.sort_using_layer(-1, reverse=True)\n\n # Feed the samples to the model to obtain each layers' activations\n v = testset.get_layer(0)\n hs = model.transform(v)[1:]\n\n # Read model weights...
[ "0.738038", "0.73127115", "0.72855484", "0.71372217", "0.71338505", "0.7091663", "0.7032691", "0.70161164", "0.70137024", "0.700338", "0.7001627", "0.69800854", "0.69596195", "0.695848", "0.69472855", "0.69203967", "0.69185114", "0.6883289", "0.68369806", "0.68326753", "0.680...
0.6781248
22
Initialize a dictionary to store meg data.
def _init_meg_map_dict(bands, length=0): # Initialize dictionary meg_map = dict() # Add oscillation bands for band in bands: meg_map[band] = np.zeros(length) return meg_map
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__ (self):\n self.tag = 0\n self.mDict = {}", "def __init__(self):\n self.metadata = {}\n self.geometry = {'array': None, \n 'geom': None, \n 'wkt': None}", "def _init_data(self, data):\n assert type(data) is dict, \"d...
[ "0.65221053", "0.6519056", "0.6435812", "0.6426081", "0.63085574", "0.6253862", "0.62165797", "0.6209712", "0.6182277", "0.6175457", "0.6171431", "0.61652136", "0.6152268", "0.6128132", "0.6106072", "0.6094757", "0.6087292", "0.60812783", "0.60812783", "0.60812783", "0.608127...
0.7191502
0
Pulls pretrained DeepLabV3+ from url This is tf.keras implementation of
def __call__(self): custom_obj = {'tf': tf, 'relu6': tf.nn.relu6} wfile = self._get_model_weights() model = tf.keras.models.load_model(wfile, custom_objects=custom_obj) if not self._trainable: # freeze encoder layers up to # expanded_conv_16_project_BN ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pretrained(name=\"ld_wiki_tatoeba_cnn_21\", lang=\"xx\", remote_loc=None):\n from sparknlp.pretrained import ResourceDownloader\n return ResourceDownloader.downloadModel(LanguageDetectorDL, name, lang, remote_loc)", "def pretrained(name=\"classifierdl_use_trec6\", lang=\"en\", remote_loc=None):...
[ "0.6629888", "0.6493069", "0.627831", "0.612835", "0.6115105", "0.61075747", "0.6104076", "0.6082155", "0.6082155", "0.6078139", "0.6067847", "0.60656", "0.6035227", "0.6028215", "0.5997613", "0.59751064", "0.594546", "0.5934192", "0.5929656", "0.59257925", "0.58849776", "0...
0.0
-1
Return the number of rows.
def rowCount(self, parent=QtCore.QModelIndex()) -> int: return len(self.__layers)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getNumRows(self) -> int:\n ...", "def num_rows(self):\n return (len(self.rows))", "def row_count(self) -> int:\n return len(self.rows)", "def row_count(self) -> int:\n return len(self.rows)", "def num_rows(self):\n return len(self.rows)", "def get_num_rows(self):\n ...
[ "0.9221344", "0.8939995", "0.8883343", "0.8883343", "0.8881884", "0.88316065", "0.8796254", "0.87434655", "0.8638738", "0.8571888", "0.8547149", "0.85056275", "0.8504988", "0.8499684", "0.84940827", "0.8438511", "0.8278957", "0.8185211", "0.81843865", "0.81450695", "0.8119182...
0.0
-1
Utility method that always returns a list. If key exist and the value is a list in d then that list is returned, otherwise, an empty list is returned.
def GetFromDictList(d, key): l = d.get(key, []) if type(l) != list: return [] return l
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getlist(self, key):\n \n value = self.get(key, [])\n if value is None or isinstance(value, (list, tuple)):\n return value\n else:\n return [value]", "def key_value_list(d):\n if not isinstance(d, dict) and not isinstance(d, list):\n return []\n\n ...
[ "0.72853464", "0.7013545", "0.7013545", "0.6771207", "0.67573655", "0.65821946", "0.63759434", "0.63417846", "0.6174591", "0.61409533", "0.60571563", "0.5963631", "0.59533596", "0.58586586", "0.58340245", "0.5809507", "0.5805185", "0.5793023", "0.5779125", "0.5757464", "0.573...
0.79954433
0
Backwards compatiable load function that accepts persisted yaml files from the PaperDoll since before it was corified and moved to /Script.
def NastyYamlLoad(yamlStr): import paperDoll as PD sys.modules[PD.__name__] = PD instance = None try: blue.statistics.EnterZone('yaml.load') instance = yaml.load(yamlStr, Loader=yaml.CLoader) except Exception: log.LogError('PaperDoll: Yaml parsing failed for data', yamlStr) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_datas(self) -> tp.Dict[str, dict]:\n with open(self._file, \"r\") as stream:\n try:\n load: tp.Dict[str, dict] = yaml.safe_load(stream)\n logger.info(\"YAML imported\")\n return load\n except yaml.YAMLError as exc:\n ...
[ "0.7281001", "0.72235364", "0.70129895", "0.6895817", "0.68383574", "0.67873293", "0.6784121", "0.6781646", "0.67720926", "0.67609584", "0.674579", "0.6664529", "0.66637355", "0.66241574", "0.6623994", "0.6611047", "0.6610229", "0.65818065", "0.6576585", "0.65561444", "0.6532...
0.65845966
17
Call to get the owner of the bot.
def owner(self) -> discord.User: if self.config.owner_id: return self.get_user(self.config.owner_id) if self.owner_ids: return self.get_user(self.config.owner_ids[0]) return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def owner(self) -> None:\n return self.bot.get_user(self.bot.config.owner_ids[0])", "def bot_owner_id(self):\n return self._bot_owner_id", "def owner(self):\n answer = self._call('owner')\n return answer.owner", "def get_owner(self):\n return self.settings.get(\"owner\", No...
[ "0.8326994", "0.78402513", "0.7766874", "0.74439675", "0.7442147", "0.7386024", "0.7237047", "0.72207123", "0.7179173", "0.7179173", "0.7121887", "0.7121887", "0.7118069", "0.70490706", "0.7042409", "0.69483256", "0.69077873", "0.6869944", "0.68012583", "0.6789864", "0.675047...
0.77768236
2
Call to get the owner of the bot.
def owner(self) -> None: return self.bot.get_user(self.bot.config.owner_ids[0])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bot_owner_id(self):\n return self._bot_owner_id", "def owner(self) -> discord.User:\n if self.config.owner_id:\n return self.get_user(self.config.owner_id)\n if self.owner_ids:\n return self.get_user(self.config.owner_ids[0])\n return None", "def owner(self...
[ "0.78402513", "0.77768236", "0.7766874", "0.74439675", "0.7442147", "0.7386024", "0.7237047", "0.72207123", "0.7179173", "0.7179173", "0.7121887", "0.7121887", "0.7118069", "0.70490706", "0.7042409", "0.69483256", "0.69077873", "0.6869944", "0.68012583", "0.6789864", "0.67504...
0.8326994
0
This section is responsible for creating walls within each room.
def select_walls(matrix, xaxis, yaxis, zaxis): clear() print("Now we're going to construct the interior of the rooms.") print("I'm going to present you with all rooms that have been selected.") print("I want you to indicate where the walls should be placed in each room.") print("Just like room selec...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_walls(self):\n for x in range(self.width):\n self.add_thing(Wall(), (x, 0))\n self.add_thing(Wall(), (x, self.height - 1))\n\n for y in range(self.height):\n self.add_thing(Wall(), (0, y))\n self.add_thing(Wall(), (self.width - 1, y))", "def add_w...
[ "0.75122344", "0.74758214", "0.72311574", "0.7036463", "0.69679815", "0.69407743", "0.6887307", "0.68627524", "0.68519384", "0.6831062", "0.6793732", "0.67647225", "0.67353094", "0.6638775", "0.66148823", "0.65871984", "0.654321", "0.6524759", "0.65238833", "0.6470802", "0.64...
0.56316346
80