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

Force the contacts to have consecutive IDs starting from 1 #343

Merged
merged 1 commit into from
Jun 13, 2023
Merged
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
9 changes: 8 additions & 1 deletion src/SolidStateDetector/SolidStateDetector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,14 @@ function SolidStateDetector{T}(config_file::Dict, input_units::NamedTuple) where
@assert haskey(config_detector, "contacts") "Each detector needs at least two contacts. Please define the them in the configuration file."
contacts = broadcast(c -> Contact{T}(c, input_units, transformations), config_detector["contacts"])

passives = []
# SolidStateDetectors.jl does not allow for arbitrary contact IDs yet (issue #288)
# They need to be in order (1, 2, ... , N), so throw an error if this is not the case.
if !all(getfield.(contacts, :id) .== eachindex(contacts))
ArgumentError("SolidStateDetectors.jl only supports contact IDs that are in order.\n
Please set the ID of the first contact to 1, the ID of the second contact to 2, etc.")
end

passives = Passive{T}[]
if haskey(config_detector, "passives") # "passives" as entry of "detectors"
append!(passives, broadcast(p -> Passive{T}(p, input_units, transformations), config_detector["passives"]))
end
Expand Down