QuantizationJob

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=1]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjadext/nauert/../../abjad/system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; } subgraph "cluster_abjadext.nauert" { graph [label="abjadext.nauert"]; node [color=2]; "abjadext.nauert.QuantizationJob.QuantizationJob" [URL="../api/abjadext/nauert/QuantizationJob.html#abjadext.nauert.QuantizationJob.QuantizationJob", color=black, fontcolor=white, label="Quantization\nJob", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadObject.AbjadObject" -> "abjadext.nauert.QuantizationJob.QuantizationJob"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

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

Quantization job.

Copiable, picklable class for generating all QGrids which are valid under a given SearchTree for a sequence of QEventProxies.

>>> q_event_a = abjadext.nauert.PitchedQEvent(250, [0, 1])
>>> q_event_b = abjadext.nauert.SilentQEvent(500)
>>> q_event_c = abjadext.nauert.PitchedQEvent(750, [3, 7])
>>> proxy_a = abjadext.nauert.QEventProxy(q_event_a, 0.25)
>>> proxy_b = abjadext.nauert.QEventProxy(q_event_b, 0.5)
>>> proxy_c = abjadext.nauert.QEventProxy(q_event_c, 0.75)
>>> definition = {2: {2: None}, 3: None, 5: None}
>>> search_tree = abjadext.nauert.UnweightedSearchTree(definition)
>>> job = abjadext.nauert.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.


Attributes Summary

__call__ Calls quantization job.
__eq__ 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.
__hash__ Hashes quantization job.
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.

Special methods

__call__()

Calls quantization job.

Returns none.

__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.

__hash__()

Hashes quantization job.

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

Returns integer.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Read-only properties

job_id

The job id of the QuantizationJob.

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

Returns int.

q_event_proxies

The QEventProxies the QuantizationJob was instantiated with.

>>> q_event_a = abjadext.nauert.PitchedQEvent(250, [0, 1])
>>> q_event_b = abjadext.nauert.SilentQEvent(500)
>>> q_event_c = abjadext.nauert.PitchedQEvent(750, [3, 7])
>>> proxy_a = abjadext.nauert.QEventProxy(q_event_a, 0.25)
>>> proxy_b = abjadext.nauert.QEventProxy(q_event_b, 0.5)
>>> proxy_c = abjadext.nauert.QEventProxy(q_event_c, 0.75)
>>> definition = {2: {2: None}, 3: None, 5: None}
>>> search_tree = abjadext.nauert.UnweightedSearchTree(definition)
>>> job = abjadext.nauert.QuantizationJob(
...     1, search_tree, [proxy_a, proxy_b, proxy_c])
>>> job()
>>> for q_event_proxy in job.q_event_proxies:
...     print(format(q_event_proxy, 'storage'))
...
abjadext.nauert.QEventProxy(
    abjadext.nauert.PitchedQEvent(
        offset=abjad.Offset(250, 1),
        pitches=(
            abjad.NamedPitch("c'"),
            abjad.NamedPitch("cs'"),
            ),
        ),
    abjad.Offset(1, 4)
    )
abjadext.nauert.QEventProxy(
    abjadext.nauert.SilentQEvent(
        offset=abjad.Offset(500, 1),
        ),
    abjad.Offset(1, 2)
    )
abjadext.nauert.QEventProxy(
    abjadext.nauert.PitchedQEvent(
        offset=abjad.Offset(750, 1),
        pitches=(
            abjad.NamedPitch("ef'"),
            abjad.NamedPitch("g'"),
            ),
        ),
    abjad.Offset(3, 4)
    )

Returns tuple.

q_grids

The generated QGrids.

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

Returns tuple.

search_tree

The search tree the QuantizationJob was instantiated with.

Return SearchTree instance.