From b4aaa0524ebcf464dfae4c1b7aba7924f3f5c774 Mon Sep 17 00:00:00 2001 From: Niklas Schmitz Date: Mon, 18 Nov 2024 11:04:40 +0100 Subject: [PATCH] Remove change_parameters fallback implementation (#16) (#17) * Remove change_parameters identity fallback * Add test for parameter interface defaults * Bump version: 0.2.4 -> 0.3.0 --- Project.toml | 2 +- src/interface.jl | 4 +++- test/runtests.jl | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 65daca0..85ffa31 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DftFunctionals" uuid = "6bd331d2-b28d-4fd3-880e-1a1c7f37947f" authors = ["Michael F. Herbst "] -version = "0.2.4" +version = "0.3.0" [deps] ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" diff --git a/src/interface.jl b/src/interface.jl index 4581a31..684421c 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -53,8 +53,10 @@ Generally the identifier of the functional will be changed to reflect the change in parameter values unless `keep_identifier` is true. To get the tuple of adjustable parameters and their current values check out [`parameters`](@ref). It is not checked that the correct parameters are passed. + +`change_parameters(f::Functional, params_new; keep_identifier=false)::Functional` """ -change_parameters(f::Functional, ::AbstractArray; keep_identifier=false) = f +function change_parameters end # TODO These values are read-only for now and their defaults hard-coded for Float64 """ diff --git a/test/runtests.jl b/test/runtests.jl index d966773..ab5c4e3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -43,6 +43,14 @@ end end end +@testset "Parameter interface defaults" begin + struct NewExchange <: Functional{:lda,:x} + end + f = NewExchange() + @test parameters(f) == ComponentArray{Bool}() + x = ComponentArray{Bool}() + @test_throws MethodError change_parameters(f, x) +end @testset "LDA potential (without spin)" begin ρ = [0.1, 0.2, 0.3, 0.4, 0.5]