query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Transform a list to a string formated as needed by ee.data.getMapId
def visparamsListToStr(params): n = len(params) if n == 1: newbands = '{}'.format(params[0]) elif n == 3: newbands = '{},{},{}'.format(params[0], params[1], params[2]) else: newbands = '{}'.format(params[0]) return newbands
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ilist_to_string(ilist):\n return ','.join([str(i.id) for i in ilist])", "def ids_to_string(idlist):\r\n if len(idlist) == 1:\r\n return \"{:d}\".format(idlist[0])\r\n else:\r\n return \"-\".join([\"{:d}\".format(id) for id in idlist])", "def _toStr(toL...
[ "0.729713", "0.68306583", "0.6754455", "0.65001553", "0.6493538", "0.6473663", "0.63421607", "0.6309583", "0.6294838", "0.62305075", "0.6191517", "0.61853415", "0.61712337", "0.61606354", "0.61281884", "0.60822123", "0.60800713", "0.6073825", "0.6043308", "0.5988336", "0.5984...
0.0
-1
Creates the dataset supplied to a machine learning model
def create_dataset(learning_sets=1000, strategy_func=None): player_strategy_func = functools.partial(record_results, strategy_func=strategy_func) pazaak.player = Player.create_computer( "MLTrainee", strategy_func=player_strategy_func) pazaak.opponent = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dataset(request):\n X, y = make_classification(\n n_samples=700, n_features=10, n_informative=8, n_redundant=2,\n n_classes=2, n_clusters_per_class=2, random_state=6483\n )\n\n request.cls.dataset = Dataset(X, y)", "def make_dataset():\n\n\tnumberOfTrials = dataset_params.num_of_sample...
[ "0.746535", "0.73120326", "0.7208702", "0.71942693", "0.7115091", "0.7108602", "0.70534754", "0.7048029", "0.7043748", "0.7016524", "0.70022446", "0.6975309", "0.69719553", "0.6969983", "0.6955111", "0.692997", "0.69233376", "0.69161254", "0.68900263", "0.68848497", "0.688082...
0.0
-1
Return iterable of items of visible settings.
def items(self): return ((name, self.__getitem__(name)) for name in self._visible_setting_names_gen)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iter__(self):\n return self._visible_setting_names_gen", "def itervisible(self):\r\n return (x for x in self.iterall() if x.visible)", "def __iter__(self):\n\n return iter(self._settings)", "def displayable_items(self):\r\n return [self]", "def visibleCustPropertyMap(self):\...
[ "0.7279885", "0.7267947", "0.65820557", "0.63729936", "0.63654995", "0.63602865", "0.6282477", "0.6172064", "0.61598647", "0.61598647", "0.6100472", "0.6078936", "0.6055264", "0.6025614", "0.59961957", "0.5995111", "0.5966118", "0.59611255", "0.5922551", "0.5846191", "0.58214...
0.75481284
0
Return OrderedDict of visible settings (only). v0.3.0b23 Renamed ``as_OrderedDict`` ==> ``as_OD`` to match new classmethods ``log_calls.get_factory_defaults_OD()``, ``log_calls.get_defaults_OD()``. ``as_OrderedDict`` deprecated.
def as_OD(self) -> OrderedDict: od = OrderedDict() for k, v in self._tagged_values_dict.items(): if self._is_visible(k): od[k] = v[1] return od
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_OrderedDict(self) -> OrderedDict:\n # Issue a warning. (and don't do it ALL the time.)\n # In Py3.2+ \"DeprecationWarning is now ignored by default\"\n # (https://docs.python.org/3/library/warnings.html),\n # so to see it, you have to run the Python interpreter\n # with th...
[ "0.72723657", "0.64953995", "0.599914", "0.59140605", "0.5855487", "0.5819378", "0.5805842", "0.57763267", "0.5764847", "0.5680197", "0.56526464", "0.56526464", "0.56526464", "0.56526464", "0.56526464", "0.5554834", "0.54985285", "0.54845226", "0.54612637", "0.5458843", "0.54...
0.7217826
1
Return dict of visible settings only.
def as_dict(self): return dict(self.as_OD())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_settings():\n settings = {}\n for setting in cfg.displayable_setting:\n settings[setting] = getattr(cfg, setting)\n return settings", "def get_settings():\n settings = {}\n for setting in cfg.displayable_setting:\n settings[setting] = getattr(cfg, setting)\n return setting...
[ "0.7164341", "0.7164341", "0.6497938", "0.6436229", "0.6407377", "0.63851285", "0.637306", "0.63516265", "0.61506206", "0.61283076", "0.60858643", "0.6082611", "0.6074878", "0.6063961", "0.6054", "0.60517675", "0.6047326", "0.60042816", "0.60041624", "0.5980791", "0.59798", ...
0.0
-1
Optionally restricts the returned purchases to a given user, by filtering against a `username` query parameter in the URL.
def get_queryset(self): queryset = super(APIListSession, self).get_queryset() name = self.request.QUERY_PARAMS.get('name', None) if name is not None: queryset = queryset.filter(name__istartswith=name) return queryset
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_queryset(self):\n username = self.kwargs.get('username', None)\n filters = {}\n if username:\n filters['user__username'] = username\n return super(PhotosListView, self).get_queryset().filter(**filters)", "def filter_queryset(self, request, queryset, view):\n ...
[ "0.5969605", "0.5967352", "0.5935199", "0.5913032", "0.5907405", "0.56655383", "0.5654719", "0.5545946", "0.5543182", "0.5509911", "0.5503585", "0.5496294", "0.54886097", "0.54850096", "0.54732347", "0.5471758", "0.54525506", "0.5417577", "0.5408846", "0.53820425", "0.537237"...
0.0
-1
Configuration for pagerduty webhooks. should be a list of urls and potentially a method and service key. If no method is given, then by default we use POST.
def _get_config(self): return self._get_from_settings(settings.INTEGRATIONS_PAGER_DUTY_WEBHOOKS, 'service_key')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(__self__, *,\n endpoint_type: pulumi.Input[str],\n endpoint_url: Optional[pulumi.Input[str]] = None):\n pulumi.set(__self__, \"endpoint_type\", 'WebHook')\n if endpoint_url is not None:\n pulumi.set(__self__, \"endpoint_url\", endpoint_url)", ...
[ "0.56825024", "0.55748695", "0.52065146", "0.51284236", "0.5098357", "0.5044752", "0.49917582", "0.49581757", "0.49214095", "0.49090406", "0.4884698", "0.4807357", "0.47881272", "0.47756574", "0.47467887", "0.474105", "0.47324342", "0.4710558", "0.47067958", "0.47038037", "0....
0.48956776
10
Returns the area of the shape
def area(self): raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def area(self):\n return self._ned_shape.area", "def area(self) -> float:\n raise NotImplementedError", "def area(self):\n if len(self.exterior) < 3:\n raise Exception(\"Cannot compute the polygon's area because it contains less than three points.\")\n poly = self.to_shap...
[ "0.859019", "0.8223659", "0.82033783", "0.8161135", "0.8153257", "0.8126897", "0.8097558", "0.808943", "0.8084013", "0.807406", "0.806642", "0.8037737", "0.8026512", "0.8009989", "0.7994286", "0.7991728", "0.7977729", "0.79765373", "0.79758316", "0.7957411", "0.7957411", "0...
0.7534482
87
Equality test between two shapes. For a shape to be equal, it must be of the same type and have the same dimensions. Use the builtin function isinstance to test if an object is of certain class.
def __eq__(self, other): result = False if isinstance(other, Shape) and (self.area == other.area): return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _shape_compare(shape1, shape2):\n if len(shape1) != len(shape2):\n return False\n for s1, s2 in zip(shape1, shape2):\n if s1 != s2:\n return False\n return True", "def __eq__(self, other):\n if self.__class__ != other.__class__:\n return False\n retu...
[ "0.74056536", "0.69240475", "0.6783828", "0.6772851", "0.6606767", "0.65793025", "0.6548446", "0.6503426", "0.6425911", "0.64205295", "0.64096797", "0.63700736", "0.6365644", "0.6365644", "0.63648695", "0.6340254", "0.63392174", "0.63301665", "0.63232285", "0.63153183", "0.62...
0.72085375
1
The negation of __eq__()
def __ne__(self, other): return not self.__eq__(other)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(self, other):\n return not (self == other) # opposite of __eq__", "def __ne__(self, other):\n return not (self == other) # opposite of __eq__", "def __ne__(self, rhs):\n return not self.__eq__(rhs)", "def __ne__(self, other):\r\n return not self.__eq__...
[ "0.86765426", "0.8645536", "0.8535451", "0.8486587", "0.8486587", "0.8486587", "0.8486587", "0.8482508", "0.84345186", "0.8409536", "0.83678347", "0.83592594", "0.83318496", "0.8328637", "0.83278143", "0.83257824", "0.83159024", "0.83159024", "0.8313147", "0.8309293", "0.8308...
0.8435813
16
Returns True if the area this (self) shape is greater than the area of other
def __ge__(self, other): result = False if isinstance(other, Shape) and (self.area >= other.area): result = True return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __le__(self, other):\n result = False\n if isinstance(other, Shape) and (self.area <= other.area):\n result = True\n return result", "def __gt__(self, other):\n result = False\n if isinstance(other, Shape):\n result = not self.__le__(other)\n re...
[ "0.8331194", "0.7953167", "0.76349974", "0.7415147", "0.7393997", "0.71921486", "0.7114024", "0.7082409", "0.7029152", "0.6991529", "0.6942335", "0.6929441", "0.6929441", "0.6870842", "0.67834115", "0.67241895", "0.6692907", "0.6679769", "0.66771895", "0.6631828", "0.6610698"...
0.86083716
0
Returns True if the area of this (self) shape is less than or equal to the area of other
def __le__(self, other): result = False if isinstance(other, Shape) and (self.area <= other.area): result = True return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ge__(self, other):\n result = False\n if isinstance(other, Shape) and (self.area >= other.area):\n result = True\n return result", "def __le__(self, other):\n\t\tif not isinstance(other, Rectangle):\n\t\t\traise NotImplementedError(\"Please use an object of class <Rectangle...
[ "0.8715131", "0.7831714", "0.7559855", "0.7518955", "0.7251432", "0.72309667", "0.71970767", "0.714618", "0.71029073", "0.70804566", "0.70627064", "0.7017961", "0.696284", "0.68677694", "0.6863134", "0.6859571", "0.6795157", "0.67324734", "0.6731651", "0.6712539", "0.6687741"...
0.86514556
1
The negation of __ge__()
def __lt__(self, other): result = False if isinstance(other, Shape): result = not self.__ge__(other) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ge__(self, other):\n return not self < other", "def __neg__(self):\n return self.negated()", "def __ge__(self, other):\n return not (self < other)", "def __ge__(self, other):\n return not (self < other)", "def __ge__(self, other: t.Any) -> bool:\n return self._op_bo...
[ "0.7661835", "0.7584696", "0.75646937", "0.75646937", "0.7480662", "0.74716365", "0.7403784", "0.73606515", "0.73051107", "0.7238806", "0.72060925", "0.7175532", "0.71358085", "0.7128466", "0.7115488", "0.71095836", "0.71095836", "0.7104713", "0.7089538", "0.70445156", "0.704...
0.0
-1
Returns the area of the shape
def area(self): return math.pi * math.pow(self.radius, 2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def area(self):\n return self._ned_shape.area", "def area(self) -> float:\n raise NotImplementedError", "def area(self):\n if len(self.exterior) < 3:\n raise Exception(\"Cannot compute the polygon's area because it contains less than three points.\")\n poly = self.to_shap...
[ "0.859019", "0.8223659", "0.82033783", "0.8161135", "0.8153257", "0.8126897", "0.8097558", "0.808943", "0.8084013", "0.807406", "0.806642", "0.8037737", "0.8026512", "0.8009989", "0.7994286", "0.7991728", "0.7977729", "0.79765373", "0.79758316", "0.7957411", "0.7957411", "0...
0.79501474
21
Converts a partition in the string format (array where the ith value is the cluster label of the ith pattern) to index format (list of arrays, there the kth array contains the pattern indices that belong to the kth cluster)
def convertClusterStringToIndex(partition): clusters = np.unique(partition) nclusters = clusters.size # nclusters = partition.max() # for cluster id = 0, 1, 2, 3, .... finalPartition = [None] * nclusters for c,l in enumerate(clusters): finalPartition[c] = np.where(partition==l)[0].astype(np...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def partitionLabels(self, S: str) -> List[int]:\n \n \n last_indexes = [0]*26\n #creating char array of last occurence of chars in the string\n for i,v in enumerate(S):\n last_indexes[ord(v) - ord('a')] = i\n \n i = 0\n result = []\n while i...
[ "0.5925552", "0.5858884", "0.56210023", "0.55792004", "0.54533696", "0.5421615", "0.5378818", "0.53204715", "0.5143858", "0.5092617", "0.5044954", "0.50094765", "0.50045216", "0.49995995", "0.49965984", "0.49921343", "0.49490908", "0.4915926", "0.49066436", "0.4903262", "0.48...
0.7572422
0
Return the number of vertices.
def n_vertices(self): return len(self.minimized_generators())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_vertices(self):\n return len(self.vertices)", "def num_vertices(self):\n return len(self.vertices)", "def get_vertices_count(self) -> int:\n # TODO: verify the following claim:\n raise NotImplementedError", "def return_num_vertices(self):\n return self.__size", "d...
[ "0.90264654", "0.90264654", "0.90181196", "0.89943784", "0.8987268", "0.89685875", "0.89193565", "0.8867708", "0.87823063", "0.8756588", "0.8621158", "0.8594945", "0.8565224", "0.8559106", "0.83967066", "0.814736", "0.8050035", "0.7982884", "0.7942759", "0.77242476", "0.77136...
0.8068461
16
r""" Return whether the polyhedron is a simplex.
def is_simplex(self): return self.affine_dimension()+1==self.n_vertices()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_simplex(self):\n return self.is_compact() and (self.dim()+1==self.n_vertices())", "def is_lattice_polytope(self):\n try: \n return self._is_lattice_polytope\n except AttributeError:\n pass\n self._is_lattice_polytope = self.is_compact() and \\\n ...
[ "0.7685915", "0.63701785", "0.62163824", "0.61906505", "0.60468453", "0.57904786", "0.57758516", "0.5758545", "0.5755731", "0.5755731", "0.57181674", "0.5689106", "0.565801", "0.5636389", "0.5622241", "0.5606565", "0.55976117", "0.5580155", "0.5566296", "0.5565474", "0.551944...
0.7512576
1
r""" Return the coordinates of a rectangular box containing the nonempty polytope.
def bounding_box(self): box_min = [] box_max = [] if self.is_empty(): raise ValueError('empty polytope is not allowed') for i in range(0, self.space_dimension()): x = Variable(i) coords = [ v.coefficient(x) for v in self.generators() ] max_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_box_coordinates(self):\n return QRect(self.box_begin,self.box_end)", "def get_bounding_box(self):\n if len(self.polygons) == 0:\n return None\n return numpy.array(((min(pts[:, 0].min() for pts in self.polygons),\n min(pts[:, 1].min() for pts...
[ "0.63409775", "0.632882", "0.63254714", "0.61974984", "0.61970156", "0.61970156", "0.6183701", "0.61812335", "0.6176942", "0.617173", "0.61472386", "0.6144035", "0.61042213", "0.60493445", "0.60319835", "0.60307", "0.5999625", "0.5997661", "0.5980633", "0.59701407", "0.595623...
0.65211827
0
Test whether the polytope contains the origin
def contains_origin(self): return self.contains(self.ambient_space().zero())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __contains__(self, point): \n corners = self.corners\n\n if isinstance(point, tuple):\n from pyresample.spherical_geometry import Coordinate\n retval = planar_point_inside(Coordinate(*point), corners)\n else:\n retval = planar_point_inside(point, corners)\n...
[ "0.6899739", "0.6712414", "0.66916883", "0.6679886", "0.66471994", "0.66103554", "0.65895504", "0.65677446", "0.65637016", "0.65357816", "0.6508317", "0.64728767", "0.6442526", "0.6413078", "0.641134", "0.6358808", "0.6354649", "0.6335065", "0.6324314", "0.6319295", "0.630875...
0.719159
0
Can view public album only test can view public photo Photo view inherits permission from album Cannot view other access types cannot edit album or upload photos Cannot add non logged in user to group
def test_not_logged_in(self): # test show album self.perm_escalate_helper(self.albumcontrol, self.showalbumrequest, self.testalbum, self.testalbum.id, AnonymousUser(), album.display_album, ALBUM_PUBLIC) # test photo view self.perm_escalate_helper_get_w...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_logged_in_owner(self):\n self.make_logged_in_owner()\n\n # test show album\n self.perm_escalate_helper(self.albumcontrol, self.showalbumrequest, self.testalbum, self.testalbum.id,\n self.u, album.display_album, ALBUM_PRIVATE)\n\n # test photo vi...
[ "0.71027064", "0.70107204", "0.6759053", "0.67118376", "0.6653932", "0.6425039", "0.63897693", "0.6334919", "0.6330488", "0.6147539", "0.6105312", "0.61035687", "0.59973615", "0.5973367", "0.5963133", "0.59630114", "0.5957307", "0.5941269", "0.59344816", "0.5929374", "0.59285...
0.6730464
3
Only owner can edit album access type
def test_post_change_access_type_as_owner(self): assert self.testalbum.accesstype != ALBUM_GROUPS self.make_logged_in_owner() # get our manage page with form resp = self.client.get(reverse('manage_album', kwargs={'albumid': self.testalbum.id})) # get and populate form m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_post_change_access_type_as_not_owner(self):\n self.make_logged_in_owner()\n\n # get our manage page with form (use self.u as self.u2 will not obtain the form)\n # using self.u will not affect our test later because we aren't using the client later\n resp = self.client.get(rever...
[ "0.6623354", "0.6365966", "0.63652945", "0.59733254", "0.5968752", "0.5968712", "0.59127766", "0.58734393", "0.584542", "0.5844539", "0.5831569", "0.58220494", "0.58199775", "0.58112174", "0.57121664", "0.56697106", "0.5665176", "0.56256956", "0.55976534", "0.55976534", "0.55...
0.7004207
0
Draw bounding boxes and face landmarks on image.
def show_faces(boxes, landmarks): count = 1 for bb, _ in zip(boxes, landmarks): x1, y1, x2, y2 = int(bb[0]), int(bb[1]), int(bb[2]), int(bb[3]) w = x2 - x1 h = y2 - y1 print("face ID: {}".format(count)) print("confidence= {}; x1= {}, y1= {}; w= {}, h={}".format(float(bb[4...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_bboxes(img, bounding_boxes=None, facial_landmarks=[]):\n\n img_copy = img.copy()\n draw = ImageDraw.Draw(img_copy)\n# for b in bounding_boxes:\n# draw.rectangle([\n# (b[0], b[1]), (b[2], b[3])\n# ], outline='white')\n\n for p in facial_landmarks:\n for i...
[ "0.74263984", "0.71847194", "0.71534646", "0.681396", "0.67984676", "0.67735565", "0.6728688", "0.66572297", "0.6576932", "0.65266746", "0.64973855", "0.64893055", "0.64694124", "0.64526737", "0.6439481", "0.63985014", "0.63944423", "0.63930523", "0.637468", "0.6362509", "0.6...
0.6034798
42
Return only unread items in the current queryset
def unread(self): return self.filter(unread=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(self):\n return self.filter(unread=False)", "def mark_all_as_unread(self, recipient=None):\n qs = self.read()\n if recipient:\n qs = qs.filter(recipient=recipient)\n\n return qs.update(unread=True)", "def show_unread_only(self):\n return getattr(self.curre...
[ "0.70482844", "0.682411", "0.66922337", "0.6524507", "0.6502747", "0.64200646", "0.6319133", "0.6289243", "0.6133515", "0.61255664", "0.6113764", "0.60435224", "0.60361713", "0.5991643", "0.5987574", "0.59566915", "0.59405494", "0.589638", "0.5888084", "0.58750683", "0.586536...
0.83509827
0
Return only read items in the current queryset
def read(self): return self.filter(unread=False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_queryset(self):\n assigned_only = bool(\n int(self.request.query_params.get('assigned_only', 0))\n )\n queryset = self.queryset\n if assigned_only:\n queryset = queryset.filter(recipe__isnull=False)\n\n return queryset.filter(user=self.request.user)....
[ "0.6898312", "0.6880635", "0.6769891", "0.6681806", "0.65600204", "0.6555961", "0.65422046", "0.65367025", "0.6507255", "0.6498471", "0.649454", "0.64729667", "0.64707977", "0.64580935", "0.64251167", "0.642261", "0.64035976", "0.6399541", "0.628724", "0.62831336", "0.6277897...
0.6651604
4
Mark as read any unread elements in the current queryset with optional filter by recipient first.
def mark_all_as_read(self, recipient=None): qs = self.unread() if recipient: qs = qs.filter(recipient=recipient) return qs.update(unread=False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mark_all_as_unread(self, recipient=None):\n qs = self.read()\n if recipient:\n qs = qs.filter(recipient=recipient)\n\n return qs.update(unread=True)", "def mark_all_notifications_as_read(self):\n for n in Notification.objects(owner=self, unread=True):\n n.unread = Fa...
[ "0.8149184", "0.6695991", "0.65963686", "0.6445189", "0.6266585", "0.6145472", "0.6115554", "0.60817283", "0.6014856", "0.60138476", "0.5950054", "0.5920773", "0.59200925", "0.58971286", "0.58797807", "0.5798755", "0.57938415", "0.57885987", "0.57164454", "0.57032067", "0.566...
0.8287843
0
Mark as unread any read elements in the current queryset with optional filter by recipient first.
def mark_all_as_unread(self, recipient=None): qs = self.read() if recipient: qs = qs.filter(recipient=recipient) return qs.update(unread=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mark_all_as_read(self, recipient=None):\n qs = self.unread()\n if recipient:\n qs = qs.filter(recipient=recipient)\n\n return qs.update(unread=False)", "def mark_all_notifications_as_read(self):\n for n in Notification.objects(owner=self, unread=True):\n n.unread = F...
[ "0.8241442", "0.6823792", "0.6467324", "0.64359885", "0.6303324", "0.6250385", "0.61088943", "0.6077141", "0.605408", "0.595215", "0.5885047", "0.57958233", "0.57116383", "0.5692349", "0.5681563", "0.56339556", "0.56147397", "0.5589526", "0.5587749", "0.5557525", "0.5487218",...
0.82400215
1
Create superuser account with profile.
def forwards(self, orm): location_type = orm['mooi.Location'] if len(location_type.objects.all()) == 0: l = location_type(city="Lethbridge", country="Canada") l.save() else: l = location_type.objects.all()[0] user_type = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_superuser(username, email, password):\n if username and email and password:\n user, created = User.objects.get_or_create(pk=defaults.USERWARE_SUPERUSER_ID)\n if user:\n user.username = username\n user.email = email\n user.set_password(password)\n ...
[ "0.76332116", "0.7566097", "0.7477461", "0.74764544", "0.7279949", "0.725951", "0.7222048", "0.721943", "0.72176826", "0.7211102", "0.7200973", "0.7199087", "0.71972203", "0.71915865", "0.71893543", "0.71846783", "0.7175617", "0.71663225", "0.71592563", "0.71470547", "0.71470...
0.0
-1
Sets up the environment before each unit test is to be executed. Currently doing nothing. But can be used later
def setUp(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n test_env_setup()", "def SetupEnvironment(self):\n pass", "def setUp(self) -> None:\n\n self.helper = EnvironmentVariableHelper()\n\n self.test_name = \"PYFUNCEBLE_TESTING\"\n self.temp_env_file = tempfile.NamedTemporaryFile(\"w\", delete=False)", "def _set_up...
[ "0.8525599", "0.75550187", "0.7542546", "0.74949723", "0.74695784", "0.74695784", "0.74204147", "0.7413349", "0.7376618", "0.7376618", "0.73672885", "0.73343885", "0.7234784", "0.7198547", "0.7191751", "0.718753", "0.718674", "0.718674", "0.7176137", "0.7170364", "0.71680677"...
0.70038
59
Sets up the environment before each unit test is to be executed. Currently doing nothing. But can be used later
def tearDown(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n test_env_setup()", "def SetupEnvironment(self):\n pass", "def setUp(self) -> None:\n\n self.helper = EnvironmentVariableHelper()\n\n self.test_name = \"PYFUNCEBLE_TESTING\"\n self.temp_env_file = tempfile.NamedTemporaryFile(\"w\", delete=False)", "def _set_up...
[ "0.8524596", "0.7553352", "0.7541603", "0.7495074", "0.7469093", "0.7469093", "0.74202925", "0.74127406", "0.7375052", "0.7375052", "0.7366469", "0.7334497", "0.7234067", "0.7197635", "0.7191083", "0.7186808", "0.71858484", "0.71858484", "0.7176271", "0.71698034", "0.71675646...
0.0
-1
Unload a config entry.
async def async_unload_entry(hass, config_entry) -> bool: unload_ok = await hass.config_entries.async_unload_platforms( config_entry, PLATFORMS ) for listener in hass.data[DOMAIN][config_entry.entry_id][DATA_LISTENER]: listener() username = config_entry.title if unload_ok: ha...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def async_unload_entry(hass, config_entry):\n unload_ok = await hass.config_entries.async_forward_entry_unload(\n config_entry, \"climate\"\n )\n return unload_ok", "async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:\n hass.data.pop(DOMAIN)\n return True", ...
[ "0.697284", "0.6888074", "0.6779855", "0.6747459", "0.6689002", "0.6657831", "0.66162205", "0.6603433", "0.65925974", "0.65595686", "0.65411645", "0.6507643", "0.6507643", "0.6507643", "0.6507643", "0.64977276", "0.64931643", "0.6486601", "0.6486601", "0.6486601", "0.6486601"...
0.6331371
49
Return the state attributes of the device.
def extra_state_attributes(self): attr = self._attributes if self.tesla_device.has_battery(): attr[ATTR_BATTERY_LEVEL] = self.tesla_device.battery_level() attr[ATTR_BATTERY_CHARGING] = self.tesla_device.battery_charging() return attr
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def device_state_attributes(self):\r\n return self.attributes", "def device_state_attributes(self):\r\n return self._attributes", "def device_state_attributes(self):\n return self._state_attrs", "def device_state_attributes(self):\n return self._state_attrs", "def device_state_a...
[ "0.92738223", "0.92053986", "0.91516256", "0.91516256", "0.9148889", "0.9148889", "0.9148889", "0.9148889", "0.9148889", "0.9148889", "0.9148889", "0.9148889", "0.9148889", "0.9148889", "0.9148889", "0.9148889", "0.9148889", "0.9148746", "0.9148746", "0.9137698", "0.9110632",...
0.71577644
97
Asserts tensors are all valid types (see `_valid_dtypes`).
def assert_valid_dtypes(tensors): valid_dtypes = get_valid_dtypes() for t in tensors: dtype = t.dtype.base_dtype if dtype not in valid_dtypes: raise ValueError( "Invalid type %r for %s, expected: %s." % ( dtype, t.name, [v for v in valid_dtypes]))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _assert_float32(tensors):\n if not isinstance(tensors, dict):\n tensors = [tensors]\n else:\n tensors = tensors.values()\n for tensor in tensors:\n if tensor.dtype.base_dtype != dtypes.float32:\n raise TypeError('Expected dtype=float32, %s.' % tensor)", "def _check_tensor_shapes(tensors):\n ...
[ "0.7506081", "0.73362756", "0.71375376", "0.6766203", "0.67619795", "0.66803056", "0.66416717", "0.66136044", "0.65626323", "0.65183413", "0.6508184", "0.64626044", "0.63577646", "0.63570553", "0.6276486", "0.6239653", "0.62203544", "0.6192686", "0.6172948", "0.61684495", "0....
0.8475636
0
Perform shunting yard algorithm on a intfix expression, converting it to postfix
def toPostfix(infix): output = "" # Output stack - the numbers in our expression operators = "" # Operator stack (using string for ease but could be a list) precedence = {"*": 100, "/": 90, "+": 80, "-": 70, "(": 60, ")": 50} # Operator precedence dictionary - operator characters mapped to an arbitrary num...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shunt(infix):\n #convert input to a stack list\n infix=list(infix)[::-1]\n #operator stack and output list as empty lists\n opers,postfix =[],[]\n #operator precedence\n prec={'*':100,'.':90, '|':80, '/':80, '\\\\':80, ')':70, '(':60}\n\n #loop through input one character at a time\n...
[ "0.7443024", "0.7406202", "0.7386452", "0.70468843", "0.70278895", "0.70041054", "0.6984032", "0.6950477", "0.69484496", "0.6902685", "0.68938285", "0.6893169", "0.68559843", "0.68503684", "0.6847236", "0.67644864", "0.6705752", "0.6704068", "0.67032105", "0.6632743", "0.6583...
0.7235973
3
Returns `(wdl, policy)` `input` is a tensor of shape (B, 5, 9, 9) `wdl` is a tensor of shape (B, 3) with win/draw/loss logits `policy` is a tensor of shape (B, 9, 9)
def forward(self, input): common = self.common_tower(input) wdl = self.wdl_head(common) policy = self.policy_head(common) return wdl, policy
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_policy_value_net(self): \n with tf.name_scope(\"inputs\"):\n self.state_input = tf.placeholder(tf.float32, shape=[None, 4, self.board_width, self.board_height], name=\"state\")\n# self.state = tf.transpose(self.state_input, [0, 2, 3, 1])\n \n self.w...
[ "0.64060295", "0.6375401", "0.619609", "0.59501207", "0.5941833", "0.59387183", "0.5844711", "0.574098", "0.5738611", "0.57171434", "0.5714585", "0.5713394", "0.5707327", "0.57007277", "0.5688644", "0.5647133", "0.56270766", "0.5596827", "0.5556138", "0.55426383", "0.55329776...
0.6360984
2
add money from another money instance
def add(self, another: 'Money'): self.amount += another.amount
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __add__(self, other):\n if type(other) == int or type(other) == float:\n x = (other * Ccy.currencies[self.unit])\n else:\n x = (other.value / Ccy.currencies[other.unit] * Ccy.currencies[self.unit])\n return Ccy(x + self.value, self.unit)", "def add(self, amount=0.0,...
[ "0.77010214", "0.7309261", "0.7299525", "0.71722984", "0.7103269", "0.6977607", "0.69049823", "0.6864783", "0.6840795", "0.68180084", "0.6779612", "0.67316747", "0.6633485", "0.66250294", "0.6614977", "0.66145754", "0.66079766", "0.6600268", "0.6568502", "0.65442556", "0.6535...
0.8203601
0
Sets the learning rate to the initial LR decayed by 10 every 30 epochs
def adjust_learning_rate(optimizer, epoch): lr = LEARNING_RATE * (0.1 ** (epoch // 10)) for param_group in optimizer.param_groups: param_group['lr'] = lr
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr", "def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l...
[ "0.79140896", "0.7908034", "0.7850816", "0.7776915", "0.7735598", "0.7732588", "0.7723862", "0.77235436", "0.77208304", "0.7710736", "0.76948273", "0.7675381", "0.76670265", "0.76670265", "0.76670265", "0.7657111", "0.76431805", "0.7640621", "0.7639109", "0.76275903", "0.7625...
0.7497913
56
check if email name exists
def check_user_email(self, email): useremails = [] for user in self.__users: if user['email'] == email: useremails.append(user) return useremails
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_email(self, data, field_name):\n existing = User.objects.filter(email__iexact=data['email'])\n if existing.exists():\n raise fields.ValidationError(\"A user with that email already exists.\")\n else:\n return data", "def email_exists(self, input_email):\n ...
[ "0.7598863", "0.7505227", "0.74932563", "0.73975956", "0.7233865", "0.7220981", "0.7185408", "0.71058303", "0.70901567", "0.70203346", "0.696664", "0.69582343", "0.69582343", "0.692829", "0.692491", "0.690814", "0.6891653", "0.68747824", "0.6872933", "0.6863027", "0.68582296"...
0.0
-1
Compute Mean Decrease Impurity
def feat_imp_MDI(fit, feat_names): df0 = {i: tree.feature_importances_ for i, tree in enumerate(fit.estimators_)} df0 = pd.DataFrame.from_dict(df0, orient='index') df0.columns = feat_names df0 = df0.replace(0, np.nan) imp = pd.concat({"mean": df0.mean(), "std": df0.std() * (df0.shape[0] ** -0.5)}, a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def em_mean(self) -> float:\n if self.__total_pulls == 0:\n raise Exception('Number of pulls is 0. No empirical mean.')\n return self.__total_rewards / self.__total_pulls", "def penalty(self):\n assert len(self.weights) == len(self.means), \"Dimensions!\"\n out = np.exp(self.data['riskfr...
[ "0.6738428", "0.65751326", "0.6504247", "0.64743066", "0.63883114", "0.6367197", "0.6367197", "0.6359551", "0.6328843", "0.6274222", "0.62369144", "0.6224393", "0.62218136", "0.620982", "0.61958605", "0.61889756", "0.61721057", "0.6153389", "0.6136677", "0.6130705", "0.612178...
0.0
-1
Compute Mean Decrease Impurity
def feat_imp_MDI_clustered(fit, feat_names, clstrs): df0 = {i:tree.feature_importances_ for i, tree in enumerate(fit.estimators_)} df0 = pd.DataFrame.from_dict(df0, orient='index') df0.columns = feat_names df0 = df0.replace(0, np.nan) #because max_features=1 imp = group_mean_std(df0, clstrs) imp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def em_mean(self) -> float:\n if self.__total_pulls == 0:\n raise Exception('Number of pulls is 0. No empirical mean.')\n return self.__total_rewards / self.__total_pulls", "def penalty(self):\n assert len(self.weights) == len(self.means), \"Dimensions!\"\n out = np.exp(self.data['riskfr...
[ "0.6738428", "0.65751326", "0.6504247", "0.64743066", "0.63883114", "0.6367197", "0.6367197", "0.6359551", "0.6328843", "0.6274222", "0.62369144", "0.6224393", "0.62218136", "0.620982", "0.61958605", "0.61889756", "0.61721057", "0.6153389", "0.6136677", "0.6130705", "0.612178...
0.0
-1
Find closest match for RGB value in a list of values
def find_best_tile(rgblist, avg_rgb): nearest_match = 0 # index of matching tile rgb entry in rgblist smallest_dif = 9999999 matches = [] for i, v in enumerate(rgblist): diff_r, diff_g, diff_b = rgb_difference(avg_rgb, v) dif = diff_r+diff_g+diff_b # combined component difference ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recognize_color(color, palette):\n min_distance = np.inf\n most_similar_color = None\n for cname, cvalue in palette.items():\n distance = np.sum(np.abs(np.array(color) - np.array(cvalue)))\n if distance < min_distance:\n min_distance = distance\n most_similar_color ...
[ "0.68546337", "0.6765456", "0.6623281", "0.65899837", "0.6561299", "0.646242", "0.6360151", "0.63391995", "0.63147473", "0.6251739", "0.61985415", "0.6196607", "0.6191791", "0.61638075", "0.60804695", "0.60673904", "0.6057577", "0.604574", "0.6020293", "0.5969926", "0.5955155...
0.67357403
2
Given a list of sequences, returns a list of all the Nth elements of all the contained sequences
def nths(x, n): return [l[n] for l in x]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_n(sequence: Sequence[T], n: int) -> List[T]:\n\t\n\tfor i in range(len(sequence) - (n-1)):\n\t\tyield sequence[i:i+n]", "def take(n, seq):\n seq = iter(seq)\n result = []\n try:\n for i in range(n):\n result.append(next(seq))\n except StopIteration:\n pass\n retur...
[ "0.67824453", "0.6711831", "0.6682033", "0.6622858", "0.65729344", "0.65729344", "0.65345293", "0.6462962", "0.6442502", "0.63893867", "0.63618004", "0.6296349", "0.62567306", "0.62521297", "0.62317187", "0.62030333", "0.6199455", "0.61901057", "0.6173687", "0.616543", "0.614...
0.6288655
12
Creates a Pandas DataFrame from evaluated arms then returns it. The method should be called to fetch evaluation results of arms that are populated and evaluated so far.
def list_parameter_value_scores( self, legit_arms_only: bool = False ) -> pd.DataFrame: # For experiments which have not ran generate_evaluate_new_parameter_values, # we cannot provide trial data without metrics, so we return empty dataframe if not self._exp.metrics: ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_pandas(self):\n return pd.DataFrame(self.results)", "def eval(self, expr, **kwargs):\n return DataFrameDefault.register(pandas.DataFrame.eval)(\n self, expr=expr, **kwargs\n )", "def calc(self) -> pd.DataFrame:\n raise NotImplementedError", "def to_dataframe(sel...
[ "0.6268015", "0.61456525", "0.60872823", "0.6067448", "0.6017158", "0.59829694", "0.5928756", "0.5867335", "0.57907546", "0.5744226", "0.57348514", "0.57159543", "0.57092667", "0.5661073", "0.56391126", "0.56378055", "0.5622132", "0.5620824", "0.56201214", "0.5615019", "0.560...
0.0
-1
Deletes the asset along with all related files.
def purge(self): from models.accounts import Account # Make sure we have access to the associated account frame if not isinstance(self.account, Account): self.account = Account.one(Q._id == self.account) # Get the backend required to delete the asset backend = self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(self):\n\n try:\n remove(self.file)\n except OSError:\n pass", "def delete(self):\n\t\tif self.hasUdim:\n\t\t\tfor a in self.udimPaths:\n\t\t\t\ta.delete()\n\t\telse:\n\t\t\tsuper( textureFile, self ).delete()", "def delete(self, *args, **kwargs):\...
[ "0.7099656", "0.7088097", "0.70433116", "0.7038795", "0.703813", "0.7019916", "0.6939001", "0.68539244", "0.6824652", "0.67941606", "0.6768188", "0.6751628", "0.674828", "0.6718848", "0.67148787", "0.66472703", "0.6611027", "0.6574475", "0.65682936", "0.6568066", "0.6565361",...
0.7396225
0
Sends a 401 response that enables basic auth
def authenticate(): return Response( 'Could not verify your access level for that URL.\n' 'You have to login with proper credentials', 401, {'WWW-Authenticate': 'Basic realm="Login Required"'})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate():\n return Response('Not Authorized', 401, {'WWW-Authenticate': 'Basic realm=\"api\"'})", "def authenticate():\n return Response(\n '', 401, {'WWW-Authenticate': 'Basic realm=\"Login Required\"'}\n )", "def authenticate():\n return Response(\n 'You have to login with pro...
[ "0.8093736", "0.80926424", "0.7958403", "0.7852648", "0.7843114", "0.7824419", "0.776624", "0.7754693", "0.774767", "0.774767", "0.774767", "0.774767", "0.774767", "0.774767", "0.774767", "0.774767", "0.771945", "0.7667712", "0.7664151", "0.76493174", "0.76140213", "0.76131...
0.7810746
12
r"""calculate innerproduct of two vectors
def inner_product_similarity(a: torch.Tensor, b: torch.Tensor, dim=1) -> torch.Tensor: outputs = (a * b).sum(dim=dim) return outputs
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vectordot(a, b):\n return np.sum(a * b, 1)", "def outer_product(x,y):\n\n return x[:,0]*y[:,1] -x[:,1]*y[:,0]", "def dotProduct(v1, v2):\n return sum((a * b) for a, b in zip(v1, v2))", "def dotproduct(vec1, vec2):\n return sum((a*b) for a, b in zip(vec1, vec2))", "def inner_prod(x, y):\n ...
[ "0.78818625", "0.7840256", "0.78061914", "0.7664833", "0.7597032", "0.7539705", "0.75373507", "0.7528351", "0.75119084", "0.7494979", "0.74937993", "0.7483999", "0.7404615", "0.73875093", "0.7378977", "0.7344735", "0.7322445", "0.7317016", "0.729418", "0.72655314", "0.7254504...
0.711213
27
Convert two coordinates to distance. This is an approximation since the earth is not spherical, but accuracy is <100m, especially for close points
def latlon2distance(lat1, long1, lat2, long2, miles=False): global verbose if lat1 == lat2 and long1 == long2: return 0 # Convert latitude and longitude to # spherical coordinates in radians. degrees_to_radians = math.pi / 180.0 # phi = 90 - latitude phi1 = (90.0 - lat1) * degree...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distance(lat1, lon1, lat2, lon2):\n lon1, lat1 = math.radians(lon1), math.radians(lat1)\n lon2, lat2 = math.radians(lon2), math.radians(lat2)\n a = (math.sin((lat2 - lat1) / 2) ** 2 +\n math.cos(lat1) * math.cos(lat2) * math.sin((lon2 - lon1) / 2) ** 2)\n c = 2 * math.atan2(math.sqrt(a), ma...
[ "0.77847093", "0.7778113", "0.7691996", "0.76404685", "0.7635144", "0.76170677", "0.75912017", "0.758252", "0.75410104", "0.7538496", "0.7533932", "0.7513564", "0.7489735", "0.74745035", "0.7469778", "0.74419445", "0.743006", "0.7417641", "0.7414186", "0.7389299", "0.73878515...
0.7250461
37
Asks user to specify a city, month, and day to analyze.
def get_filters(): print('Hello! Let\'s explore some US bikeshare data!') while True: # initialize variables city = str() month = str() day = str() # get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs va...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)", "def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f...
[ "0.66714007", "0.65354675", "0.64593667", "0.6374057", "0.6348314", "0.63097656", "0.62868035", "0.6259136", "0.62316", "0.62130964", "0.62050414", "0.6181105", "0.6171822", "0.61686903", "0.6158568", "0.61582303", "0.61532456", "0.61444426", "0.6131269", "0.610484", "0.61025...
0.5765217
73
Loads data for the specified city and filters by month and day if applicable.
def load_data(city, month, day): # load data file into a dataframe df = pd.read_csv(CITY_DATA[city]) # convert the Start Time column to datetime df['Start Time'] = pd.to_datetime(df['Start Time']) # extract month and day of week from Start Time to create new columns df['month'] = df['Start Ti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ...
[ "0.81320685", "0.8108889", "0.8045821", "0.8042514", "0.80090284", "0.80071104", "0.79991937", "0.7998333", "0.7988789", "0.797905", "0.79737365", "0.79610896", "0.7956163", "0.7947432", "0.79463065", "0.7908287", "0.7908229", "0.7904569", "0.7900715", "0.78930074", "0.788921...
0.7762852
44
Displays statistics on the most frequent times of travel.
def time_stats(df): print('\nCalculating The Most Frequent Times of Travel...\n') start_time = time.time() # display the most common month df['Month'] = df['Start Time'].dt.month popular_month = df['Month'].mode()[0] months = ['january', 'february', 'march', 'april', 'may', 'june'] popular...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\...
[ "0.80235124", "0.80223495", "0.7914819", "0.78260994", "0.7821642", "0.78139323", "0.77653635", "0.7739615", "0.77358055", "0.7733576", "0.7686211", "0.7667902", "0.76510555", "0.76440334", "0.76391727", "0.7636328", "0.7624661", "0.7622607", "0.76119757", "0.7599401", "0.758...
0.7375577
48
Displays statistics on the most popular stations and trip.
def station_stats(df): print('\nCalculating The Most Popular Stations and Trip...\n') start_time = time.time() # display most commonly used start station popular_start_station = df['Start Station'].mode()[0] print('The most common start station is {}.'.format(popular_start_station)) # displa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m...
[ "0.7815675", "0.7662213", "0.7553417", "0.74914914", "0.74748665", "0.7446617", "0.7428588", "0.74237514", "0.74177027", "0.7400495", "0.7387161", "0.7385634", "0.73647535", "0.735934", "0.73566747", "0.73548365", "0.7351854", "0.735057", "0.73421645", "0.7340198", "0.7337384...
0.7351274
17
Displays statistics on the total and average trip duration.
def trip_duration_stats(df): print('\nCalculating Trip Duration...\n') start_time = time.time() # display total travel time total_travel_time = df['Trip Duration'].sum() print('The total travel time is {} seconds.'.format(total_travel_time)) # display mean travel time mean_travel_time = d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri...
[ "0.814274", "0.8025143", "0.80041367", "0.79496753", "0.7937415", "0.79312176", "0.7926815", "0.7915187", "0.79142886", "0.7908032", "0.79055744", "0.7900715", "0.7891682", "0.78894734", "0.7886722", "0.78851086", "0.7884266", "0.7882474", "0.78738385", "0.78686154", "0.78664...
0.779246
50
Renders the home page.
def home(request): assert isinstance(request, HttpRequest) if request.method == 'POST': form = ExecuteForm(request.POST) if form.is_valid(): param_values = form.param_values() active_requirements = retrieve_governance_processes.get_active_requirements(param_values) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_home():\r\n\treturn render_template(\"index.html\")", "def home():\n\n return render_template('home_page.html')", "def home():\n\n return render_template(\"home.html\")", "def home():\n return render_template('home.html')", "def home():\n return render_template('home.html')", "def ...
[ "0.85574406", "0.853399", "0.8351404", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.82762724", "0.827363", "...
0.0
-1
Sort keys in natural order. alist.sort(key=natural_keys) sorts in human order
def _natural_keys(text: str) -> list[int | str]: return [_atoi(c) for c in re.split(r"(\d+)", text)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def natural_sorted(iterable, key=None, reverse=False):\n prog = re.compile(r\"(\\d+)\")\n\n def alphanum_key(element):\n \"\"\"Split given key in list of strings and digits\"\"\"\n return [int(c) if c.isdigit() else c for c in prog.split(element[0])]\n\n return sorted(iterable, key=alphanum_...
[ "0.72135127", "0.7069677", "0.70522374", "0.7022288", "0.6996026", "0.69952947", "0.69952947", "0.69942534", "0.6935378", "0.6918341", "0.68842477", "0.68387383", "0.67742425", "0.6752038", "0.6741934", "0.6623228", "0.6603354", "0.65939903", "0.6506977", "0.64753", "0.642262...
0.57556057
68
Returns the minimax action using self.depth and self.evaluationFunction
def getAction(self, gameState): "*** YOUR CODE HERE ***" def MaxValue(gameState, currentDepth, agentNumber, alpha, beta): if currentDepth is self.depth or gameState.isWin() or gameState.isLose(): return (self.evaluationFunction(gameState), Directions.NORTH) largestValue = float...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = minimax(self.evaluationFunction, 1, 0,\n gameState.generateSuccessor(0, move), self.depth)\n if util > _max o...
[ "0.7482665", "0.7383559", "0.71806973", "0.7110041", "0.70884514", "0.70694935", "0.70683014", "0.7048308", "0.70055133", "0.69651455", "0.69642085", "0.69604385", "0.6945924", "0.68998593", "0.6895832", "0.688605", "0.6826282", "0.6767276", "0.6758028", "0.6751636", "0.67054...
0.62381893
91
Returns an action. You can use any method you want and search to any depth you want. Just remember that the minicontest is timed, so you have to trade off speed and computation. Ghosts don't behave randomly anymore, but they aren't perfect either they'll usually just make a beeline straight towards Pacman (or away from...
def getAction(self, gameState): "*** YOUR CODE HERE ***" def betterEvaluationFunction(currentGameState): """ Your extreme ghost-hunting, pellet-nabbing, food-gobbling, unstoppable evaluation function (question 5). DESCRIPTION: <write something here so we know what you did> ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAction(self, gameState):\n return self.minimax(gameState, self.depth, 0)", "def getAction(self, gameState):\n \"*** YOUR CODE HERE ***\"\n def minMaxHelper(gameState, deepness, agent):\n if agent >= gameState.getNumAgents():\n agent = 0\n deepness ...
[ "0.681938", "0.67913616", "0.6711234", "0.6693713", "0.6639412", "0.66190666", "0.66154623", "0.66107804", "0.6582712", "0.6574378", "0.65683085", "0.6560998", "0.65354615", "0.652438", "0.6507904", "0.6482287", "0.64716065", "0.64590627", "0.64441186", "0.64328986", "0.64254...
0.0
-1
Return random sequence from given symbols.
def r_string(symbols, length): return ''.join(R.choice(symbols) for _ in range(length))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_random_string(symbols, length):\n sym_list = symbols.split()\n str_list = random.sample(sym_list, length)\n gen_string = ''.join(str_list)\n return gen_string", "def r_symbols(size, symbols, length, used=None):\n if length == 1 and not used:\n return R.sample(symbols, size)\n rset, ...
[ "0.6912479", "0.6896193", "0.64176685", "0.63608897", "0.63608897", "0.62606645", "0.6181966", "0.60993093", "0.6035954", "0.6015151", "0.60045147", "0.5866798", "0.58473676", "0.577889", "0.5687884", "0.5680363", "0.56696355", "0.5622887", "0.5582495", "0.5570999", "0.557099...
0.6241128
6
Return unique random from given symbols.
def r_symbols(size, symbols, length, used=None): if length == 1 and not used: return R.sample(symbols, size) rset, used = set(), set(used or []) while len(rset) < size: s = r_string(symbols, R.randint(1, length)) if s not in used: rset.add(s) return list(rset)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_random_string(symbols, length):\n sym_list = symbols.split()\n str_list = random.sample(sym_list, length)\n gen_string = ''.join(str_list)\n return gen_string", "def random_name(symbols=6):\n name = ''\n for i in range(symbols):\n name += random.choice(random.choice(string.a...
[ "0.68097275", "0.6796289", "0.6531428", "0.63834316", "0.6230177", "0.6142438", "0.6130961", "0.6090409", "0.605147", "0.60116196", "0.60116196", "0.59850353", "0.5915632", "0.59008545", "0.58801645", "0.5849815", "0.5848722", "0.5843362", "0.5842244", "0.5842244", "0.5809862...
0.72217846
0
Returns an image cropped to a given bounding box of topleft coords, width, and height
def crop(img: 'np.ndarray', x: int, y: int, width: int, height: int) -> 'np.ndarray': return img[y:y+height, x:x+width]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def crop_bounding_box(im, x, y, w, h):\n return im[y:y+h, x:x+w]", "def crop_img(image, bound):\n scale = 1.01 # 1%\n return image.crop((bound.vertices[0].x // scale, bound.vertices[0].y // scale,\n int(bound.vertices[2].x * scale), int(bound.vertices[2].y) * scale))", "def ...
[ "0.8006162", "0.7641336", "0.73939323", "0.73522437", "0.7264899", "0.72374666", "0.7231631", "0.7175395", "0.71222407", "0.7096828", "0.70619", "0.70159024", "0.6929799", "0.69007486", "0.6846229", "0.68405634", "0.68261665", "0.680526", "0.67607194", "0.675444", "0.6744464"...
0.6951326
12
Returns an image array with the bounding boxes drawn around potential faces
def draw_boxes(bboxes: [[int]], img: 'np.array', line_width: int=2) -> 'np.array': for x, y, w, h in bboxes: cv2.rectangle(img, (x, y), (x+w, y+h), (0, 255, 0), line_width) return img
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _box_faces(image):\n for face in image.faces:\n _box_face(image, face)\n return image", "def detect_faces(self, img) -> list:\r\n if img is None or not hasattr(img, \"shape\"):\r\n raise InvalidImage(\"Image not valid.\")\r\n\r\n height, width, _ = img.shape\r\n s...
[ "0.7231385", "0.70575005", "0.69649845", "0.6934131", "0.68481743", "0.68187964", "0.6790303", "0.6778396", "0.67521256", "0.67091864", "0.670835", "0.6687314", "0.6667951", "0.6657301", "0.66537535", "0.6620427", "0.6619383", "0.6603832", "0.65846264", "0.65814936", "0.65778...
0.60267806
82
getRowsInPatch(patchExtractor self, int patchNo) > int
def getRowsInPatch(self, patchNo): return _patchExtractor.patchExtractor_getRowsInPatch(self, patchNo)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cpp_getInRowCount(self, patchNo, rowsInPatch):\n return _patchExtractor.patchExtractor_cpp_getInRowCount(self, patchNo, rowsInPatch)", "def cpp_getInRowDist(self, patchNo, rowsInPatch):\n return _patchExtractor.patchExtractor_cpp_getInRowDist(self, patchNo, rowsInPatch)", "def _get_diff_table...
[ "0.7120613", "0.70130247", "0.6967381", "0.69396794", "0.6686294", "0.6436948", "0.6318141", "0.61928076", "0.5942566", "0.5908626", "0.58674777", "0.57319534", "0.5729985", "0.57270205", "0.57155514", "0.5681618", "0.5678783", "0.5668167", "0.5641656", "0.563912", "0.563912"...
0.8608684
0
Test the email for a new user is normalized.
def test_new_user_email_normalized(self): email = "test@GMAIL.com" user = get_user_model().objects.create_user(email, "test123") self.assertEqual(user.email, email.lower())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_new_email_normalised(self):\n\n email = \"test@RANDOMEMAIL.org\"\n user = get_user_model().objects.create_user(\n email,\n password=\"password\"\n )\n\n self.assertEqual(user.email, email.lower())", "def test_new_user_email_normalized(self):\n ema...
[ "0.81897974", "0.81854635", "0.80989337", "0.80989337", "0.80989337", "0.80869216", "0.8085598", "0.8081318", "0.80742913", "0.807111", "0.80134684", "0.7951628", "0.7949418", "0.7935576", "0.79177845", "0.7852213", "0.7762513", "0.77296513", "0.7638634", "0.72424656", "0.699...
0.80452335
10
Test creating user with no email, raising error.
def test_new_user_invalid_email(self): with self.assertRaises(ValueError): get_user_model().objects.create_user(None, "test123")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_creating_a_new_user_without_email(self):\n\n with self.assertRaises(ValueError):\n get_user_model().objects.create_user(None, \"Test1234\")", "def test_private_create_user_without_email(self):\n with pytest.raises(ValueError) as exinfo:\n EmailUser.objects._create_use...
[ "0.88847715", "0.8881028", "0.8658336", "0.86044484", "0.86016303", "0.8587475", "0.85804915", "0.85804915", "0.85804915", "0.85804915", "0.85804915", "0.8568544", "0.8563551", "0.85625273", "0.855346", "0.8544043", "0.85112053", "0.84912694", "0.8488609", "0.8456821", "0.844...
0.8584102
6
Test the tag string representation.
def test_tag_str(self): tag = models.Tag.objects.create( user=sample_user(), name="test" ) self.assertEqual(str(tag), tag.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tag_str(self):\n tag = models.Tag.objects.create(\n user=sample_user(),\n name='Internal'\n )\n\n self.assertEqual(str(tag), tag.name)", "def test_tag_str(self):\n tag = models.Tag.objects.create(\n user=sample_user(),\n name='Docke...
[ "0.72895104", "0.7171557", "0.7063181", "0.7063181", "0.70455164", "0.7023461", "0.69877744", "0.69252986", "0.6797239", "0.6262929", "0.62071216", "0.6088981", "0.6069819", "0.6066025", "0.6051664", "0.60141516", "0.59420615", "0.5885668", "0.5862406", "0.5859795", "0.585467...
0.7016783
6
Test that the object string representation exists.
def test_child_str(self): child = models.Child.objects.create( user=sample_user(), name="test name" ) self.assertEqual(str(child), child.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_string(obj):\n return isinstance(obj, basestring)", "def assert_is_string(object_to_test):\n if( (type(object_to_test) == type(\"\")) or (type(object_to_test) == type(u\"\")) ):\n return\n logging.error(\"assert_is_string() test failed!\")\n logging.critical(repr(locals()))\n rai...
[ "0.6883389", "0.6751426", "0.67105246", "0.66613513", "0.65444773", "0.6389217", "0.63700664", "0.63410264", "0.6296289", "0.6273821", "0.62157017", "0.6212587", "0.6210213", "0.62097156", "0.6207504", "0.616656", "0.6157989", "0.6129764", "0.61285543", "0.6106197", "0.609470...
0.0
-1
Test that the object string representation exists.
def test_parent_str(self): parent = models.Parent.objects.create( user=sample_user(), address="test add 1", age=34, job="test 1" ) self.assertEqual(str(parent), parent.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_string(obj):\n return isinstance(obj, basestring)", "def assert_is_string(object_to_test):\n if( (type(object_to_test) == type(\"\")) or (type(object_to_test) == type(u\"\")) ):\n return\n logging.error(\"assert_is_string() test failed!\")\n logging.critical(repr(locals()))\n rai...
[ "0.6883389", "0.6751426", "0.67105246", "0.66613513", "0.65444773", "0.6389217", "0.63700664", "0.63410264", "0.6296289", "0.6273821", "0.62157017", "0.6212587", "0.6210213", "0.62097156", "0.6207504", "0.616656", "0.6157989", "0.6129764", "0.61285543", "0.6106197", "0.609470...
0.0
-1
Computes the limit of ``e(z)`` at the point ``z0``.
def limit(e, z, z0, direction=1): if direction == 0: llim = Limit[z:z0:-1](e).doit(deep=False) rlim = Limit[z:z0:1](e).doit(deep=False) if llim == rlim: return rlim else: # TODO: choose a better error? raise ValueError("The limit does not exist si...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def limit(e, z, z0, dir=\"+\"):\n e = sympify(e)\n z = sympify(z)\n z0 = sympify(z0)\n\n if e == z:\n return z0\n\n if not e.has(z):\n return e\n\n # gruntz fails on factorials but works with the gamma function\n # If no factorial term is present, e should remain unchanged.\n ...
[ "0.6971941", "0.6704616", "0.6488667", "0.62273675", "0.62254685", "0.6125671", "0.60867894", "0.59588027", "0.59099895", "0.5893584", "0.58721125", "0.58721125", "0.5858836", "0.5858836", "0.5831781", "0.5831719", "0.57754225", "0.5762995", "0.5756769", "0.5745146", "0.57190...
0.65920043
2
Generate a zero filled tensor with shape [batch_size, state_size].
def _generate_zero_filled_state(batch_size_tensor, state_size, dtype): if batch_size_tensor is None or dtype is None: raise ValueError( 'batch_size and dtype cannot be None while constructing initial state: ' 'batch_size={}, dtype={}'.format(batch_size_tensor, dtype)) def create...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zero_state(self, batch_size):\n p = self.params\n if (p.inference_step_max_length is not None and\n p.inference_step_max_length > 0 and not p.right_context):\n if p.minimize_state_size:\n state0 = self._zero_state_static_length_inputs(batch_size)\n else:\n state0 = self._ze...
[ "0.7964132", "0.77353954", "0.7673046", "0.7648777", "0.75975615", "0.7548125", "0.7500736", "0.74102706", "0.7395627", "0.7327956", "0.7233562", "0.70724785", "0.7066714", "0.7061532", "0.70601034", "0.7034415", "0.7020263", "0.6976337", "0.6942931", "0.68871313", "0.6842832...
0.8226042
0
Return the list of entries, sorted in alphanumeric order.
def get_list(self): return sorted(self.__entries.keys())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_nicely(l):\n l.sort(key=alphanum_key)\n return l", "def _sorted_nicely(self, l):\n\n import re\n\n convert = lambda text: int(text) if text.isdigit() else \"\"\n\n alphanum_key = lambda key: [\n convert(c) for c in re.split(\n '([0-9]+)', key)...
[ "0.6854139", "0.6823913", "0.67764205", "0.6680143", "0.6594456", "0.65583354", "0.6539899", "0.6539899", "0.65296704", "0.6502949", "0.64674604", "0.64409995", "0.64186716", "0.63814783", "0.6380038", "0.62976825", "0.6235633", "0.6233257", "0.6227888", "0.6214825", "0.61979...
0.7139579
0
Return True if entry is in the list.
def is_in(self, entry): return entry in self.__entries
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _listContains(self, l, entry):\n for i in range(0, len(l)):\n if l[i] == entry:\n return True\n return False", "def is_entry_in_list(entry, a_list):\n for item in a_list:\n if entry['description'] == item['description']:\n return True\n return F...
[ "0.84130394", "0.73973686", "0.7322556", "0.71771896", "0.710285", "0.7082837", "0.70814323", "0.7064511", "0.69458514", "0.69020206", "0.6901877", "0.6813846", "0.679964", "0.6771887", "0.67582667", "0.67236793", "0.67057556", "0.67039394", "0.670361", "0.670361", "0.6686598...
0.86869526
0
This method should return the ID of the node with the least number of links entering the node. Ties can be broken arbitrarily.
def findLeastEnteringLinks(self): leastEnteringLinks = self.numLinks + 1 leastEnteringNode = None for i in self.node: if len(self.node[i].reverseStar) < leastEnteringLinks: leastEnteringLinks = len(self.node[i].reverseStar) leastEnteringNode = i return leastEnter...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_node_id(self) -> int:\n\n if len(self.nodes) > 0:\n min_node_id = min([min(nodes.id) if len(nodes) > 0 else 0 for nodes in self.nodes])\n else:\n min_node_id = 0\n\n return min_node_id", "def next_node_id(self) -> int:\n i = 1\n while True:\n ...
[ "0.6475857", "0.6475529", "0.62453", "0.6199938", "0.60163385", "0.5900314", "0.5846705", "0.5831179", "0.5831179", "0.58225", "0.58090204", "0.5806918", "0.57154554", "0.5651046", "0.5649684", "0.5616286", "0.5576941", "0.55421007", "0.54925513", "0.5492026", "0.549186", "...
0.6612177
0
Search for the first element with `data` matching `key`. Return the element or `None` if not found. Takes O(n) time.
def find(self, key): curr_node = self.head while curr_node is not None: # a normal traversal and checking first match if curr_node.data == key: return curr_node curr_node = curr_node.next return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first(data, key):\n for i in data:\n if key(i):\n return i\n return None", "def find(self, key):\n if self.head is None:\n return\n itr = self.head\n while itr:\n if itr.data == key:\n return itr.data\n ...
[ "0.82270503", "0.791213", "0.7607604", "0.7265716", "0.7207818", "0.70598406", "0.69981915", "0.683854", "0.67239046", "0.6720846", "0.67038524", "0.6698351", "0.66664386", "0.6632762", "0.662701", "0.662701", "0.65646315", "0.6545879", "0.6499581", "0.6478936", "0.6468783", ...
0.7480239
3
Evaluate model on the validation set.
def eval_model_on_valid(args): cfg, lbl = util.get_label_cfg_by_args(args) uid = cfg['uniqueid'] print('We are playing with %s' % uid) outdir='models/%s/gate_expert' % uid outname='gate_expert_model.pt' if KLLOSS: outname = 'gate_expert_kldiv_model.pt' if args.warm: outname =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate(self):\n self.set_model_mode('eval')\n self.evaluator.reset()\n losses = MetricMeter()\n\n print('Do evaluation on {} set'.format('valid set'))\n data_loader = self.val_loader\n assert data_loader is not None\n for batch_idx, batch in enumerate(data_loa...
[ "0.7596748", "0.7155282", "0.6981885", "0.6962062", "0.6943697", "0.68454134", "0.6844227", "0.6817886", "0.6808465", "0.67985827", "0.67644453", "0.67536557", "0.67080617", "0.6675372", "0.6675372", "0.6675372", "0.6636181", "0.6632665", "0.6626803", "0.6613798", "0.65951616...
0.6094128
92
Create a multi node evaluator from a normal evaluator. Actually this method patches the evaluator to work in multi node environment. This method adds several hidden attributes starting with `_mn_` prefix.
def create_multi_node_evaluator(actual_evaluator, communicator): actual_evaluator._mn_original_evaluate = actual_evaluator.evaluate actual_evaluator._mn_communicator = communicator def new_evaluate(self): local_mean_dict = self._mn_original_evaluate() global_mean_dict = { name:...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_evaluator(cfg: CfgNode) -> EvaluatorBase:\n name = cfg[\"name\"]\n evaluator = simple_build(name, cfg, EVALUATORS)\n return evaluator", "def fix_evaluator(self):\n with self.override_evaluator(self._get_evaluators()):\n yield", "def freeze_evaluator(self):\n self._ev...
[ "0.5455857", "0.5405566", "0.540301", "0.5279121", "0.52723044", "0.52307564", "0.5227944", "0.5204107", "0.51693076", "0.51637036", "0.51153404", "0.5008149", "0.49991485", "0.49854365", "0.49624103", "0.49487355", "0.48920062", "0.48911744", "0.48495838", "0.48334694", "0.4...
0.7159068
0
Converts target to a one_hot tensor, also removing road class.
def _target_to_one_hot(target_tensor): target_tensor = target_tensor.unsqueeze(2) one_hot = torch.zeros(target_tensor.shape[0], target_tensor.shape[1], 3) one_hot = one_hot.scatter_(2, target_tensor.to(dtype=torch.long), 1) return one_hot
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_one_hot_encoding(target_data):\n target_data = target_data.squeeze()\n n_class = len(np.unique(target_data))\n res = np.eye(n_class)[target_data.astype(int)]\n return res", "def _get_one_hot(targets, num_classes):\n ret = np.zeros((num_classes, targets.shape[0]))\n ...
[ "0.7231508", "0.71516806", "0.7093084", "0.70565", "0.6951194", "0.67715627", "0.6661924", "0.6619369", "0.66047204", "0.66047204", "0.660428", "0.6592657", "0.65826064", "0.65747976", "0.65747976", "0.65747976", "0.6560438", "0.6555326", "0.6541294", "0.6527257", "0.65124637...
0.7818838
0
Processes out for GUI by selecting only max values. Since the GUI should only show colors for max values, if we feed the entire processed image to the GUI, there will be overlapping red and green classifications. We therefore choose to only show the max prob for
def _process_out_for_gui(prediction, argmax): out = torch.zeros_like(prediction) # Create a curbs mask mask = argmax == 1 # Fill seg 1 (curbs) with those in the mask out[1] = torch.where(mask, prediction[1], out[2]) # Create a curb cuts mask mask = argmax == 2 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maxi():\r\n st.dataframe(Data.style.highlight_max(axis=0))", "def max_scale_image(self):\n maximum = np.argmax(self.transform, 0)\n return self.scale_array[maximum] * (self.support.sum(0) > 0)", "def filter_max_rgb(img: np.ndarray):\n # split the image into its BGR components\n (B, G...
[ "0.61669374", "0.61012304", "0.60315263", "0.5883978", "0.5881208", "0.5820257", "0.5771618", "0.5761641", "0.5755116", "0.5732433", "0.57094836", "0.56955004", "0.56943476", "0.56845987", "0.5673669", "0.5666221", "0.56469786", "0.56256205", "0.5622159", "0.5603496", "0.5602...
0.56060076
19
Scale a vector in place by a given scalar.
def scale(self, s): for n in range(len(self.mV)): self.mV[n] *= s return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scale(first,scalar):\n if isinstance(first,FreeCAD.Vector):\n return FreeCAD.Vector(first.x*scalar, first.y*scalar, first.z*scalar)", "def scale_vector(vector, scale):\n return vector[0] * scale, vector[1] * scale, vector[2] * scale", "def apply_scalar(vector, scalar):\n new_coordinates = [...
[ "0.7657619", "0.76082075", "0.7125825", "0.7068847", "0.7017182", "0.7010788", "0.6949135", "0.6896336", "0.6886232", "0.6781433", "0.67697185", "0.67210245", "0.66553795", "0.66331583", "0.65780276", "0.65698117", "0.6500405", "0.6490538", "0.64773756", "0.6453958", "0.63990...
0.62584585
27
Multiply a vector by a scalar, return the scaled vector. The original vector remains unchanged.
def mults(self, s): prod = Vector.fromSequence(self.mV) prod.scale(s) return prod
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scale_vector(vector, scale):\n return vector[0] * scale, vector[1] * scale, vector[2] * scale", "def scale_vector(vector, f):\n f = float(f)\n return [vector[0] * f, vector[1] * f, vector[2] * f]", "def __mul__(self, scale):\n return Vec(self.x * scale, self.y * scale)", "def scale(first,...
[ "0.7906971", "0.719061", "0.71584755", "0.70123404", "0.6992106", "0.6954798", "0.69505566", "0.69505566", "0.69176275", "0.6898154", "0.6852842", "0.6847814", "0.6823905", "0.6813576", "0.6631866", "0.6604233", "0.65732515", "0.65299594", "0.6518655", "0.6473653", "0.6364983...
0.65644646
17
Dot Product or Scalar Product or Inner Product
def dot(self, v): if (len(self) != len(v)): raise IndexError('Vectors to be dotted must be the same size.') return sum([x[0]*x[1] for x in zip(self, v)])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dotproduct(v1, v2):\n\treturn sum(imap(operator.mul, v1, v2))", "def __mul__(self, other): \n if isinstance(other, Iterable):\n # dot product\n return self.x * other[0] + self.y * other[1]\n else:\n # scalar product\n return Vector(self.x * oth...
[ "0.72794324", "0.7160914", "0.7086121", "0.70314544", "0.70310175", "0.69989634", "0.69978535", "0.69908285", "0.6984889", "0.69460356", "0.6913086", "0.6910551", "0.68604994", "0.6855037", "0.6845777", "0.67754745", "0.6773863", "0.67717004", "0.6755288", "0.67389643", "0.67...
0.0
-1
Test the vector dot routine.
def testDot(self): v1 = Vector(1, 2, 3, 4) v2 = Vector(0, 1, 0, 0) v3 = Vector(1, 1, 1, 1) assert(v1.dot(v2) == 2) assert(v1.dot(v3) == 10) assert Vector(0.1, -0.2, 0.3).dot(Vector(5, 1, -1)) == 0 hitException = False v1 = Vector(1, 2, 3) v2 = Ve...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_dot():\n assert_equal(dot(Vector(3.0, 2.0), Vector(2.0, -1.0)), 4.0)", "def test_dot(self):\n\n vec1 = Vec3(3, 4, 5)\n vec2 = Vec3(2, 3, 4)\n dot = vec1.dot(vec2)\n\n expected = 3 * 2 + 4 * 3 + 5 * 4\n\n self.assertEqual(dot, expected)", "def test_dot_vm(self):\n ...
[ "0.8792508", "0.8250485", "0.8175246", "0.8140671", "0.81281394", "0.77727354", "0.7743112", "0.77401596", "0.7670081", "0.7594576", "0.75657135", "0.75162584", "0.7422966", "0.7407283", "0.7381236", "0.7379276", "0.7315566", "0.7268221", "0.7222487", "0.71905494", "0.7161037...
0.8270796
1
Copy the init_frame to the animation canvas.
def _init_frame(self : "animation", init_frame : "matplotlib.figure.Figure", init_ax : "matplotlib.axes._subplots.AxesSubplot" ): self._cframe = init_frame.canvas.copy_from_bbox(init_ax.bbox)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_anim(frame, self):\n self.step()\n self.im.set_data(self.array)\n self.im2.set_data(self.array2)", "def _init_anim(self):\n pass", "def draw(self, frame):\n frame[OFS:OFS+self.image.shape[0], OFS:OFS+self.image.shape[1]] = self.image", "def clone(self, *args):\n ...
[ "0.61197925", "0.57791626", "0.570642", "0.56398755", "0.5636277", "0.5596702", "0.5571598", "0.5561143", "0.5558893", "0.5557281", "0.5477211", "0.5431832", "0.5431161", "0.54261124", "0.54193294", "0.5407763", "0.53776693", "0.53739405", "0.5349505", "0.53438383", "0.534285...
0.8051166
0
Fastforward the iterator by skipping num_to_skip elements.
def skip(self, num_to_skip): next(itertools.islice(self.itr, num_to_skip, num_to_skip), None) self.len -= num_to_skip return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def skip(self, n=None):\n while n > 0:\n try:\n self.next()\n except StopIteration:\n break\n n -= 1", "def skip(self, n):\n return self.__class__(itertools.islice(self, n, None))", "def pairwise_skip(iterable, skip):\n xs = iter(i...
[ "0.7216536", "0.71086544", "0.67903686", "0.6532568", "0.65208286", "0.64413977", "0.64413977", "0.6097464", "0.60848653", "0.5955997", "0.5954538", "0.5882709", "0.5880086", "0.58601195", "0.5854986", "0.58196247", "0.57909316", "0.57852155", "0.57723093", "0.5764881", "0.57...
0.7884194
0
Compute the deviance explained for a given GAM This is based on/ named after the score function GAM has in the latest version (on github), but is not included in the latest pip release. GAM.score() does the same internally.
def score(gam, X, y): r2 = gam._estimate_r2(X=X, y=y) return r2['explained_deviance']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mean_gamma_deviance(self):\n print('Mean Gamma deviance regression loss: ' + str(mean_gamma_deviance(self.model.dataset.get_y_test(),\n self.model.get_predicted())))", "def deviance(y_true, y_pred):\n # calculate log-lik...
[ "0.60150075", "0.5844768", "0.5706404", "0.5497586", "0.54892814", "0.52928287", "0.52528054", "0.5244635", "0.5207472", "0.52073324", "0.5199894", "0.5159096", "0.5135629", "0.51332515", "0.5101725", "0.50675684", "0.5051917", "0.50428164", "0.50418603", "0.50280946", "0.501...
0.7498992
0
Verify that calling ``Context.use_certificate_file`` with the given filename doesn't raise an exception.
def _use_certificate_file_test(self, certificate_file): # TODO # Hard to assert anything. But we could set a privatekey then ask # OpenSSL if the cert and key agree using check_privatekey. Then as # long as check_privatekey works right we're good... with open(certificate_file, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_use_certificate_file_missing(self, tmpfile):\n ctx = Context(SSLv23_METHOD)\n with pytest.raises(Error):\n ctx.use_certificate_file(tmpfile)", "def __test_cert_file__(parser, certfile):\n if not os.path.exists(certfile):\n parser.error(\"invalid certificate fil...
[ "0.76372015", "0.7521765", "0.7370167", "0.7057169", "0.6676152", "0.66680485", "0.658187", "0.6538492", "0.65014946", "0.6350473", "0.6146684", "0.6127108", "0.61176974", "0.6094233", "0.60840565", "0.60709757", "0.6053602", "0.59963715", "0.59662956", "0.5915616", "0.590432...
0.7144712
3
Verify that if path to a file containing a certificate is passed to `Context.load_verify_locations` for the ``cafile`` parameter, that certificate is used as a trust root for the purposes of verifying connections created using that `Context`.
def _load_verify_cafile(self, cafile): with open(cafile, "w") as fObj: fObj.write(root_cert_pem.decode("ascii")) self._load_verify_locations_test(cafile)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_load_client_ca(self, context, ca_file):\n context.load_client_ca(ca_file)", "def load_verify_locations(self, cafile: Optional[Any] = ..., dummy: Optional[Any] = ...):\n ...", "def _load_verify_locations_test(self, *args):\n (server, client) = socket_pair()\n\n clientContext...
[ "0.69898313", "0.6911153", "0.6752831", "0.66460335", "0.6550578", "0.64713603", "0.63790816", "0.63611484", "0.6288409", "0.6263157", "0.619495", "0.6138633", "0.6084154", "0.60716987", "0.6025006", "0.6000163", "0.59720093", "0.59587586", "0.59567475", "0.5956507", "0.58939...
0.7611622
0
Test that we load certificates successfully on linux from the fallback path. To do this we set the _CRYPTOGRAPHY_MANYLINUX_CA_FILE and _CRYPTOGRAPHY_MANYLINUX_CA_DIR vars to be equal to whatever the current OpenSSL default is and we disable SSL_CTX_SET_default_verify_paths so that it can't find certs unless it loads vi...
def test_fallback_default_verify_paths(self, monkeypatch): context = Context(SSLv23_METHOD) monkeypatch.setattr( _lib, "SSL_CTX_set_default_verify_paths", lambda x: 1 ) monkeypatch.setattr( SSL, "_CRYPTOGRAPHY_MANYLINUX_CA_FILE", _ffi.strin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_verify_no_fallback_if_env_vars_set(self, monkeypatch):\n context = Context(SSLv23_METHOD)\n monkeypatch.setattr(\n _lib, \"SSL_CTX_set_default_verify_paths\", lambda x: 1\n )\n dir_env_var = _ffi.string(_lib.X509_get_default_cert_dir_env()).decode(\n \"asc...
[ "0.7450741", "0.7258399", "0.6598385", "0.6573747", "0.6393772", "0.63077897", "0.624019", "0.6207533", "0.6116091", "0.5999623", "0.587996", "0.58346957", "0.58139616", "0.58091944", "0.57906646", "0.57210904", "0.5695405", "0.5690719", "0.56486547", "0.561328", "0.5589827",...
0.82309383
0
`Context.set_default_verify_paths` causes the platformspecific CA certificate locations to be used for verification purposes.
def test_set_default_verify_paths(self): # Testing this requires a server with a certificate signed by one # of the CAs in the platform CA location. Getting one of those # costs money. Fortunately (or unfortunately, depending on your # perspective), it's easy to think of a public serve...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_fallback_default_verify_paths(self, monkeypatch):\n context = Context(SSLv23_METHOD)\n monkeypatch.setattr(\n _lib, \"SSL_CTX_set_default_verify_paths\", lambda x: 1\n )\n monkeypatch.setattr(\n SSL,\n \"_CRYPTOGRAPHY_MANYLINUX_CA_FILE\",\n ...
[ "0.8237935", "0.70706284", "0.63992846", "0.6220236", "0.6152528", "0.6097904", "0.6004967", "0.5983814", "0.59050137", "0.58319056", "0.5744637", "0.57060546", "0.5569509", "0.5537821", "0.54582053", "0.5456701", "0.5450961", "0.5432836", "0.54178566", "0.54047644", "0.53625...
0.764056
1
`Context.add_extra_chain_cert` accepts an `X509` instance to add to the certificate chain. See `_create_certificate_chain` for the details of the certificate chain tested. The chain is tested by starting a server with scert and connecting to it with a client which trusts cacert and requires verification to succeed.
def test_add_extra_chain_cert(self, tmpdir): chain = _create_certificate_chain() [(cakey, cacert), (ikey, icert), (skey, scert)] = chain # Dump the CA certificate to a file because that's the only way to load # it as a trusted CA in the client context. for cert, name in [ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_add_extra_chain_cert_invalid_cert(self):\n context = Context(SSLv23_METHOD)\n with pytest.raises(TypeError):\n context.add_extra_chain_cert(object())", "def _use_certificate_chain_file_test(self, certdir):\n chain = _create_certificate_chain()\n [(cakey, cacert), (...
[ "0.70445734", "0.5654997", "0.5540081", "0.52199924", "0.5189117", "0.518401", "0.5133375", "0.50478923", "0.5036916", "0.5029977", "0.50285953", "0.5026589", "0.50093544", "0.49522883", "0.49463817", "0.4887031", "0.4880789", "0.48772016", "0.4865383", "0.48555857", "0.48492...
0.8151521
0
Verify that `Context.use_certificate_chain_file` reads a certificate chain from a specified file. The chain is tested by starting a server with scert and connecting to it with a client which trusts cacert and requires verification to succeed.
def _use_certificate_chain_file_test(self, certdir): chain = _create_certificate_chain() [(cakey, cacert), (ikey, icert), (skey, scert)] = chain makedirs(certdir) chainFile = join_bytes_or_unicode(certdir, "chain.pem") caFile = join_bytes_or_unicode(certdir, "ca.pem") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_use_certificate_chain_file_missing_file(self, tmpfile):\n context = Context(SSLv23_METHOD)\n with pytest.raises(Error):\n context.use_certificate_chain_file(tmpfile)", "def test_use_certificate_chain_file_wrong_args(self):\n context = Context(SSLv23_METHOD)\n with ...
[ "0.7072866", "0.679626", "0.65914047", "0.6446013", "0.6434783", "0.6099239", "0.6093269", "0.60484606", "0.5919493", "0.5852325", "0.5824202", "0.57843", "0.57340074", "0.57236016", "0.5691547", "0.56375515", "0.5605486", "0.5571679", "0.55528474", "0.55528307", "0.5519333",...
0.7675559
0
``Context.use_certificate_chain_file`` accepts the name of a file (as an instance of ``bytes``) to specify additional certificates to use to construct and verify a trust chain.
def test_use_certificate_chain_file_bytes(self, tmpfile): self._use_certificate_chain_file_test( tmpfile + NON_ASCII.encode(getfilesystemencoding()) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _use_certificate_chain_file_test(self, certdir):\n chain = _create_certificate_chain()\n [(cakey, cacert), (ikey, icert), (skey, scert)] = chain\n\n makedirs(certdir)\n\n chainFile = join_bytes_or_unicode(certdir, \"chain.pem\")\n caFile = join_bytes_or_unicode(certdir, \"ca....
[ "0.7088364", "0.68672633", "0.65272206", "0.63694173", "0.6157593", "0.5392983", "0.5303036", "0.5301923", "0.5162677", "0.5153086", "0.5076176", "0.5076176", "0.5070984", "0.5047885", "0.50207293", "0.50073785", "0.50040305", "0.49987042", "0.4970048", "0.49608603", "0.49300...
0.60747707
5
``Context.use_certificate_chain_file`` accepts the name of a file (as an instance of ``unicode``) to specify additional certificates to use to construct and verify a trust chain.
def test_use_certificate_chain_file_unicode(self, tmpfile): self._use_certificate_chain_file_test( tmpfile.decode(getfilesystemencoding()) + NON_ASCII )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _use_certificate_chain_file_test(self, certdir):\n chain = _create_certificate_chain()\n [(cakey, cacert), (ikey, icert), (skey, scert)] = chain\n\n makedirs(certdir)\n\n chainFile = join_bytes_or_unicode(certdir, \"chain.pem\")\n caFile = join_bytes_or_unicode(certdir, \"ca....
[ "0.70721024", "0.683286", "0.65274775", "0.63977337", "0.61185515", "0.6034236", "0.5443655", "0.5291755", "0.5175406", "0.5175406", "0.51648915", "0.51597226", "0.5039007", "0.50263", "0.5002649", "0.49906528", "0.49828988", "0.497971", "0.49731255", "0.4971664", "0.49131346...
0.54953724
6
`Context.load_tmp_dh` raises `OpenSSL.SSL.Error` if the specified file does not exist.
def test_load_tmp_dh_missing_file(self): context = Context(SSLv23_METHOD) with pytest.raises(Error): context.load_tmp_dh(b"hello")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_tmp_dh_test(self, dhfilename):\n context = Context(SSLv23_METHOD)\n with open(dhfilename, \"w\") as dhfile:\n dhfile.write(dhparam)\n\n context.load_tmp_dh(dhfilename)", "def test_load_tmp_dh_bytes(self, tmpfile):\n self._load_tmp_dh_test(\n tmpfile + N...
[ "0.741622", "0.6135961", "0.60764277", "0.5984462", "0.5913388", "0.58383244", "0.5722175", "0.51604617", "0.5106356", "0.5088859", "0.5016822", "0.49577874", "0.4910753", "0.49094552", "0.4769575", "0.47682315", "0.47424796", "0.47354278", "0.4705936", "0.46853462", "0.46412...
0.7363981
1
Verify that calling ``Context.load_tmp_dh`` with the given filename does not raise an exception.
def _load_tmp_dh_test(self, dhfilename): context = Context(SSLv23_METHOD) with open(dhfilename, "w") as dhfile: dhfile.write(dhparam) context.load_tmp_dh(dhfilename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_load_tmp_dh_missing_file(self):\n context = Context(SSLv23_METHOD)\n with pytest.raises(Error):\n context.load_tmp_dh(b\"hello\")", "def test_load_tmp_dh_wrong_args(self):\n context = Context(SSLv23_METHOD)\n with pytest.raises(TypeError):\n context.load...
[ "0.7482503", "0.66209334", "0.6611675", "0.63573027", "0.63007486", "0.6226172", "0.6214404", "0.61765474", "0.60564274", "0.60423076", "0.6022991", "0.6014146", "0.6011779", "0.60000086", "0.5959136", "0.5907364", "0.58748734", "0.579498", "0.5768735", "0.5765749", "0.576475...
0.6649592
1
`Context.set_tlsext_use_srtp' enables negotiating SRTP keying material. It raises an Error if the call to OpenSSL fails.
def test_set_tlsext_use_srtp_invalid_profile(self): context = Context(SSLv23_METHOD) with pytest.raises(Error): context.set_tlsext_use_srtp(b"SRTP_BOGUS")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_set_tlsext_use_srtp_valid(self):\n context = Context(SSLv23_METHOD)\n assert context.set_tlsext_use_srtp(b\"SRTP_AES128_CM_SHA1_80\") is None", "def test_set_tlsext_use_srtp_not_bytes(self):\n context = Context(SSLv23_METHOD)\n with pytest.raises(TypeError):\n cont...
[ "0.7914808", "0.75990784", "0.5521938", "0.5364851", "0.5298976", "0.51505953", "0.5120962", "0.5107119", "0.5107119", "0.5065725", "0.5046407", "0.5030587", "0.49557236", "0.49556577", "0.49357468", "0.4934172", "0.49276707", "0.49276707", "0.48830944", "0.4876146", "0.48621...
0.72756135
2
`Context.set_tlsext_use_srtp' enables negotiating SRTP keying material. It does not return anything.
def test_set_tlsext_use_srtp_valid(self): context = Context(SSLv23_METHOD) assert context.set_tlsext_use_srtp(b"SRTP_AES128_CM_SHA1_80") is None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_set_tlsext_use_srtp_not_bytes(self):\n context = Context(SSLv23_METHOD)\n with pytest.raises(TypeError):\n context.set_tlsext_use_srtp(str(\"SRTP_AES128_CM_SHA1_80\"))", "def test_set_tlsext_use_srtp_invalid_profile(self):\n context = Context(SSLv23_METHOD)\n with ...
[ "0.6794031", "0.6776855", "0.5398269", "0.53937185", "0.53937185", "0.53787106", "0.5339967", "0.5208999", "0.5208999", "0.5162452", "0.51441574", "0.5062849", "0.5062849", "0.5044793", "0.49778324", "0.49631548", "0.49620128", "0.4953031", "0.49239883", "0.49133965", "0.4899...
0.73919845
0
`Connection.get_verified_chain` returns `None` when used with an object which has not been connected.
def test_get_verified_chain_unconnected(self): ctx = Context(SSLv23_METHOD) server = Connection(ctx, None) assert None is server.get_verified_chain()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_verified_chain_none(self):\n ctx = Context(SSLv23_METHOD)\n ctx.use_privatekey(load_privatekey(FILETYPE_PEM, server_key_pem))\n ctx.use_certificate(load_certificate(FILETYPE_PEM, server_cert_pem))\n server = Connection(ctx, None)\n server.set_accept_state()\n ...
[ "0.72356075", "0.6516011", "0.64850485", "0.58327687", "0.5695895", "0.5683576", "0.5646767", "0.54307663", "0.5401225", "0.53712016", "0.5192937", "0.51813453", "0.5153969", "0.51122844", "0.50901634", "0.5085649", "0.5075841", "0.5060673", "0.50462776", "0.50350034", "0.502...
0.73946834
0
On the server side of a connection, `Connection.get_session` returns a `Session` instance representing the SSL session for that connection.
def test_server_get_session(self): server, client = loopback() session = server.get_session() assert isinstance(session, Session)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_session(self):\n return self.session", "def session(self):\n session = None\n connected = False\n while not connected:\n try:\n session = self.session_pool.pop()\n except IndexError:\n connection = connect(self.address, self....
[ "0.7002584", "0.6943071", "0.689391", "0.6870021", "0.6864597", "0.6826882", "0.67674696", "0.67425627", "0.6732157", "0.67073566", "0.67073566", "0.6698668", "0.66721576", "0.6621473", "0.6613276", "0.660114", "0.6579035", "0.65626115", "0.6560886", "0.65531117", "0.6540734"...
0.6768378
6
On the client side of a connection, `Connection.get_session` returns a `Session` instance representing the SSL session for that connection.
def test_client_get_session(self): server, client = loopback() session = client.get_session() assert isinstance(session, Session)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_session(self):\n return self.session", "def session(self) -> ClientSession:\r\n return self._session", "def session(self):\n session = None\n connected = False\n while not connected:\n try:\n session = self.session_pool.pop()\n exc...
[ "0.69788146", "0.6895548", "0.68738663", "0.68620473", "0.6857909", "0.67981935", "0.6769713", "0.6745633", "0.6730902", "0.6716698", "0.66974306", "0.66851914", "0.66851914", "0.66198975", "0.66122663", "0.66109854", "0.65905344", "0.6580653", "0.6566618", "0.65608925", "0.6...
0.68518996
5
`Connection.get_cipher_name` returns `None` if no connection has been established.
def test_get_cipher_name_before_connect(self): ctx = Context(SSLv23_METHOD) conn = Connection(ctx, None) assert conn.get_cipher_name() is None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getCipherName(self):\r\n if not self._writeState.encContext:\r\n return None\r\n return self._writeState.encContext.name", "def getCipherName(self):\r\n return CipherSuite.canonicalCipherName(self.cipherSuite)", "def test_get_cipher_name(self):\n server, client = loop...
[ "0.7374929", "0.6577182", "0.6361748", "0.6246593", "0.61044776", "0.6038715", "0.5832968", "0.571345", "0.5626739", "0.55488193", "0.5474489", "0.5474489", "0.54179496", "0.5390568", "0.53418404", "0.532458", "0.5320074", "0.53011125", "0.5265817", "0.5249775", "0.52338815",...
0.78029853
0
`Connection.get_cipher_version` returns `None` if no connection has been established.
def test_get_cipher_version_before_connect(self): ctx = Context(SSLv23_METHOD) conn = Connection(ctx, None) assert conn.get_cipher_version() is None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_version(self):\n if _cbc_version is None:\n return _extract_version('')\n return _cbc_version", "def test_get_cipher_version(self):\n server, client = loopback()\n server_cipher_version, client_cipher_version = (\n server.get_cipher_version(),\n ...
[ "0.7060065", "0.6595193", "0.655542", "0.6473601", "0.61320066", "0.60428816", "0.6033592", "0.6017922", "0.6003208", "0.59844977", "0.59333223", "0.5910073", "0.58815914", "0.58550805", "0.5841287", "0.58089674", "0.57918185", "0.57665384", "0.57665384", "0.5739545", "0.5733...
0.7854007
0
`Connection.get_cipher_version` returns a `unicode` string giving the protocol name of the currently used cipher.
def test_get_cipher_version(self): server, client = loopback() server_cipher_version, client_cipher_version = ( server.get_cipher_version(), client.get_cipher_version(), ) assert isinstance(server_cipher_version, str) assert isinstance(client_cipher_versi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getVersionName(self):\r\n if self.version == (3,0):\r\n return \"SSL 3.0\"\r\n elif self.version == (3,1):\r\n return \"TLS 1.0\"\r\n elif self.version == (3,2):\r\n return \"TLS 1.1\"\r\n else:\r\n return None", "def test_get_cipher_ver...
[ "0.71353376", "0.7095967", "0.6739492", "0.66506165", "0.6500688", "0.62499315", "0.6127998", "0.6115142", "0.60745996", "0.6062142", "0.60207003", "0.60207003", "0.5968103", "0.5963072", "0.5939079", "0.5926248", "0.5882892", "0.5876587", "0.58687204", "0.58650774", "0.58095...
0.66550493
3