aeye-lab / pymovements

A python package for processing eye movement data
https://pymovements.readthedocs.io
MIT License
61 stars 12 forks source link

improve usability of gaze.from_numpy() by allowing lists of column indices #500

Open dkrako opened 1 year ago

dkrako commented 1 year ago

Description of the problem

The current implementation expects a named list of columns for the numpy array: https://github.com/aeye-lab/pymovements/blob/279d886c9c380a3bf17439c08cb30cf84ad8aa51/src/pymovements/gaze/integration.py#L33-L42

This list of names is then used to specify the columns in the data via pixel_columns etc.

Description of a solution

Instead it shouldn't be necessary to provide a list of names, but we should be able to specify the columns by their index.

def from_numpy(
        data: np.ndarray,
        schema: list[str] = None,
        experiment: Experiment | None = None,
        orient: Literal['col', 'row'] = 'col',
        pixel_columns: list[str] | list[int] | None = None,
        position_columns: list[str] | list[int] | None = None,
        velocity_columns: list[str] | list[int] | None = None,
        acceleration_columns: list[str] | list[int] | None = None,
) -> GazeDataFrame: