Skip to content

Commit

Permalink
Fix comparison of zero NBodyMatrixElements (#19)
Browse files Browse the repository at this point in the history
* Fix comparison of zero NBodyMatrixElements

* Bump version

* Update CI config
  • Loading branch information
jagot authored Sep 12, 2022
1 parent 542da81 commit a299d73
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ jobs:
matrix:
version:
- '1.6'
- '1.7'
- 'nightly'
- '1'
os:
- ubuntu-latest
- macOS-latest
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "EnergyExpressions"
uuid = "f4b57a2e-27c7-11e9-0cb0-edd185b706f6"
authors = ["Stefanos Carlström <[email protected]>"]
version = "0.1.0"
version = "0.1.1"

[deps]
AtomicLevels = "10933b4c-d60f-11e8-1fc6-bd9035a249a1"
Expand Down
1 change: 1 addition & 0 deletions src/nbody_matrix_elements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ an expression with a reference, generated otherwise. It may not be
performant. It may also fail on edge cases.
"""
function compare(a::NBodyMatrixElement, op, b::NBodyMatrixElement; kwargs...)
iszero(a) && iszero(b) && return op(0, 0)
ad,bd = map((a,b)) do o
od = Dict{Vector{NBodyTermFactor},Number}()
for term in o.terms
Expand Down
6 changes: 6 additions & 0 deletions test/nbody_matrix_elements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,18 @@
@testset "NBodyMatrixElement" begin
o = one(NBodyMatrixElement)
z = zero(NBodyMatrixElement)
az = convert(NBodyMatrixElement, 0)
bz = 0convert(NBodyMatrixElement, 1)

@test o == one(z)
@test isone(o)

@test z == zero(o)
@test iszero(z)
@test z == az
@test z == bz
@test z az
@test z bz


h = FieldFreeOneBodyHamiltonian()
Expand Down

2 comments on commit a299d73

@jagot
Copy link
Member Author

@jagot jagot commented on a299d73 Sep 12, 2022

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@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/68163

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.1.1 -m "<description of version>" a299d739e131b69bfed5673253eb0ee4ec4ad392
git push origin v0.1.1

Please sign in to comment.