Skip to content

Commit 48ba8d3

Browse files
authored
Add Aqua to tests, fix issues (#144)
1 parent 5b2845a commit 48ba8d3

File tree

8 files changed

+25
-21
lines changed

8 files changed

+25
-21
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ProximalOperators"
22
uuid = "a725b495-10eb-56fe-b38b-717eba820537"
3-
version = "0.15.3"
3+
version = "0.16.0"
44

55
[deps]
66
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Build status](https://github.com/JuliaFirstOrder/ProximalOperators.jl/workflows/CI/badge.svg?branch=master)](https://github.com/JuliaFirstOrder/ProximalOperators.jl/actions?query=workflow%3ACI+branch%3Amaster)
44
[![codecov](https://codecov.io/gh/JuliaFirstOrder/ProximalOperators.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaFirstOrder/ProximalOperators.jl)
55
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4020558.svg)](https://doi.org/10.5281/zenodo.4020558)
6+
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
67

78
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliafirstorder.github.io/ProximalOperators.jl/stable)
89
[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://juliafirstorder.github.io/ProximalOperators.jl/latest)

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3-
ProximalOperators = "a725b495-10eb-56fe-b38b-717eba820537"
43
ProximalCore = "dc4f5ac2-75d1-4f31-931e-60435d74994b"
4+
ProximalOperators = "a725b495-10eb-56fe-b38b-717eba820537"
55

66
[compat]
77
Documenter = "0.27"

src/ProximalOperators.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export prox, prox!, gradient, gradient!
1919
# Utilities
2020

2121
include("utilities/approx_inequality.jl")
22-
include("utilities/tuples.jl")
2322
include("utilities/linops.jl")
2423
include("utilities/symmetricpacked.jl")
2524
include("utilities/uniformarrays.jl")

src/calculus/separableSum.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,23 @@ component_types(::Type{SeparableSum{T}}) where T = fieldtypes(T)
4141

4242
(g::SeparableSum)(xs::Tuple) = sum(f(x) for (f, x) in zip(g.fs, xs))
4343

44-
prox!(ys::Tuple, fs::Tuple, xs::Tuple, gamma::Number) = sum(prox!(y, f, x, gamma) for (y, f, x) in zip(ys, fs, xs))
44+
prox!(ys::Tuple, g::SeparableSum, xs::Tuple, gamma::Number) = sum(prox!(y, f, x, gamma) for (y, f, x) in zip(ys, g.fs, xs))
4545

46-
prox!(ys::Tuple, fs::Tuple, xs::Tuple, gammas::Tuple) = sum(prox!(y, f, x, gamma) for (y, f, x, gamma) in zip(ys, fs, xs, gammas))
46+
prox!(ys::Tuple, g::SeparableSum, xs::Tuple, gammas::Tuple) = sum(prox!(y, f, x, gamma) for (y, f, x, gamma) in zip(ys, g.fs, xs, gammas))
4747

48-
prox!(ys::Tuple, g::SeparableSum, xs::Tuple, gamma) = prox!(ys, g.fs, xs, gamma)
48+
function prox(g::SeparableSum, xs::Tuple, gamma=1)
49+
ys = similar.(xs)
50+
fys = prox!(ys, g, xs, gamma)
51+
return ys, fys
52+
end
4953

50-
gradient!(grads::Tuple, fs::Tuple, xs::Tuple) = sum(gradient!(grad, f, x) for (grad, f, x) in zip(grads, fs, xs))
54+
gradient!(grads::Tuple, g::SeparableSum, xs::Tuple) = sum(gradient!(grad, f, x) for (grad, f, x) in zip(grads, g.fs, xs))
5155

52-
gradient!(grads::Tuple, g::SeparableSum, xs::Tuple) = gradient!(grads, g.fs, xs)
56+
function gradient(g::SeparableSum, xs::Tuple)
57+
ys = similar.(xs)
58+
fxs = gradient!(ys, g, xs)
59+
return ys, fxs
60+
end
5361

5462
function prox_naive(f::SeparableSum, xs::Tuple, gamma)
5563
fys = real(eltype(xs[1]))(0)

src/utilities/tuples.jl

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[deps]
2-
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
3-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
43
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
4+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
55
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
6+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

test/runtests.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ using ProximalOperators:
1818
is_positively_homogeneous,
1919
is_support
2020

21+
using Aqua
22+
2123
function call_test(f, x::ArrayOrTuple{R}) where R <: Real
2224
try
2325
fx = @inferred f(x)
@@ -30,6 +32,8 @@ function call_test(f, x::ArrayOrTuple{R}) where R <: Real
3032
end
3133
end
3234

35+
Base.zero(xs::Tuple) = Base.zero.(xs)
36+
3337
# tests equality of the results of prox, prox! and prox_naive
3438
function prox_test(f, x::ArrayOrTuple{R}, gamma=1) where R <: Real
3539
y, fy = @inferred prox(f, x, gamma)
@@ -109,8 +113,8 @@ function predicates_test(f)
109113
@test !is_strongly_convex(f) || is_convex(f)
110114
end
111115

112-
@testset "Sanity checks" begin
113-
@test isempty(detect_unbound_args(ProximalOperators))
116+
@testset "Aqua" begin
117+
Aqua.test_all(ProximalOperators; ambiguities=false)
114118
end
115119

116120
@testset "Utilities" begin

0 commit comments

Comments
 (0)