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

Normalize indices in promote_shape error messages (take 2) #41311

Merged
merged 5 commits into from
Feb 4, 2024

Commits on Feb 3, 2024

  1. Normalize indices in promote_shape error messages.

    Seeing implementation like `Base.OneTo` in error messages may be
    confusing to some users (cf discussion in JuliaLang#39242,
    [discourse](https://discourse.julialang.org/t/promote-shape-dimension-mismatch/57529/)).
    
    This PR turns
    ```julia
    julia> ones(2, 3) + ones(3, 2)
    ERROR: DimensionMismatch("dimensions must match: a has dims (Base.OneTo(2), Base.OneTo(3)), b has dims (Base.OneTo(3), Base.OneTo(2)), mismatch at 1")
    ```
    into
    ```julia
    julia> ones(2, 3) + ones(3, 2)
    ERROR: DimensionMismatch("dimensions must match: a has axes (1:2, 1:3), b has axes (1:3, 1:2), mismatch at 1")
    ```
    
    Fixes JuliaLang#40118.
    
    Acked-by: Tamas K. Papp <[email protected]>
    tpapp authored and vtjnash committed Feb 3, 2024
    Configuration menu
    Copy the full SHA
    a73a3d2 View commit details
    Browse the repository at this point in the history
  2. customize error message based on types

    tpapp authored and vtjnash committed Feb 3, 2024
    Configuration menu
    Copy the full SHA
    2060101 View commit details
    Browse the repository at this point in the history
  3. fix ambiguity

    tpapp authored and vtjnash committed Feb 3, 2024
    Configuration menu
    Copy the full SHA
    d20425c View commit details
    Browse the repository at this point in the history
  4. remove redundant "dimensions must match"

    thanks @mcabbott
    tpapp authored and vtjnash committed Feb 3, 2024
    Configuration menu
    Copy the full SHA
    74a626c View commit details
    Browse the repository at this point in the history
  5. some more improvements

    - avoid assuming the tuples have the same eltype
    - coerce the inputs to simpler representations before printing, if
      unambiguous
    - update a couple more error messages with the same text
    - use string builder, instead of repeated concatenation
    vtjnash committed Feb 3, 2024
    Configuration menu
    Copy the full SHA
    ce7a16e View commit details
    Browse the repository at this point in the history