Symmetry

class kanon.tables.symmetries.Symmetry(symtype: Literal['periodic', 'mirror'], offset: int = 0, sign: Literal[-1, 1] = 1, source: Tuple[float | Real, float | Real] | None = None, targets: List[float | Real] | None = None)[source] [edit on github]

Bases: object

Defines a symmetry strategy that can be applied on a DataFrame from a specified source interval to one or multiple target keys

>>> df = DataFrame({"val": [5, 9, 2]} ,index=[0,1,3])
>>> sym = Symmetry("mirror")
>>> df.pipe(sym)
val
0   5
1   9
3   2
5   9
6   5
>>> sym = Symmetry("periodic", sign=-1, offset=2)
>>> df.pipe(sym)
val
0   5
1   9
3   2
4  -3
5  -7
7   0
>>> sym = Symmetry("periodic", sign=-1, source=(0,1), targets=[6,10])
>>> df.pipe(sym)
val
0    5
1    9
3    2
6   -5
7   -9
10  -5
11  -9
Parameters:
  • symtype (Literal["periodic", "mirror"]) – Type of the symmetry, it can be of the same direction (periodic) or the oposite (mirror)

  • offset (int, optional) – Offset to add to the symmetry values, defaults to 0

  • sign (Sign, optional) – Relative signs of the symmetry values from source values, defaults to 1

  • source (Tuple[Real, Real], optional) – Tuple representing the lower and upper bound to take the values from, defaults to the whole DataFrame

  • targets (List[int], optional) – List of keys where the symmetry are pasted, defaults to the end of the DataFrame

Attributes Summary

offset

sign

source

targets

Methods Summary

__call__(df)

Call self as a function.

Attributes Documentation

offset: int = 0
sign: Literal[-1, 1] = 1
source: Tuple[float | Real, float | Real] | None = None
targets: List[float | Real] | None = None

Methods Documentation

__call__(df: DataFrame)[source] [edit on github]

Call self as a function.