signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
def _getCharacterMapping(self): | layer = self.defaultLayer<EOL>return layer.getCharacterMapping()<EOL> | This is the environment implementation of
:meth:`BaseFont.getCharacterMapping`.
Subclasses may override this method. | f10854:c0:m87 |
def _get_selectedLayers(self): | return self._getSelectedSubObjects(self.layers)<EOL> | Subclasses may override this method. | f10854:c0:m89 |
def _set_selectedLayers(self, value): | return self._setSelectedSubObjects(self.layers, value)<EOL> | Subclasses may override this method. | f10854:c0:m91 |
def _get_selectedLayerNames(self): | selected = [layer.name for layer in self.selectedLayers]<EOL>return selected<EOL> | Subclasses may override this method. | f10854:c0:m93 |
def _set_selectedLayerNames(self, value): | select = [self.layers(name) for name in value]<EOL>self.selectedLayers = select<EOL> | Subclasses may override this method. | f10854:c0:m95 |
def _get_selectedGuidelines(self): | return self._getSelectedSubObjects(self.guidelines)<EOL> | Subclasses may override this method. | f10854:c0:m97 |
def _set_selectedGuidelines(self, value): | return self._setSelectedSubObjects(self.guidelines, value)<EOL> | Subclasses may override this method. | f10854:c0:m99 |
def _get_x(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseGuideline.x`. This must return an
:ref:`type-int-float`.
Subclasses must override this method. | f10855:c0:m8 |
def _set_x(self, value): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseGuideline.x`. **value** will be
an :ref:`type-int-float`.
Subclasses must override this method. | f10855:c0:m9 |
def _get_y(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseGuideline.y`. This must return an
:ref:`type-int-float`.
Subclasses must override this method. | f10855:c0:m12 |
def _set_y(self, value): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseGuideline.y`. **value** will be
an :ref:`type-int-float`.
Subclasses must override this method. | f10855:c0:m13 |
def _get_angle(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseGuideline.angle`. This must return an
:ref:`type-angle`.
Subclasses must override this method. | f10855:c0:m16 |
def _set_angle(self, value): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseGuideline.angle`. **value** will be
an :ref:`type-angle`.
Subclasses must override this method. | f10855:c0:m17 |
def _get_index(self): | glyph = self.glyph<EOL>if glyph is not None:<EOL><INDENT>parent = glyph<EOL><DEDENT>else:<EOL><INDENT>parent = self.font<EOL><DEDENT>if parent is None:<EOL><INDENT>return None<EOL><DEDENT>return parent.guidelines.index(self)<EOL> | Get the guideline's index.
This must return an ``int``.
Subclasses may override this method. | f10855:c0:m19 |
def _get_name(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseGuideline.name`. This must return a
:ref:`type-string` or ``None``. The returned
value will be normalized with
:func:`normalizers.normalizeGuidelineName`.
Subclasses must override this method. | f10855:c0:m22 |
def _set_name(self, value): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseGuideline.name`. **value** will be
a :ref:`type-string` or ``None``. It will
have been normalized with
:func:`normalizers.normalizeGuidelineName`.
Subclasses must override this method. | f10855:c0:m23 |
def _get_color(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseGuideline.color`. This must return
a :ref:`type-color` or ``None``. The
returned value will be normalized with
:func:`normalizers.normalizeColor`.
Subclasses must override this method. | f10855:c0:m26 |
def _set_color(self, value): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseGuideline.color`. **value** will
be a :ref:`type-color` or ``None``.
It will have been normalized with
:func:`normalizers.normalizeColor`.
Subclasses must override this method. | f10855:c0:m27 |
def _transformBy(self, matrix, **kwargs): | t = transform.Transform(*matrix)<EOL>x, y = t.transformPoint((self.x, self.y))<EOL>self.x = x<EOL>self.y = y<EOL>angle = math.radians(-self.angle)<EOL>dx = math.cos(angle)<EOL>dy = math.sin(angle)<EOL>tdx, tdy = t.transformPoint((dx, dy))<EOL>ta = math.atan2(tdy - t[<NUM_LIT:5>], tdx - t[<NUM_LIT:4>])<EOL>self.angle = ... | This is the environment implementation of
:meth:`BaseGuideline.transformBy`.
**matrix** will be a :ref:`type-transformation`.
that has been normalized with :func:`normalizers.normalizeTransformationMatrix`.
Subclasses may override this method. | f10855:c0:m28 |
def isCompatible(self, other): | return super(BaseGuideline, self).isCompatible(other, BaseGuideline)<EOL> | Evaluate interpolation compatibility with **other**. ::
>>> compatible, report = self.isCompatible(otherGuideline)
>>> compatible
True
>>> compatible
[Warning] Guideline: "xheight" + "cap_height"
[Warning] Guideline: "xheight" has name xheight | "cap_height" has
name c... | f10855:c0:m29 |
def _isCompatible(self, other, reporter): | guideline1 = self<EOL>guideline2 = other<EOL>if guideline1.name != guideline2.name:<EOL><INDENT>reporter.nameDifference = True<EOL>reporter.warning = True<EOL><DEDENT> | This is the environment implementation of
:meth:`BaseGuideline.isCompatible`.
Subclasses may override this method. | f10855:c0:m30 |
def round(self): | self._round()<EOL> | Round the guideline's coordinate.
>>> guideline.round()
This applies to the following:
* x
* y
It does not apply to
* angle | f10855:c0:m31 |
def _round(self, **kwargs): | self.x = normalizers.normalizeRounding(self.x)<EOL>self.y = normalizers.normalizeRounding(self.y)<EOL> | This is the environment implementation of
:meth:`BaseGuideline.round`.
Subclasses may override this method. | f10855:c0:m32 |
def __eq__(self, other): | if isinstance(other, self.__class__):<EOL><INDENT>return self.points == other.points<EOL><DEDENT>return NotImplemented<EOL> | The :meth:`BaseObject.__eq__` method can't be used here
because the :class:`BaseContour` implementation contructs
segment objects without assigning an underlying ``naked``
object. Therefore, comparisons will always fail. This
method overrides the base method and compares the
:class:`BasePoint` contained by the segment.... | f10856:c0:m7 |
def _get_index(self): | contour = self.contour<EOL>value = contour.segments.index(self)<EOL>return value<EOL> | Subclasses may override this method. | f10856:c0:m9 |
def _get_type(self): | value = self.onCurve.type<EOL>return value<EOL> | Subclasses may override this method. | f10856:c0:m12 |
def _set_type(self, newType): | oldType = self.type<EOL>if oldType == newType:<EOL><INDENT>return<EOL><DEDENT>contour = self.contour<EOL>if contour is None:<EOL><INDENT>raise FontPartsError("<STR_LIT>")<EOL><DEDENT>if newType in ("<STR_LIT>", "<STR_LIT>") and oldType in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>pass<EOL><DEDENT>elif newType not in ("<S... | Subclasses may override this method. | f10856:c0:m13 |
def _get_smooth(self): | return self.onCurve.smooth<EOL> | Subclasses may override this method. | f10856:c0:m16 |
def _set_smooth(self, value): | self.onCurve.smooth = value<EOL> | Subclasses may override this method. | f10856:c0:m17 |
def _getItem(self, index): | return self.points[index]<EOL> | Subclasses may override this method. | f10856:c0:m19 |
def _iterPoints(self, **kwargs): | points = self.points<EOL>count = len(points)<EOL>index = <NUM_LIT:0><EOL>while count:<EOL><INDENT>yield points[index]<EOL>count -= <NUM_LIT:1><EOL>index += <NUM_LIT:1><EOL><DEDENT> | Subclasses may override this method. | f10856:c0:m21 |
def _len(self, **kwargs): | return len(self.points)<EOL> | Subclasses may override this method. | f10856:c0:m23 |
def _get_points(self): | if not hasattr(self, "<STR_LIT>"):<EOL><INDENT>return tuple()<EOL><DEDENT>return tuple(self._points)<EOL> | Subclasses may override this method. | f10856:c0:m25 |
def _get_onCurve(self): | return self.points[-<NUM_LIT:1>]<EOL> | Subclasses may override this method. | f10856:c0:m27 |
def _get_base_offCurve(self): | return self._get_offCurve()<EOL> | Subclasses may override this method. | f10856:c0:m28 |
def _get_offCurve(self): | return self.points[:-<NUM_LIT:1>]<EOL> | Subclasses may override this method. | f10856:c0:m29 |
def _transformBy(self, matrix, **kwargs): | for point in self.points:<EOL><INDENT>point.transformBy(matrix)<EOL><DEDENT> | Subclasses may override this method. | f10856:c0:m30 |
def isCompatible(self, other): | return super(BaseSegment, self).isCompatible(other, BaseSegment)<EOL> | Evaluate interpolation compatibility with **other**. ::
>>> compatible, report = self.isCompatible(otherSegment)
>>> compatible
False
>>> compatible
[Fatal] Segment: [0] + [0]
[Fatal] Segment: [0] is line | [0] is move
[Fatal] Segment: [1] + [1]
[Fatal] Segment: [1] is line | [1] is qcu... | f10856:c0:m31 |
def _isCompatible(self, other, reporter): | segment1 = self<EOL>segment2 = other<EOL>if segment1.type != segment2.type:<EOL><INDENT>if set((segment1.type, segment2.type)) != set(("<STR_LIT>", "<STR_LIT>")):<EOL><INDENT>reporter.typeDifference = True<EOL>reporter.fatal = True<EOL><DEDENT><DEDENT> | This is the environment implementation of
:meth:`BaseSegment.isCompatible`.
Subclasses may override this method. | f10856:c0:m32 |
def round(self): | for point in self.points:<EOL><INDENT>point.round()<EOL><DEDENT> | Round coordinates in all points. | f10856:c0:m33 |
def relativeBCPIn(anchor, BCPIn): | return (BCPIn[<NUM_LIT:0>] - anchor[<NUM_LIT:0>], BCPIn[<NUM_LIT:1>] - anchor[<NUM_LIT:1>])<EOL> | convert absolute incoming bcp value to a relative value | f10857:m0 |
def absoluteBCPIn(anchor, BCPIn): | return (BCPIn[<NUM_LIT:0>] + anchor[<NUM_LIT:0>], BCPIn[<NUM_LIT:1>] + anchor[<NUM_LIT:1>])<EOL> | convert relative incoming bcp value to an absolute value | f10857:m1 |
def relativeBCPOut(anchor, BCPOut): | return (BCPOut[<NUM_LIT:0>] - anchor[<NUM_LIT:0>], BCPOut[<NUM_LIT:1>] - anchor[<NUM_LIT:1>])<EOL> | convert absolute outgoing bcp value to a relative value | f10857:m2 |
def absoluteBCPOut(anchor, BCPOut): | return (BCPOut[<NUM_LIT:0>] + anchor[<NUM_LIT:0>], BCPOut[<NUM_LIT:1>] + anchor[<NUM_LIT:1>])<EOL> | convert relative outgoing bcp value to an absolute value | f10857:m3 |
def _get_identifier(self): | return self._point.identifier<EOL> | Subclasses may override this method. | f10857:c0:m3 |
def _getIdentifier(self): | return self._point.getIdentifier()<EOL> | Subclasses may override this method. | f10857:c0:m4 |
def _get_anchor(self): | point = self._point<EOL>return (point.x, point.y)<EOL> | Subclasses may override this method. | f10857:c0:m14 |
def _set_anchor(self, value): | pX, pY = self.anchor<EOL>x, y = value<EOL>dX = x - pX<EOL>dY = y - pY<EOL>self.moveBy((dX, dY))<EOL> | Subclasses may override this method. | f10857:c0:m15 |
def _get_bcpIn(self): | segment = self._segment<EOL>offCurves = segment.offCurve<EOL>if offCurves:<EOL><INDENT>bcp = offCurves[-<NUM_LIT:1>]<EOL>x, y = relativeBCPIn(self.anchor, (bcp.x, bcp.y))<EOL><DEDENT>else:<EOL><INDENT>x = y = <NUM_LIT:0><EOL><DEDENT>return (x, y)<EOL> | Subclasses may override this method. | f10857:c0:m18 |
def _set_bcpIn(self, value): | x, y = absoluteBCPIn(self.anchor, value)<EOL>segment = self._segment<EOL>if segment.type == "<STR_LIT>" and value != (<NUM_LIT:0>, <NUM_LIT:0>):<EOL><INDENT>raise FontPartsError(("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>)<EOL><DEDENT>else:<EOL><INDENT>offCurves = segment.offCurve<EOL>if offCurves:<EOL><INDENT>if value == (<NUM... | Subclasses may override this method. | f10857:c0:m19 |
def _get_bcpOut(self): | nextSegment = self._nextSegment<EOL>offCurves = nextSegment.offCurve<EOL>if offCurves:<EOL><INDENT>bcp = offCurves[<NUM_LIT:0>]<EOL>x, y = relativeBCPOut(self.anchor, (bcp.x, bcp.y))<EOL><DEDENT>else:<EOL><INDENT>x = y = <NUM_LIT:0><EOL><DEDENT>return (x, y)<EOL> | Subclasses may override this method. | f10857:c0:m22 |
def _set_bcpOut(self, value): | x, y = absoluteBCPOut(self.anchor, value)<EOL>segment = self._segment<EOL>nextSegment = self._nextSegment<EOL>if nextSegment.type == "<STR_LIT>" and value != (<NUM_LIT:0>, <NUM_LIT:0>):<EOL><INDENT>raise FontPartsError(("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>)<EOL><DEDENT>else:<EOL><INDENT>offCurves = nextSegment.offCurve<EO... | Subclasses may override this method. | f10857:c0:m23 |
def _get_type(self): | point = self._point<EOL>typ = point.type<EOL>bType = None<EOL>if point.smooth:<EOL><INDENT>if typ == "<STR_LIT>":<EOL><INDENT>bType = "<STR_LIT>"<EOL><DEDENT>elif typ == "<STR_LIT>":<EOL><INDENT>nextSegment = self._nextSegment<EOL>if nextSegment is not None and nextSegment.type == "<STR_LIT>":<EOL><INDENT>bType = "<STR... | Subclasses may override this method. | f10857:c0:m26 |
def _set_type(self, value): | point = self._point<EOL>if value == "<STR_LIT>" and point.type == "<STR_LIT>":<EOL><INDENT>segment = self._segment<EOL>segment.type = "<STR_LIT>"<EOL>segment.smooth = True<EOL><DEDENT>elif value == "<STR_LIT>" and point.type == "<STR_LIT>":<EOL><INDENT>point.smooth = False<EOL><DEDENT> | Subclasses may override this method. | f10857:c0:m27 |
def _get_index(self): | contour = self.contour<EOL>value = contour.bPoints.index(self)<EOL>return value<EOL> | Subclasses may override this method. | f10857:c0:m29 |
def _transformBy(self, matrix, **kwargs): | anchor = self.anchor<EOL>bcpIn = absoluteBCPIn(anchor, self.bcpIn)<EOL>bcpOut = absoluteBCPOut(anchor, self.bcpOut)<EOL>points = [bcpIn, anchor, bcpOut]<EOL>t = transform.Transform(*matrix)<EOL>bcpIn, anchor, bcpOut = t.transformPoints(points)<EOL>x, y = anchor<EOL>self._point.x = x<EOL>self._point.y = y<EOL>self.bcpIn... | Subclasses may override this method. | f10857:c0:m30 |
def round(self): | x, y = self.anchor<EOL>self.anchor = (normalizers.normalizeRounding(x),<EOL>normalizers.normalizeRounding(y))<EOL>x, y = self.bcpIn<EOL>self.bcpIn = (normalizers.normalizeRounding(x),<EOL>normalizers.normalizeRounding(y))<EOL>x, y = self.bcpOut<EOL>self.bcpOut = (normalizers.normalizeRounding(x),<EOL>normalizers.normal... | Round coordinates. | f10857:c0:m31 |
def _get_x(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseAnchor.x`. This must return an
:ref:`type-int-float`.
Subclasses must override this method. | f10859:c0:m7 |
def _set_x(self, value): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseAnchor.x`. **value** will be
an :ref:`type-int-float`.
Subclasses must override this method. | f10859:c0:m8 |
def _get_y(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseAnchor.y`. This must return an
:ref:`type-int-float`.
Subclasses must override this method. | f10859:c0:m11 |
def _set_y(self, value): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseAnchor.y`. **value** will be
an :ref:`type-int-float`.
Subclasses must override this method. | f10859:c0:m12 |
def _get_index(self): | glyph = self.glyph<EOL>if glyph is None:<EOL><INDENT>return None<EOL><DEDENT>return glyph.anchors.index(self)<EOL> | Get the anchor's index.
This must return an ``int``.
Subclasses may override this method. | f10859:c0:m14 |
def _get_name(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseAnchor.name`. This must return a
:ref:`type-string` or ``None``. The returned
value will be normalized with
:func:`normalizers.normalizeAnchorName`.
Subclasses must override this method. | f10859:c0:m17 |
def _set_name(self, value): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseAnchor.name`. **value** will be
a :ref:`type-string` or ``None``. It will
have been normalized with
:func:`normalizers.normalizeAnchorName`.
Subclasses must override this method. | f10859:c0:m18 |
def _get_color(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseAnchor.color`. This must return
a :ref:`type-color` or ``None``. The
returned value will be normalized with
:func:`normalizers.normalizeColor`.
Subclasses must override this method. | f10859:c0:m21 |
def _set_color(self, value): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseAnchor.color`. **value** will
be a :ref:`type-color` or ``None``.
It will have been normalized with
:func:`normalizers.normalizeColor`.
Subclasses must override this method. | f10859:c0:m22 |
def _transformBy(self, matrix, **kwargs): | t = transform.Transform(*matrix)<EOL>x, y = t.transformPoint((self.x, self.y))<EOL>self.x = x<EOL>self.y = y<EOL> | This is the environment implementation of
:meth:`BaseAnchor.transformBy`.
**matrix** will be a :ref:`type-transformation`.
that has been normalized with
:func:`normalizers.normalizeTransformationMatrix`.
Subclasses may override this method. | f10859:c0:m23 |
def isCompatible(self, other): | return super(BaseAnchor, self).isCompatible(other, BaseAnchor)<EOL> | Evaluate interpolation compatibility with **other**. ::
>>> compatible, report = self.isCompatible(otherAnchor)
>>> compatible
True
>>> compatible
[Warning] Anchor: "left" + "right"
[Warning] Anchor: "left" has name left | "right" has name right
This will return a ``bool`` indicating if the an... | f10859:c0:m24 |
def _isCompatible(self, other, reporter): | anchor1 = self<EOL>anchor2 = other<EOL>if anchor1.name != anchor2.name:<EOL><INDENT>reporter.nameDifference = True<EOL>reporter.warning = True<EOL><DEDENT> | This is the environment implementation of
:meth:`BaseAnchor.isCompatible`.
Subclasses may override this method. | f10859:c0:m25 |
def round(self): | self._round()<EOL> | Round the anchor's coordinate.
>>> anchor.round()
This applies to the following:
* x
* y | f10859:c0:m26 |
def _round(self): | self.x = normalizers.normalizeRounding(self.x)<EOL>self.y = normalizers.normalizeRounding(self.y)<EOL> | This is the environment implementation of
:meth:`BaseAnchor.round`.
Subclasses may override this method. | f10859:c0:m27 |
def _get_text(self): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseFeatures.text`. This must return a
:ref:`type-string`.
Subclasses must override this method. | f10860:c0:m5 |
def _set_text(self, value): | self.raiseNotImplementedError()<EOL> | This is the environment implementation of
:attr:`BaseFeatures.text`. **value** will be
a :ref:`type-string`.
Subclasses must override this method. | f10860:c0:m6 |
def AskString(message, value='<STR_LIT>', title='<STR_LIT>'): | return dispatcher["<STR_LIT>"](message=message, value=value, title=title)<EOL> | An ask a string dialog, a `message` is required.
Optionally a `value` and `title` can be provided.
::
from fontParts.ui import AskString
print(AskString("who are you?")) | f10863:m0 |
def AskYesNoCancel(message, title='<STR_LIT>', default=<NUM_LIT:0>, informativeText="<STR_LIT>"): | return dispatcher["<STR_LIT>"](message=message, title=title,<EOL>default=default, informativeText=informativeText)<EOL> | An ask yes, no or cancel dialog, a `message` is required.
Optionally a `title`, `default` and `informativeText` can be provided.
The `default` option is to indicate which button is the default button.
::
from fontParts.ui import AskYesNoCancel
print(AskYesNoCancel("who are you?")) | f10863:m1 |
def FindGlyph(aFont, message="<STR_LIT>", title='<STR_LIT>'): | return dispatcher["<STR_LIT>"](aFont=aFont, message=message, title=title)<EOL> | A dialog to search a glyph for a provided font.
Optionally a `message`, `title` and `allFonts` can be provided.
from fontParts.ui import FindGlyph
from fontParts.world import CurrentFont
glyph = FindGlyph(CurrentFont())
print(glyph) | f10863:m2 |
def GetFile(message=None, title=None, directory=None, fileName=None,<EOL>allowsMultipleSelection=False, fileTypes=None): | return dispatcher["<STR_LIT>"](message=message, title=title, directory=directory,<EOL>fileName=fileName,<EOL>allowsMultipleSelection=allowsMultipleSelection,<EOL>fileTypes=fileTypes)<EOL> | An get file dialog.
Optionally a `message`, `title`, `directory`, `fileName` and
`allowsMultipleSelection` can be provided.
::
from fontParts.ui import GetFile
print(GetFile()) | f10863:m3 |
def GetFileOrFolder(message=None, title=None, directory=None, fileName=None,<EOL>allowsMultipleSelection=False, fileTypes=None): | return dispatcher["<STR_LIT>"](message=message, title=title,<EOL>directory=directory, fileName=fileName,<EOL>allowsMultipleSelection=allowsMultipleSelection,<EOL>fileTypes=fileTypes)<EOL> | An get file or folder dialog.
Optionally a `message`, `title`, `directory`, `fileName`,
`allowsMultipleSelection` and `fileTypes` can be provided.
::
from fontParts.ui import GetFileOrFolder
print(GetFileOrFolder()) | f10863:m4 |
def Message(message, title='<STR_LIT>', informativeText="<STR_LIT>"): | return dispatcher["<STR_LIT>"](message=message, title=title,<EOL>informativeText=informativeText)<EOL> | An message dialog.
Optionally a `message`, `title` and `informativeText` can be provided.
::
from fontParts.ui import Message
print(Message("This is a message")) | f10863:m5 |
def PutFile(message=None, fileName=None): | return dispatcher["<STR_LIT>"](message=message, fileName=fileName)<EOL> | An put file dialog.
Optionally a `message` and `fileName` can be provided.
::
from fontParts.ui import PutFile
print(PutFile()) | f10863:m6 |
def SearchList(items, message="<STR_LIT>", title='<STR_LIT>'): | return dispatcher["<STR_LIT>"](items=items, message=message, title=title)<EOL> | A dialgo to search a given list.
Optionally a `message`, `title` and `allFonts` can be provided.
::
from fontParts.ui import SearchList
result = SearchList(["a", "b", "c"])
print(result) | f10863:m7 |
def SelectFont(message="<STR_LIT>", title='<STR_LIT>', allFonts=None): | return dispatcher["<STR_LIT>"](message=message, title=title, allFonts=allFonts)<EOL> | Select a font from all open fonts.
Optionally a `message`, `title` and `allFonts` can be provided.
If `allFonts` is `None` it will list all open fonts.
::
from fontParts.ui import SelectFont
font = SelectFont()
print(font) | f10863:m8 |
def SelectGlyph(aFont, message="<STR_LIT>", title='<STR_LIT>'): | return dispatcher["<STR_LIT>"](aFont=aFont, message=message, title=title)<EOL> | Select a glyph for a given font.
Optionally a `message` and `title` can be provided.
::
from fontParts.ui import SelectGlyph
font = CurrentFont()
glyph = SelectGlyph(font)
print(glyph) | f10863:m9 |
def ProgressBar(title="<STR_LIT>", ticks=None, label="<STR_LIT>"): | return dispatcher["<STR_LIT>"](title=title, ticks=ticks, label=label)<EOL> | A progess bar dialog.
Optionally a `title`, `ticks` and `label` can be provided.
::
from fontParts.ui import ProgressBar
bar = ProgressBar()
# do something
bar.close() | f10863:m10 |
def create_epochs(data, events_onsets, sampling_rate=<NUM_LIT:1000>, duration=<NUM_LIT:1>, onset=<NUM_LIT:0>, index=None): | <EOL>if isinstance(duration, list) or isinstance(duration, np.ndarray):<EOL><INDENT>duration = np.array(duration)<EOL><DEDENT>else:<EOL><INDENT>duration = np.array([duration]*len(events_onsets))<EOL><DEDENT>if isinstance(onset, list) or isinstance(onset, np.ndarray):<EOL><INDENT>onset = np.array(onset)<EOL><DEDENT>else... | Epoching a dataframe.
Parameters
----------
data : pandas.DataFrame
Data*time.
events_onsets : list
A list of event onsets indices.
sampling_rate : int
Sampling rate (samples/second).
duration : int or list
Duration(s) of each epoch(s) (in seconds).
onset : int
Epoch onset(s) relative to events_ons... | f10891:m0 |
def interpolate(values, value_times, sampling_rate=<NUM_LIT:1000>): | <EOL><INDENT>initial_index = value_times[<NUM_LIT:0>]<EOL>value_times = np.array(value_times) - initial_index<EOL>spline = scipy.interpolate.splrep(x=value_times, y=values, k=<NUM_LIT:3>, s=<NUM_LIT:0>) <EOL>x = np.arange(<NUM_LIT:0>, value_times[-<NUM_LIT:1>], <NUM_LIT:1>)<EOL>signal = scipy.interpolate.splev(x=x, tc... | 3rd order spline interpolation.
Parameters
----------
values : dataframe
Values.
value_times : list
Time indices of values.
sampling_rate : int
Sampling rate (samples/second).
Returns
----------
signal : pd.Series
An array containing the values indexed by time.
Example
----------
>>> import neurokit ... | f10892:m0 |
def find_peaks(signal): | derivative = np.gradient(signal, <NUM_LIT:2>)<EOL>peaks = np.where(np.diff(np.sign(derivative)))[<NUM_LIT:0>]<EOL>return(peaks)<EOL> | Locate peaks based on derivative.
Parameters
----------
signal : list or array
Signal.
Returns
----------
peaks : array
An array containing the peak indices.
Example
----------
>>> signal = np.sin(np.arange(0, np.pi*10, 0.05))
>>> peaks = nk.find_peaks(signal)
>>> nk.plot_events_in_signal(signal, peaks)
Not... | f10892:m1 |
def complexity(signal, sampling_rate=<NUM_LIT:1000>, shannon=True, sampen=True, multiscale=True, spectral=True, svd=True, correlation=True, higushi=True, petrosian=True, fisher=True, hurst=True, dfa=True, lyap_r=False, lyap_e=False, emb_dim=<NUM_LIT:2>, tolerance="<STR_LIT:default>", k_max=<NUM_LIT:8>, bands=None, tau=... | if tolerance == "<STR_LIT:default>":<EOL><INDENT>tolerance = <NUM_LIT>*np.std(signal)<EOL><DEDENT>complexity = {}<EOL>----------------------------------------------------------------------------<EOL>if shannon is True:<EOL><INDENT>try:<EOL><INDENT>complexity["<STR_LIT>"] = complexity_entropy_shannon(signal)<EOL><DEDENT... | Computes several chaos/complexity indices of a signal (including entropy, fractal dimensions, Hurst and Lyapunov exponent etc.).
Parameters
----------
signal : list or array
List or array of values.
sampling_rate : int
Sampling rate (samples/second).
shannon : bool
Computes Shannon entropy.
sampen : bool
... | f10894:m0 |
def complexity_entropy_shannon(signal): | <EOL>f not isinstance(signal, str):<EOL><INDENT>signal = list(signal)<EOL><DEDENT>ignal = np.array(signal)<EOL><INDENT>Create a frequency data<EOL><DEDENT>ata_set = list(set(signal))<EOL>req_list = []<EOL>or entry in data_set:<EOL><INDENT>counter = <NUM_LIT:0.><EOL>for i in signal:<EOL><INDENT>if i == entry:<EOL><INDEN... | Computes the shannon entropy. Copied from the `pyEntropy <https://github.com/nikdon/pyEntropy>`_ repo by tjugo.
Parameters
----------
signal : list or array
List or array of values.
Returns
----------
shannon_entropy : float
The Shannon Entropy as float value.
Example
----------
>>> import neurokit as nk
>... | f10894:m1 |
def complexity_entropy_multiscale(signal, max_scale_factor=<NUM_LIT:20>, m=<NUM_LIT:2>, r="<STR_LIT:default>"): | if r == "<STR_LIT:default>":<EOL><INDENT>r = <NUM_LIT>*np.std(signal)<EOL><DEDENT>n = len(signal)<EOL>per_scale_entropy_values = np.zeros(max_scale_factor)<EOL>for i in range(max_scale_factor):<EOL><INDENT>b = int(np.fix(n / (i + <NUM_LIT:1>)))<EOL>temp_ts = [<NUM_LIT:0>] * int(b)<EOL>for j in range(b):<EOL><INDENT>num... | Computes the Multiscale Entropy. Uses sample entropy with 'chebychev' distance.
Parameters
----------
signal : list or array
List or array of values.
max_scale_factor: int
Max scale factor (*tau*). The max length of coarse-grained time series analyzed. Will analyze scales for all integers from 1:max_scale_fact... | f10894:m2 |
def complexity_fd_higushi(signal, k_max): | signal = np.array(signal)<EOL>L = []<EOL>x = []<EOL>N = signal.size<EOL>km_idxs = np.triu_indices(k_max - <NUM_LIT:1>)<EOL>km_idxs = k_max - np.flipud(np.column_stack(km_idxs)) -<NUM_LIT:1><EOL>km_idxs[:,<NUM_LIT:1>] -= <NUM_LIT:1><EOL>for k in range(<NUM_LIT:1>, k_max):<EOL><INDENT>Lk = <NUM_LIT:0><EOL>for m in range(... | Computes Higuchi Fractal Dimension of a signal. Based on the `pyrem <https://github.com/gilestrolab/pyrem>`_ repo by Quentin Geissmann.
Parameters
----------
signal : list or array
List or array of values.
k_max : int
The maximal value of k. The point at which the FD plateaus is considered a saturation point a... | f10894:m3 |
def complexity_entropy_spectral(signal, sampling_rate, bands=None): | psd = np.abs(np.fft.rfft(signal))**<NUM_LIT:2><EOL>psd /= np.sum(psd) <EOL>if bands is None:<EOL><INDENT>power_per_band= psd[psd><NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>freqs = np.fft.rfftfreq(signal.size, <NUM_LIT:1>/float(sampling_rate))<EOL>bands = np.asarray(bands)<EOL>freq_limits_low = np.concatenate([[<NUM_LIT... | Computes Spectral Entropy of a signal. Based on the `pyrem <https://github.com/gilestrolab/pyrem>`_ repo by Quentin Geissmann. The power spectrum is computed through fft. Then, it is normalised and assimilated to a probability density function.
Parameters
----------
signal : list or array
List or array of values.
... | f10894:m4 |
def complexity_entropy_svd(signal, tau=<NUM_LIT:1>, emb_dim=<NUM_LIT:2>): | mat = _embed_seq(signal, tau, emb_dim)<EOL>W = np.linalg.svd(mat, compute_uv = False)<EOL>W /= sum(W) <EOL>entropy_svd = -<NUM_LIT:1>*sum(W * np.log2(W))<EOL>return(entropy_svd)<EOL> | Computes the Singular Value Decomposition (SVD) entropy of a signal. Based on the `pyrem <https://github.com/gilestrolab/pyrem>`_ repo by Quentin Geissmann.
Parameters
----------
signal : list or array
List or array of values.
tau : int
The delay
emb_dim : int
The embedding dimension (*m*, the length of ve... | f10894:m6 |
def complexity_fd_petrosian(signal): | diff = np.diff(signal)<EOL>prod = diff[<NUM_LIT:1>:-<NUM_LIT:1>] * diff[<NUM_LIT:0>:-<NUM_LIT:2>]<EOL>N_delta = np.sum(prod < <NUM_LIT:0>)<EOL>n = len(signal)<EOL>fd_petrosian = np.log(n)/(np.log(n)+np.log(n/(n+<NUM_LIT>*N_delta)))<EOL>return(fd_petrosian)<EOL> | Computes the Petrosian Fractal Dimension of a signal. Based on the `pyrem <https://github.com/gilestrolab/pyrem>`_ repo by Quentin Geissmann.
Parameters
----------
signal : list or array
List or array of values.
Returns
----------
fd_petrosian : float
The Petrosian FD as float value.
Example
----------
>>> ... | f10894:m7 |
def complexity_fisher_info(signal, tau=<NUM_LIT:1>, emb_dim=<NUM_LIT:2>): | mat = _embed_seq(signal, tau, emb_dim)<EOL>W = np.linalg.svd(mat, compute_uv = False)<EOL>W /= sum(W) <EOL>FI_v = (W[<NUM_LIT:1>:] - W[:-<NUM_LIT:1>]) **<NUM_LIT:2> / W[:-<NUM_LIT:1>]<EOL>fisher_info = np.sum(FI_v)<EOL>return(fisher_info)<EOL> | Computes the Fisher information of a signal. Based on the `pyrem <https://github.com/gilestrolab/pyrem>`_ repo by Quentin Geissmann.
Parameters
----------
signal : list or array
List or array of values.
tau : int
The delay
emb_dim : int
The embedding dimension (*m*, the length of vectors to compare).
Retu... | f10894:m8 |
def binarize_signal(signal, treshold="<STR_LIT>", cut="<STR_LIT>"): | if treshold == "<STR_LIT>":<EOL><INDENT>treshold = (np.max(np.array(signal)) - np.min(np.array(signal)))/<NUM_LIT:2><EOL><DEDENT>signal = list(signal)<EOL>binary_signal = []<EOL>for i in range(len(signal)):<EOL><INDENT>if cut == "<STR_LIT>":<EOL><INDENT>if signal[i] > treshold:<EOL><INDENT>binary_signal.append(<NUM_LIT... | Binarize a channel based on a continuous channel.
Parameters
----------
signal = array or list
The signal channel.
treshold = float
The treshold value by which to select the events. If "auto", takes the value between the max and the min.
cut = str
"higher" or "lower", define the events as above or under th... | f10895:m0 |
def localize_events(events_channel, treshold="<STR_LIT>", cut="<STR_LIT>", time_index=None): | events_channel = binarize_signal(events_channel, treshold=treshold, cut=cut)<EOL>events = {"<STR_LIT>":[], "<STR_LIT>":[]}<EOL>if time_index is not None:<EOL><INDENT>events["<STR_LIT>"] = []<EOL><DEDENT>index = <NUM_LIT:0><EOL>for key, g in (groupby(events_channel)):<EOL><INDENT>duration = len(list(g))<EOL>if key == <N... | Find the onsets of all events based on a continuous signal.
Parameters
----------
events_channel = array or list
The trigger channel.
treshold = float
The treshold value by which to select the events. If "auto", takes the value between the max and the min.
cut = str
"higher" or "lower", define the events a... | f10895:m1 |
def find_events(events_channel, treshold="<STR_LIT>", cut="<STR_LIT>", time_index=None, number="<STR_LIT:all>", after=<NUM_LIT:0>, before=None, min_duration=<NUM_LIT:1>): | events = localize_events(events_channel, treshold=treshold, cut=cut, time_index=time_index)<EOL>if len(events["<STR_LIT>"]) == <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>")<EOL>return()<EOL><DEDENT>toremove = []<EOL>for event in range(len(events["<STR_LIT>"])):<EOL><INDENT>if events["<STR_LIT>"][event] < min_duration:<EO... | Find and select events based on a continuous signal.
Parameters
----------
events_channel : array or list
The trigger channel.
treshold : float
The treshold value by which to select the events. If "auto", takes the value between the max and the min.
cut : str
"higher" or "lower", define the events as above... | f10895:m2 |
def plot_events_in_signal(signal, events_onsets, color="<STR_LIT>", marker=None): | df = pd.DataFrame(signal)<EOL>ax = df.plot()<EOL>def plotOnSignal(x, color, marker=None):<EOL><INDENT>if (marker is None):<EOL><INDENT>plt.axvline(x=event, color=color)<EOL><DEDENT>else:<EOL><INDENT>plt.plot(x, signal[x], marker, color=color)<EOL><DEDENT><DEDENT>events_onsets = np.array(events_onsets)<EOL>try:<EOL><IND... | Plot events in signal.
Parameters
----------
signal : array or DataFrame
Signal array (can be a dataframe with many signals).
events_onsets : list or ndarray
Events location.
color : int or list
Marker color.
marker : marker or list of markers (for possible marker values, see: https://matplotlib.org/api/ma... | f10895:m3 |
def eda_process(eda, sampling_rate=<NUM_LIT:1000>, alpha=<NUM_LIT>, gamma=<NUM_LIT>, filter_type = "<STR_LIT>", scr_method="<STR_LIT>", scr_treshold=<NUM_LIT:0.1>): | <EOL>eda = np.array(eda)<EOL>eda_df = pd.DataFrame({"<STR_LIT>": np.array(eda)})<EOL>if filter_type is not None:<EOL><INDENT>filtered, _, _ = biosppy.tools.filter_signal(signal=eda,<EOL>ftype=filter_type,<EOL>band='<STR_LIT>',<EOL>order=<NUM_LIT:4>,<EOL>frequency=<NUM_LIT:5>,<EOL>sampling_rate=sampling_rate)<EOL>filter... | Automated processing of EDA signal using convex optimization (CVXEDA; Greco et al., 2015).
Parameters
----------
eda : list or array
EDA signal array.
sampling_rate : int
Sampling rate (samples/second).
alpha : float
cvxEDA penalization for the sparse SMNA driver.
gamma : float
cvxEDA penalization for... | f10896:m0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.