Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before = "text/plain"
def identify(self, guess):
byte_stream = guess.get_utf8()
if not byte_stream.startswith("#!"):
return
line = byte_stream[2:80].lower().strip()
if line.startswith("/usr/bin/env"):
line = line[12:].strip()
words = line.split()
names = words[0].split("/")
if names[-1]:
return "text/%s" % names[-1]
@provides(IFileRecognizer)
class PrivateTextRecognizer(HasTraits):
"""Recognizer for pound bang style executable script files
"""
id = "text/private"
before = "text/poundbang"
header = "#!omnivore-private\n"
def identify(self, guess):
byte_stream = guess.get_utf8()
if not byte_stream.startswith(self.header):
return
return self.id
self.add_trait('channel', DelegatesTo('view'))
self.add_trait('xfacet', DelegatesTo('view'))
self.add_trait('yfacet', DelegatesTo('view'))
self.add_trait('huefacet', DelegatesTo('view'))
self.add_trait('subset', DelegatesTo('view'))
def is_wi_valid(self, wi):
return (wi.previous
and wi.previous.result
and self.is_valid(wi.previous.result))
def plot_wi(self, wi, pane):
pane.plot(wi.previous.result, self)
@provides(IViewPlugin)
class ThresholdSelectionPlugin(Plugin):
"""
classdocs
"""
id = 'edu.mit.synbio.cytoflowgui.view.threshold'
view_id = 'edu.mit.synbio.cytoflow.view.threshold'
short_name = "Threshold"
def get_view(self):
return ThresholdSelectionView()
@contributes_to(VIEW_PLUGIN_EXT)
def get_plugin(self):
return self
editor = SubsetListEditor(conditions = "context.previous_conditions")),
label = "Subset",
show_border = False,
show_labels = False),
Item('context.view_warning',
resizable = True,
visible_when = 'context.view_warning',
editor = ColorTextEditor(foreground_color = "#000000",
background_color = "#ffff99")),
Item('context.view_error',
resizable = True,
visible_when = 'context.view_error',
editor = ColorTextEditor(foreground_color = "#000000",
background_color = "#ff9191"))))
@provides(ISelectionView)
class Range2DSelectionView(PluginViewMixin, RangeSelection2D):
handler_factory = Callable(RangeView2DHandler, transient = True)
op = Instance(IOperation, fixed = True)
xlow = DelegatesTo('op', status = True)
xhigh = DelegatesTo('op', status = True)
ylow = DelegatesTo('op', status = True)
yhigh = DelegatesTo('op', status = True)
plot_params = Instance(ScatterplotPlotParams, ())
name = Str
def should_plot(self, changed, payload):
if changed == Changed.PREV_RESULT or changed == Changed.VIEW:
return True
else:
return False
#
# Author: Enthought, Inc.
# Description:
""" The Wx-specific implementation of the spin field class """
import wx
from traits.api import provides
from pyface.fields.i_spin_field import ISpinField, MSpinField
from .field import Field
@provides(ISpinField)
class SpinField(MSpinField, Field):
""" The Wx-specific implementation of the spin field class """
# ------------------------------------------------------------------------
# IWidget interface
# ------------------------------------------------------------------------
def _create_control(self, parent):
""" Create the toolkit-specific control that represents the widget. """
control = wx.SpinCtrl(parent, style=wx.TE_PROCESS_ENTER)
return control
# ------------------------------------------------------------------------
# Private interface
# ------------------------------------------------------------------------
from traits.api import (HasStrictTraits, Str, CStr, List, Float, provides,
Instance, Bool, on_trait_change, Any,
Constant)
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import cytoflow.utility as util
from cytoflow.views import ISelectionView, ScatterplotView
from .i_operation import IOperation
from .base_op_views import Op2DView
@provides(IOperation)
class PolygonOp(HasStrictTraits):
"""
Apply a polygon gate to a cytometry experiment.
Attributes
----------
name : Str
The operation name. Used to name the new metadata field in the
experiment that's created by :meth:`apply`
xchannel, ychannel : Str
The names of the x and y channels to apply the gate.
xscale, yscale : {'linear', 'log', 'logicle'} (default = 'linear')
The scales applied to the data before drawing the polygon.
""" Enthought pyface package component
"""
import wx
from traits.api import Bool, provides, Str
from pyface.i_directory_dialog import IDirectoryDialog, MDirectoryDialog
from .dialog import Dialog
@provides(IDirectoryDialog)
class DirectoryDialog(MDirectoryDialog, Dialog):
""" The toolkit specific implementation of a DirectoryDialog. See the
IDirectoryDialog interface for the API documentation.
"""
# 'IDirectoryDialog' interface -----------------------------------------
default_path = Str()
message = Str()
new_directory = Bool(True)
path = Str()
# ------------------------------------------------------------------------
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!
""" A dialog that allows the user to select a color. """
from pyface.qt import QtGui
from traits.api import Bool, provides
from pyface.color import Color, PyfaceColor
from pyface.i_color_dialog import IColorDialog
from .dialog import Dialog
@provides(IColorDialog)
class ColorDialog(Dialog):
""" A dialog that allows the user to choose a color.
"""
# 'IColorDialog' interface ----------------------------------------------
#: The color in the dialog.
color = PyfaceColor()
#: Whether or not to allow the user to chose an alpha value.
show_alpha = Bool(False)
# ------------------------------------------------------------------------
# 'IDialog' interface.
# ------------------------------------------------------------------------
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
import numpy as np
import pandas as pd
from traits.api import HasStrictTraits, Str, List, Enum, Float, Constant, \
provides
from cytoflow.operations import IOperation
from cytoflow.utility import CytoflowOpError
@provides(IOperation)
class LogTransformOp(HasStrictTraits):
"""
An operation that applies a natural log10 transformation to channels.
It can be configured to mask or clip values less than some threshold.
The log10 transform is sometimes okay for basic visualization, but
most analyses should be using `HlogTransformOp` or `LogicleTransformOp`.
Attributes
----------
name : Str
The name of the transformation (for UI representation; optional for
interactive use)
channels : List(Str)
A list of the channels on which to apply the transformation
# if triggered:
# if not self.triggered:
# self.triggered = True
# else:
# self.triggered = False
#
# return self.triggered
#
# def get_message(self, value):
# cond, trigger = self.get_alarm_params()
# tstamp = datetime.strftime(datetime.now(), '%Y-%m-%d %H:%M:%S')
#
# return '<<<<<>>>>> {} {} {}'.format(tstamp, value, cond, trigger)
@provides(ICoreDevice)
class CoreDevice(ScanableDevice, HasCommunicator, ConsumerMixin):
"""
"""
_auto_started = False
_no_response_counter = 0
_scheduler_name = None
def send_email_notification(self, message):
if self.application:
tm = self.application.get_service('pychron.social.emailer.Emailer')
if tm:
tm.broadcast(message)
else:
self.warning('No emailer available')
editor = SubsetListEditor(conditions = "context.previous_wi.conditions")),
label = "Subset",
show_border = False,
show_labels = False),
Item('context.view_warning',
resizable = True,
visible_when = 'context.view_warning',
editor = ColorTextEditor(foreground_color = "#000000",
background_color = "#ffff99")),
Item('context.view_error',
resizable = True,
visible_when = 'context.view_error',
editor = ColorTextEditor(foreground_color = "#000000",
background_color = "#ff9191"))))
@provides(ISelectionView)
class RangeSelectionView(PluginViewMixin, RangeSelection):
handler_factory = Callable(RangeViewHandler)
op = Instance(IOperation, fixed = True)
low = DelegatesTo('op', status = True)
high = DelegatesTo('op', status = True)
plot_params = Instance(HistogramPlotParams, ())
name = Str
def should_plot(self, changed, payload):
if changed == Changed.PREV_RESULT or changed == Changed.VIEW:
return True
else:
return False
def plot_wi(self, wi):
self.plot(wi.previous_wi.result, **self.plot_params.trait_get())