conductor.native.lib.sequence module

A Sequence is a set of positive integers representing frames.

To create a sequence, use the create method and pass either:

  • frame spec: e.g. string “1-10, 14, 20-50x4”
  • range: one, two, or three integers representing start, end, step.
  • iterable: something that implements __iter__, e.g. a list.

If the input is valid, either a Sequence or a Progression will be created. A Progression is a Sequence that can be expressed as an arithmetic progression, i.e. start,end,step.

A Sequence has methods to split itself into chunks. Chunks are subsequences and are themselves of type, Sequence or Progression.

class conductor.native.lib.sequence.Progression(start, end, step, **kw)

Bases: conductor.native.lib.sequence.Sequence

static factory(iterable, **kw)

Split a sequence of integers into arithmetic progressions.

This is not necessarily the most compact set of progressions in the sequence as that would take too long for large sets, and be really difficult to code. This algorithm walks through the sorted sequence, gathers elements with the same gap as the previous element. The max size keyword arg will limit the length of progressions.

range
step
class conductor.native.lib.sequence.Sequence(iterable, **kw)

Bases: object

A collection of frames with the ability to generate chunks.

best_chunk_size()

Determine the best distribution of frames per chunk based on the current number of chunks.

For example, if chunk size is 70 and there are 100 frames, 2 chunks will be generated with 70 and 30 frames. It would be better to have 50 frames per chunk and this method returns that number.

Note

It doesn’t make sense to use the best chunk size when chunk strategy is progressions.

chunk_count()

Calculate the number of chunks that will be emitted.

If strategy is progressions we just generate them and count the objects. Otherwise we can calculate from the frame length and chunk size directly

chunk_size

Return chunk size.

chunk_strategy

Return the current strategy for emitting chunks.

chunks()

return list of chunks according to size and chunk strategy.

Strategy can be linear, cycle, or progressions. Others may be added in future, such as binary.

  • “linear” will generate Sequences by simply walking along the list of frames and grouping so that each group has chunk_size frames. i.e. Fill chunk 1 then chunk 2 …
  • “cycle” will generate Sequences by distributing the frames in each chunk in such a way that they get filled in parallel group 1 gets frame 1, group 2 gets frame 2 and we cycle around. See _cycle_chunks()
  • “progressions” tries to walk along as in linear strategy, but with the constraint that each Sequence is a Progression and can be expressed with start, end, step. See Progression.factory()
static create(*args, **kw)

Factory which will create either a Sequence or a Progression.

A Sequence is an arbitrary list of frames with unique sorted elements. A Progression, which is a subclass of Sequence, can be expressed as an arithmetic progression: i.e. start, end, step.

end

return the last frame.

expand(template)

Expand a hash template with this sequence.

For example:

/some/directory_###/image.#####.exr.

Sequence is invalid if it contains no hashes.

  1. First we replace the hashes with a template placeholder that specifies the padding as a number.
  2. Then we use format to replace the placehoders with numbers.
intersection(iterable)

Generate a Sequence that is the intersection of an iterable with this Sequence.

This is useful for determining which scout frames are valid

is_progression()

Is this sequence a progression.

static is_valid_spec(spec)
offset(value)

Generate a new Sequence with all values offset.

It is an error if the new sequence would contain negative numbers.

static permutations(template, **kw)
start

return the first frame.

subsample(count)

Take a selection of elements from the sequence.

Return value is a new sequence where the elements are plucked in the most distributed way.

to(range_sep, step_sep, block_sep)
union(iterable)

Generate a Sequence that is the union of an iterable with this Sequence.

This is useful for getting a sequence that covers multiple output ranges.