How to use the traits.api.Constant function in traits

To help you get started, we’ve selected a few traits examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bpteague / cytoflow / cytoflow / operations / binning.py View on Github external
:context: close-figs 
    
        >>> ex2 = bin_op.apply(ex)
    
    Plot the result
    
    .. plot::
        :context: close-figs

        >>> bin_op.default_view().plot(ex2)  

    """
    
    # traits
    id = Constant('edu.mit.synbio.cytoflow.operations.binning')
    friendly_id = Constant("Binning")
    
    name = CStr()
    bin_count_name = CStr()
    channel = Str()
    num_bins = util.Removed(err_string = "'num_bins' was removed in 0.9")
    bin_width = util.PositiveFloat(0, allow_zero = True)
    scale = util.ScaleEnum
    
    _max_num_bins = Int(100)

    def apply(self, experiment):
        """
        Applies the binning to an experiment.
        
        Parameters
        ----------
github enthought / enable / enthought / savage / compliance / sike.py View on Github external
class ProfileAdapter(TabularAdapter):
    """ Display profiling records in a TabularEditor.
    """
    columns = profile_columns

    # Whether filenames should only be displayed as basenames or not.
    basenames = Bool(True, update=True)

    # Whether times should be shown as percentages or not.
    percentages = Bool(True, update=True)

    # The total time to use for calculating percentages.
    total_time = Float(1.0, update=True)

    ncalls_width = Constant(55)
    nonrec_calls_width = Constant(55)
    inline_time_width = Constant(75)
    cum_time_width = Constant(75)
    func_name_width = Constant(200)
    line_width = Constant(50)

    ncalls_alignment = Constant('right')
    nonrec_calls_alignment = Constant('right')
    inline_time_alignment = Constant('right')
    cum_time_alignment = Constant('right')
    line_alignment = Constant('right')

    file_text = Property(Str)
    inline_time_text = Property(Str)
    cum_time_text = Property(Str)

    def _get_file_text(self):
github bpteague / cytoflow / cytoflow / operations / range.py View on Github external
Examples
    --------
    
    In an IPython notebook with `%matplotlib notebook`
    
    >>> r = RangeOp(name = "RangeGate",
    ...             channel = 'Y2-A')
    >>> rv = r.default_view()
    >>> rv.interactive = True
    >>> rv.plot(ex2)
    >>> ### draw a range on the plot ###
    >>> print r.low, r.high
    """
    
    id = Constant('edu.mit.synbio.cytoflow.views.range')
    friendly_id = Constant("Range Selection")

    xfacet = Constant(None)
    yfacet = Constant(None)
    
    scale = util.ScaleEnum
    
    interactive = Bool(False, transient = True)

    # internal state.
    _ax = Any(transient = True)
    _span = Instance(util.SpanSelector, transient = True)
    _low_line = Instance(Line2D, transient = True)
    _high_line = Instance(Line2D, transient = True)
    _hline = Instance(Line2D, transient = True)
github enthought / traitsui / examples / demo / Advanced / Tabular_editor_demo.py View on Github external
# List of (Column labels, Column ID).
    columns = [('Name', 'name'),
               ('Age', 'age'),
               ('Address', 'address'),
               ('Spouse', 'spouse')]

    row_label_name = 'surname'

    # Interfacing between the model and the view: make some of the cell
    # attributes a property whose behavior is then controlled by the get
    # (and optionally set methods). The cell is identified by its column
    # ID (age, spouse).

    # Font fails with wx in OSX; see traitsui issue #13:
    # font                      = 'Courier 10'
    age_alignment = Constant('right')
    MarriedPerson_age_image = Property
    MarriedPerson_bg_color = Color(0xE0E0FF)
    MarriedPerson_spouse_text = Property
    Person_spouse_text = Constant('')

    def _get_MarriedPerson_age_image(self):
        if self.item.age < 18:
            return '@icons:red_ball'

        return None

    def _get_MarriedPerson_spouse_text(self):
        return self.item.partner.name

#-- Tabular Editor Definition --------------------------------------------
github enthought / enable / enthought / savage / compliance / sike.py View on Github external
""" Display profiling records in a TabularEditor.
    """
    columns = profile_columns

    # Whether filenames should only be displayed as basenames or not.
    basenames = Bool(True, update=True)

    # Whether times should be shown as percentages or not.
    percentages = Bool(True, update=True)

    # The total time to use for calculating percentages.
    total_time = Float(1.0, update=True)

    ncalls_width = Constant(55)
    nonrec_calls_width = Constant(55)
    inline_time_width = Constant(75)
    cum_time_width = Constant(75)
    func_name_width = Constant(200)
    line_width = Constant(50)

    ncalls_alignment = Constant('right')
    nonrec_calls_alignment = Constant('right')
    inline_time_alignment = Constant('right')
    cum_time_alignment = Constant('right')
    line_alignment = Constant('right')

    file_text = Property(Str)
    inline_time_text = Property(Str)
    cum_time_text = Property(Str)

    def _get_file_text(self):
        fn = self.item.file_line_name[0]
github enthought / traitsui / traitsui / table_column.py View on Github external
return (xgetattr(object, name[:col]), name[col + 1 :])


class ExpressionColumn(ObjectColumn):
    """ A column for displaying computed values.
    """

    # -------------------------------------------------------------------------
    #  Trait definitions:
    # -------------------------------------------------------------------------

    #: The Python expression used to return the value of the column:
    expression = Expression

    #: Is this column editable?
    editable = Constant(False)

    #: The globals dictionary that should be passed to the expression
    #: evaluation:
    globals = Any({})

    def get_raw_value(self, object):
        """ Gets the unformatted value of the column for a specified object.
        """
        try:
            return eval(self.expression_, self.globals, {"object": object})
        except Exception:
            logger.exception(
                "Error evaluating table column expression: %s"
                % self.expression
            )
            return None
github bpteague / cytoflow / cytoflow / operations / xform_stat.py View on Github external
Examples
    --------
    
    >>> stats_op = ChannelStatisticOp(name = "Mean",
    ...                               channel = "Y2-A",
    ...                               function = np.mean,
    ...                               by = ["Dox"])
    >>> ex2 = stats_op.apply(ex)
    >>> log_op = TransformStatisticOp(name = "LogMean",
    ...                               statistic = ("Mean", "mean"),
    ...                               function = np.log)
    >>> ex3 = log_op.apply(ex2)  
    """
    
    id = Constant('edu.mit.synbio.cytoflow.operations.transform_statistic')
    friendly_id = Constant("Transform Statistic")

    name = CStr
    statistic = Tuple(Str, Str)
    function = Callable
    statistic_name = Str
    by = List(Str)    
    fill = Any(0)

    def apply(self, experiment):
        """
        Applies :attr:`function` to a statistic.
        
        Parameters
        ----------
        experiment : Experiment
github bpteague / cytoflow / cytoflow / operations / autofluorescence.py View on Github external
class AutofluorescenceDiagnosticView(HasStrictTraits):
    """
    Plots a histogram of each channel, and its median in red.  Serves as a
    diagnostic for the autofluorescence correction.
    
    Attributes
    ----------
    op : Instance(AutofluorescenceOp)
        The :class:`AutofluorescenceOp` whose parameters we're viewing. Set 
        automatically if you created the instance using 
        :meth:`AutofluorescenceOp.default_view`.

    """
    
    # traits   
    id = Constant('edu.mit.synbio.cytoflow.view.autofluorescencediagnosticview')
    friendly_id = Constant("Autofluorescence Diagnostic")

    op = Instance(AutofluorescenceOp)    
    
    def plot(self, experiment, **kwargs):
        """
        Plot a faceted histogram view of a channel
        """
        
        if experiment is None:
            raise util.CytoflowViewError('experiment', "No experiment specified")
        
        if not self.op.channels:
            raise util.CytoflowViewError('op', "No channels specified")
        
        if not self.op._af_median:
github bpteague / cytoflow / cytoflowgui / tasbe_calibration.py View on Github external
def _do_convert_fired(self):
        
        dialog = FileDialog(action = 'open files',
                            wildcard = (FileDialog.create_wildcard("FCS files", "*.fcs"))) #@UndefinedVariable  
        if dialog.open() == OK:            
            self.model.input_files = dialog.paths


@provides(IOperation)
class TasbeCalibrationOp(PluginOpMixin):
    handler_factory = Callable(TasbeHandler)
    
    id = Constant('edu.mit.synbio.cytoflowgui.op_plugins.bleedthrough_piecewise')
    friendly_id = Constant("Quantitative Pipeline")
    name = Constant("TASBE")
    
    fsc_channel = DelegatesTo('_polygon_op', 'xchannel', estimate = True)
    ssc_channel = DelegatesTo('_polygon_op', 'ychannel', estimate = True)
    vertices = DelegatesTo('_polygon_op', 'vertices', estimate = True)
    channels = List(Str, estimate = True)
    
    blank_file = File(filter = ["*.fcs"], estimate = True)
    
    bleedthrough_list = List(_BleedthroughControl, estimate = True)

    beads_name = Str(estimate = True)
    beads_file = File(filter = ["*.fcs"], estimate = True)
    units_list = List(_Unit, estimate = True)
    
    bead_peak_quantile = Int(80, estimate = True)
github bpteague / cytoflow / cytoflow / views / i_view.py View on Github external
Could be a histogram, a density plot, a scatter plot, a statistical
    visualization like a bar chart of population means; even a textual 
    representation like a table.
    
    Attributes
    ----------
    id : Constant
        A unique id for this view.  Prefix: "edu.mit.cytoflow.views"

    friendly_id : Constant
        The human-readable id of this view: eg, "Histogram"
    """

    id = Constant("FIXME")
    friendly_id = Constant("FIXME")
         
    def plot(self, experiment, **kwargs):
        """Plot a visualization of flow data using the pyplot stateful interface