本文整理汇总了Python中augustus.core.NumpyInterface.NP.copy方法的典型用法代码示例。如果您正苦于以下问题:Python NP.copy方法的具体用法?Python NP.copy怎么用?Python NP.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类augustus.core.NumpyInterface.NP
的用法示例。
在下文中一共展示了NP.copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from augustus.core.NumpyInterface import NP [as 别名]
# 或者: from augustus.core.NumpyInterface.NP import copy [as 别名]
def draw(self, state, plotCoordinates, plotDefinitions, performanceTable):
"""Draw the plot element.
This stage consists of creating an SVG image of the
pre-computed data.
@type state: ad-hoc Python object
@param state: State information that persists long enough to use quantities computed in C{prepare} in the C{draw} stage. This is a work-around of lxml's refusal to let its Python instances maintain C{self} and it is unrelated to DataTableState.
@type plotCoordinates: PlotCoordinates
@param plotCoordinates: The coordinate system in which this plot element will be placed.
@type plotDefinitions: PlotDefinitions
@type plotDefinitions: The dictionary of key-value pairs that forms the <defs> section of the SVG document.
@type performanceTable: PerformanceTable
@param performanceTable: Measures and records performance (time and memory consumption) of the drawing process.
@rtype: SvgBinding
@return: An SVG fragment representing the fully drawn plot element.
"""
svg = SvgBinding.elementMaker
performanceTable.begin("PlotHistogram draw")
cumulative = self.get("cumulative", defaultFromXsd=True, convertType=True)
vertical = self.get("vertical", defaultFromXsd=True, convertType=True)
visualization = self.get("visualization", defaultFromXsd=True)
output = svg.g()
if len(state.count) > 0:
if state.fieldType is not self.fieldTypeNumeric:
if vertical:
strings = plotCoordinates.xstrings
else:
strings = plotCoordinates.ystrings
newCount = []
for string in strings:
try:
index = state.edges.index(string)
except ValueError:
newCount.append(0.0)
else:
newCount.append(state.count[index])
state.count = newCount
state.edges = [(i - 0.5, i + 0.5) for i in xrange(len(strings))]
if vertical:
Ax = NP("array", [low if low is not None else float("-inf") for low, high in state.edges], dtype=NP.dtype(float))
Bx = NP(Ax.copy())
Cx = NP("array", [high if high is not None else float("inf") for low, high in state.edges], dtype=NP.dtype(float))
Dx = NP(Cx.copy())
Ay = NP("zeros", len(state.count), dtype=NP.dtype(float))
if cumulative:
Cy = NP("cumsum", NP("array", state.count, dtype=NP.dtype(float)))
By = NP("roll", Cy, 1)
By[0] = 0.0
else:
By = NP("array", state.count, dtype=NP.dtype(float))
Cy = NP(By.copy())
Dy = NP(Ay.copy())
else:
if cumulative:
Cx = NP("cumsum", NP("array", state.count, dtype=NP.dtype(float)))
Bx = NP("roll", Cx, 1)
Bx[0] = 0.0
else:
Bx = NP("array", state.count, dtype=NP.dtype(float))
Cx = NP(Bx.copy())
Ax = NP("zeros", len(state.count), dtype=NP.dtype(float))
Dx = NP(Ax.copy())
Ay = NP("array", [low if low is not None else float("-inf") for low, high in state.edges], dtype=NP.dtype(float))
By = NP(Ay.copy())
Cy = NP("array", [high if high is not None else float("inf") for low, high in state.edges], dtype=NP.dtype(float))
Dy = NP(Cy.copy())
AX, AY = plotCoordinates(Ax, Ay)
BX, BY = plotCoordinates(Bx, By)
CX, CY = plotCoordinates(Cx, Cy)
DX, DY = plotCoordinates(Dx, Dy)
if visualization == "skyline":
gap = self.get("gap", defaultFromXsd=True, convertType=True)
if vertical:
if gap > 0.0 and NP(NP(DX - gap/2.0) - NP(AX + gap/2.0)).min() > 0.0:
AX += gap/2.0
BX += gap/2.0
CX -= gap/2.0
DX -= gap/2.0
else:
if gap > 0.0 and NP(NP(AY + gap/2.0) - NP(DY - gap/2.0)).min() > 0.0:
AY -= gap/2.0
BY -= gap/2.0
CY += gap/2.0
DY += gap/2.0
pathdata = []
nextIsMoveto = True
for i in xrange(len(state.count)):
iprev = i - 1
#.........这里部分代码省略.........