本文整理汇总了Python中enthought.traits.api.HasTraits.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python HasTraits.__init__方法的具体用法?Python HasTraits.__init__怎么用?Python HasTraits.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enthought.traits.api.HasTraits
的用法示例。
在下文中一共展示了HasTraits.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, source, **traits):
HasTraits.__init__(self, **traits)
nTs = self.time.shape[0]
if isinstance(source, HasTraits):
self.traited = True
self.tracking = source.traits(track=True).keys()
for attr in self.tracking:
shape = (nTs,)
if type(getattr(source, attr)) is _numpy.ndarray:
shape += getattr(source, attr).shape
self.data[attr] = _numpy.zeros(shape, "d")
else:
if type(source) is type([]):
self.tracking = source
for var in source:
self.data[var] = _numpy.zeros((nTs,), "d")
self._update = _copy(source)
elif type(source) is type({}):
self.tracking = source.keys()
for var in self.tracking:
shape = (nTs,) + tuple(source[var])
self.data[var] = _numpy.zeros(shape, "d")
self._update = _copy(self.tracking)
else:
raise TypeError, self.__class__.__doc__
self.source = source
示例2: handle_arguments
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def handle_arguments(self,*args,**kwargs):
HasTraits.__init__(self) #magic by fnoble
for a in args:
if isinstance(a,Frame):
self.parent=a
for k,v in kwargs.items():
if k == 'frame':
self.parent=v
elif k == 'T':
if isinstance(v,Expression):
self.T=v
else:
self.T=self.parent.variables.new_expression(v)
elif len(self.trait_get(k))>0:
#self.trait_set({k:v})
self.__setattr__(k,v)
elif len(self.actor.trait_get(k))>0:
self.actor.__setattr__(k,v)
elif len(self.properties.trait_get(k))>0:
self.properties.__setattr__(k,v)
elif len(self.source.trait_get(k))>0:
self.source.__setattr__(k,v)
else :
print "unknown argument", k , v
if not(self.parent):
self.parent = WorldFrame()
示例3: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, fgcolor=(0.0, 0.0, 0.0), bgcolor=(1.0, 1.0, 1.0),
**traits):
HasTraits.__init__(self, **traits)
scene = self.scene.scene
scene.foreground = fgcolor
scene.background = bgcolor
示例4: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, condition, avg_beams, stats_results, **traits):
HasTraits.__init__(self, **traits)
self._avg_dict = {}
self.stats_results = stats_results
for c, b in zip(condition, avg_beams):
self._avg_beams.append(str(c))
self._avg_dict[str(c)] = b
示例5: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, pos_data, **traits):
"""Required first argument is the 4-column data array from a Pos.p file
"""
HasTraits.__init__(self, **traits)
if not (pos_data[:,-1] == -99).all():
valid = (pos_data[:,-1] != -99).nonzero()[0]
pos_data = pos_data[valid]
self.t, self.x, self.y, self.angle = pos_data.T
示例6: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, **traits):
HasTraits.__init__(self, **traits)
self.engine_view = EngineView(engine=self.scene.engine)
# Hook up the current_selection to change when the one in the engine
# changes. This is probably unnecessary in Traits3 since you can show
# the UI of a sub-object in T3.
self.scene.engine.on_trait_change(self._selection_change,
'current_selection')
示例7: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, *args, **kw):
HasTraits.__init__(self, *args, **kw)
numpoints = 200
plotdata = ArrayPlotData(x=sort(random(numpoints)), y=random(numpoints))
plot = Plot(plotdata)
plot.plot(("x", "y"), type="scatter")
plot.tools.append(PanTool(plot))
plot.overlays.append(ZoomTool(plot))
self.plot = plot
示例8: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__ ( self, object, name, index, trait, value ):
HasTraits.__init__( self )
self.inited = False
self.object = object
self.name = name
self.index = index
if trait is not None:
self.add_trait( 'value', trait )
self.value = value
self.inited = True
示例9: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, *args, **kw):
HasTraits.__init__(self, *args, **kw)
# Create the data and the PlotData object
x = linspace(-14, 14, 100)
y = sin(x) * x**3
plotdata = ArrayPlotData(x = x, y = y)
# Create the scatter plot
plot = Plot(plotdata)
plot.plot(("x", "y"), type=self.plot_type, color="blue")
plot.tools.append(PanTool(plot))
plot.tools.append(ZoomTool(plot))
self.plot = plot
示例10: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, **traits):
HasTraits.__init__(self, **traits)
try:
if not path.exists(self.datadir):
makedirs(self.datadir)
except OSError:
self.out('Reverting to base directory:\n%s'%ANA_DIR, error=True)
self.datadir = ANA_DIR
finally:
self.datadir = path.abspath(self.datadir)
self.out('%s initialized:\n%s'%(self.__class__.__name__, str(self)))
示例11: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, pmap, **traits):
HasTraits.__init__(self, **traits)
try:
self.PMap = pmap
except TraitError:
self.out('PlaceMap subclass instance required', error=True)
return
self.fdata = self.PMap.get_field_data()
self.udata = self.PMap.get_unit_data()
self.add_trait('unit', Range(low=0, high=self.PMap.num_maps-1))
self._update_unit_values()
self.out('Bringing up place-map visualization...')
self.view()
self.out('Done!')
示例12: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, eval=None, label='Value',
trait=None, min=0.0, max=1.0,
initial=None, **traits):
HasTraits.__init__(self, **traits)
if trait is None:
if min > max:
min, max = max, min
if initial is None:
initial = min
elif not (min <= initial <= max):
initial = [min, max][
abs(initial - min) >
abs(initial - max)]
trait = Range(min, max, value=initial)
self.add_trait(label, trait)
示例13: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, *l, **kw):
# TODO: implement aspect ratio maintaining
HasTraits.__init__(self, *l, **kw)
#self.plotdata = ArrayPlotData(x=self.pointsx, y=self.pointsy)
plot = Plot(self.plotdata)
plot.plot(("x", "y"))
plot.plot(("x", "y"), type='scatter')
plot.tools.append(PanTool(plot, drag_button='left'))
plot.tools.append(ZoomTool(plot, tool_mode='box'))
plot.tools.append(DragZoom(plot, tool_mode='box', drag_button='right'))
plot.tools.append(CustomSaveTool(plot))#, filename='/home/pankaj/Desktop/file.png'))
plot.tools.append(TraitsTool(plot))
self.plot = plot
self.set_plotdata()
示例14: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, under_image, over_image):
"""
Provide the underlay and overlay NiftiImages. Can also
provide filename strings.
Example:
stat = OverlayMap('anat.nii.gz','stat.nii.gz')
"""
# we've got traits
HasTraits.__init__(self)
# load in the image
if isinstance(under_image, NiftiImage):
# use it
self.__under_image = under_image
elif isinstance(under_image, str):
# load from file
self.__under_image = NiftiImage(under_image)
else:
raise ValueError("under_image must be a NiftiImage or a file.")
# TODO: set the extent and spacing of the under image
# set the over data
if isinstance(over_image, str):
# load from file
over_image = NiftiImage(over_image)
if isinstance(over_image, NiftiImage):
# TODO: make sure it matches the dims of under image
# TODO: set the extent
# save just the dat
self.__over_image = over_image.data.T
elif isinstance(over_image, np.ndarray):
# just set it
# assumes it matches the dims and extent of the under image
self.__over_image = over_image
else:
raise ValueError("over_image must be a NiftiImage, ndarray, or file.")
self.__over_image = np.ma.masked_invalid(self.__over_image)
self.configure_traits()
pass
示例15: __init__
# 需要导入模块: from enthought.traits.api import HasTraits [as 别名]
# 或者: from enthought.traits.api.HasTraits import __init__ [as 别名]
def __init__(self, **traits):
self.property = self.actor.property
HasTraits.__init__(self, **traits)
self._create_points(self.coords,self.indices)
self._color_changed(self.color)
self._visibility_changed(self.visibility)
normals = tvtk.PolyDataNormals(input = self.polydata)
m = tvtk.PolyDataMapper(input = normals.output) # the usual vtk pipleine countinuation
self.actor.mapper = m
self.property = self.actor.property
self.property.representation = self.representation
show_actor(self.actor) # passing the actors function for rendering
self.viewer = get_viewer() # getting the ivtk viewer
self.property.on_trait_change(self.viewer.scene.render)
self.actor.on_trait_change(self.viewer.scene.render)