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

simdec.tableau function modifies states argument #33

Closed
matt-graham opened this issue May 22, 2024 · 1 comment
Closed

simdec.tableau function modifies states argument #33

matt-graham opened this issue May 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@matt-graham
Copy link
Contributor

Raising as part of JOSS review openjournals/joss-reviews/issues/6713

Currently the simdec.tableau function modifies the states list argument passed to the function in the for loop in lines

for i, state in enumerate(states):
if isinstance(state, int):
states: list
if state == 2:
states[i] = ["low", "high"]
elif state == 3:
states[i] = ["low", "medium", "high"]

This results in a cryptic TypeError: slice indices must be integers or None or have an __index__ method error if calling simdec.palette subsequently on the same states argument, for example (running from root of repository)

import numpy as np
import pandas as pd
import simdec as sd

data = pd.read_csv("tests/data/stress.csv")
output_name, *variable_names = list(data.columns)
inputs, output = data[variable_names], data[output_name]
sensitivity_analysis_result = sd.sensitivity_indices(inputs=inputs, output=output)
decomposition_results = sd.decomposition(
    inputs=inputs,
    output=output,
    sensitivity_indices=sensitivity_analysis_result.first_order
)

table, styler = sd.tableau(
    var_names=variable_names,
    statistic=decomposition_results.statistic,
    states=decomposition_results.states,
    bins=decomposition_results.bins,
    palette=sd.palette(decomposition_results.states)
)

sd.palette(decomposition_results.states)
@tupui tupui added the bug Something isn't working label May 22, 2024
@tupui
Copy link
Member

tupui commented May 22, 2024

Thanks, good catch. Should be fixed with d0a3fb5

@tupui tupui closed this as completed May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants