Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: JuliaPhysics/Measurements.jl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 560c33bdf441c93b2546f36741361238662cf3ae
Choose a base ref
..
head repository: JuliaPhysics/Measurements.jl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 68e999351b53d7cc2d5b70429a53ee08e744a5a6
Choose a head ref
Showing with 35 additions and 4 deletions.
  1. +5 −1 Project.toml
  2. +13 −0 ext/MeasurementsBaseTypeExt.jl
  3. +2 −1 src/Measurements.jl
  4. +1 −1 src/derivatives-type.jl
  5. +14 −1 test/runtests.jl
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -11,27 +11,31 @@ RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[weakdeps]
BaseType = "7fbed51b-1ef5-4d67-9085-a4a9b26f478c"
Juno = "e5e0dc1b-0480-54bc-9374-aad01c23163d"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[extensions]
MeasurementsBaseTypeExt = "BaseType"
MeasurementsJunoExt = "Juno"
MeasurementsRecipesBaseExt = "RecipesBase"
MeasurementsSpecialFunctionsExt = "SpecialFunctions"
MeasurementsSymbolicsExt = "Symbolics"
MeasurementsUnitfulExt = "Unitful"

[compat]
BaseType = "0.2"
Calculus = "0.4.1, 0.5"
RecipesBase = "0.6.0, 0.7, 0.8, 1.0"
Requires = "0.5.0, 1"
julia = "1.6"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BaseType = "7fbed51b-1ef5-4d67-9085-a4a9b26f478c"
Juno = "e5e0dc1b-0480-54bc-9374-aad01c23163d"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
@@ -42,4 +46,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["Aqua", "QuadGK", "RecipesBase", "SpecialFunctions", "Statistics", "Symbolics", "Test", "Unitful"]
test = ["Aqua", "BaseType", "QuadGK", "RecipesBase", "SpecialFunctions", "Statistics", "Symbolics", "Test", "Unitful"]
13 changes: 13 additions & 0 deletions ext/MeasurementsBaseTypeExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module MeasurementsBaseTypeExt

if isdefined(Base, :get_extension)
using Measurements: Measurement
import BaseType: base_numeric_type
else
using ..Measurements: Measurement
import ..BaseType: base_numeric_type
end

base_numeric_type(::Type{<:Measurement{T}}) where {T} = base_numeric_type(T)

end
3 changes: 2 additions & 1 deletion src/Measurements.jl
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ Return a `Measurement` object with `val` as nominal value and `err` as
uncertainty. `err` defaults to 0 if omitted.
The binary operator `±` is equivalent to `measurement`, so you can construct a
`Measurement` object by explicitely writing `123 ± 4`.
`Measurement` object by explicitly writing `123 ± 4`.
If `val` is `missing`, `missing` is returned.
"""
@@ -135,6 +135,7 @@ end

@static if !isdefined(Base, :get_extension)
function __init__()
@require BaseType = "7fbed51b-1ef5-4d67-9085-a4a9b26f478c" include("../ext/MeasurementsBaseTypeExt.jl")
@require Unitful="1986cc42-f94f-5a68-af5c-568840ba703d" include("../ext/MeasurementsUnitfulExt.jl")
@require SpecialFunctions="276daf66-3868-5448-9aa4-cd146d93841b" include("../ext/MeasurementsSpecialFunctionsExt.jl")
@require Juno="e5e0dc1b-0480-54bc-9374-aad01c23163d" include("../ext/MeasurementsJunoExt.jl")
2 changes: 1 addition & 1 deletion src/derivatives-type.jl
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
#
### Commentary:
#
# This file containes the definition of Derivatives type. This is borrowed from
# This file contains the definition of Derivatives type. This is borrowed from
# Base.ImmutableDict type (see base/dict.jl in Julia source code), introduced in
# Julia 0.5. `get' and `getindex' have methods different from those of the
# standard Base.ImmutabileDict, otherwise Derivatives and Base.ImmutableDict
15 changes: 14 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Measurements, SpecialFunctions, QuadGK, Calculus
using Measurements, SpecialFunctions, QuadGK, Calculus, BaseType
using Test, LinearAlgebra, Statistics, Unitful, Printf, Aqua

if !isdefined(Base,:get_extension)
@@ -1066,6 +1066,19 @@ end
@test range(0±0, step=1±.1, length=10) isa StepRangeLen
end

@testset "Base type" begin
for T in (Float16, Float32, Float64)
x = Measurement{T}(1.0)
@test base_numeric_type(x) == T
@test base_numeric_type(typeof(x)) == T

# Should still work for nested types:
nested_x = x * u"m"
@test base_numeric_type(x) == T
@test base_numeric_type(typeof(x)) == T
end
end

@static if Base.VERSION >= v"1.9" # We only support Symbolics w/ Julia 1.9+.
@testset "Symbolics" begin
include("symbolics.jl")