Skip to content

DomainError in show(::Minuit) when parameter values are very large #51

@zejianzhuang-uv

Description

@zejianzhuang-uv

Title: DomainError in show(::Minuit) when parameter values are very large

Body:

When displaying a Minuit object in VSCode notebook (or any context that calls show(::Minuit)), a DomainError is thrown if any parameter value has reached a very large magnitude (e.g. -1.57e103). The error occurs at util.jl:306 and is caused by exponentiation of a negative float, which requires a complex argument in Julia.

Error message:

DomainError with -1.5700540615245946e103:
Exponentiation yielding a complex result requires a complex argument.
Replace x^y with (x+0im)^y, Complex(x)^y, or similar.

Stacktrace (relevant part):

[1] throw_exp_domainerror(x::Float64) @ Base.Math ./math.jl:41
[2] ^(x::Float64, y::Float64) @ Base.Math ./math.jl:1155
...
[13] show(io::IOContext{IOBuffer}, m::Minuit) @ Minuit2 ~/.julia/packages/Minuit2/dpRUQ/src/util.jl:306

To reproduce:
Run a minimization where parameters are not sufficiently constrained, allowing them to reach extreme values. Then display the Minuit object (e.g. as the last expression in a Jupyter/VSCode notebook cell).

Expected behavior:
show(::Minuit) should handle extreme or invalid parameter values gracefully without throwing an error.

Suggested fix:
Wrap the exponentiation at util.jl:306 with a check or use abs(x)^y, or guard with a try/catch inside show.

Workaround:
Suppress automatic display by appending ; to any cell that returns a Minuit object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions