From 467ae2789e7684cc4bf759eb3e86ce78b06bd89f Mon Sep 17 00:00:00 2001 From: singularitti Date: Wed, 1 Nov 2023 10:14:04 -0400 Subject: [PATCH] Add checks in `ReciprocalPath` constructor --- src/reciprocal.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/reciprocal.jl b/src/reciprocal.jl index 27594c0..2118404 100644 --- a/src/reciprocal.jl +++ b/src/reciprocal.jl @@ -90,7 +90,15 @@ struct ReciprocalPath{T} start_node::ReducedCoordinates{T} end_node::ReducedCoordinates{T} density::Int64 + function ReciprocalPath{T}(start_node, end_node, density) where {T} + if density < 2 + throw(ArgumentError("you need at least two points to define a path!")) + end + return new(start_node, end_node, density) + end end +ReciprocalPath(start_node, end_node, density) = + ReciprocalPath{Base.promote_eltype(start_node, end_node)}(start_node, end_node, density) function ReciprocalPath(bz::BrillouinZone, start_node::Symbol, end_node::Symbol, density) points = specialpoints(bz) return ReciprocalPath(points[start_node], points[end_node], density)