From 89a231f78e100786d7e0bbb81f247d9f056899a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Mandl=C3=ADk?= Date: Sun, 13 Oct 2024 20:13:40 +0200 Subject: [PATCH] fixed doctests --- docs/src/examples/musk/Manifest.toml | 316 ++++++++++++++++--------- src/datanodes/bagnode.jl | 8 +- src/datanodes/datanode.jl | 40 ++-- src/datanodes/lazynode.jl | 4 +- src/datanodes/productnode.jl | 18 +- src/datanodes/weighted_bagnode.jl | 8 +- src/modelnodes/arraymodel.jl | 2 +- src/modelnodes/bagmodel.jl | 14 +- src/modelnodes/lazymodel.jl | 6 +- src/modelnodes/productmodel.jl | 20 +- src/modelnodes/reflectinmodel.jl | 76 +++--- src/show.jl | 10 +- src/special_arrays/maybe_hot_matrix.jl | 6 +- src/special_arrays/special_arrays.jl | 4 +- src/util.jl | 82 +++---- test/hierarchical_utils.jl | 32 +-- test/io.jl | 74 +++--- 17 files changed, 404 insertions(+), 316 deletions(-) diff --git a/docs/src/examples/musk/Manifest.toml b/docs/src/examples/musk/Manifest.toml index 33fd2a3e..67f113db 100644 --- a/docs/src/examples/musk/Manifest.toml +++ b/docs/src/examples/musk/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.10.4" +julia_version = "1.11.0" manifest_format = "2.0" project_hash = "c980577c0415d2c228751f8ca1d6579dbbffa98a" @@ -16,24 +16,28 @@ weakdeps = ["ChainRulesCore", "Test"] AbstractFFTsTestExt = "Test" [[deps.Accessors]] -deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "LinearAlgebra", "MacroTools", "Markdown", "Test"] -git-tree-sha1 = "c0d491ef0b135fd7d63cbc6404286bc633329425" +deps = ["CompositionsBase", "ConstructionBase", "InverseFunctions", "LinearAlgebra", "MacroTools", "Markdown"] +git-tree-sha1 = "b392ede862e506d451fc1616e79aa6f4c673dab8" uuid = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" -version = "0.1.36" +version = "0.1.38" [deps.Accessors.extensions] AccessorsAxisKeysExt = "AxisKeys" + AccessorsDatesExt = "Dates" AccessorsIntervalSetsExt = "IntervalSets" AccessorsStaticArraysExt = "StaticArrays" AccessorsStructArraysExt = "StructArrays" + AccessorsTestExt = "Test" AccessorsUnitfulExt = "Unitful" [deps.Accessors.weakdeps] AxisKeys = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5" + Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" Requires = "ae029012-a4dd-5104-9daa-d747884805df" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" + Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [[deps.Adapt]] @@ -53,10 +57,11 @@ version = "2.3.0" [[deps.ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" -version = "1.1.1" +version = "1.1.2" [[deps.Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" +version = "1.11.0" [[deps.Atomix]] deps = ["UnsafeAtomics"] @@ -65,16 +70,17 @@ uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" version = "0.1.0" [[deps.BangBang]] -deps = ["Compat", "ConstructionBase", "InitialValues", "LinearAlgebra", "Requires", "Setfield", "Tables"] -git-tree-sha1 = "7aa7ad1682f3d5754e3491bb59b8103cae28e3a3" +deps = ["Accessors", "ConstructionBase", "InitialValues", "LinearAlgebra", "Requires"] +git-tree-sha1 = "e2144b631226d9eeab2d746ca8880b7ccff504ae" uuid = "198e06fe-97b7-11e9-32a5-e1d131e6ad66" -version = "0.3.40" +version = "0.4.3" [deps.BangBang.extensions] BangBangChainRulesCoreExt = "ChainRulesCore" BangBangDataFramesExt = "DataFrames" BangBangStaticArraysExt = "StaticArrays" BangBangStructArraysExt = "StructArrays" + BangBangTablesExt = "Tables" BangBangTypedTablesExt = "TypedTables" [deps.BangBang.weakdeps] @@ -82,10 +88,12 @@ version = "0.3.40" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" + Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9" [[deps.Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +version = "1.11.0" [[deps.Baselet]] git-tree-sha1 = "aebf55e6d7795e02ca500a689d326ac979aaf89e" @@ -99,15 +107,15 @@ version = "0.5.0" [[deps.ChainRules]] deps = ["Adapt", "ChainRulesCore", "Compat", "Distributed", "GPUArraysCore", "IrrationalConstants", "LinearAlgebra", "Random", "RealDot", "SparseArrays", "SparseInverseSubset", "Statistics", "StructArrays", "SuiteSparse"] -git-tree-sha1 = "5ec157747036038ec70b250f578362268f0472f1" +git-tree-sha1 = "be227d253d132a6d57f9ccf5f67c0fb6488afd87" uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2" -version = "1.68.0" +version = "1.71.0" [[deps.ChainRulesCore]] deps = ["Compat", "LinearAlgebra"] -git-tree-sha1 = "71acdbf594aab5bbb2cec89b208c41b4c411e49f" +git-tree-sha1 = "3e4b134270b372f2ed4d4d0e936aabaefc1802bc" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "1.24.0" +version = "1.25.0" weakdeps = ["SparseArrays"] [deps.ChainRulesCore.extensions] @@ -119,16 +127,16 @@ uuid = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" version = "1.0.2" [[deps.CommonSubexpressions]] -deps = ["MacroTools", "Test"] -git-tree-sha1 = "7b8a93dba8af7e3b42fecabf646260105ac373f7" +deps = ["MacroTools"] +git-tree-sha1 = "cda2cfaebb4be89c9084adaca7dd7333369715c5" uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" -version = "0.3.0" +version = "0.3.1" [[deps.Compat]] deps = ["TOML", "UUIDs"] -git-tree-sha1 = "b1c55339b7c6c350ee89f2c1604299660525b248" +git-tree-sha1 = "8ae8d32e09f0dcf42a36b90d4e17f5dd2e4c4215" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.15.0" +version = "4.16.0" weakdeps = ["Dates", "LinearAlgebra"] [deps.Compat.extensions] @@ -149,17 +157,18 @@ weakdeps = ["InverseFunctions"] CompositionsBaseInverseFunctionsExt = "InverseFunctions" [[deps.ConstructionBase]] -deps = ["LinearAlgebra"] -git-tree-sha1 = "260fd2400ed2dab602a7c15cf10c1933c59930a2" +git-tree-sha1 = "76219f1ed5771adbb096743bff43fb5fdd4c1157" uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9" -version = "1.5.5" +version = "1.5.8" [deps.ConstructionBase.extensions] ConstructionBaseIntervalSetsExt = "IntervalSets" + ConstructionBaseLinearAlgebraExt = "LinearAlgebra" ConstructionBaseStaticArraysExt = "StaticArrays" [deps.ConstructionBase.weakdeps] IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" + LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [[deps.ContextVariablesX]] @@ -179,10 +188,10 @@ uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" version = "1.16.0" [[deps.DataFrames]] -deps = ["Compat", "DataAPI", "DataStructures", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "REPL", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"] -git-tree-sha1 = "04c738083f29f86e62c8afc341f0967d8717bdb8" +deps = ["Compat", "DataAPI", "DataStructures", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"] +git-tree-sha1 = "fb61b4812c49343d7ef0b533ba982c46021938a6" uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" -version = "1.6.1" +version = "1.7.0" [[deps.DataStructures]] deps = ["Compat", "InteractiveUtils", "OrderedCollections"] @@ -198,6 +207,7 @@ version = "1.0.0" [[deps.Dates]] deps = ["Printf"] uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" +version = "1.11.0" [[deps.DefineSingletons]] git-tree-sha1 = "0fba8b706d0178b4dc7fd44a96a92382c9065c2c" @@ -225,6 +235,7 @@ version = "1.15.1" [[deps.Distributed]] deps = ["Random", "Serialization", "Sockets"] uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" +version = "1.11.0" [[deps.DocStringExtensions]] deps = ["LibGit2"] @@ -239,9 +250,9 @@ version = "1.6.0" [[deps.FLoops]] deps = ["BangBang", "Compat", "FLoopsBase", "InitialValues", "JuliaVariables", "MLStyle", "Serialization", "Setfield", "Transducers"] -git-tree-sha1 = "ffb97765602e3cbe59a0589d237bf07f245a8576" +git-tree-sha1 = "0a2e5873e9a5f54abb06418d57a8df689336a660" uuid = "cc61a311-1640-44b5-9fba-1b764f453329" -version = "0.2.1" +version = "0.2.2" [[deps.FLoopsBase]] deps = ["ContextVariablesX"] @@ -251,18 +262,19 @@ version = "0.1.1" [[deps.FileIO]] deps = ["Pkg", "Requires", "UUIDs"] -git-tree-sha1 = "82d8afa92ecf4b52d78d869f038ebfb881267322" +git-tree-sha1 = "62ca0547a14c57e98154423419d8a342dca75ca9" uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -version = "1.16.3" +version = "1.16.4" [[deps.FileWatching]] uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" +version = "1.11.0" [[deps.FillArrays]] deps = ["LinearAlgebra"] -git-tree-sha1 = "0653c0a2396a6da5bc4766c43041ef5fd3efbe57" +git-tree-sha1 = "6a70198746448456524cb442b8af316927ff3e1a" uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" -version = "1.11.0" +version = "1.13.0" [deps.FillArrays.extensions] FillArraysPDMatsExt = "PDMats" @@ -281,21 +293,27 @@ uuid = "26cc04aa-876d-5657-8c51-4c34ba976000" version = "0.12.32" [[deps.Flux]] -deps = ["Adapt", "ChainRulesCore", "Compat", "Functors", "LinearAlgebra", "MLUtils", "MacroTools", "NNlib", "OneHotArrays", "Optimisers", "Preferences", "ProgressLogging", "Random", "Reexport", "SparseArrays", "SpecialFunctions", "Statistics", "Zygote"] -git-tree-sha1 = "a5475163b611812d073171583982c42ea48d22b0" +deps = ["Adapt", "ChainRulesCore", "Compat", "Functors", "LinearAlgebra", "MLDataDevices", "MLUtils", "MacroTools", "NNlib", "OneHotArrays", "Optimisers", "Preferences", "ProgressLogging", "Random", "Reexport", "Setfield", "SparseArrays", "SpecialFunctions", "Statistics", "Zygote"] +git-tree-sha1 = "37fa32a50c69c10c6ea1465d3054d98c75bd7777" uuid = "587475ba-b771-5e3f-ad9e-33799f191a9c" -version = "0.14.15" +version = "0.14.22" [deps.Flux.extensions] FluxAMDGPUExt = "AMDGPU" FluxCUDAExt = "CUDA" FluxCUDAcuDNNExt = ["CUDA", "cuDNN"] + FluxEnzymeExt = "Enzyme" + FluxMPIExt = "MPI" + FluxMPINCCLExt = ["CUDA", "MPI", "NCCL"] FluxMetalExt = "Metal" [deps.Flux.weakdeps] AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" + MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" Metal = "dde4c033-4e86-420c-a63e-0dd931031962" + NCCL = "3fe64909-d7a1-4096-9b7d-7a0f12cf0f6b" cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" [[deps.ForwardDiff]] @@ -310,19 +328,20 @@ weakdeps = ["StaticArrays"] [[deps.Functors]] deps = ["LinearAlgebra"] -git-tree-sha1 = "8a66c07630d6428eaab3506a0eabfcf4a9edea05" +git-tree-sha1 = "64d8e93700c7a3f28f717d265382d52fac9fa1c1" uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196" -version = "0.4.11" +version = "0.4.12" [[deps.Future]] deps = ["Random"] uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" +version = "1.11.0" [[deps.GPUArrays]] deps = ["Adapt", "GPUArraysCore", "LLVM", "LinearAlgebra", "Printf", "Random", "Reexport", "Serialization", "Statistics"] -git-tree-sha1 = "38cb19b8a3e600e509dc36a6396ac74266d108c1" +git-tree-sha1 = "62ee71528cca49be797076a76bdc654a170a523e" uuid = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" -version = "10.1.1" +version = "10.3.1" [[deps.GPUArraysCore]] deps = ["Adapt"] @@ -332,9 +351,9 @@ version = "0.1.6" [[deps.HierarchicalUtils]] deps = ["DataStructures", "OrderedCollections"] -path = "../../../../../HierarchicalUtils" +git-tree-sha1 = "e557591ce208361842641a35222814c6245b2044" uuid = "f9ccea15-0695-44b9-8113-df7c26ae4fa9" -version = "2.2.2" +version = "2.2.3" [[deps.IRTools]] deps = ["InteractiveUtils", "MacroTools"] @@ -348,24 +367,32 @@ uuid = "22cec73e-a1b8-11e9-2c92-598750a2cf9c" version = "0.3.1" [[deps.InlineStrings]] -deps = ["Parsers"] -git-tree-sha1 = "9cc2baf75c6d09f9da536ddf58eb2f29dedaf461" +git-tree-sha1 = "45521d31238e87ee9f9732561bfee12d4eebd52d" uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48" -version = "1.4.0" +version = "1.4.2" + + [deps.InlineStrings.extensions] + ArrowTypesExt = "ArrowTypes" + ParsersExt = "Parsers" + + [deps.InlineStrings.weakdeps] + ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd" + Parsers = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" [[deps.InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +version = "1.11.0" [[deps.InverseFunctions]] -deps = ["Test"] -git-tree-sha1 = "e7cbed5032c4c397a6ac23d1493f3289e01231c4" +git-tree-sha1 = "a779299d77cd080bf77b97535acecd73e1c5e5cb" uuid = "3587e190-3f89-42d0-90ee-14403ec27112" -version = "0.1.14" -weakdeps = ["Dates"] +version = "0.1.17" +weakdeps = ["Dates", "Test"] [deps.InverseFunctions.extensions] - DatesExt = "Dates" + InverseFunctionsDatesExt = "Dates" + InverseFunctionsTestExt = "Test" [[deps.InvertedIndices]] git-tree-sha1 = "0dc7b50b8d436461be01300fd8cd45aa0274b038" @@ -383,16 +410,16 @@ uuid = "82899510-4779-5014-852e-03e436cf321d" version = "1.0.0" [[deps.JLD2]] -deps = ["FileIO", "MacroTools", "Mmap", "OrderedCollections", "Pkg", "PrecompileTools", "Reexport", "Requires", "TranscodingStreams", "UUIDs", "Unicode"] -git-tree-sha1 = "bdbe8222d2f5703ad6a7019277d149ec6d78c301" +deps = ["FileIO", "MacroTools", "Mmap", "OrderedCollections", "PrecompileTools", "Requires", "TranscodingStreams"] +git-tree-sha1 = "aeab5c68eb2cf326619bf71235d8f4561c62fe22" uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819" -version = "0.4.48" +version = "0.5.5" [[deps.JLLWrappers]] deps = ["Artifacts", "Preferences"] -git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca" +git-tree-sha1 = "be3dc50a92e5a386872a493a10050136d4703f9b" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.5.0" +version = "1.6.1" [[deps.JuliaVariables]] deps = ["MLStyle", "NameResolution"] @@ -401,22 +428,26 @@ uuid = "b14d175d-62b4-44ba-8fb7-3064adc8c3ec" version = "0.2.4" [[deps.KernelAbstractions]] -deps = ["Adapt", "Atomix", "InteractiveUtils", "LinearAlgebra", "MacroTools", "PrecompileTools", "Requires", "SparseArrays", "StaticArrays", "UUIDs", "UnsafeAtomics", "UnsafeAtomicsLLVM"] -git-tree-sha1 = "db02395e4c374030c53dc28f3c1d33dec35f7272" +deps = ["Adapt", "Atomix", "InteractiveUtils", "MacroTools", "PrecompileTools", "Requires", "StaticArrays", "UUIDs", "UnsafeAtomics", "UnsafeAtomicsLLVM"] +git-tree-sha1 = "04e52f596d0871fa3890170fa79cb15e481e4cd8" uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c" -version = "0.9.19" +version = "0.9.28" [deps.KernelAbstractions.extensions] EnzymeExt = "EnzymeCore" + LinearAlgebraExt = "LinearAlgebra" + SparseArraysExt = "SparseArrays" [deps.KernelAbstractions.weakdeps] EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" + LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[deps.LLVM]] deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Preferences", "Printf", "Requires", "Unicode"] -git-tree-sha1 = "9ed3ebaf6bc3db16cf45ce34b968d348fc54d990" +git-tree-sha1 = "4ad43cb0a4bb5e5b1506e1d1f48646d7e0c80363" uuid = "929cbde3-209d-540e-8aea-75f648917ca0" -version = "7.2.0" +version = "9.1.2" [deps.LLVM.extensions] BFloat16sExt = "BFloat16s" @@ -426,9 +457,9 @@ version = "7.2.0" [[deps.LLVMExtra_jll]] deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"] -git-tree-sha1 = "88b916503aac4fb7f701bb625cd84ca5dd1677bc" +git-tree-sha1 = "05a8bd5a42309a9ec82f700876903abce1017dd3" uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab" -version = "0.0.29+0" +version = "0.0.34+0" [[deps.LaTeXStrings]] git-tree-sha1 = "50901ebc375ed41dbf8058da26f9de442febbbec" @@ -438,6 +469,7 @@ version = "1.3.1" [[deps.LazyArtifacts]] deps = ["Artifacts", "Pkg"] uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" +version = "1.11.0" [[deps.LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] @@ -447,16 +479,17 @@ version = "0.6.4" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "8.4.0+0" +version = "8.6.0+0" [[deps.LibGit2]] deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +version = "1.11.0" [[deps.LibGit2_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" -version = "1.6.4+0" +version = "1.7.2+0" [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] @@ -465,10 +498,12 @@ version = "1.11.0+1" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +version = "1.11.0" [[deps.LinearAlgebra]] deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +version = "1.11.0" [[deps.LogExpFunctions]] deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"] @@ -488,6 +523,47 @@ version = "0.3.28" [[deps.Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" +version = "1.11.0" + +[[deps.MLDataDevices]] +deps = ["Adapt", "Functors", "Preferences", "Random"] +git-tree-sha1 = "e16288e37e76d68c3f1c418e0a2bec88d98d55fc" +uuid = "7e8f7934-dd98-4c1a-8fe8-92b47a384d40" +version = "1.2.0" + + [deps.MLDataDevices.extensions] + MLDataDevicesAMDGPUExt = "AMDGPU" + MLDataDevicesCUDAExt = "CUDA" + MLDataDevicesChainRulesCoreExt = "ChainRulesCore" + MLDataDevicesFillArraysExt = "FillArrays" + MLDataDevicesGPUArraysExt = "GPUArrays" + MLDataDevicesMLUtilsExt = "MLUtils" + MLDataDevicesMetalExt = ["GPUArrays", "Metal"] + MLDataDevicesReactantExt = "Reactant" + MLDataDevicesRecursiveArrayToolsExt = "RecursiveArrayTools" + MLDataDevicesReverseDiffExt = "ReverseDiff" + MLDataDevicesSparseArraysExt = "SparseArrays" + MLDataDevicesTrackerExt = "Tracker" + MLDataDevicesZygoteExt = "Zygote" + MLDataDevicescuDNNExt = ["CUDA", "cuDNN"] + MLDataDevicesoneAPIExt = ["GPUArrays", "oneAPI"] + + [deps.MLDataDevices.weakdeps] + AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" + GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" + MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54" + Metal = "dde4c033-4e86-420c-a63e-0dd931031962" + Reactant = "3c362404-f566-11ee-1572-e11a4b42c853" + RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" + cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" + oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" [[deps.MLStyle]] git-tree-sha1 = "bc38dff0548128765760c79eb7388a4b37fae2c8" @@ -509,20 +585,21 @@ version = "0.5.13" [[deps.Markdown]] deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +version = "1.11.0" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.2+1" +version = "2.28.6+0" [[deps.MicroCollections]] -deps = ["BangBang", "InitialValues", "Setfield"] -git-tree-sha1 = "629afd7d10dbc6935ec59b32daeb33bc4460a42e" +deps = ["Accessors", "BangBang", "InitialValues"] +git-tree-sha1 = "44d32db644e84c75dab479f1bc15ee76a1a3618f" uuid = "128add7d-3638-4c79-886c-908ea0c25c34" -version = "0.1.4" +version = "0.2.0" [[deps.Mill]] -deps = ["Accessors", "ChainRulesCore", "Combinatorics", "DataFrames", "DataStructures", "FiniteDifferences", "Flux", "HierarchicalUtils", "LinearAlgebra", "MLUtils", "MacroTools", "OneHotArrays", "PooledArrays", "Preferences", "SparseArrays", "Statistics", "Test"] +deps = ["Accessors", "ChainRulesCore", "Combinatorics", "Compat", "DataFrames", "DataStructures", "FiniteDifferences", "Flux", "HierarchicalUtils", "LinearAlgebra", "MLUtils", "MacroTools", "OneHotArrays", "PooledArrays", "Preferences", "SparseArrays", "Statistics", "Test"] path = "../../../.." uuid = "1d0525e4-8992-11e8-313c-e310e1f6ddea" version = "2.10.5" @@ -535,27 +612,32 @@ version = "1.2.0" [[deps.Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" +version = "1.11.0" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2023.1.10" +version = "2023.12.12" [[deps.NNlib]] -deps = ["Adapt", "Atomix", "ChainRulesCore", "GPUArraysCore", "KernelAbstractions", "LinearAlgebra", "Pkg", "Random", "Requires", "Statistics"] -git-tree-sha1 = "3d4617f943afe6410206a5294a95948c8d1b35bd" +deps = ["Adapt", "Atomix", "ChainRulesCore", "GPUArraysCore", "KernelAbstractions", "LinearAlgebra", "Random", "Statistics"] +git-tree-sha1 = "da09a1e112fd75f9af2a5229323f01b56ec96a4c" uuid = "872c559c-99b0-510c-b3b7-b6c96a88d5cd" -version = "0.9.17" +version = "0.9.24" [deps.NNlib.extensions] NNlibAMDGPUExt = "AMDGPU" NNlibCUDACUDNNExt = ["CUDA", "cuDNN"] NNlibCUDAExt = "CUDA" NNlibEnzymeCoreExt = "EnzymeCore" + NNlibFFTWExt = "FFTW" + NNlibForwardDiffExt = "ForwardDiff" [deps.NNlib.weakdeps] AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" + FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" [[deps.NaNMath]] @@ -583,7 +665,7 @@ version = "0.2.5" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.23+4" +version = "0.3.27+1" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] @@ -607,16 +689,16 @@ git-tree-sha1 = "dfdf5519f235516220579f949664f1bf44e741c5" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" version = "1.6.3" -[[deps.Parsers]] -deps = ["Dates", "PrecompileTools", "UUIDs"] -git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821" -uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "2.8.1" - [[deps.Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.10.0" +version = "1.11.0" + + [deps.Pkg.extensions] + REPLExt = "REPL" + + [deps.Pkg.weakdeps] + REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" [[deps.PooledArrays]] deps = ["DataAPI", "Future"] @@ -643,13 +725,14 @@ version = "0.2.0" [[deps.PrettyTables]] deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "Reexport", "StringManipulation", "Tables"] -git-tree-sha1 = "66b20dd35966a748321d3b2537c4584cf40387c7" +git-tree-sha1 = "1101cd475833706e4d0e7b122218257178f48f34" uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" -version = "2.3.2" +version = "2.4.0" [[deps.Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" +version = "1.11.0" [[deps.ProgressLogging]] deps = ["Logging", "SHA", "UUIDs"] @@ -657,13 +740,10 @@ git-tree-sha1 = "80d919dee55b9c50e8d9e2da5eeafff3fe58b539" uuid = "33c8b6b6-d38a-422a-b730-caa89a2f386c" version = "0.1.4" -[[deps.REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] -uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" - [[deps.Random]] deps = ["SHA"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +version = "1.11.0" [[deps.RealDot]] deps = ["LinearAlgebra"] @@ -694,12 +774,13 @@ version = "0.7.0" [[deps.SentinelArrays]] deps = ["Dates", "Random"] -git-tree-sha1 = "90b4f68892337554d31cdcdbe19e48989f26c7e6" +git-tree-sha1 = "ff11acffdb082493657550959d4feb4b6149e73a" uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c" -version = "1.4.3" +version = "1.4.5" [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" +version = "1.11.0" [[deps.Setfield]] deps = ["ConstructionBase", "Future", "MacroTools", "StaticArraysCore"] @@ -720,6 +801,7 @@ version = "0.9.4" [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" +version = "1.11.0" [[deps.SortingAlgorithms]] deps = ["DataStructures"] @@ -730,7 +812,7 @@ version = "1.2.1" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -version = "1.10.0" +version = "1.11.0" [[deps.SparseInverseSubset]] deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"] @@ -756,9 +838,9 @@ version = "0.1.15" [[deps.StaticArrays]] deps = ["LinearAlgebra", "PrecompileTools", "Random", "StaticArraysCore"] -git-tree-sha1 = "9ae599cd7529cfce7fea36cf00a62cfc56f0f37c" +git-tree-sha1 = "eeafab08ae20c62c44c8399ccb9354a04b80db50" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "1.9.4" +version = "1.9.7" weakdeps = ["ChainRulesCore", "Statistics"] [deps.StaticArrays.extensions] @@ -766,14 +848,19 @@ weakdeps = ["ChainRulesCore", "Statistics"] StaticArraysStatisticsExt = "Statistics" [[deps.StaticArraysCore]] -git-tree-sha1 = "36b3d696ce6366023a0ea192b4cd442268995a0d" +git-tree-sha1 = "192954ef1208c7019899fbf8049e717f92959682" uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" -version = "1.4.2" +version = "1.4.3" [[deps.Statistics]] -deps = ["LinearAlgebra", "SparseArrays"] +deps = ["LinearAlgebra"] +git-tree-sha1 = "ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0" uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -version = "1.10.0" +version = "1.11.1" +weakdeps = ["SparseArrays"] + + [deps.Statistics.extensions] + SparseArraysExt = ["SparseArrays"] [[deps.StatsAPI]] deps = ["LinearAlgebra"] @@ -789,9 +876,9 @@ version = "0.34.3" [[deps.StringManipulation]] deps = ["PrecompileTools"] -git-tree-sha1 = "a04cabe79c5f01f4d723cc6704070ada0b9d46d5" +git-tree-sha1 = "a6b1675a536c5ad1a60e5a5153e1fee12eb146e3" uuid = "892a3eda-7b42-436c-8928-eab12a02cf0e" -version = "0.3.4" +version = "0.4.0" [[deps.StructArrays]] deps = ["ConstructionBase", "DataAPI", "Tables"] @@ -813,7 +900,7 @@ uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" [[deps.SuiteSparse_jll]] deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" -version = "7.2.1+1" +version = "7.7.0+0" [[deps.TOML]] deps = ["Dates"] @@ -827,10 +914,10 @@ uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" version = "1.0.1" [[deps.Tables]] -deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits"] -git-tree-sha1 = "cb76cf677714c095e535e3501ac7954732aeea2d" +deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "OrderedCollections", "TableTraits"] +git-tree-sha1 = "598cd7c1f68d1e205689b1c2fe65a9f85846f297" uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" -version = "1.11.1" +version = "1.12.0" [[deps.Tar]] deps = ["ArgTools", "SHA"] @@ -840,23 +927,21 @@ version = "1.10.0" [[deps.Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +version = "1.11.0" [[deps.TranscodingStreams]] -git-tree-sha1 = "a947ea21087caba0a798c5e494d0bb78e3a1a3a0" +git-tree-sha1 = "0c45878dcfdcfa8480052b6ab162cdd138781742" uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" -version = "0.10.9" -weakdeps = ["Random", "Test"] - - [deps.TranscodingStreams.extensions] - TestExt = ["Test", "Random"] +version = "0.11.3" [[deps.Transducers]] -deps = ["Adapt", "ArgCheck", "BangBang", "Baselet", "CompositionsBase", "ConstructionBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "Setfield", "SplittablesBase", "Tables"] -git-tree-sha1 = "3064e780dbb8a9296ebb3af8f440f787bb5332af" +deps = ["Accessors", "ArgCheck", "BangBang", "Baselet", "CompositionsBase", "ConstructionBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "SplittablesBase", "Tables"] +git-tree-sha1 = "7deeab4ff96b85c5f72c824cae53a1398da3d1cb" uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999" -version = "0.4.80" +version = "0.4.84" [deps.Transducers.extensions] + TransducersAdaptExt = "Adapt" TransducersBlockArraysExt = "BlockArrays" TransducersDataFramesExt = "DataFrames" TransducersLazyArraysExt = "LazyArrays" @@ -864,6 +949,7 @@ version = "0.4.80" TransducersReferenceablesExt = "Referenceables" [deps.Transducers.weakdeps] + Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02" @@ -873,9 +959,11 @@ version = "0.4.80" [[deps.UUIDs]] deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +version = "1.11.0" [[deps.Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +version = "1.11.0" [[deps.UnsafeAtomics]] git-tree-sha1 = "6331ac3440856ea1988316b46045303bef658278" @@ -884,9 +972,9 @@ version = "0.2.1" [[deps.UnsafeAtomicsLLVM]] deps = ["LLVM", "UnsafeAtomics"] -git-tree-sha1 = "d9f5962fecd5ccece07db1ff006fb0b5271bdfdd" +git-tree-sha1 = "2d17fabcd17e67d7625ce9c531fb9f40b7c42ce4" uuid = "d80eeb9a-aca5-4d75-85e5-170c8b632249" -version = "0.1.4" +version = "0.2.1" [[deps.Zlib_jll]] deps = ["Libdl"] @@ -895,9 +983,9 @@ version = "1.2.13+1" [[deps.Zygote]] deps = ["AbstractFFTs", "ChainRules", "ChainRulesCore", "DiffRules", "Distributed", "FillArrays", "ForwardDiff", "GPUArrays", "GPUArraysCore", "IRTools", "InteractiveUtils", "LinearAlgebra", "LogExpFunctions", "MacroTools", "NaNMath", "PrecompileTools", "Random", "Requires", "SparseArrays", "SpecialFunctions", "Statistics", "ZygoteRules"] -git-tree-sha1 = "19c586905e78a26f7e4e97f81716057bd6b1bc54" +git-tree-sha1 = "f2f85ad73ca67b5d3c94239b0fde005e0fe2d900" uuid = "e88e6eb3-aa80-5325-afca-941959d7151f" -version = "0.6.70" +version = "0.6.71" [deps.Zygote.extensions] ZygoteColorsExt = "Colors" @@ -918,12 +1006,12 @@ version = "0.2.5" [[deps.libblastrampoline_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.8.0+1" +version = "5.11.0+0" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.52.0+1" +version = "1.59.0+0" [[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] diff --git a/src/datanodes/bagnode.jl b/src/datanodes/bagnode.jl index 6f3d8909..1020ea50 100644 --- a/src/datanodes/bagnode.jl +++ b/src/datanodes/bagnode.jl @@ -34,12 +34,12 @@ If `b` is an `AbstractVector`, [`Mill.bags`](@ref) is applied first. # Examples ```jldoctest julia> BagNode(ArrayNode(maybehotbatch([1, missing, 2], 1:2)), AlignedBags([1:1, 2:3])) -BagNode 2 obs, 104 bytes - ╰── ArrayNode(2×3 MaybeHotMatrix with Union{Missing, Bool} elements) 3 obs, 87 bytes +BagNode 2 obs, 80 bytes + ╰── ArrayNode(2×3 MaybeHotMatrix with Union{Missing, Bool} elements) 3 obs, 74 bytes julia> BagNode(randn(2, 5), [1, 2, 2, 1, 1]) -BagNode 2 obs, 200 bytes - ╰── ArrayNode(2×5 Array with Float64 elements) 5 obs, 128 bytes +BagNode 2 obs, 272 bytes + ╰── ArrayNode(2×5 Array with Float64 elements) 5 obs, 136 bytes ``` See also: [`WeightedBagNode`](@ref), [`AbstractBagNode`](@ref), diff --git a/src/datanodes/datanode.jl b/src/datanodes/datanode.jl index 72356b81..f4ba96f1 100644 --- a/src/datanodes/datanode.jl +++ b/src/datanodes/datanode.jl @@ -77,16 +77,16 @@ julia> catobs(ArrayNode(zeros(2, 2)), ArrayNode([1 2; 3 4])) 0.0 0.0 3.0 4.0 julia> n = ProductNode(t1=ArrayNode(randn(2, 3)), t2=BagNode(ArrayNode(randn(3, 8)), bags([1:3, 4:5, 6:8]))) -ProductNode 3 obs, 24 bytes - ├── t1: ArrayNode(2×3 Array with Float64 elements) 3 obs, 96 bytes - ╰── t2: BagNode 3 obs, 112 bytes - ╰── ArrayNode(3×8 Array with Float64 elements) 8 obs, 240 bytes +ProductNode 3 obs, 0 bytes + ├── t1: ArrayNode(2×3 Array with Float64 elements) 3 obs, 104 bytes + ╰── t2: BagNode 3 obs, 96 bytes + ╰── ArrayNode(3×8 Array with Float64 elements) 8 obs, 248 bytes julia> catobs(n[1], n[3]) -ProductNode 2 obs, 24 bytes - ├── t1: ArrayNode(2×2 Array with Float64 elements) 2 obs, 80 bytes - ╰── t2: BagNode 2 obs, 96 bytes - ╰── ArrayNode(3×6 Array with Float64 elements) 6 obs, 192 bytes +ProductNode 2 obs, 0 bytes + ├── t1: ArrayNode(2×2 Array with Float64 elements) 2 obs, 88 bytes + ╰── t2: BagNode 2 obs, 80 bytes + ╰── ArrayNode(3×6 Array with Float64 elements) 6 obs, 200 bytes ``` See also: [`Mill.subset`](@ref). @@ -107,8 +107,8 @@ julia> Mill.subset(ArrayNode(NGramMatrix(["Hello", "world"])), 2) "world" julia> Mill.subset(BagNode(ArrayNode(randn(2, 8)), [1:2, 3:3, 4:7, 8:8]), 1:3) -BagNode 3 obs, 112 bytes - ╰── ArrayNode(2×7 Array with Float64 elements) 7 obs, 160 bytes +BagNode 3 obs, 96 bytes + ╰── ArrayNode(2×7 Array with Float64 elements) 7 obs, 168 bytes ``` See also: [`catobs`](@ref). @@ -123,12 +123,12 @@ Remove instances from `n` using `mask` and remap bag indices accordingly. # Examples ```jldoctest julia> b1 = BagNode(ArrayNode([1 2 3; 4 5 6]), bags([1:2, 0:-1, 3:3])) -BagNode 3 obs, 112 bytes - ╰── ArrayNode(2×3 Array with Int64 elements) 3 obs, 96 bytes +BagNode 3 obs, 96 bytes + ╰── ArrayNode(2×3 Array with Int64 elements) 3 obs, 104 bytes julia> b2 = removeinstances(b1, [false, true, true]) -BagNode 3 obs, 112 bytes - ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes +BagNode 3 obs, 96 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes julia> b2.data 2×2 ArrayNode{Matrix{Int64}, Nothing}: @@ -174,14 +174,14 @@ Recursively apply `f` to data in all leaves of `x`. # Examples ```jldoctest julia> n1 = ProductNode(a=zeros(2,2), b=ones(2,2)) -ProductNode 2 obs, 16 bytes - ├── a: ArrayNode(2×2 Array with Float64 elements) 2 obs, 80 bytes - ╰── b: ArrayNode(2×2 Array with Float64 elements) 2 obs, 80 bytes +ProductNode 2 obs, 0 bytes + ├── a: ArrayNode(2×2 Array with Float64 elements) 2 obs, 88 bytes + ╰── b: ArrayNode(2×2 Array with Float64 elements) 2 obs, 88 bytes julia> n2 = Mill.mapdata(x -> x .+ 1, n1) -ProductNode 2 obs, 16 bytes - ├── a: ArrayNode(2×2 Array with Float64 elements) 2 obs, 80 bytes - ╰── b: ArrayNode(2×2 Array with Float64 elements) 2 obs, 80 bytes +ProductNode 2 obs, 0 bytes + ├── a: ArrayNode(2×2 Array with Float64 elements) 2 obs, 88 bytes + ╰── b: ArrayNode(2×2 Array with Float64 elements) 2 obs, 88 bytes julia> Mill.data(n2).a 2×2 ArrayNode{Matrix{Float64}, Nothing}: diff --git a/src/datanodes/lazynode.jl b/src/datanodes/lazynode.jl index 35876e9a..c7d650d3 100644 --- a/src/datanodes/lazynode.jl +++ b/src/datanodes/lazynode.jl @@ -51,8 +51,8 @@ end; ```jldoctest julia> LazyNode{:Sentence}(["foo bar", "baz"]) |> Mill.unpack2mill -BagNode 2 obs, 120 bytes - ╰── ArrayNode(2053×3 NGramMatrix with Int64 elements) 3 obs, 274 bytes +BagNode 2 obs, 80 bytes + ╰── ArrayNode(2053×3 NGramMatrix with Int64 elements) 3 obs, 170 bytes ``` See also: [`LazyNode`](@ref), [`LazyModel`](@ref). diff --git a/src/datanodes/productnode.jl b/src/datanodes/productnode.jl index 035059ab..12803a2c 100644 --- a/src/datanodes/productnode.jl +++ b/src/datanodes/productnode.jl @@ -34,20 +34,20 @@ an [`ArrayNode`](@ref). # Examples ```jldoctest julia> ProductNode((ArrayNode(zeros(2, 2)), ArrayNode(Flux.onehotbatch([1, 2], 1:2)))) -ProductNode 2 obs, 24 bytes - ├── ArrayNode(2×2 Array with Float64 elements) 2 obs, 80 bytes - ╰── ArrayNode(2×2 OneHotArray with Bool elements) 2 obs, 80 bytes +ProductNode 2 obs, 0 bytes + ├── ArrayNode(2×2 Array with Float64 elements) 2 obs, 88 bytes + ╰── ArrayNode(2×2 OneHotArray with Bool elements) 2 obs, 64 bytes julia> ProductNode(x1 = ArrayNode(NGramMatrix(["Hello", "world"])), x2 = BagNode(ArrayNode([1 2; 3 4]), [1:2, 0:-1])) -ProductNode 2 obs, 48 bytes - ├── x1: ArrayNode(2053×2 NGramMatrix with Int64 elements) 2 obs, 146 bytes - ╰── x2: BagNode 2 obs, 96 bytes - ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes +ProductNode 2 obs, 0 bytes + ├── x1: ArrayNode(2053×2 NGramMatrix with Int64 elements) 2 obs, 114 bytes + ╰── x2: BagNode 2 obs, 80 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes julia> ProductNode([1 2 3]) -ProductNode 3 obs, 8 bytes - ╰── ArrayNode(1×3 Array with Int64 elements) 3 obs, 72 bytes +ProductNode 3 obs, 0 bytes + ╰── ArrayNode(1×3 Array with Int64 elements) 3 obs, 80 bytes julia> ProductNode((ArrayNode([1 2; 3 4]), ArrayNode([1 2 3; 4 5 6]))) ERROR: AssertionError: All subtrees must have an equal amount of instances! diff --git a/src/datanodes/weighted_bagnode.jl b/src/datanodes/weighted_bagnode.jl index e096a2ab..f818119c 100644 --- a/src/datanodes/weighted_bagnode.jl +++ b/src/datanodes/weighted_bagnode.jl @@ -32,12 +32,12 @@ If `b` is an `AbstractVector`, [`Mill.bags`](@ref) is applied first. # Examples ```jldoctest julia> WeightedBagNode(ArrayNode(NGramMatrix(["s1", "s2"])), bags([1:2, 0:-1]), [0.2, 0.8]) -WeightedBagNode 2 obs, 184 bytes - ╰── ArrayNode(2053×2 NGramMatrix with Int64 elements) 2 obs, 140 bytes +WeightedBagNode 2 obs, 144 bytes + ╰── ArrayNode(2053×2 NGramMatrix with Int64 elements) 2 obs, 108 bytes julia> WeightedBagNode(zeros(2, 2), [1, 2], [1, 2]) -WeightedBagNode 2 obs, 160 bytes - ╰── ArrayNode(2×2 Array with Float64 elements) 2 obs, 80 bytes +WeightedBagNode 2 obs, 240 bytes + ╰── ArrayNode(2×2 Array with Float64 elements) 2 obs, 88 bytes ``` See also: [`BagNode`](@ref), [`AbstractBagNode`](@ref), [`AbstractMillNode`](@ref), [`BagModel`](@ref). diff --git a/src/modelnodes/arraymodel.jl b/src/modelnodes/arraymodel.jl index a264c1ff..e754b7e5 100644 --- a/src/modelnodes/arraymodel.jl +++ b/src/modelnodes/arraymodel.jl @@ -18,7 +18,7 @@ julia> n = ArrayNode(randn(Float32, 2, 2)) ```jldoctest array_model julia> m = ArrayModel(Dense(2, 2)) -ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 104 bytes +ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 112 bytes ``` ```jldoctest array_model; filter=$DOCTEST_FILTER diff --git a/src/modelnodes/bagmodel.jl b/src/modelnodes/bagmodel.jl index f202a02f..d0ed907e 100644 --- a/src/modelnodes/bagmodel.jl +++ b/src/modelnodes/bagmodel.jl @@ -11,12 +11,12 @@ model `bm` on the aggregated representation of every bag in the data node. julia> Random.seed!(0); julia> n = BagNode(ArrayNode(randn(Float32, 3, 2)), bags([0:-1, 1:2])) -BagNode 2 obs, 96 bytes - ╰── ArrayNode(3×2 Array with Float32 elements) 2 obs, 72 bytes +BagNode 2 obs, 80 bytes + ╰── ArrayNode(3×2 Array with Float32 elements) 2 obs, 80 bytes julia> m = BagModel(ArrayModel(Dense(3, 2)), SegmentedMeanMax(2), Dense(4, 2)) -BagModel ↦ [SegmentedMean(2); SegmentedMax(2)] ↦ Dense(4 => 2) 4 arrays, 14 params, 216 bytes - ╰── ArrayModel(Dense(3 => 2)) 2 arrays, 8 params, 112 bytes +BagModel ↦ [SegmentedMean(2); SegmentedMax(2)] ↦ Dense(4 => 2) 4 arrays, 14 params, 224 bytes + ╰── ArrayModel(Dense(3 => 2)) 2 arrays, 8 params, 120 bytes julia> m(n) 2×2 Matrix{Float32}: @@ -51,12 +51,12 @@ it is wrapped into an [`ArrayNode`](@ref). # Examples ```jldoctest julia> m = BagModel(ArrayModel(Dense(3, 2)), SegmentedMeanMax(2), Dense(4, 2)) -BagModel ↦ [SegmentedMean(2); SegmentedMax(2)] ↦ Dense(4 => 2) 4 arrays, 14 params, 216 bytes - ╰── ArrayModel(Dense(3 => 2)) 2 arrays, 8 params, 112 bytes +BagModel ↦ [SegmentedMean(2); SegmentedMax(2)] ↦ Dense(4 => 2) 4 arrays, 14 params, 224 bytes + ╰── ArrayModel(Dense(3 => 2)) 2 arrays, 8 params, 120 bytes julia> m = BagModel(Dense(4, 3), BagCount(SegmentedMean(3))) BagModel ↦ BagCount(SegmentedMean(3)) ↦ identity 1 arrays, 3 params (all zero), 52 bytes - ╰── ArrayModel(Dense(4 => 3)) 2 arrays, 15 params, 140 bytes + ╰── ArrayModel(Dense(4 => 3)) 2 arrays, 15 params, 148 bytes ``` See also: [`AbstractMillModel`](@ref), [`AbstractAggregation`](@ref), [`BagCount`](@ref), diff --git a/src/modelnodes/lazymodel.jl b/src/modelnodes/lazymodel.jl index 78b2cf84..cfe2f3e3 100644 --- a/src/modelnodes/lazymodel.jl +++ b/src/modelnodes/lazymodel.jl @@ -25,7 +25,7 @@ LazyNode{:Sentence, Vector{String}, Nothing}: julia> m = LazyModel{:Sentence}(BagModel(Dense(2053, 3), SegmentedMean(3), identity)) LazyModel{Sentence} ╰── BagModel ↦ SegmentedMean(3) ↦ identity 1 arrays, 3 params (all zero), 52 bytes - ╰── ArrayModel(Dense(2053 => 3)) 2 arrays, 6_162 params, 24.148 KiB + ╰── ArrayModel(Dense(2053 => 3)) 2 arrays, 6_162 params, 24.156 KiB ``` ```jldoctest unpack2mill; filter=$DOCTEST_FILTER @@ -60,11 +60,11 @@ it is wrapped into an [`ArrayNode`](@ref). ```jldoctest julia> LazyModel{:Sentence}(ArrayModel(Dense(2, 2))) LazyModel{Sentence} - ╰── ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 104 bytes + ╰── ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 112 bytes julia> LazyModel(:Sentence, Dense(2, 2)) LazyModel{Sentence} - ╰── ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 104 bytes + ╰── ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 112 bytes ``` See also: [`AbstractMillModel`](@ref), [`LazyNode`](@ref), [`Mill.unpack2mill`](@ref). diff --git a/src/modelnodes/productmodel.jl b/src/modelnodes/productmodel.jl index 7986d2df..8d8487ee 100644 --- a/src/modelnodes/productmodel.jl +++ b/src/modelnodes/productmodel.jl @@ -9,14 +9,14 @@ A model node for processing [`ProductNode`](@ref)s. For each subtree of the data julia> Random.seed!(0); julia> n = ProductNode(a=ArrayNode([0 1; 2 3]), b=ArrayNode([4 5; 6 7])) -ProductNode 2 obs, 16 bytes - ├── a: ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes - ╰── b: ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes +ProductNode 2 obs, 0 bytes + ├── a: ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes + ╰── b: ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes julia> m1 = ProductModel(a=ArrayModel(Dense(2, 2)), b=ArrayModel(Dense(2, 2))) ProductModel ↦ identity - ├── a: ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 104 bytes - ╰── b: ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 104 bytes + ├── a: ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 112 bytes + ╰── b: ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 112 bytes ``` ```jldoctest product_model; filter=$DOCTEST_FILTER @@ -70,19 +70,19 @@ an [`ArrayNode`](@ref). ```jldoctest julia> ProductModel(a=ArrayModel(Dense(2, 2)), b=identity) ProductModel ↦ identity - ├── a: ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 104 bytes + ├── a: ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 112 bytes ╰── b: ArrayModel(identity) julia> ProductModel(Dense(4, 2); a=ArrayModel(Dense(2, 2)), b=Dense(2, 2)) -ProductModel ↦ Dense(4 => 2) 2 arrays, 10 params, 120 bytes - ├── a: ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 104 bytes - ╰── b: ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 104 bytes +ProductModel ↦ Dense(4 => 2) 2 arrays, 10 params, 128 bytes + ├── a: ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 112 bytes + ╰── b: ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 112 bytes julia> ProductModel((identity, BagModel(ArrayModel(Dense(2, 2)), SegmentedMean(2), identity))) ProductModel ↦ identity ├── ArrayModel(identity) ╰── BagModel ↦ SegmentedMean(2) ↦ identity 1 arrays, 2 params (all zero), 48 bytes - ╰── ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 104 bytes + ╰── ArrayModel(Dense(2 => 2)) 2 arrays, 6 params, 112 bytes julia> ProductModel(identity) ProductModel ↦ identity diff --git a/src/modelnodes/reflectinmodel.jl b/src/modelnodes/reflectinmodel.jl index 03e40abb..d4822559 100644 --- a/src/modelnodes/reflectinmodel.jl +++ b/src/modelnodes/reflectinmodel.jl @@ -33,63 +33,63 @@ layers in these types are replaced by their imputing variants. # Examples ```jldoctest julia> n1 = ProductNode(a=ArrayNode(NGramMatrix(["a", missing]))) -ProductNode 2 obs, 32 bytes - ╰── a: ArrayNode(2053×2 NGramMatrix with Union{Missing, Int64} elements) 2 obs, 129 bytes +ProductNode 2 obs, 0 bytes + ╰── a: ArrayNode(2053×2 NGramMatrix with Union{Missing, Int64} elements) 2 obs, 97 bytes julia> n2 = ProductNode((ArrayNode([0 1]), BagNode(ArrayNode([0 1; 2 3]), bags([1:1, 2:2])))) -ProductNode 2 obs, 24 bytes - ├── ArrayNode(1×2 Array with Int64 elements) 2 obs, 64 bytes - ╰── BagNode 2 obs, 96 bytes - ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes +ProductNode 2 obs, 0 bytes + ├── ArrayNode(1×2 Array with Int64 elements) 2 obs, 72 bytes + ╰── BagNode 2 obs, 80 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes julia> n = ProductNode((n1, n2)) -ProductNode 2 obs, 56 bytes - ├── ProductNode 2 obs, 32 bytes - │ ╰── a: ArrayNode(2053×2 NGramMatrix with Union{Missing, Int64} elements) 2 obs, 129 bytes - ╰── ProductNode 2 obs, 24 bytes - ├── ArrayNode(1×2 Array with Int64 elements) 2 obs, 64 bytes - ╰── BagNode 2 obs, 96 bytes - ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes +ProductNode 2 obs, 0 bytes + ├── ProductNode 2 obs, 0 bytes + │ ╰── a: ArrayNode(2053×2 NGramMatrix with Union{Missing, Int64} elements) 2 obs, 97 bytes + ╰── ProductNode 2 obs, 0 bytes + ├── ArrayNode(1×2 Array with Int64 elements) 2 obs, 72 bytes + ╰── BagNode 2 obs, 80 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes julia> reflectinmodel(n) -ProductModel ↦ Dense(20 => 10) 2 arrays, 210 params, 920 bytes +ProductModel ↦ Dense(20 => 10) 2 arrays, 210 params, 928 bytes ├── ProductModel ↦ identity - │ ╰── a: ArrayModel([postimputing]Dense(2053 => 10)) 3 arrays, 20_550 params, 80.391 KiB - ╰── ProductModel ↦ Dense(11 => 10) 2 arrays, 120 params, 560 bytes + │ ╰── a: ArrayModel([postimputing]Dense(2053 => 10)) 3 arrays, 20_550 params, 80.398 KiB + ╰── ProductModel ↦ Dense(11 => 10) 2 arrays, 120 params, 568 bytes ├── ArrayModel(identity) - ╰── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) 4 arrays, 240 params, 1.094 KiB - ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 200 bytes + ╰── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) 4 arrays, 240 params, 1.102 KiB + ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 208 bytes julia> reflectinmodel(n, d -> Dense(d, 3), SegmentedMean, all_imputing=true) -ProductModel ↦ Dense(6 => 3) 2 arrays, 21 params, 164 bytes +ProductModel ↦ Dense(6 => 3) 2 arrays, 21 params, 172 bytes ├── ProductModel ↦ identity - │ ╰── a: ArrayModel([postimputing]Dense(2053 => 3)) 3 arrays, 6_165 params, 24.199 KiB - ╰── ProductModel ↦ Dense(4 => 3) 2 arrays, 15 params, 140 bytes - ├── ArrayModel([preimputing]Dense(1 => 1)) 3 arrays, 3 params, 132 bytes - ╰── BagModel ↦ SegmentedMean(3) ↦ Dense(3 => 3) 3 arrays, 15 params, 180 bytes - ╰── ArrayModel([preimputing]Dense(2 => 3)) 3 arrays, 11 params, 164 bytes + │ ╰── a: ArrayModel([postimputing]Dense(2053 => 3)) 3 arrays, 6_165 params, 24.207 KiB + ╰── ProductModel ↦ Dense(4 => 3) 2 arrays, 15 params, 148 bytes + ├── ArrayModel([preimputing]Dense(1 => 1)) 3 arrays, 3 params, 140 bytes + ╰── BagModel ↦ SegmentedMean(3) ↦ Dense(3 => 3) 3 arrays, 15 params, 188 bytes + ╰── ArrayModel([preimputing]Dense(2 => 3)) 3 arrays, 11 params, 172 bytes julia> printtree(n; trav=true) -ProductNode [""] 2 obs, 56 bytes - ├── ProductNode ["E"] 2 obs, 32 bytes - │ ╰── a: ArrayNode(2053×2 NGramMatrix with Union{Missing, Int64} elements) ["M"] 2 obs, 129 bytes - ╰── ProductNode ["U"] 2 obs, 24 bytes - ├── ArrayNode(1×2 Array with Int64 elements) ["Y"] 2 obs, 64 bytes - ╰── BagNode ["c"] 2 obs, 96 bytes - ╰── ArrayNode(2×2 Array with Int64 elements) ["e"] 2 obs, 80 bytes +ProductNode [""] 2 obs, 0 bytes + ├── ProductNode ["E"] 2 obs, 0 bytes + │ ╰── a: ArrayNode(2053×2 NGramMatrix with Union{Missing, Int64} elements) ["M"] 2 obs, 97 bytes + ╰── ProductNode ["U"] 2 obs, 0 bytes + ├── ArrayNode(1×2 Array with Int64 elements) ["Y"] 2 obs, 72 bytes + ╰── BagNode ["c"] 2 obs, 80 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) ["e"] 2 obs, 88 bytes julia> reflectinmodel(n, d -> Dense(d, 3), SegmentedMean; fsm=Dict("e" => d -> Chain(Dense(d, 2), Dense(2, 2))), fsa=Dict("c" => SegmentedLSE), single_key_identity=false, single_scalar_identity=false) -ProductModel ↦ Dense(6 => 3) 2 arrays, 21 params, 164 bytes - ├── ProductModel ↦ Dense(3 => 3) 2 arrays, 12 params, 128 bytes - │ ╰── a: ArrayModel([postimputing]Dense(2053 => 3)) 3 arrays, 6_165 params, 24.199 KiB - ╰── ProductModel ↦ Dense(6 => 3) 2 arrays, 21 params, 164 bytes - ├── ArrayModel(Dense(1 => 3)) 2 arrays, 6 params, 104 bytes - ╰── BagModel ↦ SegmentedLSE(2) ↦ Dense(2 => 3) 4 arrays, 13 params, 212 bytes - ╰── ArrayModel(Chain(Dense(2 => 2), Dense(2 => 2))) 4 arrays, 12 params, 208 bytes +ProductModel ↦ Dense(6 => 3) 2 arrays, 21 params, 172 bytes + ├── ProductModel ↦ Dense(3 => 3) 2 arrays, 12 params, 136 bytes + │ ╰── a: ArrayModel([postimputing]Dense(2053 => 3)) 3 arrays, 6_165 params, 24.207 KiB + ╰── ProductModel ↦ Dense(6 => 3) 2 arrays, 21 params, 172 bytes + ├── ArrayModel(Dense(1 => 3)) 2 arrays, 6 params, 112 bytes + ╰── BagModel ↦ SegmentedLSE(2) ↦ Dense(2 => 3) 4 arrays, 13 params, 220 bytes + ╰── ArrayModel(Chain(Dense(2 => 2), Dense(2 => 2))) 4 arrays, 12 params, 224 bytes ``` See also: [`AbstractMillNode`](@ref), [`AbstractMillModel`](@ref), [`ProductNode`](@ref), [`BagNode`](@ref), [`ArrayNode`](@ref). diff --git a/src/show.jl b/src/show.jl index 35e99083..9458e2c7 100644 --- a/src/show.jl +++ b/src/show.jl @@ -24,11 +24,11 @@ Print summary of parameters of node `n`. # Examples ```jldoctest julia> n = ProductNode(ArrayNode(randn(2, 3))) -ProductNode 3 obs, 8 bytes - ╰── ArrayNode(2×3 Array with Float64 elements) 3 obs, 96 bytes +ProductNode 3 obs, 0 bytes + ╰── ArrayNode(2×3 Array with Float64 elements) 3 obs, 104 bytes julia> datasummary(n) -"Data summary: 3 obs, 112 bytes." +"Data summary: 3 obs, 104 bytes." ``` See also: [`modelsummary`](@ref). @@ -104,10 +104,10 @@ Print summary of parameters of model `m`. ```jldoctest julia> m = ProductModel(ArrayModel(Dense(2, 3))) ProductModel ↦ identity - ╰── ArrayModel(Dense(2 => 3)) 2 arrays, 9 params, 116 bytes + ╰── ArrayModel(Dense(2 => 3)) 2 arrays, 9 params, 124 bytes julia> modelsummary(m) -"Model summary: 2 arrays, 9 params, 116 bytes" +"Model summary: 2 arrays, 9 params, 124 bytes" ``` See also: [`datasummary`](@ref). diff --git a/src/special_arrays/maybe_hot_matrix.jl b/src/special_arrays/maybe_hot_matrix.jl index 7f0568a7..1daece51 100644 --- a/src/special_arrays/maybe_hot_matrix.jl +++ b/src/special_arrays/maybe_hot_matrix.jl @@ -97,9 +97,9 @@ julia> maybehotbatch([:c, :a], [:a, :b, :c]) julia> maybehotbatch([missing, 2], 1:3) 3×2 MaybeHotMatrix with eltype Union{Missing, Bool}: - missing ⋅ - missing true - missing ⋅ + missing ⋅ + missing 1 + missing ⋅ ``` See also: [`maybehot`](@ref), [`MaybeHotMatrix`](@ref), [`MaybeHotVector`](@ref). diff --git a/src/special_arrays/special_arrays.jl b/src/special_arrays/special_arrays.jl index 3ee51e76..65e04522 100644 --- a/src/special_arrays/special_arrays.jl +++ b/src/special_arrays/special_arrays.jl @@ -107,7 +107,7 @@ Like `Flux.Dense`, but use a [`PreImputingMatrix`](@ref) instead of a standard m # Examples ```jldoctest julia> d = preimputing_dense(2, 3) -[preimputing]Dense(2 => 3) 3 arrays, 11 params, 164 bytes +[preimputing]Dense(2 => 3) 3 arrays, 11 params, 172 bytes julia> typeof(d.weight) PreImputingMatrix{Float32, Matrix{Float32}, Vector{Float32}} @@ -129,7 +129,7 @@ Like `Flux.Dense`, but use a [`PostImputingMatrix`](@ref) instead of a standard # Examples ```jldoctest julia> d = postimputing_dense(3, 2) -[postimputing]Dense(3 => 2) 3 arrays, 10 params, 160 bytes +[postimputing]Dense(3 => 2) 3 arrays, 10 params, 168 bytes julia> typeof(d.weight) PostImputingMatrix{Float32, Matrix{Float32}, Vector{Float32}} diff --git a/src/util.jl b/src/util.jl index e48a2021..3fc7a6b5 100644 --- a/src/util.jl +++ b/src/util.jl @@ -15,10 +15,10 @@ predicate `p`. # Examples ```jldoctest julia> n = ProductNode((BagNode(missing, bags([0:-1, 0:-1])), ArrayNode([1 2; 3 4]))) -ProductNode 2 obs, 16 bytes - ├── BagNode 2 obs, 88 bytes +ProductNode 2 obs, 0 bytes + ├── BagNode 2 obs, 80 bytes │ ╰── ∅ - ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes julia> pred_lens(x -> x isa ArrayNode, n) 1-element Vector{Any}: @@ -54,10 +54,10 @@ Return a `Vector` of [`Accessors.jl`](https://github.com/JuliaObjects/Accessors. # Examples ```jldoctest julia> n = ProductNode((BagNode(missing, bags([0:-1, 0:-1])), ArrayNode([1 2; 3 4]))) -ProductNode 2 obs, 16 bytes - ├── BagNode 2 obs, 88 bytes +ProductNode 2 obs, 0 bytes + ├── BagNode 2 obs, 80 bytes │ ╰── ∅ - ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes julia> list_lens(n) 9-element Vector{Any}: @@ -85,10 +85,10 @@ least one observation. # Examples ```jldoctest julia> n = ProductNode((BagNode(missing, bags([0:-1, 0:-1])), ArrayNode([1 2; 3 4]))) -ProductNode 2 obs, 16 bytes - ├── BagNode 2 obs, 88 bytes +ProductNode 2 obs, 0 bytes + ├── BagNode 2 obs, 80 bytes │ ╰── ∅ - ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes julia> findnonempty_lens(n) 3-element Vector{Any}: @@ -110,10 +110,10 @@ when compared to `x` using `Base.===`. # Examples ```jldoctest julia> n = ProductNode((BagNode(missing, bags([0:-1, 0:-1])), ArrayNode([1 2; 3 4]))) -ProductNode 2 obs, 16 bytes - ├── BagNode 2 obs, 88 bytes +ProductNode 2 obs, 0 bytes + ├── BagNode 2 obs, 80 bytes │ ╰── ∅ - ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes julia> find_lens(n, n.data[1]) 1-element Vector{Any}: @@ -135,10 +135,10 @@ lenses such that they access each node in tree `n` egal to node under code `c` i julia> n = ProductNode((BagNode(missing, bags([0:-1, 0:-1])), ArrayNode([1 2; 3 4]))); julia> printtree(n; trav=true) -ProductNode [""] 2 obs, 16 bytes - ├── BagNode ["E"] 2 obs, 88 bytes +ProductNode [""] 2 obs, 0 bytes + ├── BagNode ["E"] 2 obs, 80 bytes │ ╰── ∅ ["M"] - ╰── ArrayNode(2×2 Array with Int64 elements) ["U"] 2 obs, 80 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) ["U"] 2 obs, 88 bytes julia> code2lens(n, "U") 1-element Vector{Any}: @@ -160,10 +160,10 @@ such that they access each node in tree `n` egal to node accessible by lens `l`. julia> n = ProductNode((BagNode(missing, bags([0:-1, 0:-1])), ArrayNode([1 2; 3 4]))); julia> printtree(n; trav=true) -ProductNode [""] 2 obs, 16 bytes - ├── BagNode ["E"] 2 obs, 88 bytes +ProductNode [""] 2 obs, 0 bytes + ├── BagNode ["E"] 2 obs, 80 bytes │ ╰── ∅ ["M"] - ╰── ArrayNode(2×2 Array with Int64 elements) ["U"] 2 obs, 80 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) ["U"] 2 obs, 88 bytes julia> lens2code(n, (@optic _.data[2])) 1-element Vector{String}: @@ -191,16 +191,16 @@ Convert [`Accessors.jl`](https://github.com/JuliaObjects/Accessors.jl) lens `l` ```jldoctest julia> n = ProductNode((BagNode(randn(Float32, 2, 2), bags([0:-1, 0:-1])), ArrayNode(Float32[1 2; 3 4]))) -ProductNode 2 obs, 24 bytes - ├── BagNode 2 obs, 96 bytes - │ ╰── ArrayNode(2×2 Array with Float32 elements) 2 obs, 64 bytes - ╰── ArrayNode(2×2 Array with Float32 elements) 2 obs, 64 bytes +ProductNode 2 obs, 0 bytes + ├── BagNode 2 obs, 80 bytes + │ ╰── ArrayNode(2×2 Array with Float32 elements) 2 obs, 72 bytes + ╰── ArrayNode(2×2 Array with Float32 elements) 2 obs, 72 bytes julia> m = reflectinmodel(n) -ProductModel ↦ Dense(20 => 10) 2 arrays, 210 params, 920 bytes - ├── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) 4 arrays, 240 params, 1.094 KiB - │ ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 200 bytes - ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 200 bytes +ProductModel ↦ Dense(20 => 10) 2 arrays, 210 params, 928 bytes + ├── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) 4 arrays, 240 params, 1.102 KiB + │ ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 208 bytes + ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 208 bytes julia> model_lens(m, (@optic _.data[2])) (@o _.ms[2]) @@ -226,16 +226,16 @@ Convert [`Accessors.jl`](https://github.com/JuliaObjects/Accessors.jl) lens `l` # Examples ```jldoctest julia> n = ProductNode((BagNode(randn(Float32, 2, 2), bags([0:-1, 0:-1])), ArrayNode(Float32[1 2; 3 4]))) -ProductNode 2 obs, 24 bytes - ├── BagNode 2 obs, 96 bytes - │ ╰── ArrayNode(2×2 Array with Float32 elements) 2 obs, 64 bytes - ╰── ArrayNode(2×2 Array with Float32 elements) 2 obs, 64 bytes +ProductNode 2 obs, 0 bytes + ├── BagNode 2 obs, 80 bytes + │ ╰── ArrayNode(2×2 Array with Float32 elements) 2 obs, 72 bytes + ╰── ArrayNode(2×2 Array with Float32 elements) 2 obs, 72 bytes julia> m = reflectinmodel(n) -ProductModel ↦ Dense(20 => 10) 2 arrays, 210 params, 920 bytes - ├── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) 4 arrays, 240 params, 1.094 KiB - │ ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 200 bytes - ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 200 bytes +ProductModel ↦ Dense(20 => 10) 2 arrays, 210 params, 928 bytes + ├── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) 4 arrays, 240 params, 1.102 KiB + │ ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 208 bytes + ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 208 bytes julia> data_lens(n, (@optic _.ms[2])) (@o _.data[2]) @@ -263,15 +263,15 @@ Short description # Examples ```jldoctest julia> n = ProductNode((BagNode(randn(2, 2), bags([0:-1, 0:-1])), ArrayNode([1 2; 3 4]))) -ProductNode 2 obs, 24 bytes - ├── BagNode 2 obs, 96 bytes - │ ╰── ArrayNode(2×2 Array with Float64 elements) 2 obs, 80 bytes - ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes +ProductNode 2 obs, 0 bytes + ├── BagNode 2 obs, 80 bytes + │ ╰── ArrayNode(2×2 Array with Float64 elements) 2 obs, 88 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes julia> replacein(n, n.data[1], ArrayNode(maybehotbatch([1, 2], 1:2))) -ProductNode 2 obs, 24 bytes - ├── ArrayNode(2×2 MaybeHotMatrix with Bool elements) 2 obs, 80 bytes - ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 80 bytes +ProductNode 2 obs, 0 bytes + ├── ArrayNode(2×2 MaybeHotMatrix with Bool elements) 2 obs, 64 bytes + ╰── ArrayNode(2×2 Array with Int64 elements) 2 obs, 88 bytes ``` """ replacein(x, _, _) = x diff --git a/test/hierarchical_utils.jl b/test/hierarchical_utils.jl index 6690a8b1..dda71fc3 100644 --- a/test/hierarchical_utils.jl +++ b/test/hierarchical_utils.jl @@ -148,24 +148,24 @@ end @testset "printtree" begin @test buf_printtree(n2, trav=true) == """ - ProductNode [""] 2 obs, 120 bytes - ├── ProductNode ["E"] 2 obs, 80 bytes - │ ├─── b: BagNode ["I"] 2 obs, 192 bytes - │ │ ╰── ArrayNode(3×4 Array with Float32 elements) ["K"] 4 obs, 96 bytes - │ ╰── wb: WeightedBagNode ["M"] 2 obs, 280 bytes - │ ╰── ArrayNode(17×4 NGramMatrix with Int64 elements) ["O"] 4 obs, 186 bytes - ╰── ArrayNode(10×2 SparseMatrixCSC with Float32 elements) ["U"] 2 obs, 464 bytes + ProductNode [""] 2 obs, 0 bytes + ├── ProductNode ["E"] 2 obs, 0 bytes + │ ├─── b: BagNode ["I"] 2 obs, 176 bytes + │ │ ╰── ArrayNode(3×4 Array with Float32 elements) ["K"] 4 obs, 104 bytes + │ ╰── wb: WeightedBagNode ["M"] 2 obs, 240 bytes + │ ╰── ArrayNode(17×4 NGramMatrix with Int64 elements) ["O"] 4 obs, 154 bytes + ╰── ArrayNode(10×2 SparseMatrixCSC with Float32 elements) ["U"] 2 obs, 424 bytes """ @test buf_printtree(n2m, trav=true) == """ - ProductModel ↦ Dense(20 => 10) [""] 2 arrays, 210 params, 920 bytes - ├── ProductModel ↦ Dense(20 => 10) ["E"] 2 arrays, 210 params, 920 bytes - │ ├─── b: BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["I"] 4 arrays, 240 params, 1.094 KiB - │ │ ╰── ArrayModel(Dense(3 => 10)) ["K"] 2 arrays, 40 params, 240 bytes - │ ╰── wb: BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["M"] 4 arrays, 240 params, 1.094 KiB - │ ╰── ArrayModel(Dense(17 => 10)) ["O"] 2 arrays, 180 params, 800 bytes - ╰── ArrayModel(Dense(10 => 10)) ["U"] 2 arrays, 110 params, 520 bytes + ProductModel ↦ Dense(20 => 10) [""] 2 arrays, 210 params, 928 bytes + ├── ProductModel ↦ Dense(20 => 10) ["E"] 2 arrays, 210 params, 928 bytes + │ ├─── b: BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["I"] 4 arrays, 240 params, 1.102 KiB + │ │ ╰── ArrayModel(Dense(3 => 10)) ["K"] 2 arrays, 40 params, 248 bytes + │ ╰── wb: BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["M"] 4 arrays, 240 params, 1.102 KiB + │ ╰── ArrayModel(Dense(17 => 10)) ["O"] 2 arrays, 180 params, 808 bytes + ╰── ArrayModel(Dense(10 => 10)) ["U"] 2 arrays, 110 params, 528 bytes """ end @@ -188,7 +188,7 @@ end @test buf_printtree(m, trav=true) == """ LazyModel{Codons} [""] - ╰── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["U"] 4 arrays, 240 params, 1.094 KiB - ╰── ArrayModel(Dense(64 => 10)) ["k"] 2 arrays, 650 params, 2.617 KiB + ╰── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) ["U"] 4 arrays, 240 params, 1.102 KiB + ╰── ArrayModel(Dense(64 => 10)) ["k"] 2 arrays, 650 params, 2.625 KiB """ end diff --git a/test/io.jl b/test/io.jl index bb8ddfb1..f0ac559b 100644 --- a/test/io.jl +++ b/test/io.jl @@ -7,72 +7,72 @@ 2×5 ArrayNode{Matrix{Float32}, Nothing}: 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0""" - @test datasummary(an) == "Data summary: 5 obs, 88 bytes." + @test datasummary(an) == "Data summary: 5 obs, 96 bytes." anm = reflectinmodel(an) @test repr(anm) == "ArrayModel(Dense(2 => 10))" @test repr(anm; context=:compact => true) == "ArrayModel" @test repr(MIME("text/plain"), anm) == """ - ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 200 bytes""" - @test modelsummary(anm) == "Model summary: 2 arrays, 30 params, 200 bytes" + ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 208 bytes""" + @test modelsummary(anm) == "Model summary: 2 arrays, 30 params, 208 bytes" bn = BagNode(deepcopy(an), bags([1:2, 3:5])) @test repr(bn) == repr(bn; context=:compact => true) == "BagNode" @test repr(MIME("text/plain"), bn) == """ - BagNode 2 obs, 96 bytes - ╰── ArrayNode(2×5 Array with Float32 elements) 5 obs, 88 bytes""" - @test datasummary(bn) == "Data summary: 2 obs, 184 bytes." + BagNode 2 obs, 80 bytes + ╰── ArrayNode(2×5 Array with Float32 elements) 5 obs, 96 bytes""" + @test datasummary(bn) == "Data summary: 2 obs, 176 bytes." bnm = reflectinmodel(bn, d -> Dense(d, 10), SegmentedMean) @test repr(bnm) == "BagModel ↦ SegmentedMean(10) ↦ Dense(10 => 10)" @test repr(bnm; context=:compact => true) == "BagModel" @test repr(MIME("text/plain"), bnm) == """ - BagModel ↦ SegmentedMean(10) ↦ Dense(10 => 10) 3 arrays, 120 params, 600 bytes - ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 200 bytes""" - @test modelsummary(bnm) == "Model summary: 5 arrays, 150 params, 800 bytes" + BagModel ↦ SegmentedMean(10) ↦ Dense(10 => 10) 3 arrays, 120 params, 608 bytes + ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 208 bytes""" + @test modelsummary(bnm) == "Model summary: 5 arrays, 150 params, 816 bytes" wbn = WeightedBagNode(deepcopy(an), bags([1:2, 3:5]), rand(Float32, 5)) @test repr(wbn) == repr(wbn; context=:compact => true) == "WeightedBagNode" @test repr(MIME("text/plain"), wbn) == """ - WeightedBagNode 2 obs, 164 bytes - ╰── ArrayNode(2×5 Array with Float32 elements) 5 obs, 88 bytes""" - @test datasummary(wbn) == "Data summary: 2 obs, 252 bytes." + WeightedBagNode 2 obs, 148 bytes + ╰── ArrayNode(2×5 Array with Float32 elements) 5 obs, 96 bytes""" + @test datasummary(wbn) == "Data summary: 2 obs, 244 bytes." wbnm = reflectinmodel(wbn) @test repr(wbnm) == "BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10)" @test repr(wbnm; context=:compact => true) == "BagModel" @test repr(MIME("text/plain"), wbnm) == """ - BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) 4 arrays, 240 params, 1.094 KiB - ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 200 bytes""" - @test modelsummary(wbnm) == "Model summary: 6 arrays, 270 params, 1.289 KiB" + BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) 4 arrays, 240 params, 1.102 KiB + ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 208 bytes""" + @test modelsummary(wbnm) == "Model summary: 6 arrays, 270 params, 1.305 KiB" pn = ProductNode(bn=deepcopy(bn), wbn=deepcopy(wbn)) @test repr(pn) == repr(pn; context=:compact => true) == "ProductNode" @test repr(MIME("text/plain"), pn) == """ - ProductNode 2 obs, 40 bytes - ├─── bn: BagNode 2 obs, 96 bytes - │ ╰── ArrayNode(2×5 Array with Float32 elements) 5 obs, 88 bytes - ╰── wbn: WeightedBagNode 2 obs, 164 bytes - ╰── ArrayNode(2×5 Array with Float32 elements) 5 obs, 88 bytes""" - @test datasummary(pn) == "Data summary: 2 obs, 516 bytes." + ProductNode 2 obs, 0 bytes + ├─── bn: BagNode 2 obs, 80 bytes + │ ╰── ArrayNode(2×5 Array with Float32 elements) 5 obs, 96 bytes + ╰── wbn: WeightedBagNode 2 obs, 148 bytes + ╰── ArrayNode(2×5 Array with Float32 elements) 5 obs, 96 bytes""" + @test datasummary(pn) == "Data summary: 2 obs, 420 bytes." pnm = reflectinmodel(pn, d -> Dense(d, 10), BagCount ∘ SegmentedMean) @test repr(pnm) == "ProductModel ↦ Dense(20 => 10)" @test repr(pnm; context=:compact => true) == "ProductModel" @test repr(MIME("text/plain"), pnm) == """ - ProductModel ↦ Dense(20 => 10) 2 arrays, 210 params, 920 bytes - ├─── bn: BagModel ↦ BagCount(SegmentedMean(10)) ↦ Dense(11 => 10) 3 arrays, 130 params, 640 bytes - │ ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 200 bytes - ╰── wbn: BagModel ↦ BagCount(SegmentedMean(10)) ↦ Dense(11 => 10) 3 arrays, 130 params, 640 bytes - ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 200 bytes""" - @test modelsummary(pnm) == "Model summary: 12 arrays, 530 params, 2.539 KiB" + ProductModel ↦ Dense(20 => 10) 2 arrays, 210 params, 928 bytes + ├─── bn: BagModel ↦ BagCount(SegmentedMean(10)) ↦ Dense(11 => 10) 3 arrays, 130 params, 648 bytes + │ ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 208 bytes + ╰── wbn: BagModel ↦ BagCount(SegmentedMean(10)) ↦ Dense(11 => 10) 3 arrays, 130 params, 648 bytes + ╰── ArrayModel(Dense(2 => 10)) 2 arrays, 30 params, 208 bytes""" + @test modelsummary(pnm) == "Model summary: 12 arrays, 530 params, 2.578 KiB" ln = LazyNode{:Sentence}(["a", "b", "c", "d"]) @test repr(ln) == "LazyNode{Sentence}(String)" @@ -92,21 +92,21 @@ @test repr(MIME("text/plain"), lnm) == """ LazyModel{Sentence} - ╰── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) 4 arrays, 240 params, 1.094 KiB - ╰── ArrayModel(Dense(2053 => 10)) 2 arrays, 20_540 params, 80.312 KiB""" - @test modelsummary(lnm) == "Model summary: 6 arrays, 20_780 params, 81.406 KiB" + ╰── BagModel ↦ BagCount([SegmentedMean(10); SegmentedMax(10)]) ↦ Dense(21 => 10) 4 arrays, 240 params, 1.102 KiB + ╰── ArrayModel(Dense(2053 => 10)) 2 arrays, 20_540 params, 80.320 KiB""" + @test modelsummary(lnm) == "Model summary: 6 arrays, 20_780 params, 81.422 KiB" end @testset "special parameter values" begin m = reflectinmodel(ArrayNode(ones(Float32, 2, 5))) m.m.weight[1,1] = Inf - @test repr(MIME("text/plain"), m) == "ArrayModel(Dense(2 => 10)) 2 arrays, 30 params (some Inf), 200 bytes" + @test repr(MIME("text/plain"), m) == "ArrayModel(Dense(2 => 10)) 2 arrays, 30 params (some Inf), 208 bytes" m.m.bias[1] = NaN - @test repr(MIME("text/plain"), m) == "ArrayModel(Dense(2 => 10)) 2 arrays, 30 params (some NaN), 200 bytes" + @test repr(MIME("text/plain"), m) == "ArrayModel(Dense(2 => 10)) 2 arrays, 30 params (some NaN), 208 bytes" m.m.weight .= 0 m.m.bias .= 0 - @test repr(MIME("text/plain"), m) == "ArrayModel(Dense(2 => 10)) 2 arrays, 30 params (all zero), 200 bytes" + @test repr(MIME("text/plain"), m) == "ArrayModel(Dense(2 => 10)) 2 arrays, 30 params (all zero), 208 bytes" end @testset "aggregation io" begin @@ -187,8 +187,8 @@ end @test repr(MIME("text/plain"), X) == """ 2×2 MaybeHotMatrix with eltype Union{Missing, Bool}: - missing ⋅ - missing true""" + missing ⋅ + missing 1""" X = MaybeHotMatrix([missing, missing, missing], 4) @test repr(X) == "MaybeHotMatrix(I = [missing, missing, missing], l = 4)" @@ -238,11 +238,11 @@ end @testset "imputing dense io" begin m = preimputing_dense(1, 1) @test repr(m) == repr(m; context=:compact => true) == "[preimputing]Dense(1 => 1)" - @test repr(MIME("text/plain"), m) == "[preimputing]Dense(1 => 1) 3 arrays, 3 params, 132 bytes" + @test repr(MIME("text/plain"), m) == "[preimputing]Dense(1 => 1) 3 arrays, 3 params, 140 bytes" m = postimputing_dense(2, 1) @test repr(m) == repr(m; context=:compact => true) == "[postimputing]Dense(2 => 1)" - @test repr(MIME("text/plain"), m) == "[postimputing]Dense(2 => 1) 3 arrays, 4 params, 136 bytes" + @test repr(MIME("text/plain"), m) == "[postimputing]Dense(2 => 1) 3 arrays, 4 params, 144 bytes" end @testset "ngram matrix io" begin