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

Add UnknownDirection #94

Merged
merged 1 commit into from
Jul 8, 2024
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
2 changes: 1 addition & 1 deletion src/QEDbase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export mass, charge
export base_state, propagator

# directions
export ParticleDirection, Incoming, Outgoing
export ParticleDirection, Incoming, Outgoing, UnknownDirection
export is_incoming, is_outgoing

# polarizations and spins
Expand Down
26 changes: 26 additions & 0 deletions src/particles/direction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,29 @@ struct Outgoing <: ParticleDirection end
is_incoming(::Outgoing) = false
is_outgoing(::Outgoing) = true
Base.show(io::IO, ::Outgoing) = print(io, "outgoing")

"""
UnknownDirection <: ParticleDirection

Concrete implementation of a [`ParticleDirection`](@ref) to indicate that a particle has an unknown direction.
This can mean that a specific direction does not make sense in the given context, that the direction is unavailable, or that it is unnecessary.

```jldoctest
julia> using QEDbase

julia> UnknownDirection()
unknown direction
```

!!! note "ParticleDirection Interface"
Besides being a subtype of [`ParticleDirection`](@ref), `UnknownDirection` has

```julia
is_incoming(::UnknownDirection) = false
is_outgoing(::UnknownDirection) = false
```
"""
struct UnknownDirection <: ParticleDirection end
is_incoming(::UnknownDirection) = false
is_outgoing(::UnknownDirection) = false
Base.show(io::IO, ::UnknownDirection) = print(io, "unknown direction")
2 changes: 1 addition & 1 deletion test/particle_properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_broadcast(x::AbstractSpinOrPolarization) = x

@testset "scalar broadcasting" begin
@testset "directions" begin
@testset "$dir" for dir in (Incoming(), Outgoing())
@testset "$dir" for dir in (Incoming(), Outgoing(), UnknownDirection())
@test test_broadcast.(dir) == dir
end
end
Expand Down
Loading