Esempio n. 1
0
 def __init__(self, axis, **kwargs):
     HasTraits.__init__(self, **kwargs)  # @UndefinedVariable
    def __init__(self, couch_points):
        # Do not forget to call the parent's __init__
        HasTraits.__init__(self)

        self.couch_points = couch_points
        self.setup_animation()
Esempio n. 3
0
 def __init__(self, *args, **kwargs):  # noqa: D102
     logger.debug(
         "Initializing Kit2fiff-GUI with %s backend", ETSConfig.toolkit)
     HasTraits.__init__(self, *args, **kwargs)
 def __init__(self, **traits):
     HasTraits.__init__(self, **traits)
     self.engine_view = EngineView(engine=self.scene.engine)
Esempio n. 5
0
 def __init__(self):
     # Do not forget to call the parent's __init__
     HasTraits.__init__(self)
     x, y, z, = tens_fld(1,1,1,self.beta, self.alpha)
     self.plot = self.scene.mlab.mesh(x, y, z, colormap='copper', representation='surface')
Esempio n. 6
0
    def __init__(self,
                 visualisation_model,
                 decision_threshold,
                 start_day=3,
                 num_of_shown_days="30 days",
                 precompute_cache=False):
        '''

        :param visualisation_model: an instance of EventDataModel
        :param decision_threshold: a float larger or equal to 0.0 that is used for deciding when an anomaly score is significantly anomalous
        :param start_day: an integer >= or an instance of datetime.date or an string, like "2014-10-11" or a tuple, like (2014, 10, 11)
        :param num_of_shown_days: an integer > 1 that specifies the number of days back in time from start_day that will be shown.
        :param precompute_cache: boolean that indates whether all anomaly scores should be computed at once or when asked for.
        :return:
        '''
        assert isinstance(visualisation_model, EventDataModel)
        assert isinstance(
            start_day, int) or isinstance(start_day, str) or isinstance(
                start_day, datetime.date) or (isinstance(start_day, tuple)
                                              and len(start_day) == 3)
        HasTraits.__init__(self)

        self.used_cache_size = 0  # must be initialized
        self._data = visualisation_model._event_data_object

        self.num_of_shown_days = num_of_shown_days  # Updates self.used_cache_size

        self._vis_model = visualisation_model
        self._anomaly_detector = visualisation_model._anomaly_detector
        self.anomaly_detection_threshold = decision_threshold

        dates = visualisation_model._event_data_object.dates_
        self._data_times = array([datetools.to_datetime(d) for d in dates])

        self.source_names = list(
            unique(visualisation_model._event_data_object.sources_))
        self._data_sources = array([
            self.source_names.index(source)
            for source in visualisation_model._event_data_object.sources_
        ])
        self._num_of_sources = len(unique(
            self.source_names))  # number of sources

        self.barcharts = []
        self.barchart_actors = []
        self.time_text3ds = []
        self.source_text3ds = []
        self.xy_positions = []

        self._high_start_day_number = int(
            (self._data_times.max() - self._data_times.min()).days)

        self.scene.anti_aliasing_frames = 8

        # add traits dynamically
        self.add_trait("Relative_Start_Day",
                       Range(0, self._high_start_day_number))

        self.add_trait("_selected_source_name",
                       Enum(None, [None] + self.source_names))

        self.configure_traits()

        # add the mouse pick handler
        self.picker = self.scene.mayavi_scene.on_mouse_pick(
            self.vis_picker, 'cell')

        self.picker.tolerance = 0.01

        self.severity_color = [
            (1, x / 100.0, x / 100.0)
            for x in range(70, 30, -40 /
                           self._vis_model.num_of_severity_levels_)
        ]

        # This used for a fix to manage a bug in Mayavi library, an invisible default object
        self._obj = self.scene.mlab.points3d(0, 0, 0, opacity=0.0)

        # Cache all anomaly calculations for all data values
        if precompute_cache:
            self.used_cache_size = len(self._data)
            for data_index in xrange(len(self._data)):
                self._populate_cache(data_index)

        self.start_day = start_day

        self.update()
Esempio n. 7
0
 def test_new(self):
     # Should not raise DeprecationWarning.
     HasTraits(x=10)
Esempio n. 8
0
def service_factory(**properties):
    """ A factory for foos. """

    return HasTraits(**properties)
 def __init__(self):
     HasTraits.__init__(self)
     x, y, z = curve(self.n_turns)
     self.plot = self.scene.mlab.plot3d(x, y, z)
Esempio n. 10
0
 def __init__(self):
     HasTraits.__init__(self)
     x, y, z = curve(n_turns=2)
     # Populating our plot
     self.plot = self.scene.mlab.plot3d(x, y, z)
Esempio n. 11
0
 def __init__(self, text="", **kwtraits):
     if 'text' not in kwtraits:
         kwtraits['text'] = text
     HasTraits.__init__(self, **kwtraits)
     self._bounding_box = [0, 0]
     return
Esempio n. 12
0
 def set(self, *args, **kw):
     print('nacsd', args, kw)
     return HasTraits.set(self, *args, **kw)
Esempio n. 13
0
    def __init__(self, kp):

        """Initializer of the UI class"""

        ###################################################
        #
        # Initialize the scene
        #
        ###################################################

        # super class initializer
        HasTraits.__init__(self)

        # Drawer instance
        self.drawer = Drawer(self.scene)

        ###################################################
        #
        # Retrieve Data
        #
        ###################################################

        # store the kp
        self.kp = kp
        if self.kp.owl_files:
            self.kp.load_owl()
        elif self.kp.n3_files:
            self.kp.load_n3()
        elif self.kp.blazehost:
            self.kp.get_everything_blaze()
        else:
            self.kp.get_everything()
        
        ###################################################
        #
        # Fill the side lists
        #
        ###################################################
        
        # get data properties
        dps = self.kp.get_data_properties()
        for dp in dps:
            self.dataproperties_list.append(TraitDataProperty(dp_name = str(dp[0]), dp_domain = str(dp[1]), dp_range = str(dp[2])))

        # get object properties
        ops = self.kp.get_object_properties()    
        for op in ops:
            self.objectproperties_list.append(TraitObjectProperty(op_name = str(op[0]), op_domain = str(op[1]), op_range = str(op[2])))

        # get instances
        for res in self.kp.get_instances():
            self.resources_list.append(TraitResource(resource_name = str(res[0])))

        # get classes
        cs = self.kp.get_classes()
        for c in cs:
            self.classes_list.append(TraitClass(class_name = str(c)))

        ###################################################
        #
        # Draw
        #
        ###################################################

        # initialize data structures
        self.res_list = ResourceList()
        self.planes = []
        self.active_labels = []

        # get and analyze knowledge
        self.data_classifier()
        self.calculate_placement()
        self.draw()
Esempio n. 14
0
 def __init__(self, path=default_path):
     HasTraits.__init__(self)
     self.path = path
     self.exp_path = os.path.dirname(self.path)
Esempio n. 15
0
 def __init__(self, **kwargs):
     transforms.Transform.__init__(self)
     HasTraits.__init__(self, **kwargs)  # @UndefinedVariable
Esempio n. 16
0
#class TestClass(HasTraits):
#    b1 = Bool
#    b2 = Bool
#    b3 = Bool
#    _updated = Bool(False)

#
#for e in dir(view1):
#    print e

#for attr in ['b1', "title", "handler", "buttons"]:
#    print attr, getattr(view1, attr, None)

#tc = TestClass()
#tc.add_trait( 'b4',Bool)

t = HasTraits()
nameL = []
for i in range(4):
    name = 'r%d' % i
    t.add_trait(name, Range(1, 10, i))
    nameL.append(name)

view1 = View(nameL,
             title="Alter Title",
             handler=TC_Handler(),
             buttons=['OK', 'Cancel'])

t.configure_traits(view=view1)
Esempio n. 17
0
 def __init__(self, **traits):
     HasTraits.__init__(self, **traits)
     self.generate_data()
Esempio n. 18
0
    def __init__(self):
        # Do not forget to call the parent's __init__
        HasTraits.__init__(self)

        data = sio.loadmat('img_max50')
        self.H = data['H1']