query
stringlengths
9
9.05k
document
stringlengths
10
222k
metadata
dict
negatives
listlengths
30
30
negative_scores
listlengths
30
30
document_score
stringlengths
4
10
document_rank
stringclasses
2 values
This function is called every frame in order to move the bubble by adding velocity to the current position.
def update_Bubble(self): self.Bubble_initial_pos[0] += self.Bubble_vel[0] self.Bubble_initial_pos[1] += self.Bubble_vel[1] self.x0 = self.Bubble_initial_pos[0] - self.Bubble_radius self.y0 = self.Bubble_initial_pos[1] - self.Bubble_radius self.x1 = self.Bubble_initial_pos[0] + self.Bubble_radius self.y1...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __move__(self):\n v = self.velocity\n p = self.position\n p += v\n self.rect.x = round(p.x)\n self.rect.y = round(p.y)", "def move(self) -> None:\n self.delta_time += 1 / 30 # FPS is 30 frames per second\n\n if self.is_active:\n self.y -= self.velo...
[ "0.72875935", "0.7223443", "0.7160067", "0.71597624", "0.7157398", "0.7047452", "0.70189065", "0.6950814", "0.69158775", "0.690638", "0.68649626", "0.68400294", "0.68346345", "0.6818551", "0.6810752", "0.6804744", "0.67949694", "0.6792838", "0.6777871", "0.67754734", "0.67619...
0.7511647
0
calculate the distance between the center of the bubble to the vertical boundaries so if a bubble hits a boundary the velocity will be reversed and the bubble will bounced back
def check_boundary(self): if self.Bubble_initial_pos[0] <= self.Bubble_radius or self.Bubble_initial_pos[0] >= self.tk_pic.width - self.Bubble_radius: self.Bubble_vel[0] = -self.Bubble_vel[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _wall_bounce(self):\n\n if (self.pos[0] < self.rad):\n self.vel[0] = abs(self.vel[0])\n elif (self.pos[0] > self.disp_size[0]-self.rad):\n self.vel[0] = -abs(self.vel[0])\n if (self.pos[1] < self.rad):\n self.vel[1] = abs(self.vel[1])\n elif (self.po...
[ "0.6740721", "0.6735434", "0.65934277", "0.6589779", "0.6537949", "0.6521331", "0.64413774", "0.6283957", "0.62451136", "0.62337214", "0.6190644", "0.61282355", "0.6126832", "0.6122662", "0.6113883", "0.60888785", "0.6078052", "0.60620725", "0.59820735", "0.5979536", "0.59465...
0.69175285
0
checking if the bubble hits the top boundary or checking against other bubbles in a set
def is_stuck(self, Set, list_of_grids): if self.Bubble_initial_pos[1] <= self.Bubble_radius: self.min_dist_grid(list_of_grids, self.Bubble_initial_pos) self.Bubble_vel = [0, 0] Set.add(self) return True for ball in set(Set): if dist(self.Bubble_initial_pos, ball.Bubble_initial_pos) <= (2.0*self.Bu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contains(outer, inner):\n return inner.tl.x >= outer.tl.x and inner.tl.y >= outer.tl.y and \\\n inner.br.x <= outer.br.x and inner.br.y <= outer.br.y", "def _check_autos_top(self):\n\t\tscreen_rect = self.screen.get_rect()\n\t\tfor auto in self.autos.sprites():\n\t\t\tif auto.rect.top <= screen_...
[ "0.6342368", "0.61449707", "0.61386395", "0.61384434", "0.61041063", "0.6046054", "0.6021348", "0.6003862", "0.5977543", "0.5972233", "0.5964116", "0.5960889", "0.5958814", "0.5912531", "0.5894147", "0.5886586", "0.5845208", "0.58375573", "0.5833458", "0.5832912", "0.58169484...
0.6749455
0
this function takes a set parameter which includes all the bubbles already shooted and check against tne new bubble for adjacency, if this is the case. it puts the adjacent bubble inside the adjacency dictionary
def build_adj_dict(self, Set): if len(Set): for bubble in Set: distance = dist(bubble.Bubble_last_pos, self.Bubble_last_pos) if distance <= (bubble.Bubble_radius * 1.2 + self.Bubble_radius * 1.2): # add edge between new bubble and existing bubble if bubble.color not in self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bubble_detection(self, sorted_node):\n \n source = sorted_node[0]\n bubble = {} # for storing result\n potential = {} # for storing path of potential entrance\n\n # transverse topologically sorted node\n for i in sorted_node:\n \n if ...
[ "0.6080883", "0.5986052", "0.58647454", "0.5485936", "0.54382175", "0.5356066", "0.52835506", "0.52652603", "0.52627796", "0.5237947", "0.5234397", "0.5215227", "0.519121", "0.51909536", "0.5185811", "0.51854384", "0.5177779", "0.5175422", "0.51465696", "0.5146367", "0.513209...
0.7417326
0
after shooting the current bubble we need to check the same color chain list and basically do a DFS chdecking the adjacent dictionary of the current bubble and go through all the neighbors and make a list
def get_bubble_chain(self, same_color_chain_list): if self.color in self.adj_dict.keys(): for bubble in self.adj_dict[self.color]: if bubble not in same_color_chain_list: same_color_chain_list.append(bubble) bubble.get_bubble_chain(same_color_chain_list) return same_color_chain_list
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depthFirstSearch(problem):\r\n \"*** YOUR CODE HERE ***\"\r\n node = problem.getStartState()\r\n if (problem.isGoalState(node)):\r\n return [] # no need to make any moves of the start state is goal\r\n start = (node, 'NoDirection',0)\r\n\r\n frontier_queue = Stack() # queue for frontier\r\n frontier_q...
[ "0.6156264", "0.61540574", "0.6060593", "0.6047061", "0.60353357", "0.6003812", "0.5869801", "0.5858092", "0.5761984", "0.5755588", "0.57477355", "0.57311314", "0.57289463", "0.5715091", "0.57118684", "0.5711063", "0.56961477", "0.56884044", "0.56866187", "0.56659824", "0.566...
0.64001536
0
iterating through adjacent dictioanry of the bubble and if the adjacent bubble is in the same color chain list we remove the adjacent bubble from adjacent dictionary and continue the process recursively.
def bubble_chain_delete(self, same_color_chain_list): for bubble in self.adj_dict[self.color]: if bubble in same_color_chain_list: self.adj_dict[self.color].remove(bubble) bubble.bubble_chain_delete(same_color_chain_list) del same_color_chain_list[:]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bubble_chain(self, same_color_chain_list):\n\n\t\tif self.color in self.adj_dict.keys():\n\t\t\tfor bubble in self.adj_dict[self.color]:\n\t\t\t\tif bubble not in same_color_chain_list:\n\t\t\t\t\tsame_color_chain_list.append(bubble) \n\t\t\t\t\tbubble.get_bubble_chain(same_color_chain_list)\n\t\treturn sa...
[ "0.584494", "0.57048845", "0.56603295", "0.5635225", "0.5635225", "0.5590221", "0.558908", "0.5570247", "0.5566825", "0.546077", "0.5446849", "0.5402084", "0.5393324", "0.5373242", "0.53316444", "0.5321955", "0.52458644", "0.5161439", "0.5151174", "0.5136839", "0.5096091", ...
0.7163129
0
Build figure showing evolution of number of cases vs. time for all countries. The visibility of traces is set to 0 so that the interactive app will toggle the visibility.
def make_timeplot(df_measure, df_prediction): # mode = 'confirmed' mode = 'active' df_measure_confirmed = df_measure[mode] colors = px.colors.qualitative.Dark24 n_colors = len(colors) fig = go.Figure() for i, country in enumerate(df_measure_confirmed.columns): fig.add_trace(go.Scatte...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n \n \"\"\" Download and load data\"\"\"\n dfs = get_data()\n \n \"\"\" Preprocess data, combine rows for country provinces\"\"\"\n combine_list = [\"Australia\", \"US\", \"Canada\", \"Mainland China\", \"China\"]\n for key in dfs.keys():\n dfs[key] = preprocess(df=dfs[key],...
[ "0.6106977", "0.590167", "0.58638334", "0.5849094", "0.58287686", "0.58038944", "0.5781595", "0.57352144", "0.5714658", "0.56770647", "0.56719023", "0.56667536", "0.5655021", "0.56501675", "0.5631814", "0.5609977", "0.5589845", "0.5569374", "0.5558337", "0.55570006", "0.55495...
0.60101783
1
Returns the value of the Legendre function of order n at mu using the recursive relationship.
def Legendre( n, mu, checkXRange = True ) : if( n < 0 ) : raise ValueError( "\nError, n = %d < 0" % n ) if( checkXRange and ( abs( mu ) > 1 ) ) : raise ValueError( "Legendre: |mu| > 1; mu = %g" % mu ) Pn = 0. Pnp1 = 1. n_ = 0 twoNp1 = 1 while( n_ < n ) : Pnm1 = Pn Pn = Pnp1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate( self, mu ) :\n\n P = 0.\n for l, c_l in enumerate( self.coefficients ) : P += ( l + 0.5 ) * c_l * Legendre( l, mu, checkXRange = False ) \n return( P )", "def kernel(mu, N):\n\n # Check that -1 <= mu <= 1\n mu = np.clip(mu, -1, 1)\n\n # Need Legendre polynomials\n l...
[ "0.6603976", "0.59581256", "0.56422675", "0.55663896", "0.5556986", "0.5553476", "0.54552644", "0.54552644", "0.5419963", "0.5384031", "0.5382197", "0.53664225", "0.53317434", "0.53305066", "0.53236717", "0.53169984", "0.5280863", "0.52714354", "0.52698654", "0.52614695", "0....
0.78307503
0
Sets the (l+1)^th Legendre coefficient to c_l. l must be less than or equal to lMax.
def __setitem__( self, l, c_l ) : if( l == len( self ) ) : self.coefficients.append( float( c_l ) ) else : self.coefficients[l] = float( c_l )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setLCLimits(*args):\n args[0].Limit.LCLimit.lc_limit = args[1]", "def lx(self, l: int, lfrac: float) -> float:\n self._check_lfrac(lfrac)\n self._raise_if_not_line(l)\n result = self._read_inline(f\"lx({l},{lfrac})\")\n return result", "def setRLC(self, r, l, c):\n ...
[ "0.5854318", "0.5695988", "0.55575544", "0.5549274", "0.5408312", "0.5369444", "0.53651094", "0.53555906", "0.5324815", "0.5274224", "0.52695966", "0.52662396", "0.5258872", "0.5255069", "0.52126175", "0.51849425", "0.517177", "0.5165747", "0.5158866", "0.5154706", "0.5151277...
0.62202406
0
Returns a series that is the sum of self and other. Other must be of type series.
def __add__( self, other ) : try : other = float( other ) c_ls = self.copy( ) for l, c_l in enumerate( c_ls ) : c_ls.coefficients[l] += other except : self.checkSameSeriesType( other ) c_l1, c_l2 = self, other if( len( self ) < len...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iadd__(self, other):\n\n other_data = self._setup_numeric(other)\n self.data[:] = self.data + other_data\n\n return self", "def add(self, other):\n return Rational(self.numerator * other.denominator + other.numerator * self.denominator,\n self.denominator * other....
[ "0.6732401", "0.67292297", "0.67142594", "0.66830236", "0.66806585", "0.6671922", "0.6629293", "0.6621051", "0.6610413", "0.6592071", "0.65873456", "0.6580911", "0.65693367", "0.65573466", "0.65534055", "0.65260255", "0.65138066", "0.65138066", "0.65107846", "0.65107846", "0....
0.7240741
0
Returns a new series that is each coefficient of self multiplied by value. Value must be convertible to a float.
def __mul__( self, value ) : value_ = float( value ) c_ls = self.copy( ) for l, c_l in enumerate( self ) : c_ls[l] *= value return( c_ls )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __mul__(self, value):\n cls = self.__class__\n return cls(value*self.x, value*self.y, value*self.z)", "def __ipow__(self, d_value: float):\n self.set_value(self.get_value() ** d_value)\n return self", "def at_value(self, *value):\n result = 0\n for x in value:\n ...
[ "0.6526637", "0.59920275", "0.5877977", "0.57127595", "0.56562215", "0.565022", "0.5612607", "0.55870175", "0.5569441", "0.5535825", "0.55135864", "0.5511268", "0.54755336", "0.54657716", "0.5462264", "0.5456879", "0.5451897", "0.5451897", "0.54485744", "0.5428359", "0.540833...
0.70890975
0
Returns a string representation of the Legendre coefficients of self.
def __str__( self ) : return( ' '.join( [ "%g" % c_l for c_l in self.coefficients ] ) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self) -> str:\n polynomial = \"\"\n for i in range(self.degree, -1, -1):\n if self.coefficients[i] == 0:\n continue\n elif self.coefficients[i] > 0:\n if polynomial:\n polynomial += \" + \"\n else:\n ...
[ "0.7132573", "0.7088107", "0.7008161", "0.6643579", "0.6630837", "0.65799516", "0.6563335", "0.6466858", "0.64041", "0.6261458", "0.61700726", "0.60786355", "0.60670334", "0.6052568", "0.60470456", "0.59455264", "0.59455264", "0.5886966", "0.5853961", "0.5853961", "0.5837405"...
0.7432365
0
Returns the (l+1)^th Legendre coefficient. Returns 0 if l is greater than lMax. This is like __getitem__ but allows for l to be greater than lMax.
def getCoefficientSafely( self, l ) : if( l >= len( self ) ) : return( 0. ) return( self.coefficients[l] )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def L(self) -> float:\n return self._L", "def get_index_lm(l, m):\n return (l+1)**2 -1 -l + m", "def lmax(self):\n return self._get_mean_and_samples_attribute('lmax')", "def rough_l_max(L):\r\n # TODO: Check if L is sparse or not, and handle the situation accordingly\r\n\r\n l_max ...
[ "0.5956594", "0.56653345", "0.56390405", "0.549751", "0.5469573", "0.5406137", "0.5384759", "0.5371135", "0.532755", "0.5325025", "0.5284894", "0.5221713", "0.5215056", "0.5202324", "0.5152489", "0.51466537", "0.51410526", "0.5139852", "0.5134509", "0.51142156", "0.5101439", ...
0.61501306
0
Translate a series XML element into its python xData class.
def parseXMLNode( cls, xDataElement, xPath, linkData, axes = None, **kwargs ) : xPath.append( xDataElement.tag ) domainMin, domainMax = cls.fixedDomain( ) attrs = { 'label' : None, 'index' : None, 'value' : None, 'domainMin' : domainMin, 'domainMax' : domainMax, 'lowerIndex' : 0 } attr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _xml_to_series(self, xml):\n d = self._xml_to_dict(xml)\n d = d['Data']\n if isinstance(d, basestring):\n raise EmptyXMLError('Provided xml has no content.')\n shows = d['Series'] #list of dicts\n if self.get_first:\n if isinstance(shows, list):\n ...
[ "0.7209701", "0.5524327", "0.5493264", "0.5473774", "0.5464128", "0.5341623", "0.5281256", "0.52495944", "0.5248997", "0.5244229", "0.51978624", "0.51956004", "0.5122658", "0.5092953", "0.5086773", "0.5048923", "0.502929", "0.4988998", "0.49827087", "0.49827087", "0.49813077"...
0.6444945
1
Using the Legendre coefficients, this method calculates f(mu) and returns it.
def evaluate( self, mu ) : P = 0. for l, c_l in enumerate( self.coefficients ) : P += ( l + 0.5 ) * c_l * Legendre( l, mu, checkXRange = False ) return( P )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Legendre( n, mu, checkXRange = True ) :\n\n if( n < 0 ) : raise ValueError( \"\\nError, n = %d < 0\" % n )\n if( checkXRange and ( abs( mu ) > 1 ) ) : raise ValueError( \"Legendre: |mu| > 1; mu = %g\" % mu )\n Pn = 0.\n Pnp1 = 1.\n n_ = 0\n twoNp1 = 1\n while( n_ < n ) :\n Pnm1 = Pn...
[ "0.64417124", "0.595938", "0.5904728", "0.5848365", "0.5793681", "0.57124436", "0.56580293", "0.5592754", "0.555065", "0.5519865", "0.55143887", "0.5509193", "0.5488926", "0.54510695", "0.54483145", "0.54373556", "0.5436866", "0.54365134", "0.5432546", "0.5413616", "0.5411583...
0.71115977
0
Returns True if self is isotropic.
def isIsotropic( self ) : for coefficient in self[1:] : if( coefficient != 0. ) : return( False ) return( True )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_isotropic(self):\n return self.fibres is None", "def is_antipodal(self):\n return self._.r if self._.antipodal else False", "def is_robotic(self) -> bool:\n return ATTRIBUTE.Robotic.value in self.type_data.attributes", "def is_robotic(self) -> bool:\n return ATTRIBUTE.Robot...
[ "0.6674173", "0.64685154", "0.64624655", "0.64624655", "0.6391895", "0.636559", "0.61655384", "0.6147174", "0.6121771", "0.60040575", "0.6002268", "0.59890157", "0.5985029", "0.5967995", "0.5946954", "0.59440166", "0.5927661", "0.59239507", "0.59239507", "0.5911612", "0.59031...
0.65501744
1
Using the polynomial coefficients, this method calculates p(x) and returns it.
def evaluate( self, x ) : P = 0. for c_l in reversed( self.coefficients ) : P = c_l + x * P return( P )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def polyval(p, x):\r\n val = 0\r\n ii = len(p) - 1\r\n for i in range(len(p) - 1):\r\n val += p[i] * (x ** ii)\r\n ii -= 1\r\n return val + p[-1]", "def calculate(self, x):\n result = 0\n\n for index, polynomial in self.polynomials.items():\n result += polynomia...
[ "0.76876384", "0.7051328", "0.69178843", "0.69167584", "0.6904733", "0.68358755", "0.68264157", "0.68209225", "0.6787622", "0.677656", "0.66627693", "0.665794", "0.664937", "0.664921", "0.6647714", "0.6580837", "0.65802336", "0.65658826", "0.654453", "0.6528762", "0.6490086",...
0.76625
1
This method returns 'RAW'.
def get_format(self): return "RAW"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw(self):\n return self._raw_string", "def raw(self):\n return self.__raw", "def raw(self):\n return self._raw", "def raw(self):\n return self._raw", "def string_raw(self):\n return \"x%x\" % self.encoded", "def raw(self) -> str:\n return \"\".join(seg.raw for...
[ "0.7502845", "0.7163016", "0.7101279", "0.7101279", "0.69248754", "0.68336487", "0.6782092", "0.6782092", "0.6578932", "0.652213", "0.6412629", "0.63334876", "0.6205379", "0.61936384", "0.6184491", "0.6145013", "0.6077389", "0.60748297", "0.6074065", "0.6068648", "0.60305035"...
0.85680264
0
Returns the key in its encoded format.
def get_encoded(self): return self.key
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key(self):\n return self._key.decode('utf-8')", "def _encode_key(self, key: str) -> str:\n return key", "def _encode_key(self, key):\n return key.encode() if isinstance(key, str) else key", "def serialize_key(key: str) -> bytes:\n return key.encode(\"utf-8\")", "def convert_key_...
[ "0.8215692", "0.81841284", "0.78692085", "0.7757779", "0.7640764", "0.7590201", "0.7566031", "0.7489003", "0.747827", "0.7348015", "0.72925466", "0.72872823", "0.72589284", "0.72465247", "0.72465247", "0.72465247", "0.72465247", "0.72465247", "0.72465247", "0.72465247", "0.72...
0.85462946
0
Collision detection with the walls of the container
def detectWallCollision(self): if self.posn_x > cw - self.ball_width: # Collision with right-hand container wall. self.velocity_x = -self.velocity_x * self.coef_restitution # reverse direction. self.posn_x = cw - self.ball_width * 1.1 # anti-s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wall_collision(self):\n border_box_pos_1 = self.box_1.x - self.box_1.width/2\n\n if (border_box_pos_1) <= 0:\n return True\n else:\n return False", "def collision(self):\n # Check collision with walls\n (x_coord, y_coord) = (self.x_coord[0], self.y_coo...
[ "0.76513547", "0.7455491", "0.74258953", "0.7281895", "0.7255909", "0.7159387", "0.71485865", "0.71444386", "0.7023218", "0.7013492", "0.69634444", "0.69453317", "0.6879182", "0.68535346", "0.6850642", "0.6817415", "0.6763192", "0.6747918", "0.67314297", "0.66993546", "0.6680...
0.7787998
0
Runs the logic using a collection of object as input
def run(self, objects: typing.Any) -> None: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _run(self):\n self._algorithm(self._list, self)", "def process(self, lists, subqueries):\n pass", "def loop_over_objects_helper(self, object_type, func, *args, **kwargs):\n # Grab the given object type from the model map. If the objects\n # are not present, raise a KeyError.\n ...
[ "0.64997923", "0.62685126", "0.5997839", "0.59453803", "0.58588666", "0.5838392", "0.57906306", "0.57193726", "0.5654708", "0.55780613", "0.55450344", "0.553748", "0.5489368", "0.5441914", "0.54274994", "0.5420949", "0.5394527", "0.5388258", "0.5377579", "0.53677344", "0.5354...
0.63551706
1
Determines the path loss for a packet travelling from src location to destination location. Packet was sent with tx_config configuration.
def path_loss(self, src_loc, dest_loc, tx_config): dist = src_loc.distance(dest_loc) return self.Lpld0 + 10*self.gamma*log10(dist/float(self.d0))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_rssi(self, src_loc, dest_loc, tx_config):\n path_loss = self.path_loss(src_loc, dest_loc, tx_config)\n return tx_config['txp'] - path_loss", "def loss(self, walks_emb_src, walks_emb_dst, neg_emb):\n path_src = tf.reshape(walks_emb_src, shape=[-1, self.walk_len, self.dim])\n path...
[ "0.674986", "0.60227305", "0.5851387", "0.53834826", "0.5176884", "0.5174622", "0.5126004", "0.50792956", "0.5075611", "0.500634", "0.4984215", "0.49827313", "0.4960117", "0.49503386", "0.49472216", "0.49341878", "0.49263918", "0.49155793", "0.4891904", "0.48906642", "0.48898...
0.72606647
0
Based on the tx configuration, determine the RSSI of the pkt at dest.
def calculate_rssi(self, src_loc, dest_loc, tx_config): path_loss = self.path_loss(src_loc, dest_loc, tx_config) return tx_config['txp'] - path_loss
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rssi(self) -> float:\n # Read RSSI register and convert to value using formula in datasheet.\n return -self._read_u8(_REG_RSSI_VALUE) / 2.0", "def get_in_RSSI(self) -> int:\n if self.in_RSSI != None:\n return self.in_RSSI\n return 0", "def _computeRSSI(self, mote, nei...
[ "0.5984466", "0.57516813", "0.57059294", "0.5567797", "0.54825824", "0.537442", "0.52905333", "0.52889425", "0.5037328", "0.48434648", "0.48133722", "0.4779608", "0.47561026", "0.4742333", "0.47392353", "0.4727579", "0.47151554", "0.4714786", "0.46503556", "0.4650297", "0.461...
0.7357441
0
Based on the sensitivity and TX configuration determine the maximum comms range. This is the range where the RSSI is equal to the sensitivity.
def max_comms_range(self, tx_config): return self.d0*exp( (tx_config['txp'] - self.Lpld0 - self.sensitivity[tx_config['sf']]) /(10*self.gamma))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_max_gains(self):\n return tuple([lib.is_SetHWGainFactor(self.hcam,0x800c+i,100)/100 for i in range(4)])", "def lmax(self):\n cond = (self.transmit / self.transmit.max()) > 1./100\n return max(self.wavelength[cond])", "def getLimits(self):\n lims = [x * self.getSign() + self....
[ "0.6390648", "0.6270354", "0.6173292", "0.61217535", "0.6020237", "0.60165995", "0.59595704", "0.5935162", "0.58295065", "0.5764414", "0.57366824", "0.57298064", "0.5717924", "0.57154125", "0.570595", "0.5691025", "0.5680515", "0.5676426", "0.5651727", "0.5650576", "0.5639042...
0.76952827
0
A demonstration of the shiftreduce parser.
def demo(): from nltk import parse, CFG grammar = CFG.fromstring(""" S -> NP VP NP -> Det N | Det N PP VP -> V NP | V NP PP PP -> P NP NP -> 'I' N -> 'man' | 'park' | 'telescope' | 'dog' Det -> 'the' | 'a' P -> 'in' | 'with' V -> 'saw' """) sent = 'I saw a man in t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_shift(doctest):", "def apply_shift(text, shift):\n ### TODO.", "def build_decoder(shift):\n ### TODO.", "def test_operator_shift(self, test_dag):\n # Unpack the fixture\n dag, (op1, op2, op3, op4) = test_dag\n # Arrange the operators with a Label in the middle\n op1...
[ "0.62178683", "0.5718296", "0.56403923", "0.5574365", "0.5548652", "0.55287296", "0.55234", "0.54169196", "0.5321487", "0.53060097", "0.52379894", "0.5229038", "0.5229038", "0.52050644", "0.5087424", "0.5082732", "0.5081176", "0.5062432", "0.5037365", "0.5009065", "0.4988842"...
0.6531078
0
Gets an item pk, and renders it to HTML string to be insert. item is passed to the template (item_render_template) with context item, MEDIA_URL, STATIC_URL
def render(self, item): item = self.model._default_manager.get(pk=item) t = select_template(self.item_render_template) return t.render({ "MEDIA_URL": settings.MEDIA_URL, "STATIC_URL": settings.STATIC_URL, "item": item, })
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def purchase_item(item_id):\n\n item = get_item(item_id)\n\n return render_template('item_page.html', item=item)", "def item_detail(request, item_id):\n # Select product based on URL param\n item = SELECT('item', where=f'id = {item_id}', _print=False)\n\n context = {\n 'item': item,\n ...
[ "0.64942527", "0.64280474", "0.64015543", "0.6391801", "0.62767833", "0.6190961", "0.60706973", "0.60299075", "0.6025066", "0.6013051", "0.6002143", "0.5973874", "0.58614033", "0.5742975", "0.5734385", "0.5710842", "0.56530493", "0.5636068", "0.55900115", "0.5583476", "0.5574...
0.7327048
0
This is the most basic form that can be used to save the model. Useful for adding an instance quickly. It will _only_ pull required fields.
def get_minimal_add_form(self): # Get all the required fields and make a modelform for it. exclude_fields = [] for field in self.model._meta.fields: if field.blank: exclude_fields.append(field.name) instance_form = modelform_factory(self.model, for...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_model(self, request, instance, form, change):\n pass", "def make_form(self):", "def save(self, *args, **kwargs):\n step_numeral, step_name = kwargs.pop('step', (None, None))\n\n if step_numeral == 1:\n \"\"\"\n Basic Form: Application & File Uploader\n ...
[ "0.6487552", "0.6425866", "0.6395475", "0.61050564", "0.6084664", "0.6071691", "0.59957045", "0.5984506", "0.5904618", "0.5901611", "0.58907235", "0.5820635", "0.579715", "0.5766481", "0.5764703", "0.5751767", "0.5751443", "0.5696115", "0.56934285", "0.5678543", "0.5670781", ...
0.66471136
0
new_instance is the created instance of self.model or none, depending on if form.is_valid. Passed, for consistancy's sake to the template as "object" This view is csrf_exempt, which aparently conflicts with django's admin_view wrapper. This is problematic, as it exposes this view to anybody who knows the URL. @ Uploadi...
def add_view(self, request): instance_form = self.get_minimal_add_form() form = instance_form(request.POST, request.FILES, prefix=self.base_url()) new_instance = None if form.is_valid(): new_instance = form.save() template = select_template(self.item_add_t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_form(self, *args, **kwargs):\n form = super(PhotoCreateView, self).get_form(*args, **kwargs)\n form.instance = self.model(user=self.request.user)\n return form", "def _changeform_view(self, request, object_id, form_url, extra_context):\n to_field = request.POST.get(TO_FIELD_VA...
[ "0.68707997", "0.6645655", "0.6299408", "0.6197577", "0.6148819", "0.60302633", "0.5976359", "0.5936282", "0.59293664", "0.59227264", "0.5884773", "0.58750415", "0.58431286", "0.58412063", "0.57736975", "0.5757849", "0.5714333", "0.571321", "0.57058716", "0.5696463", "0.56889...
0.68890953
0
Act differently during frontendadmin(ajax) just reload the page.
def response_change(self, request, obj): # in these cases, the redirect is good if list(set(request.POST.keys()) & set(["_addanother", "_saveasnew", "_continue"])): return super(ServeeModelAdmin, self).response_change(request, obj) # we want to override the de...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_ajax(self):\r\n pass", "def response_add(self, request, obj):\r\n\r\n # in these cases, the redirect is good\r\n if list(set(request.POST.keys()) & set([\"_addanother\", \"_continue\"])):\r\n return super(ServeeModelAdmin, self).response_change(request, obj)\r\n\r\n ...
[ "0.67872304", "0.67808384", "0.6434937", "0.61325985", "0.60853684", "0.60397327", "0.59562564", "0.56881356", "0.56881356", "0.5658444", "0.5658444", "0.5648641", "0.5583236", "0.5546604", "0.5545976", "0.55168295", "0.55059016", "0.5488037", "0.547987", "0.54797786", "0.545...
0.71794033
0
Add the insert_classes to the template context.
def change_view(self, *args, **kwargs): if not kwargs.get("extra_context"): kwargs["extra_context"] = {} kwargs["extra_context"].update({ "insert_classes": self.admin_site.insert_classes, }) return super(ServeeModelAdmin, self).change_view(*args, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def context_processor(self, f):\n self.template_context_processors.append(f)\n return f", "def template_extra_functions(self):\n\t\treturn []", "def context_processors(self):\n return [\n 'leonardo.module.web.processors.page.add_page_if_missing',\n 'leonardo.module.we...
[ "0.53074515", "0.5232773", "0.5182725", "0.5136563", "0.49825484", "0.4918508", "0.48738423", "0.48681477", "0.48595372", "0.4854011", "0.48513415", "0.48496512", "0.48175302", "0.47874135", "0.47463384", "0.47449088", "0.4729792", "0.4728767", "0.4679898", "0.46660915", "0.4...
0.6078363
0
Removes a class from the insert_classes dictionary. This is useful if a third party registerd the class, and you want to edit it.
def unregister_insert(self, class_registered): insert_class = class_registered(self) if self.insert_classes.get(insert_class.base_url()): self.insert_classes.pop(insert_class.base_url())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drop_class(self, cls, ignore_instances=False):\n if ignore_instances:\n self.client.command(\n 'DROP CLASS {} UNSAFE'.format(cls.registry_name))\n else:\n self.client.command(\n 'DROP CLASS {}'.format(cls.registry_name))", "def remove_class(se...
[ "0.677817", "0.64633715", "0.63530385", "0.6161206", "0.6133437", "0.5975117", "0.587572", "0.58445567", "0.5810443", "0.57666874", "0.5766499", "0.5642622", "0.5572861", "0.55175626", "0.5512522", "0.54581606", "0.54308844", "0.53479004", "0.5342448", "0.53288907", "0.532503...
0.77176946
0
Add our custom views to the admin urlconf.
def get_urls(self): urls = super(ServeeAdminSite, self).get_urls() from django.conf.urls import patterns, url, include # Custom Views for path, view, name in self.custom_views: urls += patterns('', url(r'^%s$' % path, self.admin_view(view)), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_urls(self):\n from django.conf.urls import patterns, url\n\n def wrap(view):\n def wrapper(*args, **kwargs):\n return self.admin_site.admin_view(view)(*args, **kwargs)\n return update_wrapper(wrapper, view)\n\n info = self.model._meta.app_label, sel...
[ "0.69641805", "0.6957946", "0.6925975", "0.6830163", "0.66237915", "0.655973", "0.6506462", "0.64976776", "0.64515716", "0.6426359", "0.61631274", "0.6125907", "0.6113139", "0.60923207", "0.6085934", "0.59991777", "0.593703", "0.5930592", "0.5917166", "0.5911305", "0.5887767"...
0.7136453
0
Delay is added to the end of sliding window
def test_delay_is_added(self): sliding_window = SlidingWindow(SLIDING_WINDOW_SIZE) network_delay = 100 sliding_window.add_delay(network_delay) self.assertListEqual(sliding_window.delays, [network_delay])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_only_one_delay_in_window(self):\n sliding_window = SlidingWindow(SLIDING_WINDOW_SIZE)\n sliding_window.delays = [100]\n self.assertEqual(sliding_window.get_median(), -1)", "def test_window_moves_when_new_element_is_added(self):\n sliding_window = SlidingWindow(SLIDING_WINDOW_...
[ "0.67120695", "0.6611301", "0.6397901", "0.63865626", "0.6247225", "0.613232", "0.610431", "0.60738903", "0.598787", "0.5978602", "0.5901754", "0.5861907", "0.5767483", "0.5708435", "0.57012904", "0.5647375", "0.56368834", "0.5552368", "0.5504418", "0.550315", "0.55010825", ...
0.6828685
0
Sliding window moves forward when new element is added
def test_window_moves_when_new_element_is_added(self): sliding_window = SlidingWindow(SLIDING_WINDOW_SIZE) network_delays = [100, 101, 102, 103] for delay in network_delays: sliding_window.add_delay(delay) expected_window = [101, 102, 103] self.assertListEqual(sliding...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sliding_window(self, incr):\n\n start_val = incr - self._sw_val\n end_val = incr\n\n if end_val < len((self._array_dict['RSSI'])):\n for norm_arrays, sw_arrays in zip(self._array_dict.values(), self._sw_dict.items()):\n self._sw_dict[sw_arrays[0]] = norm_arrays[st...
[ "0.6407099", "0.6262832", "0.572742", "0.56406695", "0.5605781", "0.558722", "0.55864877", "0.5579424", "0.5578618", "0.5480919", "0.5468543", "0.5468479", "0.54672027", "0.54548794", "0.5436433", "0.543541", "0.5418146", "0.5414443", "0.54053897", "0.540163", "0.54001105", ...
0.6884597
0
Return 1 if window consists only of one delay
def test_only_one_delay_in_window(self): sliding_window = SlidingWindow(SLIDING_WINDOW_SIZE) sliding_window.delays = [100] self.assertEqual(sliding_window.get_median(), -1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def only_once(self) -> bool:\n return self.times == 1", "def WIN_BONUS() -> int:\n return 2", "def have_window(self) -> bool:\r\n return (\r\n self._first_enc_at is not None\r\n and (time.time() > self._first_enc_at + self.window_size)\r\n )", "def win_condition(...
[ "0.6120669", "0.5967327", "0.5824077", "0.5681338", "0.55996656", "0.552794", "0.5500834", "0.5461671", "0.5458871", "0.54479957", "0.5445786", "0.5444349", "0.54390913", "0.54297787", "0.5404225", "0.53687716", "0.5367317", "0.536625", "0.53505546", "0.53489333", "0.5348357"...
0.65569186
0
Split a datetime to date & time
def split_time_date(date_time=None): parsed_date_time = get_date_time(date_time) return { "date": parsed_date_time.strftime(app_constant.DATE_FORMAT), "time": parsed_date_time.strftime(app_constant.TIME_FORMAT) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_dt(dt):\n\n return str(dt).split('T')[0]", "def _splitTime(self, time): \n if (time):\n x = re.split(\"[-\\/\\s:]\", time)\n else:\n x = []\n # Pad the list to four elements (year,month,day,hour)\n while (len(x) < 4):\n x.append(No...
[ "0.74842346", "0.6733259", "0.6559034", "0.6395996", "0.6392102", "0.62619", "0.6228184", "0.6187185", "0.61774886", "0.61401385", "0.6133529", "0.6044404", "0.6043459", "0.60233825", "0.5892401", "0.58080775", "0.58048415", "0.58048415", "0.57950556", "0.57824", "0.57497704"...
0.702378
1
Month difference between two date
def month_difference(start_date, end_date): diff = get_date_difference(start_date, end_date, date_format=app_constant.DATE_FORMAT) return (diff.years * 12) + diff.months
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def diff_month(d1, d2):\n return ceil(abs((d1.year - d2.year) * 12 + d1.month - d2.month))", "def month_diff(date1, date2):\n # First make sure, that date2 > date1\n if date1.daysTo(date2) < 0:\n date_tmp = date1\n date1 = date2\n date2 = date_tmp\n years = date2.year() - date1.y...
[ "0.82325315", "0.8005704", "0.741271", "0.70641917", "0.65974706", "0.6472219", "0.64395374", "0.6343015", "0.6343015", "0.6265528", "0.62616324", "0.622663", "0.6211122", "0.6019535", "0.6005004", "0.5913367", "0.5909849", "0.58972967", "0.58922505", "0.5863856", "0.5855514"...
0.80673754
1
Construct a new date (future or past)
def get_future_date(start_date, days=0, months=0, years=0, date_format=app_constant.DATE_FORMAT): start_date = _get_date_time(date_time=start_date, datetime_format=date_format) return start_date + relativedelta(days=days, months=months, years=years)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dateByDelta(daysInTheFuture=1):\n\ttmDT = datetime.today() + timedelta(days=daysInTheFuture)\n\tnewDate = datetime(tmDT.year,tmDT.month,tmDT.day).date()\n\treturn newDate", "def create_past_date(self, days):\n past_date = datetime.now() - timedelta(days=days)\n return past_date.isoformat()", ...
[ "0.6429355", "0.63900787", "0.60867727", "0.5903733", "0.58893687", "0.5872935", "0.5819383", "0.5772095", "0.5758269", "0.57405734", "0.57303375", "0.5671708", "0.5663274", "0.56041557", "0.56016487", "0.5589651", "0.5586186", "0.55746186", "0.55397856", "0.5534919", "0.5501...
0.6847329
0
Convert a given time to a specified Timezone
def convert_timezone(date_time, tz=pytz.timezone('UTC'), datetime_format=app_constant.DATE_TIME_ZONE_FORMAT): date_time = _get_date_time(date_time=date_time, datetime_format=datetime_format) return date_time.astimezone(tz)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def localize_time(self, apitime):\n return self.feedzone.localize(apitime).astimezone(self.localzone)", "def convert_timezone(time):\n if time is None:\n return None\n from_zone = tz.tzutc()\n to_zone = tz.tzlocal()\n try:\n utc = datetime.strptime(time, \"%Y-%m-%dT%H:%M:%S.%fZ\"...
[ "0.69090134", "0.65010804", "0.641043", "0.6359306", "0.6335926", "0.62799233", "0.6257645", "0.6246228", "0.61895317", "0.61705077", "0.6158007", "0.61537564", "0.6142579", "0.61303157", "0.6061626", "0.60292166", "0.5995043", "0.59764725", "0.5971496", "0.5970153", "0.59701...
0.6869383
1
>>> remove_letter("a", "apple") 'pple' >>> remove_letter("a", "banana") 'bnn' >>> remove_letter("z", banana") 'banana' >>> remove_letter("i", "Mississippi") 'Msssspp'
def remove_letter(letter, strng):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_letter(letter, strng):\n remlet = \"\"\n for char in strng:\n if char != letter:\n remlet += char\n return remlet", "def string_letter_removal(word, letter):\n text_mod = \"\"\n for char in word:\n if char != letter:\n text_mod += char\n return tex...
[ "0.8298941", "0.7729498", "0.75472677", "0.7349093", "0.70963615", "0.7044786", "0.69434154", "0.6912378", "0.6608461", "0.65321374", "0.6377171", "0.6357978", "0.62362015", "0.6218578", "0.6200802", "0.6156349", "0.6135685", "0.6132042", "0.6126742", "0.6114257", "0.6113749"...
0.81897223
1
Produces a dictionary of tensors from a encoder and decoder models meeting certain architectural requirements.
def unpack_tensors(encoder, decoder): check_compatibility(encoder, decoder) x = encoder.inputs[0] tensor_dict = dict( x=x, z=encoder(x)[0], z_mu=encoder(x)[1], z_log_sigma=encoder(x)[2]) tensor_dict['y'] = decoder(tensor_dict['z']) tensor_dict['y_pred'] = decoder(tensor_dic...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _construct_encoders_decoders(self):\n self.enc_inp = {}\n self.dec_out = {}\n if self.encode_hints:\n self.enc_hint = {}\n if self.decode_diffs:\n self.node_dec_diff = hk.Linear(1)\n self.edge_dec_diff = (hk.Linear(1), hk.Linear(1), hk.Linear(1))\n self.graph_dec_diff = (hk.Line...
[ "0.6491345", "0.628663", "0.6172864", "0.6107827", "0.593901", "0.5870205", "0.5722494", "0.5674444", "0.566754", "0.56221086", "0.56219274", "0.5612807", "0.56075126", "0.55893755", "0.558819", "0.55707943", "0.55290484", "0.5523337", "0.5448422", "0.54086035", "0.53987795",...
0.6665784
0
If there is some Twitter API error, sends a notification and raises a ConnectionError.
def on_error(self, status: int): # Write all held tweets to files before closing self.total_tweet_counter += len(self.tweet_list) processing.process_tweets(self.tweet_list, self.tweet_handler_map, force_write=True) # Close files for tweet_handler in self.tweet_handler_map.values...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_error(self, status_code, data):\n logging.warning(\"Error recieving tweet: {0}\".format(status_code))", "def raise_connection_error(api_url, headers, timeout, proxies):\n raise requests.exceptions.ConnectionError", "def raise_connection_error(api_url, headers, timeout, proxies):\n raise req...
[ "0.72328466", "0.68385476", "0.68385476", "0.6720339", "0.666342", "0.660527", "0.64794886", "0.638833", "0.6363097", "0.6350749", "0.63188213", "0.62969935", "0.6281233", "0.6280862", "0.6258383", "0.62533885", "0.62472016", "0.6184027", "0.6167688", "0.6166812", "0.6161041"...
0.70774806
1
Flatten the tokens in the Stanza Doc and extract the token indices of the sentence start tokens to set is_sent_start.
def get_tokens_with_heads(self, snlp_doc): tokens = [] heads = [] offset = 0 for sentence in snlp_doc.sentences: for token in sentence.tokens: for word in token.words: # Here, we're calculating the absolute token index in the doc, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def doc2features(self,sent):\n return [self.word2features(sent['tokens'], i) for i in range(len(sent['tokens']))]", "def parts_of_speech_tags(self, tokenized_doc):\n return [(token.text, token.pos_) for token in self.parser(\n tokenized_doc)]", "def tokenize(self, sentences) -> Tuple[D...
[ "0.62763965", "0.5977885", "0.5910608", "0.5859339", "0.58517545", "0.5819559", "0.5686344", "0.5659545", "0.56377864", "0.5613838", "0.56110424", "0.5609064", "0.5549162", "0.5546483", "0.5544879", "0.5544212", "0.55393726", "0.54986614", "0.54953146", "0.54937124", "0.54873...
0.6099458
1
Check if the token exists as a unit in snlp's pretrained embeddings.
def token_has_vector(self, token): return self.svecs.vocab.unit2id(token.text) != UNK_ID
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_real_word(self, token):\n return not (token in self._non_words)", "def has_u(term):\n return term.amp.has(u)", "def check_for_token(token):\n try:\n decode_token(token)\n return True\n except:\n return False", "def has_unk(self) -> bool:\n return hasatt...
[ "0.6238588", "0.6236793", "0.6072188", "0.599305", "0.594227", "0.5844112", "0.5839025", "0.5815151", "0.57773656", "0.57769096", "0.57725686", "0.57637846", "0.5709141", "0.5702916", "0.5623615", "0.5610389", "0.55766875", "0.555442", "0.5527062", "0.5522508", "0.5490068", ...
0.6644645
0
Find pretrained word embeddings in any of a SNLP's processors.
def _find_embeddings(snlp): embs = None for proc in snlp.processors.values(): if hasattr(proc, "pretrain") and isinstance(proc.pretrain, Pretrain): embs = proc.pretrain break return embs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_embeddings():\n return embedding_utils.PretrainedWordEmbeddings(\n lowercase=FLAGS.lowercase,\n embeddings_path=FLAGS.fasttext_embeddings,\n max_vocab_size=FLAGS.max_vocab_size,\n skip_header=True)", "def load_pretrained_embedding(self, pre_embeddings):\n assert (pre_embeddin...
[ "0.613095", "0.59338266", "0.58154035", "0.57895327", "0.57876235", "0.57724077", "0.5741475", "0.570383", "0.56820476", "0.5624938", "0.5610429", "0.55781853", "0.5510196", "0.54778856", "0.54656994", "0.5434147", "0.5395072", "0.53939927", "0.5386714", "0.5381251", "0.53805...
0.82044744
0
Return all timestamps in the samples in the responses.
async def _timestamps(cls, responses: SourceResponses) -> set[int]: timestamps = set() async for samples in cls._samples(responses): timestamps |= {int(sample["timeStamp"]) for sample in samples} return timestamps
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def timestamps(self) -> List[T]:\n return self._timestamps", "def get_timestamps(self, dataset_name):\n return get_timestamps(self, dataset_name)", "def timestamps(self) -> List[float]:\n return self._timestamps", "def timestamps(self) -> List[float]:\n return self._timestamps", ...
[ "0.6813355", "0.66259265", "0.66027653", "0.66027653", "0.6582531", "0.6447626", "0.6399028", "0.63555336", "0.6333369", "0.6092941", "0.6090253", "0.60653746", "0.6026671", "0.6019697", "0.60101277", "0.5995389", "0.5968695", "0.59591484", "0.5957563", "0.5922962", "0.589244...
0.796029
0
Parse the CSV rows from the responses.
async def __parse_csv(responses: SourceResponses) -> Samples: rows = [] for response in responses: csv_text = await response.text() rows.extend(list(csv.DictReader(StringIO(csv_text.strip(), newline="")))) return rows
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def __parse_csv(responses: SourceResponses) -> list[dict[str, str]]:\n rows = []\n for response in responses:\n csv_text = (await response.text()).strip()\n rows.extend(list(csv.DictReader(StringIO(csv_text, newline=\"\"))))\n return rows", "def parse_rows(self, r...
[ "0.8132793", "0.7847308", "0.7116943", "0.6605606", "0.65382075", "0.65351474", "0.6265736", "0.6219541", "0.61053914", "0.6097307", "0.60733235", "0.60321105", "0.60313576", "0.5913238", "0.5911507", "0.5887053", "0.58852226", "0.58548886", "0.58535045", "0.5829456", "0.5823...
0.80211383
1
Return the number of successful samples.
def _success_count(cls, samples: Samples) -> int: return cls.__sample_count(samples, "true")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __sample_count(samples: Samples, sample_result: Literal[\"true\", \"false\"]) -> int:\n return len([sample for sample in samples if sample[\"success\"] == sample_result])", "def _error_count(cls, samples: Samples) -> int:\n return cls.__sample_count(samples, \"false\")", "def _number_of_sampl...
[ "0.7836772", "0.76988053", "0.7595048", "0.7236961", "0.7212369", "0.7132432", "0.7100951", "0.7099411", "0.70672077", "0.69685566", "0.6964144", "0.6901672", "0.68813807", "0.6881145", "0.68793553", "0.679865", "0.67660755", "0.6756977", "0.6756977", "0.6756977", "0.675406",...
0.86692584
0
Return the number of errored samples.
def _error_count(cls, samples: Samples) -> int: return cls.__sample_count(samples, "false")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error_count(self):\n return len(self.errors)", "def lines_errored(self) -> int:\n with self.lock:\n return self._lines_errored", "def get_error_count(self):\n return sum(1 for outcome in (r.outcome for r in self.values()) if outcome == Result.ERROR)", "def n_remaining_samp...
[ "0.7144486", "0.71003336", "0.68761474", "0.68356186", "0.68356186", "0.68356186", "0.6805688", "0.6715426", "0.67001444", "0.6651466", "0.6625623", "0.6604433", "0.64905816", "0.64795065", "0.646882", "0.636956", "0.63643855", "0.63273096", "0.62564415", "0.62402165", "0.622...
0.8395357
0
Return the number of samples with the specified sample result.
def __sample_count(samples: Samples, sample_result: Literal["true", "false"]) -> int: return len([sample for sample in samples if sample["success"] == sample_result])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count(self,value = 1):\n n = 0\n for s in self.sample:\n if s == value:\n n += 1\n return n", "def sample_count(self):", "def _success_count(cls, samples: Samples) -> int:\n return cls.__sample_count(samples, \"true\")", "def sample_count(self):\n ...
[ "0.67250776", "0.6629143", "0.6474104", "0.6336485", "0.6300626", "0.62085545", "0.6151715", "0.61309946", "0.6031883", "0.6023944", "0.59977853", "0.59915626", "0.5985132", "0.5936911", "0.590638", "0.5900984", "0.58958775", "0.5871683", "0.58622366", "0.5861072", "0.5828974...
0.8437955
0
Is called to create share from snapshot.
def create_share_from_snapshot( self, context, share, snapshot, share_server=None): LOG.debug("Create share from snapshot.") raise NotImplementedError()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_share_from_snapshot(self, context, share, snapshot,\n share_server=None):\n raise NotImplementedError()", "def create_snapshot(self, pool, project, share, snapshot):\n svc = self.snapshots_path % (pool, project, share)\n arg = {'name': snapshot}\n...
[ "0.8654978", "0.73031986", "0.66048306", "0.6560302", "0.6292823", "0.61521786", "0.6131044", "0.6098478", "0.6058628", "0.6057237", "0.6039007", "0.5985215", "0.59419197", "0.5908196", "0.58891326", "0.5884616", "0.5869908", "0.58671415", "0.5840786", "0.58349425", "0.583046...
0.8667362
0
Allow access to the share.
def allow_access(self, context, share, access, share_server=None): LOG.debug("Allow access.") self.helper._allow_access(share['name'], access, share['share_proto'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allow_access(self, context, share, access, share_server=None):\n self._get_helper(share).allow_access('/', share, access)", "def canShare(self):\n return False", "def _allow_access(self, context, share, access, share_server=None):\n if access['access_type'] != 'ip':\n raise ...
[ "0.8126944", "0.7822199", "0.7598446", "0.74235785", "0.70686233", "0.70590013", "0.70208716", "0.6820408", "0.673909", "0.6679184", "0.6624387", "0.6609415", "0.6541578", "0.6514042", "0.6488971", "0.6430162", "0.6430162", "0.63272744", "0.6213297", "0.6192507", "0.6114378",...
0.84221536
0
Deny access to the share.
def deny_access(self, context, share, access, share_server=None): LOG.debug("Deny access.") self.helper._deny_access(share['name'], access, share['share_proto'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deny_access(self, context, share, access, share_server=None):\n self._get_helper(share).deny_access('/', share, access)", "def _deny_access(self, context, share, access, share_server=None):\n if access['access_type'] != 'ip':\n LOG.debug('Quobyte driver only supports ip access contro...
[ "0.8123156", "0.8024274", "0.76958644", "0.67959553", "0.675488", "0.67534244", "0.65651906", "0.6514734", "0.6497103", "0.6492349", "0.6489137", "0.64158607", "0.64025235", "0.62671417", "0.6246837", "0.60803324", "0.6022774", "0.6022139", "0.6017365", "0.5993733", "0.598517...
0.8372942
0
Find a peak of a discrete function. The function input and output must be integers.
def find_peak(func, low, high): def derivative(x): return func(x)-func(x+1) a = bisect_left(derivative, 0, low, high) result = func(a) index = a # Unfortunately the above only finds a value where there is no change, so we have to continue searching for the # maximum value. The binary ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_peak(list_of_integer):\n if not list_of_integer:\n return (None)\n return R_fp(list_of_integer, 0, len(list_of_integer) - 1,\n len(list_of_integer))", "def peak(data, fft_data=None):\n return np.max(np.abs(data))", "def find_max_f():\n fmax = fmin(g, 2)\n return fm...
[ "0.6552329", "0.6401683", "0.6322719", "0.61030346", "0.6097119", "0.60493207", "0.5997935", "0.59250695", "0.59248614", "0.5902524", "0.58721644", "0.58703446", "0.586329", "0.579758", "0.57791305", "0.5768711", "0.5753331", "0.5752943", "0.56979895", "0.5670073", "0.5640742...
0.69185483
0
Verify that the 'mapping' element of the header matches 'self.mapping_type'.
def _check_type(self): assert self.mapping == self.mapping_type, \ "Expected header mapping='{}' but got mapping='{}' in '{}'".format( self.mapping_type, self.mapping.upper(), self.filename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_check_map(self):\r\n\r\n header, mapping_data = check_map(self.valid_mapping_data_golay)\r\n\r\n expected_header =\\\r\n ['SampleID',\r\n 'BarcodeSequence',\r\n 'LinkerPrimerSequence',\r\n 'Description']\r\n expected_mapping_data =\\\r\n ...
[ "0.7248495", "0.6446224", "0.6280398", "0.6254651", "0.59662724", "0.589317", "0.58858556", "0.5869658", "0.58460075", "0.5841542", "0.5779263", "0.577921", "0.57563955", "0.57414865", "0.5733594", "0.5703318", "0.5678211", "0.5659926", "0.56521684", "0.5647698", "0.5629558",...
0.838961
0
Verify self.observatory is a supported observatory.
def check_observatory(self): assert self.observatory in ALL_OBSERVATORIES, \ "Invalid observatory " + repr(self.observatory) + " in " + repr(self.filename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_observatory(lasco):\n assert lasco.observatory == \"SOHO\"", "def _assert_problem_is_valid(self) -> None:\n # Will throw error if any of these are not set\n specified = self.ignore + self.silence + self.target\n if not all(\n [\n pr in specified\n ...
[ "0.5788112", "0.57282144", "0.5721854", "0.5534891", "0.54900455", "0.54611546", "0.5335963", "0.5304369", "0.52799594", "0.52225983", "0.52074", "0.52018386", "0.51832324", "0.5169151", "0.51360226", "0.5135743", "0.5126425", "0.511922", "0.5118436", "0.5094865", "0.5092534"...
0.8219229
0
Verify self.instrument is a supported instrument.
def check_instrument(self): assert self.instrument in self.obs_package.INSTRUMENTS, \ "Invalid instrument " + repr(self.instrument) + " in " + repr(self.filename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_instrument(self, nexus_base):\n assert isinstance(nexus_base.instrument, nx.NXinstrument)", "def is_ivi_instrument(self): \n \n return False", "def _is_instrumentable(obj):\n try:\n # Only callables can be instrumented\n if not hasattr(obj, \"__call__\"):\n return F...
[ "0.70053124", "0.6637295", "0.5873785", "0.5760696", "0.5746066", "0.5731625", "0.5677123", "0.56261504", "0.5580738", "0.54702765", "0.54702765", "0.54702765", "0.54702765", "0.5460659", "0.5457866", "0.5315709", "0.5314786", "0.531215", "0.5270405", "0.52021", "0.5181723", ...
0.8005163
0
Verify self.filekind is a supported filekind.
def check_filekind(self): assert self.filekind in self.obs_package.FILEKINDS, \ "Invalid filekind " + repr(self.filekind) + " in " + repr(self.filename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _IsFile(self, kind, path):\n\n return { Database.TEST : self._IsTestFile,\n Database.RESOURCE : self._IsResourceFile,\n Database.SUITE : self._IsSuiteFile } [kind] (path)", "def test_allowed_file(self):\r\n u = Uploader()\r\n for ext in u.allowed_extension...
[ "0.64936244", "0.6368033", "0.63460654", "0.61710685", "0.61701775", "0.61468863", "0.60850877", "0.6062987", "0.60531515", "0.60286754", "0.6024042", "0.6004679", "0.5960114", "0.59362644", "0.59286594", "0.59258145", "0.59241706", "0.59177876", "0.59172714", "0.590702", "0....
0.8553937
0
Load a mapping file `basename` and do syntax and basic validation. If `path` is specified, recursively load all files relative to `path` and include path in the name of the mapping.
def from_file(cls, basename, *args, **keys): log.verbose("Loading mapping", repr(basename), verbosity=55) path = keys.get("path", None) if path: filename = os.path.join(path, os.path.basename(basename)) basename = filename else: filename = config.locat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load(path):\n pass", "def load_mappings(filepath):\n return pickle.load(open(filepath, \"rb\"))", "def load(self, path):\n pass", "def load(self, path):\n pass", "def _load(mapping, **keys):\n return keys[\"loader\"](mapping, **keys)", "def _resolve_load(self, basename):\n ...
[ "0.59477055", "0.56830925", "0.5441185", "0.5441185", "0.54035115", "0.5384552", "0.5380374", "0.533791", "0.5289132", "0.5283645", "0.52580696", "0.5214647", "0.5198375", "0.51491284", "0.51450175", "0.51379985", "0.5135484", "0.507817", "0.5059064", "0.50562894", "0.5015083...
0.70921797
0
Construct a mapping from string `text` nominally named `basename`.
def from_string(cls, text, basename="(noname)", *args, **keys): keys.pop("comment", None) # discard comment if defined header, selector, comment = cls._parse_header_selector(text, basename) mapping = cls(basename, header, selector, comment=comment, **keys) try: mapping._chec...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_file(cls, basename, *args, **keys):\n log.verbose(\"Loading mapping\", repr(basename), verbosity=55)\n path = keys.get(\"path\", None)\n if path:\n filename = os.path.join(path, os.path.basename(basename))\n basename = filename\n else:\n filenam...
[ "0.5875259", "0.5264839", "0.5232474", "0.51025933", "0.5036929", "0.49311957", "0.49263504", "0.49231306", "0.49153697", "0.48793212", "0.4873257", "0.4844714", "0.47899547", "0.4780782", "0.4714158", "0.47026387", "0.46955714", "0.469526", "0.46923745", "0.46922857", "0.466...
0.6237095
0
Given a mapping at `filepath`, validate it and return a fully instantiated (header, selector) tuple.
def _parse_header_selector(cls, text, where=""): with log.augment_exception("Can't load file " + where, exception_class=crexc.MappingError): code = MAPPING_VERIFIER.compile_and_check(text) header, selector, comment = cls._interpret(code) return ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_mapping_file(mapping: Path) -> Tuple:\n name_column = []\n xdm_one_data_model = []\n\n with open(mapping, newline=\"\") as csvfile:\n reader = csv.DictReader(\n csvfile, delimiter=\"\\t\" if str(mapping).endswith(\"tsv\") else \",\"\n )\n\n if not reader.fieldnames...
[ "0.5274137", "0.5266964", "0.5256009", "0.51845556", "0.5139166", "0.5059241", "0.5046252", "0.5009625", "0.49811822", "0.4970169", "0.49642307", "0.49616304", "0.49406773", "0.49354082", "0.4930032", "0.4926242", "0.49253115", "0.48855686", "0.48534927", "0.48459545", "0.478...
0.61023575
0
Interpret a valid rmap code object and return it's header and selector.
def _interpret(cls, code): namespace = {} namespace.update(selectors.SELECTORS) exec(code, namespace) header = LowerCaseDict(namespace["header"]) selector = namespace["selector"] comment = namespace.get("comment", None) if isinstance(selector, selectors.Parameters...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parseCodeLine(self, text):\n\t\tcodeRegex = re.compile(r\"^\\[0x([0-9a-f]{8})\\]\\t0x([0-9a-f]{8}) (.+)$\")\n\t\t# attempt to match the code\n\t\tm = codeRegex.match(text)\n\t\t# If no match found, return None.\n\t\tif (m is None): return None\n\t\tresult = {}\n\t\tresult['encoded_instruction'] = int(m.group(...
[ "0.62368625", "0.6180533", "0.60376525", "0.59087044", "0.5857235", "0.5630329", "0.5493413", "0.53673923", "0.53580856", "0.5276486", "0.51929486", "0.5129242", "0.5124326", "0.5110148", "0.5098064", "0.5075925", "0.5072615", "0.505133", "0.50489664", "0.5005041", "0.4996282...
0.6740135
0
Get the references mentioned by the closure of this mapping but not in the cache.
def missing_references(self): return [ ref for ref in self.reference_names() if not config.file_in_cache(self.name, self.observatory) ]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def references(self) -> Collection[Access]:\n # we don't want to publicly expose the mutable version of this\n return self.__accesses", "def missing_mappings(self):\n return [ mapping for mapping in self.mapping_names() if not config.file_in_cache(self.name, self.observatory) ]", "def get_...
[ "0.5917911", "0.5849297", "0.5824473", "0.58160526", "0.5787286", "0.5781524", "0.5726434", "0.56811655", "0.5641355", "0.5490074", "0.5472923", "0.54542756", "0.54375136", "0.53960466", "0.5391382", "0.5391382", "0.5377214", "0.53681505", "0.5359045", "0.53483653", "0.534032...
0.6933123
0
Get the mappings mentioned by the closure of this mapping but not in the cache.
def missing_mappings(self): return [ mapping for mapping in self.mapping_names() if not config.file_in_cache(self.name, self.observatory) ]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy_backward_mapping(self) -> Dict[str, Set[str]]:\n return deepcopy(self._backward_mapping)", "def mapped(self):\n return self.__mapped", "def get_current_mappings(self):\n return {name: getattr(self, name) for name in self.__mapped_names}", "def _map___iter__(self):\n retur...
[ "0.57950556", "0.57526094", "0.5700315", "0.56994575", "0.5640845", "0.5522319", "0.54425335", "0.54216254", "0.54086065", "0.5398602", "0.53906703", "0.53830254", "0.538106", "0.53755575", "0.5351649", "0.53514457", "0.53514457", "0.5342949", "0.5339821", "0.5336493", "0.527...
0.7483489
0
Return the "locate" module associated with self.observatory.
def locate(self): return utils.get_object("crds", self.observatory, "locate")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _find_corresponding_module_for_location(self, location):\r\n try:\r\n return self.descriptor.system.load_item(location)\r\n except ItemNotFoundError:\r\n # The linked problem doesn't exist.\r\n log.error(\"Problem {0} does not exist in this course.\".format(locati...
[ "0.6068479", "0.57807004", "0.5746378", "0.5712822", "0.5599184", "0.5570406", "0.5529222", "0.55230594", "0.54524994", "0.54434997", "0.54419243", "0.5433323", "0.5408109", "0.53695834", "0.53694195", "0.5361878", "0.5343193", "0.5291578", "0.5282428", "0.52512145", "0.52421...
0.69079846
0
Return the package (__init__) associated with self.observatory.
def obs_package(self): return utils.get_observatory_package(self.observatory)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _package(self):\n if self._package_obj is None:\n self._package_obj = self._import_package()\n\n return self._package_obj", "def __init__(self, package_name, base_path):\n self.package_name = package_name\n self.base_path = base_path", "def __init__(self, package_name: str) -...
[ "0.64644915", "0.5877105", "0.5834435", "0.57718587", "0.5505472", "0.54826957", "0.5470002", "0.53614956", "0.5353158", "0.53348565", "0.5328132", "0.5315724", "0.5286506", "0.5280729", "0.52674055", "0.5262433", "0.5237213", "0.5227226", "0.5215764", "0.5215764", "0.5194799...
0.7533003
0
Return indented source code for nested `dict`.
def _format_dict(self, dict_, indent=0): prefix = indent*" "*4 output = "{\n" for key, val in sorted(dict_.items()): if isinstance(val, dict): rval = self._format_dict(val, indent+1) else: rval = repr(val) output += prefix + " "...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prettify(tree, indent=0):\n for key, value in six.iteritems(tree):\n if key == FILE_MARKER:\n if value:\n print((' ' * indent + str(value)))\n else:\n print((' ' * indent + str(key)))\n if isinstance(value, dict):\n prettify(valu...
[ "0.6598759", "0.60950667", "0.60702443", "0.59938025", "0.59820527", "0.58328205", "0.5821386", "0.5810367", "0.5772005", "0.57573265", "0.5720894", "0.5720287", "0.57131714", "0.5704295", "0.56647605", "0.5618599", "0.5537958", "0.55279154", "0.55272096", "0.5494798", "0.544...
0.61075217
1
Verify that the mapping header has a checksum and that it is correct, else raise an appropriate exception.
def _check_hash(self, text): old = self.header.get("sha1sum", None) if old is None: raise crexc.ChecksumError("sha1sum is missing in " + repr(self.basename)) if self._get_checksum(text) != self.header["sha1sum"]: raise crexc.ChecksumError("sha1sum mismatch in " + repr(sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _verify_hash(self, read_bytes):\n if self.hash is None:\n raise QuiltException(\"Hash missing - need to build the package\")\n _check_hash_type_support(self.hash.get('type'))\n digest = hashlib.sha256(read_bytes).hexdigest()\n if digest != self.hash.get('value'):\n ...
[ "0.6547166", "0.64717543", "0.6423799", "0.62826645", "0.6063777", "0.605815", "0.6007377", "0.5951486", "0.59418464", "0.591026", "0.5902226", "0.586081", "0.58396226", "0.5818784", "0.5779963", "0.57782453", "0.57749486", "0.57320946", "0.57255006", "0.5707526", "0.5689474"...
0.6917576
0
Compute the rmap checksum over the original file contents. Skip over the sha1sum line.
def _get_checksum(self, text): # Compute the new checksum over everything but the sha1sum line. # This will fail if sha1sum appears for some other reason. It won't ;-) text = "".join([line for line in text.splitlines(True) if "sha1sum" not in line]) return utils.str_checksum(text)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checksum_of(filepath):\n bfsz = 10240000 # 10 MB buffer\n sum = hashlib.sha256()\n with open(filepath) as fd:\n while True:\n buf = fd.read(bfsz)\n if not buf: break\n sum.update(buf)\n return sum.hexdigest()", "def compute_checksum(filename):\n cmd = ...
[ "0.6229765", "0.6211366", "0.61984205", "0.614336", "0.6107678", "0.6074083", "0.6022084", "0.59833366", "0.59514105", "0.58906347", "0.5866025", "0.5843083", "0.58272135", "0.5816864", "0.58127195", "0.5800951", "0.57998943", "0.57929355", "0.5768371", "0.57609755", "0.57362...
0.6605972
0
Determine the set of parkeys required for this mapping and all the mappings selected by it.
def get_required_parkeys(self): parkeys = set(self.parkey) parkeys |= set(self.header.get("extra_keys",[])) if hasattr(self, "selections"): for selection in self.selections.normal_values(): parkeys |= set(selection.get_required_parkeys()) return sorted(parkeys...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_parkey_map(self):\n pkmap = {}\n for selection in self.selections.normal_values():\n for parkey, choices in selection.get_parkey_map().items():\n if parkey not in pkmap:\n pkmap[parkey] = set()\n pkmap[parkey] |= set(choices)\n ...
[ "0.77100307", "0.74034214", "0.68887526", "0.6884747", "0.63165545", "0.6161529", "0.59732664", "0.59591097", "0.59545034", "0.5952784", "0.59481066", "0.5936447", "0.5922515", "0.59016585", "0.58633244", "0.58582795", "0.5838069", "0.5823652", "0.58234143", "0.5816664", "0.5...
0.83907646
0
Return the names and values of `dataset`s header parameters which are required to compute best references for it. `original_name` is used to determine file type when `dataset` is a temporary file with a useless name.
def get_minimum_header(self, dataset, original_name=None): from crds import data_file header = data_file.get_conditioned_header(dataset, original_name=original_name) return self.minimize_header(header)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _pname_and_metadata(in_file):\n\n\n if in_file.endswith(\".csv\"):\n raise ValueError(\"Did not find input metadata file: %s\" % in_file)\n base, md, global_vars = in_file, {}, {}\n md_file = None\n return base, md, global_vars, md_file", "def dataset_headers(dataset):\n return list(dat...
[ "0.5813021", "0.5777645", "0.5580188", "0.55409557", "0.5522791", "0.54143167", "0.53004843", "0.5299755", "0.52852845", "0.5272425", "0.522247", "0.5220462", "0.51883674", "0.5187494", "0.51628", "0.51459926", "0.5133356", "0.51244134", "0.5080788", "0.5051744", "0.50469464"...
0.66943854
0
Compare `self` with `new_mapping` and return a list of difference tuples, prefixing each tuple with context `path`.
def difference(self, new_mapping, path=(), pars=(), include_header_diffs=False, recurse_added_deleted=False): new_mapping = asmapping(new_mapping, cache="readonly") log.verbose("Difference:", self.filename, "vs.",new_mapping.filename) differences = self.difference_header(new_mapping, path=path, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_equivalent_mapping(self, mapping):\n if not mapping.endswith(\".rmap\"):\n log.warning(\"Invalid comparison context\", repr(self.name), \"for\", repr(mapping))\n return None\n return self", "def _return_new_mapping(self):\n # Change old mapping to 1D in order to...
[ "0.58727014", "0.5671631", "0.5615423", "0.5562913", "0.55018324", "0.55001116", "0.54435325", "0.5438776", "0.5430974", "0.53907245", "0.5388208", "0.53846306", "0.5374919", "0.5283035", "0.5246808", "0.5245082", "0.52218205", "0.52138203", "0.5209764", "0.51679605", "0.5142...
0.6332717
0
Return the list of diff tuples for all nested changed files in a higher level addition or deletion. added_deleted should be "added" or "deleted"
def diff_files(self, added_deleted, path=(), pars=()): diffs = [] for key, selection in self.selections.items(): if self._is_normal_value(key): diffs.extend(selection.diff_files(added_deleted, path + (key,), pars + (self.diff_name,))) else: delete_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def diff_files(self, added_deleted, path=(), pars=()):\n body_diffs = self.selector.flat_diff(added_deleted + \" terminal\",\n path = path + ((self.filename,)), pars = pars + (self.diff_name,))\n for diff in body_diffs:\n diff.instrument = self.instrument\n diff.f...
[ "0.70776576", "0.6808515", "0.5998419", "0.5944883", "0.5859819", "0.58514106", "0.58426577", "0.5804762", "0.5722642", "0.56984836", "0.5673258", "0.5666977", "0.5647898", "0.5640162", "0.55840707", "0.5576593", "0.5572213", "0.5556975", "0.5546418", "0.5517638", "0.5457746"...
0.7194671
0
Return True IFF the value of selection `key` is not special, i.e. N/A or OMIT.
def _is_normal_value(self, key): return not MappingSelectionsDict.is_special_value(self.selections[key])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_key(key, options):\n animal_id, exp_date, exp_type = key.split('_')\n if ((options.animal_id is None or animal_id == options.animal_id)\n and (options.exp_date is None or exp_date == options.exp_date)\n and (options.exp_type is None or exp_type == options.exp_type)):\n ...
[ "0.6634218", "0.6445927", "0.6199985", "0.6199985", "0.6176141", "0.6162723", "0.61119634", "0.6107314", "0.60931975", "0.60664", "0.60658973", "0.60524154", "0.59763485", "0.5953498", "0.5953017", "0.5945266", "0.59221864", "0.5914089", "0.5903909", "0.5848411", "0.58422154"...
0.76937
0
Return selections[key] if it is a special value, otherwise assume it is a mapping and return the sha1sum header field.
def _value_xsum(self, key): value = self.selections[key] return value if MappingSelectionsDict.is_special_value(value) else value.sha1sum
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _value_name(self, key):\n value = self.selections[key]\n return value if MappingSelectionsDict.is_special_value(value) else value.filename", "def get_value(self, query_dict, k): \n if k in query_dict:\n return query_dict[k]\n return ''", "def getHeaderVal2(self, key):...
[ "0.5511655", "0.5326234", "0.5080606", "0.50753695", "0.5059404", "0.50054836", "0.49646384", "0.49473068", "0.48772615", "0.48430172", "0.4791655", "0.47699592", "0.47659943", "0.4762923", "0.4737509", "0.47148252", "0.46964842", "0.46878076", "0.46824905", "0.4676877", "0.4...
0.710665
0
Name used to identify mapping item in DiffTuple's
def diff_name(self): return self.__class__.__name__ # .replace("Context","").replace("Mapping","")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mapping(tag):\n\n return gvars.METAINFO['tag_map'][tag.replace('1', '')]", "def mapping_validator_key(mapping):\n return (mapping.instrument + \"_all_ld.tpn\", mapping.name)", "def map_stat_name(self, generic_name):\n pass", "def tuple_namer(name,tupl):\n tupl_templ = collections.namedtuple...
[ "0.5976721", "0.5805962", "0.5802045", "0.5691261", "0.56759506", "0.56430155", "0.56193644", "0.56187594", "0.5615198", "0.5549079", "0.55295223", "0.54763854", "0.54675186", "0.54620516", "0.5458351", "0.5440784", "0.5440742", "0.54397917", "0.5438309", "0.54178095", "0.541...
0.6718752
0
Return the "extended match tuples" which can be followed to arrive at `filename`.
def file_matches(self, filename): return sorted([match for value in self.selections.normal_values() for match in value.file_matches(filename)])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_matches(self, filename):\n sofar = (((\"observatory\", self.observatory),\n (\"instrument\",self.instrument),\n (\"filekind\", self.filekind),),)\n return sorted(self.selector.file_matches(filename, sofar))", "def filter_matches(filename, e):\n transcri...
[ "0.70852643", "0.5814033", "0.5685335", "0.56232864", "0.55870366", "0.54747164", "0.5459371", "0.54327714", "0.54226106", "0.5408159", "0.54054785", "0.5393163", "0.5348826", "0.530674", "0.5301661", "0.52917695", "0.5289794", "0.52849317", "0.52679116", "0.5255556", "0.5246...
0.68663955
1
Verify that `key` in `nested's` header matches `key` in `self's` header.
def _check_nested(self, key, self_val, nested): nested_val = getattr(nested, key) assert self_val == nested_val, \ "selector['{}']='{}' in '{}' doesn't match header['{}']='{}' in nested file '{}'.".format( key, self_val, self.filename, key, nested_val, nested.filename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __check_headers_contains_elem(headers, element, nested_elem=None):\n\n if element in headers:\n if nested_elem is not None and nested_elem not in headers[element]:\n return __get_eval_result(\n \"FAILED\", f\"No {element} header with {nested_elem} found\", 90\n )\...
[ "0.5876144", "0.5482642", "0.5348312", "0.52099615", "0.52019954", "0.5198552", "0.51827693", "0.51575434", "0.5119613", "0.5103147", "0.5102439", "0.50886077", "0.5069892", "0.50462174", "0.5046008", "0.5037914", "0.5013706", "0.49743828", "0.4961676", "0.49118248", "0.48897...
0.77519494
0
Return a 'pure data' dictionary representation of this mapping and it's children suitable for conversion to json. If `recursive` is nonzero, return that many levels of the hierarchy starting with this one. If recursive is zero, only return the filename and header of the next levels down, not the contents.
def todict(self, recursive=10): # dict required here for subsequent update. selections = dict([(key, val.todict(recursive-1)) if recursive-1 else (val.basename, val.header) for (key,val) in self.selections.normal_items()]) selections.update...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def todict(self, recursive=10):\n nested = self.selector.todict_flat()\n return {\n \"header\" : { key : self.header[key] for key in self.header },\n \"text_descr\" : self.obs_package.TEXT_DESCR[self.filekind],\n \"parameters\" : tuple(nested[\"parameters\...
[ "0.6563336", "0.6272748", "0.6204542", "0.6141629", "0.6061648", "0.6052795", "0.60331994", "0.603217", "0.59721714", "0.59569734", "0.59464496", "0.59462386", "0.58574337", "0.5791486", "0.572643", "0.5703174", "0.5666113", "0.56604475", "0.565065", "0.5646841", "0.564678", ...
0.6310611
1
Return the name of the instrument which corresponds to `header`. Called for unknownmapping types. Overridden by PipelineMapping which figures it out from header.
def get_instrument(self, header): return self.instrument.upper()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_instrument(self, header):\n for key in [self.instrument_key.upper(), self.instrument_key.lower()] + INSTRUMENT_KEYWORDS:\n try: # This hack makes FITS headers work prior to back-mapping to data model names.\n instr = header[key]\n except KeyError:\n ...
[ "0.7364939", "0.6340998", "0.6289825", "0.62578225", "0.6250203", "0.61934525", "0.61870235", "0.56813604", "0.56717426", "0.5642592", "0.5616464", "0.5616156", "0.5575051", "0.55086774", "0.5411532", "0.53919655", "0.5248192", "0.5244311", "0.52442414", "0.52432454", "0.5237...
0.72569793
1
Add or replace and element of this mapping's selector. For rewriting only. Return the casecorrected value of `key` and the value that was replaced or None as (corrected_key, replaced_value).
def set_item(self, key, value): key, value = str(key), str(value) key = self.locate.match_context_key(key) replaced = self.selector.get(key, None) self.selector[key] = value return key, replaced
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replacer(replace_value, key=None):\n\n if key is not None:\n if key not in exempt:\n return check_replace(replace_value)\n else:\n return replace_value, False\n else:\n return check_replace(replace_value)", "def replace(letter, key)...
[ "0.57965434", "0.5427491", "0.530871", "0.52828443", "0.5177788", "0.51264983", "0.5106385", "0.50619286", "0.5055118", "0.50530094", "0.5033185", "0.50244236", "0.50048053", "0.50011414", "0.49857733", "0.49826366", "0.49671373", "0.4947503", "0.49305063", "0.49285352", "0.4...
0.62148297
0
Validate nested mappings, common properties for all context mappings.
def validate(self): super(ContextMapping, self).validate() self.check_observatory() for key, mapping in self.selections.normal_items(): self._check_nested("observatory", self.observatory, mapping) # mapping.validate()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_map(\n mapping: Mapping[str, Any], ref: str, types: Set[str],\n depth: int) -> Optional[SchemaError]:\n return _validate_type_recursively(\n mapping=mapping['values'],\n ref='{}/values'.format(ref),\n types=types,\n depth=depth + 1)", "def validate_mappi...
[ "0.62847006", "0.6168283", "0.5923675", "0.5923007", "0.58604425", "0.58528364", "0.5812085", "0.5788622", "0.5761183", "0.56510454", "0.56269205", "0.56207526", "0.56195116", "0.5604191", "0.5563201", "0.55237544", "0.55105007", "0.54775876", "0.5401004", "0.53677845", "0.53...
0.7640336
0
Return the best references for keyword map `header`. If `include` is None, collect all filekinds, else only those listed.
def get_best_references(self, header, include=None): header = dict(header) # make a copy instrument = self.get_instrument(header) imap = self.get_imap(instrument) return imap.get_best_references(header, include)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_best_references(self, header, include=None):\n if include is not None and self.filekind not in include:\n raise crexc.CrdsUnknownReftypeError(self.__class__.__name__, repr(self.basename),\n \"can only compute bestrefs for type\", repr(self.filekind...
[ "0.7796792", "0.6983415", "0.66475034", "0.55885285", "0.5355604", "0.5125761", "0.48445216", "0.4796289", "0.47444442", "0.46709636", "0.4617276", "0.4590989", "0.45799023", "0.44888404", "0.44722995", "0.4464342", "0.44386035", "0.44377455", "0.4419278", "0.4411576", "0.440...
0.7561035
1
Return the old references defined in keyword map `header` using this context to define the types to return when `include` is None. >>> p = get_cached_mapping("hst.pmap")
def get_old_references(self, header, include=None): header = dict(header) # make a copy instrument = self.get_instrument(header) imap = self.get_imap(instrument) return imap.get_old_references(header, include)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_old_references(self, header, include=None):\n refs = {}\n if not include:\n include = self.selections.keys()\n include = [ key.upper() for key in include ]\n header = { key.upper() : val.strip() for (key, val) in header.items() }\n for filekind in include:\n ...
[ "0.58063656", "0.5448276", "0.53934395", "0.4980537", "0.4953682", "0.49390468", "0.48950902", "0.4860994", "0.48410496", "0.48235476", "0.4755104", "0.47173062", "0.46787423", "0.46766564", "0.46740246", "0.460356", "0.45773873", "0.45665455", "0.45400843", "0.44870508", "0....
0.6178377
0
Return the InstrumentMapping corresponding to `instrument`.
def get_imap(self, instrument): instrument_hacks = { "wfii" : "wfpc2", } instrument = instrument_hacks.get(instrument.lower(), instrument.lower()) try: return self.selections[instrument] except (crexc.IrrelevantReferenceTypeError, crexc.OmitReferen...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_instrument(instrument_id=\"ncnr.refl\"):\n instrument = lookup_instrument(instrument_id)\n return instrument.get_definition()", "def get_imap(self, instrument):\n return self", "def get_audio_for_instrument(self, instrument):\n if instrument not in self.instruments.keys():\n ...
[ "0.5929521", "0.57473254", "0.5602187", "0.559294", "0.54870445", "0.5410827", "0.5379594", "0.53350097", "0.51673365", "0.51327395", "0.51284194", "0.5075691", "0.50439453", "0.5037495", "0.49898946", "0.4956659", "0.49090317", "0.49028575", "0.48884937", "0.48750225", "0.48...
0.6168152
0
Return the filekinds associated with `dataset` by examining it's parameters. Currently returns ALL filekinds for `dataset`s instrument. Not all are necessarily appropriate for the current mode. `dataset` can be a filename or a header dictionary.
def get_filekinds(self, dataset): if isinstance(dataset, str): from crds import data_file instrument = data_file.getval(dataset, self.instrument_key) elif isinstance(dataset, dict): instrument = self.get_instrument(dataset) else: raise ValueError(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_filekinds(self, dataset=None):\n return [self.filekind]", "def get_filekinds(self, dataset=None):\n return list(sorted(self.selections.keys()))", "def data_kinds():\n\n return ...", "def __get_dataset_type(dataset):\n op_type = None\n if isinstance(dataset, de.ShuffleDa...
[ "0.79175556", "0.7322624", "0.6177465", "0.5541745", "0.54738116", "0.52953106", "0.52280706", "0.5216596", "0.51764673", "0.5086715", "0.5038887", "0.50224817", "0.5009041", "0.5003045", "0.49990016", "0.49926507", "0.4941071", "0.49005267", "0.4874711", "0.48460323", "0.482...
0.87270916
0
Get the instrument name defined by file `header`.
def get_instrument(self, header): for key in [self.instrument_key.upper(), self.instrument_key.lower()] + INSTRUMENT_KEYWORDS: try: # This hack makes FITS headers work prior to back-mapping to data model names. instr = header[key] except KeyError: continue...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_instrument(self, header):\n return self.instrument.upper()", "def get_instrument_name(input_file):\n\n # Make sure file exists.\n if not path.isfile(input_file):\n raise HSTSpecPrevError(\"Input file not found, looking for file: \" +\n input_file)\n\n ...
[ "0.8051503", "0.76146734", "0.74972427", "0.6648914", "0.619578", "0.6169737", "0.60781354", "0.6043918", "0.60418934", "0.604101", "0.603707", "0.6025987", "0.5878389", "0.5868001", "0.58589363", "0.5845565", "0.5836895", "0.5782834", "0.57721764", "0.5727537", "0.5680242", ...
0.7745138
1
Given `filename` nominally to insert, return the instrument it corresponds to.
def get_item_key(self, filename): instrument, _filekind = utils.get_file_properties(self.observatory, filename) return instrument.upper()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def instrument_code(filename):\n class_names = ['bass', 'brass', 'flute', 'guitar',\n 'keyboard', 'mallet', 'organ', 'reed',\n 'string', 'synth_lead', 'vocal']\n\n for name in class_names:\n if name in filename:\n return class_names.index(name)\n else:...
[ "0.63432825", "0.5685332", "0.5651017", "0.56305975", "0.5620066", "0.55203086", "0.5364042", "0.53584176", "0.52498347", "0.5249769", "0.5227431", "0.5220461", "0.51690537", "0.51568395", "0.51402605", "0.51383924", "0.5123531", "0.5120262", "0.51111925", "0.5086953", "0.505...
0.56870943
1
Perform InstrumentContext semantic checks which require can loading submappings.
def validate(self): super(InstrumentContext, self).validate() self.check_instrument() for filekind, refmap in self.selections.normal_items(): self._check_nested("instrument", self.instrument, refmap) self._check_nested("filekind", filekind, refmap)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate(self):\n super(ContextMapping, self).validate()\n self.check_observatory()\n for key, mapping in self.selections.normal_items():\n self._check_nested(\"observatory\", self.observatory, mapping)\n # mapping.validate()", "def validate(self):\n super(Pi...
[ "0.5763955", "0.5138671", "0.51228786", "0.5063058", "0.50112444", "0.50112444", "0.48996466", "0.48375756", "0.4808484", "0.4789548", "0.47517684", "0.46935448", "0.46935448", "0.46935448", "0.46804965", "0.46644026", "0.46416977", "0.46413684", "0.4640811", "0.46071", "0.45...
0.5889465
0
Given `filekind`, return the corresponding ReferenceMapping.
def get_rmap(self, filekind): filekind = str(filekind).lower() if filekind not in self.selections: raise crexc.CrdsUnknownReftypeError("Unknown reference type", repr(filekind)) if MappingSelectionsDict.is_na_value(self.selections[filekind]): log.verbose("Reference type", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_equivalent_mapping(self, mapping):\n if mapping.endswith(\".pmap\"):\n log.warning(\"Invalid comparison context\", repr(self.name), \"for\", repr(mapping))\n return None\n if mapping.endswith(\".imap\"):\n return self\n else:\n _instrument, f...
[ "0.5471157", "0.52598226", "0.52377194", "0.513132", "0.5100493", "0.50545925", "0.5051891", "0.5006914", "0.5002767", "0.4985887", "0.4961495", "0.49428982", "0.492694", "0.49137774", "0.4906986", "0.49061614", "0.49039468", "0.4898485", "0.4872381", "0.4850316", "0.47976655...
0.7478125
0
Returns a map of old references which were recorded in `header`, returning only those types listed in `include` or all types if `include` is None.
def get_old_references(self, header, include=None): refs = {} if not include: include = self.selections.keys() include = [ key.upper() for key in include ] header = { key.upper() : val.strip() for (key, val) in header.items() } for filekind in include: try...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_old_references(self, header, include=None):\n header = dict(header) # make a copy\n instrument = self.get_instrument(header)\n imap = self.get_imap(instrument)\n return imap.get_old_references(header, include)", "def get_best_references(self, header, include=None):\n ...
[ "0.7120397", "0.6615969", "0.6128362", "0.55122733", "0.53388506", "0.5099462", "0.5080262", "0.50660115", "0.5062413", "0.50057197", "0.49959412", "0.48876953", "0.487751", "0.48744804", "0.4814226", "0.47613057", "0.47611335", "0.47277915", "0.46785277", "0.4665702", "0.466...
0.7631689
0
Infers the legal values of each parkey from the rmap itself. This is a potentially different answer than that defined by the TPNs, the latter being considered definitive.
def get_parkey_map(self): pkmap = {} for selection in self.selections.normal_values(): for parkey, choices in selection.get_parkey_map().items(): if parkey not in pkmap: pkmap[parkey] = set() pkmap[parkey] |= set(choices) for parkey...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_parkey_map(self):\n parkey_map = self.selector.get_parkey_map()\n tpn_values = self.tpn_valid_values\n for key in self.get_extra_parkeys():\n if key in parkey_map and \"CORR\" not in key:\n continue\n parkey_map[key] = tpn_values.get(key, [])\n ...
[ "0.6899546", "0.54604226", "0.5449051", "0.544157", "0.52519596", "0.51215595", "0.50897855", "0.50834656", "0.5073524", "0.50516486", "0.5044989", "0.5044285", "0.5027417", "0.5017201", "0.50144386", "0.4987731", "0.4980357", "0.49537742", "0.49489978", "0.4944258", "0.49391...
0.6218803
1
Based on the TPNs, return a mapping from parkeys to their valid values for all parkeys for all filekinds of this instrument. This will return the definitive lists of legal values, not all of which are required to be represented in rmaps; these are the values that could be in an rmap, not necessarily what is in any give...
def get_valid_values_map(self, condition=False, remove_special=True): pkmap = {} for selection in self.selections.normal_values(): rmap_pkmap = selection.get_valid_values_map(condition) for key in rmap_pkmap: if key not in pkmap: pkmap[key] = s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_valid_values_map(self, condition=True):\n tpninfos = self.locate.get_all_tpninfos(self.instrument, self.filekind, \"ld_tpn\")\n required_keys = self.get_required_parkeys()\n valid_values = {}\n for info in tpninfos:\n if info.is_complex_constraint:\n co...
[ "0.7064245", "0.59559137", "0.5249311", "0.51613444", "0.46955064", "0.4682218", "0.45826307", "0.45770824", "0.45466453", "0.45286086", "0.4511221", "0.4509656", "0.44920567", "0.4487549", "0.44754007", "0.44585463", "0.44482496", "0.44347003", "0.44057247", "0.43969247", "0...
0.68236417
1
difference specialized to add .instrument to diff.
def difference(self, *args, **keys): diffs = super(InstrumentContext, self).difference(*args, **keys) for diff in diffs: diff.instrument = self.instrument return diffs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _diff(self, param, diff):\n pass", "def test_ddiff_v1(self):\n print \"\\n\"\n for d in ddiff_v1(a, b): print d\n self.assertEqual(d, \"+FUN\")", "def test_ddiff_v2(self):\n print \"\\n\"\n for d in ddiff_v2(a, b): print d\n self.asse...
[ "0.684647", "0.6118167", "0.6114174", "0.5965493", "0.58985114", "0.5890914", "0.5875951", "0.5870153", "0.5870153", "0.58347166", "0.5805703", "0.5705194", "0.5681944", "0.56630933", "0.56466585", "0.56383187", "0.56323844", "0.56282103", "0.5610057", "0.5577739", "0.5558089...
0.7708242
0
Check that the schema URI corresponds to a schema that ASDF knows how to load.
def check_schema_uri(self): import asdf if self.schema_uri is not None: with log.augment_exception("Invalid ASDF schema URI:", self.schema_uri): asdf.schema.load_schema(self.schema_uri)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isValidForSchema(schema):\n\n return True", "def has_schema_url(self):\n return self.get_schema_url() is not None", "def validate_schema(self):\n\n _schema_translator = {\n 'dav': 'http',\n 'davs': 'https',\n }\n\n _logger.debug(\n \"[%s]V...
[ "0.7494463", "0.74928015", "0.71921045", "0.6985547", "0.67408013", "0.66970265", "0.669097", "0.6629568", "0.657201", "0.65507907", "0.65264744", "0.651484", "0.6500421", "0.64862937", "0.6479879", "0.6428947", "0.6390829", "0.63670677", "0.6363229", "0.6342376", "0.63076854...
0.91323584
0
Return (expr, compiled_expr) for some rmap header expression, generally a predicate which is evaluated in the context of the matching header to fine tune behavior. Screen the expr for dangerous code.
def get_expr(self, expr): # secured expr = utils.condition_source_code_keys(expr, self.get_required_parkeys()) try: return expr, MAPPING_VERIFIER.compile_and_check(expr, source=self.basename, mode="eval") except crexc.MappingFormatError as exc: raise crexc.MappingFormatE...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def condition_matching_header(rmapping, header):\n return dict(header) # NOOP for JWST, may have to revisit", "def _parse_header_selector(cls, text, where=\"\"):\n with log.augment_exception(\"Can't load file \" + where,\n exception_class=crexc.MappingError):\n ...
[ "0.62505054", "0.5664072", "0.55157167", "0.5448111", "0.5293382", "0.51835847", "0.50907916", "0.49033022", "0.48854586", "0.48682195", "0.4825192", "0.48089302", "0.47336385", "0.47008398", "0.46907955", "0.46765032", "0.46473163", "0.45791027", "0.45728475", "0.45463088", ...
0.5901772
1
Return plugin hook function generically named `name` or `default` if `name` is not defined in the associated instrument package or in the rmap header. Until hooks is defined in header, get_hook will return the generically named function in the instrument package. hooks in rmap header supports future versions of hooks w...
def get_hook(self, name, default): hooks = self.header.get("hooks", None) if hooks: # Either get the replacement name, or use the original name if not found. hook_name = hooks.get(name, name) else: # No hooks dict, just use the original name. hook_name = "_".join([nam...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_hooks(name):\n register_all_hooks()\n return _hooks.get(name, [])", "def get_function_hooks(cls, name: str) -> Optional[FuncExtensionHooks]:\n return cls._func_exts.get(name.lower())", "def hook(self, name):\r\n def wrapper(func):\r\n self.hooks.add(name, func)\r\n ...
[ "0.6265378", "0.61983436", "0.6110327", "0.5990552", "0.595409", "0.592262", "0.58816445", "0.58770305", "0.5795603", "0.5733936", "0.5682361", "0.5588625", "0.5392701", "0.5392371", "0.53859705", "0.5378947", "0.5360521", "0.5316959", "0.53106576", "0.52762175", "0.523062", ...
0.8373538
0
Return the filekinds associated with this dataset, but for an rmap, just the rmap's filekind.
def get_filekinds(self, dataset=None): return [self.filekind]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_filekinds(self, dataset):\n if isinstance(dataset, str):\n from crds import data_file\n instrument = data_file.getval(dataset, self.instrument_key)\n elif isinstance(dataset, dict):\n instrument = self.get_instrument(dataset)\n else:\n raise...
[ "0.6755291", "0.63168913", "0.6067385", "0.56254", "0.5590905", "0.54043055", "0.53119016", "0.5294864", "0.52706003", "0.52025044", "0.5193021", "0.51874894", "0.5179585", "0.51639795", "0.4996122", "0.4957242", "0.4926664", "0.4862079", "0.48513278", "0.48207068", "0.477602...
0.708144
0
Return a single best reference value associated with this .rmap and `header`. Map exceptions from nested methods onto simple "NOT FOUND..." strings which are exempted from reference downloads.
def get_best_ref(self, header): try: return self._get_best_ref(header) except crexc.IrrelevantReferenceTypeError: return "NOT FOUND n/a" except crexc.OmitReferenceTypeError: return None except Exception as exc: if log.get_exception_trap(): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_best_ref(self, header_in):\n header_in = dict(header_in)\n log.verbose(\"Getting bestrefs:\", self.basename, verbosity=55)\n expr_header = utils.condition_header_keys(header_in)\n self.check_rmap_omit(expr_header) # Should bestref be omitted based on rmap_omit expr?\n ...
[ "0.65399826", "0.63303155", "0.58166724", "0.56890595", "0.5620219", "0.5607178", "0.5595612", "0.54113394", "0.5389037", "0.5344463", "0.5336916", "0.5293894", "0.52344364", "0.5233662", "0.52096534", "0.5206609", "0.51923794", "0.51888233", "0.51846033", "0.5181724", "0.512...
0.78032064
0
Calls dnr_check function from an observatory locate.py module. Returns True if conditions are met for a Do Not Reprocess dataset, which allows _get_best_ref to consider the reftype as irrelevant, and effectively sets the best reference as "NOT FOUND N/A" instead of throwing an error. Returns False if the dnr_check func...
def dnr_check(self, header): try: return self.locate.dnr_check(header) except Exception: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _referencedChecker(self, entity, params):\n\n if 'ref_logic' not in params:\n return False\n\n logic = self.helper.getLogicForItem(params, 'ref_logic')\n filter = {\n params['ref_field']: entity.key()\n }\n ref_entity = logic.getForFields(filter=filter, unique=True)\n\n result...
[ "0.542884", "0.5306924", "0.50712955", "0.506827", "0.506827", "0.50459373", "0.49886557", "0.49859595", "0.49559534", "0.49388665", "0.49249467", "0.49221686", "0.48443177", "0.48343343", "0.48326856", "0.48051947", "0.4798201", "0.47870502", "0.47146225", "0.47100133", "0.4...
0.59603035
0