use of org.flyte.api.v1.Variable in project vcell by virtualcell.
the class NetCDFReader method getStartTime.
/**
* Get starting time. 0 dimension.
* @return double, starting time.
*/
public double getStartTime() throws IOException {
Variable v = ncfile.findVariable("TStart");
Double val = 0.0;
try {
val = v.readScalarDouble();
} catch (IOException ioe) {
ioe.printStackTrace(System.err);
throw new IOException("Cannot get proper starting time from the model.");
}
return val;
}
use of org.flyte.api.v1.Variable in project vcell by virtualcell.
the class NetCDFRefDataReader method getRegionVar_one.
public double[] getRegionVar_one(int roiIdx) throws IOException {
if ((this != null) && (getRegionVariable() != null)) {
Variable regionVars = getRegionVariable();
int[] shape = regionVars.getShape();
ArrayDouble.D2 data = null;
try {
data = (ArrayDouble.D2) regionVars.read();
} catch (Exception e) {
e.printStackTrace(System.err);
throw new IOException("Can not read species' names from the model.");
}
int numTimePoints = shape[0];
double[] values = new double[numTimePoints];
for (int i = 0; i < numTimePoints; i++) {
values[i] = data.get(i, roiIdx);
}
// }
return values;
}
return null;
}
use of org.flyte.api.v1.Variable in project packages-jpl by SWI-Prolog.
the class Test method test_6.
static void test_6() {
System.out.print("test 6...");
Variable X = new Variable("X");
Query q6 = new Query("p", new Term[] { X, X });
Term[] x_target = new Term[] { a };
Map<String, Term>[] solutions = q6.allSolutions();
if (solutions.length != 1) {
System.out.println("p(X, X) failed:");
System.out.println("\tExpected: 1 solution");
System.out.println("\tGot: " + solutions.length);
// System.exit(1);
}
for (int i = 0; i < solutions.length; ++i) {
Object x_binding = solutions[i].get("X");
if (!x_binding.equals(x_target[i])) {
System.out.println("p(X, X) failed:");
System.out.println("\tExpected: " + x_target[i]);
System.out.println("\tGot: " + x_binding);
// System.exit(1);
}
}
System.out.println("passed");
}
use of org.flyte.api.v1.Variable in project packages-jpl by SWI-Prolog.
the class Test method test_5.
static void test_5() {
System.out.print("test 5...");
Variable X = new Variable("X");
Variable Y = new Variable("Y");
Query q5 = new Query("p", new Term[] { X, Y });
Term[] x_target = new Term[] { a, a };
Term[] y_target = new Term[] { a, b };
Map<String, Term>[] solutions = q5.allSolutions();
if (solutions.length != 2) {
System.out.println("p(X, Y) failed:");
System.out.println("\tExpected: 2 solutions");
System.out.println("\tGot: " + solutions.length);
// System.exit(1);
}
for (int i = 0; i < solutions.length; ++i) {
Term x_binding = solutions[i].get("X");
if (!x_binding.equals(x_target[i])) {
System.out.println("p(X, Y) failed:");
System.out.println("\tExpected: " + x_target[i]);
System.out.println("\tGot: " + x_binding);
// System.exit(1);
}
Term y_binding = solutions[i].get("Y");
if (!y_binding.equals(y_target[i])) {
System.out.println("p( X, Y ) failed:");
System.out.println("\tExpected: " + y_target[i]);
System.out.println("\tGot: " + y_binding);
// System.exit(1);
}
}
System.out.println("passed");
}
use of org.flyte.api.v1.Variable in project packages-jpl by SWI-Prolog.
the class Test method test_4.
static void test_4() {
System.out.print("test 4...");
Variable X = new Variable("X");
Query q4 = new Query("p", new Term[] { X });
Term[] target = new Term[] { a, f_a, pair_a_b, new Variable("_") };
Map<String, Term>[] solutions = q4.allSolutions();
if (solutions.length != 4) {
System.out.println("p(X) failed:");
System.out.println("\tExpected: 4 solutions");
System.out.println("\tGot: " + solutions.length);
// System.exit(1);
}
for (int i = 0; i < solutions.length - 1; ++i) {
Term binding = (Term) solutions[i].get("X");
if (!binding.equals(target[i])) {
System.out.println("p(X) failed");
System.out.println("\tExpected: " + target[i]);
System.out.println("\tGot: " + binding);
// System.exit(1);
}
}
System.out.println("passed");
}
Aggregations