Skip to content

Commit

Permalink
Remove change_parameters fallback implementation (#16) (#17)
Browse files Browse the repository at this point in the history
* Remove change_parameters identity fallback

* Add test for parameter interface defaults

* Bump version: 0.2.4 -> 0.3.0
  • Loading branch information
niklasschmitz authored Nov 18, 2024
1 parent b92e3d8 commit b4aaa05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DftFunctionals"
uuid = "6bd331d2-b28d-4fd3-880e-1a1c7f37947f"
authors = ["Michael F. Herbst <info@michael-herbst.com>"]
version = "0.2.4"
version = "0.3.0"

[deps]
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
Expand Down
4 changes: 3 additions & 1 deletion src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

2 comments on commit b4aaa05

@mfherbst
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/119685

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.0 -m "<description of version>" b4aaa0524ebcf464dfae4c1b7aba7924f3f5c774
git push origin v0.3.0

Please sign in to comment.