Skip to content

Commit

Permalink
Move setting function metadata to a function.
Browse files Browse the repository at this point in the history
  • Loading branch information
orenbenkiki committed Apr 1, 2024
1 parent 3d267ff commit 7580d2d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
34 changes: 13 additions & 21 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-04-01T13:53:18","documenter_version":"1.3.0"}}
{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-04-01T20:12:39","documenter_version":"1.3.0"}}
12 changes: 7 additions & 5 deletions src/computations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 7580d2d

Please sign in to comment.