diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 107a8921e..90b65b910 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -101,29 +101,40 @@ repos: rev: 6.1.0 hooks: - id: flake8 -- repo: https://github.com/PyCQA/pylint - rev: v3.0.0a7 - hooks: - - id: pylint - name: pylint - entry: pylint - language: system - types: [python] - files: ^src/ - args: - [ - '--output-format=parseable', - '--rcfile=pylintrc', - ] - - id: pylint - name: pylint-tests-directory - entry: pylint - language: system - types: [python] - files: ^tests/ - args: - [ - '--output-format=parseable', - '--disable=missing-class-docstring,missing-function-docstring,protected-access', - '--rcfile=pylintrc', - ] +- repo: https://github.com/pycqa/pydocstyle + rev: 6.3.0 + hooks: + - id: pydocstyle + files: ^src/ + - id: pydocstyle + files: ^tests/ + args: + [ + '--ignore=D103,D213', + ] +- repo: https://github.com/PyCQA/pylint + rev: v3.0.0a7 + hooks: + - id: pylint + name: pylint + entry: pylint + language: system + types: [python] + files: ^src/ + args: + [ + '--output-format=parseable', + '--rcfile=pylintrc', + ] + - id: pylint + name: pylint-tests-directory + entry: pylint + language: system + types: [python] + files: ^tests/ + args: + [ + '--output-format=parseable', + '--disable=missing-class-docstring,missing-function-docstring,protected-access', + '--rcfile=pylintrc', + ] diff --git a/src/pymovements/dataset/dataset.py b/src/pymovements/dataset/dataset.py index 40218e20c..7eea58629 100644 --- a/src/pymovements/dataset/dataset.py +++ b/src/pymovements/dataset/dataset.py @@ -870,7 +870,6 @@ def path(self) -> Path: Example ------- - By passing a `str` or a `Path` as `path` during initialization you can explicitly set the directory path of the dataset: >>> import pymovements as pm diff --git a/src/pymovements/dataset/dataset_definition.py b/src/pymovements/dataset/dataset_definition.py index 272f90390..018f80652 100644 --- a/src/pymovements/dataset/dataset_definition.py +++ b/src/pymovements/dataset/dataset_definition.py @@ -62,6 +62,7 @@ class DatasetDefinition: custom_read_kwargs : dict[str, Any], optional If specified, these keyword arguments will be passed to the file reading function. """ + # pylint: disable=too-many-instance-attributes name: str = '.' diff --git a/src/pymovements/dataset/dataset_files.py b/src/pymovements/dataset/dataset_files.py index 24a7be514..8dd3899f5 100644 --- a/src/pymovements/dataset/dataset_files.py +++ b/src/pymovements/dataset/dataset_files.py @@ -347,7 +347,6 @@ def add_fileinfo( pl.DataFrame: Dataframe with added columns from fileinfo dictionary keys. """ - df = df.select( [ pl.lit(value).alias(column) diff --git a/src/pymovements/dataset/dataset_paths.py b/src/pymovements/dataset/dataset_paths.py index 3e768d18f..1bcbd4f63 100644 --- a/src/pymovements/dataset/dataset_paths.py +++ b/src/pymovements/dataset/dataset_paths.py @@ -184,7 +184,6 @@ def dataset(self) -> Path: Example ------- - By passing a `str` or a `Path` as `path` during initialization you can explicitly set the directory path of the dataset: >>> import pymovements as pm @@ -242,7 +241,6 @@ def events(self) -> Path: Example ------- - >>> import pymovements as pm >>> >>> dataset = pm.Dataset("ToyDataset", path='/path/to/your/dataset/') @@ -273,7 +271,6 @@ def preprocessed(self) -> Path: Example ------- - >>> import pymovements as pm >>> >>> dataset = pm.Dataset("ToyDataset", path='/path/to/your/dataset/') @@ -306,7 +303,6 @@ def raw(self) -> Path: Example ------- - >>> import pymovements as pm >>> >>> dataset = pm.Dataset("ToyDataset", path='/path/to/your/dataset/') diff --git a/src/pymovements/datasets/gazebase.py b/src/pymovements/datasets/gazebase.py index da74cf8ac..4241a7e68 100644 --- a/src/pymovements/datasets/gazebase.py +++ b/src/pymovements/datasets/gazebase.py @@ -96,6 +96,7 @@ class GazeBase(DatasetDefinition): >>> dataset.load()# doctest: +SKIP """ + # pylint: disable=similarities # The PublicDatasetDefinition child classes potentially share code chunks for definitions. diff --git a/src/pymovements/datasets/gazebasevr.py b/src/pymovements/datasets/gazebasevr.py index f14456072..758dbf81b 100644 --- a/src/pymovements/datasets/gazebasevr.py +++ b/src/pymovements/datasets/gazebasevr.py @@ -97,6 +97,7 @@ class GazeBaseVR(DatasetDefinition): >>> dataset.load()# doctest: +SKIP """ + # pylint: disable=similarities # The PublicDatasetDefinition child classes potentially share code chunks for definitions. diff --git a/src/pymovements/datasets/judo1000.py b/src/pymovements/datasets/judo1000.py index 8af9d608a..0f7e3b72e 100644 --- a/src/pymovements/datasets/judo1000.py +++ b/src/pymovements/datasets/judo1000.py @@ -89,6 +89,7 @@ class JuDo1000(DatasetDefinition): >>> dataset.load()# doctest: +SKIP """ + # pylint: disable=similarities # The PublicDatasetDefinition child classes potentially share code chunks for definitions. diff --git a/src/pymovements/datasets/toy_dataset.py b/src/pymovements/datasets/toy_dataset.py index 27c2056a3..929efb50d 100644 --- a/src/pymovements/datasets/toy_dataset.py +++ b/src/pymovements/datasets/toy_dataset.py @@ -87,6 +87,7 @@ class ToyDataset(DatasetDefinition): >>> dataset.load()# doctest: +SKIP """ + # pylint: disable=similarities # The PublicDatasetDefinition child classes potentially share code chunks for definitions. diff --git a/src/pymovements/datasets/toy_dataset_eyelink.py b/src/pymovements/datasets/toy_dataset_eyelink.py index 4a86c9db5..11a7b4fa0 100644 --- a/src/pymovements/datasets/toy_dataset_eyelink.py +++ b/src/pymovements/datasets/toy_dataset_eyelink.py @@ -90,6 +90,7 @@ class ToyDatasetEyeLink(DatasetDefinition): >>> dataset.load()# doctest: +SKIP """ + # pylint: disable=similarities # The DatasetDefinition child classes potentially share code chunks for definitions. diff --git a/src/pymovements/events/detection/_fill.py b/src/pymovements/events/detection/_fill.py index 21946c363..f4c3d4dfa 100644 --- a/src/pymovements/events/detection/_fill.py +++ b/src/pymovements/events/detection/_fill.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds the implementation of the ivt algorithm. -""" +"""This module holds the implementation of the event fill function.""" from __future__ import annotations import numpy as np @@ -36,8 +34,7 @@ def fill( minimum_duration: int = 1, name: str = 'unclassified', ) -> EventDataFrame: - """ - Classify all previously unclassified timesteps as events. + """Classify all previously unclassified timesteps as events. Parameters ---------- @@ -55,7 +52,6 @@ def fill( pl.DataFrame A dataframe with detected fixations as rows. """ - timesteps = np.array(timesteps) # Create binary mask where each existing event is marked. diff --git a/src/pymovements/events/detection/_idt.py b/src/pymovements/events/detection/_idt.py index 72f0cd978..8d94db1db 100644 --- a/src/pymovements/events/detection/_idt.py +++ b/src/pymovements/events/detection/_idt.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds the implementation for idt algorithm. -""" +"""This module holds the implementation for I-DT algorithm.""" from __future__ import annotations import numpy as np @@ -60,8 +58,7 @@ def idt( include_nan: bool = False, name: str = 'fixation', ) -> EventDataFrame: - """ - Fixation identification based on dispersion threshold. + """Fixation identification based on dispersion threshold (I-DT). The algorithm identifies fixations by grouping consecutive points within a maximum separation (dispersion) threshold and a minimum duration threshold. diff --git a/src/pymovements/events/detection/_ivt.py b/src/pymovements/events/detection/_ivt.py index a34cd477d..12cc8e848 100644 --- a/src/pymovements/events/detection/_ivt.py +++ b/src/pymovements/events/detection/_ivt.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds the implementation of the ivt algorithm. -""" +"""This module holds the implementation of the I-VT algorithm.""" from __future__ import annotations import numpy as np @@ -41,8 +39,7 @@ def ivt( include_nan: bool = False, name: str = 'fixation', ) -> EventDataFrame: - """ - Identification of fixations based on velocity-threshold + """Identification of fixations based on velocity-threshold (I-VT). The algorithm classifies each point as a fixation if the velocity is below the given velocity threshold. Consecutive fixation points are merged into diff --git a/src/pymovements/events/detection/_library.py b/src/pymovements/events/detection/_library.py index f213e7533..6457bd3dc 100644 --- a/src/pymovements/events/detection/_library.py +++ b/src/pymovements/events/detection/_library.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds the EventDataFrame class. -""" +"""This module holds the EventDetectionLibrary class.""" from __future__ import annotations from collections.abc import Callable @@ -32,7 +30,7 @@ class EventDetectionLibrary: Attributes ---------- - methods: + `methods`: Dictionary of event detection methods. """ diff --git a/src/pymovements/events/detection/_microsaccades.py b/src/pymovements/events/detection/_microsaccades.py index 3654da1c7..f5c2281d1 100644 --- a/src/pymovements/events/detection/_microsaccades.py +++ b/src/pymovements/events/detection/_microsaccades.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds the implementation for the Engbert microsaccades algorithm. -""" +"""This module holds the implementation for the Engbert microsaccades algorithm.""" from __future__ import annotations from collections.abc import Sized diff --git a/src/pymovements/events/frame.py b/src/pymovements/events/frame.py index 3b7b96ab9..6ce425bb4 100644 --- a/src/pymovements/events/frame.py +++ b/src/pymovements/events/frame.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds the EventDataFrame class. -""" +"""This module holds the EventDataFrame class.""" from __future__ import annotations from collections.abc import Sequence @@ -126,9 +124,11 @@ def schema(self) -> pl.type_aliases.SchemaDict: return self.frame.schema def __len__(self) -> int: + """Get number of events in dataframe.""" return self.frame.__len__() def __getitem__(self, *args: Any, **kwargs: Any) -> Any: + """Get item.""" return self.frame.__getitem__(*args, **kwargs) @property @@ -137,7 +137,7 @@ def columns(self) -> list[str]: return self.frame.columns def _add_duration_property(self) -> None: - """Adds duration property column to dataframe.""" + """Add duration property column to dataframe.""" self.frame = self.frame.select([pl.all(), duration().alias('duration')]) def add_event_properties( diff --git a/src/pymovements/events/properties.py b/src/pymovements/events/properties.py index 297d64f9f..c1363c317 100644 --- a/src/pymovements/events/properties.py +++ b/src/pymovements/events/properties.py @@ -39,16 +39,16 @@ def amplitude( position_column: str = 'position', n_components: int = 2, ) -> pl.Expr: - """Amplitude of an event. + r"""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} + \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 + 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 @@ -80,16 +80,16 @@ def dispersion( position_column: str = 'position', n_components: int = 2, ) -> pl.Expr: - """ + r""" Dispersion of an event. The dispersion is calculated as: .. math:: - \\text{Dispersion} = x_{\\text{max}} - x_{\\text{min}} + y_{\\text{max}} - y_{\\text{min}} + \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 + 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 @@ -118,12 +118,12 @@ def disposition( position_column: str = 'position', n_components: int = 2, ) -> pl.Expr: - """Disposition of an event. + r"""Disposition of an event. The disposition is calculated as: .. math:: - \\text{Disposition} = \\sqrt{(x_0 - x_n)^2 + (y_0 - y_n)^2} + \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. @@ -168,18 +168,18 @@ def location( position_column: str = 'position', n_components: int = 2, ) -> pl.Expr: - """Location of an event. + r"""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 + \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) + \text{Location} = \text{median} \left(\text{position}_1, \ldots, + \text{position}_n \right) Parameters @@ -229,12 +229,12 @@ def peak_velocity( velocity_column: str = 'velocity', n_components: int = 2, ) -> pl.Expr: - """Peak velocity of an event. + r"""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) + \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. diff --git a/src/pymovements/exceptions.py b/src/pymovements/exceptions.py index afe3123e9..e20b04c84 100644 --- a/src/pymovements/exceptions.py +++ b/src/pymovements/exceptions.py @@ -25,5 +25,6 @@ class InvalidProperty(Exception): """Raised if requested property is invalid.""" def __init__(self, property_name: str, valid_properties: list[str]): + """Initialize InvalidProperty object.""" message = f"property '{property_name}' is invalid. Valid properties are: {valid_properties}" super().__init__(message) diff --git a/src/pymovements/gaze/experiment.py b/src/pymovements/gaze/experiment.py index 7da813803..e89b65519 100644 --- a/src/pymovements/gaze/experiment.py +++ b/src/pymovements/gaze/experiment.py @@ -29,12 +29,10 @@ @decorators.auto_str class Experiment: - """ - Experiment class for holding experiment properties. + """Experiment class for holding experiment properties. Attributes ---------- - screen : Screen Screen object for experiment sampling_rate : float @@ -46,12 +44,10 @@ def __init__( screen_width_cm: float, screen_height_cm: float, distance_cm: float, origin: str, sampling_rate: float, ): - """ - Initializes Experiment. + """Initialize Experiment. Parameters ---------- - screen_width_px : int Screen width in pixels screen_height_px : int diff --git a/src/pymovements/gaze/gaze_dataframe.py b/src/pymovements/gaze/gaze_dataframe.py index a6de1995e..f1e48f58b 100644 --- a/src/pymovements/gaze/gaze_dataframe.py +++ b/src/pymovements/gaze/gaze_dataframe.py @@ -141,7 +141,6 @@ def __init__( Examples -------- - First let's create an example `DataFrame` with three columns: the timestamp ``t`` and ``x`` and ``y`` for the pixel position. @@ -432,7 +431,6 @@ def unnest( AttributeError If number of components is not 2, 4 or 6. """ - checks.check_is_mutual_exclusive( output_columns=output_columns, output_suffixes=output_suffixes, diff --git a/src/pymovements/gaze/integration.py b/src/pymovements/gaze/integration.py index e61c9025e..66cc17cda 100644 --- a/src/pymovements/gaze/integration.py +++ b/src/pymovements/gaze/integration.py @@ -41,8 +41,7 @@ def from_numpy( velocity_columns: list[str] | None = None, acceleration_columns: list[str] | None = None, ) -> GazeDataFrame: - """Construct a :py:class:`~pymovements.gaze.gaze_dataframe.GazeDataFrame` - from a numpy array. + """Get a :py:class:`~pymovements.gaze.gaze_dataframe.GazeDataFrame` from a numpy array. Parameters ---------- @@ -91,8 +90,7 @@ def from_pandas( velocity_columns: list[str] | None = None, acceleration_columns: list[str] | None = None, ) -> GazeDataFrame: - """Construct a :py:class:`~pymovements.gaze.gaze_dataframe.GazeDataFrame` - from a pandas DataFrame. + """Get a :py:class:`~pymovements.gaze.gaze_dataframe.GazeDataFrame` from a pandas DataFrame. Parameters ---------- diff --git a/src/pymovements/gaze/screen.py b/src/pymovements/gaze/screen.py index 24e851577..772827cb8 100644 --- a/src/pymovements/gaze/screen.py +++ b/src/pymovements/gaze/screen.py @@ -29,9 +29,9 @@ @decorators.auto_str class Screen: - """ - Screen class for holding screen properties and transforming pixel - coordinates to degrees of visual angle. + """Screen class for holding screen properties. + + Also transforms pixel coordinates to degrees of visual angle. Attributes ---------- @@ -67,8 +67,7 @@ def __init__( distance_cm: float, origin: str, ): - """ - Initializes Screen. + """Initialize Screen. Parameters ---------- @@ -100,7 +99,6 @@ def __init__( height_cm=30.00, distance_cm=68.00, origin=lower left, x_max_dva=15.60, y_max_dva=12.43, x_min_dva=-15.60, y_min_dva=-12.43) - """ checks.check_no_zeros(width_px, 'width_px') checks.check_no_zeros(height_px, 'height_px') @@ -137,8 +135,7 @@ def pix2deg( self, arr: float | list[float] | list[list[float]] | np.ndarray, ) -> np.ndarray: - """ - Converts pixel screen coordinates to degrees of visual angle. + """Convert pixel screen coordinates to degrees of visual angle. Parameters ---------- diff --git a/src/pymovements/gaze/transforms.py b/src/pymovements/gaze/transforms.py index 5fc61ffe3..ebef4c02f 100644 --- a/src/pymovements/gaze/transforms.py +++ b/src/pymovements/gaze/transforms.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Module for py:func:`pymovements.gaze.transforms`""" +"""Module for py:func:`pymovements.gaze.transforms.""" from __future__ import annotations from functools import partial @@ -40,7 +40,7 @@ class TransformLibrary: Attributes ---------- - methods: + `methods`: Dictionary of transformation methods. """ @@ -175,7 +175,7 @@ def pix2deg( pixel_column: str = 'pixel', position_column: str = 'position', ) -> pl.Expr: - """Converts pixel screen coordinates to degrees of visual angle. + """Convert pixel screen coordinates to degrees of visual angle. Parameters ---------- @@ -223,7 +223,7 @@ def pix2deg( def _arctan2_helper(distance: float) -> Callable: - """Returns single-argument lambda function with fixed second argument.""" + """Return single-argument lambda function with fixed second argument.""" return lambda s: np.arctan2(s, distance) @@ -436,7 +436,7 @@ def savitzky_golay( derivative: int = 0, padding: str | float | int | None = 'nearest', ) -> pl.Expr: - """Apply a 1-D Savitzky-Golay filter to a column. :cite:p:`SavitzkyGolay1964` + """Apply a 1-D Savitzky-Golay filter to a column|_|:cite:p:`SavitzkyGolay1964`. Parameters ---------- diff --git a/src/pymovements/gaze/transforms_numpy.py b/src/pymovements/gaze/transforms_numpy.py index 2650eb2f2..fcaf2bd5d 100644 --- a/src/pymovements/gaze/transforms_numpy.py +++ b/src/pymovements/gaze/transforms_numpy.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -Transforms module. -""" +"""Transforms module.""" from __future__ import annotations from typing import Any @@ -37,7 +35,7 @@ def pix2deg( distance_cm: float, origin: str, ) -> np.ndarray: - """Converts pixel screen coordinates to degrees of visual angle. + """Convert pixel screen coordinates to degrees of visual angle. Parameters ---------- @@ -387,7 +385,7 @@ def pos2vel( def norm(arr: np.ndarray, axis: int | None = None) -> np.ndarray | Any: - r"""Takes the norm of an array. + r"""Take the norm of an array. The norm is defined by :math:`\sqrt{x^2 + y^2}` with :math:`x` being the yaw component and :math:`y` being the pitch component of a coordinate. diff --git a/src/pymovements/plotting/heatmap.py b/src/pymovements/plotting/heatmap.py index 173aa1410..44da8953a 100644 --- a/src/pymovements/plotting/heatmap.py +++ b/src/pymovements/plotting/heatmap.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -Heatmap module. -""" +"""Heatmap module.""" from __future__ import annotations import matplotlib.pyplot as plt @@ -95,7 +93,6 @@ def heatmap( plt.Figure The heatmap figure. """ - # Extract x and y positions from the gaze dataframe x = gaze.frame[position_column].list.get(0).to_numpy() y = gaze.frame[position_column].list.get(1).to_numpy() diff --git a/src/pymovements/plotting/main_sequence_plot.py b/src/pymovements/plotting/main_sequence_plot.py index f7c9edd3b..551e73152 100644 --- a/src/pymovements/plotting/main_sequence_plot.py +++ b/src/pymovements/plotting/main_sequence_plot.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds the main sequence plot. -""" +"""This module holds the main sequence plot.""" from __future__ import annotations import matplotlib.pyplot as plt @@ -42,8 +40,7 @@ def main_sequence_plot( show: bool = True, **kwargs: Collection, ) -> None: - """ - Plots the saccade main sequence. + """Plot the saccade main sequence. Parameters ---------- diff --git a/src/pymovements/plotting/traceplot.py b/src/pymovements/plotting/traceplot.py index 643d951d3..4bacb1fe8 100644 --- a/src/pymovements/plotting/traceplot.py +++ b/src/pymovements/plotting/traceplot.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds the traceplot. -""" +"""This module holds the traceplot.""" from __future__ import annotations import sys diff --git a/src/pymovements/plotting/tsplot.py b/src/pymovements/plotting/tsplot.py index d0ce9def5..8207ea715 100644 --- a/src/pymovements/plotting/tsplot.py +++ b/src/pymovements/plotting/tsplot.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds the time series plot. -""" +"""This module holds the time series plot.""" from __future__ import annotations import math diff --git a/src/pymovements/synthetic/step_function.py b/src/pymovements/synthetic/step_function.py index 67ad9e670..dbed373f4 100644 --- a/src/pymovements/synthetic/step_function.py +++ b/src/pymovements/synthetic/step_function.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds the synthetic eye gaze step function. -""" +"""This module holds the synthetic eye gaze step function.""" from __future__ import annotations from collections.abc import Sized diff --git a/src/pymovements/utils/archives.py b/src/pymovements/utils/archives.py index 5a29553d3..53f53c0c7 100644 --- a/src/pymovements/utils/archives.py +++ b/src/pymovements/utils/archives.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -Utils module for extracting archives and decompressing files. -""" +"""Utils module for extracting archives and decompressing files.""" from __future__ import annotations import bz2 @@ -42,6 +40,7 @@ def extract_archive( verbose: int = 1, ) -> Path: """Extract an archive. + The archive type and a possible compression is automatically detected from the file name. If the file is compressed but not an archive the call is dispatched to :func:`_decompress`. diff --git a/src/pymovements/utils/checks.py b/src/pymovements/utils/checks.py index 4fc06a3a8..a82d350fc 100644 --- a/src/pymovements/utils/checks.py +++ b/src/pymovements/utils/checks.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds basic checks which will be reused in other modules. -""" +"""This module holds basic checks which will be reused in other modules.""" from __future__ import annotations from collections.abc import Sized @@ -29,9 +27,7 @@ def check_no_zeros(variable: Any, name: str = 'variable') -> None: - """ - Check if variable, or if it is iterable, any of its components are zero. - """ + """Check if variable, or if it is iterable, any of its components are zero.""" # construct error message first error_message = f'{name} must not be zero' @@ -54,9 +50,7 @@ def check_no_zeros(variable: Any, name: str = 'variable') -> None: def check_nan_both_channels(arr: np.ndarray) -> None: - """ - Checks if all nans occur at the same time steps for both channels. - """ + """Check if all nans occur at the same time steps for both channels.""" # sanity check: horizontal and vertical gaze coordinates missing # values at the same time (Eyelink eyetracker never records only # one coordinate) @@ -67,7 +61,7 @@ def check_nan_both_channels(arr: np.ndarray) -> None: def check_shapes(**kwargs: Any) -> None: - """Checks if all provided arrays are of shape ``(N, 2)`` and shape is equal for all arrays. + """Check if all provided arrays are of shape ``(N, 2)`` and shape is equal for all arrays. Parameters ---------- @@ -79,7 +73,6 @@ def check_shapes(**kwargs: Any) -> None: ValueError If any of the arrays is not of shape ``(N, 2)`` or if the shapes are not equal. """ - for key, array in kwargs.items(): if array.ndim != 2 or array.shape[1] != 2: raise ValueError(f'{key} must have shape (N, 2) but have shape {array.shape}') diff --git a/src/pymovements/utils/decorators.py b/src/pymovements/utils/decorators.py index 15155b67a..5ccd42b28 100644 --- a/src/pymovements/utils/decorators.py +++ b/src/pymovements/utils/decorators.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds utils for developers and is not part of the user API. -""" +"""This module holds utils for developers and is not part of the user API.""" from __future__ import annotations from typing import Any @@ -29,9 +27,7 @@ def auto_str(cls: type[ClassT]) -> type[ClassT]: - """ - Automatically generate __str__() to include all arguments. Can be used as a decorator. - """ + """Automatically generate __str__() to include all arguments. Can be used as a decorator.""" def shorten(value: Any) -> str: if isinstance(value, float): value = f'{value:.2f}' diff --git a/src/pymovements/utils/downloads.py b/src/pymovements/utils/downloads.py index 8ea1ae403..fc053fd0c 100644 --- a/src/pymovements/utils/downloads.py +++ b/src/pymovements/utils/downloads.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -Utils module for downloading files. -""" +"""Utils module for downloading files.""" from __future__ import annotations import hashlib @@ -218,7 +216,10 @@ def __init__(self, **kwargs: Any): super().__init__(unit='B', unit_scale=True, unit_divisor=1024, miniters=1, **kwargs) def update_to(self, b: int = 1, bsize: int = 1, tsize: None | int = None) -> bool | None: - """ + """Update progress bar. + + Parameters + ---------- b : int, optional Number of blocks transferred so far [default: 1]. bsize : int, optional diff --git a/src/pymovements/utils/filters.py b/src/pymovements/utils/filters.py index d75f49a96..525a30525 100644 --- a/src/pymovements/utils/filters.py +++ b/src/pymovements/utils/filters.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds filter specific funtions. -""" +"""This module holds filter specific funtions.""" from __future__ import annotations import numpy as np @@ -31,8 +29,7 @@ def filter_candidates_remove_nans( candidates: list[np.ndarray], values: np.ndarray, ) -> list[np.ndarray]: - """ - Filters a list of candidates for an event-detection algorithm + """Filter a list of candidates for an event-detection algorithm. Removes leading and ending np.nans for all candidates in candidates @@ -69,8 +66,7 @@ def events_split_nans( candidates: list[np.ndarray], values: np.ndarray, ) -> list[np.ndarray]: - """ - Filters a list of candidates for an event-detection algorithm + """Filter a list of candidates for an event-detection algorithm. Splits events if np.nans are within an event diff --git a/src/pymovements/utils/parsing.py b/src/pymovements/utils/parsing.py index b48c52587..439e8d732 100755 --- a/src/pymovements/utils/parsing.py +++ b/src/pymovements/utils/parsing.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" Converts ascii to csv files.""" +"""Module for parsing input data.""" from __future__ import annotations import re @@ -38,14 +38,13 @@ def check_nan(sample_location: str) -> float: - """Returns position as float or np.nan depending on validity of sample + """Return position as float or np.nan depending on validity of sample. Parameters ---------- sample_location: str Sample location as extracted from ascii file. """ - try: ret = float(sample_location) except ValueError: @@ -113,7 +112,7 @@ def parse_eyelink( patterns: list | None = None, schema: dict | None = None, ) -> pl.DataFrame: - """Processes ascii files to csv. + """Process EyeLink asc file. Parameters ---------- diff --git a/src/pymovements/utils/paths.py b/src/pymovements/utils/paths.py index 590c0d25d..4da14e249 100644 --- a/src/pymovements/utils/paths.py +++ b/src/pymovements/utils/paths.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds path specific funtions. -""" +"""This module holds path specific funtions.""" from __future__ import annotations import re @@ -31,8 +29,8 @@ def get_filepaths( extension: str | list[str] | None = None, regex: re.Pattern | None = None, ) -> list[Path]: - """ - Get filepaths from rootpath depending on extension or regular expression. + """Get filepaths from rootpath depending on extension or regular expression. + Passing extension and regex is mutually exclusive. Parameters @@ -52,7 +50,6 @@ def get_filepaths( ------ ValueError If both extension and regex is being passed. - """ if extension is not None and regex is not None: raise ValueError('extension and regex are mutually exclusive') diff --git a/src/pymovements/utils/strings.py b/src/pymovements/utils/strings.py index 799ba5e38..e7a274759 100644 --- a/src/pymovements/utils/strings.py +++ b/src/pymovements/utils/strings.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module holds string specific funtions. -""" +"""This module holds string specific funtions.""" from __future__ import annotations import re @@ -30,8 +28,8 @@ def curly_to_regex(s: str) -> re.Pattern: - """ - Returns regex pattern converted from provided python formatting style pattern. + """Return regex pattern converted from provided python formatting style pattern. + By default all parameters are strings, if you want to specify number you can do: {num:d} If you want to specify parameter's length you can do: {two_symbols:2} or {four_digits:4d} Characters { and } can be escaped the same way as in python: {{ and }} diff --git a/tests/__init__.py b/tests/__init__.py index d42c5aa46..780b97397 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -17,3 +17,4 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +"""pymovements top-level module.""" diff --git a/tests/dataset/dataset_download_test.py b/tests/dataset/dataset_download_test.py index 12106a59f..ca26acbe9 100644 --- a/tests/dataset/dataset_download_test.py +++ b/tests/dataset/dataset_download_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Test all download and extract functionality of pymovements.Dataset""" +"""Test all download and extract functionality of pymovements.Dataset.""" from __future__ import annotations from dataclasses import dataclass diff --git a/tests/dataset/dataset_files_test.py b/tests/dataset/dataset_files_test.py index 005a45098..95e4ae670 100644 --- a/tests/dataset/dataset_files_test.py +++ b/tests/dataset/dataset_files_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" Tests pymovements asc to csv processing""" +"""Tests pymovements asc to csv processing.""" # flake8: noqa: E101, W191, E501 # pylint: disable=duplicate-code import numpy as np diff --git a/tests/datasets/datasets_test.py b/tests/datasets/datasets_test.py index 9e8360b99..6df6db7d0 100644 --- a/tests/datasets/datasets_test.py +++ b/tests/datasets/datasets_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Test public dataset definitions""" +"""Test public dataset definitions.""" from __future__ import annotations import pytest diff --git a/tests/events/detection/fill_test.py b/tests/events/detection/fill_test.py index 34aebbbba..5870bc44f 100644 --- a/tests/events/detection/fill_test.py +++ b/tests/events/detection/fill_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""This module tests functionality of the IVT algorithm.""" +"""Tests functionality of the IVT algorithm.""" from __future__ import annotations import numpy as np diff --git a/tests/events/detection/idt_test.py b/tests/events/detection/idt_test.py index 4695df140..47bea10cc 100644 --- a/tests/events/detection/idt_test.py +++ b/tests/events/detection/idt_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""This module tests functionality of the IDT algorithm.""" +"""Tests functionality of the IDT algorithm.""" import numpy as np import pytest from polars.testing import assert_frame_equal diff --git a/tests/events/detection/ivt_test.py b/tests/events/detection/ivt_test.py index c0fac5823..e5377db55 100644 --- a/tests/events/detection/ivt_test.py +++ b/tests/events/detection/ivt_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""This module tests functionality of the IVT algorithm.""" +"""Test functionality of the IVT algorithm.""" from __future__ import annotations import numpy as np diff --git a/tests/events/properties_test.py b/tests/events/properties_test.py index 1d16b8456..ab0c57337 100644 --- a/tests/events/properties_test.py +++ b/tests/events/properties_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Test module pymovements.events.event_properties""" +"""Test module pymovements.events.event_properties.""" import numpy as np import polars as pl import pytest diff --git a/tests/gaze/transforms/center_origin_test.py b/tests/gaze/transforms/center_origin_test.py index f7dea5c3b..12f7e16cd 100644 --- a/tests/gaze/transforms/center_origin_test.py +++ b/tests/gaze/transforms/center_origin_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Test pymovements.gaze.transforms.center_origin""" +"""Test pymovements.gaze.transforms.center_origin.""" import polars as pl import pytest from polars.testing import assert_frame_equal diff --git a/tests/gaze/transforms/downsample_test.py b/tests/gaze/transforms/downsample_test.py index 239fdd948..9e8411efa 100644 --- a/tests/gaze/transforms/downsample_test.py +++ b/tests/gaze/transforms/downsample_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Test pymovements.gaze.transforms.downsample""" +"""Test pymovements.gaze.transforms.downsample.""" import polars as pl import pytest from polars.testing import assert_frame_equal diff --git a/tests/gaze/transforms/norm_test.py b/tests/gaze/transforms/norm_test.py index a89d22c97..d57ede27b 100644 --- a/tests/gaze/transforms/norm_test.py +++ b/tests/gaze/transforms/norm_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Test pymovements.gaze.transforms.norm""" +"""Test pymovements.gaze.transforms.norm.""" import polars as pl import pytest from polars.testing import assert_series_equal diff --git a/tests/gaze/transforms/pix2deg_test.py b/tests/gaze/transforms/pix2deg_test.py index 0e8bbe32a..0ec5b775d 100644 --- a/tests/gaze/transforms/pix2deg_test.py +++ b/tests/gaze/transforms/pix2deg_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Test pymovements.gaze.transforms.pix2deg""" +"""Test pymovements.gaze.transforms.pix2deg.""" import numpy as np import polars as pl import pytest diff --git a/tests/gaze/transforms/pos2acc_test.py b/tests/gaze/transforms/pos2acc_test.py index a7f47aecc..815d44047 100644 --- a/tests/gaze/transforms/pos2acc_test.py +++ b/tests/gaze/transforms/pos2acc_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Test pymovements.gaze.transforms.pos2acc""" +"""Test pymovements.gaze.transforms.pos2acc.""" import polars as pl import pytest from polars.testing import assert_frame_equal diff --git a/tests/gaze/transforms/pos2vel_test.py b/tests/gaze/transforms/pos2vel_test.py index 6f30f3ab8..ea8a5661d 100644 --- a/tests/gaze/transforms/pos2vel_test.py +++ b/tests/gaze/transforms/pos2vel_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Test pymovements.gaze.transforms.pos2vel""" +"""Test pymovements.gaze.transforms.pos2vel.""" import polars as pl import pytest from polars.testing import assert_frame_equal diff --git a/tests/gaze/transforms/savitzky_golay_test.py b/tests/gaze/transforms/savitzky_golay_test.py index c6cb4e7d3..6c1d3bda7 100644 --- a/tests/gaze/transforms/savitzky_golay_test.py +++ b/tests/gaze/transforms/savitzky_golay_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Test pymovements.gaze.transforms.savitzky_golay""" +"""Test pymovements.gaze.transforms.savitzky_golay.""" import polars as pl import pytest from polars.testing import assert_frame_equal diff --git a/tests/gaze/transforms/transforms_library_test.py b/tests/gaze/transforms/transforms_library_test.py index 2dbc7f915..c20a27607 100644 --- a/tests/gaze/transforms/transforms_library_test.py +++ b/tests/gaze/transforms/transforms_library_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Test public dataset definitions""" +"""Test public dataset definitions.""" from __future__ import annotations import pytest diff --git a/tests/gaze/transforms_numpy_test.py b/tests/gaze/transforms_numpy_test.py index 4884dc7ac..5ca219f72 100644 --- a/tests/gaze/transforms_numpy_test.py +++ b/tests/gaze/transforms_numpy_test.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -Test all functions in pymovements.transforms. -""" +"""Test all functions in pymovements.transforms.""" import numpy as np import pytest diff --git a/tests/synthetic/step_function_test.py b/tests/synthetic/step_function_test.py index c8bcb0c9f..337343a18 100644 --- a/tests/synthetic/step_function_test.py +++ b/tests/synthetic/step_function_test.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -This module tests functionality of the synthetic eye gaze step function. -""" +"""Tests functionality of the synthetic eye gaze step function.""" import numpy as np import pytest diff --git a/tests/utils/archives_test.py b/tests/utils/archives_test.py index 6115a3118..1f20818a1 100644 --- a/tests/utils/archives_test.py +++ b/tests/utils/archives_test.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -Test pymovements utils archives. -""" +"""Test pymovements utils archives.""" import bz2 import gzip import lzma @@ -35,9 +33,7 @@ def test_extract_archive_wrong_suffix(): - """ - Test unsupported suffix for extract_archive() - """ + """Test unsupported suffix for extract_archive().""" with pytest.raises(RuntimeError) as excinfo: extract_archive(pathlib.Path('test.jpg')) msg, = excinfo.value.args @@ -46,9 +42,7 @@ def test_extract_archive_wrong_suffix(): def test_detect_file_type_no_suffixes(): - """ - Test extract_archive() for no files with suffix - """ + """Test extract_archive() for no files with suffix.""" with pytest.raises(RuntimeError) as excinfo: extract_archive(pathlib.Path('test')) msg, = excinfo.value.args diff --git a/tests/utils/checks_test.py b/tests/utils/checks_test.py index 30c00301a..f3f9f57b4 100644 --- a/tests/utils/checks_test.py +++ b/tests/utils/checks_test.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -Test pymovements checks. -""" +"""Test pymovements checks.""" import numpy as np import pytest @@ -53,9 +51,7 @@ ], ) def test_check_no_zeros_raises_error(variable, expected_error, expected_err_msg): - """ - Test that check_no_zeros() only raises an Exception if there are zeros in the input array. - """ + """Test that check_no_zeros() only raises an Exception if there are zeros in the input array.""" if expected_error is None: checks.check_no_zeros(variable) else: @@ -101,9 +97,9 @@ def test_check_no_zeros_raises_error(variable, expected_error, expected_err_msg) ], ) def test_check_nan_both_channels_raises_error(arr, expected_error, expected_err_msg): - """ - Test that check_nan_both_channels() only raises an Exception if all nans - occur at the same time step for both channels. + """Test that check_nan_both_channels() raises an Exception. + + Only iff all nans occur at the same time step for both channels. """ if expected_error is None: checks.check_nan_both_channels(arr) @@ -186,10 +182,10 @@ def test_check_nan_both_channels_raises_error(arr, expected_error, expected_err_ ], ) def test_check_shapes_raises_error(kwargs, expected_error, expected_err_msg): - """ - Test that check_shapes() only raises an Exception if - the shapes of the positions and velocities are not (N, 2) or if the lengths - of the positions and velocities are not equal. + """Test that check_shapes() raises an Exception. + + Only if the shapes of the positions and velocities are not (N, 2) or if the lengths of the + positions and velocities are not equal. """ if expected_error is None: checks.check_shapes(**kwargs) diff --git a/tests/utils/downloads_test.py b/tests/utils/downloads_test.py index d9133aa75..ae6ff3bc1 100644 --- a/tests/utils/downloads_test.py +++ b/tests/utils/downloads_test.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -Test pymovements utils downloads. -""" +"""Test pymovements utils downloads.""" import hashlib import os.path from unittest import mock diff --git a/tests/utils/filters_test.py b/tests/utils/filters_test.py index c4c03047d..577f678c1 100644 --- a/tests/utils/filters_test.py +++ b/tests/utils/filters_test.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -Test pymovements filters. -""" +"""Test pymovements filters.""" from __future__ import annotations import numpy as np diff --git a/tests/utils/parsing_test.py b/tests/utils/parsing_test.py index 0c13b83c8..2ce4777aa 100644 --- a/tests/utils/parsing_test.py +++ b/tests/utils/parsing_test.py @@ -17,7 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" Tests pymovements asc to csv processing""" +"""Tests pymovements asc to csv processing.""" import numpy as np import polars as pl import pytest diff --git a/tests/utils/paths_test.py b/tests/utils/paths_test.py index 0443c50c3..0291093c5 100644 --- a/tests/utils/paths_test.py +++ b/tests/utils/paths_test.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -Test pymovements paths. -""" +"""Test pymovements paths.""" import pathlib import re import unittest @@ -32,9 +30,7 @@ def test_get_filepaths_mut_excl_extension_and_regex_error(): - """ - Test mutually exclusive extension and regex in get_filepaths. - """ + """Test mutually exclusive extension and regex in get_filepaths.""" with pytest.raises(ValueError) as excinfo: get_filepaths(path='tmp', extension='extension', regex=re.compile('regex')) msg, = excinfo.value.args diff --git a/tests/utils/strings_test.py b/tests/utils/strings_test.py index 4efea6ea0..32874b208 100644 --- a/tests/utils/strings_test.py +++ b/tests/utils/strings_test.py @@ -17,9 +17,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""" -Test pymovements string utilities. -""" +"""Test pymovements string utilities.""" from __future__ import annotations import re