Skip to content

Commit

Permalink
Fix IndZero (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
lostella committed Dec 29, 2023
1 parent fc3b637 commit 3da5fec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name = "ProximalCore"
uuid = "dc4f5ac2-75d1-4f31-931e-60435d74994b"
authors = ["Lorenzo Stella <lorenzostella@gmail.com>"]
version = "0.1.1"
version = "0.1.2"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[compat]
LinearAlgebra = "1.2"
julia = "1.2"
4 changes: 2 additions & 2 deletions src/ProximalCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ struct IndZero end
function (::IndZero)(x)
R = real(eltype(x))
if iszero(x)
return R(Inf)
return R(0)
end
return R(0)
return R(Inf)
end

is_convex(::Type{IndZero}) = true
Expand Down
7 changes: 4 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ end
@test is_generalized_quadratic(IndZero())

for T in [Float32, Float64]
@test let x = T[1.0, 2.0, 3.0]
prox(IndZero(), x, T(42)) == (T[0, 0, 0], T(0))
end
x = T[1.0, 2.0, 3.0]
@test IndZero()(x) == T(Inf)
@test IndZero()(T[0, 0, 0]) == T(0)
@test prox(IndZero(), x, T(42)) == (T[0, 0, 0], T(0))
end

end
Expand Down

2 comments on commit 3da5fec

@lostella
Copy link
Member 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/97916

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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 v0.1.2 -m "<description of version>" 3da5fecc3655d4c4b537c6d737d8fb9908220e3e
git push origin v0.1.2

Please sign in to comment.