When trying to concatenate a string with the output from a LOV if the LOV value is an empty string like "" it'll return the error string index out of range. This was previously not an issue in Taipy version <4.0.
Steps to Reproduce Issue
from taipy.gui import Gui, Markdown
import plotly.graph_objects as go
import numpy as np
## Mock code
class Pipeline:
def __init__(self):
self.instance = {"model_1": Model()}
class Model:
def __init__(self):
self.confusion_matrix = {
"group_norm": self.create_confusion_matrix(normalized=True),
"group": self.create_confusion_matrix(normalized=False)
}
def create_confusion_matrix(self, normalized=False):
# Example data for a 3x3 confusion matrix
matrix = np.array([
[30, 2, 1],
[5, 25, 2],
[3, 4, 28]
])
if normalized:
matrix = matrix / matrix.sum(axis=1)[:, np.newaxis]
fig = go.Figure(data=go.Heatmap(
z=matrix,
x=['A', 'B', 'C'],
y=['A', 'B', 'C'],
colorscale='Blues'
))
# Add title based on normalization
title = "Normalized Confusion Matrix" if normalized else "Confusion Matrix"
fig.update_layout(title=title)
return fig
# Usage
pipeline = Pipeline()
types = [("_norm", "Normalized"), ("", "Raw Count")]
selected_type = types[0]
exec_matrix_page = Markdown("""
# Results
<|{selected_type}|toggle|lov={types}|>
<|chart|figure={pipeline.instance["model_1"].confusion_matrix["group"+ selected_type[0]]}|rebuild|>
""")
if __name__ == "__main__":
gui = Gui(page=exec_matrix_page)
gui.run(port=5001)`
Version of Taipy
4.0
Acceptance Criteria
[ ] A unit test reproducing the bug is added.
[ ] Any new code is covered by a unit tested.
[ ] Check code coverage is at least 90%.
[ ] The bug reporter validated the fix.
[ ] Related issue(s) in taipy-doc are created for documentation and Release Notes are updated.
What went wrong? 🤔
When trying to concatenate a string with the output from a LOV if the LOV value is an empty string like
""
it'll return the errorstring index out of range
. This was previously not an issue in Taipy version <4.0.Steps to Reproduce Issue
Version of Taipy
4.0
Acceptance Criteria
Code of Conduct