Adding non-overloaded method signatures for adding 1D vs 2D observations for common class for continuous MI and CMI estimators, since JPype 0.7 does not seem able to resolve overloaded 1D vs 2D arrays any longer

This commit is contained in:
Joseph Lizier 2019-07-25 23:11:44 +10:00
parent 1667b9fe7a
commit 2ab3ac01bb
2 changed files with 105 additions and 0 deletions

View File

@ -264,6 +264,19 @@ public abstract class ConditionalMutualInfoMultiVariateCommon implements
addedMoreThanOneObservationSet = false;
}
/**
* A non-overloaded method signature for setObservations with 2D arguments, as there have been
* some problems calling overloaded versions of setObservations from jpype.
*
* @param var1
* @param var2
* @param cond
* @throws Exception
*/
public void setObservations2D(double[][] var1, double[][] var, double[][] cond) throws Exception {
setObservations(var1, var, cond);
}
@Override
public void setObservations(double[] var1, double[] var2,
double[] cond) throws Exception {
@ -273,6 +286,19 @@ public abstract class ConditionalMutualInfoMultiVariateCommon implements
addedMoreThanOneObservationSet = false;
}
/**
* A non-overloaded method signature for setObservations with 1D arguments, as there have been
* some problems calling overloaded versions of setObservations from jpype.
*
* @param var1
* @param var2
* @param cond
* @throws Exception
*/
public void setObservations1D(double[] var1, double[] var, double[] cond) throws Exception {
setObservations(var1, var, cond);
}
@Override
public void startAddObservations() {
vectorOfVar1Observations = new Vector<double[][]>();
@ -312,6 +338,19 @@ public abstract class ConditionalMutualInfoMultiVariateCommon implements
}
}
/**
* A non-overloaded method signature for addObservations with 2D arguments, as there have been
* some problems calling overloaded versions of setObservations from jpype.
*
* @param var1
* @param var2
* @param cond
* @throws Exception
*/
public void addObservations2D(double[][] var1, double[][] var, double[][] cond) throws Exception {
addObservations(var1, var, cond);
}
@Override
public void addObservations(double[] var1, double[] var2,
double[] cond) throws Exception {
@ -329,6 +368,19 @@ public abstract class ConditionalMutualInfoMultiVariateCommon implements
}
/**
* A non-overloaded method signature for addObservations with 1D arguments, as there have been
* some problems calling overloaded versions of setObservations from jpype.
*
* @param var1
* @param var2
* @param cond
* @throws Exception
*/
public void addObservations1D(double[] var1, double[] var, double[] cond) throws Exception {
addObservations(var1, var, cond);
}
@Override
public void addObservations(double[][] var1, double[][] var2,
double[][] cond,

View File

@ -244,23 +244,51 @@ public abstract class MutualInfoMultiVariateCommon implements
}
}
@Override
public void setObservations(double[][] source, double[][] destination) throws Exception {
startAddObservations();
addObservations(source, destination);
finaliseAddObservations();
}
/**
* A non-overloaded method signature for setObservations with 2D arguments, as there have been
* some problems calling overloaded versions of setObservations from jpype.
*
* @param source
* @param destination
* @throws Exception
*/
public void setObservations2D(double[][] source, double[][] destination) throws Exception {
setObservations(source, destination);
}
@Override
public void setObservations(double[] source, double[] destination) throws Exception {
startAddObservations();
addObservations(source, destination);
finaliseAddObservations();
}
/**
* A non-overloaded method signature for setObservations with 1D arguments, as there have been
* some problems calling overloaded versions of setObservations from jpype.
*
* @param source
* @param destination
* @throws Exception
*/
public void setObservations1D(double[] source, double[] destination) throws Exception {
setObservations(source, destination);
}
@Override
public void startAddObservations() {
vectorOfSourceObservations = new Vector<double[][]>();
vectorOfDestinationObservations = new Vector<double[][]>();
}
@Override
public void addObservations(double[][] source, double[][] destination) throws Exception {
if (vectorOfSourceObservations == null) {
// startAddObservations was not called first
@ -286,6 +314,19 @@ public abstract class MutualInfoMultiVariateCommon implements
vectorOfDestinationObservations.add(destination);
}
/**
* A non-overloaded method signature for addObservations with 2D arguments, as there have been
* some problems calling overloaded versions of setObservations from jpype.
*
* @param source
* @param destination
* @throws Exception
*/
public void addObservations2D(double[][] source, double[][] destination) throws Exception {
addObservations(source, destination);
}
@Override
public void addObservations(double[] source, double[] destination) throws Exception {
if ((dimensionsDest != 1) || (dimensionsSource != 1)) {
@ -298,6 +339,18 @@ public abstract class MutualInfoMultiVariateCommon implements
MatrixUtils.reshape(destination, destination.length, 1));
}
/**
* A non-overloaded method signature for addObservations with 1D arguments, as there have been
* some problems calling overloaded versions of setObservations from jpype.
*
* @param source
* @param destination
* @throws Exception
*/
public void addObservations1D(double[] source, double[] destination) throws Exception {
addObservations(source, destination);
}
public void addObservations(double[][] source, double[][] destination,
int startTime, int numTimeSteps) throws Exception {
if (vectorOfSourceObservations == null) {