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

Relaxing ::Real requirement #1801

Closed
MilesCranmer opened this issue Nov 19, 2023 · 1 comment
Closed

Relaxing ::Real requirement #1801

MilesCranmer opened this issue Nov 19, 2023 · 1 comment

Comments

@MilesCranmer
Copy link

Hi,

I was wondering if the requirement for numeric types to be ::Real could be relaxed to ::Any? Since Julia doesn't have multiple inheritance, this limits the range of types you can use perhaps more than necessary. There are some types which act exactly like a Real in every other way, except they do not inherit from Real, so it would be great if one could use those as well.

My specific use-case is I'm trying to use physical units in a Distributions model, but both Unitful.Quantity and DynamicQuantities.Quantity are <:Number so are incompatible, despite the numerical type being a Real in both cases (base type Float64).

julia> using DynamicQuantities  # or Unitful

julia> Normal(10u"km/s", 1u"km/s")
ERROR: MethodError: no method matching Normal(::Quantity{Float64, Dimensions{…}}, ::Quantity{Float64, Dimensions{…}})
Stacktrace:
 [1] top-level scope
   @ REPL[6]:1
Some type information was truncated. Use `show(err)` to see complete types.

I think that 10 km/s ± 1 km/s is a standard description for a physical measurement so this would be useful to have.

Cheers,
Miles

(copied from TuringLang/Turing.jl#2133 as the same issue arises there)

@MilesCranmer
Copy link
Author

MilesCranmer commented Nov 19, 2023

Ah, just noticed #1684 and #1691 right after posting. Feel free to close if you wish

Edit 2: also I see #1413. Maybe the fix is to add an extension to DynamicQuantities.jl?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants