timprove function return and docstring - Granular.jl - Julia package for granul… | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 506d369785cbe84aad93c068b0bc917d65eabf98 | |
parent 118b5f914de15690331b7484b3cc6c3478363bd4 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Wed, 22 Nov 2017 11:13:30 -0500 | |
improve function return and docstring | |
Diffstat: | |
M src/grid.jl | 19 +++++++++++-------- | |
1 file changed, 11 insertions(+), 8 deletions(-) | |
--- | |
diff --git a/src/grid.jl b/src/grid.jl | |
t@@ -523,6 +523,10 @@ attempting after `n_iter` iterations, each with randomly … | |
This function assumes that existing grains have been binned according to the | |
grid (e.g., using `sortGrainsInGrid()`). | |
+If the function sucessfully finds a position it will be returned as a | |
+two-component Vector{Float64}. If a position is not found, the function will | |
+return `false`. | |
+ | |
# Arguments | |
* `simulation::Simulation`: the simulation object to add grains to. | |
* `grid::Any`: the grid to use for position search. | |
t@@ -611,16 +615,15 @@ function findEmptyPositionInGridCell(simulation::Simulat… | |
break | |
end | |
end | |
- if verbose && !overlap_found | |
- info("Found position $pos in cell $i,$j") | |
- elseif verbose && overlap_found | |
- info("Free position not found in cell $i,$j") | |
+ if isnan(pos[1]) || isnan(pos[2]) | |
+ if verbose | |
+ warn("could not determine free position in cell $i,$j") | |
+ end | |
+ return false | |
end | |
- | |
if !overlap_found | |
- if isnan(pos[1]) || isnan(pos[2]) | |
- warn("could not determine free position in cell") | |
- return false | |
+ if verbose | |
+ info("Found position $pos in cell $i,$j") | |
end | |
return pos | |
else |