Skip to content

Commit

Permalink
Format .jl files (#164)
Browse files Browse the repository at this point in the history
Co-authored-by: mohamed82008 <mohamed82008@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and mohamed82008 authored Oct 23, 2023
1 parent 9019088 commit e08b325
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ makedocs(;
sitename="TopOpt.jl",
format=Documenter.HTML(; prettyurls=get(ENV, "CI", nothing) == "true"),
# doctest = false,
warnonly = true,
plugins = [bib],
warnonly=true,
plugins=[bib],
pages=[
"Home" => "index.md",
"Problem types" => "examples/problem.md",
Expand Down
8 changes: 5 additions & 3 deletions src/TopOpt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ function PseudoDensities(x::A) where {T,N,A<:AbstractArray{T,N}}
end
function PseudoDensities{I,P,F}(x::A) where {I,P,F,T,N,A<:AbstractArray{T,N}}
return PseudoDensities{I,P,F,T,N,A}(x)
end
function ChainRulesCore.rrule(::Type{PseudoDensities{I, P, F, T, N, A}}, x) where {I, P, F, T, N, A <: AbstractArray{T, N}}
PseudoDensities{I, P, F, T, N, A}(x), Δ -> (NoTangent(), Δ isa Tangent ? Δ.x : Δ)
end
function ChainRulesCore.rrule(
::Type{PseudoDensities{I,P,F,T,N,A}}, x
) where {I,P,F,T,N,A<:AbstractArray{T,N}}
return PseudoDensities{I,P,F,T,N,A}(x), Δ -> (NoTangent(), Δ isa Tangent ? Δ.x : Δ)
end

Base.BroadcastStyle(::Type{T}) where {T<:PseudoDensities} = Broadcast.ArrayStyle{T}()
Expand Down
4 changes: 3 additions & 1 deletion src/Utilities/penalties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ end
@inline (P::ProjectedPenalty)(x::Real) = P.penalty(P.proj(x))
@forward_property ProjectedPenalty penalty

(P::AbstractProjection)(x::PseudoDensities{I,T,F}) where {I,T,F} = PseudoDensities{I,T,F}(P(x.x))
function (P::AbstractProjection)(x::PseudoDensities{I,T,F}) where {I,T,F}
return PseudoDensities{I,T,F}(P(x.x))
end
(P::AbstractProjection)(x::AbstractArray) = map(P, x)

mutable struct HeavisideProjection{T} <: AbstractProjection
Expand Down

0 comments on commit e08b325

Please sign in to comment.