Descriptor developer API¶
A Descriptor is a special kind of object which takes in one or many RecordCollection, and output one or many
RecordCollection where each enclosed Record have an additional
property.
The developer API exposes the abstract base class for all descriptors which indicates necessary interfaces to
implement to construct a valid Descriptor.
It also exposes two special kinds of Descriptor:
The
ColorEngine, which is used internally to generate acolorproperty which contains theColorused to plot aRecordfrom one or twoDescriptor.The
ByCategoryDescriptorwhich wraps aDescriptorto make it dependent on a monitored property inRecord.
-
class
plums.plot.engine.Descriptor(name)[source]¶ Bases:
objectAbstract base class for all
Descriptor.A
Descriptoris a class used to extract relevant information from a collection ofRecord.More specifically, a
Descriptoris used in two phases:In a first time, optional internals are updated and/or accumulated over the entire collection of
RecordCollectiontuples. Those internals will be used to tailor theDescriptorto the description task specific context (e.g. like updating a range of possible value to later normalize or clip a property value).In a second time, the descriptor is used to construct a new
RecordCollectionor a tuple ofRecordCollectionwhere each enclosedRecordis added a named property containing the adequate description of theRecordfrom a tuple ofRecordCollection.
Subclasses must override the two interfaces used to do so:
update(*record_collections)andcompute(*record_collections)as well as thereset()method and the_make_interface()private method.- Parameters
name (str) – The
Descriptorname.
-
name¶ The
Descriptorname.- Type
-
abstract
update(*record_collections)[source]¶ Update internal values from
Recorddescriptions.- Parameters
*record_collections (
RecordCollection) –RecordCollectionof whichRecordwill be used to update internals.
-
abstract
compute(*record_collections)[source]¶ Construct new
RecordCollectionwhere each enclosedRecordis added a named description property.- Parameters
*record_collections (
RecordCollection) –RecordCollectionused to construct newRecordCollectionwith describedRecord.- Returns
A described
RecordCollectiontuple.- Return type
(
RecordCollection, )
-
abstract
reset()[source]¶ Reset
Descriptorinternals to factory values.
-
class
plums.plot.engine.color_engine.ByCategoryDescriptor(monitored_property, descriptor)[source]¶ Bases:
plums.plot.engine.descriptor.DescriptorWrapper class to split a given
Descriptorinterface calls along a set of categories.- Parameters
monitored_property (str) – The
Recordproperty to monitor for the collection and descriptor split.descriptor (
Descriptor) – ADescriptorto split along a set of categories.
-
property
type¶ Either
categoricalorcontinuous. The enclosedDescriptortype.- Type
-
update(*record_collections)[source]¶ Update internal values of category-split
DescriptorfromRecorddescriptions.- Parameters
*record_collections (
RecordCollection) –RecordCollectionof whichRecordwill be used to update internals.
-
compute(*record_collections)[source]¶ Construct new
RecordCollectionwhere each enclosedRecordis added a named description property.- Parameters
*record_collections (
RecordCollection) –RecordCollectionused to construct newRecordCollectionwith describedRecord.- Returns
A described
RecordCollectiontuple.- Return type
(
RecordCollection, )
-
reset()[source]¶ Reset
Descriptorinternals to factory values.
-
class
plums.plot.engine.color_engine.ColorEngine(main_descriptor, secondary_descriptor=None, ctype='sRGB255')[source]¶ Bases:
plums.plot.engine.descriptor.DescriptorA special
Descriptorused to generateColorfrom one or twoDescriptor.More specifically, a
ColorEngineis used in two phases:In a first time, enclosed
Descriptorinternals are updated and/or accumulated over the entire collection ofRecordCollectiontuples.In a second time, the
ColorEngineis used to construct a newRecordCollectionwhere each enclosedRecordis added a property calledcolorcontaining aColorinstance computed from the properties computed by the enclosedDescriptor.
- Parameters
main_descriptor (
Descriptor) – The principalDescriptor. It might be a categorical descriptor or a continuous descriptor, in which case no secondary_descriptor can be provided.secondary_descriptor (
Descriptor) – Optional. Default to None. A refinementDescriptor. It might be a categorical descriptor or a continuous descriptor.ctype (str) – The color space the generated
Colorwill live in (e.g. “sRGB255” or “JCh”).
-
property
ctype¶ The color space the
ColorMaplives in (e.g. “sRGB255” or “JCh”).See also
For more information on valid color spaces, please see
Color.- Type
-
update(*record_collections)[source]¶ Update the enclosed
DescriptorfromRecordpropertynamevalue.- Parameters
*record_collections (
RecordCollection) –RecordCollectionof whichRecordwill be used to update the enclosedDescriptor.
-
compute(*record_collections)[source]¶ Construct a new
RecordCollectionwhere each enclosedRecordis added aColoras a property.- Parameters
**record_collections (
RecordCollection) –RecordCollectionused to construct newRecordCollectionwith describedRecord.- Returns
A tuple containing one
RecordCollectionwith colors.- Return type
(
RecordCollection, )
-
reset()[source]¶ Reset
DescriptorenclosedDescriptorto factory values.