This is an automated email from the ASF dual-hosted git repository.
baunsgaard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/main by this push:
new 75cf454e28 [MINOR] Remove exception in cast as IntArray
75cf454e28 is described below
commit 75cf454e282100be722a3dc9805d941dc16ee770
Author: Sebastian Baunsgaard <[email protected]>
AuthorDate: Tue Jan 30 14:01:45 2024 +0100
[MINOR] Remove exception in cast as IntArray
This commit removes the exception in cast as IntArray from DoubleArray.
We encounter an issue in this conversion for large numbers of double
values, that does not cast perfectly to the same double values when
casting the integer values back to doubles.
The script that reproduce the bug is:
```
k = ifdef($k, 5)
paq = ifdef($paq, 1)
X = round(rand(rows = 50, cols = 10, min=1, max=10))
y = X %*% rand(rows = ncol(X), cols = 1)
w = lm(X = X, y = y)
yhat = X %*% w
ress = slicefinder(X = X, e = abs(y - yhat), k = k, maxL = 0, minSup =
1, alpha = 1, selFeat = TRUE, verbose = TRUE)
print(toString(ress))
```
A subsequent commits add a test case that ensure this bug does not
happen again.
---
.../sysds/runtime/frame/data/columns/DoubleArray.java | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git
a/src/main/java/org/apache/sysds/runtime/frame/data/columns/DoubleArray.java
b/src/main/java/org/apache/sysds/runtime/frame/data/columns/DoubleArray.java
index 68672c5d73..8835b7c21c 100644
--- a/src/main/java/org/apache/sysds/runtime/frame/data/columns/DoubleArray.java
+++ b/src/main/java/org/apache/sysds/runtime/frame/data/columns/DoubleArray.java
@@ -293,33 +293,24 @@ public class DoubleArray extends Array<Double> {
@Override
protected Array<Integer> changeTypeInteger() {
int[] ret = new int[size()];
- for(int i = 0; i < size(); i++) {
- if(_data[i] != (int) _data[i])
- throw new DMLRuntimeException("Unable to change
to Integer from Double array because of value:" + _data[i]);
+ for(int i = 0; i < size(); i++)
ret[i] = (int) _data[i];
- }
return new IntegerArray(ret);
}
@Override
protected Array<Long> changeTypeLong() {
long[] ret = new long[size()];
- for(int i = 0; i < size(); i++) {
- if(_data[i] != (long) _data[i])
- throw new DMLRuntimeException("Unable to change
to Long from Double array because of value:" + _data[i]);
+ for(int i = 0; i < size(); i++)
ret[i] = (long) _data[i];
- }
return new LongArray(ret);
}
@Override
protected Array<Object> changeTypeHash64() {
long[] ret = new long[size()];
- for(int i = 0; i < size(); i++) {
- if(_data[i] != (long) _data[i])
- throw new DMLRuntimeException("Unable to change
to Long from Double array because of value:" + _data[i]);
+ for(int i = 0; i < size(); i++)
ret[i] = (long) _data[i];
- }
return new HashLongArray(ret);
}