query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Return the colormode or set it to 1.0 or 255. | def colormode(self, cmode=None):
if cmode is None:
return self._colormode
if cmode == 1.0:
self._colormode = float(cmode)
elif cmode == 255:
self._colormode = int(cmode) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def potential_color(self):\n\n return (1., 1., 0.)",
"def get_color(self):\r\n return self.__color",
"def _get_color(self):\n return self.__color",
"def _get_color(self):\n return self.__color",
"def _get_color(self):\n return self.__color",
"def _get_color(self):\n return self.... | [
"0.61560196",
"0.60476726",
"0.5993631",
"0.5993631",
"0.5993631",
"0.5993631",
"0.59807307",
"0.5946223",
"0.5924161",
"0.5885491",
"0.58824646",
"0.5869164",
"0.58573097",
"0.58573097",
"0.58441573",
"0.58146566",
"0.58009475",
"0.57854545",
"0.5779842",
"0.5760599",
"0.574... | 0.827122 | 0 |
Reset all Turtles on the Screen to their initial state. No argument. | def reset(self):
for Myturtle in self._turtles:
Myturtle._setmode(self._mode)
Myturtle.reset() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n TNavigator.reset(self)\n TPen._reset(self)\n self._clear()\n self._drawturtle()\n self._update()",
"def reset(self):\n self._turtle.clear()\n self._turtle.setposition((0,0)) \n self._turtle.shape('turtle')\n self.color = 're... | [
"0.7616165",
"0.7476714",
"0.706625",
"0.70513546",
"0.703268",
"0.6975026",
"0.6952702",
"0.6930557",
"0.6837944",
"0.68164074",
"0.67610794",
"0.67327464",
"0.6727695",
"0.6708193",
"0.66862565",
"0.6662717",
"0.6635122",
"0.66217583",
"0.65915465",
"0.65861017",
"0.6581068... | 0.78922325 | 0 |
Return the list of turtles on the screen. | def turtles(self):
return self._turtles | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turtles(self):\n return self._turtles[:]",
"def makeTurtles(num):\n turtles = []\n for i in range(num):\n t = turtle.Turtle()\n #t.speed(0) # can set this for superfast disc movement\n t.up()\n t.shape('square')\n t.shapesize(stretch_len=(2 + i)) #bottom turtle... | [
"0.77794784",
"0.618826",
"0.6020392",
"0.5884094",
"0.5768146",
"0.570828",
"0.570828",
"0.55725443",
"0.55628484",
"0.5510625",
"0.5503567",
"0.5488319",
"0.5483643",
"0.54379463",
"0.54103893",
"0.53822607",
"0.5370226",
"0.5332753",
"0.53281486",
"0.5306837",
"0.5304102",... | 0.79770064 | 0 |
Return the height of the Myturtle window. | def window_height(self):
return self._window_size()[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def height(self):\n _, ymin, _, ymax = self.viewport\n return self.parent.window_size[1] * (ymax - ymin)",
"def height(self):\n return(self.SCREEN_H)",
"def height(self) -> int:\n return self.screen.getmaxyx()[0]",
"def winfo_screenheight(self):\n return self.height",
"de... | [
"0.77892154",
"0.7528305",
"0.74939007",
"0.72679096",
"0.7238108",
"0.7189834",
"0.71686447",
"0.7113705",
"0.70795184",
"0.70795184",
"0.70783186",
"0.70663285",
"0.70663285",
"0.70663285",
"0.7059714",
"0.7046815",
"0.7046815",
"0.7046815",
"0.7046815",
"0.70452046",
"0.70... | 0.7765762 | 1 |
Return the Canvas of this TurtleScreen | def getcanvas(self):
return self.cv | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def canvas(self):\n return self._canvas",
"def Screen():\n if Myturtle._screen is None:\n Myturtle._screen = _Screen()\n return Myturtle._screen",
"def get_canvas(self, key) -> tk.Canvas:\n try:\n canvas = self._Canvases[key]\n except KeyError:\n canvas =... | [
"0.746768",
"0.6747746",
"0.6109935",
"0.60657513",
"0.6064832",
"0.5963825",
"0.5963825",
"0.5963825",
"0.5834056",
"0.57346946",
"0.5724637",
"0.56410736",
"0.5569283",
"0.55174804",
"0.5481251",
"0.5480726",
"0.5480726",
"0.5450803",
"0.5432645",
"0.54213107",
"0.53938913"... | 0.682368 | 1 |
Bind fun to keypress event of key if key is given, or to any keypressevent if no key is given. | def onkeypress(self, fun, key=None):
if fun is None:
if key in self._keys:
self._keys.remove(key)
elif key is not None and key not in self._keys:
self._keys.append(key)
self._onkeypress(fun, key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _onkeypress(self, fun, key=None):\n if fun is None:\n if key is None:\n self.cv.unbind(\"<KeyPress>\", None)\n else:\n self.cv.unbind(\"<KeyPress-%s>\" % key, None)\n else:\n def eventfun(event):\n fun()\n if... | [
"0.8049445",
"0.728405",
"0.7153001",
"0.69796234",
"0.690792",
"0.6847852",
"0.6822198",
"0.67301124",
"0.6724557",
"0.6638977",
"0.65856296",
"0.651688",
"0.6496849",
"0.646137",
"0.642909",
"0.6423411",
"0.6415512",
"0.64058536",
"0.63954604",
"0.638796",
"0.6359569",
"0... | 0.75433004 | 1 |
Install a timer, which calls fun after t milliseconds. | def ontimer(self, fun, t=0):
self._ontimer(fun, t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _ontimer(self, fun, t):\n if t == 0:\n self.cv.after_idle(fun)\n else:\n self.cv.after(t, fun)",
"def start(self, sec, callFunc, *args, **kwargs):\n self.cancel()\n \n def doit(args=args, kwargs=kwargs):\n self._timerID = None\n c... | [
"0.6821705",
"0.65327096",
"0.64860356",
"0.6438011",
"0.6404118",
"0.6387972",
"0.6329832",
"0.632448",
"0.62718546",
"0.62434834",
"0.61498404",
"0.61293244",
"0.6124812",
"0.6119987",
"0.61141527",
"0.6110378",
"0.6106083",
"0.60576034",
"0.6030907",
"0.60302967",
"0.60103... | 0.7901022 | 0 |
Set Myturtlemode to 'standard', 'world' or 'logo'. | def _setmode(self, mode=None):
if mode is None:
return self._mode
if mode not in ["standard", "logo", "world"]:
return
self._mode = mode
if mode in ["standard", "world"]:
self._angleOffset = 0
self._angleOrient = 1
else: # mode == "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setTurtle(t):\r\n t.pu()\r\n t.goto(initialCoordinates())",
"def setTeXMode(mode):\n if mode:\n dislin.texmod('ON')\n else:\n dislin.texmod('OFF')",
"def setScreenMode(mode='normal'):\n screendict = {'normal':'REVERS', 'black':'NOREV'}\n dislin.scrmod(screendict[mode])",
"... | [
"0.617484",
"0.6054048",
"0.58294433",
"0.58062625",
"0.578314",
"0.572466",
"0.5707494",
"0.5694985",
"0.5639299",
"0.55981785",
"0.55439913",
"0.547545",
"0.5439024",
"0.5428712",
"0.54244",
"0.5385512",
"0.53238237",
"0.53238237",
"0.5302166",
"0.5295186",
"0.5282529",
"... | 0.7149584 | 0 |
Set the angle measurement units to radians. No arguments. | def radians(self):
self._setDegreesPerAU(2*math.pi) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setAngle(self,angle = 2.5):\n pass",
"def set_angle(self, angle=0.0):\n self.angle = angle",
"def setAngle(self, angle):\n self._angle = (angle + math.pi / 2) % math.pi - math.pi / 2\n # self._angle = angle % (2*math.pi)",
"def set_angle(self, ang):\n if ang < 0:\n ... | [
"0.7401127",
"0.72532266",
"0.71483475",
"0.7056934",
"0.7036004",
"0.69982886",
"0.69501126",
"0.6810016",
"0.6792665",
"0.6785843",
"0.6776767",
"0.6732968",
"0.6699184",
"0.6673731",
"0.6673587",
"0.66574335",
"0.6656543",
"0.6632068",
"0.66133535",
"0.655427",
"0.65488106... | 0.76691765 | 0 |
Move the Myturtle move by the specified distance. | def move(self, distance):
self._go(distance) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_turtle(self):\n self.forward(self.move_speed)",
"def random_move(turtle, distance):\n angle = uniform(-90,90)\n d = uniform(0,distance)\n turtle.left(angle)\n turtle.forward(d)",
"def move(self, direction, distance):\r\n distance = float(distance)\r\n distance = int(round(dist... | [
"0.7544096",
"0.7527483",
"0.7361911",
"0.7250653",
"0.7237959",
"0.7123979",
"0.7103639",
"0.7019398",
"0.68791384",
"0.6832654",
"0.68047816",
"0.68012816",
"0.6792912",
"0.6776059",
"0.6766702",
"0.676111",
"0.66931254",
"0.66137624",
"0.6593665",
"0.6574645",
"0.65081805"... | 0.82346404 | 0 |
Pull the pen up no drawing when moving. | def penup(self):
if not self._drawing:
return
self.pen(pendown=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def up(self):\n self.move(0, 1)",
"def move_up(self):\n\n if self.ycor() > 115:\n self.sety(130)\n else:\n new_y = self.ycor() + 40\n self.sety(new_y)",
"def up():\n global y, canvas # y é modificado\n canvas.create_line(x, y, x, y - 10... | [
"0.7055451",
"0.6950502",
"0.6936961",
"0.6897536",
"0.68377566",
"0.6774552",
"0.6772057",
"0.6721872",
"0.6721722",
"0.6694255",
"0.6583421",
"0.6510559",
"0.65014124",
"0.6495371",
"0.6493058",
"0.6481815",
"0.64671576",
"0.6464092",
"0.6451035",
"0.643395",
"0.6425636",
... | 0.79198366 | 0 |
Return or set the pen's attributes. | def pen(self, pen=None, **pendict):
_pd = {"shown" : self._shown,
"pendown" : self._drawing,
"pencolor" : self._pencolor,
"fillcolor" : self._fillcolor,
"pensize" : self._pensize,
"speed" : self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def penColor( self ):\n return self._penColor",
"def GetClassDefaultAttributes(self):\r\n\r\n attr = wx.VisualAttributes()\r\n attr.colFg = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)\r\n attr.colBg = wx.SystemSettings_GetColour(wx.SYS_COLOUR_LISTBOX)\r\n attr.font =... | [
"0.60591114",
"0.59521186",
"0.59521186",
"0.58202076",
"0.57496095",
"0.5679918",
"0.5650609",
"0.5590791",
"0.5566379",
"0.55577755",
"0.55260926",
"0.548827",
"0.54644173",
"0.5462271",
"0.5438474",
"0.54303217",
"0.54254085",
"0.53719974",
"0.5362841",
"0.5352906",
"0.531... | 0.6233249 | 0 |
Delete the Myturtle's drawings and restore its default values. | def reset(self):
TNavigator.reset(self)
TPen._reset(self)
self._clear()
self._drawturtle()
self._update() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __del__(self):\n self._screen._removePen(self)\n del self._turtle",
"def clear(self):\n self._turtle.clear()",
"def clear(self):\n self._turtle.clear()",
"def _clear_drawing(self) -> None:\n self.vertices.clear()\n self.edges.clear()\n self.subplot.clear()... | [
"0.73617107",
"0.72710234",
"0.72710234",
"0.7256286",
"0.7098996",
"0.7083982",
"0.69770163",
"0.69302595",
"0.6780149",
"0.6776574",
"0.6736947",
"0.6652254",
"0.66375005",
"0.6420664",
"0.6326357",
"0.62954605",
"0.6271878",
"0.6266315",
"0.62353224",
"0.6225887",
"0.61865... | 0.7408434 | 0 |
Create and return a clone of the Myturtle. | def clone(self):
screen = self.screen
self._newLine(self._drawing)
Myturtle = self.Myturtle
self.screen = None
self.Myturtle = None # too make self deepcopy-able
q = deepcopy(self)
self.screen = screen
self.Myturtle = Myturtle
q.screen = scree... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone(self):\n return self.__class__(self, self.spectrum, wallet=self.wallet)",
"def clone(self):",
"def clone(self):\n return self",
"def getturtle(self):\n return self",
"def clone(self):\n return self.__class__(self.name, *self)",
"def clone(self):\n return _libs... | [
"0.7177898",
"0.693291",
"0.67999446",
"0.67262167",
"0.6714216",
"0.6671243",
"0.6549572",
"0.65426743",
"0.6524553",
"0.6518727",
"0.65127915",
"0.6445799",
"0.644339",
"0.6410385",
"0.63900346",
"0.6379961",
"0.6378835",
"0.63401765",
"0.6336102",
"0.633265",
"0.63267416",... | 0.8369563 | 0 |
Set Myturtle shape to shape with given name / return current shapename. | def shape(self, name=None):
if name is None:
return self.Myturtle.shapeIndex
if not name in self.screen.getshapes():
raise TurtleGraphicsError("There is no shape named %s" % name)
self.Myturtle._setshape(name)
self._update() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetShape(self, *args):\n return _XCAFDoc.XCAFDoc_ShapeTool_SetShape(self, *args)",
"def _spawn_turtle(self, trt_x, trt_y, name=None):\n\n\t\tif name is None or name == \"\":\n\t\t\tname = self._create_unique_turtle_name()\n\t\telif self._has_turtle(name):\n\t\t\treturn \"\"\n\n\t\tturtle = Turtle(name... | [
"0.6143828",
"0.6078034",
"0.60113525",
"0.5845368",
"0.5724729",
"0.57068795",
"0.5691938",
"0.5600295",
"0.558822",
"0.5547906",
"0.5531356",
"0.5514071",
"0.5507343",
"0.5481607",
"0.547538",
"0.5390002",
"0.53875524",
"0.5384286",
"0.53407335",
"0.53226936",
"0.524077",
... | 0.77385914 | 0 |
Calculate transformed shape polygon according to resizemode and shapetransform. | def _getshapepoly(self, polygon, compound=False):
if self._resizemode == "user" or compound:
t11, t12, t21, t22 = self._shapetrafo
elif self._resizemode == "auto":
l = max(1, self._pensize/5.0)
t11, t12, t21, t22 = l, 0, 0, l
elif self._resizemode == "noresize... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _transform_polygons(self, polygons):\n if self.rotation is not None:\n ct = numpy.cos(self.rotation * numpy.pi / 180.0)\n st = numpy.sin(self.rotation * numpy.pi / 180.0) * _mpone\n if self.magnification is not None:\n mag = numpy.array((self.magnification, self.m... | [
"0.63912666",
"0.62640005",
"0.6012609",
"0.58500296",
"0.57715154",
"0.5723352",
"0.5626749",
"0.55777913",
"0.5576676",
"0.55393016",
"0.5469966",
"0.5469966",
"0.54367065",
"0.54367065",
"0.5385322",
"0.53791654",
"0.53470826",
"0.5342397",
"0.532508",
"0.53185755",
"0.531... | 0.63864154 | 1 |
Manages the correct rendering of the Myturtle with respect to its shape, resizemode, stretch and tilt etc. | def _drawturtle(self):
screen = self.screen
shape = screen._shapes[self.Myturtle.shapeIndex]
ttype = shape._type
titem = self.Myturtle._item
if self._shown and screen._updatecounter == 0 and screen._tracing > 0:
self._hidden_from_screen = False
tshape = sh... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_turtle():\n turtle.setup(width=screen_width)\n turtle.shape(turtle_shape)\n turtle.title(title)",
"def _update_layout(self):\n for i in self._MODES:\n self._parts[i].set_texture(self._prefix + i, \"skin\", resize=True)\n\n # Top and Left\n self._parts[\"Top\"... | [
"0.6403576",
"0.5803147",
"0.5757534",
"0.57560647",
"0.57122225",
"0.5616213",
"0.5585007",
"0.55566514",
"0.549937",
"0.54844797",
"0.5455318",
"0.5445823",
"0.544214",
"0.53811437",
"0.53739995",
"0.53730935",
"0.5357551",
"0.5353902",
"0.53484035",
"0.53455514",
"0.534189... | 0.7145209 | 0 |
Stamp a copy of the turtleshape onto the canvas and return its id. | def stamp(self):
screen = self.screen
shape = screen._shapes[self.Myturtle.shapeIndex]
ttype = shape._type
tshape = shape._data
if ttype == "polygon":
stitem = screen._createpoly()
if self._resizemode == "noresize": w = 1
elif self._resizemode ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shape_id(self):\n return self._shape_id",
"def shape(self, name=None):\n if name is None:\n return self.Myturtle.shapeIndex\n if not name in self.screen.getshapes():\n raise TurtleGraphicsError(\"There is no shape named %s\" % name)\n self.Myturtle._setshape(... | [
"0.59545773",
"0.5305236",
"0.52509373",
"0.51337767",
"0.499248",
"0.49788505",
"0.4818722",
"0.4803845",
"0.47822112",
"0.47462147",
"0.47376835",
"0.47128975",
"0.46846437",
"0.4662359",
"0.46457627",
"0.46033564",
"0.45889434",
"0.4588359",
"0.4588201",
"0.4573066",
"0.45... | 0.6368406 | 0 |
Delete stamp with given stampid | def clearstamp(self, stampid):
self._clearstamp(stampid)
self._update() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clearstamp(self, stampid):\n if stampid in self.stampItems:\n if isinstance(stampid, tuple):\n for subitem in stampid:\n self.screen._delete(subitem)\n else:\n self.screen._delete(stampid)\n self.stampItems.remove(stampid... | [
"0.6817432",
"0.6323765",
"0.6092936",
"0.5960528",
"0.5938911",
"0.5921734",
"0.5871521",
"0.58428675",
"0.58353716",
"0.5810618",
"0.58022326",
"0.5802029",
"0.57991624",
"0.5793931",
"0.57803595",
"0.57751805",
"0.5750283",
"0.57027435",
"0.5691786",
"0.5686231",
"0.564471... | 0.6856775 | 0 |
Delete all or first/last n of Myturtle's stamps. | def clearstamps(self, n=None):
if n is None:
toDelete = self.stampItems[:]
elif n >= 0:
toDelete = self.stampItems[:n]
else:
toDelete = self.stampItems[n:]
for item in toDelete:
self._clearstamp(item)
self._update() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def erase(self, n=1):\n if len(self.x) < n:\n raise IndexError('Does not have enough data to erase!')\n for k in range(n):\n self.diff.pop()\n self.x.pop()",
"def delete_all(self, n):\n for i in range(n):\n try:\n del self.dictionary... | [
"0.66142964",
"0.62436444",
"0.61857015",
"0.60634005",
"0.5881258",
"0.585615",
"0.5854961",
"0.58503574",
"0.5723285",
"0.57020855",
"0.5692238",
"0.5617511",
"0.5545051",
"0.54746693",
"0.54557824",
"0.54481196",
"0.542017",
"0.54046494",
"0.5377807",
"0.5370303",
"0.53703... | 0.7791653 | 0 |
Move the pen to the point end, thereby drawing a line if pen is down. All other methods for Myturtle movement depend on this one. | def _goto(self, end):
## Version with undo-stuff
go_modes = ( self._drawing,
self._pencolor,
self._pensize,
isinstance(self._fillpath, list))
screen = self.screen
undo_entry = ("go", self._position, end, go_modes,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_of_line():\r\n set_point(point().end_of_line())",
"def move(self,x,y):\n assert (type(x) in [int, float]), \"parameter x:%s is not a valid number\" % `x`\n assert (type(y) in [int, float]), \"parameter y:%s is not a valid number\" % `y`\n d = self._turtle.isdown()\n if d:\n ... | [
"0.6613528",
"0.6424479",
"0.641985",
"0.64038825",
"0.6334372",
"0.63291734",
"0.6282229",
"0.62446344",
"0.62211007",
"0.62094563",
"0.61869323",
"0.6183097",
"0.6168437",
"0.61666554",
"0.6136846",
"0.6133894",
"0.61330557",
"0.6131271",
"0.60847",
"0.603834",
"0.60336095"... | 0.7294586 | 0 |
Closes current line item and starts a new one. | def _newLine(self, usePos=True):
if len(self.currentLine) > 1:
self.screen._drawline(self.currentLineItem, self.currentLine,
self._pencolor, self._pensize)
self.currentLineItem = self.screen._createline()
self.items.append(self.currentLin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enter(self):\n if self.pos < self.line_length():\n # If the position is not at the end of the line split the line\n self.buffer.split_line(self.line, self.pos)\n else:\n self.buffer.insert_line(\"\", self.line + 1)\n \n self.line += 1\n self.pos = 0\n self.has_changes = True",
... | [
"0.59516805",
"0.58582115",
"0.5794361",
"0.5769524",
"0.57671",
"0.5683701",
"0.5653681",
"0.5647587",
"0.5551085",
"0.5520081",
"0.55083084",
"0.5490593",
"0.54669076",
"0.54596514",
"0.5449109",
"0.5424114",
"0.53633904",
"0.5338641",
"0.53292465",
"0.53283644",
"0.5254835... | 0.5974907 | 0 |
Start recording the vertices of a polygon. | def begin_poly(self):
self._poly = [self._position]
self._creatingPoly = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initiate(self):\n pts = []\n for point in self.points:\n pt = gr.Point(point[0],point[1])\n pts.append(pt)\n\n self.vis = [gr.Polygon(pts)]\n\n self.draw()",
"def give_polygon(vertices, points):\n polygon = np.zeros((len(vertices), 2))\n for i, ... | [
"0.62927264",
"0.61782724",
"0.6133704",
"0.60111237",
"0.57999295",
"0.57220894",
"0.56979716",
"0.5694384",
"0.5685063",
"0.56764746",
"0.5590536",
"0.5583972",
"0.55473775",
"0.5522647",
"0.55015236",
"0.5489928",
"0.54840237",
"0.54795456",
"0.5473881",
"0.54701525",
"0.5... | 0.67437726 | 0 |
Return the Turtleobject itself. | def getturtle(self):
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obj(self) -> object:\n pass",
"def obj(self):\r\n return self._obj",
"def fire_torpedo(self):\n return Torpedo(self)",
"def obj(self):\n if not self._obj:\n self._get()\n return self._obj",
"def Screen():\n if Myturtle._screen is None:\n Myturtle.... | [
"0.6059407",
"0.59336627",
"0.58552444",
"0.5826366",
"0.5818572",
"0.5818455",
"0.5800745",
"0.57855034",
"0.5761922",
"0.5760971",
"0.5730162",
"0.56956524",
"0.5682162",
"0.5641696",
"0.5630629",
"0.55974203",
"0.55940217",
"0.5570873",
"0.5502058",
"0.54970336",
"0.548608... | 0.7841631 | 0 |
Return the singleton screen object. If none exists at the moment, create a new one and return it, else return the existing one. | def Screen():
if Myturtle._screen is None:
Myturtle._screen = _Screen()
return Myturtle._screen | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getInstance(screen):\r\n if Game.__instance == None:\r\n Game.__instance = Game(screen)\r\n return Game.__instance",
"def getScreen(self):\n \n return self.screen",
"def getscreen(self):\n return self.screen",
"def getscreen(self):\n return self.screen... | [
"0.7267535",
"0.6170684",
"0.6133751",
"0.6133751",
"0.60925436",
"0.59846085",
"0.5899024",
"0.58917165",
"0.57748014",
"0.577314",
"0.57484686",
"0.5736769",
"0.5713113",
"0.56793666",
"0.56304425",
"0.5627452",
"0.5620755",
"0.5566278",
"0.55652213",
"0.55126613",
"0.55042... | 0.6517337 | 1 |
Create and write docstringdictionary to file. | def GdictWrite(filename="turtle_docstringdict"):
docsdict = {}
for methodname in gScreenFunc:
key = "_Screen."+methodname
docsdict[key] = eval(key).__doc__
for methodname in gMoveFunc:
key = "Myturtle."+methodname
docsdict[key] = eval(key).__doc__
with open("%s.py" % fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_dictionary(args, dictio):\n if not args.dictfile.endswith(\".file\"):\n args.dictfile += \".file\"\n with open(args.dictfile, \"wb\") as f:\n dump(dictio, f, protocol=HIGHEST_PROTOCOL)",
"def write_completed_dictionary_to_file(the_dict):\n\ttry:\n\t\toutputLocation = open('usable_di... | [
"0.61986554",
"0.6153944",
"0.58657086",
"0.57220095",
"0.5718355",
"0.5694824",
"0.5671296",
"0.566762",
"0.56513095",
"0.5645625",
"0.56439674",
"0.5630535",
"0.5581719",
"0.55736256",
"0.5555813",
"0.55523473",
"0.5548598",
"0.554656",
"0.5536558",
"0.55274606",
"0.5520095... | 0.68189085 | 0 |
Read in docstrings from langspecific docstring dictionary. Transfer docstrings, translated to lang, from a dictionaryfile to the methods of classes Screen and Myturtle and in revised form to the corresponding functions. | def read_docstrings(lang):
modname = "turtle_docstringdict_%(language)s" % {'language':lang.lower()}
module = __import__(modname)
docsdict = module.docsdict
for key in docsdict:
try:
# eval(key).im_func.__doc__ = docsdict[key]
eval(key).__doc__ = docsdict[key]
exce... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_doxygen_docstring(lines, name):\n\n lines = lines[:]\n newlines = []\n indent = 0\n reading_desc = False\n\n while lines:\n line = lines.pop(0)\n if line.startswith(\"////\"):\n continue\n\n line = line.rstrip()\n if line.startswith('///<'):\n ... | [
"0.5545969",
"0.5444798",
"0.5415546",
"0.53539515",
"0.5306852",
"0.5291794",
"0.5276163",
"0.5273808",
"0.5238084",
"0.51521593",
"0.51123774",
"0.51029795",
"0.51015687",
"0.50694877",
"0.5067063",
"0.50619537",
"0.5060623",
"0.5039005",
"0.5029071",
"0.5023167",
"0.500853... | 0.8345374 | 0 |
Serialize the string date to a datetime value. | def serialize_date(value):
return datetime.strptime(value, '%d %b %Y') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _serialize_date(val):\n return date_to_iso8601(val)",
"def _serialize_datetime(val):\n return datetime_to_iso8601(val)",
"def serialize(date):\n # From database to client\n\n # Convert date-object to datetime\n # See: https://stackoverflow.com/questions/1937622/convert-date-to-da... | [
"0.71354926",
"0.68498755",
"0.66490716",
"0.6419961",
"0.6376044",
"0.63656783",
"0.6365236",
"0.63495934",
"0.6346184",
"0.634235",
"0.6338759",
"0.62420154",
"0.62168455",
"0.62115145",
"0.619565",
"0.6186587",
"0.6179467",
"0.61690307",
"0.6158575",
"0.6152683",
"0.614988... | 0.7412838 | 0 |
A property decorator that memoizes the result. This is used to memoize the results of class properties, to be used when computing the property value is expensive. | def memoized_property(func: Function) -> property:
# Based on Danijar Hafner's implementation of a lazy property, available at:
# https://danijar.com/structuring-your-tensorflow-models/
attribute_name = "_memoized_property_" + func.__name__
@property
@functools.wraps(func)
def decorator(self):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cached_property(func):\n return Property(fget=func, cached=True)",
"def cached_property(fun):\n @functools.wraps(fun)\n def get(self):\n try:\n return self._cache[fun]\n except AttributeError:\n self._cache = {}\n except KeyError:\n pass\n ... | [
"0.74533105",
"0.7447887",
"0.733369",
"0.7268538",
"0.7268411",
"0.7180744",
"0.7005188",
"0.68395853",
"0.6735997",
"0.6628319",
"0.65378666",
"0.6476915",
"0.64601874",
"0.64601874",
"0.64601874",
"0.6451155",
"0.64159197",
"0.6384591",
"0.6326874",
"0.6313788",
"0.6263166... | 0.7997713 | 0 |
Return the paths of a user's SSH files. | def GetUserFiles(user, mkdir=False, dircheck=True, kind=constants.SSHK_DSA,
_homedir_fn=None):
if _homedir_fn is None:
_homedir_fn = utils.GetHomeDir
user_dir = _homedir_fn(user)
if not user_dir:
raise errors.OpExecError("Cannot resolve home of user '%s'" % user)
if kind == constants.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __parse_user_keyfiles(self):\n\n user_sshdir = os.path.expanduser('~/.ssh')\n if not os.path.isdir(user_sshdir):\n return\n\n paths = []\n for filename in os.listdir(user_sshdir):\n if filename in SSH_CONFIG_FILES or os.path.splitext(filename)[1] != '.pub':\n ... | [
"0.6815306",
"0.65893316",
"0.6569793",
"0.6539029",
"0.6516319",
"0.634172",
"0.62293583",
"0.61868155",
"0.61260295",
"0.6075835",
"0.6063089",
"0.5990238",
"0.5982808",
"0.595064",
"0.593153",
"0.5919284",
"0.59001994",
"0.58423096",
"0.58388907",
"0.5830525",
"0.5772707",... | 0.67957896 | 1 |
Wrapper over L{GetUserFiles} to retrieve files for all SSH key types. See L{GetUserFiles} for details. | def GetAllUserFiles(user, mkdir=False, dircheck=True, _homedir_fn=None):
helper = compat.partial(GetUserFiles, user, mkdir=mkdir, dircheck=dircheck,
_homedir_fn=_homedir_fn)
result = [(kind, helper(kind=kind)) for kind in constants.SSHK_ALL]
authorized_keys = [i for (_, (_, _, i)) in re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetUserFiles(user, mkdir=False, dircheck=True, kind=constants.SSHK_DSA,\n _homedir_fn=None):\n if _homedir_fn is None:\n _homedir_fn = utils.GetHomeDir\n\n user_dir = _homedir_fn(user)\n if not user_dir:\n raise errors.OpExecError(\"Cannot resolve home of user '%s'\" % user)\n\n if ki... | [
"0.7022788",
"0.6507771",
"0.644886",
"0.622935",
"0.5820931",
"0.5751039",
"0.55767727",
"0.55684954",
"0.5534864",
"0.55161965",
"0.5452578",
"0.54422456",
"0.54075515",
"0.5397115",
"0.53943914",
"0.5381998",
"0.5344919",
"0.5326442",
"0.53219026",
"0.5310566",
"0.5283549"... | 0.702468 | 0 |
Builds a list with needed SSH options. | def _BuildSshOptions(self, batch, ask_key, use_cluster_key,
strict_host_check, private_key=None, quiet=True,
port=None):
options = [
"-oEscapeChar=none",
"-oHashKnownHosts=no",
"-oGlobalKnownHostsFile=%s" % pathutils.SSH_KNOWN_HOSTS_FILE,
"-oUser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_options(self):\n opts = [\n \"-k rpm.rpmva=off\",\n \"-k apache.log=True\",\n ]\n\n sensitive_keys = {\n self._engine_plugin: 'sensitive_keys',\n 'ovirt_engine_dwh': 'dwh_sensitive_keys',\n }\n if self.configuration['include_s... | [
"0.6554022",
"0.639308",
"0.62351835",
"0.6176157",
"0.6151676",
"0.60372573",
"0.5989086",
"0.5973253",
"0.5886928",
"0.58624715",
"0.58454704",
"0.58434445",
"0.58004487",
"0.5762706",
"0.5728157",
"0.5720622",
"0.5677747",
"0.5641881",
"0.5615017",
"0.55816853",
"0.5575047... | 0.70109904 | 0 |
Verify hostname consistency via SSH. This functions connects via ssh to a node and compares the hostname reported by the node to the name with have (the one that we connected to). This is used to detect problems in ssh known_hosts files (conflicting known hosts) and inconsistencies between dns/hosts entries and local m... | def VerifyNodeHostname(self, node, ssh_port):
cmd = ("if test -z \"$GANETI_HOSTNAME\"; then"
" hostname --fqdn;"
"else"
" echo \"$GANETI_HOSTNAME\";"
"fi")
retval = self.Run(node, constants.SSH_LOGIN_USER, cmd,
quiet=False, port=ssh_port)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def needs_ssh(hostname, _socket=None):\n if hostname.lower() in ['localhost', '127.0.0.1', '127.0.1.1']:\n return False\n _socket = _socket or socket\n fqdn = _socket.getfqdn()\n if hostname == fqdn:\n return False\n local_hostname = _socket.gethostname()\n local_short_hostname = lo... | [
"0.69107556",
"0.656078",
"0.656078",
"0.65098125",
"0.6342981",
"0.63187635",
"0.63187635",
"0.6303591",
"0.62600493",
"0.6256846",
"0.62546986",
"0.6138215",
"0.61173916",
"0.6107151",
"0.5987594",
"0.5957575",
"0.5948089",
"0.5927646",
"0.5832362",
"0.58163154",
"0.5786314... | 0.7773422 | 0 |
Writes the clusterwide equally known_hosts file. | def WriteKnownHostsFile(cfg, file_name):
data = ""
if cfg.GetRsaHostKey():
data += "%s ssh-rsa %s\n" % (cfg.GetClusterName(), cfg.GetRsaHostKey())
if cfg.GetDsaHostKey():
data += "%s ssh-dss %s\n" % (cfg.GetClusterName(), cfg.GetDsaHostKey())
utils.WriteFile(file_name, mode=0600, data=data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_hosts_file(n, path=\"./tests/fixtures\"):\n if not os.path.isdir(path):\n os.mkdir(path)\n with open(f\"{path}/hosts.txt\", \"w\") as f:\n for i in range(n):\n f.write(f\"{i},localhost,127.0.0.1,{5000+i}\\n\")",
"def write(content):\n with open(TMP_HOSTS_FILE, \"w\"... | [
"0.6225859",
"0.60397935",
"0.5874528",
"0.5857438",
"0.58426636",
"0.5815164",
"0.57000405",
"0.554411",
"0.55060196",
"0.5492018",
"0.54734915",
"0.53940684",
"0.53639436",
"0.53541887",
"0.5298685",
"0.5272429",
"0.521711",
"0.51572895",
"0.5101507",
"0.5088074",
"0.502690... | 0.7264671 | 0 |
Charge un personnage et l'associe dans self.personnages | def load_perso(self, id_utilisateur):
"""
res = self.db.requete_db(\"""SELECT * FROM utilisateurs\
WHERE id_utilisateur=?\""",\
(id_utilisateur,))
"""
perso = Personnage(self, id_utilisateur)
self.personnages... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return \"Personne: nom({}), prénom({}), âges ({})\".format(self.nom, self.prenom, self.age)",
"def crier_ordres(self, personnage):\n adverse = self.adverse\n msg = \"{} s'écrie : un boulet sur {} !\".format(\n personnage.distinction_audible, adverse.desc_... | [
"0.591366",
"0.56589794",
"0.5635063",
"0.5557006",
"0.554344",
"0.5504283",
"0.5426705",
"0.53781843",
"0.53479624",
"0.5333507",
"0.5312377",
"0.53016996",
"0.53004044",
"0.5246279",
"0.5229622",
"0.52253735",
"0.5167496",
"0.5154765",
"0.51299393",
"0.5124255",
"0.5115383"... | 0.66468084 | 0 |
Handles a game win and draws a win board on the screen. If part of a tournament, it will set the winning player as a winner in the tournament. | def handleWin(self, winningplayer):
self.board.drawWinBoard(winningplayer, self.istournament)
self.board = None
self.ui.game = None
if self.istournament:
if winningplayer == 1:
self.ui.tournament.setWinner(1)
if winningplayer == -1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def win(self, player):\n if player == 1:\n a = self.player_one.moves\n else:\n a = self.player_two.moves\n winning_moves = []\n for i in range(1, 9, 3):\n winning_moves.append(range(i, i + 3))\n for i in range(1, 4):\n winning_moves.app... | [
"0.7354114",
"0.73210603",
"0.72094834",
"0.7175612",
"0.7138135",
"0.7133121",
"0.71170354",
"0.7065439",
"0.7011677",
"0.6992712",
"0.6905542",
"0.69014484",
"0.68530196",
"0.6849343",
"0.6781418",
"0.67568487",
"0.6755098",
"0.67207557",
"0.6717351",
"0.6711404",
"0.669175... | 0.86119634 | 0 |
Handles a game draw and draws a draw board on the screen. If part of a tournament 3 draws have been made in a row, it will randomize a winner. | def handleDraw(self):
print("Its a draaaw")
self.board.drawDrawBoard()
self.ui.game = None
if self.istournament:
if self.tournamentgame.gamecount < 2:
self.tournamentgame.gamecount = self.tournamentgame.gamecount+1
self.board.displayTournament... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __check_winner(self):\n for i in range(0, 3):\n col = self.__get_col(i)\n if col.get(self.player_char) == 3:\n print('\\nYou win!')\n self.game_ended = True\n return\n if col.get(self.opponent_char) == 3:\n prin... | [
"0.71793014",
"0.7135505",
"0.69333947",
"0.679917",
"0.67140776",
"0.6689482",
"0.6616458",
"0.6603764",
"0.660077",
"0.6580719",
"0.6579889",
"0.6572002",
"0.6518525",
"0.65171593",
"0.64786243",
"0.647032",
"0.6414249",
"0.63918775",
"0.63835615",
"0.6371472",
"0.6370773",... | 0.8386807 | 0 |
Causes the current player to forfeit the current game. | def playerForfeit(self):
self.handleWin(self.currentplayer*-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play(self, player, game): \n super().play(player, game)\n game.set_action(\"SLEEP_CODER\")",
"def update(self):\r\n if not self.tr.game_over and self.tr.turn_tracker:\r\n self.computer_play()",
"def play_game(self):\n # need everyone to pass to move to next... | [
"0.72997624",
"0.7028231",
"0.6982496",
"0.69552714",
"0.69463617",
"0.69215953",
"0.6851516",
"0.675886",
"0.668377",
"0.66815096",
"0.66583437",
"0.66448665",
"0.65827966",
"0.655984",
"0.65565306",
"0.654274",
"0.65393883",
"0.6524599",
"0.6484492",
"0.6471058",
"0.6466911... | 0.77158123 | 0 |
Returns the sensor type, f.e. thb. | def get_sensor_type(self):
return self.data[1][:-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\n return self._sensor_type",
"def device_class(self):\n return self.sensor_type[\"class\"]",
"def device_class(self) -> str | None:\n return self._get_sensor_type()[2]",
"def metertype(self):\n return self._metertype.get_waarde()",
"def get_default_sensor... | [
"0.712751",
"0.6980082",
"0.6964943",
"0.6866985",
"0.6718667",
"0.67184216",
"0.6718335",
"0.67090505",
"0.6664326",
"0.6664326",
"0.66510004",
"0.6639602",
"0.6639602",
"0.66321737",
"0.66211474",
"0.6606579",
"0.66017085",
"0.653939",
"0.64990103",
"0.6498133",
"0.64922404... | 0.8380098 | 0 |
Returns the sensor number | def get_sensor_number(self):
return int(self.data[1][-1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_wind_sensor(self) -> int:\n self.serial.write(b\"V!\")\n wind_sensor = self.__extract_int(self.__read_response(1)[0], b\"!w\")\n\n return wind_sensor",
"def get_number(self):\n return self.__device_number",
"def getLightSensor() -> int:\n pass",
"def sensor(self , senso... | [
"0.72921866",
"0.72716254",
"0.72215855",
"0.6991148",
"0.6926272",
"0.6887004",
"0.6755828",
"0.67055243",
"0.67028284",
"0.6701708",
"0.66806006",
"0.6632175",
"0.661996",
"0.6568401",
"0.65603375",
"0.6507038",
"0.6482421",
"0.6466721",
"0.643406",
"0.6386015",
"0.6343718"... | 0.88487446 | 0 |
Returns the full sensor name, f.e. wind0 | def get_sensor_name(self):
return self.data[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._sensor.name",
"def friendly_name(self):\n return self._sensor_name",
"def name(self):\n return f\"{self._name} {SENSOR_TYPES[self.sensor][0]}\"",
"def name(self):\n return self.device.device_data[self.device_id]['name'] + \\\n f' {self._se... | [
"0.7582795",
"0.7523397",
"0.7500788",
"0.7433387",
"0.7193106",
"0.71633244",
"0.71525973",
"0.70375884",
"0.70051795",
"0.6941416",
"0.6824166",
"0.6777688",
"0.67560774",
"0.6752853",
"0.6744714",
"0.66684556",
"0.66287833",
"0.66215414",
"0.6407245",
"0.6396662",
"0.63772... | 0.8127429 | 0 |
Returns the value of a t sensor | def get_t_value(self):
return float(self.data[2]) / 10 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_value(self):\n return self.sensor.get_value()",
"def raw_sensor_temp(self):\n\n # return the value in millicelsius\n return float(self.raw_sensor_strings[1].split(\"=\")[1])",
"def get_ir_sensor_temperature(self) -> float:\n self.serial.write(b\"T!\")\n ir_sensor_temp... | [
"0.77358204",
"0.7388789",
"0.7291502",
"0.72200984",
"0.7182863",
"0.71696424",
"0.7142843",
"0.7139891",
"0.7104367",
"0.7070535",
"0.7047923",
"0.7047081",
"0.6964376",
"0.69313365",
"0.6930856",
"0.69106907",
"0.68933904",
"0.68690497",
"0.6823682",
"0.6791697",
"0.676789... | 0.7398517 | 1 |
Returns the mean values of a given tvalue list | def get_t_mean_value(self, value_list):
if not len(value_list):
return None
else:
return round(statistics.mean(value_list), 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_th_mean_values(self, value_list):\n if not len(value_list):\n return None, None, None\n t, h, d = map(list, zip(*value_list))\n return (\n round(statistics.mean(t), 1),\n int(round(statistics.mean(h), 0)),\n round(statistics.mean(d), 1),\n ... | [
"0.8035656",
"0.7831136",
"0.7761068",
"0.768525",
"0.7579617",
"0.7523615",
"0.7422822",
"0.73106337",
"0.72299606",
"0.7228836",
"0.72205615",
"0.7220237",
"0.719906",
"0.71492904",
"0.71233815",
"0.71087384",
"0.7099522",
"0.7043981",
"0.7041665",
"0.70132077",
"0.6996165"... | 0.84303254 | 0 |
Returns values (temp/hum/dew/baro/forecast/sealevel) of a thb sensor | def get_thb_values(self):
return (
float(self.data[2]) / 10, # temp
int(self.data[3]), # hum
float(self.data[4]) / 10, # dew
float(self.data[5]) / 10, # baro
int(self.data[6]), # forecast
float(self.data[7]) / 10, # pressure at sealev... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sensors_data(self):\n\n temp_in_celsius = self.get_temperature()\n\n return (\n round(temp_in_celsius, 1), \n round(self.to_fahrenheit(temp_in_celsius), 1), \n round(self.get_humidity(), 0), \n round(self.get_pressure(), 1)\n )",
"def tempe... | [
"0.71954936",
"0.71794486",
"0.69512266",
"0.68936956",
"0.67637795",
"0.6748177",
"0.66847765",
"0.66613424",
"0.66547906",
"0.6625184",
"0.6584921",
"0.6561356",
"0.65596384",
"0.655392",
"0.6550401",
"0.6500118",
"0.6472888",
"0.6423746",
"0.642214",
"0.6420399",
"0.640965... | 0.79888725 | 0 |
Returns the mean values of a given thvalue list | def get_th_mean_values(self, value_list):
if not len(value_list):
return None, None, None
t, h, d = map(list, zip(*value_list))
return (
round(statistics.mean(t), 1),
int(round(statistics.mean(h), 0)),
round(statistics.mean(d), 1),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mean(listvalue):\n\treturn sum(listvalue)/len(listvalue)",
"def get_thb_mean_values(self, value_list):\n if not len(value_list):\n return None, None, None, None, None\n\n temp, hum, dew, baro, forecast, sealevel = map(list, zip(*value_list))\n return (\n round(stat... | [
"0.8034713",
"0.7950179",
"0.7874193",
"0.785855",
"0.78545845",
"0.7767807",
"0.7683209",
"0.7574799",
"0.75705093",
"0.7557271",
"0.74656934",
"0.7425457",
"0.7381087",
"0.73020715",
"0.7276637",
"0.7194838",
"0.7187722",
"0.7095684",
"0.70814633",
"0.70770663",
"0.7069976"... | 0.83481723 | 0 |
Returns values (dir/gust/avg/chill) of a wind sensor | def get_wind_values(self):
return (
int(self.data[2]), # dir
float(self.data[3]) / 10, # gust
float(self.data[4]) / 10, # avg
float(self.data[5]) / 10, # chill
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wind_speed(self):\n names = ['anc_mean_wind_speed']\n return self.sensor.get_with_fallback('wind_speed', names)",
"def get_sensors_data(self):\n\n temp_in_celsius = self.get_temperature()\n\n return (\n round(temp_in_celsius, 1), \n round(self.to_fahrenheit(t... | [
"0.70536834",
"0.6606275",
"0.6605308",
"0.66043174",
"0.6554906",
"0.652577",
"0.6509941",
"0.64786017",
"0.64461035",
"0.6393536",
"0.62955326",
"0.6292042",
"0.6269706",
"0.6226568",
"0.6199306",
"0.6139651",
"0.6106034",
"0.6064414",
"0.60123414",
"0.5982694",
"0.59728",
... | 0.83013546 | 0 |
Returns the mean values of a given windvalue list | def get_wind_mean_values(self, value_list):
if not len(value_list):
return None, None, None, None
dir, gust, avg, chill = map(list, zip(*value_list))
return (
int(round(statistics.mean(dir), 0)),
round(statistics.mean(gust), 1),
round(statistics.m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean(list_of_values):\r\n # Explicit float(...) to allow for Python 2 division.\r\n return sum(list_of_values) / float(len(list_of_values))",
"def get_rain_mean_values(self, value_list):\n if not len(value_list):\n return None, None\n\n rate, total = map(list, zip(*valu... | [
"0.7609455",
"0.75113475",
"0.7445969",
"0.7359098",
"0.7183681",
"0.7170421",
"0.7114486",
"0.7094264",
"0.7062167",
"0.7044667",
"0.7039881",
"0.7026979",
"0.70164853",
"0.6987465",
"0.69849795",
"0.6969095",
"0.69474036",
"0.69014347",
"0.6857735",
"0.68284947",
"0.6737842... | 0.85772514 | 0 |
Returns the mean value of a given solvalue list | def get_sol_mean_value(self, value_list):
if len(value_list):
return int(round(statistics.mean(value_list), 0))
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mean(listvalue):\n\treturn sum(listvalue)/len(listvalue)",
"def mean(list_of_values):\r\n # Explicit float(...) to allow for Python 2 division.\r\n return sum(list_of_values) / float(len(list_of_values))",
"def mean_value( values ):\n return sum( values ) / len( values )",
"def mean(val... | [
"0.77464134",
"0.76582295",
"0.74594337",
"0.74359584",
"0.7278",
"0.7259888",
"0.72362965",
"0.7208554",
"0.7151343",
"0.70732075",
"0.70670736",
"0.69791293",
"0.6977969",
"0.69734216",
"0.6966683",
"0.6957543",
"0.69306076",
"0.6917578",
"0.68614304",
"0.6828481",
"0.67620... | 0.8417053 | 0 |
Returns the value of a uv sensor | def get_uv_value(self):
return float(int(self.data[2]) / 10) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUVIndex(self):\n\t\tval = grovepi.analogRead(self.uv_sensor)\n\t\tillumination_intensity = val*307\n\t\tuv_index = illumination_intensity/float(200)\n\t\treturn uv_index",
"def read_uv(self):\n return self._read16(0x2C, little_endian=True) / 100",
"def get_value(self):\n return self.sensor... | [
"0.7297083",
"0.71961826",
"0.7134578",
"0.6486077",
"0.64282644",
"0.6422018",
"0.6419723",
"0.64034706",
"0.64009273",
"0.64002705",
"0.6395955",
"0.6345213",
"0.634253",
"0.6341466",
"0.6248994",
"0.6207543",
"0.618416",
"0.61705834",
"0.6160929",
"0.6148105",
"0.6148105",... | 0.7817373 | 0 |
Returns the mean value of a given uvvalue list | def get_uv_mean_value(self, value_list):
if len(value_list):
return int(round(statistics.mean(value_list), 0))
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mean(listvalue):\n\treturn sum(listvalue)/len(listvalue)",
"def mean(list_of_values):\r\n # Explicit float(...) to allow for Python 2 division.\r\n return sum(list_of_values) / float(len(list_of_values))",
"def mean_value( values ):\n return sum( values ) / len( values )",
"def get_sol_... | [
"0.7751135",
"0.75171626",
"0.75041956",
"0.7471181",
"0.74531263",
"0.7412795",
"0.73203397",
"0.7221085",
"0.71762145",
"0.71451473",
"0.71089",
"0.7086222",
"0.7031144",
"0.70291066",
"0.7024628",
"0.6963111",
"0.6928992",
"0.69074994",
"0.69034994",
"0.6855154",
"0.684955... | 0.848832 | 0 |
Returns the rain sensor values (rate/total) | def get_rain_values(self):
return float(self.data[2]) / 10, float(self.data[4]) / 10 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raw_rain_sensor_temp(self) -> int:\n self._update_analog_value_cache()\n return self.analog_cache.rain_sensor_temp",
"def get_rain_mean_values(self, value_list):\n if not len(value_list):\n return None, None\n\n rate, total = map(list, zip(*value_list))\n rain = ... | [
"0.72224313",
"0.7113404",
"0.7036755",
"0.67013526",
"0.65311795",
"0.6367569",
"0.6340259",
"0.63118654",
"0.6237534",
"0.61978304",
"0.6195324",
"0.6149609",
"0.6134852",
"0.60428345",
"0.60210586",
"0.60131687",
"0.5961657",
"0.5958928",
"0.5943346",
"0.5934416",
"0.59271... | 0.83477956 | 0 |
Returns the mean values of a rain sensor | def get_rain_mean_values(self, value_list):
if not len(value_list):
return None, None
rate, total = map(list, zip(*value_list))
rain = round(total[-1] - total[0], 1)
# Rain can't be negative and in january many rain sensors are
# resetted to 0 which leads to negativ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rain_values(self):\n return float(self.data[2]) / 10, float(self.data[4]) / 10",
"def get_mean(self):\n return self.serie.mean()",
"def calculate_mean(weather_data):\n sum_value=0\n\n for value in weather_data:\n sum_value += float(value)\n \n mean = sum_value/len(weath... | [
"0.7449613",
"0.7121376",
"0.7068443",
"0.7016701",
"0.68816674",
"0.6832859",
"0.680174",
"0.67747545",
"0.6772888",
"0.6760779",
"0.6729011",
"0.6711309",
"0.67074865",
"0.6706144",
"0.67000014",
"0.6675047",
"0.66674566",
"0.6647652",
"0.65865636",
"0.65680385",
"0.6568038... | 0.7855634 | 0 |
Helper method for converting deprecated limit_price and stop_price arguments into ExecutionStyle instances. This function assumes that either style == None or (limit_price, stop_price) == (None, None). | def __convert_order_params_for_blotter(limit_price, stop_price, style):
if style:
assert (limit_price, stop_price) == (None, None)
return style
if limit_price and stop_price:
return StopLimitOrder(limit_price, stop_price)
if limit_price:
return Lim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_style(style):\n if isinstance(style, (str, dict)):\n return Style(style)\n elif isinstance(style, Style):\n return style\n else:\n return Style()",
"def validate_order_params(self,\n asset,\n amount,\n ... | [
"0.5426312",
"0.52149206",
"0.5101911",
"0.5037377",
"0.50249916",
"0.500891",
"0.49706978",
"0.48260212",
"0.48249587",
"0.480683",
"0.47849914",
"0.47360033",
"0.47242194",
"0.47186542",
"0.47162336",
"0.4714977",
"0.47024837",
"0.469033",
"0.46809167",
"0.4660018",
"0.4655... | 0.72234297 | 0 |
Register a new AccountControl to be checked on each bar. | def register_account_control(self, control):
if self.initialized:
raise RegisterAccountControlPostInit()
self.account_controls.append(control) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_trading_control(self, control):\n if self.initialized:\n raise RegisterTradingControlPostInit()\n self.trading_controls.append(control)",
"def register(account_type):\n def class_rebuilder(cls):\n ACCOUNT_TYPES[account_type] = cls\n return cls\n return class_rebuilde... | [
"0.621743",
"0.5511488",
"0.55006987",
"0.54347086",
"0.54347086",
"0.54347086",
"0.54347086",
"0.53059524",
"0.5241029",
"0.52371526",
"0.52322316",
"0.5176735",
"0.51662064",
"0.5137405",
"0.5110972",
"0.50961804",
"0.5025272",
"0.5015871",
"0.5009514",
"0.500842",
"0.49696... | 0.7682392 | 0 |
Set a limit on the maximum leverage of the algorithm. | def set_max_leverage(self, max_leverage):
control = MaxLeverage(max_leverage)
self.register_account_control(control) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_limit_max():\n limit_max = request.params.get(\"limit_max\", 0, type=float)\n output = request.params.get(\"output\", 1, type=int)\n retval = RP_LIB.rp_LimitMax(output, ctypes.c_float(limit_max))\n if retval != 0:\n LOG.error(\"Failed to set maximum output voltage. Error code: %s\", ERRO... | [
"0.724919",
"0.7016326",
"0.7016326",
"0.6927392",
"0.6867965",
"0.6846231",
"0.6833265",
"0.6795299",
"0.67814326",
"0.67062867",
"0.6705914",
"0.66737866",
"0.6662624",
"0.6634589",
"0.6630519",
"0.6624588",
"0.65863127",
"0.6568773",
"0.6564483",
"0.6545328",
"0.6545328",
... | 0.78781945 | 0 |
Register a new TradingControl to be checked prior to order calls. | def register_trading_control(self, control):
if self.initialized:
raise RegisterTradingControlPostInit()
self.trading_controls.append(control) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_account_control(self, control):\n if self.initialized:\n raise RegisterAccountControlPostInit()\n self.account_controls.append(control)",
"def add_control(self, iot_control):\n if isinstance(iot_control, Alarm):\n iot_control.message_tx_event += self.send_a... | [
"0.6567349",
"0.5557626",
"0.55111516",
"0.55111516",
"0.55111516",
"0.55111516",
"0.5382541",
"0.53327614",
"0.52990526",
"0.5287516",
"0.5225305",
"0.5105157",
"0.50551075",
"0.4919047",
"0.48890963",
"0.48584044",
"0.48385772",
"0.4827087",
"0.47736055",
"0.47574076",
"0.4... | 0.822567 | 0 |
Set a limit on the number of shares and/or dollar value of any single order placed for sid. Limits are treated as absolute values and are enforced at the time that the algo attempts to place an order for sid. If an algorithm attempts to place an order that would result in exceeding one of these limits, raise a TradingC... | def set_max_order_size(self,
asset=None,
max_shares=None,
max_notional=None,
on_error='fail'):
control = MaxOrderSize(asset=asset,
max_shares=max_shares,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strict_limit(self, strict_limit):\n\n self._strict_limit = strict_limit",
"def limit_chase(self, oq, max_chase=3.0, failsafe=False, double_check=False):\n ret = self.send_order(oq=oq, ot='limit', price=None)\n order_id = ret[0]['orderID']\n last_price = ret[0]['price']\n si... | [
"0.5921895",
"0.57735974",
"0.5725143",
"0.57079554",
"0.56382525",
"0.5630813",
"0.55486006",
"0.5509752",
"0.54923606",
"0.5483896",
"0.5443233",
"0.54388654",
"0.5404075",
"0.53903586",
"0.5376704",
"0.5374852",
"0.53745776",
"0.53409106",
"0.53382504",
"0.53382504",
"0.53... | 0.5819131 | 1 |
Set a restriction on which assets can be ordered. | def set_asset_restrictions(self, restrictions, on_error='fail'):
control = RestrictedListOrder(on_error, restrictions)
self.register_trading_control(control)
self.restrictions |= restrictions | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_itar_restrict_asset(self):\n pass",
"def set_restriction_filters(self):\n self.restriction_filters[\"pk__exact\"] = self.request.user.pk",
"def test_itar_restrict_test_asset(self):\n pass",
"def set_do_not_order_list(self, restricted_list, on_error='fail'):\n if isinstanc... | [
"0.5862194",
"0.5779639",
"0.5694709",
"0.56470656",
"0.55811715",
"0.54445773",
"0.52758116",
"0.51754206",
"0.5161849",
"0.5132235",
"0.5066222",
"0.5035237",
"0.501944",
"0.49849662",
"0.4979434",
"0.4963584",
"0.49379414",
"0.4887372",
"0.4876058",
"0.4779043",
"0.4779043... | 0.7511529 | 0 |
Returns all packages of uniq. | def get_packages():
packages = find_packages()
packages = ['{}.{}'.format('uniq', package) for package in packages]
packages.append('uniq')
return packages | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def packages(self):\n return []",
"def test_distinct(self):\n pkgs = [\n make_package(factory=DynamoPackage),\n make_package(version=\"1.3\", filename=\"mypath3\", factory=DynamoPackage),\n make_package(\"mypkg2\", \"1.3.4\", \"my/other/path\", factory=DynamoPackage... | [
"0.6430366",
"0.6309106",
"0.6299323",
"0.62896633",
"0.6276589",
"0.62677157",
"0.62133825",
"0.6208776",
"0.61960036",
"0.61661726",
"0.611649",
"0.60419285",
"0.59264976",
"0.58020616",
"0.5763166",
"0.57164764",
"0.56727856",
"0.56717694",
"0.56565005",
"0.5655758",
"0.56... | 0.81401074 | 0 |
Return the NSPopUpButton that this object wraps. | def getNSPopUpButton(self):
return self._nsObject | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def button(self):\n return self._button",
"def button(self):\n return self._button",
"def GetButton(self):\r\n\r\n return self.button",
"def okButton(self):\n return self.__okButton",
"def okButton(self):\n return self.__okButton",
"def okButton(self):\n return s... | [
"0.6526846",
"0.6526846",
"0.64482844",
"0.6378192",
"0.6378192",
"0.6378192",
"0.63245046",
"0.62547964",
"0.5730146",
"0.56952465",
"0.5684308",
"0.5434167",
"0.53666764",
"0.5366605",
"0.5349822",
"0.5349822",
"0.5349822",
"0.5344203",
"0.5318714",
"0.5275598",
"0.52448124... | 0.91227067 | 0 |
Get the index selected item in the pop up list. | def get(self):
return self._nsObject.indexOfSelectedItem() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def 取选中项索引(self): # real signature unknown; restored from __doc__\n return self.GetSelection()",
"def get_selected_index(self) -> int:\n return self._selected_index",
"def get_selected_ix( self ):\n selected_ix = self.listbox.curselection()\n\n if selected_ix == tuple( ):\n ... | [
"0.75485176",
"0.74857414",
"0.73887503",
"0.7338485",
"0.73112506",
"0.7015429",
"0.6953144",
"0.6934704",
"0.6860859",
"0.6768367",
"0.67466336",
"0.6598296",
"0.65866166",
"0.656888",
"0.65520436",
"0.6459978",
"0.6419767",
"0.64153636",
"0.64102745",
"0.637221",
"0.634435... | 0.766464 | 0 |
Set the items to appear in the pop up list. | def setItems(self, items):
self._nsObject.removeAllItems()
for item in items:
if isinstance(item, NSMenuItem):
menu = self._nsObject.menu()
menu.addItem_(item)
else:
self._nsObject.addItemWithTitle_(item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preset_items(self):\r\n\r\n raise NotImplementedError",
"def populate_list(self):\n counter = 0\n for group_name in self.parent.all_groups.keys():\n counter += 1\n exec('self.groupItem' + str(counter) + ' = QListWidgetItem()')\n eval('self.groupItem' + st... | [
"0.63553745",
"0.62045294",
"0.6187062",
"0.6155583",
"0.615099",
"0.614435",
"0.6051566",
"0.5928233",
"0.59158075",
"0.5898852",
"0.5891935",
"0.58433574",
"0.5743328",
"0.5739274",
"0.5722288",
"0.57069904",
"0.5697331",
"0.5622134",
"0.5607024",
"0.5606295",
"0.5558778",
... | 0.6685008 | 0 |
Apply the shrinkage operator to the singular values obtained from the SVD of X. The parameter tau is used as the scaling parameter to the shrink function. Returns the matrix obtained by computing U shrink(s) V where U are the left singular vectors of X V are the right singular vectors of X s are the singular values as ... | def svd_shrink(X, tau):
U,s,V = np.linalg.svd(X, full_matrices=False)
return np.dot(U, np.dot(np.diag(shrink(s, tau)), V)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shrink(X, tau):\n V = np.copy(X).reshape(X.size)\n for i in xrange(V.size):\n V[i] = math.copysign(max(abs(V[i]) - tau, 0), V[i])\n if V[i] == -0:\n V[i] = 0\n return V.reshape(X.shape)",
"def svt(X, tau):\n U, S, Vt = la.svd(X,full_matrices=False)\n Xs = np.dot(U * st... | [
"0.65727735",
"0.6489692",
"0.58918875",
"0.5725711",
"0.56523156",
"0.5544449",
"0.5430515",
"0.54155755",
"0.5347083",
"0.52910936",
"0.5272394",
"0.52572405",
"0.5206992",
"0.51743233",
"0.5170114",
"0.5169911",
"0.5154137",
"0.5126522",
"0.51069653",
"0.5103173",
"0.50936... | 0.83569604 | 0 |
Apply the shrinkage operator the the elements of X. Returns V such that V[i,j] = max(abs(X[i,j]) tau,0). | def shrink(X, tau):
V = np.copy(X).reshape(X.size)
for i in xrange(V.size):
V[i] = math.copysign(max(abs(V[i]) - tau, 0), V[i])
if V[i] == -0:
V[i] = 0
return V.reshape(X.shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shrink(x: np.ndarray, t: float) -> np.ndarray:\n return np.sign(x) * np.maximum(np.abs(x) - t, 0)",
"def svd_shrink(X, tau):\n U,s,V = np.linalg.svd(X, full_matrices=False)\n return np.dot(U, np.dot(np.diag(shrink(s, tau)), V))",
"def maxmarginal(self, target, out=None):\n return self.__opReduc... | [
"0.60550916",
"0.5972582",
"0.5969634",
"0.59686756",
"0.5896139",
"0.5784762",
"0.5737154",
"0.57011837",
"0.5677368",
"0.5558483",
"0.55497855",
"0.55328274",
"0.54991966",
"0.5492068",
"0.5474867",
"0.5435057",
"0.54302967",
"0.54115343",
"0.5405042",
"0.5398064",
"0.53841... | 0.74336606 | 0 |
Evaluate the Frobenius norm of X Returns sqrt(sum_i sum_j X[i,j] ^ 2) | def frobeniusNorm(X):
accum = 0
V = np.reshape(X,X.size)
for i in xrange(V.size):
accum += abs(V[i] ** 2)
return np.sqrt(accum) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normFro(X):\n return norm(X)",
"def squared_frobenius_norm(x):\n # http://mathworld.wolfram.com/FrobeniusNorm.html\n # The gradient of KL[p,q] is not defined when p==q. The culprit is\n # tf.norm, i.e., we cannot use the commented out code.\n # return tf.square(tf.norm(x, ord=\"fro\", axis=[-2... | [
"0.7487804",
"0.73903",
"0.7302113",
"0.7199961",
"0.7122286",
"0.70065945",
"0.6957892",
"0.6941357",
"0.69108367",
"0.67138755",
"0.6710018",
"0.6634665",
"0.65393853",
"0.6538264",
"0.6525256",
"0.6451336",
"0.64268863",
"0.6420409",
"0.63798773",
"0.63551456",
"0.6353465"... | 0.8461247 | 0 |
Evaluate the L1 norm of X Returns the max over the sum of each column of X | def L1Norm(X):
return max(np.sum(X,axis=0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def norm1(x):\n n, p = x.shape\n if p == 1 or n == 1:\n return np.sum(np.abs(x))\n else:\n return np.max(np.sum(np.abs(x), axis=0))",
"def norm1(X):\r\n # pass\r\n if X.shape[0]*X.shape[1] == 0:\r\n return 0\r\n return abs(X).sum()\r\n # return LA.norm(X, 1)\r",
"def n... | [
"0.75343716",
"0.73331046",
"0.7129455",
"0.7089392",
"0.67368776",
"0.6676168",
"0.6675522",
"0.6635472",
"0.6539204",
"0.65240026",
"0.6478929",
"0.6411275",
"0.6410474",
"0.640039",
"0.6349481",
"0.6343169",
"0.6333034",
"0.6278802",
"0.62678295",
"0.6257422",
"0.6254585",... | 0.8427064 | 0 |
Fail if there are no instances of theClass in theList with given params | def failUnlessContainsInstanceOf(self, theClass, params, theList, msg=None):
self.failIfNoMessage(theList)
failure=(msg or 'no %s instances in %s' % (theClass.__name__, repr(theList)))
for item in theList:
if issubclass(item.__class__, theClass):
if not params: return
for k, v in para... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def failIfContainsInstanceOf(self, theClass, params, theList, msg=None):\n\n self.failIfNoMessage(theList)\n\n for item in theList:\n if theClass==Message and isinstance(item,SelfDoesntMatchLocation):\n continue\n if theClass==Message and isinstance(item,MissingSelf):\n continue\n ... | [
"0.74682057",
"0.5826906",
"0.56888276",
"0.56885767",
"0.5665245",
"0.5642358",
"0.5449294",
"0.544411",
"0.5437559",
"0.5421472",
"0.53909975",
"0.537806",
"0.53212565",
"0.5292676",
"0.52794766",
"0.52672017",
"0.5241191",
"0.5227246",
"0.5198345",
"0.5182619",
"0.51759696... | 0.81702864 | 0 |
Fail if there are instances of theClass in theList with given params | def failIfContainsInstanceOf(self, theClass, params, theList, msg=None):
self.failIfNoMessage(theList)
for item in theList:
if theClass==Message and isinstance(item,SelfDoesntMatchLocation):
continue
if theClass==Message and isinstance(item,MissingSelf):
continue
if issubclas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def failUnlessContainsInstanceOf(self, theClass, params, theList, msg=None):\n self.failIfNoMessage(theList)\n\n failure=(msg or 'no %s instances in %s' % (theClass.__name__, repr(theList)))\n for item in theList:\n if issubclass(item.__class__, theClass):\n if not params: return\n for ... | [
"0.82829416",
"0.59194654",
"0.5835831",
"0.5819622",
"0.57178164",
"0.57031244",
"0.5564605",
"0.55354965",
"0.54351664",
"0.5432013",
"0.5417413",
"0.53615993",
"0.5354359",
"0.5329314",
"0.532291",
"0.5317593",
"0.52947307",
"0.52838063",
"0.5276541",
"0.5276059",
"0.52725... | 0.76709884 | 1 |
Extract description and exception from XML file The deal here is that each test case is an XML file which contains not only a possibly invalid RSS feed but also the description of the test, i.e. the exception that we would expect the RSS validator to raise (or not) when it validates the feed. The expected exception and | def getDescription(xmlfile):
stream = open(xmlfile)
xmldoc = stream.read()
stream.close()
search_results = desc_re.search(xmldoc)
if search_results:
description, cond, excName, plist = list(search_results.groups())
else:
search_results = validome_re.search(xmldoc)
if search_results:
plis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_xml_files_with_missing_info():\n\n # Test when k is missing from constant type reaction\n with pytest.raises(ValueError):\n xml_filename = \"tests/test_xml_files/k_const.xml\"\n parser = XMLParser(xml_filename)\n\n # Test when A is missing from Arrhenius type reaction\n with pyte... | [
"0.65230197",
"0.632303",
"0.59146357",
"0.5833376",
"0.5792351",
"0.5747134",
"0.5722811",
"0.5718106",
"0.571344",
"0.57032037",
"0.56968766",
"0.5693936",
"0.56484044",
"0.56384706",
"0.563128",
"0.5619023",
"0.5594202",
"0.55784297",
"0.55595875",
"0.5551427",
"0.5536601"... | 0.7382706 | 0 |
If cells become indistinguishable from each other, create "shadow cells" for estimation | def _create_shadow_cells(self, assignments):
prev_assignments = assignments[:, 1]
num_assigned = prev_assignments.shape[0]
prev_set = {i for i in range(len(self._prev_cells))}
assigned_set = set(prev_assignments)
diff_set = prev_set - assigned_set
new_assignments = np.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cell(x, y):\n try:\n if cells[y][x]['filled'] == 1:\n return # this has already been processed\n except IndexError:\n return\n cells[y][x]['filled'] = 1 # this cell is now filled\n\n nn = []\n for nx, ny in neighbours(x, y):\n try:\n if cells[ny][nx]['f... | [
"0.62244296",
"0.60063124",
"0.58079845",
"0.58031946",
"0.5771031",
"0.5768273",
"0.57047147",
"0.56749296",
"0.56458306",
"0.5631052",
"0.5592751",
"0.55902314",
"0.55531824",
"0.5511874",
"0.55042386",
"0.55030495",
"0.5474308",
"0.54628766",
"0.5454802",
"0.54457825",
"0.... | 0.69373477 | 0 |
Returns an empty statement object prepopulated with the correct action and the desired effect. | def _getEmptyStatement(self, effect):
statement = {
'Action': 'execute-api:Invoke',
'Effect': effect[:1].upper() + effect[1:].lower(),
'Resource': []
}
return statement | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_empty_statement(self, statement) -> None:\n pass",
"def build_statement(\n user: AbstractUser,\n verb: Verb,\n obj: Activity,\n context: Context,\n statement_id: Optional[uuid.UUID] = None,\n) -> Optional[Statement]:\n timestamp = timezone.now().isoformat()\n actor = _get_acto... | [
"0.61875755",
"0.5945088",
"0.5859864",
"0.57459265",
"0.5473468",
"0.54569197",
"0.54220784",
"0.53668594",
"0.5349767",
"0.5299655",
"0.5270274",
"0.52688295",
"0.5244726",
"0.5232134",
"0.5232134",
"0.515628",
"0.5091806",
"0.5071736",
"0.50493217",
"0.50363576",
"0.500546... | 0.7049263 | 0 |
This function loops over an array of objects containing a resourceArn and conditions statement and generates the array of statements for the policy. | def _getStatementForEffect(self, effect, methods):
statements = []
if len(methods) > 0:
statement = self._getEmptyStatement(effect)
for curMethod in methods:
if curMethod['conditions'] is None or len(curMethod['conditions']) == 0:
statement['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def role_policy_statements(role_name):\n policies = []\n role = iam.Role(role_name)\n \n role_policies = [p.policy_document['Statement'] for p in role.policies.all()]\n for p in role_policies:\n policies.extend(p)\n \n attached_policies = [p.default_version.document['Statement'] for p i... | [
"0.6252711",
"0.6066124",
"0.5917153",
"0.57497823",
"0.5632386",
"0.55001336",
"0.54665285",
"0.5361675",
"0.53571266",
"0.5334229",
"0.5300288",
"0.5228003",
"0.5077554",
"0.5066187",
"0.5017407",
"0.500456",
"0.4999616",
"0.49988353",
"0.4989274",
"0.4978008",
"0.49254087"... | 0.6140488 | 1 |
Adds a '' allow to the policy to authorize access to all methods of an API | def allowAllMethods(self):
self._addMethod("Allow", HttpVerb.ALL, "*", []) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowMethod(self, verb, resource):\n self._addMethod(\"Allow\", verb, resource, [])",
"def allowMethodWithConditions(self, verb, resource, conditions):\n self._addMethod(\"Allow\", verb, resource, conditions)",
"def __acl__(self):\n yield 'Allow', 'system.Everyone', 'none'\n yield secur... | [
"0.7216631",
"0.6613155",
"0.64923126",
"0.6455998",
"0.6446395",
"0.6407103",
"0.6355493",
"0.63049835",
"0.6148039",
"0.60514975",
"0.599496",
"0.598555",
"0.59486866",
"0.5947886",
"0.5905025",
"0.58962584",
"0.5878088",
"0.5875807",
"0.5761485",
"0.572492",
"0.57181853",
... | 0.6924644 | 1 |
Adds a '' allow to the policy to deny access to all methods of an API | def denyAllMethods(self):
self._addMethod("Deny", HttpVerb.ALL, "*", []) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowMethod(self, verb, resource):\n self._addMethod(\"Allow\", verb, resource, [])",
"def denyMethod(self, verb, resource):\n self._addMethod(\"Deny\", verb, resource, [])",
"def __acl__(self):\n yield 'Allow', 'system.Everyone', 'none'\n yield security.DENY_ALL",
"def allowAllMethod... | [
"0.71312696",
"0.7063275",
"0.67070395",
"0.6678199",
"0.6510527",
"0.64685214",
"0.63343185",
"0.62958235",
"0.62838495",
"0.6273429",
"0.6226591",
"0.6207807",
"0.61567885",
"0.6132413",
"0.61106557",
"0.60410565",
"0.5937659",
"0.59356344",
"0.5866076",
"0.5838073",
"0.581... | 0.71914613 | 0 |
Adds an API Gateway method (Http verb + Resource path) to the list of allowed methods for the policy | def allowMethod(self, verb, resource):
self._addMethod("Allow", verb, resource, []) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _addMethod(self, effect, verb, resource, conditions):\n if verb != '*' and not hasattr(HttpVerb, verb):\n raise NameError('Invalid HTTP verb ' + verb + '. Allowed verbs in HttpVerb class')\n resourcePattern = re.compile(self.pathRegex)\n if not resourcePattern.match(resource):\n... | [
"0.69362235",
"0.69090146",
"0.6906327",
"0.6576892",
"0.64880985",
"0.63947076",
"0.6353988",
"0.63424957",
"0.6294204",
"0.6255156",
"0.6255058",
"0.6137722",
"0.6134042",
"0.6133043",
"0.61138725",
"0.6084404",
"0.6029374",
"0.6018546",
"0.598662",
"0.59777766",
"0.5936681... | 0.70141923 | 0 |
Generates the policy document based on the internal lists of allowed and denied | def build(self):
if ((self.allowMethods is None or len(self.allowMethods) == 0) and
(self.denyMethods is None or len(self.denyMethods) == 0)):
raise NameError("No statements defined for the policy")
policy = {
'principalId': self.principalId,
'policyD... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_policies(self, cr, uid, context=None):\n return [('optional', _('Optional')),\n ('always', _('Always')),\n ('never', _('Never'))]",
"def _get_fake_policy_document():\n return {\n \"Version\": \"2000-01-01\",\n \"Statement\": [... | [
"0.6304702",
"0.58589256",
"0.5853127",
"0.58469373",
"0.5558938",
"0.5537385",
"0.5523633",
"0.55235267",
"0.55221826",
"0.54749024",
"0.54417336",
"0.54417336",
"0.54417336",
"0.5441389",
"0.5411109",
"0.5367578",
"0.535472",
"0.5340589",
"0.53121686",
"0.53085357",
"0.5283... | 0.6665991 | 0 |
Load sentences. A line must contain at least a word and its tag. Sentences are separated by empty lines. | def load_sentences(path):
sentences = []
sentence = []
num = 0
with codecs.open(path, 'r', 'utf8') as fread:
# n_lines = len(fread)
print("Read from {:s}".format(path))
# pbar = progressbar.ProgressBar(max_value=n_lines)
for line_idx, line in enumerate(fread):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_sentences(path, lower, zeros=True):\n sentences = []\n sentence = []\n for line in codecs.open(path, 'r', 'utf8'):\n line = zero_digits(line.rstrip()) if zeros else line.rstrip()\n if not line:\n if len(sentence) > 0:\n if 'DOCSTART' not in sentence[0][0]:\... | [
"0.73260915",
"0.72926795",
"0.6630065",
"0.65276825",
"0.6465343",
"0.6369665",
"0.63562053",
"0.63426006",
"0.6305672",
"0.6272708",
"0.6236807",
"0.6198804",
"0.61588985",
"0.6153663",
"0.608253",
"0.6081131",
"0.60524327",
"0.6020787",
"0.6013786",
"0.60017645",
"0.599008... | 0.74319476 | 0 |
Check and update sentences tagging scheme to IOB2. Only IOB1 and IOB2 schemes are accepted. | def update_tag_scheme(sentences, tag_scheme):
for i, s in enumerate(sentences):
tags = [w[-1] for w in s]
# Check that tags are given in the IOB format
if not NER_utils.iob2(tags):
s_str = '\n'.join(' '.join(w) for w in s)
raise Exception('Sentences should be given in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tag_scheme(sentences, tag_scheme):\n for i, s in enumerate(sentences):\n tags = [w[-1] for w in s]\n # Check that tags are given in the IOB format\n if not iob2(tags):\n s_str = '\\n'.join(' '.join(w) for w in s)\n raise Exception('Sentences should be given ... | [
"0.75835204",
"0.6604394",
"0.6375619",
"0.63179696",
"0.5746531",
"0.55641425",
"0.5533739",
"0.5410123",
"0.53316265",
"0.5255677",
"0.5166876",
"0.5161488",
"0.5138688",
"0.5126411",
"0.5123757",
"0.5066761",
"0.50608045",
"0.5048021",
"0.50355095",
"0.502674",
"0.5022408"... | 0.7471344 | 1 |
Helper function that provides a simple "Try Again" page. | def tryAgain(request, msg=None, url=None, buttonText=None,
title=None):
if msg is None:
msg = "Please try again"
if url is None:
url = "javascript:history.back()"
if buttonText is None:
buttonText = "Try Again"
if title is None:
title = "Try Again"
contex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ask_again(self, wrong_info):\n return input(f\"Wrong {wrong_info}, please try again: \")",
"def on_fail(utterance):\n\n self.log.info(\"Utterance: {}\".format(utterance))\n\n user_response = self.ask_yesno('try.again')\n\n return 'try.again' if user_response is None el... | [
"0.6091591",
"0.60179615",
"0.60155046",
"0.5943941",
"0.59362453",
"0.58752775",
"0.5838683",
"0.5830095",
"0.58006173",
"0.5692293",
"0.5689304",
"0.5579053",
"0.5545659",
"0.55337924",
"0.5531429",
"0.5526757",
"0.5498794",
"0.54846203",
"0.5453377",
"0.54490054",
"0.53779... | 0.75363 | 0 |
Given a team pass_code, return the school name. | def schoolNameFromPassCode(pass_code):
try:
return Team.objects.get(pass_code=pass_code).organization.name
except Team.DoesNotExist:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getschool(s,refconvdf,schooltaglist): \r\n taglist=gettotaltags(s,refconvdf) \r\n schoolname=list(set(schooltaglist.name.values).intersection(taglist)) \r\n if not schoolname:#check if empty \r\n return 'None'\r\n else:\r\n return schoolname\r\n ... | [
"0.602459",
"0.56425226",
"0.56172824",
"0.5562424",
"0.5503714",
"0.549422",
"0.54849327",
"0.5414529",
"0.5342843",
"0.5312967",
"0.52557176",
"0.5190712",
"0.5178283",
"0.51297957",
"0.5119001",
"0.51174057",
"0.5111106",
"0.5100947",
"0.506486",
"0.5032186",
"0.5019904",
... | 0.8858064 | 0 |
Handle an add/user GET request (URL coming from another page) | def get(self, request):
self.context["form"] = AddUserForm()
return render(request, "dbkeeper/add.html", self.context) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users_page(request):",
"def addUser():\n if request.method == \"POST\":\n (result, status) = parse_user_data(request)\n return jsonify(result), status # HTTP Status Created [201]\n if request.method == \"DELETE\":\n (result, status) = delete_user_data(request)\n return jsoni... | [
"0.6340799",
"0.60597724",
"0.59811425",
"0.59551364",
"0.59493613",
"0.5945991",
"0.5883485",
"0.58578",
"0.5839479",
"0.5800304",
"0.57811564",
"0.5772578",
"0.5767761",
"0.576326",
"0.5717431",
"0.5711894",
"0.5692957",
"0.5684099",
"0.56637645",
"0.56426305",
"0.5640269",... | 0.6323659 | 1 |
Handle an add/user POST request (form submit or resubmit) | def post(self, request):
self.context["form"] = AddUserForm(request.POST)
form = self.context["form"]
if form.is_valid():
# Reject input if user already exists
username = form.cleaned_data["username"]
if User.objects.filter(username=username).count() > 0:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addUser():\n if request.method == \"POST\":\n (result, status) = parse_user_data(request)\n return jsonify(result), status # HTTP Status Created [201]\n if request.method == \"DELETE\":\n (result, status) = delete_user_data(request)\n return jsonify(result), status # HTTP Stat... | [
"0.7210867",
"0.71598583",
"0.69765174",
"0.6758249",
"0.67008495",
"0.66891205",
"0.66871625",
"0.6586135",
"0.6584424",
"0.65641356",
"0.6499921",
"0.64976716",
"0.6490107",
"0.64696383",
"0.6460626",
"0.6412279",
"0.63844705",
"0.63715136",
"0.63650995",
"0.6359513",
"0.63... | 0.7240148 | 0 |
Display the Add form with the AddLaunchParams fields | def get(self, request):
try:
launchParams = Setting.getLaunchParams()
d = {}
for tri,color in ((0,"r"), (1,"g"), (2,"b")):
for vert in (0, 1, 2):
v = color + "v{}".format(vert)
name,lat,lon,angle = launchParams[tri][vert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_add_actor(self):\n\t\tformulario = view_form_actor.Form(self)\n\t\tformulario.exec_()\n\t\tself.load_data()",
"def get_project_add_form():\n\n return render_template(\"project_add.html\")",
"def get_form(self):\n # setup request layer\n self.request = TestRequest()\n # get add ... | [
"0.63401496",
"0.62683624",
"0.6101274",
"0.60733443",
"0.60659564",
"0.59358907",
"0.5907794",
"0.58550936",
"0.5840284",
"0.5796411",
"0.5787442",
"0.575894",
"0.5718366",
"0.5710715",
"0.5703746",
"0.57016623",
"0.56800807",
"0.56598663",
"0.5647814",
"0.56415087",
"0.5619... | 0.699335 | 0 |
Display the Add form with the AddSecureParams fields | def get(self, request):
form = AddSecureParamsForm()
#form.setFixedFields()
try:
secureParams = Setting.getSecureParams()
form.setFields(len(secureParams["sets"]))
except:
self.context["data"] = { "numRows": 0 }
self.context["form"] = form
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_add_student_form():\n\n return render_template(\"add_student_form.html\")",
"def get_student_add_form():\n\n return render_template(\"student_add.html\")",
"def display_form():\n\n return render_template('add_new_student.html')",
"def get(self, request):\n self.context[\"form\"] = Ad... | [
"0.6632061",
"0.64132214",
"0.639975",
"0.6244252",
"0.62157214",
"0.612753",
"0.6044558",
"0.60000664",
"0.5979012",
"0.59370697",
"0.5908866",
"0.58461404",
"0.5841678",
"0.5826378",
"0.58164346",
"0.57106",
"0.57002246",
"0.56978536",
"0.5674832",
"0.56701356",
"0.5669822"... | 0.772944 | 0 |
Display the add_return_params form. If RETURN_PARAMS already exists in the database, the form is populated with the current values. | def get(self, request):
# self.context["form"] = AddReturnParamsForm()
# return render(request, "dbkeeper/add_return_params.html", self.context)
try:
returnParams = Setting.getReturnParams()
d = {}
for station in range(0, 6):
fields = ["st{}{}"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_window(self):\n frame = tk.Frame(master=self.param_window)\n frame.grid(padx=10, pady=20, columnspan=2)\n tk.Label(master=frame, text=\"Enter simulation parameters\").pack()\n\n self.status_text = tk.StringVar()\n self.status_text.set(\"Status message\")\n \n ... | [
"0.5159244",
"0.5159088",
"0.51492167",
"0.5143759",
"0.5083419",
"0.502979",
"0.5025307",
"0.5007266",
"0.50014144",
"0.49637106",
"0.49195036",
"0.48437077",
"0.481711",
"0.4801792",
"0.47871172",
"0.4770667",
"0.47538763",
"0.47397462",
"0.47369665",
"0.46932358",
"0.46872... | 0.7080442 | 0 |
Display the save_settings page. | def SaveSettings(request):
return render(request, "dbkeeper/save_settings.html") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _onSettings(self, event):\n dialog = sc.SettingsDialog(self)\n if dialog.ShowModal() == wx.ID_OK:\n dialog.saveSettings()\n dialog.Destroy()",
"def save(self):\n return self.client._perform_empty(\"PUT\", \"/admin/general-settings\", body = self.settings)",
"def save_... | [
"0.6948361",
"0.6705164",
"0.6664211",
"0.66351837",
"0.6594391",
"0.6520603",
"0.64986426",
"0.64945",
"0.6485608",
"0.64128584",
"0.63740045",
"0.63704425",
"0.63322747",
"0.6324476",
"0.6320958",
"0.63104993",
"0.6297963",
"0.6241315",
"0.6220317",
"0.61829704",
"0.6119481... | 0.7923202 | 0 |
This fonction uses the mean to calculate the std of all the moves for a dtype (att) and an axis of that dtype (s) | def calculate_std(self, _moves, s, att):
# std = 0
# for move in _moves:
# std += move.__dict__[att].__dict__[s] ** 2
# std -= self.mean_instance.__dict__[att].__dict__[s] ** 2
# std /= len(_moves)
# std = np.sqrt(std)
move_array = []
for move in _move... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _loss_std_mean(self, iterations):\n\n loss_array = np.array(self._loss_list[-iterations:])\n return loss_array.mean(), loss_array.std()",
"def unstandardize(da: xr.DataArray, mean: xr.DataArray, std: xr.DataArray):\n return (std * da) + mean",
"def mean_std_calc(dataloader):\n mean = 0\... | [
"0.6982349",
"0.6848713",
"0.68165255",
"0.67980915",
"0.66196024",
"0.66095495",
"0.65971655",
"0.6595731",
"0.6563074",
"0.65236825",
"0.64669746",
"0.644305",
"0.64084727",
"0.63442326",
"0.63397527",
"0.63314974",
"0.6327874",
"0.63175726",
"0.63169307",
"0.6295772",
"0.6... | 0.69120014 | 1 |
Shouldn't be able to update a nonexistent card. | def test_update_non_existent(cards_db):
i = 123 # any number will do, db is empty
with pytest.raises(InvalidCardId):
cards_db.update_card(i, Card(summary="bar", owner="not me")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_owner(cards_db):\n i = cards_db.add_card(Card(\"foo\", owner=\"me\"))\n cards_db.update_card(i, Card(owner=\"not me\", state=None))\n\n mod = cards_db.get_card(i)\n assert mod == Card(\"foo\", owner=\"not me\")",
"def test_update_both(cards_db):\n i = cards_db.add_card(Card(\"foo\"... | [
"0.72570544",
"0.6971975",
"0.64662427",
"0.63850427",
"0.6337639",
"0.6297447",
"0.6253069",
"0.6226289",
"0.6153988",
"0.6153988",
"0.613771",
"0.6100459",
"0.60533106",
"0.60427165",
"0.60209745",
"0.60053265",
"0.59934855",
"0.5950459",
"0.59163815",
"0.5905842",
"0.59028... | 0.78111476 | 0 |
Create a new rule for the project's channel tags. | def add_tag_rule(self, name: str, platform: ButlerPlatformType):
self.tag_rules[name] = platform | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_rule(self: object,\n body: dict,\n cs_username: str = None # pylint: disable=W0613 # cs_username is deprecated\n ) -> dict:\n # [POST] https://assets.falcon.crowdstrike.com/support/api/swagger.html#/custom-ioa/create-rule\n return ... | [
"0.5678899",
"0.5306978",
"0.51936877",
"0.51825786",
"0.5098872",
"0.49936134",
"0.49537468",
"0.49180532",
"0.49175808",
"0.49095017",
"0.48956937",
"0.4893867",
"0.4890588",
"0.48864338",
"0.48617128",
"0.48356813",
"0.48139465",
"0.48046735",
"0.4803962",
"0.47751865",
"0... | 0.5360202 | 1 |
Plot loss and val loss. | def plot_loss():
df = pd.read_csv('data/loss.csv', encoding='utf-8')
loss = df['loss'].values
val_loss = df['val_loss'].values
x = [i for i in range(1, len(loss) + 1)]
plt.plot(x, loss, label='Train loss')
plt.plot(x, val_loss, label='Val loss')
plt.xlabel('Epochs')
plt.ylabel('Contras... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss_plot(train_loss, val_loss, filename):\n\tplt.plot(train_loss)\n\tplt.plot(val_loss)\n\tplt.ylabel('Loss')\n\tplt.xlabel('Epochs')\n\tplt.legend(['Train', 'Val'], loc='upper right')\n\tplt.savefig(filename)\n\tplt.close()",
"def plot_loss(stats):\r\n plt.plot(stats['train_loss_ind'], stats['train_loss... | [
"0.82998466",
"0.82797426",
"0.80859876",
"0.7981037",
"0.7693412",
"0.76680315",
"0.7617962",
"0.7617048",
"0.75987184",
"0.75846845",
"0.7553299",
"0.7551096",
"0.7526244",
"0.74546194",
"0.73826283",
"0.73073465",
"0.72436315",
"0.72190005",
"0.71932274",
"0.71717453",
"0.... | 0.84513193 | 0 |
Plot reduced dimension result wiht tSNE. Arguments | def plot_reduce_dimension(model):
outputs = []
n = 8
paths = 'data/grimace'
dirs = np.random.choice(os.listdir(paths), n)
for d in dirs:
p = paths + '/' + str(d)
files = os.listdir(p)
if files:
for f in files:
img = os.path.join(p, f)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_tsne_reduction(x_values: np.ndarray, y_values: np.ndarray) -> alt.Chart:\n tsne = manifold.TSNE()\n x_transformed = tsne.fit_transform(x_values)\n\n return plot_dimensionality_reduction(x_transformed, y_values)",
"def tsne_plot(features: {}, labels: {}):\n # T-SNE computation\n tsne = TSN... | [
"0.721223",
"0.69622654",
"0.6888345",
"0.6780966",
"0.6607102",
"0.6492365",
"0.64915717",
"0.6449874",
"0.64182204",
"0.6315417",
"0.6142444",
"0.61178076",
"0.6068446",
"0.6066621",
"0.6031151",
"0.60284644",
"0.60229105",
"0.59930944",
"0.5989",
"0.5987734",
"0.59864",
... | 0.7649347 | 0 |
Taking password length from user | def pwd_len():
while True:
password_length = input('How much length for password u want ? Minimum length is 6 and Maximum length is 25 : ')
try:
password_length = int(password_length)
if 6 <= password_length <= 25:
break
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password_length(self):\n return self.__password_length",
"def passWord(pwd):\n pwdLen = len(pwd)\n if pwdLen < 4:\n raise Exception(\"The password is too short.\")\n if pwdLen > 8:\n raise Exception(\"tHE password is too long\")\n else:\n print('the length of the passw... | [
"0.7629029",
"0.7612529",
"0.7593266",
"0.75244534",
"0.738702",
"0.7358815",
"0.73539585",
"0.73169446",
"0.71829206",
"0.7180958",
"0.71143186",
"0.71080285",
"0.7094232",
"0.7092153",
"0.708661",
"0.7074669",
"0.70689845",
"0.7059098",
"0.7052881",
"0.7052881",
"0.7003661"... | 0.7817949 | 0 |
How much symbols user wants | def symbol_len(password_length):
while True:
symb_length = input('How much symbols you want in password? At least 1 : ')
try:
symb_length = int(symb_length)
if 1 <= symb_length <= (password_length - 2):
break
else:
print('{}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def len_special(self):\n return sum(self.count(term_chars) * len(term_chars) for term_chars in termcolor.values())",
"def part_one():\n return symbol_counts[\"~\"] + symbol_counts[\"|\"]",
"def embedcount(line):\r\n\r\n x_temp = line.count(BOX_CHAR['lu'])\r\n return self.default... | [
"0.6444634",
"0.6134199",
"0.6113141",
"0.60651857",
"0.5984401",
"0.59586775",
"0.59318316",
"0.59293085",
"0.59119457",
"0.584206",
"0.584206",
"0.58049524",
"0.5760604",
"0.5757853",
"0.57293653",
"0.5727135",
"0.5700855",
"0.5645191",
"0.5637213",
"0.56198454",
"0.5615442... | 0.63217 | 1 |
Typical use is to specify an INI file, which contains all the metadata relevant to a set of scans. This function is called with | def scan_metadata(inifile=None, **kwargs):
#frame = inspect.currentframe() # see https://stackoverflow.com/a/582206 and
#args = inspect.getargvalues(frame)[3] # https://docs.python.org/3/library/inspect.html#inspect.getargvalues
BMMuser, dcm = user_ns['BMMuser'], user_ns['dcm']
parameters = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_metadata(metadata_file, config):\n metadata_list = []\n import sys\n if metadata_file in sys.argv:\n return config\n try:\n with open(metadata_file, \"r\") as fh:\n reader = csv.DictReader(fh.readlines())\n metadata_list = [row for row in reader]\n ru... | [
"0.62581795",
"0.6172191",
"0.5904631",
"0.5810348",
"0.5731689",
"0.5710172",
"0.5697868",
"0.5671793",
"0.5557136",
"0.55527836",
"0.5547069",
"0.5531849",
"0.5523526",
"0.5495392",
"0.54795927",
"0.5473922",
"0.5470717",
"0.54607505",
"0.54423887",
"0.54402304",
"0.543897"... | 0.6766333 | 0 |
Tests for when the population is implemented with errors | def test_make_pop_exception(self, patch_log, patch_random):
patch_random.side_effect = ValueError
# Population is initialised with no households
pop_params = {"population_size": 10, "cell_number": 1,
"microcell_number": 1}
ToyPopulationFactory.make_pop(pop_params)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_errors(self) -> None:",
"def has_errors(self) -> bool:",
"def check_set_errors(self):\n raise NotImplementedError(\"Implement it in a subclass.\")",
"def test_raises(self):\n no_replicates = 25\n try:\n replicate(experiment3, no_replicates)\n except RuntimeErr... | [
"0.6724634",
"0.6614121",
"0.6571839",
"0.6506624",
"0.6498713",
"0.6492715",
"0.6352794",
"0.6229535",
"0.6203304",
"0.6190145",
"0.61648875",
"0.6164363",
"0.6125414",
"0.6124468",
"0.6115176",
"0.60903215",
"0.6060993",
"0.6059786",
"0.60476184",
"0.6033371",
"0.6023753",
... | 0.6928545 | 0 |
Tests when households are implemented. | def test_if_households(self, pop_size, cell_number, microcell_number,
household_number):
# Initialises population with households
pop_params = {"population_size": pop_size, "cell_number": cell_number,
"microcell_number": microcell_number,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_households_in_admin_unit(self):",
"def test_createHousehold_single(self):\n h = self.z.createHousehold(\"testHousehold\")\n self.assertTrue(self.z.getHousehold(\"testHousehold\") is not None, \"No household came back from the database.\")\n self.assertTrue(self.z.getHousehold(\"test... | [
"0.6838143",
"0.6817663",
"0.6814737",
"0.655817",
"0.6156855",
"0.6130907",
"0.5943895",
"0.5855799",
"0.5852164",
"0.5847315",
"0.5841273",
"0.5840119",
"0.5839334",
"0.5837827",
"0.5781486",
"0.5735657",
"0.5691197",
"0.5643968",
"0.5629447",
"0.5597476",
"0.5569006",
"0... | 0.7057865 | 0 |
The Jitsi name should be the meeting ID stripped of all dashes. | def test_models_meetings_jitsi_name(self):
meeting = MeetingFactory(id="2a76d5ee-8310-4a28-8e7f-c34dbdc4dd8a")
self.assertEqual(meeting.jitsi_name, "2a76d5ee83104a288e7fc34dbdc4dd8a") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_models_meetings_name_prefix(self):\n room = MeetingFactory(id=\"f629e68e-e256-44fe-8ba6-a7e0849de00b\")\n self.assertEqual(room.jitsi_name, \"123f629e68ee25644fe8ba6a7e0849de00b\")",
"def format_jira(jid: str) -> str:\n jid = jid.lower().strip()\n jid = jid.split('_')[0]\n j = \"\... | [
"0.6866796",
"0.6679597",
"0.62532425",
"0.61189544",
"0.60640043",
"0.5963949",
"0.58309263",
"0.5824851",
"0.58022356",
"0.5795273",
"0.5780392",
"0.5699202",
"0.56982464",
"0.5674717",
"0.56611484",
"0.56552875",
"0.5650024",
"0.5633229",
"0.55841947",
"0.55732095",
"0.556... | 0.734015 | 0 |
normalize freqs to have sum of squares 1 modifies in place | def normalize(freqs):
square_sum = 0
for _,v in freqs.items():
square_sum += v**2
rss = math.sqrt(square_sum)
for k in freqs:
freqs[k] /= rss
return freqs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def freqnorm(freq):\n t = 0.0\n for i in freq:\n t += freq[i]\n for i in freq:\n freq[i] /= t\n return freq",
"def _normalize_counts(counts, val=1):\n n = sum(counts.values())\n frequencies = {}\n for r in list(counts.keys()):\n frequencies[r] = val * float(counts[r]) / ... | [
"0.7933617",
"0.66565824",
"0.65418106",
"0.6425697",
"0.6359233",
"0.633326",
"0.6305108",
"0.6268649",
"0.6249235",
"0.6235215",
"0.62128705",
"0.6194164",
"0.6144104",
"0.61389965",
"0.6133477",
"0.6125413",
"0.61036325",
"0.60963297",
"0.6072995",
"0.6057717",
"0.60538304... | 0.8390002 | 0 |
uses article Id, returns a list of ids (descending order of relevance) of indices of top sentence in the article, using pagerank algorithm | def textrank(artId):
divisor = 4
min_num, max_num = 3, 10
art = id2news[artId]
if len(art.sentences) <= 3:
return art.body_text #no textrank if no text to rank...
cosine_matrix = np.asarray([[lemma_similarity(sent_1, sent_2) for sent_1 in art.sentences] for sent_2 in art.sentences])
g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_article_indices(self, article_id):\n start, end, _ = self.article_features[article_id]\n return list(range(start, end + 1))",
"def top_sentences(query, sentences, idf, n):\n ll=[]\n for s in sentences:\n st=sentences[s]\n st=[word.lower() for word in st]\n found_w... | [
"0.64989346",
"0.5971395",
"0.57531977",
"0.5531953",
"0.544047",
"0.53984046",
"0.53607553",
"0.53604835",
"0.5280121",
"0.52442205",
"0.51826274",
"0.51738113",
"0.51463974",
"0.5126516",
"0.5115128",
"0.5109",
"0.51089376",
"0.51077867",
"0.5099182",
"0.5094853",
"0.508908... | 0.64167094 | 1 |
Inserts Qt Creator markers around the class brief paragraph. | def insert_class_markers(soup):
# look for class name in a div like <div class="title">Namespace::MyClass Class Reference</div>
title_div = soup.find("div", "title")
if not title_div:
raise ValueError("The following div was not found : <div class='title'>...<div>")
# titlediv.get_text()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def brief(self):\n result = \"({0.mode}) {0.name}\".format(self)\n if self.content_hash_before is None:\n result += \" (new)\"\n return result",
"def help(cls):\n return textwrap.dedent(cls.__doc__).strip()",
"def _create_readme(self, name, summary, description):\n ... | [
"0.62908995",
"0.58696854",
"0.5801665",
"0.577401",
"0.5764486",
"0.57053465",
"0.57039404",
"0.56879723",
"0.5668434",
"0.5647913",
"0.56420195",
"0.5619122",
"0.5604377",
"0.55983883",
"0.55982256",
"0.5554882",
"0.5552204",
"0.55472237",
"0.55414754",
"0.55331683",
"0.550... | 0.7318693 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.