Skip to content

Commit

Permalink
Merge pull request #15 from MineralsCloud:Cell
Browse files Browse the repository at this point in the history
Fix checkers in `Cell` constructors
  • Loading branch information
singularitti authored Sep 18, 2023
2 parents 114c321 + 36c528a commit ddac61c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/cell.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ function Cell(lattice, positions, atoms)
if !(lattice isa Lattice)
lattice = Lattice(lattice)
end
if positions isa AbstractVector
P = eltype(Base.promote_typeof(positions...))
positions = collect(map(MVector{3,P}, positions))
else
throw(ArgumentError("`positions` must be a `Vector` of `Vector`s!"))
typeassert(positions, AbstractVector{<:AbstractVector})
P = eltype(Base.promote_typeof(positions...))
positions = collect(map(MVector{3,P}, positions))
for position in positions
if any(abs.(position) .> oneunit(eltype(position)))
throw(ArgumentError("atomic positions must be fractional!"))
end
end
L, T = eltype(lattice), eltype(atoms)
return Cell{L,P,T}(lattice, positions, atoms)
Expand Down

0 comments on commit ddac61c

Please sign in to comment.