A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/JuliaLang/julia/issues/22216 below:

Unitless typeof and eltype · Issue #22216 · JuliaLang/julia · GitHub

A very common operation when trying to write package which works with unitful quantities is getting the unitless element-type. This is required to find the right eps or set the tolerance to the correct Number type. However, I am not sure of a completely generic way to handle this. typeof(first(one(u))) works well in a pinch, but I am noticing an issue with GPUArrays which do not have indexing and thus don't have first defined. So the only way I know of to always get the unitless element type is eltype(u./u), which has an extra operation just to grab the type.

Is there a generic function to strip the units off of a type? Some unitless(T) to get whatever the type of the non-unit part is? That would be a clear way to implement this.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4