Pattern

class octa.patterns.Pattern.Pattern(pattern, patterntype='', patterndirection='', patternclass='Pattern')

Methods

octa.patterns.Pattern.Pattern.RepeatPattern(self, n_repeats, max_elements=None)

Repeats the pattern as a whole.

Parameters
  • n_repeats (int) – How many times the pattern needs to be repeated.

  • max_elements (int, optional) – Maximum number of elements in the resulting pattern. The default is None.

Returns

Updated Pattern instance.

Return type

Pattern

octa.patterns.Pattern.Pattern.RepeatElements(self, n_repeats, max_elements=None)

Repeats each element in the pattern.

Parameters
  • n_repeats (int) – How many times each elements needs to be repeated.

  • max_elements (int, optional) – Maximum number of elements in the resulting pattern. If specified, the pattern will be truncated to this number of elements if the total length is exceeded after applying the repetition. The default is None.

Returns

Updated Pattern instance.

Return type

Pattern

octa.patterns.Pattern.Pattern.RepeatPatternToSize(self, count)

Repeats the pattern until the total pattern length is equal to or exceeds the requested count. If the total pattern length exceeds the count, the pattern is truncated.

Parameters

count (int) – Required number of elements in the pattern.

Returns

Updated Pattern instance.

Return type

Pattern

octa.patterns.Pattern.Pattern.RepeatElementsToSize(self, count)

Repeats the elements in the pattern until the total pattern length is equal or exceeds to the requested count. If the total pattern length exceeds the count, the pattern is truncated.

Parameters

count (int) – Required number of elements in the pattern.

Returns

Updated Pattern instance.

Return type

Pattern

octa.patterns.Pattern.Pattern.AddNormalJitter(self, mu=0, std=1, axis=None)

Adds a sample from a random normal distribution to each element in the pattern.

Parameters
  • mu (float, optional) – Mean of the normal distribution. The default is 0.

  • std (float, optional) – Standard deviation of the normal distribution. The default is 1.

  • axis (string, optional) – String that contains the axis to which jitter should be applied. Possible values are “x”, “y”, “xy” or “x=y”.

Returns

Updated Pattern instance.

Return type

Pattern

octa.patterns.Pattern.Pattern.AddUniformJitter(self, min_val=- 1, max_val=1, axis=None)

Adds a sample from a uniform distribution to each element in the pattern.

Parameters
  • min_val (float, optional) – Lower bound of the uniform distribution

  • max_val (float, optional) – Upper bound of the uniform distribution

  • axis (string, optional) – String that contains the axis to which jitter should be applied. Possible values are “x”, “y”, “xy” or “x=y”.

Returns

Updated Pattern instance.

Return type

Pattern

octa.patterns.Pattern.Pattern.RandomizeOrder(self)

Randomizes the order of the elements in the pattern.

Returns

Updated Pattern instance.

Return type

Pattern

octa.patterns.Pattern.Pattern.CreateGradientPattern(start_value, end_value, n_elements)

Private method for creating a list of gradient values, taking into account the type of start and end value.

Parameters
  • start_value (string, int, float, or tuple) – Value for the first element in the list.

  • end_value (string, int, float, or tuple) – Value for the last element in the list.

  • n_elements (int) – Total number of elements in the list of gradient values.

Returns

Updated Pattern instance.

Return type

Pattern

octa.patterns.Pattern.Pattern.CreateNumberRangeList(start_number, end_number, n_elements)

Creates a range of numbers, starting at start_number and ending with end_number (included).

Parameters
  • start_number (int or float) – First number in the list.

  • end_number (int or float) – Final number in the list.

  • n_elements (int) – Total number of elements in the list. Value must be >= 2.

Returns

number_range – A range of numbers.

Return type

list

octa.patterns.Pattern.Pattern.CreateColorRangeList(start_color, end_color, n_elements)

Creates a range of colors.

Parameters
  • start_color (string) – Name of the first color in the list.

  • end_color (string) – Name of the final color in the list.

  • n_elements (int) – Total number of colors in the list. Value must be >= 2.

Returns

color_range – A list with hexadecimal color values.

Return type

list

octa.patterns.Pattern.Pattern.Create2DGradient(x, y, n_elements)

Creates a 2D gradient

Parameters
  • x (list) – List of x coordinates (can also be a Sequence or LinearGradient)

  • y (list) – List of y coordinates (can also be a Sequence or LinearGradient)

  • n_elements (int) – Total number of elements in the list.

Returns

result – A list of tuples.

Return type

list

octa.patterns.Pattern.Sequence(start, step)

Creates a sequence based on a start value and a step size.

Parameters
  • start (int or float) – Numeric start value.

  • step (int or float) – Numeric step size.

octa.patterns.Pattern.LinearGradient(start, end, n_elements, invert=False)

Creates a linear gradient based on a start value, an end value, and a number of elements. :Parameters: * start (int or float) – Numeric value for the first element in the list.

  • end (list) – Numeric value for the last element in the list.

  • n_elements (int) – Total number of elements in the list.

  • invert (Boolean) – Indicates whether the gradient needs to be inverted. Default is false.