Skip to content
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

error in numerical checking when only 1 record exists in matrix; not encountered in current CA setup #88

Open
aldivi opened this issue Jun 8, 2021 · 0 comments

Comments

@aldivi
Copy link
Owner

aldivi commented Jun 8, 2021

first found in line 3814 (by steve bassett)
fix is to add drop = F so that the matrix is not converted to a vector:
conv_own[,conv_own$Land_Type] <- apply(conv_own[,conv_own$Land_Type,drop=F], 2, function (x) {replace(x, x < 0, 0.00)})

This also happens with extraction in line 3833. The fix here is to check for length:

If conv_col_names has length < 2, and if so treat this replacement as a vector. But you also have to check whether zinds contains an index indicating that this column adds to zero:
if (length(conv_col_names < 2) & length(zinds) > 0) {
conv_own[,conv_col_names][,zinds] = -conv_own2[,conv_col_names][,zinds]
} else {
conv_own[,conv_col_names][,zinds] = -conv_own2[,conv_col_names][,zinds]
}

Note that in the original, it is ok if zinds has length zero because nothing gets changed (i am not sure that it can even have length zero, so maybe it doesn't matter in the new case either, but you don't want to do the replacement if there are no zinds)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant