cytoflow.utility.custom_traits#

Custom traits for cytoflow

PositiveInt, PositiveFloat – versions of traits.trait_types.Int and traits.trait_types.Float that must be positive (and optionally 0).

PositiveCInt, PositiveCFloat – versions of traits.trait_types.CInt, traits.trait_types.CFloat that must be positive (and optionally 0).

IntOrNone, FloatOrNone – versions of traits.trait_types.Int and traits.trait_types.Float that may also hold the value None.

CIntOrNone, CFloatOrNone – versions of traits.trait_types.CInt and traits.trait_types.CFloat that may also hold the value None.

ScaleEnum – an enumeration whose value is one of the registered scales.

Removed – a trait that was present in a previous version but was removed.

Deprecated – a trait that was present in a previous version but was renamed.

class cytoflow.utility.custom_traits.PositiveInt(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]#

Bases: BaseInt

Defines a trait whose value must be a positive integer

info_text = 'a positive integer'#

A description of the type of value this trait accepts:

validate(obj, name, value)[source]#

Validates that a specified value is valid for this trait.

class cytoflow.utility.custom_traits.PositiveCInt(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]#

Bases: BaseCInt

Defines a trait whose converted value must be a positive integer

info_text = 'a positive integer'#

A description of the type of value this trait accepts:

validate(obj, name, value)[source]#

Validates that a specified value is valid for this trait.

Note: The ‘fast validator’ version performs this check in C.

class cytoflow.utility.custom_traits.PositiveFloat(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]#

Bases: BaseFloat

Defines a trait whose value must be a positive float

info_text = 'a positive float'#

A description of the type of value this trait accepts:

validate(obj, name, value)[source]#

Validates that a specified value is valid for this trait.

Note: The ‘fast validator’ version performs this check in C.

class cytoflow.utility.custom_traits.PositiveCFloat(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]#

Bases: BaseCFloat

Defines a trait whose converted value must be a positive float

info_text = 'a positive float'#

A description of the type of value this trait accepts:

validate(obj, name, value)[source]#

Validates that a specified value is valid for this trait.

Note: The ‘fast validator’ version performs this check in C.

class cytoflow.utility.custom_traits.FloatOrNone(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]#

Bases: BaseFloat

Defines a trait whose value must be a float or None

info_text = 'a float or None'#

A description of the type of value this trait accepts:

validate(obj, name, value)[source]#

Validates that a specified value is valid for this trait.

Note: The ‘fast validator’ version performs this check in C.

class cytoflow.utility.custom_traits.CFloatOrNone(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]#

Bases: BaseCFloat

Defines a trait whose converted value must be a float or None

info_text = 'a float or None'#

A description of the type of value this trait accepts:

validate(obj, name, value)[source]#

Validates that a specified value is valid for this trait.

Note: The ‘fast validator’ version performs this check in C.

class cytoflow.utility.custom_traits.UnitFloat(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]#

Bases: BaseFloat

Defines a trait whose value must be a float between 0 and 1 (inclusive)

validate(obj, name, value)[source]#

Validates that a specified value is valid for this trait.

Note: The ‘fast validator’ version performs this check in C.

class cytoflow.utility.custom_traits.IntOrNone(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]#

Bases: BaseInt

Defines a trait whose value must be an integer or None

info_text = 'an int or None'#

A description of the type of value this trait accepts:

validate(obj, name, value)[source]#

Validates that a specified value is valid for this trait.

class cytoflow.utility.custom_traits.CIntOrNone(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]#

Bases: BaseCInt

Defines a trait whose converted value must be an integer or None

info_text = 'an int or None'#

A description of the type of value this trait accepts:

validate(obj, name, value)[source]#

Validates that a specified value is valid for this trait.

Note: The ‘fast validator’ version performs this check in C.

class cytoflow.utility.custom_traits.ScaleEnum(*args, **metadata)[source]#

Bases: BaseEnum

Defines an enumeration that contains one of the registered data scales

info_text = 'an enum containing one of the registered scales'#
get_default_value()[source]#

Get information about the default value.

The default implementation analyzes the value of the trait’s default_value attribute and determines an appropriate default_value_type for the default_value. If you need to override this method to provide a different result tuple, the following values are valid values for default_value_type:

  • 0, 1: The default_value item of the tuple is the default value.

  • 2: The object containing the trait is the default value.

  • 3: A new copy of the list specified by default_value is the default value.

  • 4: A new copy of the dictionary specified by default_value is the default value.

  • 5: A new instance of TraitListObject constructed using the default_value list is the default value.

  • 6: A new instance of TraitDictObject constructed using the default_value dictionary is the default value.

  • 7: default_value is a tuple of the form: (callable, args, kw), where callable is a callable, args is a tuple, and kw is either a dictionary or None. The default value is the result obtained by invoking callable(\*args, \*\*kw).

  • 8: default_value is a callable. The default value is the result obtained by invoking default_value(object), where object is the object containing the trait. If the trait has a validate() method, the validate() method is also called to validate the result.

  • 9: A new instance of TraitSetObject constructed using the default_value set is the default value.

Returns:

default_value_type, default_value – The default value information, consisting of an integer, giving the type of default value, and the corresponding default value as described above.

Return type:

int, any

class cytoflow.utility.custom_traits.Removed(**metadata)[source]#

Bases: TraitType

Names a trait that was present in a previous version but was removed.

Trait metadata:

  • err_string : the error string in the error

  • gui : if True, don’t return a backtrace (because it’s very slow)

  • warningif True, raise a warning when the trait is referenced.

    Otherwise, raise an exception.

get(obj, name)[source]#
set(obj, name, value)[source]#
class cytoflow.utility.custom_traits.Deprecated(**metadata)[source]#

Bases: TraitType

Names a trait that was present in a previous version but was renamed. When the trait is accessed, a warning is raised, and the access is passed through to the new trait.

Trait metadata:
  • new : the name of the new trait

  • err_string : the error string in the error

  • gui : if True, don’t return a backtrace (because it’s very slow)

get(obj, name)[source]#
set(obj, name, value)[source]#
class cytoflow.utility.custom_traits.ChangedStr(**metadata)[source]#

Bases: BaseStr

When an invalid type is set, return a custom string.

error(_, name, value)[source]#

Raises a TraitError exception.

This method is called by the validate() method when an assigned value is not valid. Raising a TraitError exception either notifies the user of the problem, or, in the case of compound traits, provides a chance for another trait handler to handle to validate the value.

Parameters:
  • object (object) – The object whose attribute is being assigned.

  • name (str) – The name of the attribute being assigned.

  • value (object) – The proposed new value for the attribute.