Skip to content

Commit 8ab55fb

Browse files
committed
beta
1 parent 05361d0 commit 8ab55fb

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/StatisticalTraits.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,22 @@ for trait in TRAITS
124124
eval(ex)
125125
end
126126

127+
## INFO METHOD FOR QUERYING TRAITS
128+
129+
"""
130+
info(X)
131+
132+
Return a named-tuple of trait values for `X`, keyed on a list of
133+
traits that are meaninful for the object.
134+
135+
*Note on overloading.* This method can be overloaded directly, as in
136+
`info(X::SomeAbstractType) = ...` or, using `info(X,
137+
::Val{:some_trait}) = ...` where `:some_trait` is a key of
138+
`ScientificTypes.TRAIT_FUNCTION_GIVEN_NAME`.
139+
140+
"""
141+
info(X) = info(X, Val(ScientificTypes.trait(X)))
142+
info(X, ::Val{:other}) = NamedTuple()
143+
127144
end # module
145+

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,8 @@ const NONCONSTANT = [:docstring,
7373
Main.eval(ex)
7474
end
7575
end
76+
77+
78+
## INFO STUB
79+
80+
@test StatisticalTraits.info(42) == NamedTuple()

0 commit comments

Comments
 (0)