Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better consistency with the blue style #317

Merged
merged 2 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ whitespace_ops_in_indices = true
pipe_to_function_call = true
import_to_using = true
always_use_return = true
whitespace_in_kwargs = false
remove_extra_newlines = true
annotate_untyped_fields_with_any = false
conditional_to_if = false
27 changes: 9 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ The following is a set of guidelines to [`Manifolds.jl`](https://juliamanifolds.

#### Table of Contents

* [I just have a question](#i-just-have-a-question)
* [How can I file an issue?](#how-can-i-file-an-issue)
* [How can I contribute?](#how-can-i-contribute)
- [Contributing to `Manifolds.jl`](#contributing-to-manifoldsjl)
- [Table of Contents](#table-of-contents)
- [I just have a question](#i-just-have-a-question)
- [How can I file an issue?](#how-can-i-file-an-issue)
- [How can I contribute?](#how-can-i-contribute)
- [Add a missing method](#add-a-missing-method)
- [Provide a new manifold](#provide-a-new-manifold)
- [Code style](#code-style)

## I just have a question

Expand Down Expand Up @@ -64,21 +69,7 @@ exp(::MyManifold, ::Any...)
### Code style

We try to follow the [documentation guidelines](https://docs.julialang.org/en/v1/manual/documentation/) from the Julia documentation as well as [Blue Style](https://github.com/invenia/BlueStyle).
We run [`JuliaFormatter.jl`](https://github.com/domluna/JuliaFormatter.jl) on the repo in the following way, which enforces a number of conventions consistent with Blue Style:

```julia
using JuliaFormatter

format(
".",
short_to_long_function_def = true,
always_for_in = true,
whitespace_ops_in_indices = true,
pipe_to_function_call = true,
import_to_using = true,
always_use_return = true,
)
```
We run [`JuliaFormatter.jl`](https://github.com/domluna/JuliaFormatter.jl) on the repo in the way set in the `.JuliaFormatter.toml` file, which enforces a number of conventions consistent with the Blue Style.

We also follow a few internal conventions:

Expand Down
24 changes: 12 additions & 12 deletions assets/logo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ normal_coord_to_vector(M, x, rθ, B) = get_vector(M, x, collect(polar_to_cart(r

normal_coord_to_point(M, x, rθ, B) = exp(M, x, normal_coord_to_vector(M, x, rθ, B))

function plot_normal_coord!(ax, M, x, B, rs, θs; ncirc = 9, options = Dict(), kwargs...)
function plot_normal_coord!(ax, M, x, B, rs, θs; ncirc=9, options=Dict(), kwargs...)
for r in rs[2:(end - 1)]
push!(
ax,
Expand All @@ -43,7 +43,7 @@ function plot_normal_coord!(ax, M, x, B, rs, θs; ncirc = 9, options = Dict(), k
),
)
end
for θ in range(0, 2π; length = ncirc)
for θ in range(0, 2π; length=ncirc)
push!(
ax,
Plot3(
Expand All @@ -55,7 +55,7 @@ function plot_normal_coord!(ax, M, x, B, rs, θs; ncirc = 9, options = Dict(), k
return ax
end

function plot_patch!(ax, M, x, B, r, θs; options = Dict())
function plot_patch!(ax, M, x, B, r, θs; options=Dict())
push!(
ax,
Plot3(
Expand All @@ -66,9 +66,9 @@ function plot_patch!(ax, M, x, B, r, θs; options = Dict())
return ax
end

function plot_geodesic!(ax, M, x, y; n = 100, options = Dict())
function plot_geodesic!(ax, M, x, y; n=100, options=Dict())
γ = shortest_geodesic(M, x, y)
T = range(0, 1; length = n)
T = range(0, 1; length=n)
push!(ax, Plot3(options, Coordinates(Tuple.(γ(T)))))
return ax
end
Expand Down Expand Up @@ -125,8 +125,8 @@ else
ymax = 1.0,
})
end
rs = range(0, π / 5; length = 6)
θs = range(0, 2π; length = 100)
rs = range(0, π / 5; length=6)
θs = range(0, 2π; length=100)

#
# Plot manifold patches
Expand All @@ -139,14 +139,14 @@ for i in eachindex(base_points)
B = DiagonalizingOrthonormalBasis(basis_vectors[i])
basis = get_basis(S, x, B)
optionsP = @pgf {fill = patch_colors[i], draw = "none", opacity = patch_opacity}
plot_patch!(tp, S, x, basis, π / 5, θs; options = optionsP)
plot_patch!(tp, S, x, basis, π / 5, θs; options=optionsP)
optionsL = @pgf {
meshlinestyle,
color = dark_mode ? "white" : "black",
line_width = mesh_line_width,
opacity = mesh_opacity,
}
plot_normal_coord!(tp, S, x, basis, rs, θs; options = optionsL)
plot_normal_coord!(tp, S, x, basis, rs, θs; options=optionsL)
end

#
Expand All @@ -158,9 +158,9 @@ options = @pgf {
line_width = geo_line_width,
color = dark_mode ? "white" : "black",
}
plot_geodesic!(tp, S, base_points[1], base_points[2]; options = options)
plot_geodesic!(tp, S, base_points[1], base_points[3]; options = options)
plot_geodesic!(tp, S, base_points[2], base_points[3]; options = options)
plot_geodesic!(tp, S, base_points[1], base_points[2]; options=options)
plot_geodesic!(tp, S, base_points[1], base_points[3]; options=options)
plot_geodesic!(tp, S, base_points[2], base_points[3]; options=options)

#
# Export Logo.
Expand Down
42 changes: 19 additions & 23 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ function add_manifold(
M::Manifold,
pts,
name;
test_tangent_vector_broadcasting = true,
retraction_methods = [],
inverse_retraction_methods = [],
point_distributions = [],
tvector_distributions = [],
test_tangent_vector_broadcasting=true,
retraction_methods=[],
inverse_retraction_methods=[],
point_distributions=[],
tvector_distributions=[],
)

SUITE["manifolds"][name] = BenchmarkGroup()
tv = log(M, pts[1], pts[2])
tv1 = log(M, pts[1], pts[2])
Expand Down Expand Up @@ -77,7 +76,6 @@ end

# General manifold benchmarks
function add_manifold_benchmarks()

SUITE["manifolds"] = BenchmarkGroup()

s2 = Manifolds.Sphere(2)
Expand Down Expand Up @@ -107,15 +105,15 @@ function add_manifold_benchmarks()
s2,
pts_s2,
"Sphere{2} -- SizedArray";
point_distributions = [ud_sphere],
tvector_distributions = [gtd_sphere],
point_distributions=[ud_sphere],
tvector_distributions=[gtd_sphere],
)

add_manifold(
array_s2,
[Size(3)([1.0, 0.0, 0.0]), Size(3)([0.0, 1.0, 0.0]), Size(3)([0.0, 0.0, 1.0])],
"ValidationManifold{Sphere{2}} -- SizedArray";
test_tangent_vector_broadcasting = false,
test_tangent_vector_broadcasting=false,
)

retraction_methods_rot = [Manifolds.PolarRetraction(), Manifolds.QRRetraction()]
Expand All @@ -129,8 +127,8 @@ function add_manifold_benchmarks()
so2,
[Size(2, 2)([cos(ϕ) -sin(ϕ); sin(ϕ) cos(ϕ)]) for ϕ in angles],
"Rotations(2) -- SizedArray",
retraction_methods = retraction_methods_rot,
inverse_retraction_methods = inverse_retraction_methods_rot,
retraction_methods=retraction_methods_rot,
inverse_retraction_methods=inverse_retraction_methods_rot,
)

so3 = Manifolds.Rotations(3)
Expand All @@ -139,11 +137,10 @@ function add_manifold_benchmarks()
so3,
[Size(3, 3)([cos(ϕ) -sin(ϕ) 0; sin(ϕ) cos(ϕ) 0; 0 0 1]) for ϕ in angles],
"Rotations(3) -- SizedArray",
retraction_methods = retraction_methods_rot,
inverse_retraction_methods = inverse_retraction_methods_rot,
retraction_methods=retraction_methods_rot,
inverse_retraction_methods=inverse_retraction_methods_rot,
)


m_prod = Manifolds.ProductManifold(s2, r2)
shape_s2r2_array = Manifolds.ShapeSpecification(Manifolds.ArrayReshaper(), s2, r2)
shape_s2r2_static = Manifolds.ShapeSpecification(Manifolds.StaticReshaper(), s2, r2)
Expand All @@ -161,7 +158,7 @@ function add_manifold_benchmarks()
m_prod,
pts_prod_mpoints,
"ProductManifold with MPoint";
test_tangent_vector_broadcasting = false,
test_tangent_vector_broadcasting=false,
)

# vector spaces and bundles
Expand All @@ -178,7 +175,7 @@ function add_manifold_benchmarks()
TB,
pts_tb,
"Tangent bundle of S² using MVectors, ProductRepr";
test_tangent_vector_broadcasting = false,
test_tangent_vector_broadcasting=false,
)
end

Expand Down Expand Up @@ -257,7 +254,7 @@ function add_manifold_benchmarks()
Ms1,
pts1,
"power manifold S²^(5,), type $(trim(string(T)))";
test_tangent_vector_broadcasting = true,
test_tangent_vector_broadcasting=true,
)
end
for T in types_s2
Expand All @@ -266,7 +263,7 @@ function add_manifold_benchmarks()
Ms2,
pts2,
"power manifold S²^(5,7), type $(trim(string(T)))";
test_tangent_vector_broadcasting = true,
test_tangent_vector_broadcasting=true,
)
end

Expand All @@ -276,7 +273,7 @@ function add_manifold_benchmarks()
Mr1,
pts1,
"power manifold SO(3)^(5,), type $(trim(string(T)))";
test_tangent_vector_broadcasting = true,
test_tangent_vector_broadcasting=true,
)
end
for T in types_r2
Expand All @@ -285,7 +282,7 @@ function add_manifold_benchmarks()
Mr2,
pts2,
"power manifold SO(3)^(5,7), type $(trim(string(T)))";
test_tangent_vector_broadcasting = true,
test_tangent_vector_broadcasting=true,
)
end

Expand Down Expand Up @@ -316,11 +313,10 @@ function add_manifold_benchmarks()
M,
pts,
"SPD manifold $(trim(string(M))), type $(trim(string(T)))";
test_tangent_vector_broadcasting = true,
test_tangent_vector_broadcasting=true,
)
end
end

end
return nothing
end
Expand Down
7 changes: 2 additions & 5 deletions benchmark/runbenchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using PkgBenchmark

#--track-allocation=all
config = BenchmarkConfig(
id = nothing,
juliacmd = `julia -O3`,
env = Dict("JULIA_NUM_THREADS" => 4),
)
config =
BenchmarkConfig(id=nothing, juliacmd=`julia -O3`, env=Dict("JULIA_NUM_THREADS" => 4))

results = benchmarkpkg("Manifolds", config)
export_markdown("benchmark/results.md", results)
14 changes: 7 additions & 7 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ isdir(generated_path) || mkdir(generated_path)
cp(
joinpath(dirname(@__DIR__), "CONTRIBUTING.md"),
joinpath(generated_path, "contributing.md");
force = true,
force=true,
)

makedocs(
# for development, we disable prettyurls
format = Documenter.HTML(prettyurls = false, assets = ["assets/favicon.ico"]),
modules = [Manifolds, ManifoldsBase, Manifolds.ManifoldTests],
authors = "Seth Axen, Mateusz Baran, Ronny Bergmann, and contributors.",
sitename = "Manifolds.jl",
pages = [
format=Documenter.HTML(prettyurls=false, assets=["assets/favicon.ico"]),
modules=[Manifolds, ManifoldsBase, Manifolds.ManifoldTests],
authors="Seth Axen, Mateusz Baran, Ronny Bergmann, and contributors.",
sitename="Manifolds.jl",
pages=[
"Home" => "index.md",
"ManifoldsBase.jl" => "interface.md",
"Examples" => ["How to implement a Manifold" => "examples/manifold.md"],
Expand Down Expand Up @@ -82,4 +82,4 @@ makedocs(
],
],
)
deploydocs(repo = "github.com/JuliaManifolds/Manifolds.jl.git", push_preview = true)
deploydocs(repo="github.com/JuliaManifolds/Manifolds.jl.git", push_preview=true)
1 change: 0 additions & 1 deletion src/Manifolds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ include("manifolds/VectorBundle.jl")
include("distributions.jl")
include("projected_distribution.jl")


# It's included early to ensure visibility of `Identity`
include("groups/group.jl")

Expand Down
1 change: 0 additions & 1 deletion src/differentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ abstract type AbstractDiffBackend end

struct NoneDiffBackend <: AbstractDiffBackend end


"""
_derivative(f, t[, backend::AbstractDiffBackend])

Expand Down
8 changes: 4 additions & 4 deletions src/groups/array_manifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function group_exp(M::ValidationManifold, X; kwargs...)
make_identity(M.manifold, array_value(X)),
array_value(X),
true;
check_base_point = false,
check_base_point=false,
kwargs...,
)
q = array_point(group_exp(M.manifold, array_value(X)))
Expand All @@ -196,7 +196,7 @@ function group_exp!(M::ValidationManifold, q, X; kwargs...)
make_identity(M.manifold, array_value(X)),
array_value(X),
true;
check_base_point = false,
check_base_point=false,
kwargs...,
)
group_exp!(M.manifold, array_value(q), array_value(X))
Expand All @@ -212,7 +212,7 @@ function group_log(M::ValidationManifold, q; kwargs...)
make_identity(M.manifold, array_value(X)),
array_value(X),
true;
check_base_point = false,
check_base_point=false,
kwargs...,
)
return X
Expand All @@ -226,7 +226,7 @@ function group_log!(M::ValidationManifold, X, q; kwargs...)
make_identity(M.manifold, array_value(X)),
array_value(X),
true;
check_base_point = false,
check_base_point=false,
kwargs...,
)
return X
Expand Down
5 changes: 2 additions & 3 deletions src/groups/group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ function decorator_transparent_dispatch(
return Val(:transparent)
end


###################
# Action directions
###################
Expand Down Expand Up @@ -811,7 +810,7 @@ For more details, see
"""
struct GroupExponentialRetraction{D<:ActionDirection} <: AbstractRetractionMethod end

function GroupExponentialRetraction(conv::ActionDirection = LeftAction())
function GroupExponentialRetraction(conv::ActionDirection=LeftAction())
return GroupExponentialRetraction{typeof(conv)}()
end

Expand All @@ -831,7 +830,7 @@ For more details, see
struct GroupLogarithmicInverseRetraction{D<:ActionDirection} <:
AbstractInverseRetractionMethod end

function GroupLogarithmicInverseRetraction(conv::ActionDirection = LeftAction())
function GroupLogarithmicInverseRetraction(conv::ActionDirection=LeftAction())
return GroupLogarithmicInverseRetraction{typeof(conv)}()
end

Expand Down
2 changes: 1 addition & 1 deletion src/groups/group_action.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function center_of_orbit(
A::AbstractGroupAction,
pts::AbstractVector,
q,
mean_method::AbstractEstimationMethod = GradientDescentEstimation(),
mean_method::AbstractEstimationMethod=GradientDescentEstimation(),
)
alignments = map(p -> optimal_alignment(A, q, p), pts)
return mean(base_group(A), alignments, mean_method)
Expand Down
Loading