JuliaPhysics / JuliaPhysics/Unitful.jl

Broadcasting `uconvert` over a range could return a range

Open
#576 0 comments 1 reaction 0 assignees View on GitHub
enhancement ranges
Dominant language
Julia
Stars
675
Forks
124
Avg merge
3h 38m
Merged PRs (30d)
1

Description

When broadcasting a unit (as a function) over a range, it returns a range. But when using `uconvert`, it allocates a vector instead:

```julia
julia> x = (1:2:5) * u"m"
(1:2:5) m

julia> x .|> u"cm"
(100:200:500) cm

julia> uconvert.(u"cm", x)
3-element Vector{Quantity{Int64, 𝐋, Unitful.FreeUnits{(cm,), 𝐋, nothing}}}:
100 cm
300 cm
500 cm
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Use the reproducer in the issue as the first check, comparing function broadcasting over the range with `uconvert.(u"cm", x)`. Trace the relevant Julia broadcasting behavior and Unitful implementation. Done means conversion preserves the range form, with coverage for the shown example.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.