order.shift

Classes and helpers to describe and work with systematic shifts.

Class Shift

class Shift(name, id, type=None, label=None, label_short=None, tags=None, aux=None)[source]

Bases: UniqueObject, CopyMixin, AuxDataMixin, TagMixin, LabelMixin

Description of a systematic shift.

Arguments

The shift name should either be "nominal" or it should have the format "<source>_<direction>" where direction is either "up" or "down". type describes the shift’s effect, which is either only rate-changing (RATE) or also shape-changing (SHAPE). When None, UNKNOWN is used.

label and label_short are forwarded to the LabelMixin, tags to the TagMixin, aux to the AuxDataMixin name and id (defaulting to an auto id) to the UniqueObject constructor.

Copy behavior

All attributes are copied.

Example

import order as od

s = od.Shift("nominal", 1)

s.name
# -> "nominal"

s.is_up
# -> False

s = Shift("pdf_up", 2)

s.source
# -> "pdf"

s.direction
# -> "up"

s.is_up
# -> True

Members

classattributeNOMINAL
type: string

Flag denoting a nominal shift ("nominal"). Same as scinum.Number.NOMINAL.

classattributeUP
type: string

Flag denoting an up variation ("up"). Same as scinum.Number.UP.

classattributeDOWN
type: string

Flag denoting a down variation ("down"). Same as scinum.Number.DOWN.

classattributeRATE
type: string

Flag denoting a rate-changing effect ("rate").

classattributeSHAPE
type: string

Flag denoting a shape-changing effect ("shape").

classattributeRATE_SHAPE
type: string

Flag denoting a both rate- and shape-changing effect ("rate_shape").

source
type: string
read-only

The source of this shift, e.g. NOMINAL, "pdf", etc.

direction
type: string
read-only

The direction of this shift, either NOMINAL, UP or DOWN.

type
type: string

The type of this shift, either RATE, SHAPE or RATE_SHAPE.

is_nominal
type: bool
read-only

Flag denoting if the shift is nominal.

is_up
type: bool
read-only

Flag denoting if the shift direction is UP.

is_down
type: bool
read-only

Flag denoting if the shift direction is DOWN.

is_rate
type: bool
read-only

Flag denoting if the shift type is rate-changing only.

is_shape
type: bool
read-only

Flag denoting if the shift type is shape-changing only.

is_rate_shape
type: bool
read-only

Flag denoting if the shift type is rate- and shape-changing.

Methods:

split_name(name)

Splits a shift name into its source and direction.

join_name(source, direction)

Joins a shift source and a shift direction to return a shift name.

classmethod split_name(name)[source]

Splits a shift name into its source and direction. If name is NOMINAL, both source and direction will be NOMINAL. Example:

split_name("nominal")  # -> ("nominal", "nominal")
split_name("pdf_up")   # -> ("pdf", "up")
split_name("pdfup")    # -> ValueError: invalid shift name format: pdfup
classmethod join_name(source, direction)[source]

Joins a shift source and a shift direction to return a shift name. If either source or direction is None, None is returned. If source is NOMINAL, direction must be NOMINAL as well. Otherwise, direction must be either UP or DOWN. Example:

join_name("nominal", "nominal")  # -> "nominal"
join_name("nominal", "up")       # -> ValueError: pointless nominal shift direction
join_name("pdf", "up")           # -> "pdf_up"
join_name("pdf", "high")         # -> ValueError: invalid shift direction