repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pymupdf/PyMuPDF | examples/PDFLinkMaint.py | PDFdisplay.Rect_to_wxRect | def Rect_to_wxRect(self, fr):
""" Return a zoomed wx.Rect for given fitz.Rect."""
r = (fr * self.zoom).irect # zoomed IRect
return wx.Rect(r.x0, r.y0, r.width, r.height) | python | def Rect_to_wxRect(self, fr):
""" Return a zoomed wx.Rect for given fitz.Rect."""
r = (fr * self.zoom).irect # zoomed IRect
return wx.Rect(r.x0, r.y0, r.width, r.height) | [
"def",
"Rect_to_wxRect",
"(",
"self",
",",
"fr",
")",
":",
"r",
"=",
"(",
"fr",
"*",
"self",
".",
"zoom",
")",
".",
"irect",
"return",
"wx",
".",
"Rect",
"(",
"r",
".",
"x0",
",",
"r",
".",
"y0",
",",
"r",
".",
"width",
",",
"r",
".",
"heig... | Return a zoomed wx.Rect for given fitz.Rect. | [
"Return",
"a",
"zoomed",
"wx",
".",
"Rect",
"for",
"given",
"fitz",
".",
"Rect",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/examples/PDFLinkMaint.py#L903-L906 | train |
pymupdf/PyMuPDF | examples/PDFLinkMaint.py | PDFdisplay.wxRect_to_Rect | def wxRect_to_Rect(self, wr):
""" Return a shrunk fitz.Rect for given wx.Rect."""
r = fitz.Rect(wr.x, wr.y, wr.x + wr.width, wr.y + wr.height)
return r * self.shrink | python | def wxRect_to_Rect(self, wr):
""" Return a shrunk fitz.Rect for given wx.Rect."""
r = fitz.Rect(wr.x, wr.y, wr.x + wr.width, wr.y + wr.height)
return r * self.shrink | [
"def",
"wxRect_to_Rect",
"(",
"self",
",",
"wr",
")",
":",
"r",
"=",
"fitz",
".",
"Rect",
"(",
"wr",
".",
"x",
",",
"wr",
".",
"y",
",",
"wr",
".",
"x",
"+",
"wr",
".",
"width",
",",
"wr",
".",
"y",
"+",
"wr",
".",
"height",
")",
"return",
... | Return a shrunk fitz.Rect for given wx.Rect. | [
"Return",
"a",
"shrunk",
"fitz",
".",
"Rect",
"for",
"given",
"wx",
".",
"Rect",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/examples/PDFLinkMaint.py#L908-L911 | train |
pymupdf/PyMuPDF | examples/PDFLinkMaint.py | PDFdisplay.is_in_free_area | def is_in_free_area(self, nr, ok = -1):
""" Determine if rect covers a free area inside the bitmap."""
for i, r in enumerate(self.link_rects):
if r.Intersects(nr) and i != ok:
return False
bmrect = wx.Rect(0,0,dlg.bitmap.Size[0],dlg.bitmap.Size[1])
return bmre... | python | def is_in_free_area(self, nr, ok = -1):
""" Determine if rect covers a free area inside the bitmap."""
for i, r in enumerate(self.link_rects):
if r.Intersects(nr) and i != ok:
return False
bmrect = wx.Rect(0,0,dlg.bitmap.Size[0],dlg.bitmap.Size[1])
return bmre... | [
"def",
"is_in_free_area",
"(",
"self",
",",
"nr",
",",
"ok",
"=",
"-",
"1",
")",
":",
"for",
"i",
",",
"r",
"in",
"enumerate",
"(",
"self",
".",
"link_rects",
")",
":",
"if",
"r",
".",
"Intersects",
"(",
"nr",
")",
"and",
"i",
"!=",
"ok",
":",
... | Determine if rect covers a free area inside the bitmap. | [
"Determine",
"if",
"rect",
"covers",
"a",
"free",
"area",
"inside",
"the",
"bitmap",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/examples/PDFLinkMaint.py#L913-L919 | train |
pymupdf/PyMuPDF | examples/PDFLinkMaint.py | PDFdisplay.get_linkrect_idx | def get_linkrect_idx(self, pos):
""" Determine if cursor is inside one of the link hot spots."""
for i, r in enumerate(self.link_rects):
if r.Contains(pos):
return i
return -1 | python | def get_linkrect_idx(self, pos):
""" Determine if cursor is inside one of the link hot spots."""
for i, r in enumerate(self.link_rects):
if r.Contains(pos):
return i
return -1 | [
"def",
"get_linkrect_idx",
"(",
"self",
",",
"pos",
")",
":",
"for",
"i",
",",
"r",
"in",
"enumerate",
"(",
"self",
".",
"link_rects",
")",
":",
"if",
"r",
".",
"Contains",
"(",
"pos",
")",
":",
"return",
"i",
"return",
"-",
"1"
] | Determine if cursor is inside one of the link hot spots. | [
"Determine",
"if",
"cursor",
"is",
"inside",
"one",
"of",
"the",
"link",
"hot",
"spots",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/examples/PDFLinkMaint.py#L921-L926 | train |
pymupdf/PyMuPDF | examples/PDFLinkMaint.py | PDFdisplay.get_bottomrect_idx | def get_bottomrect_idx(self, pos):
""" Determine if cursor is on bottom right corner of a hot spot."""
for i, r in enumerate(self.link_bottom_rects):
if r.Contains(pos):
return i
return -1 | python | def get_bottomrect_idx(self, pos):
""" Determine if cursor is on bottom right corner of a hot spot."""
for i, r in enumerate(self.link_bottom_rects):
if r.Contains(pos):
return i
return -1 | [
"def",
"get_bottomrect_idx",
"(",
"self",
",",
"pos",
")",
":",
"for",
"i",
",",
"r",
"in",
"enumerate",
"(",
"self",
".",
"link_bottom_rects",
")",
":",
"if",
"r",
".",
"Contains",
"(",
"pos",
")",
":",
"return",
"i",
"return",
"-",
"1"
] | Determine if cursor is on bottom right corner of a hot spot. | [
"Determine",
"if",
"cursor",
"is",
"on",
"bottom",
"right",
"corner",
"of",
"a",
"hot",
"spot",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/examples/PDFLinkMaint.py#L928-L933 | train |
pymupdf/PyMuPDF | fitz/utils.py | getTextWords | def getTextWords(page):
"""Return the text words as a list with the bbox for each word.
"""
CheckParent(page)
dl = page.getDisplayList()
tp = dl.getTextPage()
l = tp._extractTextWords_AsList()
del dl
del tp
return l | python | def getTextWords(page):
"""Return the text words as a list with the bbox for each word.
"""
CheckParent(page)
dl = page.getDisplayList()
tp = dl.getTextPage()
l = tp._extractTextWords_AsList()
del dl
del tp
return l | [
"def",
"getTextWords",
"(",
"page",
")",
":",
"CheckParent",
"(",
"page",
")",
"dl",
"=",
"page",
".",
"getDisplayList",
"(",
")",
"tp",
"=",
"dl",
".",
"getTextPage",
"(",
")",
"l",
"=",
"tp",
".",
"_extractTextWords_AsList",
"(",
")",
"del",
"dl",
... | Return the text words as a list with the bbox for each word. | [
"Return",
"the",
"text",
"words",
"as",
"a",
"list",
"with",
"the",
"bbox",
"for",
"each",
"word",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L349-L358 | train |
pymupdf/PyMuPDF | fitz/utils.py | getText | def getText(page, output = "text"):
""" Extract a document page's text.
Args:
output: (str) text, html, dict, json, rawdict, xhtml or xml.
Returns:
the output of TextPage methods extractText, extractHTML, extractDICT, extractJSON, extractRAWDICT, extractXHTML or etractXML respectively. Def... | python | def getText(page, output = "text"):
""" Extract a document page's text.
Args:
output: (str) text, html, dict, json, rawdict, xhtml or xml.
Returns:
the output of TextPage methods extractText, extractHTML, extractDICT, extractJSON, extractRAWDICT, extractXHTML or etractXML respectively. Def... | [
"def",
"getText",
"(",
"page",
",",
"output",
"=",
"\"text\"",
")",
":",
"CheckParent",
"(",
"page",
")",
"dl",
"=",
"page",
".",
"getDisplayList",
"(",
")",
"formats",
"=",
"(",
"\"text\"",
",",
"\"html\"",
",",
"\"json\"",
",",
"\"xml\"",
",",
"\"xht... | Extract a document page's text.
Args:
output: (str) text, html, dict, json, rawdict, xhtml or xml.
Returns:
the output of TextPage methods extractText, extractHTML, extractDICT, extractJSON, extractRAWDICT, extractXHTML or etractXML respectively. Default and misspelling choice is "text". | [
"Extract",
"a",
"document",
"page",
"s",
"text",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L360-L386 | train |
pymupdf/PyMuPDF | fitz/utils.py | getPagePixmap | def getPagePixmap(doc, pno, matrix = None, colorspace = csRGB,
clip = None, alpha = True):
"""Create pixmap of document page by page number.
Notes:
Convenience function calling page.getPixmap.
Args:
pno: (int) page number
matrix: Matrix for transformation (default:... | python | def getPagePixmap(doc, pno, matrix = None, colorspace = csRGB,
clip = None, alpha = True):
"""Create pixmap of document page by page number.
Notes:
Convenience function calling page.getPixmap.
Args:
pno: (int) page number
matrix: Matrix for transformation (default:... | [
"def",
"getPagePixmap",
"(",
"doc",
",",
"pno",
",",
"matrix",
"=",
"None",
",",
"colorspace",
"=",
"csRGB",
",",
"clip",
"=",
"None",
",",
"alpha",
"=",
"True",
")",
":",
"return",
"doc",
"[",
"pno",
"]",
".",
"getPixmap",
"(",
"matrix",
"=",
"mat... | Create pixmap of document page by page number.
Notes:
Convenience function calling page.getPixmap.
Args:
pno: (int) page number
matrix: Matrix for transformation (default: Identity).
colorspace: (str/Colorspace) rgb, rgb, gray - case ignored, default csRGB.
clip: (irect-... | [
"Create",
"pixmap",
"of",
"document",
"page",
"by",
"page",
"number",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L438-L452 | train |
pymupdf/PyMuPDF | fitz/utils.py | getToC | def getToC(doc, simple = True):
"""Create a table of contents.
Args:
simple: a bool to control output. Returns a list, where each entry consists of outline level, title, page number and link destination (if simple = False). For details see PyMuPDF's documentation.
"""
def recurse(olItem, liste... | python | def getToC(doc, simple = True):
"""Create a table of contents.
Args:
simple: a bool to control output. Returns a list, where each entry consists of outline level, title, page number and link destination (if simple = False). For details see PyMuPDF's documentation.
"""
def recurse(olItem, liste... | [
"def",
"getToC",
"(",
"doc",
",",
"simple",
"=",
"True",
")",
":",
"def",
"recurse",
"(",
"olItem",
",",
"liste",
",",
"lvl",
")",
":",
"while",
"olItem",
":",
"if",
"olItem",
".",
"title",
":",
"title",
"=",
"olItem",
".",
"title",
"else",
":",
... | Create a table of contents.
Args:
simple: a bool to control output. Returns a list, where each entry consists of outline level, title, page number and link destination (if simple = False). For details see PyMuPDF's documentation. | [
"Create",
"a",
"table",
"of",
"contents",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L528-L571 | train |
pymupdf/PyMuPDF | fitz/utils.py | updateLink | def updateLink(page, lnk):
""" Update a link on the current page. """
CheckParent(page)
annot = getLinkText(page, lnk)
if annot == "":
raise ValueError("link kind not supported")
page.parent._updateObject(lnk["xref"], annot, page = page)
return | python | def updateLink(page, lnk):
""" Update a link on the current page. """
CheckParent(page)
annot = getLinkText(page, lnk)
if annot == "":
raise ValueError("link kind not supported")
page.parent._updateObject(lnk["xref"], annot, page = page)
return | [
"def",
"updateLink",
"(",
"page",
",",
"lnk",
")",
":",
"CheckParent",
"(",
"page",
")",
"annot",
"=",
"getLinkText",
"(",
"page",
",",
"lnk",
")",
"if",
"annot",
"==",
"\"\"",
":",
"raise",
"ValueError",
"(",
"\"link kind not supported\"",
")",
"page",
... | Update a link on the current page. | [
"Update",
"a",
"link",
"on",
"the",
"current",
"page",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L990-L998 | train |
pymupdf/PyMuPDF | fitz/utils.py | insertLink | def insertLink(page, lnk, mark = True):
""" Insert a new link for the current page. """
CheckParent(page)
annot = getLinkText(page, lnk)
if annot == "":
raise ValueError("link kind not supported")
page._addAnnot_FromString([annot])
return | python | def insertLink(page, lnk, mark = True):
""" Insert a new link for the current page. """
CheckParent(page)
annot = getLinkText(page, lnk)
if annot == "":
raise ValueError("link kind not supported")
page._addAnnot_FromString([annot])
return | [
"def",
"insertLink",
"(",
"page",
",",
"lnk",
",",
"mark",
"=",
"True",
")",
":",
"CheckParent",
"(",
"page",
")",
"annot",
"=",
"getLinkText",
"(",
"page",
",",
"lnk",
")",
"if",
"annot",
"==",
"\"\"",
":",
"raise",
"ValueError",
"(",
"\"link kind not... | Insert a new link for the current page. | [
"Insert",
"a",
"new",
"link",
"for",
"the",
"current",
"page",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1000-L1008 | train |
pymupdf/PyMuPDF | fitz/utils.py | newPage | def newPage(doc, pno=-1, width=595, height=842):
"""Create and return a new page object.
"""
doc._newPage(pno, width=width, height=height)
return doc[pno] | python | def newPage(doc, pno=-1, width=595, height=842):
"""Create and return a new page object.
"""
doc._newPage(pno, width=width, height=height)
return doc[pno] | [
"def",
"newPage",
"(",
"doc",
",",
"pno",
"=",
"-",
"1",
",",
"width",
"=",
"595",
",",
"height",
"=",
"842",
")",
":",
"doc",
".",
"_newPage",
"(",
"pno",
",",
"width",
"=",
"width",
",",
"height",
"=",
"height",
")",
"return",
"doc",
"[",
"pn... | Create and return a new page object. | [
"Create",
"and",
"return",
"a",
"new",
"page",
"object",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1094-L1098 | train |
pymupdf/PyMuPDF | fitz/utils.py | insertPage | def insertPage(
doc,
pno,
text=None,
fontsize=11,
width=595,
height=842,
fontname="helv",
fontfile=None,
color=None,
):
""" Create a new PDF page and insert some text.
Notes:
Function combining Document.newPage() and Page.inser... | python | def insertPage(
doc,
pno,
text=None,
fontsize=11,
width=595,
height=842,
fontname="helv",
fontfile=None,
color=None,
):
""" Create a new PDF page and insert some text.
Notes:
Function combining Document.newPage() and Page.inser... | [
"def",
"insertPage",
"(",
"doc",
",",
"pno",
",",
"text",
"=",
"None",
",",
"fontsize",
"=",
"11",
",",
"width",
"=",
"595",
",",
"height",
"=",
"842",
",",
"fontname",
"=",
"\"helv\"",
",",
"fontfile",
"=",
"None",
",",
"color",
"=",
"None",
",",
... | Create a new PDF page and insert some text.
Notes:
Function combining Document.newPage() and Page.insertText().
For parameter details see these methods. | [
"Create",
"a",
"new",
"PDF",
"page",
"and",
"insert",
"some",
"text",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1100-L1128 | train |
pymupdf/PyMuPDF | fitz/utils.py | drawSquiggle | def drawSquiggle(page, p1, p2, breadth = 2, color=None, dashes=None,
width=1, roundCap=False, overlay=True, morph=None):
"""Draw a squiggly line from point p1 to point p2.
"""
img = page.newShape()
p = img.drawSquiggle(Point(p1), Point(p2), breadth = breadth)
img.finish(color=color, d... | python | def drawSquiggle(page, p1, p2, breadth = 2, color=None, dashes=None,
width=1, roundCap=False, overlay=True, morph=None):
"""Draw a squiggly line from point p1 to point p2.
"""
img = page.newShape()
p = img.drawSquiggle(Point(p1), Point(p2), breadth = breadth)
img.finish(color=color, d... | [
"def",
"drawSquiggle",
"(",
"page",
",",
"p1",
",",
"p2",
",",
"breadth",
"=",
"2",
",",
"color",
"=",
"None",
",",
"dashes",
"=",
"None",
",",
"width",
"=",
"1",
",",
"roundCap",
"=",
"False",
",",
"overlay",
"=",
"True",
",",
"morph",
"=",
"Non... | Draw a squiggly line from point p1 to point p2. | [
"Draw",
"a",
"squiggly",
"line",
"from",
"point",
"p1",
"to",
"point",
"p2",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1141-L1151 | train |
pymupdf/PyMuPDF | fitz/utils.py | drawQuad | def drawQuad(page, quad, color=None, fill=None, dashes=None,
width=1, roundCap=False, morph=None, overlay=True):
"""Draw a quadrilateral.
"""
img = page.newShape()
Q = img.drawQuad(Quad(quad))
img.finish(color=color, fill=fill, dashes=dashes, width=width,
roundCap=rou... | python | def drawQuad(page, quad, color=None, fill=None, dashes=None,
width=1, roundCap=False, morph=None, overlay=True):
"""Draw a quadrilateral.
"""
img = page.newShape()
Q = img.drawQuad(Quad(quad))
img.finish(color=color, fill=fill, dashes=dashes, width=width,
roundCap=rou... | [
"def",
"drawQuad",
"(",
"page",
",",
"quad",
",",
"color",
"=",
"None",
",",
"fill",
"=",
"None",
",",
"dashes",
"=",
"None",
",",
"width",
"=",
"1",
",",
"roundCap",
"=",
"False",
",",
"morph",
"=",
"None",
",",
"overlay",
"=",
"True",
")",
":",... | Draw a quadrilateral. | [
"Draw",
"a",
"quadrilateral",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1177-L1187 | train |
pymupdf/PyMuPDF | fitz/utils.py | drawPolyline | def drawPolyline(page, points, color=None, fill=None, dashes=None,
width=1, morph=None, roundCap=False, overlay=True,
closePath=False):
"""Draw multiple connected line segments.
"""
img = page.newShape()
Q = img.drawPolyline(points)
img.finish(color=color, fill=fill... | python | def drawPolyline(page, points, color=None, fill=None, dashes=None,
width=1, morph=None, roundCap=False, overlay=True,
closePath=False):
"""Draw multiple connected line segments.
"""
img = page.newShape()
Q = img.drawPolyline(points)
img.finish(color=color, fill=fill... | [
"def",
"drawPolyline",
"(",
"page",
",",
"points",
",",
"color",
"=",
"None",
",",
"fill",
"=",
"None",
",",
"dashes",
"=",
"None",
",",
"width",
"=",
"1",
",",
"morph",
"=",
"None",
",",
"roundCap",
"=",
"False",
",",
"overlay",
"=",
"True",
",",
... | Draw multiple connected line segments. | [
"Draw",
"multiple",
"connected",
"line",
"segments",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1189-L1200 | train |
pymupdf/PyMuPDF | fitz/utils.py | drawBezier | def drawBezier(page, p1, p2, p3, p4, color=None, fill=None,
dashes=None, width=1, morph=None,
closePath=False, roundCap=False, overlay=True):
"""Draw a general cubic Bezier curve from p1 to p4 using control points p2 and p3.
"""
img = page.newShape()
Q = img.drawBezier(Poin... | python | def drawBezier(page, p1, p2, p3, p4, color=None, fill=None,
dashes=None, width=1, morph=None,
closePath=False, roundCap=False, overlay=True):
"""Draw a general cubic Bezier curve from p1 to p4 using control points p2 and p3.
"""
img = page.newShape()
Q = img.drawBezier(Poin... | [
"def",
"drawBezier",
"(",
"page",
",",
"p1",
",",
"p2",
",",
"p3",
",",
"p4",
",",
"color",
"=",
"None",
",",
"fill",
"=",
"None",
",",
"dashes",
"=",
"None",
",",
"width",
"=",
"1",
",",
"morph",
"=",
"None",
",",
"closePath",
"=",
"False",
",... | Draw a general cubic Bezier curve from p1 to p4 using control points p2 and p3. | [
"Draw",
"a",
"general",
"cubic",
"Bezier",
"curve",
"from",
"p1",
"to",
"p4",
"using",
"control",
"points",
"p2",
"and",
"p3",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1240-L1251 | train |
pymupdf/PyMuPDF | fitz/utils.py | getColor | def getColor(name):
"""Retrieve RGB color in PDF format by name.
Returns:
a triple of floats in range 0 to 1. In case of name-not-found, "white" is returned.
"""
try:
c = getColorInfoList()[getColorList().index(name.upper())]
return (c[1] / 255., c[2] / 255., c[3] / 255.)
ex... | python | def getColor(name):
"""Retrieve RGB color in PDF format by name.
Returns:
a triple of floats in range 0 to 1. In case of name-not-found, "white" is returned.
"""
try:
c = getColorInfoList()[getColorList().index(name.upper())]
return (c[1] / 255., c[2] / 255., c[3] / 255.)
ex... | [
"def",
"getColor",
"(",
"name",
")",
":",
"try",
":",
"c",
"=",
"getColorInfoList",
"(",
")",
"[",
"getColorList",
"(",
")",
".",
"index",
"(",
"name",
".",
"upper",
"(",
")",
")",
"]",
"return",
"(",
"c",
"[",
"1",
"]",
"/",
"255.",
",",
"c",
... | Retrieve RGB color in PDF format by name.
Returns:
a triple of floats in range 0 to 1. In case of name-not-found, "white" is returned. | [
"Retrieve",
"RGB",
"color",
"in",
"PDF",
"format",
"by",
"name",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1848-L1858 | train |
pymupdf/PyMuPDF | fitz/utils.py | getColorHSV | def getColorHSV(name):
"""Retrieve the hue, saturation, value triple of a color name.
Returns:
a triple (degree, percent, percent). If not found (-1, -1, -1) is returned.
"""
try:
x = getColorInfoList()[getColorList().index(name.upper())]
except:
return (-1, -1, -1)
... | python | def getColorHSV(name):
"""Retrieve the hue, saturation, value triple of a color name.
Returns:
a triple (degree, percent, percent). If not found (-1, -1, -1) is returned.
"""
try:
x = getColorInfoList()[getColorList().index(name.upper())]
except:
return (-1, -1, -1)
... | [
"def",
"getColorHSV",
"(",
"name",
")",
":",
"try",
":",
"x",
"=",
"getColorInfoList",
"(",
")",
"[",
"getColorList",
"(",
")",
".",
"index",
"(",
"name",
".",
"upper",
"(",
")",
")",
"]",
"except",
":",
"return",
"(",
"-",
"1",
",",
"-",
"1",
... | Retrieve the hue, saturation, value triple of a color name.
Returns:
a triple (degree, percent, percent). If not found (-1, -1, -1) is returned. | [
"Retrieve",
"the",
"hue",
"saturation",
"value",
"triple",
"of",
"a",
"color",
"name",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1860-L1895 | train |
pymupdf/PyMuPDF | fitz/utils.py | Shape.horizontal_angle | def horizontal_angle(C, P):
"""Return the angle to the horizontal for the connection from C to P.
This uses the arcus sine function and resolves its inherent ambiguity by
looking up in which quadrant vector S = P - C is located.
"""
S = Point(P - C).unit # unit ... | python | def horizontal_angle(C, P):
"""Return the angle to the horizontal for the connection from C to P.
This uses the arcus sine function and resolves its inherent ambiguity by
looking up in which quadrant vector S = P - C is located.
"""
S = Point(P - C).unit # unit ... | [
"def",
"horizontal_angle",
"(",
"C",
",",
"P",
")",
":",
"S",
"=",
"Point",
"(",
"P",
"-",
"C",
")",
".",
"unit",
"alfa",
"=",
"math",
".",
"asin",
"(",
"abs",
"(",
"S",
".",
"y",
")",
")",
"if",
"S",
".",
"x",
"<",
"0",
":",
"if",
"S",
... | Return the angle to the horizontal for the connection from C to P.
This uses the arcus sine function and resolves its inherent ambiguity by
looking up in which quadrant vector S = P - C is located. | [
"Return",
"the",
"angle",
"to",
"the",
"horizontal",
"for",
"the",
"connection",
"from",
"C",
"to",
"P",
".",
"This",
"uses",
"the",
"arcus",
"sine",
"function",
"and",
"resolves",
"its",
"inherent",
"ambiguity",
"by",
"looking",
"up",
"in",
"which",
"quad... | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1986-L2003 | train |
pymupdf/PyMuPDF | fitz/utils.py | Shape.drawLine | def drawLine(self, p1, p2):
"""Draw a line between two points.
"""
p1 = Point(p1)
p2 = Point(p2)
if not (self.lastPoint == p1):
self.draw_cont += "%g %g m\n" % JM_TUPLE(p1 * self.ipctm)
self.lastPoint = p1
self.updateRect(p1)
self.draw... | python | def drawLine(self, p1, p2):
"""Draw a line between two points.
"""
p1 = Point(p1)
p2 = Point(p2)
if not (self.lastPoint == p1):
self.draw_cont += "%g %g m\n" % JM_TUPLE(p1 * self.ipctm)
self.lastPoint = p1
self.updateRect(p1)
self.draw... | [
"def",
"drawLine",
"(",
"self",
",",
"p1",
",",
"p2",
")",
":",
"p1",
"=",
"Point",
"(",
"p1",
")",
"p2",
"=",
"Point",
"(",
"p2",
")",
"if",
"not",
"(",
"self",
".",
"lastPoint",
"==",
"p1",
")",
":",
"self",
".",
"draw_cont",
"+=",
"\"%g %g m... | Draw a line between two points. | [
"Draw",
"a",
"line",
"between",
"two",
"points",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L2042-L2055 | train |
pymupdf/PyMuPDF | fitz/utils.py | Shape.drawPolyline | def drawPolyline(self, points):
"""Draw several connected line segments.
"""
for i, p in enumerate(points):
if i == 0:
if not (self.lastPoint == Point(p)):
self.draw_cont += "%g %g m\n" % JM_TUPLE(Point(p) * self.ipctm)
self.las... | python | def drawPolyline(self, points):
"""Draw several connected line segments.
"""
for i, p in enumerate(points):
if i == 0:
if not (self.lastPoint == Point(p)):
self.draw_cont += "%g %g m\n" % JM_TUPLE(Point(p) * self.ipctm)
self.las... | [
"def",
"drawPolyline",
"(",
"self",
",",
"points",
")",
":",
"for",
"i",
",",
"p",
"in",
"enumerate",
"(",
"points",
")",
":",
"if",
"i",
"==",
"0",
":",
"if",
"not",
"(",
"self",
".",
"lastPoint",
"==",
"Point",
"(",
"p",
")",
")",
":",
"self"... | Draw several connected line segments. | [
"Draw",
"several",
"connected",
"line",
"segments",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L2057-L2070 | train |
pymupdf/PyMuPDF | fitz/utils.py | Shape.drawBezier | def drawBezier(self, p1, p2, p3, p4):
"""Draw a standard cubic Bezier curve.
"""
p1 = Point(p1)
p2 = Point(p2)
p3 = Point(p3)
p4 = Point(p4)
if not (self.lastPoint == p1):
self.draw_cont += "%g %g m\n" % JM_TUPLE(p1 * self.ipctm)
self.draw_cont... | python | def drawBezier(self, p1, p2, p3, p4):
"""Draw a standard cubic Bezier curve.
"""
p1 = Point(p1)
p2 = Point(p2)
p3 = Point(p3)
p4 = Point(p4)
if not (self.lastPoint == p1):
self.draw_cont += "%g %g m\n" % JM_TUPLE(p1 * self.ipctm)
self.draw_cont... | [
"def",
"drawBezier",
"(",
"self",
",",
"p1",
",",
"p2",
",",
"p3",
",",
"p4",
")",
":",
"p1",
"=",
"Point",
"(",
"p1",
")",
"p2",
"=",
"Point",
"(",
"p2",
")",
"p3",
"=",
"Point",
"(",
"p3",
")",
"p4",
"=",
"Point",
"(",
"p4",
")",
"if",
... | Draw a standard cubic Bezier curve. | [
"Draw",
"a",
"standard",
"cubic",
"Bezier",
"curve",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L2072-L2089 | train |
pymupdf/PyMuPDF | fitz/utils.py | Shape.drawOval | def drawOval(self, tetra):
"""Draw an ellipse inside a tetrapod.
"""
if len(tetra) != 4:
raise ValueError("invalid arg length")
if hasattr(tetra[0], "__float__"):
q = Rect(tetra).quad
else:
q = Quad(tetra)
mt = q.ul + (q.ur - q.ul) * 0... | python | def drawOval(self, tetra):
"""Draw an ellipse inside a tetrapod.
"""
if len(tetra) != 4:
raise ValueError("invalid arg length")
if hasattr(tetra[0], "__float__"):
q = Rect(tetra).quad
else:
q = Quad(tetra)
mt = q.ul + (q.ur - q.ul) * 0... | [
"def",
"drawOval",
"(",
"self",
",",
"tetra",
")",
":",
"if",
"len",
"(",
"tetra",
")",
"!=",
"4",
":",
"raise",
"ValueError",
"(",
"\"invalid arg length\"",
")",
"if",
"hasattr",
"(",
"tetra",
"[",
"0",
"]",
",",
"\"__float__\"",
")",
":",
"q",
"=",... | Draw an ellipse inside a tetrapod. | [
"Draw",
"an",
"ellipse",
"inside",
"a",
"tetrapod",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L2091-L2114 | train |
pymupdf/PyMuPDF | fitz/utils.py | Shape.drawCurve | def drawCurve(self, p1, p2, p3):
"""Draw a curve between points using one control point.
"""
kappa = 0.55228474983
p1 = Point(p1)
p2 = Point(p2)
p3 = Point(p3)
k1 = p1 + (p2 - p1) * kappa
k2 = p3 + (p2 - p3) * kappa
return self.drawBezier(p1, k1, k... | python | def drawCurve(self, p1, p2, p3):
"""Draw a curve between points using one control point.
"""
kappa = 0.55228474983
p1 = Point(p1)
p2 = Point(p2)
p3 = Point(p3)
k1 = p1 + (p2 - p1) * kappa
k2 = p3 + (p2 - p3) * kappa
return self.drawBezier(p1, k1, k... | [
"def",
"drawCurve",
"(",
"self",
",",
"p1",
",",
"p2",
",",
"p3",
")",
":",
"kappa",
"=",
"0.55228474983",
"p1",
"=",
"Point",
"(",
"p1",
")",
"p2",
"=",
"Point",
"(",
"p2",
")",
"p3",
"=",
"Point",
"(",
"p3",
")",
"k1",
"=",
"p1",
"+",
"(",
... | Draw a curve between points using one control point. | [
"Draw",
"a",
"curve",
"between",
"points",
"using",
"one",
"control",
"point",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L2125-L2134 | train |
pymupdf/PyMuPDF | fitz/utils.py | Shape.drawQuad | def drawQuad(self, quad):
"""Draw a Quad.
"""
q = Quad(quad)
return self.drawPolyline([q.ul, q.ll, q.lr, q.ur, q.ul]) | python | def drawQuad(self, quad):
"""Draw a Quad.
"""
q = Quad(quad)
return self.drawPolyline([q.ul, q.ll, q.lr, q.ur, q.ul]) | [
"def",
"drawQuad",
"(",
"self",
",",
"quad",
")",
":",
"q",
"=",
"Quad",
"(",
"quad",
")",
"return",
"self",
".",
"drawPolyline",
"(",
"[",
"q",
".",
"ul",
",",
"q",
".",
"ll",
",",
"q",
".",
"lr",
",",
"q",
".",
"ur",
",",
"q",
".",
"ul",
... | Draw a Quad. | [
"Draw",
"a",
"Quad",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L2215-L2219 | train |
pymupdf/PyMuPDF | fitz/utils.py | Shape.drawZigzag | def drawZigzag(self, p1, p2, breadth = 2):
"""Draw a zig-zagged line from p1 to p2.
"""
p1 = Point(p1)
p2 = Point(p2)
S = p2 - p1 # vector start - end
rad = abs(S) # distance of points
cnt = 4 * int(round(rad ... | python | def drawZigzag(self, p1, p2, breadth = 2):
"""Draw a zig-zagged line from p1 to p2.
"""
p1 = Point(p1)
p2 = Point(p2)
S = p2 - p1 # vector start - end
rad = abs(S) # distance of points
cnt = 4 * int(round(rad ... | [
"def",
"drawZigzag",
"(",
"self",
",",
"p1",
",",
"p2",
",",
"breadth",
"=",
"2",
")",
":",
"p1",
"=",
"Point",
"(",
"p1",
")",
"p2",
"=",
"Point",
"(",
"p2",
")",
"S",
"=",
"p2",
"-",
"p1",
"rad",
"=",
"abs",
"(",
"S",
")",
"cnt",
"=",
"... | Draw a zig-zagged line from p1 to p2. | [
"Draw",
"a",
"zig",
"-",
"zagged",
"line",
"from",
"p1",
"to",
"p2",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L2221-L2244 | train |
pymupdf/PyMuPDF | fitz/utils.py | Shape.drawSquiggle | def drawSquiggle(self, p1, p2, breadth = 2):
"""Draw a squiggly line from p1 to p2.
"""
p1 = Point(p1)
p2 = Point(p2)
S = p2 - p1 # vector start - end
rad = abs(S) # distance of points
cnt = 4 * int(round(rad ... | python | def drawSquiggle(self, p1, p2, breadth = 2):
"""Draw a squiggly line from p1 to p2.
"""
p1 = Point(p1)
p2 = Point(p2)
S = p2 - p1 # vector start - end
rad = abs(S) # distance of points
cnt = 4 * int(round(rad ... | [
"def",
"drawSquiggle",
"(",
"self",
",",
"p1",
",",
"p2",
",",
"breadth",
"=",
"2",
")",
":",
"p1",
"=",
"Point",
"(",
"p1",
")",
"p2",
"=",
"Point",
"(",
"p2",
")",
"S",
"=",
"p2",
"-",
"p1",
"rad",
"=",
"abs",
"(",
"S",
")",
"cnt",
"=",
... | Draw a squiggly line from p1 to p2. | [
"Draw",
"a",
"squiggly",
"line",
"from",
"p1",
"to",
"p2",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L2246-L2277 | train |
pymupdf/PyMuPDF | fitz/utils.py | Shape.finish | def finish(
self,
width=1,
color=None,
fill=None,
roundCap=False,
dashes=None,
even_odd=False,
morph=None,
closePath=True
):
"""Finish the current drawing segment.
Notes:
Appl... | python | def finish(
self,
width=1,
color=None,
fill=None,
roundCap=False,
dashes=None,
even_odd=False,
morph=None,
closePath=True
):
"""Finish the current drawing segment.
Notes:
Appl... | [
"def",
"finish",
"(",
"self",
",",
"width",
"=",
"1",
",",
"color",
"=",
"None",
",",
"fill",
"=",
"None",
",",
"roundCap",
"=",
"False",
",",
"dashes",
"=",
"None",
",",
"even_odd",
"=",
"False",
",",
"morph",
"=",
"None",
",",
"closePath",
"=",
... | Finish the current drawing segment.
Notes:
Apply stroke and fill colors, dashes, line style and width, or
morphing. Also determines whether any open path should be closed
by a connecting line to its start point. | [
"Finish",
"the",
"current",
"drawing",
"segment",
"."
] | 917f2d83482510e26ba0ff01fd2392c26f3a8e90 | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L2709-L2767 | train |
stitchfix/pyxley | pyxley/charts/mg/mg.py | OptionHelper.set_float | def set_float(self, option, value):
"""Set a float option.
Args:
option (str): name of option.
value (float): value of the option.
Raises:
TypeError: Value must be a float.
"""
if not isinstance(value, float):
... | python | def set_float(self, option, value):
"""Set a float option.
Args:
option (str): name of option.
value (float): value of the option.
Raises:
TypeError: Value must be a float.
"""
if not isinstance(value, float):
... | [
"def",
"set_float",
"(",
"self",
",",
"option",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"float",
")",
":",
"raise",
"TypeError",
"(",
"\"Value must be a float\"",
")",
"self",
".",
"options",
"[",
"option",
"]",
"=",
"value"... | Set a float option.
Args:
option (str): name of option.
value (float): value of the option.
Raises:
TypeError: Value must be a float. | [
"Set",
"a",
"float",
"option",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/mg.py#L29-L41 | train |
stitchfix/pyxley | pyxley/charts/mg/mg.py | OptionHelper.set_integer | def set_integer(self, option, value):
"""Set an integer option.
Args:
option (str): name of option.
value (int): value of the option.
Raises:
ValueError: Value must be an integer.
"""
try:
int_value = int(value... | python | def set_integer(self, option, value):
"""Set an integer option.
Args:
option (str): name of option.
value (int): value of the option.
Raises:
ValueError: Value must be an integer.
"""
try:
int_value = int(value... | [
"def",
"set_integer",
"(",
"self",
",",
"option",
",",
"value",
")",
":",
"try",
":",
"int_value",
"=",
"int",
"(",
"value",
")",
"except",
"ValueError",
"as",
"err",
":",
"print",
"(",
"err",
".",
"args",
")",
"self",
".",
"options",
"[",
"option",
... | Set an integer option.
Args:
option (str): name of option.
value (int): value of the option.
Raises:
ValueError: Value must be an integer. | [
"Set",
"an",
"integer",
"option",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/mg.py#L43-L58 | train |
stitchfix/pyxley | pyxley/charts/mg/mg.py | OptionHelper.set_boolean | def set_boolean(self, option, value):
"""Set a boolean option.
Args:
option (str): name of option.
value (bool): value of the option.
Raises:
TypeError: Value must be a boolean.
"""
if not isinstance(value, bool):
... | python | def set_boolean(self, option, value):
"""Set a boolean option.
Args:
option (str): name of option.
value (bool): value of the option.
Raises:
TypeError: Value must be a boolean.
"""
if not isinstance(value, bool):
... | [
"def",
"set_boolean",
"(",
"self",
",",
"option",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"raise",
"TypeError",
"(",
"\"%s must be a boolean\"",
"%",
"option",
")",
"self",
".",
"options",
"[",
"option",
"]... | Set a boolean option.
Args:
option (str): name of option.
value (bool): value of the option.
Raises:
TypeError: Value must be a boolean. | [
"Set",
"a",
"boolean",
"option",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/mg.py#L60-L73 | train |
stitchfix/pyxley | pyxley/charts/mg/mg.py | OptionHelper.set_string | def set_string(self, option, value):
"""Set a string option.
Args:
option (str): name of option.
value (str): value of the option.
Raises:
TypeError: Value must be a string.
"""
if not isinstance(value, str):
r... | python | def set_string(self, option, value):
"""Set a string option.
Args:
option (str): name of option.
value (str): value of the option.
Raises:
TypeError: Value must be a string.
"""
if not isinstance(value, str):
r... | [
"def",
"set_string",
"(",
"self",
",",
"option",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"%s must be a string\"",
"%",
"option",
")",
"self",
".",
"options",
"[",
"option",
"]",
... | Set a string option.
Args:
option (str): name of option.
value (str): value of the option.
Raises:
TypeError: Value must be a string. | [
"Set",
"a",
"string",
"option",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/mg.py#L75-L88 | train |
stitchfix/pyxley | pyxley/charts/mg/graphic.py | Graphic.custom_line_color_map | def custom_line_color_map(self, values):
"""Set the custom line color map.
Args:
values (list): list of colors.
Raises:
TypeError: Custom line color map must be a list.
"""
if not isinstance(values, list):
raise TypeError("cus... | python | def custom_line_color_map(self, values):
"""Set the custom line color map.
Args:
values (list): list of colors.
Raises:
TypeError: Custom line color map must be a list.
"""
if not isinstance(values, list):
raise TypeError("cus... | [
"def",
"custom_line_color_map",
"(",
"self",
",",
"values",
")",
":",
"if",
"not",
"isinstance",
"(",
"values",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"\"custom_line_color_map must be a list\"",
")",
"self",
".",
"options",
"[",
"\"custom_line_color_map... | Set the custom line color map.
Args:
values (list): list of colors.
Raises:
TypeError: Custom line color map must be a list. | [
"Set",
"the",
"custom",
"line",
"color",
"map",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/graphic.py#L89-L101 | train |
stitchfix/pyxley | pyxley/charts/mg/graphic.py | Graphic.legend | def legend(self, values):
"""Set the legend labels.
Args:
values (list): list of labels.
Raises:
ValueError: legend must be a list of labels.
"""
if not isinstance(values, list):
raise TypeError("legend must be a list of label... | python | def legend(self, values):
"""Set the legend labels.
Args:
values (list): list of labels.
Raises:
ValueError: legend must be a list of labels.
"""
if not isinstance(values, list):
raise TypeError("legend must be a list of label... | [
"def",
"legend",
"(",
"self",
",",
"values",
")",
":",
"if",
"not",
"isinstance",
"(",
"values",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"\"legend must be a list of labels\"",
")",
"self",
".",
"options",
"[",
"\"legend\"",
"]",
"=",
"values"
] | Set the legend labels.
Args:
values (list): list of labels.
Raises:
ValueError: legend must be a list of labels. | [
"Set",
"the",
"legend",
"labels",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/graphic.py#L164-L176 | train |
stitchfix/pyxley | pyxley/charts/mg/graphic.py | Graphic.markers | def markers(self, values):
"""Set the markers.
Args:
values (list): list of marker objects.
Raises:
ValueError: Markers must be a list of objects.
"""
if not isinstance(values, list):
raise TypeError("Markers must be a list of... | python | def markers(self, values):
"""Set the markers.
Args:
values (list): list of marker objects.
Raises:
ValueError: Markers must be a list of objects.
"""
if not isinstance(values, list):
raise TypeError("Markers must be a list of... | [
"def",
"markers",
"(",
"self",
",",
"values",
")",
":",
"if",
"not",
"isinstance",
"(",
"values",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"\"Markers must be a list of objects\"",
")",
"self",
".",
"options",
"[",
"\"markers\"",
"]",
"=",
"values"
] | Set the markers.
Args:
values (list): list of marker objects.
Raises:
ValueError: Markers must be a list of objects. | [
"Set",
"the",
"markers",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/graphic.py#L194-L206 | train |
stitchfix/pyxley | pyxley/charts/mg/graphic.py | Graphic.get | def get(self):
"""Get graphics options."""
return {k:v for k,v in list(self.options.items()) if k in self._allowed_graphics} | python | def get(self):
"""Get graphics options."""
return {k:v for k,v in list(self.options.items()) if k in self._allowed_graphics} | [
"def",
"get",
"(",
"self",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"self",
".",
"options",
".",
"items",
"(",
")",
")",
"if",
"k",
"in",
"self",
".",
"_allowed_graphics",
"}"
] | Get graphics options. | [
"Get",
"graphics",
"options",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/graphic.py#L260-L262 | train |
stitchfix/pyxley | pyxley/charts/charts.py | Chart.apply_filters | def apply_filters(df, filters):
"""Basic filtering for a dataframe."""
idx = pd.Series([True]*df.shape[0])
for k, v in list(filters.items()):
if k not in df.columns:
continue
idx &= (df[k] == v)
return df.loc[idx] | python | def apply_filters(df, filters):
"""Basic filtering for a dataframe."""
idx = pd.Series([True]*df.shape[0])
for k, v in list(filters.items()):
if k not in df.columns:
continue
idx &= (df[k] == v)
return df.loc[idx] | [
"def",
"apply_filters",
"(",
"df",
",",
"filters",
")",
":",
"idx",
"=",
"pd",
".",
"Series",
"(",
"[",
"True",
"]",
"*",
"df",
".",
"shape",
"[",
"0",
"]",
")",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"filters",
".",
"items",
"(",
")",
")",... | Basic filtering for a dataframe. | [
"Basic",
"filtering",
"for",
"a",
"dataframe",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/charts.py#L10-L18 | train |
stitchfix/pyxley | pyxley/charts/datatables/datatable.py | DataTable.format_row | def format_row(row, bounds, columns):
"""Formats a single row of the dataframe"""
for c in columns:
if c not in row:
continue
if "format" in columns[c]:
row[c] = columns[c]["format"] % row[c]
if c in bounds:
b = bounds... | python | def format_row(row, bounds, columns):
"""Formats a single row of the dataframe"""
for c in columns:
if c not in row:
continue
if "format" in columns[c]:
row[c] = columns[c]["format"] % row[c]
if c in bounds:
b = bounds... | [
"def",
"format_row",
"(",
"row",
",",
"bounds",
",",
"columns",
")",
":",
"for",
"c",
"in",
"columns",
":",
"if",
"c",
"not",
"in",
"row",
":",
"continue",
"if",
"\"format\"",
"in",
"columns",
"[",
"c",
"]",
":",
"row",
"[",
"c",
"]",
"=",
"colum... | Formats a single row of the dataframe | [
"Formats",
"a",
"single",
"row",
"of",
"the",
"dataframe"
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/datatables/datatable.py#L70-L83 | train |
stitchfix/pyxley | pyxley/charts/datatables/datatable.py | DataTable.to_json | def to_json(df, columns, confidence={}):
"""Transforms dataframe to properly formatted json response"""
records = []
display_cols = list(columns.keys())
if not display_cols:
display_cols = list(df.columns)
bounds = {}
for c in confidence:
bounds[... | python | def to_json(df, columns, confidence={}):
"""Transforms dataframe to properly formatted json response"""
records = []
display_cols = list(columns.keys())
if not display_cols:
display_cols = list(df.columns)
bounds = {}
for c in confidence:
bounds[... | [
"def",
"to_json",
"(",
"df",
",",
"columns",
",",
"confidence",
"=",
"{",
"}",
")",
":",
"records",
"=",
"[",
"]",
"display_cols",
"=",
"list",
"(",
"columns",
".",
"keys",
"(",
")",
")",
"if",
"not",
"display_cols",
":",
"display_cols",
"=",
"list",... | Transforms dataframe to properly formatted json response | [
"Transforms",
"dataframe",
"to",
"properly",
"formatted",
"json",
"response"
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/datatables/datatable.py#L86-L117 | train |
stitchfix/pyxley | pyxley/charts/mg/figure.py | Figure.get | def get(self):
"""Return axes, graphics, and layout options."""
options = {}
for x in [self.axes, self.graphics, self.layout]:
for k, v in list(x.get().items()):
options[k] = v
return options | python | def get(self):
"""Return axes, graphics, and layout options."""
options = {}
for x in [self.axes, self.graphics, self.layout]:
for k, v in list(x.get().items()):
options[k] = v
return options | [
"def",
"get",
"(",
"self",
")",
":",
"options",
"=",
"{",
"}",
"for",
"x",
"in",
"[",
"self",
".",
"axes",
",",
"self",
".",
"graphics",
",",
"self",
".",
"layout",
"]",
":",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"x",
".",
"get",
"(",
")... | Return axes, graphics, and layout options. | [
"Return",
"axes",
"graphics",
"and",
"layout",
"options",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/figure.py#L22-L29 | train |
stitchfix/pyxley | pyxley/charts/mg/layout.py | Layout.set_margin | def set_margin(self, top=40, bottom=30, left=50, right=10, buffer_size=8):
"""Set margin of the chart.
Args:
top (int): size of top margin in pixels.
bottom (int): size of bottom margin in pixels.
left (int): size of left margin in pixels.
... | python | def set_margin(self, top=40, bottom=30, left=50, right=10, buffer_size=8):
"""Set margin of the chart.
Args:
top (int): size of top margin in pixels.
bottom (int): size of bottom margin in pixels.
left (int): size of left margin in pixels.
... | [
"def",
"set_margin",
"(",
"self",
",",
"top",
"=",
"40",
",",
"bottom",
"=",
"30",
",",
"left",
"=",
"50",
",",
"right",
"=",
"10",
",",
"buffer_size",
"=",
"8",
")",
":",
"self",
".",
"set_integer",
"(",
"\"top\"",
",",
"top",
")",
"self",
".",
... | Set margin of the chart.
Args:
top (int): size of top margin in pixels.
bottom (int): size of bottom margin in pixels.
left (int): size of left margin in pixels.
right (int): size of right margin in pixels.
buffer_size (int): b... | [
"Set",
"margin",
"of",
"the",
"chart",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/layout.py#L20-L35 | train |
stitchfix/pyxley | pyxley/charts/mg/layout.py | Layout.set_size | def set_size(self, height=220, width=350,
height_threshold=120,
width_threshold=160):
"""Set the size of the chart.
Args:
height (int): height in pixels.
width (int): width in pixels.
height_threshold (int): height th... | python | def set_size(self, height=220, width=350,
height_threshold=120,
width_threshold=160):
"""Set the size of the chart.
Args:
height (int): height in pixels.
width (int): width in pixels.
height_threshold (int): height th... | [
"def",
"set_size",
"(",
"self",
",",
"height",
"=",
"220",
",",
"width",
"=",
"350",
",",
"height_threshold",
"=",
"120",
",",
"width_threshold",
"=",
"160",
")",
":",
"self",
".",
"set_integer",
"(",
"\"height\"",
",",
"height",
")",
"self",
".",
"set... | Set the size of the chart.
Args:
height (int): height in pixels.
width (int): width in pixels.
height_threshold (int): height threshold in pixels
width_threshold (int): width threshold in pixesls | [
"Set",
"the",
"size",
"of",
"the",
"chart",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/layout.py#L37-L52 | train |
stitchfix/pyxley | pyxley/charts/mg/layout.py | Layout.get | def get(self):
"""Get layout options."""
return {k:v for k,v in list(self.options.items()) if k in self._allowed_layout} | python | def get(self):
"""Get layout options."""
return {k:v for k,v in list(self.options.items()) if k in self._allowed_layout} | [
"def",
"get",
"(",
"self",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"self",
".",
"options",
".",
"items",
"(",
")",
")",
"if",
"k",
"in",
"self",
".",
"_allowed_layout",
"}"
] | Get layout options. | [
"Get",
"layout",
"options",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/layout.py#L54-L56 | train |
stitchfix/pyxley | pyxley/react_template.py | format_props | def format_props(props, prop_template="{{k}} = { {{v}} }", delim="\n"):
""" Formats props for the React template.
Args:
props (dict): properties to be written to the template.
Returns:
Two lists, one containing variable names and the other
containing a list of p... | python | def format_props(props, prop_template="{{k}} = { {{v}} }", delim="\n"):
""" Formats props for the React template.
Args:
props (dict): properties to be written to the template.
Returns:
Two lists, one containing variable names and the other
containing a list of p... | [
"def",
"format_props",
"(",
"props",
",",
"prop_template",
"=",
"\"{{k}} = { {{v}} }\"",
",",
"delim",
"=",
"\"\\n\"",
")",
":",
"vars_",
"=",
"[",
"]",
"props_",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"props",
".",
"items",
"(",
")"... | Formats props for the React template.
Args:
props (dict): properties to be written to the template.
Returns:
Two lists, one containing variable names and the other
containing a list of props to be fed to the React template. | [
"Formats",
"props",
"for",
"the",
"React",
"template",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/react_template.py#L35-L51 | train |
stitchfix/pyxley | pyxley/ui.py | register_layouts | def register_layouts(layouts, app, url="/api/props/", brand="Pyxley"):
""" register UILayout with the flask app
create a function that will send props for each UILayout
Args:
layouts (dict): dict of UILayout objects by name
app (object): flask app
url (string): ... | python | def register_layouts(layouts, app, url="/api/props/", brand="Pyxley"):
""" register UILayout with the flask app
create a function that will send props for each UILayout
Args:
layouts (dict): dict of UILayout objects by name
app (object): flask app
url (string): ... | [
"def",
"register_layouts",
"(",
"layouts",
",",
"app",
",",
"url",
"=",
"\"/api/props/\"",
",",
"brand",
"=",
"\"Pyxley\"",
")",
":",
"def",
"props",
"(",
"name",
")",
":",
"if",
"name",
"not",
"in",
"layouts",
":",
"name",
"=",
"list",
"(",
"layouts",... | register UILayout with the flask app
create a function that will send props for each UILayout
Args:
layouts (dict): dict of UILayout objects by name
app (object): flask app
url (string): address of props; default is /api/props/ | [
"register",
"UILayout",
"with",
"the",
"flask",
"app"
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/ui.py#L5-L38 | train |
stitchfix/pyxley | pyxley/ui.py | UIComponent.register_route | def register_route(self, app):
"""Register the api route function with the app."""
if "url" not in self.params["options"]:
raise Exception("Component does not have a URL property")
if not hasattr(self.route_func, "__call__"):
raise Exception("No app route function suppli... | python | def register_route(self, app):
"""Register the api route function with the app."""
if "url" not in self.params["options"]:
raise Exception("Component does not have a URL property")
if not hasattr(self.route_func, "__call__"):
raise Exception("No app route function suppli... | [
"def",
"register_route",
"(",
"self",
",",
"app",
")",
":",
"if",
"\"url\"",
"not",
"in",
"self",
".",
"params",
"[",
"\"options\"",
"]",
":",
"raise",
"Exception",
"(",
"\"Component does not have a URL property\"",
")",
"if",
"not",
"hasattr",
"(",
"self",
... | Register the api route function with the app. | [
"Register",
"the",
"api",
"route",
"function",
"with",
"the",
"app",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/ui.py#L61-L71 | train |
stitchfix/pyxley | pyxley/ui.py | SimpleComponent.render | def render(self, path):
"""Render the component to a javascript file."""
return ReactComponent(
self.layout,
self.src_file,
self.component_id,
props=self.props,
static_path=path) | python | def render(self, path):
"""Render the component to a javascript file."""
return ReactComponent(
self.layout,
self.src_file,
self.component_id,
props=self.props,
static_path=path) | [
"def",
"render",
"(",
"self",
",",
"path",
")",
":",
"return",
"ReactComponent",
"(",
"self",
".",
"layout",
",",
"self",
".",
"src_file",
",",
"self",
".",
"component_id",
",",
"props",
"=",
"self",
".",
"props",
",",
"static_path",
"=",
"path",
")"
] | Render the component to a javascript file. | [
"Render",
"the",
"component",
"to",
"a",
"javascript",
"file",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/ui.py#L93-L100 | train |
stitchfix/pyxley | pyxley/ui.py | UILayout.add_filter | def add_filter(self, component, filter_group="pyxley-filter"):
"""Add a filter to the layout."""
if getattr(component, "name") != "Filter":
raise Exception("Component is not an instance of Filter")
if filter_group not in self.filters:
self.filters[filter_group] = []
... | python | def add_filter(self, component, filter_group="pyxley-filter"):
"""Add a filter to the layout."""
if getattr(component, "name") != "Filter":
raise Exception("Component is not an instance of Filter")
if filter_group not in self.filters:
self.filters[filter_group] = []
... | [
"def",
"add_filter",
"(",
"self",
",",
"component",
",",
"filter_group",
"=",
"\"pyxley-filter\"",
")",
":",
"if",
"getattr",
"(",
"component",
",",
"\"name\"",
")",
"!=",
"\"Filter\"",
":",
"raise",
"Exception",
"(",
"\"Component is not an instance of Filter\"",
... | Add a filter to the layout. | [
"Add",
"a",
"filter",
"to",
"the",
"layout",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/ui.py#L128-L134 | train |
stitchfix/pyxley | pyxley/ui.py | UILayout.add_chart | def add_chart(self, component):
"""Add a chart to the layout."""
if getattr(component, "name") != "Chart":
raise Exception("Component is not an instance of Chart")
self.charts.append(component) | python | def add_chart(self, component):
"""Add a chart to the layout."""
if getattr(component, "name") != "Chart":
raise Exception("Component is not an instance of Chart")
self.charts.append(component) | [
"def",
"add_chart",
"(",
"self",
",",
"component",
")",
":",
"if",
"getattr",
"(",
"component",
",",
"\"name\"",
")",
"!=",
"\"Chart\"",
":",
"raise",
"Exception",
"(",
"\"Component is not an instance of Chart\"",
")",
"self",
".",
"charts",
".",
"append",
"("... | Add a chart to the layout. | [
"Add",
"a",
"chart",
"to",
"the",
"layout",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/ui.py#L136-L140 | train |
stitchfix/pyxley | pyxley/ui.py | UILayout.build_props | def build_props(self):
"""Build the props dictionary."""
props = {}
if self.filters:
props["filters"] = {}
for grp in self.filters:
props["filters"][grp] = [f.params for f in self.filters[grp]]
if self.charts:
props["charts"] = [c.param... | python | def build_props(self):
"""Build the props dictionary."""
props = {}
if self.filters:
props["filters"] = {}
for grp in self.filters:
props["filters"][grp] = [f.params for f in self.filters[grp]]
if self.charts:
props["charts"] = [c.param... | [
"def",
"build_props",
"(",
"self",
")",
":",
"props",
"=",
"{",
"}",
"if",
"self",
".",
"filters",
":",
"props",
"[",
"\"filters\"",
"]",
"=",
"{",
"}",
"for",
"grp",
"in",
"self",
".",
"filters",
":",
"props",
"[",
"\"filters\"",
"]",
"[",
"grp",
... | Build the props dictionary. | [
"Build",
"the",
"props",
"dictionary",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/ui.py#L142-L153 | train |
stitchfix/pyxley | pyxley/ui.py | UILayout.assign_routes | def assign_routes(self, app):
"""Register routes with the app."""
for grp in self.filters:
for f in self.filters[grp]:
if f.route_func:
f.register_route(app)
for c in self.charts:
if c.route_func:
c.register_route(app) | python | def assign_routes(self, app):
"""Register routes with the app."""
for grp in self.filters:
for f in self.filters[grp]:
if f.route_func:
f.register_route(app)
for c in self.charts:
if c.route_func:
c.register_route(app) | [
"def",
"assign_routes",
"(",
"self",
",",
"app",
")",
":",
"for",
"grp",
"in",
"self",
".",
"filters",
":",
"for",
"f",
"in",
"self",
".",
"filters",
"[",
"grp",
"]",
":",
"if",
"f",
".",
"route_func",
":",
"f",
".",
"register_route",
"(",
"app",
... | Register routes with the app. | [
"Register",
"routes",
"with",
"the",
"app",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/ui.py#L155-L164 | train |
stitchfix/pyxley | pyxley/ui.py | UILayout.render_layout | def render_layout(self, app, path, alias=None):
"""Write to javascript."""
self.assign_routes(app)
return ReactComponent(
self.layout,
self.src_file,
self.component_id,
props=self.build_props(),
static_path=path,
alias=alias... | python | def render_layout(self, app, path, alias=None):
"""Write to javascript."""
self.assign_routes(app)
return ReactComponent(
self.layout,
self.src_file,
self.component_id,
props=self.build_props(),
static_path=path,
alias=alias... | [
"def",
"render_layout",
"(",
"self",
",",
"app",
",",
"path",
",",
"alias",
"=",
"None",
")",
":",
"self",
".",
"assign_routes",
"(",
"app",
")",
"return",
"ReactComponent",
"(",
"self",
".",
"layout",
",",
"self",
".",
"src_file",
",",
"self",
".",
... | Write to javascript. | [
"Write",
"to",
"javascript",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/ui.py#L166-L175 | train |
stitchfix/pyxley | pyxley/utils/flask_helper.py | default_static_path | def default_static_path():
"""
Return the path to the javascript bundle
"""
fdir = os.path.dirname(__file__)
return os.path.abspath(os.path.join(fdir, '../assets/')) | python | def default_static_path():
"""
Return the path to the javascript bundle
"""
fdir = os.path.dirname(__file__)
return os.path.abspath(os.path.join(fdir, '../assets/')) | [
"def",
"default_static_path",
"(",
")",
":",
"fdir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"fdir",
",",
"'../assets/'",
")",
")"
] | Return the path to the javascript bundle | [
"Return",
"the",
"path",
"to",
"the",
"javascript",
"bundle"
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/utils/flask_helper.py#L31-L36 | train |
stitchfix/pyxley | pyxley/utils/flask_helper.py | default_template_path | def default_template_path():
"""
Return the path to the index.html
"""
fdir = os.path.dirname(__file__)
return os.path.abspath(os.path.join(fdir, '../assets/')) | python | def default_template_path():
"""
Return the path to the index.html
"""
fdir = os.path.dirname(__file__)
return os.path.abspath(os.path.join(fdir, '../assets/')) | [
"def",
"default_template_path",
"(",
")",
":",
"fdir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"fdir",
",",
"'../assets/'",
")",
")"
] | Return the path to the index.html | [
"Return",
"the",
"path",
"to",
"the",
"index",
".",
"html"
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/utils/flask_helper.py#L38-L43 | train |
stitchfix/pyxley | pyxley/charts/mg/axes.py | Axes.set_xlim | def set_xlim(self, xlim):
""" Set x-axis limits.
Accepts a two-element list to set the x-axis limits.
Args:
xlim (list): lower and upper bounds
Raises:
ValueError: xlim must contain two elements
ValueError: Min must be less t... | python | def set_xlim(self, xlim):
""" Set x-axis limits.
Accepts a two-element list to set the x-axis limits.
Args:
xlim (list): lower and upper bounds
Raises:
ValueError: xlim must contain two elements
ValueError: Min must be less t... | [
"def",
"set_xlim",
"(",
"self",
",",
"xlim",
")",
":",
"if",
"len",
"(",
"xlim",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"\"xlim must contain two elements\"",
")",
"if",
"xlim",
"[",
"1",
"]",
"<",
"xlim",
"[",
"0",
"]",
":",
"raise",
"Value... | Set x-axis limits.
Accepts a two-element list to set the x-axis limits.
Args:
xlim (list): lower and upper bounds
Raises:
ValueError: xlim must contain two elements
ValueError: Min must be less than max | [
"Set",
"x",
"-",
"axis",
"limits",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/axes.py#L46-L65 | train |
stitchfix/pyxley | pyxley/charts/mg/axes.py | Axes.set_ylim | def set_ylim(self, ylim):
""" Set y-axis limits.
Accepts a two-element list to set the y-axis limits.
Args:
ylim (list): lower and upper bounds
Raises:
ValueError: ylim must contain two elements
ValueError: Min must be less t... | python | def set_ylim(self, ylim):
""" Set y-axis limits.
Accepts a two-element list to set the y-axis limits.
Args:
ylim (list): lower and upper bounds
Raises:
ValueError: ylim must contain two elements
ValueError: Min must be less t... | [
"def",
"set_ylim",
"(",
"self",
",",
"ylim",
")",
":",
"if",
"len",
"(",
"ylim",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"\"ylim must contain two elements\"",
")",
"if",
"ylim",
"[",
"1",
"]",
"<",
"ylim",
"[",
"0",
"]",
":",
"raise",
"Value... | Set y-axis limits.
Accepts a two-element list to set the y-axis limits.
Args:
ylim (list): lower and upper bounds
Raises:
ValueError: ylim must contain two elements
ValueError: Min must be less than max | [
"Set",
"y",
"-",
"axis",
"limits",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/axes.py#L67-L86 | train |
stitchfix/pyxley | pyxley/charts/mg/axes.py | Axes.get | def get(self):
""" Retrieve options set by user."""
return {k:v for k,v in list(self.options.items()) if k in self._allowed_axes} | python | def get(self):
""" Retrieve options set by user."""
return {k:v for k,v in list(self.options.items()) if k in self._allowed_axes} | [
"def",
"get",
"(",
"self",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"self",
".",
"options",
".",
"items",
"(",
")",
")",
"if",
"k",
"in",
"self",
".",
"_allowed_axes",
"}"
] | Retrieve options set by user. | [
"Retrieve",
"options",
"set",
"by",
"user",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/mg/axes.py#L168-L170 | train |
stitchfix/pyxley | pyxley/charts/plotly/base.py | PlotlyAPI.line_plot | def line_plot(df, xypairs, mode, layout={}, config=_BASE_CONFIG):
""" basic line plot
dataframe to json for a line plot
Args:
df (pandas.DataFrame): input dataframe
xypairs (list): list of tuples containing column names
mode (str): plotly... | python | def line_plot(df, xypairs, mode, layout={}, config=_BASE_CONFIG):
""" basic line plot
dataframe to json for a line plot
Args:
df (pandas.DataFrame): input dataframe
xypairs (list): list of tuples containing column names
mode (str): plotly... | [
"def",
"line_plot",
"(",
"df",
",",
"xypairs",
",",
"mode",
",",
"layout",
"=",
"{",
"}",
",",
"config",
"=",
"_BASE_CONFIG",
")",
":",
"if",
"df",
".",
"empty",
":",
"return",
"{",
"\"x\"",
":",
"[",
"]",
",",
"\"y\"",
":",
"[",
"]",
",",
"\"m... | basic line plot
dataframe to json for a line plot
Args:
df (pandas.DataFrame): input dataframe
xypairs (list): list of tuples containing column names
mode (str): plotly.js mode (e.g. lines)
layout (dict): layout parameters
... | [
"basic",
"line",
"plot"
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/plotly/base.py#L32-L66 | train |
stitchfix/pyxley | pyxley/charts/nvd3/pie_chart.py | PieChart.to_json | def to_json(df, values):
"""Format output for the json response."""
records = []
if df.empty:
return {"data": []}
sum_ = float(np.sum([df[c].iloc[0] for c in values]))
for c in values:
records.append({
"label": values[c],
"... | python | def to_json(df, values):
"""Format output for the json response."""
records = []
if df.empty:
return {"data": []}
sum_ = float(np.sum([df[c].iloc[0] for c in values]))
for c in values:
records.append({
"label": values[c],
"... | [
"def",
"to_json",
"(",
"df",
",",
"values",
")",
":",
"records",
"=",
"[",
"]",
"if",
"df",
".",
"empty",
":",
"return",
"{",
"\"data\"",
":",
"[",
"]",
"}",
"sum_",
"=",
"float",
"(",
"np",
".",
"sum",
"(",
"[",
"df",
"[",
"c",
"]",
".",
"... | Format output for the json response. | [
"Format",
"output",
"for",
"the",
"json",
"response",
"."
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/nvd3/pie_chart.py#L57-L71 | train |
stitchfix/pyxley | pyxley/charts/datamaps/datamaps.py | DatamapUSA.to_json | def to_json(df, state_index, color_index, fills):
"""Transforms dataframe to json response"""
records = {}
for i, row in df.iterrows():
records[row[state_index]] = {
"fillKey": row[color_index]
}
return {
"data": records,
... | python | def to_json(df, state_index, color_index, fills):
"""Transforms dataframe to json response"""
records = {}
for i, row in df.iterrows():
records[row[state_index]] = {
"fillKey": row[color_index]
}
return {
"data": records,
... | [
"def",
"to_json",
"(",
"df",
",",
"state_index",
",",
"color_index",
",",
"fills",
")",
":",
"records",
"=",
"{",
"}",
"for",
"i",
",",
"row",
"in",
"df",
".",
"iterrows",
"(",
")",
":",
"records",
"[",
"row",
"[",
"state_index",
"]",
"]",
"=",
"... | Transforms dataframe to json response | [
"Transforms",
"dataframe",
"to",
"json",
"response"
] | 2dab00022d977d986169cd8a629b3a2f91be893f | https://github.com/stitchfix/pyxley/blob/2dab00022d977d986169cd8a629b3a2f91be893f/pyxley/charts/datamaps/datamaps.py#L123-L135 | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/protocol/paho/client.py | error_string | def error_string(mqtt_errno):
"""Return the error string associated with an mqtt error number."""
if mqtt_errno == MQTT_ERR_SUCCESS:
return "No error."
elif mqtt_errno == MQTT_ERR_NOMEM:
return "Out of memory."
elif mqtt_errno == MQTT_ERR_PROTOCOL:
return "A network protocol erro... | python | def error_string(mqtt_errno):
"""Return the error string associated with an mqtt error number."""
if mqtt_errno == MQTT_ERR_SUCCESS:
return "No error."
elif mqtt_errno == MQTT_ERR_NOMEM:
return "Out of memory."
elif mqtt_errno == MQTT_ERR_PROTOCOL:
return "A network protocol erro... | [
"def",
"error_string",
"(",
"mqtt_errno",
")",
":",
"if",
"mqtt_errno",
"==",
"MQTT_ERR_SUCCESS",
":",
"return",
"\"No error.\"",
"elif",
"mqtt_errno",
"==",
"MQTT_ERR_NOMEM",
":",
"return",
"\"Out of memory.\"",
"elif",
"mqtt_errno",
"==",
"MQTT_ERR_PROTOCOL",
":",
... | Return the error string associated with an mqtt error number. | [
"Return",
"the",
"error",
"string",
"associated",
"with",
"an",
"mqtt",
"error",
"number",
"."
] | f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62 | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L145-L178 | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/protocol/paho/client.py | topic_matches_sub | def topic_matches_sub(sub, topic):
"""Check whether a topic matches a subscription.
For example:
foo/bar would match the subscription foo/# or +/bar
non/matching would not match the subscription non/+/+
"""
result = True
multilevel_wildcard = False
slen = len(sub)
tlen = len(topic... | python | def topic_matches_sub(sub, topic):
"""Check whether a topic matches a subscription.
For example:
foo/bar would match the subscription foo/# or +/bar
non/matching would not match the subscription non/+/+
"""
result = True
multilevel_wildcard = False
slen = len(sub)
tlen = len(topic... | [
"def",
"topic_matches_sub",
"(",
"sub",
",",
"topic",
")",
":",
"result",
"=",
"True",
"multilevel_wildcard",
"=",
"False",
"slen",
"=",
"len",
"(",
"sub",
")",
"tlen",
"=",
"len",
"(",
"topic",
")",
"if",
"slen",
">",
"0",
"and",
"tlen",
">",
"0",
... | Check whether a topic matches a subscription.
For example:
foo/bar would match the subscription foo/# or +/bar
non/matching would not match the subscription non/+/+ | [
"Check",
"whether",
"a",
"topic",
"matches",
"a",
"subscription",
"."
] | f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62 | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L199-L261 | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/protocol/paho/client.py | Client.configIAMCredentials | def configIAMCredentials(self, srcAWSAccessKeyID, srcAWSSecretAccessKey, srcAWSSessionToken):
"""
Make custom settings for IAM credentials for websocket connection
srcAWSAccessKeyID - AWS IAM access key
srcAWSSecretAccessKey - AWS IAM secret key
srcAWSSessionToken - AWS Session T... | python | def configIAMCredentials(self, srcAWSAccessKeyID, srcAWSSecretAccessKey, srcAWSSessionToken):
"""
Make custom settings for IAM credentials for websocket connection
srcAWSAccessKeyID - AWS IAM access key
srcAWSSecretAccessKey - AWS IAM secret key
srcAWSSessionToken - AWS Session T... | [
"def",
"configIAMCredentials",
"(",
"self",
",",
"srcAWSAccessKeyID",
",",
"srcAWSSecretAccessKey",
",",
"srcAWSSessionToken",
")",
":",
"self",
".",
"_AWSAccessKeyIDCustomConfig",
"=",
"srcAWSAccessKeyID",
"self",
".",
"_AWSSecretAccessKeyCustomConfig",
"=",
"srcAWSSecretA... | Make custom settings for IAM credentials for websocket connection
srcAWSAccessKeyID - AWS IAM access key
srcAWSSecretAccessKey - AWS IAM secret key
srcAWSSessionToken - AWS Session Token | [
"Make",
"custom",
"settings",
"for",
"IAM",
"credentials",
"for",
"websocket",
"connection",
"srcAWSAccessKeyID",
"-",
"AWS",
"IAM",
"access",
"key",
"srcAWSSecretAccessKey",
"-",
"AWS",
"IAM",
"secret",
"key",
"srcAWSSessionToken",
"-",
"AWS",
"Session",
"Token"
] | f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62 | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L526-L535 | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/protocol/paho/client.py | Client.loop | def loop(self, timeout=1.0, max_packets=1):
"""Process network events.
This function must be called regularly to ensure communication with the
broker is carried out. It calls select() on the network socket to wait
for network events. If incoming data is present it will then be
p... | python | def loop(self, timeout=1.0, max_packets=1):
"""Process network events.
This function must be called regularly to ensure communication with the
broker is carried out. It calls select() on the network socket to wait
for network events. If incoming data is present it will then be
p... | [
"def",
"loop",
"(",
"self",
",",
"timeout",
"=",
"1.0",
",",
"max_packets",
"=",
"1",
")",
":",
"if",
"timeout",
"<",
"0.0",
":",
"raise",
"ValueError",
"(",
"'Invalid timeout.'",
")",
"self",
".",
"_current_out_packet_mutex",
".",
"acquire",
"(",
")",
"... | Process network events.
This function must be called regularly to ensure communication with the
broker is carried out. It calls select() on the network socket to wait
for network events. If incoming data is present it will then be
processed. Outgoing commands, from e.g. publish(), are n... | [
"Process",
"network",
"events",
"."
] | f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62 | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L842-L913 | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/protocol/paho/client.py | Client.publish | def publish(self, topic, payload=None, qos=0, retain=False):
"""Publish a message on a topic.
This causes a message to be sent to the broker and subsequently from
the broker to any clients subscribing to matching topics.
topic: The topic that the message should be published on.
... | python | def publish(self, topic, payload=None, qos=0, retain=False):
"""Publish a message on a topic.
This causes a message to be sent to the broker and subsequently from
the broker to any clients subscribing to matching topics.
topic: The topic that the message should be published on.
... | [
"def",
"publish",
"(",
"self",
",",
"topic",
",",
"payload",
"=",
"None",
",",
"qos",
"=",
"0",
",",
"retain",
"=",
"False",
")",
":",
"if",
"topic",
"is",
"None",
"or",
"len",
"(",
"topic",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"'Inva... | Publish a message on a topic.
This causes a message to be sent to the broker and subsequently from
the broker to any clients subscribing to matching topics.
topic: The topic that the message should be published on.
payload: The actual message to send. If not given, or set to None a
... | [
"Publish",
"a",
"message",
"on",
"a",
"topic",
"."
] | f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62 | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L915-L1003 | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/protocol/paho/client.py | Client.username_pw_set | def username_pw_set(self, username, password=None):
"""Set a username and optionally a password for broker authentication.
Must be called before connect() to have any effect.
Requires a broker that supports MQTT v3.1.
username: The username to authenticate with. Need have no relationsh... | python | def username_pw_set(self, username, password=None):
"""Set a username and optionally a password for broker authentication.
Must be called before connect() to have any effect.
Requires a broker that supports MQTT v3.1.
username: The username to authenticate with. Need have no relationsh... | [
"def",
"username_pw_set",
"(",
"self",
",",
"username",
",",
"password",
"=",
"None",
")",
":",
"self",
".",
"_username",
"=",
"username",
".",
"encode",
"(",
"'utf-8'",
")",
"self",
".",
"_password",
"=",
"password"
] | Set a username and optionally a password for broker authentication.
Must be called before connect() to have any effect.
Requires a broker that supports MQTT v3.1.
username: The username to authenticate with. Need have no relationship to the client id.
password: The password to authenti... | [
"Set",
"a",
"username",
"and",
"optionally",
"a",
"password",
"for",
"broker",
"authentication",
"."
] | f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62 | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L1005-L1015 | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/protocol/paho/client.py | Client.disconnect | def disconnect(self):
"""Disconnect a connected client from the broker."""
self._state_mutex.acquire()
self._state = mqtt_cs_disconnecting
self._state_mutex.release()
self._backoffCore.stopStableConnectionTimer()
if self._sock is None and self._ssl is None:
... | python | def disconnect(self):
"""Disconnect a connected client from the broker."""
self._state_mutex.acquire()
self._state = mqtt_cs_disconnecting
self._state_mutex.release()
self._backoffCore.stopStableConnectionTimer()
if self._sock is None and self._ssl is None:
... | [
"def",
"disconnect",
"(",
"self",
")",
":",
"self",
".",
"_state_mutex",
".",
"acquire",
"(",
")",
"self",
".",
"_state",
"=",
"mqtt_cs_disconnecting",
"self",
".",
"_state_mutex",
".",
"release",
"(",
")",
"self",
".",
"_backoffCore",
".",
"stopStableConnec... | Disconnect a connected client from the broker. | [
"Disconnect",
"a",
"connected",
"client",
"from",
"the",
"broker",
"."
] | f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62 | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L1017-L1028 | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/protocol/paho/client.py | Client.subscribe | def subscribe(self, topic, qos=0):
"""Subscribe the client to one or more topics.
This function may be called in three different ways:
Simple string and integer
-------------------------
e.g. subscribe("my/topic", 2)
topic: A string specifying the subscription topic to... | python | def subscribe(self, topic, qos=0):
"""Subscribe the client to one or more topics.
This function may be called in three different ways:
Simple string and integer
-------------------------
e.g. subscribe("my/topic", 2)
topic: A string specifying the subscription topic to... | [
"def",
"subscribe",
"(",
"self",
",",
"topic",
",",
"qos",
"=",
"0",
")",
":",
"topic_qos_list",
"=",
"None",
"if",
"isinstance",
"(",
"topic",
",",
"str",
")",
":",
"if",
"qos",
"<",
"0",
"or",
"qos",
">",
"2",
":",
"raise",
"ValueError",
"(",
"... | Subscribe the client to one or more topics.
This function may be called in three different ways:
Simple string and integer
-------------------------
e.g. subscribe("my/topic", 2)
topic: A string specifying the subscription topic to subscribe to.
qos: The desired qualit... | [
"Subscribe",
"the",
"client",
"to",
"one",
"or",
"more",
"topics",
"."
] | f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62 | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L1030-L1101 | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/protocol/paho/client.py | Client.unsubscribe | def unsubscribe(self, topic):
"""Unsubscribe the client from one or more topics.
topic: A single string, or list of strings that are the subscription
topics to unsubscribe from.
Returns a tuple (result, mid), where result is MQTT_ERR_SUCCESS
to indicate success or (MQTT_... | python | def unsubscribe(self, topic):
"""Unsubscribe the client from one or more topics.
topic: A single string, or list of strings that are the subscription
topics to unsubscribe from.
Returns a tuple (result, mid), where result is MQTT_ERR_SUCCESS
to indicate success or (MQTT_... | [
"def",
"unsubscribe",
"(",
"self",
",",
"topic",
")",
":",
"topic_list",
"=",
"None",
"if",
"topic",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Invalid topic.'",
")",
"if",
"isinstance",
"(",
"topic",
",",
"str",
")",
":",
"if",
"len",
"(",
"topi... | Unsubscribe the client from one or more topics.
topic: A single string, or list of strings that are the subscription
topics to unsubscribe from.
Returns a tuple (result, mid), where result is MQTT_ERR_SUCCESS
to indicate success or (MQTT_ERR_NO_CONN, None) if the client is not
... | [
"Unsubscribe",
"the",
"client",
"from",
"one",
"or",
"more",
"topics",
"."
] | f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62 | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L1103-L1139 | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/protocol/paho/client.py | Client.will_set | def will_set(self, topic, payload=None, qos=0, retain=False):
"""Set a Will to be sent by the broker in case the client disconnects unexpectedly.
This must be called before connect() to have any effect.
topic: The topic that the will message should be published on.
payload: The message... | python | def will_set(self, topic, payload=None, qos=0, retain=False):
"""Set a Will to be sent by the broker in case the client disconnects unexpectedly.
This must be called before connect() to have any effect.
topic: The topic that the will message should be published on.
payload: The message... | [
"def",
"will_set",
"(",
"self",
",",
"topic",
",",
"payload",
"=",
"None",
",",
"qos",
"=",
"0",
",",
"retain",
"=",
"False",
")",
":",
"if",
"topic",
"is",
"None",
"or",
"len",
"(",
"topic",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"'Inv... | Set a Will to be sent by the broker in case the client disconnects unexpectedly.
This must be called before connect() to have any effect.
topic: The topic that the will message should be published on.
payload: The message to send as a will. If not given, or set to None a
zero length me... | [
"Set",
"a",
"Will",
"to",
"be",
"sent",
"by",
"the",
"broker",
"in",
"case",
"the",
"client",
"disconnects",
"unexpectedly",
"."
] | f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62 | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L1257-L1293 | train |
aws/aws-iot-device-sdk-python | AWSIoTPythonSDK/core/protocol/paho/client.py | Client.socket | def socket(self):
"""Return the socket or ssl object for this client."""
if self._ssl:
if self._useSecuredWebsocket:
return self._ssl.getSSLSocket()
else:
return self._ssl
else:
return self._sock | python | def socket(self):
"""Return the socket or ssl object for this client."""
if self._ssl:
if self._useSecuredWebsocket:
return self._ssl.getSSLSocket()
else:
return self._ssl
else:
return self._sock | [
"def",
"socket",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ssl",
":",
"if",
"self",
".",
"_useSecuredWebsocket",
":",
"return",
"self",
".",
"_ssl",
".",
"getSSLSocket",
"(",
")",
"else",
":",
"return",
"self",
".",
"_ssl",
"else",
":",
"return",
"... | Return the socket or ssl object for this client. | [
"Return",
"the",
"socket",
"or",
"ssl",
"object",
"for",
"this",
"client",
"."
] | f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62 | https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L1305-L1313 | train |
mcneel/rhino3dm | src/build_python_project.py | createproject | def createproject():
""" compile for the platform we are running on """
os.chdir(build_dir)
if windows_build:
command = 'cmake -A {} -DPYTHON_EXECUTABLE:FILEPATH="{}" ../..'.format("win32" if bitness==32 else "x64", sys.executable)
os.system(command)
if bitness==64:
for l... | python | def createproject():
""" compile for the platform we are running on """
os.chdir(build_dir)
if windows_build:
command = 'cmake -A {} -DPYTHON_EXECUTABLE:FILEPATH="{}" ../..'.format("win32" if bitness==32 else "x64", sys.executable)
os.system(command)
if bitness==64:
for l... | [
"def",
"createproject",
"(",
")",
":",
"os",
".",
"chdir",
"(",
"build_dir",
")",
"if",
"windows_build",
":",
"command",
"=",
"'cmake -A {} -DPYTHON_EXECUTABLE:FILEPATH=\"{}\" ../..'",
".",
"format",
"(",
"\"win32\"",
"if",
"bitness",
"==",
"32",
"else",
"\"x64\""... | compile for the platform we are running on | [
"compile",
"for",
"the",
"platform",
"we",
"are",
"running",
"on"
] | 89e4e46c9a07c4243ea51572de7897e03a4acda2 | https://github.com/mcneel/rhino3dm/blob/89e4e46c9a07c4243ea51572de7897e03a4acda2/src/build_python_project.py#L24-L38 | train |
getsentry/responses | responses.py | RequestsMock.add_passthru | def add_passthru(self, prefix):
"""
Register a URL prefix to passthru any non-matching mock requests to.
For example, to allow any request to 'https://example.com', but require
mocks for the remainder, you would add the prefix as so:
>>> responses.add_passthru('https://example.... | python | def add_passthru(self, prefix):
"""
Register a URL prefix to passthru any non-matching mock requests to.
For example, to allow any request to 'https://example.com', but require
mocks for the remainder, you would add the prefix as so:
>>> responses.add_passthru('https://example.... | [
"def",
"add_passthru",
"(",
"self",
",",
"prefix",
")",
":",
"if",
"_has_unicode",
"(",
"prefix",
")",
":",
"prefix",
"=",
"_clean_unicode",
"(",
"prefix",
")",
"self",
".",
"passthru_prefixes",
"+=",
"(",
"prefix",
",",
")"
] | Register a URL prefix to passthru any non-matching mock requests to.
For example, to allow any request to 'https://example.com', but require
mocks for the remainder, you would add the prefix as so:
>>> responses.add_passthru('https://example.com') | [
"Register",
"a",
"URL",
"prefix",
"to",
"passthru",
"any",
"non",
"-",
"matching",
"mock",
"requests",
"to",
"."
] | b7ab59513ffd52bf28808f45005f492f7d1bbd50 | https://github.com/getsentry/responses/blob/b7ab59513ffd52bf28808f45005f492f7d1bbd50/responses.py#L489-L500 | train |
martinblech/xmltodict | ez_setup.py | _install | def _install(archive_filename, install_args=()):
"""Install Setuptools."""
with archive_context(archive_filename):
# installing
log.warn('Installing Setuptools')
if not _python_cmd('setup.py', 'install', *install_args):
log.warn('Something went wrong during the installation.'... | python | def _install(archive_filename, install_args=()):
"""Install Setuptools."""
with archive_context(archive_filename):
# installing
log.warn('Installing Setuptools')
if not _python_cmd('setup.py', 'install', *install_args):
log.warn('Something went wrong during the installation.'... | [
"def",
"_install",
"(",
"archive_filename",
",",
"install_args",
"=",
"(",
")",
")",
":",
"with",
"archive_context",
"(",
"archive_filename",
")",
":",
"log",
".",
"warn",
"(",
"'Installing Setuptools'",
")",
"if",
"not",
"_python_cmd",
"(",
"'setup.py'",
",",... | Install Setuptools. | [
"Install",
"Setuptools",
"."
] | f3ab7e1740d37d585ffab0154edb4cb664afe4a9 | https://github.com/martinblech/xmltodict/blob/f3ab7e1740d37d585ffab0154edb4cb664afe4a9/ez_setup.py#L57-L66 | train |
martinblech/xmltodict | ez_setup.py | _build_egg | def _build_egg(egg, archive_filename, to_dir):
"""Build Setuptools egg."""
with archive_context(archive_filename):
# building an egg
log.warn('Building a Setuptools egg in %s', to_dir)
_python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
# returning the result
log.war... | python | def _build_egg(egg, archive_filename, to_dir):
"""Build Setuptools egg."""
with archive_context(archive_filename):
# building an egg
log.warn('Building a Setuptools egg in %s', to_dir)
_python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
# returning the result
log.war... | [
"def",
"_build_egg",
"(",
"egg",
",",
"archive_filename",
",",
"to_dir",
")",
":",
"with",
"archive_context",
"(",
"archive_filename",
")",
":",
"log",
".",
"warn",
"(",
"'Building a Setuptools egg in %s'",
",",
"to_dir",
")",
"_python_cmd",
"(",
"'setup.py'",
"... | Build Setuptools egg. | [
"Build",
"Setuptools",
"egg",
"."
] | f3ab7e1740d37d585ffab0154edb4cb664afe4a9 | https://github.com/martinblech/xmltodict/blob/f3ab7e1740d37d585ffab0154edb4cb664afe4a9/ez_setup.py#L69-L78 | train |
martinblech/xmltodict | ez_setup.py | _do_download | def _do_download(version, download_base, to_dir, download_delay):
"""Download Setuptools."""
py_desig = 'py{sys.version_info[0]}.{sys.version_info[1]}'.format(sys=sys)
tp = 'setuptools-{version}-{py_desig}.egg'
egg = os.path.join(to_dir, tp.format(**locals()))
if not os.path.exists(egg):
arc... | python | def _do_download(version, download_base, to_dir, download_delay):
"""Download Setuptools."""
py_desig = 'py{sys.version_info[0]}.{sys.version_info[1]}'.format(sys=sys)
tp = 'setuptools-{version}-{py_desig}.egg'
egg = os.path.join(to_dir, tp.format(**locals()))
if not os.path.exists(egg):
arc... | [
"def",
"_do_download",
"(",
"version",
",",
"download_base",
",",
"to_dir",
",",
"download_delay",
")",
":",
"py_desig",
"=",
"'py{sys.version_info[0]}.{sys.version_info[1]}'",
".",
"format",
"(",
"sys",
"=",
"sys",
")",
"tp",
"=",
"'setuptools-{version}-{py_desig}.eg... | Download Setuptools. | [
"Download",
"Setuptools",
"."
] | f3ab7e1740d37d585ffab0154edb4cb664afe4a9 | https://github.com/martinblech/xmltodict/blob/f3ab7e1740d37d585ffab0154edb4cb664afe4a9/ez_setup.py#L132-L149 | train |
martinblech/xmltodict | ez_setup.py | use_setuptools | def use_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=DEFAULT_SAVE_DIR, download_delay=15):
"""
Ensure that a setuptools version is installed.
Return None. Raise SystemExit if the requested version
or later cannot be installed.
"""
to_dir = os.path.abspa... | python | def use_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=DEFAULT_SAVE_DIR, download_delay=15):
"""
Ensure that a setuptools version is installed.
Return None. Raise SystemExit if the requested version
or later cannot be installed.
"""
to_dir = os.path.abspa... | [
"def",
"use_setuptools",
"(",
"version",
"=",
"DEFAULT_VERSION",
",",
"download_base",
"=",
"DEFAULT_URL",
",",
"to_dir",
"=",
"DEFAULT_SAVE_DIR",
",",
"download_delay",
"=",
"15",
")",
":",
"to_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"to_dir",
")... | Ensure that a setuptools version is installed.
Return None. Raise SystemExit if the requested version
or later cannot be installed. | [
"Ensure",
"that",
"a",
"setuptools",
"version",
"is",
"installed",
"."
] | f3ab7e1740d37d585ffab0154edb4cb664afe4a9 | https://github.com/martinblech/xmltodict/blob/f3ab7e1740d37d585ffab0154edb4cb664afe4a9/ez_setup.py#L152-L188 | train |
martinblech/xmltodict | ez_setup.py | _conflict_bail | def _conflict_bail(VC_err, version):
"""
Setuptools was imported prior to invocation, so it is
unsafe to unload it. Bail out.
"""
conflict_tmpl = textwrap.dedent("""
The required version of setuptools (>={version}) is not available,
and can't be installed while this script is running... | python | def _conflict_bail(VC_err, version):
"""
Setuptools was imported prior to invocation, so it is
unsafe to unload it. Bail out.
"""
conflict_tmpl = textwrap.dedent("""
The required version of setuptools (>={version}) is not available,
and can't be installed while this script is running... | [
"def",
"_conflict_bail",
"(",
"VC_err",
",",
"version",
")",
":",
"conflict_tmpl",
"=",
"textwrap",
".",
"dedent",
"(",
")",
"msg",
"=",
"conflict_tmpl",
".",
"format",
"(",
"**",
"locals",
"(",
")",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"msg",... | Setuptools was imported prior to invocation, so it is
unsafe to unload it. Bail out. | [
"Setuptools",
"was",
"imported",
"prior",
"to",
"invocation",
"so",
"it",
"is",
"unsafe",
"to",
"unload",
"it",
".",
"Bail",
"out",
"."
] | f3ab7e1740d37d585ffab0154edb4cb664afe4a9 | https://github.com/martinblech/xmltodict/blob/f3ab7e1740d37d585ffab0154edb4cb664afe4a9/ez_setup.py#L191-L206 | train |
martinblech/xmltodict | ez_setup.py | download_file_insecure | def download_file_insecure(url, target):
"""Use Python to download the file, without connection authentication."""
src = urlopen(url)
try:
# Read all the data in one block.
data = src.read()
finally:
src.close()
# Write all the data in one block to avoid creating a partial f... | python | def download_file_insecure(url, target):
"""Use Python to download the file, without connection authentication."""
src = urlopen(url)
try:
# Read all the data in one block.
data = src.read()
finally:
src.close()
# Write all the data in one block to avoid creating a partial f... | [
"def",
"download_file_insecure",
"(",
"url",
",",
"target",
")",
":",
"src",
"=",
"urlopen",
"(",
"url",
")",
"try",
":",
"data",
"=",
"src",
".",
"read",
"(",
")",
"finally",
":",
"src",
".",
"close",
"(",
")",
"with",
"open",
"(",
"target",
",",
... | Use Python to download the file, without connection authentication. | [
"Use",
"Python",
"to",
"download",
"the",
"file",
"without",
"connection",
"authentication",
"."
] | f3ab7e1740d37d585ffab0154edb4cb664afe4a9 | https://github.com/martinblech/xmltodict/blob/f3ab7e1740d37d585ffab0154edb4cb664afe4a9/ez_setup.py#L305-L316 | train |
martinblech/xmltodict | ez_setup.py | _download_args | def _download_args(options):
"""Return args for download_setuptools function from cmdline args."""
return dict(
version=options.version,
download_base=options.download_base,
downloader_factory=options.downloader_factory,
to_dir=options.to_dir,
) | python | def _download_args(options):
"""Return args for download_setuptools function from cmdline args."""
return dict(
version=options.version,
download_base=options.download_base,
downloader_factory=options.downloader_factory,
to_dir=options.to_dir,
) | [
"def",
"_download_args",
"(",
"options",
")",
":",
"return",
"dict",
"(",
"version",
"=",
"options",
".",
"version",
",",
"download_base",
"=",
"options",
".",
"download_base",
",",
"downloader_factory",
"=",
"options",
".",
"downloader_factory",
",",
"to_dir",
... | Return args for download_setuptools function from cmdline args. | [
"Return",
"args",
"for",
"download_setuptools",
"function",
"from",
"cmdline",
"args",
"."
] | f3ab7e1740d37d585ffab0154edb4cb664afe4a9 | https://github.com/martinblech/xmltodict/blob/f3ab7e1740d37d585ffab0154edb4cb664afe4a9/ez_setup.py#L397-L404 | train |
martinblech/xmltodict | ez_setup.py | main | def main():
"""Install or upgrade setuptools and EasyInstall."""
options = _parse_args()
archive = download_setuptools(**_download_args(options))
return _install(archive, _build_install_args(options)) | python | def main():
"""Install or upgrade setuptools and EasyInstall."""
options = _parse_args()
archive = download_setuptools(**_download_args(options))
return _install(archive, _build_install_args(options)) | [
"def",
"main",
"(",
")",
":",
"options",
"=",
"_parse_args",
"(",
")",
"archive",
"=",
"download_setuptools",
"(",
"**",
"_download_args",
"(",
"options",
")",
")",
"return",
"_install",
"(",
"archive",
",",
"_build_install_args",
"(",
"options",
")",
")"
] | Install or upgrade setuptools and EasyInstall. | [
"Install",
"or",
"upgrade",
"setuptools",
"and",
"EasyInstall",
"."
] | f3ab7e1740d37d585ffab0154edb4cb664afe4a9 | https://github.com/martinblech/xmltodict/blob/f3ab7e1740d37d585ffab0154edb4cb664afe4a9/ez_setup.py#L407-L411 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.registerContract | def registerContract(self, contract):
""" used for when callback receives a contract
that isn't found in local database """
if contract.m_exchange == "":
return
"""
if contract not in self.contracts.values():
contract_tuple = self.contract_to_tuple(contr... | python | def registerContract(self, contract):
""" used for when callback receives a contract
that isn't found in local database """
if contract.m_exchange == "":
return
"""
if contract not in self.contracts.values():
contract_tuple = self.contract_to_tuple(contr... | [
"def",
"registerContract",
"(",
"self",
",",
"contract",
")",
":",
"if",
"contract",
".",
"m_exchange",
"==",
"\"\"",
":",
"return",
"if",
"self",
".",
"getConId",
"(",
"contract",
")",
"==",
"0",
":",
"contract_tuple",
"=",
"self",
".",
"contract_to_tuple... | used for when callback receives a contract
that isn't found in local database | [
"used",
"for",
"when",
"callback",
"receives",
"a",
"contract",
"that",
"isn",
"t",
"found",
"in",
"local",
"database"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L245-L264 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.handleErrorEvents | def handleErrorEvents(self, msg):
""" logs error messages """
# https://www.interactivebrokers.com/en/software/api/apiguide/tables/api_message_codes.htm
if msg.errorCode is not None and msg.errorCode != -1 and \
msg.errorCode not in dataTypes["BENIGN_ERROR_CODES"]:
l... | python | def handleErrorEvents(self, msg):
""" logs error messages """
# https://www.interactivebrokers.com/en/software/api/apiguide/tables/api_message_codes.htm
if msg.errorCode is not None and msg.errorCode != -1 and \
msg.errorCode not in dataTypes["BENIGN_ERROR_CODES"]:
l... | [
"def",
"handleErrorEvents",
"(",
"self",
",",
"msg",
")",
":",
"if",
"msg",
".",
"errorCode",
"is",
"not",
"None",
"and",
"msg",
".",
"errorCode",
"!=",
"-",
"1",
"and",
"msg",
".",
"errorCode",
"not",
"in",
"dataTypes",
"[",
"\"BENIGN_ERROR_CODES\"",
"]... | logs error messages | [
"logs",
"error",
"messages"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L269-L286 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.handleServerEvents | def handleServerEvents(self, msg):
""" dispatch msg to the right handler """
self.log.debug('MSG %s', msg)
self.handleConnectionState(msg)
if msg.typeName == "error":
self.handleErrorEvents(msg)
elif msg.typeName == dataTypes["MSG_CURRENT_TIME"]:
if sel... | python | def handleServerEvents(self, msg):
""" dispatch msg to the right handler """
self.log.debug('MSG %s', msg)
self.handleConnectionState(msg)
if msg.typeName == "error":
self.handleErrorEvents(msg)
elif msg.typeName == dataTypes["MSG_CURRENT_TIME"]:
if sel... | [
"def",
"handleServerEvents",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'MSG %s'",
",",
"msg",
")",
"self",
".",
"handleConnectionState",
"(",
"msg",
")",
"if",
"msg",
".",
"typeName",
"==",
"\"error\"",
":",
"self",
"."... | dispatch msg to the right handler | [
"dispatch",
"msg",
"to",
"the",
"right",
"handler"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L289-L361 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.handleContractDetails | def handleContractDetails(self, msg, end=False):
""" handles contractDetails and contractDetailsEnd """
if end:
# mark as downloaded
self._contract_details[msg.reqId]['downloaded'] = True
# move details from temp to permanent collector
self.contract_deta... | python | def handleContractDetails(self, msg, end=False):
""" handles contractDetails and contractDetailsEnd """
if end:
# mark as downloaded
self._contract_details[msg.reqId]['downloaded'] = True
# move details from temp to permanent collector
self.contract_deta... | [
"def",
"handleContractDetails",
"(",
"self",
",",
"msg",
",",
"end",
"=",
"False",
")",
":",
"if",
"end",
":",
"self",
".",
"_contract_details",
"[",
"msg",
".",
"reqId",
"]",
"[",
"'downloaded'",
"]",
"=",
"True",
"self",
".",
"contract_details",
"[",
... | handles contractDetails and contractDetailsEnd | [
"handles",
"contractDetails",
"and",
"contractDetailsEnd"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L411-L487 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.handlePosition | def handlePosition(self, msg):
""" handle positions changes """
# log handler msg
self.log_msg("position", msg)
# contract identifier
contract_tuple = self.contract_to_tuple(msg.contract)
contractString = self.contractString(contract_tuple)
# try creating the c... | python | def handlePosition(self, msg):
""" handle positions changes """
# log handler msg
self.log_msg("position", msg)
# contract identifier
contract_tuple = self.contract_to_tuple(msg.contract)
contractString = self.contractString(contract_tuple)
# try creating the c... | [
"def",
"handlePosition",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"log_msg",
"(",
"\"position\"",
",",
"msg",
")",
"contract_tuple",
"=",
"self",
".",
"contract_to_tuple",
"(",
"msg",
".",
"contract",
")",
"contractString",
"=",
"self",
".",
"contra... | handle positions changes | [
"handle",
"positions",
"changes"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L553-L579 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.handlePortfolio | def handlePortfolio(self, msg):
""" handle portfolio updates """
# log handler msg
self.log_msg("portfolio", msg)
# contract identifier
contract_tuple = self.contract_to_tuple(msg.contract)
contractString = self.contractString(contract_tuple)
# try creating the... | python | def handlePortfolio(self, msg):
""" handle portfolio updates """
# log handler msg
self.log_msg("portfolio", msg)
# contract identifier
contract_tuple = self.contract_to_tuple(msg.contract)
contractString = self.contractString(contract_tuple)
# try creating the... | [
"def",
"handlePortfolio",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"log_msg",
"(",
"\"portfolio\"",
",",
"msg",
")",
"contract_tuple",
"=",
"self",
".",
"contract_to_tuple",
"(",
"msg",
".",
"contract",
")",
"contractString",
"=",
"self",
".",
"cont... | handle portfolio updates | [
"handle",
"portfolio",
"updates"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L600-L630 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.handleOrders | def handleOrders(self, msg):
""" handle order open & status """
"""
It is possible that orderStatus() may return duplicate messages.
It is essential that you filter the message accordingly.
"""
# log handler msg
self.log_msg("order", msg)
# get server ti... | python | def handleOrders(self, msg):
""" handle order open & status """
"""
It is possible that orderStatus() may return duplicate messages.
It is essential that you filter the message accordingly.
"""
# log handler msg
self.log_msg("order", msg)
# get server ti... | [
"def",
"handleOrders",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"log_msg",
"(",
"\"order\"",
",",
"msg",
")",
"self",
".",
"getServerTime",
"(",
")",
"time",
".",
"sleep",
"(",
"0.001",
")",
"duplicateMessage",
"=",
"False",
"if",
"msg",
".",
... | handle order open & status | [
"handle",
"order",
"open",
"&",
"status"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L655-L727 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.createTriggerableTrailingStop | def createTriggerableTrailingStop(self, symbol, quantity=1,
triggerPrice=0, trailPercent=100., trailAmount=0.,
parentId=0, stopOrderId=None, **kwargs):
""" adds order to triggerable list """
ticksize = self.contractDetails(symbol)["m_minTick"]
self.triggerableTrailingSt... | python | def createTriggerableTrailingStop(self, symbol, quantity=1,
triggerPrice=0, trailPercent=100., trailAmount=0.,
parentId=0, stopOrderId=None, **kwargs):
""" adds order to triggerable list """
ticksize = self.contractDetails(symbol)["m_minTick"]
self.triggerableTrailingSt... | [
"def",
"createTriggerableTrailingStop",
"(",
"self",
",",
"symbol",
",",
"quantity",
"=",
"1",
",",
"triggerPrice",
"=",
"0",
",",
"trailPercent",
"=",
"100.",
",",
"trailAmount",
"=",
"0.",
",",
"parentId",
"=",
"0",
",",
"stopOrderId",
"=",
"None",
",",
... | adds order to triggerable list | [
"adds",
"order",
"to",
"triggerable",
"list"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1101-L1118 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.registerTrailingStop | def registerTrailingStop(self, tickerId, orderId=0, quantity=1,
lastPrice=0, trailPercent=100., trailAmount=0., parentId=0, **kwargs):
""" adds trailing stop to monitor list """
ticksize = self.contractDetails(tickerId)["m_minTick"]
trailingStop = self.trailingStops[tickerId] = {
... | python | def registerTrailingStop(self, tickerId, orderId=0, quantity=1,
lastPrice=0, trailPercent=100., trailAmount=0., parentId=0, **kwargs):
""" adds trailing stop to monitor list """
ticksize = self.contractDetails(tickerId)["m_minTick"]
trailingStop = self.trailingStops[tickerId] = {
... | [
"def",
"registerTrailingStop",
"(",
"self",
",",
"tickerId",
",",
"orderId",
"=",
"0",
",",
"quantity",
"=",
"1",
",",
"lastPrice",
"=",
"0",
",",
"trailPercent",
"=",
"100.",
",",
"trailAmount",
"=",
"0.",
",",
"parentId",
"=",
"0",
",",
"**",
"kwargs... | adds trailing stop to monitor list | [
"adds",
"trailing",
"stop",
"to",
"monitor",
"list"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1121-L1137 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.modifyStopOrder | def modifyStopOrder(self, orderId, parentId, newStop, quantity,
transmit=True, account=None):
""" modify stop order """
if orderId in self.orders.keys():
order = self.createStopOrder(
quantity = quantity,
parentId = parentId,
... | python | def modifyStopOrder(self, orderId, parentId, newStop, quantity,
transmit=True, account=None):
""" modify stop order """
if orderId in self.orders.keys():
order = self.createStopOrder(
quantity = quantity,
parentId = parentId,
... | [
"def",
"modifyStopOrder",
"(",
"self",
",",
"orderId",
",",
"parentId",
",",
"newStop",
",",
"quantity",
",",
"transmit",
"=",
"True",
",",
"account",
"=",
"None",
")",
":",
"if",
"orderId",
"in",
"self",
".",
"orders",
".",
"keys",
"(",
")",
":",
"o... | modify stop order | [
"modify",
"stop",
"order"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1140-L1154 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.handleTrailingStops | def handleTrailingStops(self, tickerId):
""" software-based trailing stop """
# existing?
if tickerId not in self.trailingStops.keys():
return None
# continue
trailingStop = self.trailingStops[tickerId]
price = self.marketData[tickerId]['last'][0]... | python | def handleTrailingStops(self, tickerId):
""" software-based trailing stop """
# existing?
if tickerId not in self.trailingStops.keys():
return None
# continue
trailingStop = self.trailingStops[tickerId]
price = self.marketData[tickerId]['last'][0]... | [
"def",
"handleTrailingStops",
"(",
"self",
",",
"tickerId",
")",
":",
"if",
"tickerId",
"not",
"in",
"self",
".",
"trailingStops",
".",
"keys",
"(",
")",
":",
"return",
"None",
"trailingStop",
"=",
"self",
".",
"trailingStops",
"[",
"tickerId",
"]",
"price... | software-based trailing stop | [
"software",
"-",
"based",
"trailing",
"stop"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1157-L1214 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.triggerTrailingStops | def triggerTrailingStops(self, tickerId):
""" trigger waiting trailing stops """
# print('.')
# test
symbol = self.tickerSymbol(tickerId)
price = self.marketData[tickerId]['last'][0]
# contract = self.contracts[tickerId]
if symbol in self.triggerableTrailingStop... | python | def triggerTrailingStops(self, tickerId):
""" trigger waiting trailing stops """
# print('.')
# test
symbol = self.tickerSymbol(tickerId)
price = self.marketData[tickerId]['last'][0]
# contract = self.contracts[tickerId]
if symbol in self.triggerableTrailingStop... | [
"def",
"triggerTrailingStops",
"(",
"self",
",",
"tickerId",
")",
":",
"symbol",
"=",
"self",
".",
"tickerSymbol",
"(",
"tickerId",
")",
"price",
"=",
"self",
".",
"marketData",
"[",
"tickerId",
"]",
"[",
"'last'",
"]",
"[",
"0",
"]",
"if",
"symbol",
"... | trigger waiting trailing stops | [
"trigger",
"waiting",
"trailing",
"stops"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1217-L1299 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.tickerId | def tickerId(self, contract_identifier):
"""
returns the tickerId for the symbol or
sets one if it doesn't exits
"""
# contract passed instead of symbol?
symbol = contract_identifier
if isinstance(symbol, Contract):
symbol = self.contractString(symbol)... | python | def tickerId(self, contract_identifier):
"""
returns the tickerId for the symbol or
sets one if it doesn't exits
"""
# contract passed instead of symbol?
symbol = contract_identifier
if isinstance(symbol, Contract):
symbol = self.contractString(symbol)... | [
"def",
"tickerId",
"(",
"self",
",",
"contract_identifier",
")",
":",
"symbol",
"=",
"contract_identifier",
"if",
"isinstance",
"(",
"symbol",
",",
"Contract",
")",
":",
"symbol",
"=",
"self",
".",
"contractString",
"(",
"symbol",
")",
"for",
"tickerId",
"in... | returns the tickerId for the symbol or
sets one if it doesn't exits | [
"returns",
"the",
"tickerId",
"for",
"the",
"symbol",
"or",
"sets",
"one",
"if",
"it",
"doesn",
"t",
"exits"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1304-L1320 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.createTargetOrder | def createTargetOrder(self, quantity, parentId=0,
target=0., orderType=None, transmit=True, group=None, tif="DAY",
rth=False, account=None):
""" Creates TARGET order """
order = self.createOrder(quantity,
price = target,
transmit = tra... | python | def createTargetOrder(self, quantity, parentId=0,
target=0., orderType=None, transmit=True, group=None, tif="DAY",
rth=False, account=None):
""" Creates TARGET order """
order = self.createOrder(quantity,
price = target,
transmit = tra... | [
"def",
"createTargetOrder",
"(",
"self",
",",
"quantity",
",",
"parentId",
"=",
"0",
",",
"target",
"=",
"0.",
",",
"orderType",
"=",
"None",
",",
"transmit",
"=",
"True",
",",
"group",
"=",
"None",
",",
"tif",
"=",
"\"DAY\"",
",",
"rth",
"=",
"False... | Creates TARGET order | [
"Creates",
"TARGET",
"order"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1598-L1612 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.createStopOrder | def createStopOrder(self, quantity, parentId=0, stop=0., trail=None,
transmit=True, group=None, stop_limit=False, rth=False, tif="DAY",
account=None):
""" Creates STOP order """
if trail:
if trail == "percent":
order = self.createOrder(quantity,
... | python | def createStopOrder(self, quantity, parentId=0, stop=0., trail=None,
transmit=True, group=None, stop_limit=False, rth=False, tif="DAY",
account=None):
""" Creates STOP order """
if trail:
if trail == "percent":
order = self.createOrder(quantity,
... | [
"def",
"createStopOrder",
"(",
"self",
",",
"quantity",
",",
"parentId",
"=",
"0",
",",
"stop",
"=",
"0.",
",",
"trail",
"=",
"None",
",",
"transmit",
"=",
"True",
",",
"group",
"=",
"None",
",",
"stop_limit",
"=",
"False",
",",
"rth",
"=",
"False",
... | Creates STOP order | [
"Creates",
"STOP",
"order"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1615-L1657 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.createTrailingStopOrder | def createTrailingStopOrder(self, contract, quantity,
parentId=0, trailPercent=100., group=None, triggerPrice=None,
account=None):
""" convert hard stop order to trailing stop order """
if parentId not in self.orders:
raise ValueError("Order #" + str(parentId) + " do... | python | def createTrailingStopOrder(self, contract, quantity,
parentId=0, trailPercent=100., group=None, triggerPrice=None,
account=None):
""" convert hard stop order to trailing stop order """
if parentId not in self.orders:
raise ValueError("Order #" + str(parentId) + " do... | [
"def",
"createTrailingStopOrder",
"(",
"self",
",",
"contract",
",",
"quantity",
",",
"parentId",
"=",
"0",
",",
"trailPercent",
"=",
"100.",
",",
"group",
"=",
"None",
",",
"triggerPrice",
"=",
"None",
",",
"account",
"=",
"None",
")",
":",
"if",
"paren... | convert hard stop order to trailing stop order | [
"convert",
"hard",
"stop",
"order",
"to",
"trailing",
"stop",
"order"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1660-L1678 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.placeOrder | def placeOrder(self, contract, order, orderId=None, account=None):
""" Place order on IB TWS """
# get latest order id before submitting an order
self.requestOrderIds()
# continue...
useOrderId = self.orderId if orderId == None else orderId
if account:
order... | python | def placeOrder(self, contract, order, orderId=None, account=None):
""" Place order on IB TWS """
# get latest order id before submitting an order
self.requestOrderIds()
# continue...
useOrderId = self.orderId if orderId == None else orderId
if account:
order... | [
"def",
"placeOrder",
"(",
"self",
",",
"contract",
",",
"order",
",",
"orderId",
"=",
"None",
",",
"account",
"=",
"None",
")",
":",
"self",
".",
"requestOrderIds",
"(",
")",
"useOrderId",
"=",
"self",
".",
"orderId",
"if",
"orderId",
"==",
"None",
"el... | Place order on IB TWS | [
"Place",
"order",
"on",
"IB",
"TWS"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1750-L1778 | train |
ranaroussi/ezibpy | ezibpy/ezibpy.py | ezIBpy.cancelOrder | def cancelOrder(self, orderId):
""" cancel order on IB TWS """
self.ibConn.cancelOrder(orderId)
# update order id for next time
self.requestOrderIds()
return orderId | python | def cancelOrder(self, orderId):
""" cancel order on IB TWS """
self.ibConn.cancelOrder(orderId)
# update order id for next time
self.requestOrderIds()
return orderId | [
"def",
"cancelOrder",
"(",
"self",
",",
"orderId",
")",
":",
"self",
".",
"ibConn",
".",
"cancelOrder",
"(",
"orderId",
")",
"self",
".",
"requestOrderIds",
"(",
")",
"return",
"orderId"
] | cancel order on IB TWS | [
"cancel",
"order",
"on",
"IB",
"TWS"
] | 1a9d4bf52018abd2a01af7c991d7cf00cda53e0c | https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/ezibpy.py#L1781-L1787 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.