-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update() method fails when tracking non-numeric values #6998
Comments
I just ran:
And it worked fine without error. Mind posting the full traceback you get and the exact code you are running? |
Actually, The original code was working fine, but my goal is to optimize it for better maintainability and debugging. Previously, the code used |
Hi @umer066 , thank you for opening this issue! In your "Steps to Reproduce" you mentioned "Observe an error instead of graceful handling". A minimal reproducible example (or minimal working example) is the simplest version of the code that reproduces the problem. It should be self-contained, including all necessary imports, data, functions, etc., so that we can copy-paste the code and reproduce the problem. However it shouldn't contain any unnecessary data, functions, etc. (for example gates and functions that can be removed to simplify the code). On the other hand, I didn't notice any print statements being used to handle errors. Could you please point us to the specific file and line of code that you're looking at? |
https://github.com/PennyLaneAI/pennylane/blob/master/pennylane/tracker.py
In the tracker.py file
The
update()
method errors out when handling certain non-numeric values, despite theisinstance(value, Number)
check. This leads to unexpected crashes instead of safely storing values inhistory
.Steps to Reproduce:
update()
with mixed data types:python tracker.update(metric_1=10, metric_2="string", metric_3=None)
Expected Behavior:
history
.totals
.Possible Cause:
isinstance(value, Number)
may not cover all cases (e.g.,NoneType
, custom objects).Proposed Fix:
isinstance(value, Number)
correctly filters numeric types.The text was updated successfully, but these errors were encountered: