Skip to content

Commit 0235100

Browse files
committed
Add shrink_concept. New version
1 parent 64f4107 commit 0235100

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Constraints"
22
uuid = "30f324ab-b02d-43f0-b619-e131c61659f7"
33
authors = ["Jean-François Baffier"]
4-
version = "0.5.0"
4+
version = "0.5.1"
55

66
[deps]
77
CompositionalNetworks = "4b67e4b5-442d-4ef5-b760-3f5df3a57537"

src/constraint.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ function make_error(symb::Symbol)
7878
return (x; params...) -> Float64(!eval(Symbol("concept_$symb"))(x; params...))
7979
end
8080

81+
"""
82+
shrink_concept(s)
83+
84+
Simply delete the `concept_` part of symbol or string starting with it. TODO: add a check with a warning if `s` starts with something different.
85+
"""
86+
shrink_concept(s) = Symbol(string(s)[9:end])
87+
8188
## SECTION - Test Items
8289
@testitem "Empty constraint" tags = [:constraint, :empty] begin
8390
c = Constraint()

src/usual_constraints.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ end
4646
macro usual(ex::Expr)
4747
# Symbol of the concept, for instance :all_different
4848
s = ex.args[1].args[1]
49-
c = Symbol(string(s)[9:end])
49+
c = shrink_concept(s)
5050

5151
# Dict storing the existence or not of a default value for each kwarg
5252
defaults = Dict{Symbol, Bool}()

0 commit comments

Comments
 (0)