Skip to content

Add __repr__ to qp.Tracker to improve readability #9389

@andrijapau

Description

@andrijapau

This issue is part of unitaryHACK26. You have to be registered to complete this issue. Learn more about the PR submission process here and about unitaryHACK rules here!

A note about AI Slop: while we are open to collaboration with LLMs for unitaryHACK, fully AI-generated PRs are not acceptable. It is at the maintainers’ discretion whether or not LLM-generated PRs are the right fit for the issues, and those that appear fully AI-generated may be immediately rejected. Read unitaryHACK’s full AI Policy here


Feature details

Right now, the Tracker object has no defined __repr__ which makes it hard to interact with and debug,

>>> from pennylane import Tracker
>>> tracker = Tracker()
>>> tracker.update(a=2, b="b2", c=1)
>>> print(tracker)
<pennylane.devices.tracker.Tracker object at 0x1304e3a50>

We would like to add a readable __repr__ to this object that shows all of its relevant internals to the user,

>>> print(tracker)
Tracker(active=..., totals=..., persistent=..., ...)

Implementation

To complete this task, please do the following:

  1. Implement a custom __repr__ in the Tracker class.
  2. Add appropriate test(s) in tests/devices/test_tracker.py here.

Follow development questions, please ask here or consult our guide.


This issue is part of the unitaryHACK event organized by the Unitary Foundation. Please refer to the rules page of the event’s website to confirm whether you are eligible to participate. If you have any comments, questions or complaints about the event please refer to the contact information provided at the bottom of that page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement ✨New feature or requestunitaryhackDedicated issue for Unitary Fund open-source hackathon

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions