From d1ac9817cbfb8d39603b5b6845e1488ed7743cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Wed, 22 Mar 2023 15:56:53 +0000 Subject: [PATCH] Define `one(::Type{Measurement{T}})` to return `one(T)` (#135) * Define `one(::Type{Measurement{T}})` to return `one(T)` * Bring back `Unitful` + `QuadGK` test * Do not require `@inferred` on operations which can't be inferred anymore * Tighten back tolerance of QuadGK operations by requesting a specific `atol` * Update Manifest of benchmarks to get newer QuadGK version * Update `NEWS.md` --- .github/workflows/benchmark.yml | 2 +- NEWS.md | 16 ++ benchmark/Manifest.toml | 413 ++++++++++++++++++++------------ src/Measurements.jl | 1 - src/math.jl | 3 + src/quadgk.jl | 63 ----- test/complex.jl | 14 +- test/runtests.jl | 43 ++-- 8 files changed, 307 insertions(+), 248 deletions(-) delete mode 100644 src/quadgk.jl diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 0216f1e5..b712c252 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v2 - uses: julia-actions/setup-julia@v1 with: - version: '^1.6.0-0' + version: '1.8.5' - name: Cache artifacts uses: actions/cache@v2 with: diff --git a/NEWS.md b/NEWS.md index 5802ce6d..669030b4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,21 @@ # History of Measurements.jl +## v2.9.0 (2023-03-22) + +### New features + +* New methods `value(::Missing)` and `uncertainty(::Missing)` + ([#127](https://github.com/JuliaPhysics/Measurements.jl/pull/127), + [#128](https://github.com/JuliaPhysics/Measurements.jl/pull/128)). +* `one(::Measurement{T})` now returns `one(T)`, instead of an instance of + `Measurement{T}` + ([#134](https://github.com/JuliaPhysics/Measurements.jl/issues/134), + [#135](https://github.com/JuliaPhysics/Measurements.jl/pull/135)). This + change should not breaking (and hence the major version was not increased), + unless you were relying on the previous incorrect return type of + `one(::Measurement{T})`, which did not follow the precise semantic of the + `one` function. + ## v2.8.0 (2022-09-01) ### New features diff --git a/benchmark/Manifest.toml b/benchmark/Manifest.toml index 560ac837..34530c07 100644 --- a/benchmark/Manifest.toml +++ b/benchmark/Manifest.toml @@ -1,354 +1,459 @@ # This file is machine-generated - editing it directly is not advised -[[AbstractTrees]] -git-tree-sha1 = "03e0550477d86222521d254b741d470ba17ea0b5" +julia_version = "1.8.5" +manifest_format = "2.0" +project_hash = "5d77b1fe0a156dd5010a4d91bcc6181d737d9109" + +[[deps.AbstractTrees]] +git-tree-sha1 = "faa260e4cb5aba097a73fab382dd4b5819d8ec8c" uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" -version = "0.3.4" +version = "0.4.4" -[[ArgTools]] +[[deps.ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" +version = "1.1.1" -[[Artifacts]] +[[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" -[[Base64]] +[[deps.Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" -[[BenchmarkCI]] +[[deps.BenchmarkCI]] deps = ["Base64", "BenchmarkTools", "CpuId", "Dates", "GitHub", "JSON", "LinearAlgebra", "Logging", "Markdown", "Pkg", "PkgBenchmark", "Setfield", "Tar", "UnPack", "Zstd_jll"] -git-tree-sha1 = "12f462ed9007e1838ccde5f65a7370564600438f" +git-tree-sha1 = "41eef9519b5ba56f2bad6b594d6c54b847268a30" uuid = "20533458-34a3-403d-a444-e18f38190b5b" -version = "0.1.7" +version = "0.1.9" -[[BenchmarkTools]] -deps = ["JSON", "Logging", "Printf", "Statistics", "UUIDs"] -git-tree-sha1 = "9e62e66db34540a0c919d72172cc2f642ac71260" +[[deps.BenchmarkTools]] +deps = ["JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"] +git-tree-sha1 = "d9a9701b899b30332bbcb3e1679c41cce81fb0e8" uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -version = "0.5.0" +version = "1.3.2" -[[Calculus]] +[[deps.BitFlags]] +git-tree-sha1 = "43b1a4a8f797c1cddadf60499a8a077d4af2cd2d" +uuid = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" +version = "0.1.7" + +[[deps.Calculus]] deps = ["LinearAlgebra"] git-tree-sha1 = "f641eb0a4f00c343bbc32346e1217b86f3ce9dad" uuid = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" version = "0.5.1" -[[ChainRulesCore]] +[[deps.ChainRulesCore]] deps = ["Compat", "LinearAlgebra", "SparseArrays"] -git-tree-sha1 = "42e3c181483fbd2c416087a0a93838803e358358" +git-tree-sha1 = "c6d890a52d2c4d55d326439580c3b8d0875a77d9" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "0.9.38" - -[[Compat]] -deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] -git-tree-sha1 = "ac4132ad78082518ec2037ae5770b6e796f7f956" +version = "1.15.7" + +[[deps.ChangesOfVariables]] +deps = ["ChainRulesCore", "LinearAlgebra", "Test"] +git-tree-sha1 = "844b061c104c408b24537482469400af6075aae4" +uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0" +version = "0.1.5" + +[[deps.CodecZlib]] +deps = ["TranscodingStreams", "Zlib_jll"] +git-tree-sha1 = "9c209fb7536406834aa938fb149964b985de6c83" +uuid = "944b1d66-785c-5afd-91f1-9de20f533193" +version = "0.7.1" + +[[deps.Compat]] +deps = ["Dates", "LinearAlgebra", "UUIDs"] +git-tree-sha1 = "61fdd77467a5c3ad071ef8277ac6bd6af7dd4c04" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "3.27.0" +version = "4.6.0" -[[CompilerSupportLibraries_jll]] +[[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" +version = "1.0.1+0" -[[ConstructionBase]] +[[deps.ConstructionBase]] deps = ["LinearAlgebra"] -git-tree-sha1 = "48920211c95a6da1914a06c44ec94be70e84ffff" +git-tree-sha1 = "fb21ddd70a051d882a1686a5a550990bbe371a95" uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9" -version = "1.1.0" +version = "1.4.1" -[[CpuId]] +[[deps.CpuId]] deps = ["Markdown"] -git-tree-sha1 = "32d125af0fb8ec3f8935896122c5e345709909e5" +git-tree-sha1 = "fcbb72b032692610bfbdb15018ac16a36cf2e406" uuid = "adafc99b-e345-5852-983c-f28acb93d879" -version = "0.3.0" +version = "0.3.1" -[[DataStructures]] +[[deps.DataStructures]] deps = ["Compat", "InteractiveUtils", "OrderedCollections"] -git-tree-sha1 = "4437b64df1e0adccc3e5d1adbc3ac741095e4677" +git-tree-sha1 = "d1fff3a548102f48987a52a2e0d114fa97d730f0" uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -version = "0.18.9" +version = "0.18.13" -[[Dates]] +[[deps.Dates]] deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" -[[DelimitedFiles]] -deps = ["Mmap"] -uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" - -[[Distributed]] -deps = ["Random", "Serialization", "Sockets"] -uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" +[[deps.DocStringExtensions]] +deps = ["LibGit2"] +git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d" +uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" +version = "0.9.3" -[[Downloads]] -deps = ["ArgTools", "LibCURL", "NetworkOptions"] +[[deps.Downloads]] +deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" +version = "1.6.0" + +[[deps.FileWatching]] +uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" -[[Future]] +[[deps.Future]] deps = ["Random"] uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" -[[GitHub]] -deps = ["Base64", "Dates", "HTTP", "JSON", "MbedTLS", "Sockets", "SodiumSeal"] -git-tree-sha1 = "a4f61fc1b1724e6eec1d9333eac2d4b01d8fcc8f" +[[deps.GitHub]] +deps = ["Base64", "Dates", "HTTP", "JSON", "MbedTLS", "Sockets", "SodiumSeal", "URIs"] +git-tree-sha1 = "5688002de970b9eee14b7af7bbbd1fdac10c9bbe" uuid = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26" -version = "5.4.0" +version = "5.8.2" -[[HTTP]] -deps = ["Base64", "Dates", "IniFile", "MbedTLS", "NetworkOptions", "Sockets", "URIs"] -git-tree-sha1 = "c9f380c76d8aaa1fa7ea9cf97bddbc0d5b15adc2" +[[deps.HTTP]] +deps = ["Base64", "CodecZlib", "Dates", "IniFile", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"] +git-tree-sha1 = "37e4657cd56b11abe3d10cd4a1ec5fbdb4180263" uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" -version = "0.9.5" +version = "1.7.4" -[[IniFile]] -deps = ["Test"] -git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" +[[deps.IniFile]] +git-tree-sha1 = "f550e6e32074c939295eb5ea6de31849ac2c9625" uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" -version = "0.5.0" +version = "0.5.1" -[[InteractiveUtils]] +[[deps.InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" -[[JLLWrappers]] +[[deps.InverseFunctions]] +deps = ["Test"] +git-tree-sha1 = "49510dfcb407e572524ba94aeae2fced1f3feb0f" +uuid = "3587e190-3f89-42d0-90ee-14403ec27112" +version = "0.1.8" + +[[deps.IrrationalConstants]] +git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151" +uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" +version = "0.1.1" + +[[deps.JLLWrappers]] deps = ["Preferences"] -git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e" +git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.3.0" +version = "1.4.1" -[[JSON]] +[[deps.JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] -git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4" +git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e" uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -version = "0.21.1" +version = "0.21.3" -[[LeftChildRightSiblingTrees]] +[[deps.LeftChildRightSiblingTrees]] deps = ["AbstractTrees"] -git-tree-sha1 = "71be1eb5ad19cb4f61fa8c73395c0338fd092ae0" +git-tree-sha1 = "fb6803dafae4a5d62ea5cab204b1e657d9737e7f" uuid = "1d6d02ad-be62-4b6b-8a6d-2f90e265016e" -version = "0.1.2" +version = "0.2.0" -[[LibCURL]] +[[deps.LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" +version = "0.6.3" -[[LibCURL_jll]] +[[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" +version = "7.84.0+0" -[[LibGit2]] +[[deps.LibGit2]] deps = ["Base64", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" -[[LibSSH2_jll]] +[[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" +version = "1.10.2+0" -[[Libdl]] +[[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" -[[LinearAlgebra]] -deps = ["Libdl"] +[[deps.LinearAlgebra]] +deps = ["Libdl", "libblastrampoline_jll"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -[[Logging]] +[[deps.LogExpFunctions]] +deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"] +git-tree-sha1 = "680e733c3a0a9cea9e935c8c2184aea6a63fa0b5" +uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" +version = "0.3.21" + +[[deps.Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" -[[MacroTools]] +[[deps.LoggingExtras]] +deps = ["Dates", "Logging"] +git-tree-sha1 = "cedb76b37bc5a6c702ade66be44f831fa23c681e" +uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36" +version = "1.0.0" + +[[deps.MacroTools]] deps = ["Markdown", "Random"] -git-tree-sha1 = "6a8a2a625ab0dea913aba95c11370589e0239ff0" +git-tree-sha1 = "42324d08725e200c23d4dfb549e0d5d89dede2d2" uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" -version = "0.5.6" +version = "0.5.10" -[[Markdown]] +[[deps.Markdown]] deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" -[[MbedTLS]] -deps = ["Dates", "MbedTLS_jll", "Random", "Sockets"] -git-tree-sha1 = "1c38e51c3d08ef2278062ebceade0e46cefc96fe" +[[deps.MbedTLS]] +deps = ["Dates", "MbedTLS_jll", "MozillaCACerts_jll", "Random", "Sockets"] +git-tree-sha1 = "03a9b9718f5682ecb107ac9f7308991db4ce395b" uuid = "739be429-bea8-5141-9913-cc70e7f3736d" -version = "1.0.3" +version = "1.1.7" -[[MbedTLS_jll]] +[[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" +version = "2.28.0+0" -[[Measurements]] +[[deps.Measurements]] deps = ["Calculus", "LinearAlgebra", "Printf", "RecipesBase", "Requires"] path = ".." uuid = "eff96d63-e80a-5855-80a2-b1b0885c5ab7" -version = "2.6.0" +version = "2.9.0" -[[Mmap]] +[[deps.Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" -[[MozillaCACerts_jll]] +[[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" +version = "2022.2.1" -[[NetworkOptions]] +[[deps.NetworkOptions]] uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" +version = "1.2.0" -[[OpenSpecFun_jll]] +[[deps.OpenBLAS_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] +uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" +version = "0.3.20+0" + +[[deps.OpenLibm_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "05823500-19ac-5b8b-9628-191a04bc5112" +version = "0.8.1+0" + +[[deps.OpenSSL]] +deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] +git-tree-sha1 = "6503b77492fd7fcb9379bf73cd31035670e3c509" +uuid = "4d8831e6-92b7-49fb-bdf8-b643e874388c" +version = "1.3.3" + +[[deps.OpenSSL_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "9ff31d101d987eb9d66bd8b176ac7c277beccd09" +uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" +version = "1.1.20+0" + +[[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "9db77584158d0ab52307f8c04f8e7c08ca76b5b3" +git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1" uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" -version = "0.5.3+4" +version = "0.5.5+0" -[[OrderedCollections]] -git-tree-sha1 = "4fa2ba51070ec13fcc7517db714445b4ab986bdf" +[[deps.OrderedCollections]] +git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.4.0" +version = "1.4.1" -[[Parsers]] -deps = ["Dates"] -git-tree-sha1 = "c8abc88faa3f7a3950832ac5d6e690881590d6dc" +[[deps.Parsers]] +deps = ["Dates", "SnoopPrecompile"] +git-tree-sha1 = "6f4fbcd1ad45905a5dee3f4256fabb49aa2110c6" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "1.1.0" +version = "2.5.7" -[[Pkg]] +[[deps.Pkg]] deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +version = "1.8.0" -[[PkgBenchmark]] +[[deps.PkgBenchmark]] deps = ["BenchmarkTools", "Dates", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Pkg", "Printf", "TerminalLoggers", "UUIDs"] -git-tree-sha1 = "6e2856f677f8dcab289ded9c3ffb018fad38f29c" +git-tree-sha1 = "e4a10b7cdb7ec836850e43a4cee196f4e7b02756" uuid = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" -version = "0.2.10" +version = "0.2.12" -[[Preferences]] +[[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "ea79e4c9077208cd3bc5d29631a26bc0cff78902" +git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.2.1" +version = "1.3.0" -[[Printf]] +[[deps.Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" -[[ProgressLogging]] +[[deps.Profile]] +deps = ["Printf"] +uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" + +[[deps.ProgressLogging]] deps = ["Logging", "SHA", "UUIDs"] git-tree-sha1 = "80d919dee55b9c50e8d9e2da5eeafff3fe58b539" uuid = "33c8b6b6-d38a-422a-b730-caa89a2f386c" version = "0.1.4" -[[QuadGK]] +[[deps.QuadGK]] deps = ["DataStructures", "LinearAlgebra"] -git-tree-sha1 = "12fbe86da16df6679be7521dfb39fbc861e1dc7b" +git-tree-sha1 = "786efa36b7eff813723c4849c90456609cf06661" uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" -version = "2.4.1" +version = "2.8.1" -[[REPL]] +[[deps.REPL]] deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" -[[Random]] -deps = ["Serialization"] +[[deps.Random]] +deps = ["SHA", "Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -[[RecipesBase]] -git-tree-sha1 = "b3fb709f3c97bfc6e948be68beeecb55a0b340ae" +[[deps.RecipesBase]] +deps = ["SnoopPrecompile"] +git-tree-sha1 = "261dddd3b862bd2c940cf6ca4d1c8fe593e457c8" uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -version = "1.1.1" +version = "1.3.3" -[[Requires]] +[[deps.Requires]] deps = ["UUIDs"] -git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621" +git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7" uuid = "ae029012-a4dd-5104-9daa-d747884805df" -version = "1.1.3" +version = "1.3.0" -[[SHA]] +[[deps.SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +version = "0.7.0" -[[Serialization]] +[[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" -[[Setfield]] +[[deps.Setfield]] deps = ["ConstructionBase", "Future", "MacroTools", "Requires"] -git-tree-sha1 = "d5640fc570fb1b6c54512f0bd3853866bd298b3e" +git-tree-sha1 = "38d88503f695eb0301479bc9b0d4320b378bafe5" uuid = "efcf1570-3423-57d1-acb7-fd33fddbac46" -version = "0.7.0" +version = "0.8.2" + +[[deps.SimpleBufferStream]] +git-tree-sha1 = "874e8867b33a00e784c8a7e4b60afe9e037b74e1" +uuid = "777ac1f9-54b0-4bf8-805c-2214025038e7" +version = "1.1.0" -[[SharedArrays]] -deps = ["Distributed", "Mmap", "Random", "Serialization"] -uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" +[[deps.SnoopPrecompile]] +deps = ["Preferences"] +git-tree-sha1 = "e760a70afdcd461cf01a575947738d359234665c" +uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c" +version = "1.0.3" -[[Sockets]] +[[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" -[[SodiumSeal]] +[[deps.SodiumSeal]] deps = ["Base64", "Libdl", "libsodium_jll"] git-tree-sha1 = "80cef67d2953e33935b41c6ab0a178b9987b1c99" uuid = "2133526b-2bfb-4018-ac12-889fb3908a75" version = "0.1.1" -[[SparseArrays]] +[[deps.SparseArrays]] deps = ["LinearAlgebra", "Random"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -[[SpecialFunctions]] -deps = ["ChainRulesCore", "OpenSpecFun_jll"] -git-tree-sha1 = "5919936c0e92cff40e57d0ddf0ceb667d42e5902" +[[deps.SpecialFunctions]] +deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] +git-tree-sha1 = "d75bda01f8c31ebb72df80a46c88b25d1c79c56d" uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "1.3.0" +version = "2.1.7" -[[Statistics]] +[[deps.Statistics]] deps = ["LinearAlgebra", "SparseArrays"] uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -[[TOML]] +[[deps.TOML]] deps = ["Dates"] uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" +version = "1.0.0" -[[Tar]] +[[deps.Tar]] deps = ["ArgTools", "SHA"] uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" +version = "1.10.1" -[[TerminalLoggers]] +[[deps.TerminalLoggers]] deps = ["LeftChildRightSiblingTrees", "Logging", "Markdown", "Printf", "ProgressLogging", "UUIDs"] -git-tree-sha1 = "e185a19bb9172f0cf5bc71233fab92a46f7ae154" +git-tree-sha1 = "f53e34e784ae771eb9ccde4d72e578aa453d0554" uuid = "5d786b92-1e48-4d6f-9151-6b4477ca9bed" -version = "0.1.3" +version = "0.1.6" -[[Test]] +[[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -[[URIs]] -git-tree-sha1 = "7855809b88d7b16e9b029afd17880930626f54a2" +[[deps.TranscodingStreams]] +deps = ["Random", "Test"] +git-tree-sha1 = "94f38103c984f89cf77c402f2a68dbd870f8165f" +uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" +version = "0.9.11" + +[[deps.URIs]] +git-tree-sha1 = "074f993b0ca030848b897beff716d93aca60f06a" uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" -version = "1.2.0" +version = "1.4.2" -[[UUIDs]] +[[deps.UUIDs]] deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" -[[UnPack]] +[[deps.UnPack]] git-tree-sha1 = "387c1f73762231e86e0c9c5443ce3b4a0a9a0c2b" uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" version = "1.0.2" -[[Unicode]] +[[deps.Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" -[[Zlib_jll]] +[[deps.Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" +version = "1.2.12+3" -[[Zstd_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "2c1332c54931e83f8f94d310fa447fd743e8d600" +[[deps.Zstd_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "c6edfe154ad7b313c01aceca188c05c835c67360" uuid = "3161d3a3-bdf6-5164-811a-617609db77b4" -version = "1.4.8+0" +version = "1.5.4+0" + +[[deps.libblastrampoline_jll]] +deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] +uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" +version = "5.1.1+0" -[[libsodium_jll]] +[[deps.libsodium_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] git-tree-sha1 = "848ab3d00fe39d6fbc2a8641048f8f272af1c51e" uuid = "a9144af2-ca23-56d9-984f-0d03f7b5ccf8" version = "1.0.20+0" -[[nghttp2_jll]] +[[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" +version = "1.48.0+0" -[[p7zip_jll]] +[[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" +version = "17.4.0+0" diff --git a/src/Measurements.jl b/src/Measurements.jl index cdee6eac..e330192b 100644 --- a/src/Measurements.jl +++ b/src/Measurements.jl @@ -82,7 +82,6 @@ const tag_counter = Threads.Atomic{UInt64}(1) function __init__() @require Unitful="1986cc42-f94f-5a68-af5c-568840ba703d" include("unitful.jl") - @require QuadGK="1fd47b50-473d-5c70-9696-f719f8f3bcdc" include("quadgk.jl") @require SpecialFunctions="276daf66-3868-5448-9aa4-cd146d93841b" include("special-functions.jl") end diff --git a/src/math.jl b/src/math.jl index 9a00665a..3115e7f1 100644 --- a/src/math.jl +++ b/src/math.jl @@ -794,3 +794,6 @@ function Base.prod(a::AbstractArray{<:Measurement}) [prod(deleteat!(copy(x), i)) for i in eachindex(x)], a) end + +Base.one(::Type{Measurement{T}}) where T = one(T) +Base.one(::Type{Complex{Measurement{T}}}) where T = one(Complex{T}) diff --git a/src/quadgk.jl b/src/quadgk.jl deleted file mode 100644 index c8daad3c..00000000 --- a/src/quadgk.jl +++ /dev/null @@ -1,63 +0,0 @@ -### quadgk.jl -# -# Copyright (C) 2019 Mosè Giordano. -# -# Maintainer: Mosè Giordano -# Keywords: uncertainty, error propagation, physics -# -# This file is a part of Measurements.jl. -# -# License is MIT "Expat". -# -### Commentary: -# -# This file integration with QuadGK.jl. -# -### Code: - -# Helper functions to handle result of integration with QuadGK when endpoints are -# Measurement objects. - -# The integral itself is a Measurement object, propagate its uncertainty. -quadgk_result(integral::Measurement, derivative::Real, a::Measurement) = - result(integral.val, (1, derivative.val), (integral, a)) -quadgk_result(integral::Measurement, derivatives::Tuple, a::Tuple) = - result(integral.val, (1, value.(derivatives)...), (integral, a...)) -# Only endpoints are are Measurement objects. -quadgk_result(integral::Real, derivative::Real, a::Measurement) = - result(integral, derivative, a) -quadgk_result(integral::Real, derivatives::Tuple, a::Tuple) = - result(integral, derivatives, a) - -# Upper bound is a Measurement. The derivative is f(b). -function QuadGK.quadgk(f, a::S, b::Measurement{T}; kws...) where {S,T<:AbstractFloat} - F = promote_type(S, T) - bval = b.val - integral = QuadGK.quadgk(f, convert(F, a), convert(F, bval); kws...) - return (quadgk_result(integral[1], f(bval), b), integral[2]) -end - -# Lower bound is a Measurement. The derivative is -f(a). -function QuadGK.quadgk(f, a::Measurement{T}, b::S; kws...) where {S,T<:AbstractFloat} - F = promote_type(S, T) - aval = a.val - integral = QuadGK.quadgk(f, convert(F, aval), convert(F, b); kws...) - return (quadgk_result(integral[1], -f(aval), a), integral[2]) -end - -# Both bounds are Measurement's. Derivatives are -f(a) and f(b). -function QuadGK.quadgk(f, a::Measurement{T}, b::Measurement{S}; - kws...) where {T<:AbstractFloat,S<:AbstractFloat} - F = promote_type(T, S) - aval = a.val - bval = b.val - integral = QuadGK.quadgk(f, convert(F, aval), convert(F, bval); kws...) - return (quadgk_result(integral[1], (-f(aval), f(bval)), (a, b)), integral[2]) -end - -# This shouldn't be needed in most cases, but when the extrema of an integral -# are numbers with uncertainty _and_ physical units (from Unitful.jl), the -# unitful property of the numbers is lost, leading to an inconsistency: -# . -QuadGK.cachedrule(::Type{Measurement{T}}, n::Integer) where {T<:AbstractFloat} = - QuadGK.cachedrule(T, n) diff --git a/test/complex.jl b/test/complex.jl index 6b5a2174..8bb59efd 100644 --- a/test/complex.jl +++ b/test/complex.jl @@ -18,10 +18,10 @@ end @test @inferred(u * v) == @inferred(v * u) for a in (u, v, z) @test @inferred(a * 1) == @inferred(1 * a) == a - @test @inferred(a ^ 1) == a - @test @inferred(a ^ 3.0) == a * a * a - @test @inferred(a ^ 2.3) ≈ a * a * a ^ 0.3 - @test @inferred(a ^ 0) == one(a) + @test a ^ 1 == a + @test a ^ 3.0 == a * a * a + @test a ^ 2.3 ≈ a * a * a ^ 0.3 + @test a ^ 0 == one(a) @test @inferred(a * im) == @inferred(im * a) end end @@ -50,13 +50,13 @@ end @test @inferred(tanh(atanh(a))) ≈ a @test @inferred(sinpi(a)) ≈ sin(pi * a) @test @inferred(cospi(a)) ≈ cos(pi * a) - @test @inferred(sinc(a)) ≈ (sin(pi * a) / (pi * a)) + @test sinc(a) ≈ (sin(pi * a) / (pi * a)) @test @inferred(cosc(a)) ≈ ((cos(pi * a) - sin(pi * a) / (pi * a)) / a) end end @testset "Exponential and logarithm" begin - @test @inferred(u ^ v) ≈ @inferred(exp(v * log(u))) + @test u ^ v ≈ @inferred(exp(v * log(u))) for a in (u, v, z) @test @inferred(exp(a)) ≈ ℯ^a @test @inferred(expm1(a)) ≈ exp(a) - 1 @@ -75,7 +75,7 @@ end @testset "Square root" begin for a in (u, v, z) - @test @inferred(sqrt(a)) ≈ @inferred(a^0.5) + @test @inferred(sqrt(a)) ≈ a^0.5 @test @inferred(sqrt(a)*sqrt(a)) ≈ a @test @inferred(sqrt(big(a))) ≈ sqrt(a) end diff --git a/test/runtests.jl b/test/runtests.jl index e182d4ac..5b5126c6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -172,7 +172,7 @@ end @test hash(a) == hash(a) @test hash(2 * a) == hash(a + a) @test hash(a - a) == hash(zero(a)) - @test hash(a / a) == hash(one(a)) + @test hash(a / a) == hash(oneunit(a)) d = Dict(a => 42) @test d[a] == 42 # `hash` must be consistent with `==`. Skip following tests for @@ -233,11 +233,11 @@ end end for f in (muladd, fma) @test @inferred(f(w, x, y)) ≈ w*x + y - @test @inferred(f(w, x, 1)) ≈ w*x + one(y) + @test @inferred(f(w, x, 1)) ≈ w*x + oneunit(y) @test @inferred(f(w, 2, y)) ≈ w*2 + y - @test @inferred(f(w, 2, 1)) ≈ w*2 + one(x) + @test @inferred(f(w, 2, 1)) ≈ w*2 + oneunit(x) @test @inferred(f(3, x, y)) ≈ 3*x + y - @test @inferred(f(3, x, 1)) ≈ 3*x + one(w) + @test @inferred(f(3, x, 1)) ≈ 3*x + oneunit(w) @test @inferred(f(3, 2, y)) ≈ 3*2 + y end end @@ -259,7 +259,7 @@ end @test @inferred(0 / a) ≈ measurement(0) @test @inferred((0 ± 1) / a) ≈ measurement(0, 1/abs(a.val)) # Test correlation - @test @inferred(a / a) ≈ one(a) ≈ measurement(1) + @test @inferred(a / a) ≈ oneunit(a) ≈ measurement(1) # Test derivatives of "div", "fld", and "cld". They're defined to be exactly 0. # Should you discover this is not correct, update the test accordingly. for f in (div, fld, cld), b in (w, x, y) @@ -285,8 +285,8 @@ end @test @inferred(x^(pi)) ≈ measurement(31.54428070019754, 3.3033093503504967) @test @inferred(2^x) ≈ measurement(8, 0.5545177444479562) @test @inferred(pi^x) ≈ measurement(31.006276680299816, 3.5493811564854525) - @test @inferred(z ^ 2.5) ≈ @inferred(x ^ 2.5) - @test @inferred(z ^ 3) ≈ @inferred(x ^ 3) + @test z ^ 2.5 ≈ @inferred(x ^ 2.5) + @test z ^ 3 ≈ @inferred(x ^ 3) for a in (w, x, y) @test @inferred(x ^ a) ≈ @inferred(exp(a * log(x))) @test @inferred(abs(a) ^ w) ≈ @inferred(exp(w * log(abs(a)))) @@ -317,13 +317,13 @@ end @test @inferred(sind(y)) ≈ measurement(0.0697564737441253, 0.0034821554353128255) @test @inferred(sinh(y)) ≈ measurement(27.28991719712775, 5.461646567203298) for a in (w, x, y) - @test @inferred(cos(a) ^ 2 + sin(a) ^ 2) ≈ one(a) + @test @inferred(cos(a) ^ 2 + sin(a) ^ 2) ≈ oneunit(a) @test @inferred(tan(a)) ≈ sin(a) / cos(a) @test @inferred(tand(a)) ≈ sind(a) / cosd(a) @test @inferred(tanh(a)) ≈ sinh(a) / cosh(a) @test @inferred(sinpi(a))≈ sin(pi * a) atol = 1e-15 @test @inferred(cospi(a))≈ cos(pi * a) atol = 1e-15 - @test @inferred(sinc(a)) ≈ (sin(pi * a) / (pi * a)) atol = 1e-16 + @test @inferred(sinc(a)) ≈ (sin(pi * a) / (pi * a)) atol = eps(Float64) @test @inferred(cosc(a)) ≈ ((cos(pi * a) - sin(pi * a) / (pi * a)) / a) atol = 1e-15 if isdefined(Base, :sincos) # Check we got the sign of derivatives in `sincos` right. @@ -332,7 +332,7 @@ end @test c ≈ cos(a) @test s + c ≈ sin(a) + cos(a) @test s - c ≈ sin(a) - cos(a) - @test s ^ 2 + c ^ 2 ≈ one(a) + @test s ^ 2 + c ^ 2 ≈ oneunit(a) end if isdefined(Base, :sincospi) s, c = @inferred(sincospi(a)) @@ -340,7 +340,7 @@ end @test c ≈ cospi(a) @test s + c ≈ sinpi(a) + cospi(a) @test s - c ≈ sinpi(a) - cospi(a) - @test s ^ 2 + c ^ 2 ≈ one(a) + @test s ^ 2 + c ^ 2 ≈ oneunit(a) end end for c in (-1 ± 1, 0 ± 1, 1 ± 1) @@ -408,7 +408,7 @@ end @testset "Exponentials" begin @test @inferred(exp(x)) ≈ measurement(20.085536923187668, 2.008553692318767) for a in (w, 3//5*w, x/10, x, y/50, y) - @test @inferred(expm1(a)) ≈ exp(a) - one(a) + @test @inferred(expm1(a)) ≈ exp(a) - oneunit(a) @test @inferred(exp10(a)) ≈ 10^a @test @inferred(ldexp(frexp(a)...)) ≈ a @test @inferred(log2(exp2(a))) ≈ a @@ -490,7 +490,8 @@ end end @testset "One and zero" begin - @test @inferred(one(y)) ≈ measurement(1) + @test @inferred(one(y)) === 1.0 + @test @inferred(oneunit(y)) ≈ measurement(1) @test @inferred(zero(x)) ≈ measurement(0) end @@ -515,8 +516,8 @@ end @test @inferred(digamma(y)) ≈ 1.256117668431802 ± 0.056764591147422994 @test @inferred(polygamma(3, w)) ≈ 193.40909103400242 ± 0.10422749480000776 for a in (w, x, y) - @test_logs (:warn, r"factorial.*is deprecated") @test @inferred(gamma(a)) ≈ factorial(a - one(a)) - @test @inferred(gamma(a + one(a))) ≈ @test_logs (:warn, r"factorial.*is deprecated") factorial(a) + @test_logs (:warn, r"factorial.*is deprecated") @test @inferred(gamma(a)) ≈ factorial(a - oneunit(a)) + @test @inferred(gamma(a + oneunit(a))) ≈ @test_logs (:warn, r"factorial.*is deprecated") factorial(a) @test @inferred(logabsgamma(abs(a)))[1] ≈ log(gamma(abs(a))) @test @inferred(digamma(a)) ≈ polygamma(0, a) @test @inferred(digamma(invdigamma(a))) ≈ a + zero(a) @@ -731,7 +732,7 @@ end b = @inferred(A \ c) @test @inferred(A * b) ≈ c @test @inferred(b ⋅ c) ≈ 7.020527859237536 ± 0.5707235338984873 - @test @inferred(det(A)) ≈ 682 ± 9.650906693155829 + @test det(A) ≈ 682 ± 9.650906693155829 @test @inferred(A * inv(A)) ≈ I # This matrix `A` has the property that the Inf-norm of `A * inv(A) - I` has # zero value but non-zero uncertainty in Julia v1.9, which would make the @@ -853,7 +854,7 @@ end @test QuadGK.quadgk(sin, -y, y)[1] ≈ cos(-y) - cos(y) atol = 2 * eps(Float64) @test QuadGK.quadgk(exp, 0.4, x)[1] ≈ exp(x) - exp(0.4) @test QuadGK.quadgk(sin, w, 2.7)[1] ≈ cos(w) - cos(2.7) - @test QuadGK.quadgk(t -> cos(x - t), 0, 2pi)[1] ≈ measurement(0) atol = 2e-13 + @test QuadGK.quadgk(t -> cos(x - t), 0, 2pi; atol=eps(Float64))[1] ≈ measurement(0) atol = 5e-16 @test QuadGK.quadgk(t -> exp(t / w), 0, 1)[1] ≈ w * (exp(1 / w) - one(x)) for a in (w, x, y) @test QuadGK.quadgk(t -> 1 / abs2(t / a), 1, Inf)[1] ≈ a ^ 2 @@ -867,8 +868,8 @@ end # Compare some of the above integrals with results with "@uncertain" macro. @test QuadGK.quadgk(cos, x, y)[1] ≈ @uncertain(((x,y) -> QuadGK.quadgk(cos, x, y)[1])(x, y)) - @test QuadGK.quadgk(sin, -y, y)[1] ≈ - @uncertain((x -> QuadGK.quadgk(sin, -x, x)[1])(y)) atol = 5e-10 + @test QuadGK.quadgk(sin, -y, y; atol=eps(Float64))[1] ≈ + @uncertain((x -> QuadGK.quadgk(sin, -x, x; atol=eps(Float64))[1])(y)) atol = 5e-13 @test QuadGK.quadgk(exp, 0.4, x)[1] ≈ @uncertain((x -> QuadGK.quadgk(exp, 0.4, x)[1])(x)) end @@ -929,9 +930,7 @@ end F(x) = x^3 / 3 a = (5 ± 0.1)u"m" b = (10 ± 1)u"m" - # This has been broken by QuadGK v2.6.0: - # . - @test_skip (QuadGK.quadgk(f, a, b)[1]).val ≈ (F(b) - F(a)).val + @test (QuadGK.quadgk(f, a, b)[1]).val ≈ (F(b) - F(a)).val end @testset "Complex measurements" begin