Skip to content

Commit 5c4bf87

Browse files
asinghvi17Rafael Schouten
andcommitted
Address code review
Co-authored-by: Rafael Schouten <[email protected]>
1 parent 94fe7e2 commit 5c4bf87

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/types.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,26 @@ abstract type CLibraryPlanarAlgorithm <: GeometryOpsCore.SingleManifoldAlgorithm
5454

5555
function (::Type{T})(; params...) where {T <: CLibraryPlanarAlgorithm}
5656
nt = NamedTuple(params)
57-
return T(Planar(), nt)
57+
return T(nt)
5858
end
5959
(T::Type{<: CLibraryPlanarAlgorithm})(::Planar, params::NamedTuple) = T(params)
6060

6161
manifold(alg::CLibraryPlanarAlgorithm) = Planar()
6262
best_manifold(alg::CLibraryPlanarAlgorithm, input) = Planar()
6363

64+
# Rebuild methods with manifolds are here.
6465
function rebuild(alg::T, m::Planar) where {T <: CLibraryPlanarAlgorithm}
65-
return T(m, alg.params)
66+
return T(alg.params) # TODO: should this not rebuild at all, then, since nothing will change?
6667
end
67-
6868
function rebuild(alg::T, m::AutoManifold) where {T <: CLibraryPlanarAlgorithm}
69-
return T(Planar(), alg.params)
69+
return T(alg.params) # "rebuild" as a planar algorithm.
7070
end
71-
7271
function rebuild(alg::T, m::M) where {T <: CLibraryPlanarAlgorithm, M <: Manifold}
7372
throw(GeometryOpsCore.WrongManifoldException{M, Planar, T}("The algorithm `$(typeof(alg))` is only compatible with planar manifolds."))
7473
end
74+
# Rebuild methods for parameters are here. This ends up being quite useful really.
75+
rebuild(alg::T, params::NamedTuple) where {T <: CLibraryPlanarAlgorithm} = T(params)
76+
rebuild(alg::T; params...) where {T <: CLibraryPlanarAlgorithm} = T(NamedTuple(params))
7577

7678
# These are definitions for convenience, so we don't have to type out
7779
# `alg.params` every time.
@@ -163,7 +165,6 @@ struct PROJ{M <: Manifold} <: Algorithm{M}
163165
params::NamedTuple
164166
end
165167

166-
PROJ() = PROJ(Planar(), NamedTuple())
167168
PROJ(; params...) = PROJ(Planar(), NamedTuple(params))
168169
PROJ(m::Manifold) = PROJ(m, NamedTuple())
169170

0 commit comments

Comments
 (0)