Skip to content

Commit

Permalink
make all Int annotations Integer
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed Nov 16, 2024
1 parent ac031e9 commit bef122a
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 58 deletions.
22 changes: 11 additions & 11 deletions src/BlockAverages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ end
block_average(
x::AbstractVector{T};
by = mean,
min_block_size::Int = 1,
max_block_size::Int = length(x),
lags::Union{Nothing,AbstractVector{Int}} = nothing,
min_block_size::Integer = 1,
max_block_size::Integer = length(x),
lags::Union{Nothing,AbstractVector{<:Integer}} = nothing,
) where {T<:Real}
This function peforms some convergence analysis for a property computed from a series of data, typically a time-series.
Expand Down Expand Up @@ -177,9 +177,9 @@ julia> plot(b) # creates a plot with the results
function block_average(
x_input::AbstractVector{T};
by=mean,
min_block_size::Int=1,
max_block_size::Int=length(x_input),
lags::Union{Nothing,AbstractVector{Int}}=nothing
min_block_size::Integer=1,
max_block_size::Integer=length(x_input),
lags::Union{Nothing,AbstractVector{<:Integer}}=nothing
) where {T<:Real}

x = adjust_xinput(x_input, max_block_size)
Expand Down Expand Up @@ -276,9 +276,9 @@ function Base.show(io::IO, ::MIME"text/plain", m::BlockDistribution)
end

"""
block_distribution(x_input::AbstractVector; block_size::Int) =
block_distribution(mean, x_input, block_size::Int)
block_distribution(by::Function, x_input::AbstractVector, block_size::Int)
block_distribution(x_input::AbstractVector; block_size::Integer) =
block_distribution(mean, x_input, block_size::Integer)
block_distribution(by::Function, x_input::AbstractVector, block_size::Integer)
Given the data and the block size, computes the distribution of estimates of the
properties for each block. Returns a `BlockDistribution{NBLOCKS}` object. The
Expand Down Expand Up @@ -311,7 +311,7 @@ julia> histogram(d)
```
"""
function block_distribution(by::Function, x_input::AbstractVector, block_size::Int)
function block_distribution(by::Function, x_input::AbstractVector, block_size::Integer)
if block_size < 1
throw(ArgumentError((
"block_size not properly defined. Use, for example: block_distribution(x; block_size=10^5)"
Expand All @@ -328,7 +328,7 @@ function block_distribution(by::Function, x_input::AbstractVector, block_size::I
end
return BlockDistribution{nblocks}(mean(x), std(block_mean), block_mean, std(block_mean) / sqrt(nblocks))
end
block_distribution(x_input::AbstractVector; block_size::Int=0) = block_distribution(mean, x_input, block_size)
block_distribution(x_input::AbstractVector; block_size::Integer=0) = block_distribution(mean, x_input, block_size)

# Range of indices for block i of size block_size
function brange(i, block_size)
Expand Down
8 changes: 4 additions & 4 deletions src/MolecularMinimumDistances/AllPairs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ end
ypositions::AbstractVector{<:AbstractVector{T}},
cutoff::T,
unitcell::AbstractVecOrMat,
xn_atoms_per_molecule::Int,
yn_atoms_per_molecule::Int,
xn_atoms_per_molecule::Integer,
yn_atoms_per_molecule::Integer,
parallel::Bool=true
) where T<:Real
Expand Down Expand Up @@ -82,8 +82,8 @@ function AllPairs(;
ypositions::AbstractVector{<:AbstractVector{T}},
cutoff::T,
unitcell::AbstractVecOrMat,
xn_atoms_per_molecule::Union{Nothing,Int}=nothing,
yn_atoms_per_molecule::Union{Nothing,Int}=nothing,
xn_atoms_per_molecule::Union{Nothing,Integer}=nothing,
yn_atoms_per_molecule::Union{Nothing,Integer}=nothing,
xmol_indices::F1=nothing,
ymol_indices::F2=nothing,
parallel::Bool=true
Expand Down
4 changes: 2 additions & 2 deletions src/MolecularMinimumDistances/CrossPairs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end
ypositions::AbstractVector{<:AbstractVector{T}},
cutoff::T,
unitcell::AbstractVecOrMat,
xn_atoms_per_molecule::Int,
xn_atoms_per_molecule::Integer,
parallel::Bool=true
) where T<:Real
Expand Down Expand Up @@ -74,7 +74,7 @@ function CrossPairs(;
ypositions::AbstractVector{<:AbstractVector{T}},
cutoff::T,
unitcell::AbstractVecOrMat,
xn_atoms_per_molecule::Union{Nothing,Int}=nothing,
xn_atoms_per_molecule::Union{Nothing,Integer}=nothing,
xmol_indices::F1=nothing,
parallel::Bool=true
) where {T<:Real, F1<:Union{Nothing,Function}}
Expand Down
8 changes: 4 additions & 4 deletions src/MolecularMinimumDistances/MolecularMinimumDistances.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ molecules. `x` must be provided so that the type of variable of the coordinates
propagated to the distances, and `mol_indices` is the function that given an atomic index `i`
returns the index of the molecule.
init_list(::Type{T}, number_of_molecules::Int)
init_list(::Type{T}, number_of_molecules::Integer)
Given the type of the coordinates of the vector of atomic coordinates and the number of molecules,
returns the initialized array of minimum distances.
Expand Down Expand Up @@ -203,7 +203,7 @@ function init_list(x::AbstractVector{<:AbstractVector}, mol_indices::F) where {F
end
return init_list(T, number_of_molecules)
end
init_list(::Type{T}, n::Int) where {T} = fill(zero(MinimumDistance{T}), n)
init_list(::Type{T}, n::Integer) where {T} = fill(zero(MinimumDistance{T}), n)

#
# Overload of the CellListMap functions that are required for list_threaded
Expand Down Expand Up @@ -412,8 +412,8 @@ function minimum_distances(;
mol_indices=nothing,
xmol_indices=nothing,
ymol_indices=nothing,
xn_atoms_per_molecule::Union{Nothing,Int}=nothing,
yn_atoms_per_molecule::Union{Nothing,Int}=nothing,
xn_atoms_per_molecule::Union{Nothing,Integer}=nothing,
yn_atoms_per_molecule::Union{Nothing,Integer}=nothing,
parallel::Bool=true,
)
# SelfPairs
Expand Down
4 changes: 2 additions & 2 deletions src/MolecularMinimumDistances/SelfPairs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end
xpositions::AbstractVector{<:AbstractVector{T}},
cutoff::T,
unitcell::AbstractVecOrMat,
xn_atoms_per_molecule::Int,
xn_atoms_per_molecule::Integer,
parallel::Bool=true
) where T<:Real
Expand Down Expand Up @@ -66,7 +66,7 @@ function SelfPairs(;
xpositions::AbstractVector{<:AbstractVector{T}},
cutoff::T,
unitcell::AbstractVecOrMat,
xn_atoms_per_molecule::Union{Nothing,Int}=nothing,
xn_atoms_per_molecule::Union{Nothing,Integer}=nothing,
mol_indices::F1=nothing,
parallel::Bool=true,
) where {T<:Real, F1<:Union{Nothing,Function}}
Expand Down
14 changes: 7 additions & 7 deletions src/MolecularMinimumDistances/testing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import CellListMap: Box, wrap_relative_to

# For a single set of molecules
function naive_md(x, xn_atoms_per_molecule::Int, unitcell::AbstractVecOrMat, cutoff::Real)
function naive_md(x, xn_atoms_per_molecule::Integer, unitcell::AbstractVecOrMat, cutoff::Real)
box = Box(unitcell, cutoff)
naive_md(x, xn_atoms_per_molecule, box)
end
function naive_md(x, xn_atoms_per_molecule::Int, box::Box)
function naive_md(x, xn_atoms_per_molecule::Integer, box::Box)
x_list = init_list(x, i -> _mol_indices(i, xn_atoms_per_molecule))
for i in 1:length(x)-1
vx = x[i]
Expand Down Expand Up @@ -37,7 +37,7 @@ function naive_md(x, xn_atoms_per_molecule::Int, box::Box)
end

# For disjoint sets, returning only one list
function naive_md(x, y, xn_atoms_per_molecule::Int, unitcell::AbstractVecOrMat, cutoff::Real)
function naive_md(x, y, xn_atoms_per_molecule::Integer, unitcell::AbstractVecOrMat, cutoff::Real)
box = Box(unitcell, cutoff)
naive_md(x, y, xn_atoms_per_molecule, box)
end
Expand All @@ -60,7 +60,7 @@ function naive_md(x, y, xn_atoms_per_molecule, box)
end

# For disjoint sets, returning both lists
function naive_md(x, y, xn_atoms_per_molecule::Int, yn_atoms_per_molecule::Int, unitcell::AbstractVecOrMat, cutoff::Real)
function naive_md(x, y, xn_atoms_per_molecule::Integer, yn_atoms_per_molecule::Integer, unitcell::AbstractVecOrMat, cutoff::Real)
box = Box(unitcell, cutoff)
naive_md(x, y, xn_atoms_per_molecule, yn_atoms_per_molecule, box)
end
Expand Down Expand Up @@ -144,7 +144,7 @@ end
function plot_mol!(
p,
x,
n_atoms_per_molecule::Int;
n_atoms_per_molecule::Integer;
cycle=false,
markercolor=nothing
)
Expand All @@ -165,9 +165,9 @@ end
function plot_md!(
p,
x,
xn_atoms_per_molecule::Int,
xn_atoms_per_molecule::Integer,
y,
yn_atoms_per_molecule::Int,
yn_atoms_per_molecule::Integer,
md::List;
x_cycle=false,
y_cycle=false
Expand Down
4 changes: 2 additions & 2 deletions src/datastructures/Positions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ FramePositions(m::AbstractMatrix{T}) where {T} = FramePositions{T,Point3D{T},typ
FramePositions(f::Chemfiles.Frame) = positions(Chemfiles.positions(f))
FramePositions(x::FramePositions{T,P}) where {T,P} = FramePositions{T,P,typeof(x.positions)}(x.positions)

Base.getindex(x::FramePositions, i::Int) = Point3D(@view(x.positions[:, i]))
Base.getindex(x::FramePositions, i::Integer) = Point3D(@view(x.positions[:, i]))
Base.getindex(x::FramePositions, r::AbstractUnitRange) = FramePositions(x.positions[:, r])
Base.getindex(x::FramePositions, ivec::AbstractVector{<:Integer}) = FramePositions(x.positions[:, ivec])

Base.setindex!(x::FramePositions, value::AbstractVector, i::Int) = x.positions[:, i] .= value
Base.setindex!(x::FramePositions, value::AbstractVector, i::Integer) = x.positions[:, i] .= value

Base.length(x::FramePositions) = size(x.positions, 2)
Base.size(x::FramePositions) = (length(x),)
Expand Down
4 changes: 2 additions & 2 deletions src/datastructures/Simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ function set_frame_range!(simulation::Simulation; first=1, last=nothing, step=1)
end

"""
get_frame(simulation::Simulation, iframe::Int)
get_frame(simulation::Simulation, iframe::Integer)
Returns the frame at the given index in the trajectory.
Expand Down Expand Up @@ -430,7 +430,7 @@ julia> writePDB(frame4, "frame4.pdb")
required frame.
"""
function get_frame(simulation::Simulation, iframe::Int)
function get_frame(simulation::Simulation, iframe::Integer)
if !(iframe in frame_range(simulation))
throw(ArgumentError("get_frame: Index $iframe out of simulation range: $(frame_range(simulation))."))
end
Expand Down
4 changes: 2 additions & 2 deletions src/gromacs/remd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ function remd_data(log::String)
end

"""
remd_replica_path(data::GromacsREMDlog, replica::Int; stride::Int = 1)
remd_replica_path(data::GromacsREMDlog, replica::Integer; stride::Integer = 1)
Function to obtain the path of a replica in the exchange matrix.
"""
remd_replica_path(data::GromacsREMDlog, replica::Int; stride::Int=1) =
remd_replica_path(data::GromacsREMDlog, replica::Integer; stride::Integer=1) =
[findfirst(==(replica), data.exchange_matrix[i, :]) - 1 for i in 1:stride:size(data.exchange_matrix, 1)];

@testitem "REMD" begin
Expand Down
24 changes: 12 additions & 12 deletions src/miscelaneous_functions/bulk_coordination.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ _imol_atoms(imol, n, indices) = first(indices) .+ (((imol-1)*n):(imol*n-1))
"""
bulk_coordination(
simulation::Simulation;
reference_solute::AbstractVector{PDBTools.Atom},
solute::AbstractVector{PDBTools.Atom},
n_atoms_per_molecule_solute::Int,
solvent::AbstractVector{PDBTools.Atom},
n_atoms_per_molecule_solvent::Int,
reference_solute::AbstractVector{<:PDBTools.Atom},
solute::AbstractVector{<:PDBTools.Atom},
n_atoms_per_molecule_solute::Integer,
solvent::AbstractVector{<:PDBTools.Atom},
n_atoms_per_molecule_solvent::Integer,
dmax::Real = 5.0,
cutoff::Real = 20.0,
bin_size::Real = 0.1,
Expand All @@ -44,9 +44,9 @@ the distance.
- `reference_solute::AbstractVector{PDBTools.Atom}`: The atoms of the reference solute molecule
(the protein in the example above).
- `solute::AbstractVector{PDBTools.Atom}`: The atoms of the solute molecule (the TMAO in the example above).
- `n_atoms_per_molecule_solute::Int`: The number of atoms per molecule of the solute.
- `n_atoms_per_molecule_solute::Integer`: The number of atoms per molecule of the solute.
- `solvent::AbstractVector{PDBTools.Atom}`: The atoms of the solvent molecule (the water in the example above).
- `n_atoms_per_molecule_solvent::Int`: The number of atoms per molecule of the solvent.
- `n_atoms_per_molecule_solvent::Integer`: The number of atoms per molecule of the solvent.
- `dmax::Real = 5.0`: The maximum distance to the solute to consider a solvent molecule as coordinated.
- `cutoff::Real = 20.0`: The maximum distance to the reference molecule for computing the histogram.
- `bin_size::Real = 0.1`: The size of the bins for the histogram.
Expand Down Expand Up @@ -93,11 +93,11 @@ julia> plot(r, h, # plots `h` as a function of `r`
"""
function bulk_coordination(
simulation::Simulation;
reference_solute::AbstractVector{PDBTools.Atom},
solute::AbstractVector{PDBTools.Atom},
n_atoms_per_molecule_solute::Int,
solvent::AbstractVector{PDBTools.Atom},
n_atoms_per_molecule_solvent::Int,
reference_solute::AbstractVector{<:PDBTools.Atom},
solute::AbstractVector{<:PDBTools.Atom},
n_atoms_per_molecule_solute::Integer,
solvent::AbstractVector{<:PDBTools.Atom},
n_atoms_per_molecule_solvent::Integer,
dmax::Real=5.0,
cutoff::Real=20.0,
bin_size::Real=0.1,
Expand Down
4 changes: 2 additions & 2 deletions src/miscelaneous_functions/center_of_mass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ julia> cm = center_of_mass(protein_indices, simulation, coor)
"""
function PDBTools.center_of_mass(
indices::AbstractVector{Int},
indices::AbstractVector{<:Integer},
simulation::Simulation,
p::FramePositions;
iref::Union{Nothing,Int}=max(1, div(length(indices), 2)),
iref::Union{Nothing,<:Integer}=max(1, div(length(indices), 2)),
)
xref = isnothing(iref) ? nothing : p[iref]
uc = unitcell(current_frame(simulation))
Expand Down
8 changes: 4 additions & 4 deletions src/miscelaneous_functions/distances.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
distances(simulation, indices1::AbstractVector{Int}, indices2::AbstractVector{Int})
distances(simulation, selection1::AbstractVector{PDBTools.Atom}, selection2::AbstractVector{PDBTools.Atom})
distances(simulation, indices1::AbstractVector{<:Integer}, indices2::AbstractVector{<:Integer})
distances(simulation, selection1::AbstractVector{<:PDBTools.Atom}, selection2::AbstractVector{<:PDBTools.Atom})
Function that calculates the distance between the centers of mass of two selections in a simulation.
Expand Down Expand Up @@ -48,8 +48,8 @@ julia> distances(sim,
"""
function distances(
simulation::Simulation,
indices1::AbstractVector{Int},
indices2::AbstractVector{Int};
indices1::AbstractVector{<:Integer},
indices2::AbstractVector{<:Integer};
silent::Bool = false,
)
distances = zeros(length(simulation))
Expand Down
2 changes: 1 addition & 1 deletion src/miscelaneous_functions/intermittent_correlation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Returns an `OffsetArray` with indices `0:maxdelta`, where the value at position
# Arguments
- `data::AbstractVector`: The time series to be analyzed.
- `maxdelta::Int`: The maximum delta-step to be considered. Defaults to
- `maxdelta::Integer`: The maximum delta-step to be considered. Defaults to
`length(data) ÷ 10`.
- `types` (optional): A function that returns `true` for the types of data
that should be considered. Defaults to all data, i. e. `x -> true`. For
Expand Down
6 changes: 3 additions & 3 deletions src/miscelaneous_functions/most_representative_structure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ julia> most_representative_structure(simulation; atoms = "protein and name CA")
julia> calphas = select(atoms(simulation), "name CA");
julia> most_representative_structure(simulation; atoms = calphas) # atoms is an AbstractVector{PDBTools.Atom}
julia> most_representative_structure(simulation; atoms = calphas) # atoms is an Vector{PDBTools.Atom}
(4, 1.1681526249035976)
julia> ica = PDBTools.index.(calphas)
Expand All @@ -70,9 +70,9 @@ function most_representative_structure(simulation::Simulation; atoms = nothing)
else
if atoms isa AbstractVector{<:PDBTools.Atom}
indices = PDBTools.index.(atoms)
elseif atoms isa AbstractVector{Int}
elseif atoms isa AbstractVector{<:Integer}
indices = atoms
elseif atoms isa String
elseif atoms isa AbstractString
indices = PDBTools.index.(
PDBTools.select(MolSimToolkit.atoms(simulation), atoms)
)
Expand Down

0 comments on commit bef122a

Please sign in to comment.