Skip to content

Commit

Permalink
Merge pull request #31 from jverzani/relax_types
Browse files Browse the repository at this point in the history
close issue #30
  • Loading branch information
jverzani authored Nov 7, 2020
2 parents 38ff561 + a837186 commit d343438
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ImplicitEquations"
uuid = "95701278-4526-5785-aba3-513cca398f19"
version = "1.0.1"
version = "1.0.2"

[deps]
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
Expand Down
22 changes: 11 additions & 11 deletions src/predicates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ To negate a predicate, `!` is used.
"""
mutable struct Pred <: Predicate
f::Function
f
op
val
end
Expand All @@ -46,25 +46,25 @@ preds = [(:Lt, :≪, :<), # \ll
for (fn, uop, op) in preds
fnname = string(fn)
@eval begin
($fn)(f::Function, x::Real) = Pred(f, $op, x)
($uop)(f::Function, x::Real) = ($fn)(f, x)
($fn)(f::Function, g::Function) = $(fn)((x,y) -> f(x,y) - g(x,y), 0)
($uop)(f::Function, g::Function) = ($fn)(f, g)
($fn)(f, x::Real) = Pred(f, $op, x)
($uop)(f, x::Real) = ($fn)(f, x)
($fn)(f, g) = $(fn)((x,y) -> f(x,y) - g(x,y), 0)
($uop)(f, g) = ($fn)(f, g)
end
eval(Expr(:export, fn))
eval(Expr(:export, uop))
end

Neq(f::Function, x::Real) = Pred(f, !== , x)
Neq(f::Function, g::Function) = Neq((x,y) -> f(x,y) - g(x,y), 0)
Neq(f, x::Real) = Pred(f, !== , x)
Neq(f, g) = Neq((x,y) -> f(x,y) - g(x,y), 0)

(x::Real, y::Real) = (x != y)
(f::Function, x::Real) = Neq(f, x)
(f::Function, g::Function) = Neq(f, g)
(f, x::Real) = Neq(f, x)
(f, g) = Neq(f, g)

(x::Real, y::Real) = (x != y)
(f::Function, x::Real) = Neq(f, x)
(f::Function, g::Function) = Neq(f, g)
(f, x::Real) = Neq(f, x)
(f, g) = Neq(f, g)



Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ ImplicitEquations.GRAPH(Neq(f, g), -5, 5, -5, 5, 2^4, 2^4)

ImplicitEquations.GRAPH(Eq(f, g), -5, 5, -5, 5, 2^4, 2^4)
ImplicitEquations.GRAPH(f g, -5, 5, -5, 5, 2^4, 2^4)


# Issue #30: relax assumptions in predicates
struct F end
(::F)(x,y) = x^2 + y^2
ImplicitEquations.GRAPH(f 0, -5, 5, -5, 5, 2^4, 2^4)

2 comments on commit d343438

@jverzani
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/24287

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.2 -m "<description of version>" d3434382281f15b58f5dfc2dd652305c3552a98f
git push origin v1.0.2

Please sign in to comment.