fsleyes_props.properties_types
¶
Definitions for different property types.
This module provides a number of PropertyBase
subclasses which
define properties of different types. These classes are intended to be
added as attributes of a HasProperties
class definition.
Object
A property which encapsulates any value. Boolean
A property which encapsulates a bool
value.Number
Base class for the Int
andReal
classes.Int
A Number
which encapsulates an integer.Real
A Number
which encapsulates a floating point number.Percentage
A Real
property which represents a percentage.String
A property which encapsulates a string. Choice
A property which may only be set to one of a set of predefined values. FilePath
A property which represents a file or directory path. List
A property which represents a list of items, of another property type. Colour
A property which represents a RGBA colour, stored as four floating point values in the range 0.0 - 1.0
.ColourMap
A property which encapsulates a matplotlib.colors.Colormap
.Bounds
A property which represents numeric bounds in any number of dimensions, as long as that number is no more than 4. Point
A property which represents a point in some n-dimensional (up to 4) space. Array
A property which represents a numpy
array.
-
class
fsleyes_props.properties_types.
Object
(**kwargs)¶ Bases:
fsleyes_props.properties.PropertyBase
A property which encapsulates any value.
Create a
Object
property. If anequalityFunc
is not provided, any writes to this property will be treated as if the value has changed (and any listeners will be notified).-
__init__
(**kwargs)¶ Create a
Object
property. If anequalityFunc
is not provided, any writes to this property will be treated as if the value has changed (and any listeners will be notified).
-
__module__
= 'fsleyes_props.properties_types'¶
-
-
class
fsleyes_props.properties_types.
Boolean
(**kwargs)¶ Bases:
fsleyes_props.properties.PropertyBase
A property which encapsulates a
bool
value.Create a
Boolean
property.If the
default
kwarg
is not provided, a default value ofFalse
is used.-
__init__
(**kwargs)¶ Create a
Boolean
property.If the
default
kwarg
is not provided, a default value ofFalse
is used.
-
cast
(instance, attributes, value)¶ Overrides
PropertyBase.cast()
. Casts the given value to abool
.
-
__module__
= 'fsleyes_props.properties_types'¶
-
-
class
fsleyes_props.properties_types.
Number
(minval=None, maxval=None, clamped=False, **kwargs)¶ Bases:
fsleyes_props.properties.PropertyBase
Base class for the
Int
andReal
classes.A property which represents a number. Don’t use/subclass this, use/subclass one of
Int
orReal
.Define a
Number
property.Parameters: - minval – Minimum valid value
- maxval – Maximum valid value
- clamped – If
True
, the value will be clamped to its min/max bounds. - kwargs – Passed through to
PropertyBase.__init__()
. If adefault
value is not provided, it is set to something sensible.
-
__init__
(minval=None, maxval=None, clamped=False, **kwargs)¶ Define a
Number
property.Parameters: - minval – Minimum valid value
- maxval – Maximum valid value
- clamped – If
True
, the value will be clamped to its min/max bounds. - kwargs – Passed through to
PropertyBase.__init__()
. If adefault
value is not provided, it is set to something sensible.
-
validate
(instance, attributes, value)¶ Overrides
PropertyBase.validate()
. Validates the given number.Calls the
PropertyBase.validate()
method. Then, if theminval
and/ormaxval
attributes have been set, and the given value is not within those values, aValueError
is raised.Parameters: - instance – The owning
HasProperties
instance (orNone
for unbound property values). - attributes – Dictionary containing property attributes.
- value – The value to validate.
- instance – The owning
-
cast
(instance, attributes, value)¶ Overrides
PropertyBase.cast()
.If the
clamped
attribute isTrue
and theminval
and/ormaxval
have been set, this function ensures that the given value lies within theminval
andmaxval
limits. Otherwise the value is returned unchanged.
-
__module__
= 'fsleyes_props.properties_types'¶
-
class
fsleyes_props.properties_types.
Int
(**kwargs)¶ Bases:
fsleyes_props.properties_types.Number
A
Number
which encapsulates an integer.Create an
Int
property.-
__init__
(**kwargs)¶ Create an
Int
property.
-
cast
(instance, attributes, value)¶ Overrides
Number.cast()
. Casts the given value to anint
, and then passes the value toNumber.cast()
.
-
__module__
= 'fsleyes_props.properties_types'¶
-
-
class
fsleyes_props.properties_types.
Real
(precision=1e-09, **kwargs)¶ Bases:
fsleyes_props.properties_types.Number
A
Number
which encapsulates a floating point number.Define a
Real
property.Parameters: precision – Tolerance for equality testing. Set to None
to use exact equality.-
__init__
(precision=1e-09, **kwargs)¶ Define a
Real
property.Parameters: precision – Tolerance for equality testing. Set to None
to use exact equality.
-
cast
(instance, attributes, value)¶ Overrides
Number.cast()
. Casts the given value to afloat
, and then passes the value toNumber.cast()
.
-
_Real__equals
(a, b)¶ Custom equality function passed to :class`.PropertyBase.__init__`.
Tests for equality according to the
precision
passed to__init__()
.
-
__module__
= 'fsleyes_props.properties_types'¶
-
-
class
fsleyes_props.properties_types.
Percentage
(**kwargs)¶ Bases:
fsleyes_props.properties_types.Real
A
Real
property which represents a percentage.A
Percentage
property is just aReal
property with a default minimum value of0
and default maximum value of100
.Create a
Percentage
property.-
__init__
(**kwargs)¶ Create a
Percentage
property.
-
__module__
= 'fsleyes_props.properties_types'¶
-
-
class
fsleyes_props.properties_types.
String
(minlen=None, maxlen=None, **kwargs)¶ Bases:
fsleyes_props.properties.PropertyBase
A property which encapsulates a string.
Cteate a
String
property.Parameters: - minlen (int) – Minimum valid string length.
- maxlen (int) – Maximum valid string length.
-
__init__
(minlen=None, maxlen=None, **kwargs)¶ Cteate a
String
property.Parameters: - minlen (int) – Minimum valid string length.
- maxlen (int) – Maximum valid string length.
-
cast
(instance, attributes, value)¶ Overrides
PropertyBase.cast()
.Casts the given value to a string. If the given value is the empty string, it is replaced with
None
.
-
validate
(instance, attributes, value)¶ Overrides
PropertyBase.validate()
.Passes the given value to
PropertyBase.validate()
. Then, if either theminlen
ormaxlen
attributes have been set, and the given value has length less thanminlen
or greater thanmaxlen
, raises aValueError
.
-
__module__
= 'fsleyes_props.properties_types'¶
-
class
fsleyes_props.properties_types.
Choice
(choices=None, alternates=None, allowStr=False, **kwargs)¶ Bases:
fsleyes_props.properties.PropertyBase
A property which may only be set to one of a set of predefined values.
Choices can be added/removed via the
addChoice()
,removeChoice()
method, andsetChoices()
methods. Existing choices can be modified with theupdateChoice()
method.Individual choices can be enabled/disabled via the
enableChoice()
anddisableChoice()
methods. ThechoiceEnabled
attribute contains a dictionary of{choice : boolean}
mappings representing the enabled/disabled state of each choice.A set of alternate values can be provided for each choice - these alternates will be accepted when assigning to a
Choice
property.Note
If you create a
Choice
property with non-string choice and alternate values, you may run into problems when usingserialise
and/orcli
functionality, unless you setallowStr
toTrue
.Create a
Choice
property.Parameters: - choices – List of values, the possible values that this property
can take. Can alternately be a
dict
- see the note above. - alternates – A list of lists, specificying alternate acceptable
values for each choice. Can also be a dict of
{choice : [alternates]}
mappings. All alternate values must be unique - different choices cannot have equivalent alternate values. - allowStr – If
True
, string versions of any non-string choice values will be accepted -str
versions of each choice are added as alternate values for that choice. Defaults toFalse
.
-
__init__
(choices=None, alternates=None, allowStr=False, **kwargs)¶ Create a
Choice
property.Parameters: - choices – List of values, the possible values that this property
can take. Can alternately be a
dict
- see the note above. - alternates – A list of lists, specificying alternate acceptable
values for each choice. Can also be a dict of
{choice : [alternates]}
mappings. All alternate values must be unique - different choices cannot have equivalent alternate values. - allowStr – If
True
, string versions of any non-string choice values will be accepted -str
versions of each choice are added as alternate values for that choice. Defaults toFalse
.
- choices – List of values, the possible values that this property
can take. Can alternately be a
-
setDefault
(default, instance=None)¶ Sets the default choice value.
-
enableChoice
(choice, instance=None)¶ Enables the given choice.
-
disableChoice
(choice, instance=None)¶ Disables the given choice. An attempt to set the property to a disabled value will result in a
ValueError
.
-
choiceEnabled
(choice, instance=None)¶ Returns
True
if the given choice is enabled,False
otherwise.
-
getChoices
(instance=None)¶ Returns a list of the current choices.
-
getAlternates
(instance=None)¶ Returns a list of the current acceptable alternate values for each choice.
-
updateChoice
(choice, newChoice=None, newAlt=None, instance=None)¶ Updates the choice value and/or alternates for the specified choice.
-
setChoices
(choices, alternates=None, instance=None)¶ Sets the list of possible choices (and their alternate values, if not None).
-
addChoice
(choice, alternate=None, instance=None)¶ Adds a new choice to the list of possible choices.
-
removeChoice
(choice, instance=None)¶ Removes the specified choice from the list of possible choices.
-
validate
(instance, attributes, value)¶ Overrides
PropertyBase.validate()
.Raises a
ValueError
if the given value is not one of the possible values for thisChoice
property.
-
cast
(instance, attributes, value)¶ Overrides
PropertyBase.cast()
.Checks to see if the given value is a valid alternate value for a choice. If so, the alternate value is replaced with the choice value.
-
_Choice__generateAlternatesDict
(altLists)¶ Given a dictionary containing
{choice : [alternates]}
mappings, creates and returns a dictionary containing{alternate : choice}
mappings.Raises a
ValueError
if there are any duplicate alternate values.
-
_Choice__updateChoices
(choices, alternates, instance=None)¶ Used by all of the public choice modifying methods. Updates all choices, labels, and altenrates.
Parameters: - choices – A list of choice values
- alternates – A dict of
{choice : [alternates]}
mappings.
-
__module__
= 'fsleyes_props.properties_types'¶
- choices – List of values, the possible values that this property
can take. Can alternately be a
-
class
fsleyes_props.properties_types.
FilePath
(exists=False, isFile=True, suffixes=None, **kwargs)¶ Bases:
fsleyes_props.properties_types.String
A property which represents a file or directory path.
There is currently no support for validating a path which may be either a file or a directory - only one or the other.
Create a
FilePath
property.Parameters: - exists (bool) – If
True
, the path must exist. - isFile (bool) – If
True
, the path must be a file. IfFalse
, the path must be a directory. This check is only performed ifexists
isTrue
. - suffixes (list) – List of acceptable file suffixes (only relevant
if
isFile
isTrue
).
-
__init__
(exists=False, isFile=True, suffixes=None, **kwargs)¶ Create a
FilePath
property.Parameters: - exists (bool) – If
True
, the path must exist. - isFile (bool) – If
True
, the path must be a file. IfFalse
, the path must be a directory. This check is only performed ifexists
isTrue
. - suffixes (list) – List of acceptable file suffixes (only relevant
if
isFile
isTrue
).
- exists (bool) – If
-
validate
(instance, attributes, value)¶ Overrides
PropertyBase.validate()
.If the
exists
attribute is notTrue
, does nothing. Otherwise, ifisFile
isFalse
and the given value is not a path to an existing directory, aValueError
is raised.If
isFile
isTrue
, and the given value is not a path to an existing file (which, ifsuffixes
is not None, must end in one of the specified suffixes), aValueError
is raised.
-
__module__
= 'fsleyes_props.properties_types'¶
- exists (bool) – If
-
class
fsleyes_props.properties_types.
List
(listType=None, minlen=None, maxlen=None, **kwargs)¶ Bases:
fsleyes_props.properties.ListPropertyBase
A property which represents a list of items, of another property type.
If you use
List
properties, you really should read the documentation for thePropertyValueList
, as it contains important usage information.Create a
List
property.Parameters: - listType – A
PropertyBase
type, specifying the values allowed in the list. IfNone
, anything can be stored in the list, but no casting or validation will occur. - minlen (int) – Minimum list length.
- maxlen (int) – Maximum list length.
-
__init__
(listType=None, minlen=None, maxlen=None, **kwargs)¶ Create a
List
property.Parameters: - listType – A
PropertyBase
type, specifying the values allowed in the list. IfNone
, anything can be stored in the list, but no casting or validation will occur. - minlen (int) – Minimum list length.
- maxlen (int) – Maximum list length.
- listType – A
-
validate
(instance, attributes, value)¶ Overrides
PropertyBase.validate()
.Checks that the given value (which should be a list) meets the
minlen
/maxlen
attribute. Raises aValueError
if it does not.
-
__module__
= 'fsleyes_props.properties_types'¶
- listType – A
-
class
fsleyes_props.properties_types.
Colour
(**kwargs)¶ Bases:
fsleyes_props.properties.PropertyBase
A property which represents a RGBA colour, stored as four floating point values in the range
0.0 - 1.0
.RGB colours are also accepted - if an RGB colour is provided, the alpha channel is set to 1.0.
Create a
Colour
property.If the
default
kwarg
is not provided, the default is set to white.-
__init__
(**kwargs)¶ Create a
Colour
property.If the
default
kwarg
is not provided, the default is set to white.
-
validate
(instance, attributes, value)¶ Checks the given
value
, and raises aValueError
if it does not consist of three or four floating point numbers in the range(0.0 - 1.0)
.
-
cast
(instance, attributes, value)¶ Ensures that the given
value
contains three or four floating point numbers, in the range(0.0 - 1.0)
.If the alpha channel is not provided, it is set to the current alpha value (which defaults to
1.0
).
-
__module__
= 'fsleyes_props.properties_types'¶
-
-
class
fsleyes_props.properties_types.
ColourMap
(cmaps=None, **kwargs)¶ Bases:
fsleyes_props.properties.PropertyBase
A property which encapsulates a
matplotlib.colors.Colormap
.A
ColourMap
property can take anyColormap
instance as its value. ColourMap values may be specified either as aColormap
instance, or as a string containing the name of a registered colour map instance.ColourMap
properties also maintain an internal list of colour map names; while these names do not restrict the value that aColourMap
property can take, they are used for display purposes - a widget which is created for aColourMap
instance will only display the options returned by thegetColourMaps()
method. See thewidgets._ColourMap()
function.Define a
ColourMap
property.-
__init__
(cmaps=None, **kwargs)¶ Define a
ColourMap
property.
-
setColourMaps
(cmaps, instance=None)¶ Set the colour maps for this property.
Parameters: cmaps – a list of registered colour map names.
-
addColourMap
(cmap, instance=None)¶ Add a colour map to the list.
Parameters: cmap – The name of a registered colour map.
-
getColourMaps
(instance=None)¶ Returns a list containing the names of registered colour maps available for this property.
-
validate
(instance, attributes, value)¶ Overrides
PropertyBase.validate()
.Raises a
ValueError
if the givenvalue
is not a matplotlibColormap
instance.
-
cast
(instance, attributes, value)¶ Overrides
PropertyBase.cast()
.If the provided value is a string, an attempt is made to convert it to a colour map, via the
matplotlib.cm.get_cmap()
function. The value may either be the registered colour map name, or itsColormap.name
attribute. The match is case-insensitive.
-
__module__
= 'fsleyes_props.properties_types'¶
-
-
class
fsleyes_props.properties_types.
BoundsValueList
(*args, **kwargs)¶ Bases:
fsleyes_props.properties_value.PropertyValueList
A
PropertyValueList
with values which represent bounds along a number of dimensions (up to 4).This class is used by the
Bounds
property to encapsulate bounding values for an arbitrary number of dimensions. ForN+1
dimensions, the bounding values are stored as a list:[lo0, hi0, lo1, hi1, ..., loN, hiN]
This class just adds some convenience methods and attributes to the
PropertyValueList
base class. For a single dimension, a bound object has alo
value and ahi
value, specifying the bounds along that dimension. To make things confusing, each dimension also hasmin
andmax
attributes, which define the minimum/maximum values that thelo
andhigh
values may take for that dimension.Some dynamic attributes are available on
BoundsValueList
objects, allowing access to and assignment of bound values and attributes. Dimensions0, 1, 2, 3
respectively map to identifiersx, y, z, t
. If an attempt is made to access/assign an attribute corresponding to a dimension which does not exist on a particularBoundsValueList
instance (e.g. attributet
on a 3-dimensional list), anIndexError
will be raised. Here is an example of dynamic bound attribute access:class MyObj(props.HasProperties): myBounds = Bounds(ndims=4) obj = MyObj() # set/access lo/hi values together xlo, xhi = obj.mybounds.x obj.mybounds.z = (25, 30) # set/access lo/hi values separately obj.mybounds.xlo = 2 obj.mybounds.zhi = 50 # get the length of the bounds for a dimension ylen = obj.mybounds.ylen # set/access the minimum/maximum # constraints for a dimension obj.mybounds.xmin = 0 tmax = obj.mybounds.tmax
Create a
BoundsValueList
instance - seePropertyValueList.__init__()
.-
__init__
(*args, **kwargs)¶ Create a
BoundsValueList
instance - seePropertyValueList.__init__()
.
-
getLo
(axis=None)¶ Return the low value for the given (0-indexed) axis. If
axis
is not specified, the low bounds for all axes are returned.
-
getHi
(axis=None)¶ Return the high value for the given (0-indexed) axis. If
axis
is not specified, the high bounds for all axes are returned.
-
getRange
(axis)¶ Return the (low, high) values for the given (0-indexed) axis.
-
getLen
(axis)¶ Return the distance between the low and high values for the specified axis.
-
setLimit
(axis, limit, value)¶ Sets the value for the specified axis and limit (0 == low, 1 == high).
-
getLimit
(axis, limit)¶ Returns the value for the specified axis and limit (0 == low, 1 == high).
-
setLo
(axis, value)¶ Set the low value for the specified axis.
-
setHi
(axis, value)¶ Set the high value for the specified axis.
-
setRange
(axis, loval, hival)¶ Set the low and high values for the specified axis.
-
getMin
(axis)¶ Return the minimum value (the low limit) for the specified axis.
-
getMax
(axis)¶ Return the maximum value (the high limit) for the specified axis.
-
setMin
(axis, value)¶ Set the minimum value for the specified axis.
-
setMax
(axis, value)¶ Set the maximum value for the specified axis.
-
getLimits
(axis)¶ Return (minimum, maximum) limit values for the specified axis.
-
setLimits
(axis, minval, maxval)¶ Set the minimum and maximum limit values for the specified axis.
-
inBounds
(point)¶ Returns
True
if the given point (a sequence of numbers) lies within the bounds represented by thisBoundsValueList
,False
otherwise.
-
__getattr__
(name)¶ Return the specified value. Raises an
AttributeError
for unrecognised attributes, or anIndexError
if an attempt is made to access bound values values of a higher dimension than this list contains.
-
__setattr__
(name, value)¶ Set the specified value. Raises an
IndexError
if an attempt is made to assign bound values values of a higher dimension than this list contains.
-
__module__
= 'fsleyes_props.properties_types'¶
-
-
class
fsleyes_props.properties_types.
Bounds
(ndims=1, real=True, minDistance=None, clamped=True, **kwargs)¶ Bases:
fsleyes_props.properties_types.List
A property which represents numeric bounds in any number of dimensions, as long as that number is no more than 4.
Bounds
values are stored in aBoundsValueList
, a list of integer or floating point values, with two values (lo, hi) for each dimension.Bounds
values may also have bounds of their own, i.e. minimium/maximum values that the bound values can take. These bound-limits are referred to as ‘min’ and ‘max’, and can be set via theBoundsValueList.setMin()
andBoundsValueList.setMax()
methods. The advantage to using these methods, instead of using, for example,PropertyValue.setAttribute()
, is that if you use the latter you will have to set the attributes on both the low and the high values.Create a
Bounds
property.Parameters: - ndims – Number of dimensions. This is (currently) not a property attribute, hence it cannot be changed.
- real – If
True
(the default), the bound values are stored asReal
values; otherwise, they are stored asInt
values. - minDistance – Minimum distance to be maintained between the low/high values for each dimension.
- clamped – If
True
(the default), the bound values are clamped to their limits. See theNumber
class.
-
__init__
(ndims=1, real=True, minDistance=None, clamped=True, **kwargs)¶ Create a
Bounds
property.Parameters: - ndims – Number of dimensions. This is (currently) not a property attribute, hence it cannot be changed.
- real – If
True
(the default), the bound values are stored asReal
values; otherwise, they are stored asInt
values. - minDistance – Minimum distance to be maintained between the low/high values for each dimension.
- clamped – If
True
(the default), the bound values are clamped to their limits. See theNumber
class.
-
_makePropVal
(instance)¶ Overrides
ListPropertyBase._makePropVal()
.Creates and returns a
BoundsValueList
instead of aPropertyValueList
, so callers get to use the convenience methods/attributes defined in the BVL class.
-
validate
(instance, attributes, value)¶ Overrides
PropertyBase.validate()
.Raises a
ValueError
if the given value (a list of min/max values) is of the wrong length or data type, or if any of the min values are greater than the corresponding max value.
-
__module__
= 'fsleyes_props.properties_types'¶
-
class
fsleyes_props.properties_types.
PointValueList
(*args, **kwargs)¶ Bases:
fsleyes_props.properties_value.PropertyValueList
A list of values which represent a point in some n-dimensional (up to 4) space.
This class is used by the
Point
property to encapsulate point values for between 1 and 4 dimensions.This class just adds some convenience methods and attributes to the
PropertyValueList
base class, in a similar manner to theBoundsValueList
class.The point values for each dimension may be queried/assigned via the dynamic attributes
x, y, z, t
, which respectively map to dimensions0, 1, 2, 3
. When querying/assigning point values, you may use GLSL-like swizzling. For example:class MyObj(props.HasProperties): mypoint = props.Point(ndims=3) obj = MyObj() y,z = obj.mypoint.yz obj.mypoint.zxy = (3,6,1)
Create a
PointValueList
- seePropertyValueList.__init__()
.-
__init__
(*args, **kwargs)¶ Create a
PointValueList
- seePropertyValueList.__init__()
.
-
getPos
(axis)¶ Return the point value for the specified (0-indexed) axis.
-
setPos
(axis, value)¶ Set the point value for the specified axis.
-
getMin
(axis)¶ Get the minimum limit for the specified axis.
-
getMax
(axis)¶ Get the maximum limit for the specified axis.
-
getLimits
(axis)¶ Get the (minimum, maximum) limits for the specified axis.
-
setMin
(axis, value)¶ Set the minimum limit for the specified axis.
-
setMax
(axis, value)¶ Set the maximum limit for the specified axis.
-
setLimits
(axis, minval, maxval)¶ Set the minimum and maximum limits for the specified axis.
-
__getattr__
(name)¶ Return the specified point value. Raises an
AttributeError
for unrecognised attributes, or anIndexError
if a dimension which does not exist for thisPointValueList
is specified.
-
__setattr__
(name, value)¶ Set the specified point value. Raises an
IndexError
if a dimension which does not exist for thisPointValueList
is specified.
-
__module__
= 'fsleyes_props.properties_types'¶
-
-
class
fsleyes_props.properties_types.
Point
(ndims=2, real=True, **kwargs)¶ Bases:
fsleyes_props.properties_types.List
A property which represents a point in some n-dimensional (up to 4) space.
Point
property values are stored in aPointValueList
, a list of integer or floating point values, one for each dimension.Create a
Point
property.Parameters: -
__init__
(ndims=2, real=True, **kwargs)¶ Create a
Point
property.Parameters:
-
_makePropVal
(instance)¶ Overrides
ListPropertyBase._makePropVal()
.Creates and returns a
PointValueList
instead of aPropertyValueList
, so callers get to use the convenience methods/attributes defined in the PVL class.
-
__module__
= 'fsleyes_props.properties_types'¶
-
-
class
fsleyes_props.properties_types.
ArrayProxy
(*args, **kwargs)¶ Bases:
fsleyes_props.properties_value.PropertyValue
A proxy class indended to encapsulate a
numpy
array.ArrayProxy
instances are used by theArray
property type.An
ArrayProxy
is aPropertyValue
which contains, and tries to act like, anumpy
array. Element access andassignment, and attribute access can be performed through theArrayProxy
.All element assignments which occur via an
ArrayProxy
instance will result in notification of all registered listeners (see thePropertyValue.addListener()
method). A limitation of this implementation is that notification will occur even if the assignment does not change the array values.The underlying
numpy
array is accessible via thegetArray()
method. However, changes made directly to the numpy array will bypass thePropertyValue
notification procedure.Create an
ArrayProxy
. All arguments are passed through to thePropertyValue.__init__()
method.-
__init__
(*args, **kwargs)¶ Create an
ArrayProxy
. All arguments are passed through to thePropertyValue.__init__()
method.
-
get
()¶ Overrides
PropertyValue.get()
. Returns thisArrayProxy
.
-
getArray
()¶ Returns a reference to the
numpy
array encapsulated by thisArrayProxy
.
-
__getattr__
(name)¶ Returns the attribute of the
numpy
array with the given name.
-
__getitem__
(*args, **kwargs)¶ Calls the
__getitem``__ method of the ``numpy
array.
-
__setitem__
(*args, **kwargs)¶ Calls the
__setitem__
method of thenumpy
array, and triggers notification of all registered listeners.
-
__module__
= 'fsleyes_props.properties_types'¶
-
-
class
fsleyes_props.properties_types.
Array
(dtype=None, shape=None, resizable=True, **kwargs)¶ Bases:
fsleyes_props.properties.PropertyBase
A property which represents a
numpy
array. Each array is encapsulated within anArrayProxy
instance.Create an
Array
property.Warning
If you set a
default
value here (seePropertyBase.__init__()
), do not use anumpy
array - use a regular python list. It will be converted in anumpy
array internally. An equality test is made on thedefault
attribute, so if you use anumpy
array, aValueError
will be raised, asnumpy
performs equality tests on an element-wise basis.Parameters: - dtype –
numpy
data type. - shape – Initial shape of the array.
- resizable – Defaults to
True
. IfFalse
, the array size will be fixed to theshape
specified here. Different sized arrays will still be allowed, if theallowInvalid
parameter toPropertyBase.__init__()
is set toTrue
.
-
__init__
(dtype=None, shape=None, resizable=True, **kwargs)¶ Create an
Array
property.Warning
If you set a
default
value here (seePropertyBase.__init__()
), do not use anumpy
array - use a regular python list. It will be converted in anumpy
array internally. An equality test is made on thedefault
attribute, so if you use anumpy
array, aValueError
will be raised, asnumpy
performs equality tests on an element-wise basis.Parameters: - dtype –
numpy
data type. - shape – Initial shape of the array.
- resizable – Defaults to
True
. IfFalse
, the array size will be fixed to theshape
specified here. Different sized arrays will still be allowed, if theallowInvalid
parameter toPropertyBase.__init__()
is set toTrue
.
- dtype –
-
_makePropVal
(instance)¶ Overrides :meth`.PropertyBase._makePropVal`. Creates and returns an
ArrayProxy
for the giveninstance
.
-
cast
(instance, attributes, value)¶ Overrides :meth`.PropertyBase.cast`. Casts the given value to a
numpy
array (with the data type that was specified in__init__()
).
-
validate
(instance, attributes, value)¶ Overrides :meth`.PropertyBase.validate`. If the given
value
has the wrong data type, or thisArray
is not resizable and thevalue
has the wrong shape, aValueError
is raised.
-
__module__
= 'fsleyes_props.properties_types'¶
- dtype –