-
Notifications
You must be signed in to change notification settings - Fork 2
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
[feature] diamond-square and MPD #19
Conversation
Codecov Report
@@ Coverage Diff @@
## main #19 +/- ##
==========================================
- Coverage 16.39% 10.00% -6.40%
==========================================
Files 10 11 +1
Lines 122 200 +78
==========================================
Hits 20 20
- Misses 102 180 +78
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Nice. Could allow B with a warning perhaps? |
@gottacatchenall can you add an example to |
Something that occurred to me when looking at |
as far as i know, the only difference between in this case, only i'm getting closer to a minimum functioning version, hopefully by tomorrow |
this is functional, with the exception that the call |
going to go through and add documentation later, and might try it clean up more |
Sounds like unassigned memory. Which is what When you use |
ah that makes sense, didn't realize just pushed the documentation and am about to mark ready for review. at the moment the code is pretty verbose and not very "julia-ey" but seems to work fine also i want to add the warning if mat is not the right size but could make that a new pr? |
Don't you think that the issue reveals a bug though? I can't quickly see it from your code, but I bet that it means that somewhere in your algo you look up a value in your matrix but accidentally look up an unassigned value? Maybe an off-by-1 error due to the one-based indexing? Just shooting from the hip. |
Most of these functions are internal and will never be exposed to users, right? Maybe just preface them with |
@gottacatchenall is this still wip or do you want a pre-merge review? |
a couple of small changes i want to make before
also i could implement mpd pretty easily, but could also do that in a separate pr |
alright i think this is ready for a pre-merge review @tpoisot @mkborregaard |
rightSize::Bool = _isPowerOfTwo(size(mat)[1]-1) && _isPowerOfTwo(size(mat)[2]-1) | ||
latticeSize::Int = size(mat)[1] | ||
|
||
dsMat = mat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes a copy of mat if necessary and avoids it otherwise. Quite nice I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
Some rather minor comments
alright i think i got everything |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 👍
src/algorithms/diamondsquare.jl
Outdated
""" | ||
DiamondSquare | ||
|
||
This type generates a neutral landscape using the diamond-sqaures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sqaures->squares
end | ||
_diamondsquare!(dsMat, alg) | ||
|
||
mat .= dsMat[1:size(mat)[1], 1:size(mat)[2]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this maybe use the center rectangle rather than top-right one? Note sure if it makes a difference. @gottacatchenall
A few things that need to be address before I go to much further
Diamond-Square can only be run on a matrix of size
N
byN
whereN=(2^n)+1
for some integern
. The two options would be to A) assertmat
in_landscape!(mat, alg::DiamondSquare)
is the right size, or B) run DS on the smallestNxN
matrix that could containmat
and superimpose from the result ontomat
. I lean toward A) because there's no hidden memory allocation behind the scenesThere is a way to implement DS recursively, but I think it is (somehow) even less elegant than the triple-loop at the moment. I'd be willing to give it a shot though