QuantizationJob

class quantizationtools.QuantizationJob(job_id=1, search_tree=None, q_event_proxies=None, q_grids=None)

A copiable, picklable class for generating all QGrids which are valid under a given SearchTree for a sequence of QEventProxies:

>>> q_event_a = quantizationtools.PitchedQEvent(250, [0, 1])
>>> q_event_b = quantizationtools.SilentQEvent(500)
>>> q_event_c = quantizationtools.PitchedQEvent(750, [3, 7])
>>> proxy_a = quantizationtools.QEventProxy(q_event_a, 0.25)
>>> proxy_b = quantizationtools.QEventProxy(q_event_b, 0.5)
>>> proxy_c = quantizationtools.QEventProxy(q_event_c, 0.75)
>>> definition = {2: {2: None}, 3: None, 5: None}
>>> search_tree = quantizationtools.UnweightedSearchTree(definition)
>>> job = quantizationtools.QuantizationJob(
...     1, search_tree, [proxy_a, proxy_b, proxy_c])

QuantizationJob generates QGrids when called, and stores those QGrids on its q_grids attribute, allowing them to be recalled later, even if pickled:

>>> job()
>>> for q_grid in job.q_grids:
...     print(q_grid.rtm_format)
1
(1 (1 1 1 1 1))
(1 (1 1 1))
(1 (1 1))
(1 ((1 (1 1)) (1 (1 1))))

QuantizationJob is intended to be useful in multiprocessing-enabled environments.

Return QuantizationJob instance.

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_quantizationtools { graph [label=quantizationtools]; "abjad.tools.quantizationtools.QuantizationJob.QuantizationJob" [color=black, fontcolor=white, group=2, label=<<B>QuantizationJob</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.quantizationtools.QuantizationJob.QuantizationJob"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

job_id The job id of the QuantizationJob.
q_event_proxies The QEventProxies the QuantizationJob was instantiated with.
q_grids The generated QGrids.
search_tree The search tree the QuantizationJob was instantiated with.
__call__() Calls quantization job.
__eq__(argument) Is true when argument is a quantization job with job ID, search tree, q-event proxies and q-grids equal to those of this quantization job.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes quantization job.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

QuantizationJob.job_id

The job id of the QuantizationJob.

>>> job.job_id
1

Only meaningful when the job is processed via multiprocessing, as the job id is necessary to reconstruct the order of jobs.

Returns int.

QuantizationJob.q_event_proxies

The QEventProxies the QuantizationJob was instantiated with.

>>> for q_event_proxy in job.q_event_proxies:
...     print(format(q_event_proxy, 'storage'))
...
quantizationtools.QEventProxy(
    quantizationtools.PitchedQEvent(
        offset=durationtools.Offset(250, 1),
        pitches=(
            pitchtools.NamedPitch("c'"),
            pitchtools.NamedPitch("cs'"),
            ),
        ),
    durationtools.Offset(1, 4)
    )
quantizationtools.QEventProxy(
    quantizationtools.SilentQEvent(
        offset=durationtools.Offset(500, 1),
        ),
    durationtools.Offset(1, 2)
    )
quantizationtools.QEventProxy(
    quantizationtools.PitchedQEvent(
        offset=durationtools.Offset(750, 1),
        pitches=(
            pitchtools.NamedPitch("ef'"),
            pitchtools.NamedPitch("g'"),
            ),
        ),
    durationtools.Offset(3, 4)
    )

Returns tuple.

QuantizationJob.q_grids

The generated QGrids.

>>> for q_grid in job.q_grids:
...     print(q_grid.rtm_format)
1
(1 (1 1 1 1 1))
(1 (1 1 1))
(1 (1 1))
(1 ((1 (1 1)) (1 (1 1))))

Returns tuple.

QuantizationJob.search_tree

The search tree the QuantizationJob was instantiated with.

>>> job.search_tree
UnweightedSearchTree(definition={2: {2: None}, 3: None, 5: None})

Return SearchTree instance.

Special methods

QuantizationJob.__call__()

Calls quantization job.

Returns none.

QuantizationJob.__eq__(argument)

Is true when argument is a quantization job with job ID, search tree, q-event proxies and q-grids equal to those of this quantization job. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

QuantizationJob.__hash__()

Hashes quantization job.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.