Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ::AbstractOrbital behave like scalars under broadcasting #97

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/orbitals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
abstract type AbstractOrbital

Abstract supertype of all orbital types.

!!! note "Broadcasting"

When broadcasting, orbital objects behave like scalars.
"""
abstract type AbstractOrbital end
Base.Broadcast.broadcastable(x::AbstractOrbital) = Ref(x)

"""
const MQ = Union{Int,Symbol}
Expand Down
7 changes: 7 additions & 0 deletions test/orbitals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,11 @@ using Random
@test ne == e
end
end

@testset "Broadcasting" begin
@test ([o"1s", o"2p"] .== o"1s") == [true, false]
@test ([ro"1s", ro"2p-"] .== ro"1s") == [true, false]
@test ([so"1s(0,α)", so"2p(0,α)"] .== so"1s(0,α)") == [true, false]
@test ([rso"1s(1/2)", rso"2p-(1/2)"] .== rso"1s(1/2)") == [true, false]
end
end