Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.

pyTrace

Pytrace provides fixation algorithms for aggregating gazes, as well as tools to help you deal with edits that occur during eyetracking sessions.

Getting started

Installation

Requirements

pytrace requires python 3.8.5

Installation

You can install pytrace using

pip install pytrace

pyTrace comes with a command line interface as well as a python library.

To use either version, you need 3 things:

  • itrace core file output
  • gaze file output
  • changelog
  • original source file(s)

To get started:

# import pytrace
from pytrace import fixation_filter, Tracker

# run fixation filter to get fixations
fixations = fixation_filter(gazes, changelog, sources, **opts)

# Now track edits using Tracker

tracker = Tracker(fixations, changelog, sources, language)
# Note that you need to pass in the source code language,
# to help `pytrace` determine which parser to use.

Base Functionality

The main goal of Tracker is to track fixations and source code tokens across edits. Once you create a Tracker you can query it to get snapshots etc.

Snapshots

Tracker maintains a list of snapshots corresponding to the original file and subsequent edits. The original version is stored at index 0 and the first edit is stored at index 1.

# get original
tracker.get_snapshot(0)

# get first edit
tracker.get_snapshot(1)

Each snapshot is represented by a Snapshot. A Snapshot is defined as:

class Snapshot:
    id: int
    source: Source
    tokens: Tuple[Token, ...]
    changes: Tuple[TokenChange, ...] = ()
    time: float = 0.0

Snapshot.time represents the time at which a snapshot was created. It corresponds to the timestamp in the changelog that was used to create this Snapshot.

Snapshot.tokens represents the parsed source code tokens. Snapshot.changes represents all the token changes that happened to this Snapshot since the last version. For the Snapshot representing the original source, Snapshot.changes is empty.

Snapshots.source is a Source object, containing the raw text of the source code, as well as mappings from text indices to line/column numbers and vice-versa. It is defined as follows:

@dataclass(frozen=True)
class Source:
    text: str
    mapping: PositionMapping
    language: str

Gazes

You can retreive gazes for a given time window as follows:

tracker.get_gazes()
# all gazes

tracker.get_gazes(start, end)
# returns a dataframe that is filtered

The gaze dataframe is simply a pandas.DataFrame containing the original gazes, with some additional columns:

  • syntax_node - The syntax node associated with the gaze. None if the gaze doesn't fall on a token.
  • syntax_node_id - A stable id for the token associated with this gaze. None if the gaze doesn't fall on a token.

syntax_node_id is a unique id that is assigned to each token in the source code across different snapshots. For a given token, this id is unique across time and space. Thus, you can use this id to determine how

diffs

tracker.diff(0, 2) # gives you the diff between version 0 & version 1
tracker.diff_time(2300, 2400)
    # gives you the diff between time unit 2300 & time unit 2400

A SnapshotDiff is defined as follows:

class SnapshotDiff(NamedTuple):
    old: Snapshot
    new: Snapshot
    token_changes: List[TokenChange]
    gaze_changes: List[GazeChange]
    gazes: pd.DataFrame

It gives you a list of all token changes and gaze changes.

Token changes can be of 3 types: inserted, moved or deleted.

Gaze changes can be of 2 types: deleted or moved. (deleted means that the token to which the gaze was mapped to has been removed from the source.)

By default, tracker.diff(start, end) will include all the gazes from the start of the experiment (the time at which the first gaze is recorded), up until the end snapshot time. If you want to only include gazes within the timespan of the start and end snapshots, you can pass an optional parameter:

diff = tracker.diff(0, 3, window_only=True)

pytrace also provides a pretty-printer to help you print diffs for inspecting the data. It supports print gaze changes, token changes and SnapshotDiffs.

from pytrace import pprint

diff = tracker.diff(2, 3)

pprint(diff)
pprint(diff.token_changes)
pprint(diff.gaze_changes)

pytrace provides a module transforms to help you manipulate pytrace structures including Snapshots and SnapshotDiff.

from pytrace import transforms as T

diff = tracker.diff(2, 5)

# TODO

Metadata

Release files for gazel-devjeetr 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gazel-devjeetr 0.0.7
File Size Uploaded Provenance Actions
gazel-devjeetr-0.0.7.tar.gz 19.9 kB Without provenance Details for gazel-devjeetr-0.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gazel-devjeetr 0.0.7
File Interpreter ABI Platform Actions
gazel_devjeetr-0.0.7-py3-none-any.whl Python 3 none any Details for gazel_devjeetr-0.0.7-py3-none-any.whl

Total release size: 60.6 kB

Release files / gazel-devjeetr-0.0.7.tar.gz

Download URL gazel-devjeetr-0.0.7.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7772a60d1c94df03fc8d76cf1c194e23a24f16df65927afda521984a211ac7fb
BLAKE2b-256 checksum
How to use checksums
0bf1008668a7823990db1cb41d6b6fe1bbc7b42defd770e6ead128deedc51fc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / gazel_devjeetr-0.0.7-py3-none-any.whl

Download URL gazel_devjeetr-0.0.7-py3-none-any.whl
Size 40.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ebee3fd69835833d654b7e2d7f69bce7fcff29487d294f712eba287aec783a6
BLAKE2b-256 checksum
How to use checksums
3248da7851ebffc3dca2c61adad028df19e47cbdac3d297c0a9a1651cce0cf42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Security for gazel-devjeetr 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page