You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If a value list longer than the weight matrix dimensions is given to the moran function, it skews the result, as no check for that exists.
To Reproduce
Load Moran Index.gaml from the library.
Optional : run the model and change the parameter to checkerboard pattern to check that the value of Moran I is indeed -1.
Add one or more values to the vals list, e.g. by adding something like vals <+ 100.0; before line 49.
Run the model with checkerboard. No error is thrown, yet an I value different of -1 is given (about -0.008 in the example above).
Expected behavior
An error to be returned whenever the sizes of the inputs of the function are the same (length of the list and width and height of the weight matrix).
Proposed fix
Add a check in the moranIndex function that vals.size() must be equal to weightMatrix.numCols * weightMatrix.numRows.
Desktop (please complete the following information):
So here is a fix that I am not authorised to push (ERROR: Permission to gama-platform/gama.git denied to ScriBanana. (git); Can't connect to any repository: git@github.com:gama-platform/gama.git (git@github.com:gama-platform/gama.git: push not permitted) (Eclipse)).
Add following lines to msi.gama.core/src/msi/gaml/operators/Spatial.java (right after 7263):
7264if (N != weightMatrix.numRows * weightMatrix.numCols) throwGamaRuntimeException7265 .error("The lengths of the value list and of the weight matrix do not match", scope);
It is tested and working (1.9.2).
Edit : So, I sent a pull request with the fix. It is my first time doing such a thing on a big project on Github. Please point to (and forgive 🙂 ) any mistake I may have made in this process.
Hi,
Describe the bug
If a value list longer than the weight matrix dimensions is given to the
moran
function, it skews the result, as no check for that exists.To Reproduce
Moran Index.gaml
from the library.vals
list, e.g. by adding something likevals <+ 100.0;
before line 49.Expected behavior
An error to be returned whenever the sizes of the inputs of the function are the same (length of the list and width and height of the weight matrix).
Proposed fix
Add a check in the
moranIndex
function thatvals.size()
must be equal toweightMatrix.numCols * weightMatrix.numRows
.Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: