JuliaPhysics / JuliaPhysics/Unitful.jl

`unit` and `dimension` are inconsistent for `Level`s

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

Description

For `Level`s (and mixed quantities based on `Level`s), `unit` discards the logarithmic part, `dimension` does not:
```julia
julia> unit(5u"dBV") # NoUnits

julia> dimension(5u"dBV") # voltage
𝐋^2 𝐌 𝐈^-1 𝐓^-3

julia> unit(5u"dBV*m") # meters (a length)
m

julia> dimension(5u"dBV*m") # voltage * length
𝐋^3 𝐌 𝐈^-1 𝐓^-3
```
I think the behavior of `dimension` makes sense. To fix `unit`, there are two possibilities:
1. Use the `unit` of the `reflevel`, i.e., `unit(5u"dBV") == V`
2. Make `unit(::Level)` throw an error

Edit: Related: #528.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the documented `unit` and `dimension` examples for `Level`s and mixed quantities, then inspect the `Level` handling for both operations. Resolve whether `unit(::Level)` should use the reference-level unit or throw, and verify that the selected behavior is covered for both standalone and mixed quantities.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.