Skip to content
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

[🐛 BUG] Lambda function not working in delta property of metric #1518

Closed
1 of 4 tasks
FlorianJacta opened this issue Jul 15, 2024 · 1 comment
Closed
1 of 4 tasks
Labels
🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem. 🟨 Priority: Medium Not blocking but should be addressed

Comments

@FlorianJacta
Copy link
Member

FlorianJacta commented Jul 15, 2024

What went wrong? 🤔

Having a lambda function inside the delta property does not work. It would be really useful for it to work. Maybe, other properties are impacted.

image

WARNING:root:
--- 1 warning(s) were found for page '/'  ---
 - Warning 1: Metric: delta cannot be transformed into a number:
could not convert string to float: '<lambda>'
----------------------------------------------

Expected Behavior

It should work; the delta property should be able to use the lambda function to get the proper delta displayed on the metric. Maybe, other properties are impacted.

Steps to Reproduce Issue

# Import necessary libraries
import pandas as pd
import taipy as tp

import datetime as dt
import taipy.gui.builder as tgb

value = 10
previous_value = 5

with tgb.Page() as page:
    # Don't work
    tgb.metric(lambda value: value if value else 0,
        delta=lambda value, previous_value: (value - previous_value) 
                                                if value and previous_value else 0,
        max=20,
        title="Comparison",
        height="250px")

    # Works
    tgb.metric(lambda value: value if value else 0,
            delta="{(value - previous_value) if value and previous_value else 0}",
            max=20,
            title="Comparison",
            height="250px")
# Main execution block with GUI setup
if __name__ == "__main__":
    tp.Gui(page).run(title="Bug replication", port=3248)

Browsers

Chrome

OS

Windows

Version of Taipy

Develop - 7/15/24

Acceptance Criteria

  • Ensure new code is unit tested, and check code coverage is at least 90%.
  • Create related issue in taipy-doc for documentation and Release Notes.

Code of Conduct

  • I have checked the existing issues.
  • I am willing to work on this issue (optional)
@FlorianJacta FlorianJacta added 🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem. 🟨 Priority: Medium Not blocking but should be addressed labels Jul 15, 2024
@FlorianJacta
Copy link
Member Author

This is the same issue as this one: #1518

I will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem. 🟨 Priority: Medium Not blocking but should be addressed
Projects
None yet
Development

No branches or pull requests

1 participant