From 7580d2d2a934cd16261ae0975c65415c843e39b5 Mon Sep 17 00:00:00 2001 From: Oren Ben-Kiki Date: Mon, 1 Apr 2024 20:13:16 +0300 Subject: [PATCH] Move setting function metadata to a function. --- Manifest.toml | 34 ++++++++++----------------- docs/v0.1.0/.documenter-siteinfo.json | 2 +- src/computations.jl | 12 ++++++---- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index e5fc080..514f1be 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -15,22 +15,10 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" [[deps.CategoricalArrays]] -deps = ["DataAPI", "Future", "Missings", "Printf", "Requires", "Statistics", "Unicode"] -git-tree-sha1 = "1568b28f91293458345dabba6a5ea3f183250a61" +deps = ["DataAPI", "Future", "JSON", "Missings", "Printf", "Statistics", "StructTypes", "Unicode"] +git-tree-sha1 = "18d7f3e82c1a80dd38c16453b8fd3f0a7db92f23" uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597" -version = "0.10.8" - - [deps.CategoricalArrays.extensions] - CategoricalArraysJSONExt = "JSON" - CategoricalArraysRecipesBaseExt = "RecipesBase" - CategoricalArraysSentinelArraysExt = "SentinelArrays" - CategoricalArraysStructTypesExt = "StructTypes" - - [deps.CategoricalArrays.weakdeps] - JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" - RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" - SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c" - StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4" +version = "0.9.7" [[deps.Combinatorics]] git-tree-sha1 = "08c8b6831dc00bfea825826be0bc8336fc369860" @@ -304,10 +292,8 @@ uuid = "14a3606d-f60d-562e-9121-12d972cd8159" version = "2023.1.10" [[deps.Muon]] -deps = ["CategoricalArrays", "CompressHashDisplace", "DataFrames", "FileIO", "HDF5", "LinearAlgebra", "OrderedCollections", "Pkg", "PooledArrays", "Random", "SparseArrays", "StructArrays"] -git-tree-sha1 = "4dc16783ceefb335cce04c4ef2052d90db9f95e0" -repo-rev = "main" -repo-url = "https://github.com/scverse/Muon.jl" +deps = ["CategoricalArrays", "CompressHashDisplace", "DataFrames", "FileIO", "HDF5", "LinearAlgebra", "OrderedCollections", "Pkg", "Random", "SparseArrays", "StructArrays"] +git-tree-sha1 = "ff611246bb4df30c45ca56562502f96833158895" uuid = "446846d7-b4ce-489d-bf74-72da18fe3629" version = "0.2.0" @@ -339,9 +325,9 @@ version = "4.1.6+0" [[deps.OpenSSL_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "60e3045590bd104a16fefb12836c00c0ef8c7f8c" +git-tree-sha1 = "3da7367955dcc5c54c1ba4d402ccdc09a1a3e046" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "3.0.13+0" +version = "3.0.13+1" [[deps.OrderedCollections]] git-tree-sha1 = "dfdf5519f235516220579f949664f1bf44e741c5" @@ -467,6 +453,12 @@ version = "0.6.18" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +[[deps.StructTypes]] +deps = ["Dates", "UUIDs"] +git-tree-sha1 = "ca4bccb03acf9faaf4137a9abc1881ed1841aa70" +uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4" +version = "1.10.0" + [[deps.SuiteSparse_jll]] deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" diff --git a/docs/v0.1.0/.documenter-siteinfo.json b/docs/v0.1.0/.documenter-siteinfo.json index b20ab38..66d7203 100644 --- a/docs/v0.1.0/.documenter-siteinfo.json +++ b/docs/v0.1.0/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-04-01T13:53:18","documenter_version":"1.3.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-04-01T20:12:39","documenter_version":"1.3.0"}} \ No newline at end of file diff --git a/src/computations.jl b/src/computations.jl index 9fc2a9f..7a31e23 100644 --- a/src/computations.jl +++ b/src/computations.jl @@ -64,6 +64,11 @@ end const METADATA_OF_FUNCTION = Dict{AbstractString, FunctionMetadata}() +function set_metadata_of_function(full_name::AbstractString, function_metadata::FunctionMetadata)::Nothing + METADATA_OF_FUNCTION[full_name] = function_metadata + return nothing +end + """ @computation function something(...) return ... @@ -109,8 +114,7 @@ macro computation(definition) @assert function_name isa Symbol full_name = "$(__module__).$(function_name)" - global METADATA_OF_FUNCTION - METADATA_OF_FUNCTION[full_name] = FunctionMetadata(Contract[], collect_defaults(inner_definition)) + set_metadata_of_function(full_name, FunctionMetadata(Contract[], collect_defaults(inner_definition))) inner_definition[:name] = Symbol(function_name, :_inner) outer_definition[:body] = Expr( @@ -134,8 +138,7 @@ macro computation(contract, definition) @assert function_name isa Symbol full_name = "$(__module__).$(function_name)" - global METADATA_OF_FUNCTION - METADATA_OF_FUNCTION[full_name] = FunctionMetadata([eval(contract)], collect_defaults(inner_definition)) + set_metadata_of_function(full_name, FunctionMetadata([eval(contract)], collect_defaults(inner_definition))) inner_definition[:name] = Symbol(function_name, :_inner) outer_definition[:body] = Expr( @@ -164,7 +167,6 @@ macro computation(first_contract, second_contract, definition) full_name = "$(__module__).$(function_name)" - global METADATA_OF_FUNCTION METADATA_OF_FUNCTION[full_name] = FunctionMetadata([eval(first_contract), eval(second_contract)], collect_defaults(inner_definition))