Skip to content

Commit

Permalink
docs: Add latex formulas to event property docstrings (#491)
Browse files Browse the repository at this point in the history
Co-authored-by: Jakob Chwastek <[email protected]>
  • Loading branch information
dkrako and jakobchwastek authored Sep 6, 2023
1 parent 6a98c9b commit 279d886
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions src/pymovements/events/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import polars as pl


EVENT_PROPERTIES: dict[str, Callable] = {}


Expand All @@ -42,6 +41,16 @@ def amplitude(
) -> pl.Expr:
"""Amplitude of an event.
The amplitude is calculated as:
.. math::
\\text{Amplitude} = \\sqrt{(x_{\\text{max}} - x_{\\text{min}})^2 +
(y_{\\text{max}} - y_{\\text{min}})^2}
where :math:`(x_{\\text{min}},\\; x_{\\text{max}})` and
:math:`(y_{\\text{min}},\\; y_{\\text{max}})` are the minimum and maximum values of the
:math:`x` and :math:`y` components of the gaze positions during an event.
Parameters
----------
position_column
Expand Down Expand Up @@ -71,7 +80,17 @@ def dispersion(
position_column: str = 'position',
n_components: int = 2,
) -> pl.Expr:
"""Dispersion of an event.
"""
Dispersion of an event.
The dispersion is calculated as:
.. math::
\\text{Dispersion} = x_{\\text{max}} - x_{\\text{min}} + y_{\\text{max}} - y_{\\text{min}}
where :math:`(x_{\\text{min}},\\; x_{\\text{max}})` and
:math:`(y_{\\text{min}},\\; y_{\\text{max}})` are the minimum and maximum values of the
:math:`x` and :math:`y` components of the gaze positions during an event.
Parameters
----------
Expand Down Expand Up @@ -101,6 +120,14 @@ def disposition(
) -> pl.Expr:
"""Disposition of an event.
The disposition is calculated as:
.. math::
\\text{Disposition} = \\sqrt{(x_0 - x_n)^2 + (y_0 - y_n)^2}
where :math:`x_0` and :math:`y_0` are the coordinates of the starting position and
:math:`x_n` and :math:`y_n` are the coordinates of the ending position of an event.
Parameters
----------
position_column
Expand Down Expand Up @@ -143,6 +170,18 @@ def location(
) -> pl.Expr:
"""Location of an event.
For method ``mean`` the location is calculated as:
.. math::
\\text{Location} = \\frac{1}{n} \\sum_{i=1}^n \\text{position}_i
For method ``median`` the location is calculated as:
.. math::
\\text{Location} = \\text{median} \\left(\\text{position}_1, \\ldots,
\\text{position}_n \\right)
Parameters
----------
method
Expand Down Expand Up @@ -192,6 +231,14 @@ def peak_velocity(
) -> pl.Expr:
"""Peak velocity of an event.
The peak velocity is calculated as:
.. math::
\\text{Peak Velocity} = \\max \\left(\\sqrt{v_x^2 + v_y^2} \\right)
where :math:`v_x` and :math:`v_y` are the velocity components in :math:`x` and :math:`y`
direction, respectively.
Parameters
----------
velocity_column
Expand Down

0 comments on commit 279d886

Please sign in to comment.