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

Parameters plot error when result has None #1107

Open
m-philipps opened this issue Aug 14, 2023 · 5 comments
Open

Parameters plot error when result has None #1107

m-philipps opened this issue Aug 14, 2023 · 5 comments
Assignees
Labels
bug Something isn't working visualization Related to any visualization

Comments

@m-philipps
Copy link
Contributor

Bug description
visualize.parameters fails with ValueError when some of the optimization starts failed, i.e. result.optimize_result[i]['x'] is None:

---> 17 pypesto.visualize.parameters(
     18     results=result, 
     19     start_indices="all", 
     20     reference=reference,
     21 )

File [~/Documents/pyPESTO/pypesto/visualize/parameters.py:121], in parameters(results, ax, parameter_indices, lb, ub, size, reference, colors, legends, balance_alpha, start_indices, scale_to_interval, plot_inner_parameters)
    118     lb, ub, xs = map(scale_parameters, (lb, ub, xs))
    120     # call lowlevel routine
--> 121     ax = parameters_lowlevel(
    122         xs=xs,
    123         fvals=fvals,
    124         lb=lb,
    125         ub=ub,
    126         x_labels=x_labels,
    127         ax=ax,
    128         size=size,
    129         colors=colors[j],
    130         legend_text=legends[j],
    131         balance_alpha=balance_alpha,
    132     )
    134 # parse and apply plotting options
    135 ref = create_references(references=reference)

File [~/Documents/pyPESTO/pypesto/visualize/parameters.py:272], in parameters_lowlevel(xs, fvals, lb, ub, x_labels, ax, size, colors, linestyle, legend_text, balance_alpha)
    238 """
    239 Plot parameters plot using list of parameters.
    240 
   (...)
    269     The plot axes.
    270 """
    271 # parse input
--> 272 xs = np.array(xs)
    273 fvals = np.array(fvals)
    274 # remove nan or inf values in fvals and xs

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (100,) + inhomogeneous part.

Expected behavior
I would expect the parameters plot to be generated without the failed starts

Comment
In the lower level process_start_indices delete_nan_inf is only used when start_indices is set to 'all_clustered' or 'first_cluster'

@m-philipps m-philipps added the bug Something isn't working label Aug 14, 2023
@m-philipps
Copy link
Contributor Author

Is this the desired behaviour? If so I would add an informative Warning when there are failed starts in the start_indices. If not, I could use the delete_nan_inf function for all start_indices options

@m-philipps m-philipps self-assigned this Aug 14, 2023
@dweindl
Copy link
Member

dweindl commented Aug 16, 2023

Is this the desired behaviour?

No, I don't think so.

Yeah, some warning "Skipping result {id/idx} due to non-finite / missing parameter values" would make sense.

@dweindl dweindl added the visualization Related to any visualization label Oct 31, 2023
@m-philipps
Copy link
Contributor Author

closed until reproduced

@m-philipps m-philipps reopened this Dec 8, 2023
@m-philipps
Copy link
Contributor Author

Reproducing the bug is fairly straightforward with an optimisation result with any failed start, i.e. fval = inf and x = None.

The issue is that the list of parameter vectors are converted to a numpy array before filtering out None and and the function for that, delete_nan_inf, assumes them to be a numpy array.

@m-philipps
Copy link
Contributor Author

This appears to be specific to the way that each optimiser returns the values for x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working visualization Related to any visualization
Projects
None yet
Development

No branches or pull requests

2 participants