[casacore] r21168 committed - Added operator ~=...

0 views
Skip to first unread message

casa...@googlecode.com

unread,
Jan 4, 2012, 3:12:18 AM1/4/12
to casacor...@googlegroups.com
Revision: 21168
Author: gervandiepen
Date: Wed Jan 4 00:11:03 2012
Log: Added operator ~=
Added :: to table name to denote subtables
Fixed ranges like 1:2:0.3
Added function transpose and angdistx
Made addition of array to a datetime possible

http://code.google.com/p/casacore/source/detail?r=21168

Modified:
/trunk/tables/Tables/ConcatTable.cc
/trunk/tables/Tables/ExprFuncNode.cc
/trunk/tables/Tables/ExprFuncNode.h
/trunk/tables/Tables/ExprFuncNodeArray.cc
/trunk/tables/Tables/ExprFuncNodeArray.h
/trunk/tables/Tables/ExprMathNodeArray.cc
/trunk/tables/Tables/ExprMathNodeArray.h
/trunk/tables/Tables/ExprNode.cc
/trunk/tables/Tables/ExprNodeRep.cc
/trunk/tables/Tables/ExprNodeSet.cc
/trunk/tables/Tables/ExprNodeSet.h
/trunk/tables/Tables/Table.cc
/trunk/tables/Tables/Table.h
/trunk/tables/Tables/TableGram.ll
/trunk/tables/Tables/TableGram.yy
/trunk/tables/Tables/TableParse.cc
/trunk/tables/Tables/TableParse.h
/trunk/tables/Tables/TableProxy.cc
/trunk/tables/Tables/test/tExprNodeSet.cc
/trunk/tables/Tables/test/tTableKeywords.cc
/trunk/tables/apps/taql.cc

=======================================
--- /trunk/tables/Tables/ConcatTable.cc Tue Jan 3 04:37:20 2012
+++ /trunk/tables/Tables/ConcatTable.cc Wed Jan 4 00:11:03 2012
@@ -435,7 +435,7 @@

TableDesc ConcatTable::actualTableDesc() const
{
- return baseTabPtr_p[0]->actualTableDesc();
+ return *tdescPtr_p;
}

Record ConcatTable::dataManagerInfo() const
=======================================
--- /trunk/tables/Tables/ExprFuncNode.cc Sun Dec 11 23:57:36 2011
+++ /trunk/tables/Tables/ExprFuncNode.cc Wed Jan 4 00:11:03 2012
@@ -258,19 +258,19 @@
case nearabs3FUNC:
makeEqualUnits (nodes, 0, 3);
break;
+ case angdistFUNC:
+ case angdistxFUNC:
+ node->setUnit ("rad");
+ // fall through
case conesFUNC:
case cones3FUNC:
case anyconeFUNC:
case anycone3FUNC:
case findconeFUNC:
case findcone3FUNC:
- case angdistFUNC:
for (uInt i=0; i<nodes.nelements(); ++i) {
TableExprNodeUnit::adaptUnit (nodes[i], "rad");
}
- if (func == angdistFUNC) {
- node->setUnit ("rad");
- }
break;
default:
// Several functions (e.g. intFUNC, powFUNC) do not set units
@@ -764,20 +764,25 @@
return operands_p[0]->getBool(id) ?
operands_p[1]->getDouble(id) : operands_p[2]->getDouble(id);
case angdistFUNC:
+ case angdistxFUNC:
{
Array<double> a1 = operands_p[0]->getArrayDouble(id);
Array<double> a2 = operands_p[1]->getArrayDouble(id);
if (!(a1.size() == 2 && a1.contiguousStorage() &&
a2.size() == 2 && a2.contiguousStorage())) {
- throw TableInvExpr ("Arguments of angdist function must have a "
+ throw TableInvExpr ("Arguments of angdist(x) function must have
a "
"multiple of 2 values");
}
const double* d1 = a1.data();
const double* d2 = a2.data();
return angdist (d1[0], d1[1], d2[0], d2[1]);
}
+ case datetimeFUNC:
+ case mjdtodateFUNC:
+ case dateFUNC:
+ return getDate(id); // automatic conversion of MVTime to double
default:
- // Functions like MJD are implemented as Int only.
+ // Functions like YEAR are implemented as Int.
return getInt(id);
}
return 0;
@@ -1127,10 +1132,11 @@
checkNumOfArg (1, 1, nodes);
return checkDT (dtypeOper, NTAny, NTBool, nodes);
case angdistFUNC:
+ case angdistxFUNC:
checkNumOfArg (2, 2, nodes);
if (nodes[0]->valueType() != VTArray ||
nodes[1]->valueType() != VTArray) {
- throw TableInvExpr ("Arguments of angdist function "
+ throw TableInvExpr ("Arguments of angdist(x) function "
"have to be arrays");
}
if (nodes[0]->shape().product() != 2 ||
@@ -1182,6 +1188,7 @@
case boxanyFUNC:
case boxallFUNC:
case arrayFUNC:
+ case transposeFUNC:
{
// Most functions can have Int or Double in and result in Double.
dtin = NTReal;
@@ -1210,6 +1217,7 @@
dtout = NTInt;
break;
case arrayFUNC:
+ case transposeFUNC:
dtin = dtout = NTAny;
break;
default:
@@ -1221,11 +1229,12 @@
checkNumOfArg (axarg+1, axarg+1, nodes);
dtypeOper.resize(axarg+1);
dtypeOper = NTReal;
- // Check for XXXs and run/boxXXX functions if first argument is array.
+ // Check if first argument is array.
if (fType != arrayFUNC) {
if (nodes[0]->valueType() != VTArray) {
- throw TableInvExpr ("1st argument of xxxS function "
- "has to be an array");
+ throw TableInvExpr ("1st argument of function " +
+ String::toString(fType) +
+ " has to be an array");
}
}
// Check if first argument has correct type.
@@ -1240,14 +1249,16 @@
if (nodes[i]->valueType() != VTScalar ||
(nodes[i]->dataType() != NTInt &&
nodes[i]->dataType() != NTDouble)) {
- throw TableInvExpr ("2nd argument of fractile functions "
+ throw TableInvExpr ("2nd argument of fractile function "
"has to be an real scalar");
}
}
}
if (nodes[axarg]->dataType() != NTInt) {
throw TableInvExpr ("The axes arguments of runningXXX, boxedXXX,
or "
- "XXXs function have to be integers");
+ "XXXs function " +
+ String::toString(fType) +
+ " have to be integers");
}
// The last argument forms the axes as an array object.
AlwaysAssert (nodes[axarg]->valueType() == VTArray, AipsError);
@@ -1264,8 +1275,8 @@
if (vt == VTArray) {
resVT = vt;
} else if (vt != VTScalar) {
- throw (TableInvExpr
- ("Function has to have a scalar or array
argument"));
+ throw TableInvExpr ("Function " + String::toString(fType) +
+ " has to have a scalar or array argument");
}
}
switch (fType) {
@@ -1475,7 +1486,8 @@
// The following functions accept scalars only (or no arguments).
for (i=0; i< nodes.nelements(); i++) {
if (nodes[i]->valueType() != VTScalar) {
- throw (TableInvExpr ("Function has to have a scalar argument"));
+ throw TableInvExpr ("Function " + String::toString(fType) +
+ " has to have a scalar argument");
}
}
switch (fType) {
@@ -1496,7 +1508,8 @@
return checkDT (dtypeOper, NTString, NTRegex, nodes);
default:
throw (TableInvExpr ("TableExprFuncNode::checkOperands, "
- "function not contained in switch statement"));
+ "function " + String::toString(fType) +
+ " not contained in switch statement"));
}
return NTNumeric;
}
=======================================
--- /trunk/tables/Tables/ExprFuncNode.h Sun Dec 11 23:57:36 2011
+++ /trunk/tables/Tables/ExprFuncNode.h Wed Jan 4 00:11:03 2012
@@ -77,177 +77,179 @@
public:
//# Define the function types.
enum FunctionType {
- piFUNC,
- eFUNC,
- cFUNC,
+ piFUNC, //# 0
+ eFUNC, //# 1
+ cFUNC, //# 2
// for Int, or Double or Complex returning Bool
// (2 is with default tolerance)
- near2FUNC,
- near3FUNC,
- nearabs2FUNC,
- nearabs3FUNC,
+ near2FUNC, //# 3
+ near3FUNC, //# 4
+ nearabs2FUNC, //# 5
+ nearabs3FUNC, //# 6
// for Int, Double or DComplex returning Double or Complex
- sinFUNC,
- sinhFUNC,
- cosFUNC,
- coshFUNC,
- expFUNC,
- logFUNC,
- log10FUNC,
- sqrtFUNC,
- powFUNC,
- conjFUNC,
+ sinFUNC, //# 7
+ sinhFUNC, //# 8
+ cosFUNC, //# 9
+ coshFUNC, //# 10
+ expFUNC, //# 11
+ logFUNC, //# 12
+ log10FUNC, //# 13
+ sqrtFUNC, //# 14
+ powFUNC, //# 15
+ conjFUNC, //# 16
// for Int, Double or DComplex returning Int, Double or Complex
- squareFUNC,
- cubeFUNC,
- minFUNC,
- maxFUNC,
+ squareFUNC, //# 17
+ cubeFUNC, //# 18
+ minFUNC, //# 19
+ maxFUNC, //# 20
// for Int, Double or DComplex returning Int or Double
- normFUNC,
- absFUNC,
- argFUNC,
+ normFUNC, //# 21
+ absFUNC, //# 22
+ argFUNC, //# 23
// for Int, Double or DComplex returning Double
- realFUNC,
- imagFUNC,
+ realFUNC, //# 24
+ imagFUNC, //# 25
// for Int or Double returning Int (using floor)
- intFUNC,
+ intFUNC, //# 26
// for Int or Double returning Double
- asinFUNC,
- acosFUNC,
- atanFUNC,
- atan2FUNC,
- tanFUNC,
- tanhFUNC,
+ asinFUNC, //# 27
+ acosFUNC, //# 28
+ atanFUNC, //# 29
+ atan2FUNC, //# 30
+ tanFUNC, //# 31
+ tanhFUNC, //# 32
// for Int or Double returning Int or Double
- signFUNC,
- roundFUNC,
- floorFUNC,
- ceilFUNC,
- fmodFUNC,
+ signFUNC, //# 33
+ roundFUNC, //# 34
+ floorFUNC, //# 35
+ ceilFUNC, //# 36
+ fmodFUNC, //# 37
// for Int, Double or DComplex returning DComplex
- complexFUNC,
+ complexFUNC, //# 38
// for Int, Double or Complex array returning the same
- arrsumFUNC,
- arrsumsFUNC,
- arrproductFUNC,
- arrproductsFUNC,
- arrsumsqrFUNC,
- arrsumsqrsFUNC,
+ arrsumFUNC, //# 39
+ arrsumsFUNC, //# 40
+ arrproductFUNC, //# 41
+ arrproductsFUNC, //# 42
+ arrsumsqrFUNC, //# 43
+ arrsumsqrsFUNC, //# 44
// for Int or Double array returning Int or Double
- arrminFUNC,
- arrminsFUNC,
- runminFUNC,
- boxminFUNC,
- arrmaxFUNC,
- arrmaxsFUNC,
- runmaxFUNC,
- boxmaxFUNC,
+ arrminFUNC, //# 45
+ arrminsFUNC, //# 46
+ runminFUNC, //# 47
+ boxminFUNC, //# 48
+ arrmaxFUNC, //# 49
+ arrmaxsFUNC, //# 50
+ runmaxFUNC, //# 51
+ boxmaxFUNC, //# 52
// for Int or Double array returning Double
- arrmeanFUNC,
- arrmeansFUNC,
- runmeanFUNC,
- boxmeanFUNC,
- arrvarianceFUNC,
- arrvariancesFUNC,
- runvarianceFUNC,
- boxvarianceFUNC,
- arrstddevFUNC,
- arrstddevsFUNC,
- runstddevFUNC,
- boxstddevFUNC,
- arravdevFUNC,
- arravdevsFUNC,
- runavdevFUNC,
- boxavdevFUNC,
- arrrmsFUNC,
- arrrmssFUNC,
- runrmsFUNC,
- boxrmsFUNC,
- arrmedianFUNC,
- arrmediansFUNC,
- runmedianFUNC,
- boxmedianFUNC,
- arrfractileFUNC,
- arrfractilesFUNC,
+ arrmeanFUNC, //# 53
+ arrmeansFUNC, //# 54
+ runmeanFUNC, //# 55
+ boxmeanFUNC, //# 56
+ arrvarianceFUNC, //# 57
+ arrvariancesFUNC, //# 58
+ runvarianceFUNC, //# 59
+ boxvarianceFUNC, //# 60
+ arrstddevFUNC, //# 61
+ arrstddevsFUNC, //# 62
+ runstddevFUNC, //# 63
+ boxstddevFUNC, //# 64
+ arravdevFUNC, //# 65
+ arravdevsFUNC, //# 66
+ runavdevFUNC, //# 67
+ boxavdevFUNC, //# 68
+ arrrmsFUNC, //# 69
+ arrrmssFUNC, //# 70
+ runrmsFUNC, //# 71
+ boxrmsFUNC, //# 72
+ arrmedianFUNC, //# 73
+ arrmediansFUNC, //# 74
+ runmedianFUNC, //# 75
+ boxmedianFUNC, //# 76
+ arrfractileFUNC, //# 77
+ arrfractilesFUNC, //# 78
// for Bool array returning Bool
- anyFUNC,
- anysFUNC,
- runanyFUNC,
- boxanyFUNC,
- allFUNC,
- allsFUNC,
- runallFUNC,
- boxallFUNC,
+ anyFUNC, //# 79
+ anysFUNC, //# 80
+ runanyFUNC, //# 81
+ boxanyFUNC, //# 82
+ allFUNC, //# 83
+ allsFUNC, //# 84
+ runallFUNC, //# 85
+ boxallFUNC, //# 86
// for Bool array returning Int scalar
- ntrueFUNC,
- ntruesFUNC,
- gnfalseFUNC,
- nfalseFUNC,
- nfalsesFUNC,
+ ntrueFUNC, //# 87
+ ntruesFUNC, //# 88
+ gnfalseFUNC, //# 89
+ nfalseFUNC, //# 90
+ nfalsesFUNC, //# 91
// for any type returning array of that type
- arrayFUNC,
+ arrayFUNC, //# 92
+ transposeFUNC, //# 93
// for Int, Double or DComplex array returning Bool
- isnanFUNC,
- isinfFUNC,
- isfiniteFUNC,
+ isnanFUNC, //# 94
+ isinfFUNC, //# 95
+ isfiniteFUNC, //# 96
// for any array returning Bool scalar
- isdefFUNC,
+ isdefFUNC, //# 97
// for any array returning Int scalar
- ndimFUNC,
- nelemFUNC,
+ ndimFUNC, //# 98
+ nelemFUNC, //# 99
// for any array returning Int array
- shapeFUNC,
+ shapeFUNC, //# 100
// for String
- strlengthFUNC, //# returning Int
- upcaseFUNC, //# returning String
- downcaseFUNC, //# returning String
- trimFUNC, //# returning String
- ltrimFUNC, //# returning String
- rtrimFUNC, //# returning String
- substrFUNC, //# returning String
- replaceFUNC, //# returning String
- regexFUNC, //# returning TaqlRegex
- patternFUNC, //# returning TaqlRegex
- sqlpatternFUNC, //# returning TaqlRegex
+ strlengthFUNC, //# 101 returning Int
+ upcaseFUNC, //# 102 returning String
+ downcaseFUNC, //# 103 returning String
+ trimFUNC, //# 104 returning String
+ ltrimFUNC, //# 105 returning String
+ rtrimFUNC, //# 106 returning String
+ substrFUNC, //# 107 returning String
+ replaceFUNC, //# 108 returning String
+ regexFUNC, //# 109 returning TaqlRegex
+ patternFUNC, //# 110 returning TaqlRegex
+ sqlpatternFUNC, //# 111 returning TaqlRegex
// for Date
- datetimeFUNC, //# returning Date
- mjdtodateFUNC, //# returning Date
- mjdFUNC, //# returning Double
- dateFUNC, //# returning Date
- timeFUNC, //# returning Double (in radians)
- yearFUNC, //# returning Int
- monthFUNC, //# returning Int
- dayFUNC, //# returning Int
- cmonthFUNC, //# returning String
- weekdayFUNC, //# returning Int
- cdowFUNC, //# returning String
- weekFUNC, //# returning Int
- ctodFUNC, //# returning String
- cdateFUNC, //# returning String
- ctimeFUNC, //# returning String
+ datetimeFUNC, //# 112 returning Date
+ mjdtodateFUNC, //# 113 returning Date
+ mjdFUNC, //# 114 returning Double
+ dateFUNC, //# 115 returning Date
+ timeFUNC, //# 116 returning Double (in radians)
+ yearFUNC, //# 117 returning Int
+ monthFUNC, //# 118 returning Int
+ dayFUNC, //# 119 returning Int
+ cmonthFUNC, //# 120 returning String
+ weekdayFUNC, //# 121 returning Int
+ cdowFUNC, //# 122 returning String
+ weekFUNC, //# 123 returning Int
+ ctodFUNC, //# 124 returning String
+ cdateFUNC, //# 125 returning String
+ ctimeFUNC, //# 126 returning String
// return angles as hms strings
- hmsFUNC,
+ hmsFUNC, //# 127
// return angles as dms strings
- dmsFUNC,
+ dmsFUNC, //# 128
// return angles as hms/dms strings
- hdmsFUNC,
+ hdmsFUNC, //# 129
// special function returning a random Double number
- randFUNC,
+ randFUNC, //# 130
// special function returning Int row number
- rownrFUNC,
+ rownrFUNC, //# 131
// special function returning Int row id (meant for GIVING)
- rowidFUNC,
+ rowidFUNC, //# 132
// special function resembling if statement
- iifFUNC,
+ iifFUNC, //# 133
// angular distance returning radians
- angdistFUNC,
+ angdistFUNC, //# 134
+ angdistxFUNC, //# 135
// other functions, implemented in derived class
- conesFUNC,
- cones3FUNC,
- anyconeFUNC,
- anycone3FUNC,
- findconeFUNC,
- findcone3FUNC,
+ conesFUNC, //# 136
+ cones3FUNC, //# 137
+ anyconeFUNC, //# 138
+ anycone3FUNC, //# 139
+ findconeFUNC, //# 140
+ findcone3FUNC, //# 141
NRFUNC //# should be last
};

=======================================
--- /trunk/tables/Tables/ExprFuncNodeArray.cc Sun Dec 11 23:57:36 2011
+++ /trunk/tables/Tables/ExprFuncNodeArray.cc Wed Jan 4 00:11:03 2012
@@ -110,7 +110,7 @@
case TableExprFuncNode::ntruesFUNC:
case TableExprFuncNode::nfalsesFUNC:
if (operands()[axarg]->isConstant()) {
- ipos_p = getCollapseAxes (0, -1, axarg);
+ ipos_p = getAxes (0, -1, axarg);
constAxes_p = True;
}
break;
@@ -119,6 +119,12 @@
ipos_p = getArrayShape (0, axarg);
constAxes_p = True;
}
+ break;
+ case TableExprFuncNode::transposeFUNC:
+ if (operands()[axarg]->isConstant()) {
+ ipos_p = getAxes (0, -1, axarg, False);
+ constAxes_p = True;
+ }
break;
default:
break;
@@ -126,17 +132,18 @@
}


-const IPosition& TableExprFuncNodeArray::getCollapseAxes(const
TableExprId& id,
- Int ndim, uInt axarg)
+IPosition TableExprFuncNodeArray::getAxes (const TableExprId& id,
+ Int ndim, uInt axarg,
+ bool swapRemove)
{
// Get the axes if not constant (or not known).
if (!constAxes_p) {
- Array<Double> ax(operands()[axarg]->getArrayDouble(id));
+ Array<Int64> ax(operands()[axarg]->getArrayInt(id));
AlwaysAssert (ax.ndim() == 1, AipsError);
AlwaysAssert (ax.contiguousStorage(), AipsError);
ipos_p.resize (ax.nelements());
for (uInt i=0; i<ax.nelements(); i++) {
- ipos_p(i) = Int(ax.data()[i]) - origin_p;
+ ipos_p(i) = ax.data()[i] - origin_p;
}
iposN_p = ipos_p;
}
@@ -144,31 +151,51 @@
uInt nr = 0;
for (uInt i=0; i<ipos_p.nelements(); i++) {
if (ipos_p(i) < 0) {
- throw TableInvExpr ("collapseAxis < 0 used in xxxs function");
+ throw TableInvExpr ("axis < 0 used in xxxs function");
}
if (ndim < 0) {
nr = ipos_p.nelements();
} else {
if (ipos_p(i) < ndim) {
// Correct for possible specification in C-order.
- // Note that the collapse axes order is not important.
- if (isCOrder_p) ipos_p(i) = ndim - iposN_p(i) - 1;
+ // Note that for collapse the axes order is not important,
+ // but it is for transpose.
+ if (isCOrder_p && swapRemove) {
+ ipos_p(i) = ndim - iposN_p(i) - 1;
+ }
nr++;
}
}
}
- if (nr == ipos_p.nelements()) {
+ if (nr == ipos_p.nelements() || !swapRemove) {
return ipos_p;
}
// Remove axes exceeding dimensionality.
- corrCollAxes_p.resize(nr);
+ return removeAxes (ipos_p, ndim);
+}
+
+IPosition TableExprFuncNodeArray::removeAxes (const IPosition& axes,
+ Int ndim) const
+{
+ // Count axes not exceeding ndim.
+ uInt nr=0;
+ for (uInt i=0; i<axes.size(); ++i) {
+ if (axes[i] < ndim) {
+ nr++;
+ }
+ }
+ if (nr == axes.size()) {
+ return axes;
+ }
+ // Remove the too high axes.
+ IPosition newAxes(nr);
uInt j=0;
- for (uInt i=0; i<ipos_p.nelements(); i++) {
- if (ipos_p(i) < ndim) {
- corrCollAxes_p(j++) = ipos_p(i);
+ for (uInt i=0; i<axes.size(); ++i) {
+ if (ipos_p[i] < ndim) {
+ newAxes[j++] = ipos_p[i];
}
}
- return corrCollAxes_p;
+ return newAxes;
}

const IPosition& TableExprFuncNodeArray::getArrayShape(const TableExprId&
id,
@@ -176,24 +203,40 @@
{
// Get the shape if not constant.
if (!constAxes_p) {
- Array<Double> ax(operands()[axarg]->getArrayDouble(id));
+ Array<Int64> ax(operands()[axarg]->getArrayInt(id));
AlwaysAssert (ax.ndim() == 1, AipsError);
AlwaysAssert (ax.contiguousStorage(), AipsError);
uInt ndim = ax.nelements();
ipos_p.resize (ndim);
if (isCOrder_p) {
for (uInt i=0; i<ndim; i++) {
- ipos_p(i) = Int(ax.data()[ndim-i-1]);
+ ipos_p(i) = ax.data()[ndim-i-1];
}
} else {
for (uInt i=0; i<ndim; i++) {
- ipos_p(i) = Int(ax.data()[i]);
+ ipos_p(i) = ax.data()[i];
}
}
}
return ipos_p;
}
-
+
+IPosition TableExprFuncNodeArray::getOrder (const TableExprId& id, Int
ndim)
+{
+ IPosition order = getAxes(id, ndim, 1, False);
+ cout <<"order="<< order<<endl;
+ if (order.empty()) {
+ // Default is to transpose the full array.
+ order.resize (ndim);
+ for (int i=0; i<ndim; ++i) {
+ order[i] = ndim-i-1;
+ }
+ return order;
+ }
+ // Remove possibly too high axes.
+ return removeAxes (order, ndim);
+}
+

Array<Bool> TableExprFuncNodeArray::getArrayBool (const TableExprId& id)
{
@@ -317,13 +360,13 @@
case TableExprFuncNode::anysFUNC:
{
Array<Bool> arr (operands()[0]->getArrayBool(id));
- Array<uInt> res (partialNTrue (arr, getCollapseAxes(id, arr.ndim())));
+ Array<uInt> res (partialNTrue (arr, getAxes(id, arr.ndim())));
return res > 0u;
}
case TableExprFuncNode::allsFUNC:
{
Array<Bool> arr (operands()[0]->getArrayBool(id));
- Array<uInt> res (partialNFalse (arr, getCollapseAxes(id, arr.ndim())));
+ Array<uInt> res (partialNFalse (arr, getAxes(id, arr.ndim())));
return res == 0u;
}
case TableExprFuncNode::runallFUNC:
@@ -370,6 +413,11 @@
}
return res;
}
+ case TableExprFuncNode::transposeFUNC:
+ {
+ Array<Bool> arr (operands()[0]->getArrayBool(id));
+ return reorderArray (arr, getOrder(id, arr.ndim()), False);
+ }
case TableExprFuncNode::isnanFUNC:
if (argDataType() == NTComplex) {
return isNaN (operands()[0]->getArrayDComplex(id));
@@ -463,8 +511,9 @@
return result;
}
default:
- throw (TableInvExpr ("TableExprFuncNodeArray::getArrayBool, "
- "unknown function"));
+ throw TableInvExpr ("TableExprFuncNodeArray::getArrayBool, "
+ "unknown function " +
+ String::toString(funcType()));
}
return Array<Bool>();
}
@@ -564,8 +613,9 @@
}
break;
default:
- throw (TableInvExpr ("TableExprFuncNodeArray::getArrayInt, "
- "unhandled date/time function"));
+ throw TableInvExpr ("TableExprFuncNodeArray::getArrayInt, "
+ "unhandled date/time function " +
+ String::toString(funcType()));
}
values.freeStorage (val, deleteVal);
res.putStorage (resp, deleteRes);
@@ -607,27 +657,27 @@
case TableExprFuncNode::arrsumsFUNC:
{
Array<Int64> arr (operands()[0]->getArrayInt(id));
- return partialSums (arr, getCollapseAxes(id, arr.ndim()));
+ return partialSums (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrproductsFUNC:
{
Array<Int64> arr (operands()[0]->getArrayInt(id));
- return partialProducts (arr, getCollapseAxes(id, arr.ndim()));
+ return partialProducts (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrsumsqrsFUNC:
{
Array<Int64> arr (operands()[0]->getArrayInt(id));
- return partialSums (arr*arr, getCollapseAxes(id, arr.ndim()));
+ return partialSums (arr*arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrminsFUNC:
{
Array<Int64> arr (operands()[0]->getArrayInt(id));
- return partialMins (arr, getCollapseAxes(id, arr.ndim()));
+ return partialMins (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrmaxsFUNC:
{
Array<Int64> arr (operands()[0]->getArrayInt(id));
- return partialMaxs (arr, getCollapseAxes(id, arr.ndim()));
+ return partialMaxs (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::runminFUNC:
{
@@ -652,7 +702,7 @@
case TableExprFuncNode::ntruesFUNC:
{
Array<Bool> arr (operands()[0]->getArrayBool(id));
- Array<uInt> res(partialNTrue (arr, getCollapseAxes(id, arr.ndim())));
+ Array<uInt> res(partialNTrue (arr, getAxes(id, arr.ndim())));
Array<Int64> resd(res.shape());
convertArray (resd, res);
return resd;
@@ -660,7 +710,7 @@
case TableExprFuncNode::nfalsesFUNC:
{
Array<Bool> arr (operands()[0]->getArrayBool(id));
- Array<uInt> res(partialNFalse (arr, getCollapseAxes(id, arr.ndim())));
+ Array<uInt> res(partialNFalse (arr, getAxes(id, arr.ndim())));
Array<Int64> resd(res.shape());
convertArray (resd, res);
return resd;
@@ -690,6 +740,11 @@
}
return res;
}
+ case TableExprFuncNode::transposeFUNC:
+ {
+ Array<Int64> arr (operands()[0]->getArrayInt(id));
+ return reorderArray (arr, getOrder(id, arr.ndim()), False);
+ }
case TableExprFuncNode::iifFUNC:
{
Array<Bool> arrc;
@@ -765,8 +820,9 @@
return result;
}
default:
- throw (TableInvExpr ("TableExprFuncNodeArray::getArrayInt, "
- "unknown function"));
+ throw TableInvExpr ("TableExprFuncNodeArray::getArrayInt, "
+ "unknown function " +
+ String::toString(funcType()));
}
return Array<Int64>();
}
@@ -954,63 +1010,63 @@
case TableExprFuncNode::arrsumsFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
- return partialSums (arr, getCollapseAxes(id, arr.ndim()));
+ return partialSums (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrproductsFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
- return partialProducts (arr, getCollapseAxes(id, arr.ndim()));
+ return partialProducts (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrsumsqrsFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
- return partialSums (arr*arr, getCollapseAxes(id, arr.ndim()));
+ return partialSums (arr*arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrminsFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
- return partialMins (arr, getCollapseAxes(id, arr.ndim()));
+ return partialMins (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrmaxsFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
- return partialMaxs (arr, getCollapseAxes(id, arr.ndim()));
+ return partialMaxs (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrmeansFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
- return partialMeans (arr, getCollapseAxes(id, arr.ndim()));
+ return partialMeans (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrvariancesFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
- return partialVariances (arr, getCollapseAxes(id, arr.ndim()));
+ return partialVariances (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrstddevsFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
- return partialStddevs (arr, getCollapseAxes(id, arr.ndim()));
+ return partialStddevs (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arravdevsFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
- return partialAvdevs (arr, getCollapseAxes(id, arr.ndim()));
+ return partialAvdevs (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrrmssFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
- return partialRmss (arr, getCollapseAxes(id, arr.ndim()));
+ return partialRmss (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrmediansFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
- return partialMedians (arr, getCollapseAxes(id, arr.ndim()));
+ return partialMedians (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrfractilesFUNC:
{
Array<Double> arr (operands()[0]->getArrayDouble(id));
return partialFractiles (arr,
- getCollapseAxes(id, arr.ndim(), 2),
+ getAxes(id, arr.ndim(), 2),
operands()[1]->getDouble(id));
}
case TableExprFuncNode::runminFUNC:
@@ -1117,6 +1173,11 @@
}
return res;
}
+ case TableExprFuncNode::transposeFUNC:
+ {
+ Array<Double> arr (operands()[0]->getArrayDouble(id));
+ return reorderArray (arr, getOrder(id, arr.ndim()), False);
+ }
case TableExprFuncNode::iifFUNC:
{
Array<Bool> arrc;
@@ -1192,11 +1253,41 @@
return result;
}
case TableExprFuncNode::angdistFUNC:
+ {
+ Array<double> a1 = operands()[0]->getArrayDouble(id);
+ Array<double> a2 = operands()[1]->getArrayDouble(id);
+ // Treat an array of size 2 as scalar, so allow scalar-array
operations
+ // which is handled by angdistxFUNC.
+ if (a1.size() != 2 && a2.size() != 2) {
+ if (a1.size() != a2.size()) {
+ throw TableInvExpr ("Arguments of angdist function must have "
+ "equal length");
+ }
+ if (a1.size() %2 != 0) {
+ throw TableInvExpr ("Arguments of angdist function must have
a "
+ "multiple of 2 values");
+ }
+ Array<double> result(IPosition(1, a1.size()/2));
+ double* res = result.data();
+ Array<double>::const_iterator p2 = a2.begin();
+ Array<double>::const_iterator end1 = a1.end();
+ for (Array<double>::const_iterator p1 = a1.begin(); p1!=end1;
++p1) {
+ double ra1 = *p1;
+ ++p1;
+ double ra2 = *p2;
+ ++p2;
+ *res++ = acos (sin(*p1)*sin(*p2) +
cos(*p1)*cos(*p2)*cos(ra1-ra2));
+ ++p2;
+ }
+ return result;
+ } // fall through if either arrays have size 2
+ }
+ case TableExprFuncNode::angdistxFUNC:
{
Array<double> a1 = operands()[0]->getArrayDouble(id);
Array<double> a2 = operands()[1]->getArrayDouble(id);
if (!(a1.size() %2 == 0 && a2.size() %2 == 0)) {
- throw TableInvExpr ("Arguments of angdist function must have a "
+ throw TableInvExpr ("Arguments of angdistx function must have a "
"multiple of 2 values");
}
Array<double>::const_iterator end1 = a1.end();
@@ -1216,9 +1307,18 @@
}
return result;
}
+ case TableExprFuncNode::datetimeFUNC:
+ case TableExprFuncNode::mjdtodateFUNC:
+ case TableExprFuncNode::dateFUNC:
+ {
+ Array<MVTime> arr (getArrayDate(id));
+ Array<Double> res(arr.shape());
+ convertArray (res, arr);
+ return res;
+ }
default:
{
- // Functions like MJD are implemented as Int only.
+ // Functions like YEAR are implemented as Int only.
Array<Int64> arr (getArrayInt(id));
Array<Double> res(arr.shape());
convertArray (res, arr);
@@ -1299,17 +1399,17 @@
case TableExprFuncNode::arrsumsFUNC:
{
Array<DComplex> arr (operands()[0]->getArrayDComplex(id));
- return partialSums (arr, getCollapseAxes(id, arr.ndim()));
+ return partialSums (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrproductsFUNC:
{
Array<DComplex> arr (operands()[0]->getArrayDComplex(id));
- return partialProducts (arr, getCollapseAxes(id, arr.ndim()));
+ return partialProducts (arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrsumsqrsFUNC:
{
Array<DComplex> arr (operands()[0]->getArrayDComplex(id));
- return partialSums (arr*arr, getCollapseAxes(id, arr.ndim()));
+ return partialSums (arr*arr, getAxes(id, arr.ndim()));
}
case TableExprFuncNode::arrayFUNC:
{
@@ -1335,6 +1435,11 @@
}
return res;
}
+ case TableExprFuncNode::transposeFUNC:
+ {
+ Array<DComplex> arr (operands()[0]->getArrayDComplex(id));
+ return reorderArray (arr, getOrder(id, arr.ndim()), False);
+ }
case TableExprFuncNode::complexFUNC:
{
Array<DComplex> result;
@@ -1458,8 +1563,9 @@
return result;
}
default:
- throw (TableInvExpr ("TableExprFuncNodeArray::getArrayDComplex, "
- "unknown function"));
+ throw TableInvExpr ("TableExprFuncNodeArray::getArrayDComplex, "
+ "unknown function " +
+ String::toString(funcType()));
}
return Array<DComplex>();
}
@@ -1541,8 +1647,9 @@
}
break;
default:
- throw (TableInvExpr ("TableExprFuncNodeArray::getArrayString, "
- "unhandled string function"));
+ throw TableInvExpr ("TableExprFuncNodeArray::getArrayString, "
+ "unhandled string function " +
+ String::toString(funcType()));
}
strings.putStorage (str, deleteStr);
return strings;
@@ -1588,8 +1695,9 @@
}
break;
default:
- throw (TableInvExpr ("TableExprFuncNodeArray::getArrayString, "
- "unhandled date-string function"));
+ throw TableInvExpr ("TableExprFuncNodeArray::getArrayString, "
+ "unhandled date-string function " +
+ String::toString(funcType()));
}
values.freeStorage (val, deleteVal);
strings.putStorage (str, deleteStr);
@@ -1627,8 +1735,9 @@
}
break;
default:
- throw (TableInvExpr ("TableExprFuncNodeArray::getArrayString, "
- "unhandled angle-string function"));
+ throw TableInvExpr ("TableExprFuncNodeArray::getArrayString, "
+ "unhandled angle-string function " +
+ String::toString(funcType()));
}
values.freeStorage (val, deleteVal);
strings.putStorage (str, deleteStr);
@@ -1659,6 +1768,11 @@
}
return res;
}
+ case TableExprFuncNode::transposeFUNC:
+ {
+ Array<String> arr (operands()[0]->getArrayString(id));
+ return reorderArray (arr, getOrder(id, arr.ndim()), False);
+ }
case TableExprFuncNode::iifFUNC:
{
Array<Bool> arrc;
@@ -1734,8 +1848,9 @@
return result;
}
default:
- throw (TableInvExpr ("TableExprFuncNodeArray::getArrayString, "
- "unknown function"));
+ throw TableInvExpr ("TableExprFuncNodeArray::getArrayString, "
+ "unknown function " +
+ String::toString(funcType()));
}
return Array<String>();
}
@@ -1816,6 +1931,11 @@
}
return res;
}
+ case TableExprFuncNode::transposeFUNC:
+ {
+ Array<MVTime> arr (operands()[0]->getArrayDate(id));
+ return reorderArray (arr, getOrder(id, arr.ndim()), False);
+ }
case TableExprFuncNode::iifFUNC:
{
Array<Bool> arrc;
@@ -1891,8 +2011,9 @@
return result;
}
default:
- throw (TableInvExpr ("TableExprFuncNodeArray::getArrayDate, "
- "unknown function"));
+ throw TableInvExpr ("TableExprFuncNodeArray::getArrayDate, "
+ "unknown function " +
+ String::toString(funcType()));
}
return Array<MVTime>();
}
=======================================
--- /trunk/tables/Tables/ExprFuncNodeArray.h Wed Nov 30 06:43:25 2011
+++ /trunk/tables/Tables/ExprFuncNodeArray.h Wed Jan 4 00:11:03 2012
@@ -120,25 +120,28 @@
void setScale (Double scale)
{ node_p.setScale (scale); }

- // Get the collapseAxes for the partial functions.
+ // Get the collapse axes for the partial functions.
// It compares the values with the #dim and removes them if too high.
// axarg gives the argument nr of the axes.
- const IPosition& getCollapseAxes (const TableExprId& id,
- Int ndim, uInt axarg=1);
+ IPosition getAxes (const TableExprId& id,
+ Int ndim, uInt axarg=1, Bool swapRemove=True);
+
+ // Remove axes exceeding ndim.
+ IPosition removeAxes (const IPosition& axes, Int ndim) const;

// Get the shape for the array function.
// axarg gives the argument nr of the shape.
const IPosition& getArrayShape (const TableExprId& id, uInt axarg=1);

+ // Get the transpose order of the array axes.
+ IPosition getOrder (const TableExprId& id, Int ndim);
+
TableExprFuncNode node_p;
Int origin_p; //# axes origin
Bool isCOrder_p; //# axes order
Bool constAxes_p; //# True = collapse axes are
constant
IPosition ipos_p; //# the (maybe constant) axes or
shape
IPosition iposN_p; //# the non-reversed axes or shape
- IPosition corrCollAxes_p; //# the possibly corrected collapse
axes
- //# (in case an axis exceeds ndim)
- uInt lastNdim_p; //# last ndim used in
getCollapseAxes
};


=======================================
--- /trunk/tables/Tables/ExprMathNodeArray.cc Sun Jul 5 22:04:32 2009
+++ /trunk/tables/Tables/ExprMathNodeArray.cc Wed Jan 4 00:11:03 2012
@@ -26,6 +26,7 @@
//# $Id$

#include <tables/Tables/ExprMathNodeArray.h>
+#include <tables/Tables/ExprUnitNode.h>
#include <tables/Tables/TableError.h>
#include <casa/Arrays/Array.h>
#include <casa/Arrays/ArrayMath.h>
@@ -166,6 +167,42 @@
}
}

+TableExprNodeArrayPlusDate::TableExprNodeArrayPlusDate
+ (const TableExprNodeRep& node)
+: TableExprNodeArrayPlus (NTDate, node)
+{}
+TableExprNodeArrayPlusDate::~TableExprNodeArrayPlusDate()
+{}
+void TableExprNodeArrayPlusDate::handleUnits()
+{
+ if (lnode_p->dataType() == NTDouble) {
+ TableExprNodeUnit::adaptUnit (lnode_p, "d");
+ } else if (rnode_p->dataType() == NTDouble) {
+ TableExprNodeUnit::adaptUnit (rnode_p, "d");
+ }
+}
+Array<Double> TableExprNodeArrayPlusDate::getArrayDouble
+ (const TableExprId& id)
+{
+ switch (argtype_p) {
+ case ArrSca:
+ return lnode_p->getArrayDouble(id) + rnode_p->getDouble(id);
+ case ScaArr:
+ return lnode_p->getDouble(id) + rnode_p->getArrayDouble(id);
+ default:
+ break;
+ }
+ return lnode_p->getArrayDouble(id) + rnode_p->getArrayDouble(id);
+}
+Array<MVTime> TableExprNodeArrayPlusDate::getArrayDate
+ (const TableExprId& id)
+{
+ Array<Double> tmp(getArrayDouble(id));
+ Array<MVTime> res(tmp.shape());
+ convertArray (res, tmp);
+ return res;
+}
+

TableExprNodeArrayMinus::TableExprNodeArrayMinus (NodeDataType dt,
const TableExprNodeRep& node)
@@ -233,6 +270,39 @@
}
return lnode_p->getArrayDComplex (id) - rnode_p->getArrayDComplex (id);
}
+
+TableExprNodeArrayMinusDate::TableExprNodeArrayMinusDate
+ (const TableExprNodeRep& node)
+: TableExprNodeArrayMinus (NTDate, node)
+{}
+TableExprNodeArrayMinusDate::~TableExprNodeArrayMinusDate()
+{}
+void TableExprNodeArrayMinusDate::handleUnits()
+{
+ // Right hand side must be in days.
+ TableExprNodeUnit::adaptUnit (rnode_p, "d");
+}
+Array<Double> TableExprNodeArrayMinusDate::getArrayDouble
+ (const TableExprId& id)
+{
+ switch (argtype_p) {
+ case ArrSca:
+ return lnode_p->getArrayDouble(id) - rnode_p->getDouble(id);
+ case ScaArr:
+ return lnode_p->getDouble(id) - rnode_p->getArrayDouble(id);
+ default:
+ break;
+ }
+ return lnode_p->getArrayDouble(id) - rnode_p->getArrayDouble(id);
+}
+Array<MVTime> TableExprNodeArrayMinusDate::getArrayDate
+ (const TableExprId& id)
+{
+ Array<Double> tmp(getArrayDouble(id));
+ Array<MVTime> res(tmp.shape());
+ convertArray (res, tmp);
+ return res;
+}


TableExprNodeArrayTimes::TableExprNodeArrayTimes (NodeDataType dt,
=======================================
--- /trunk/tables/Tables/ExprMathNodeArray.h Sun Jul 5 22:04:32 2009
+++ /trunk/tables/Tables/ExprMathNodeArray.h Wed Jan 4 00:11:03 2012
@@ -204,6 +204,39 @@
};


+// <summary>
+// Date Array addition in table select expression tree
+// </summary>
+
+// <use visibility=local>
+
+// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
+// </reviewed>
+
+// <prerequisite>
+//# Classes you should understand before using this one.
+// <li> TableExprNode
+// <li> TableExprNodeRep
+// </prerequisite>
+
+// <synopsis>
+// This class represents an addition in a table select expression tree.
+// Strings can also be added (ie. concatenated).
+// Numeric data types will be promoted if possible, so for instance
+// an addition of Int and Complex is possible.
+// </synopsis>
+
+class TableExprNodeArrayPlusDate : public TableExprNodeArrayPlus
+{
+public:
+ TableExprNodeArrayPlusDate (const TableExprNodeRep&);
+ ~TableExprNodeArrayPlusDate();
+ virtual void handleUnits();
+ Array<Double> getArrayDouble (const TableExprId& id);
+ Array<MVTime> getArrayDate (const TableExprId& id);
+};
+
+

// <summary>
// Array addition in table select expression tree
@@ -322,6 +355,38 @@
};


+// <summary>
+// Date Array subtraction in table select expression tree
+// </summary>
+
+// <use visibility=local>
+
+// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
+// </reviewed>
+
+// <prerequisite>
+//# Classes you should understand before using this one.
+// <li> TableExprNode
+// <li> TableExprNodeRep
+// </prerequisite>
+
+// <synopsis>
+// This class represents a subtraction in a table select expression tree.
+// Numeric data types will be promoted if possible, so for instance
+// a subtraction of Int and Complex is possible.
+// </synopsis>
+
+class TableExprNodeArrayMinusDate : public TableExprNodeArrayMinus
+{
+public:
+ TableExprNodeArrayMinusDate (const TableExprNodeRep&);
+ ~TableExprNodeArrayMinusDate();
+ virtual void handleUnits();
+ Array<Double> getArrayDouble (const TableExprId& id);
+ Array<MVTime> getArrayDate (const TableExprId& id);
+};
+
+

// <summary>
// Array addition in table select expression tree
=======================================
--- /trunk/tables/Tables/ExprNode.cc Sun Dec 18 05:14:32 2011
+++ /trunk/tables/Tables/ExprNode.cc Wed Jan 4 00:11:03 2012
@@ -326,6 +326,9 @@
case TableExprNodeRep::NTString:
tsnptr = new TableExprNodeArrayPlusString (node);
break;
+ case TableExprNodeRep::NTDate:
+ tsnptr = new TableExprNodeArrayPlusDate (node);
+ break;
default:
throwInvDT("in array operator+");
}
@@ -366,6 +369,9 @@
case TableExprNodeRep::NTComplex:
tsnptr = new TableExprNodeArrayMinusDComplex (node);
break;
+ case TableExprNodeRep::NTDate:
+ tsnptr = new TableExprNodeArrayMinusDate (node);
+ break;
default:
throwInvDT("in array operator-");
}
=======================================
--- /trunk/tables/Tables/ExprNodeRep.cc Wed Nov 30 06:43:25 2011
+++ /trunk/tables/Tables/ExprNodeRep.cc Wed Jan 4 00:11:03 2012
@@ -726,7 +726,7 @@
if (leftDtype == NTString && rightDtype == NTDate) {
leftDtype = NTDate;
}
- // A double will be promoted to Date when using with a Date in a
comparison.
+ // A double will be promoted to Date when used with a Date in a
comparison.
if (opt >= OtEQ && opt <= OtIN) {
if (leftDtype == NTDate && rightDtype == NTDouble) {
rightDtype = NTDate;
@@ -740,6 +740,7 @@
return NTDouble;
}
// Date matches Date; Date+Date is not allowed
+ // Note that date/date or date*date has been catched earlier.
if (leftDtype == NTDate && rightDtype == NTDate && opt != OtPlus) {
return NTDate;
}
@@ -848,12 +849,11 @@
Bool convertConstType)
{
// Fill the children and link to them.
+ // If needed, change the children to get matching data types.
thisNode->lnode_p = left->link();
if (right != 0) {
thisNode->rnode_p = right->link();
- }
- // Change the children when needed.
- if (right != 0) {
+
// NTRegex will always be placed in the right node
if (left->dataType() == NTRegex) {
thisNode->lnode_p = right;
@@ -866,7 +866,8 @@
TableExprNode dNode = datetime (right);
unlink (right);
thisNode->rnode_p = getRep(dNode)->link();
- } else if (right->dataType() == NTDouble) {
+ } else if (right->dataType() == NTDouble ||
+ right->dataType() == NTInt) {
TableExprNode dNode = mjdtodate (right);
unlink (right);
thisNode->rnode_p = getRep(dNode)->link();
@@ -877,7 +878,8 @@
TableExprNode dNode = datetime (left);
unlink (left);
thisNode->lnode_p = getRep(dNode)->link();
- } else if (left->dataType() == NTDouble) {
+ } else if (left->dataType() == NTDouble ||
+ left->dataType() == NTInt) {
TableExprNode dNode = mjdtodate (left);
unlink (left);
thisNode->lnode_p = getRep(dNode)->link();
=======================================
--- /trunk/tables/Tables/ExprNodeSet.cc Wed Nov 30 06:43:25 2011
+++ /trunk/tables/Tables/ExprNodeSet.cc Wed Jan 4 00:11:03 2012
@@ -47,7 +47,7 @@
itsStart (0),
itsEnd (0),
itsIncr (0),
- itsMinusEnd (0),
+ itsEndExcl (False),
itsLeftClosed (True),
itsRightClosed (True),
itsDiscrete (True),
@@ -69,7 +69,7 @@
itsStart (0),
itsEnd (0),
itsIncr (0),
- itsMinusEnd (isEndExcl ? 1:0),
+ itsEndExcl (isEndExcl),
itsLeftClosed (True),
itsRightClosed (True),
itsDiscrete (True),
@@ -136,7 +136,7 @@
itsStart (that.itsStart),
itsEnd (that.itsEnd),
itsIncr (that.itsIncr),
- itsMinusEnd (that.itsMinusEnd),
+ itsEndExcl (that.itsEndExcl),
itsLeftClosed (that.itsLeftClosed),
itsRightClosed (that.itsRightClosed),
itsDiscrete (that.itsDiscrete),
@@ -161,7 +161,7 @@
itsStart (start),
itsEnd (end),
itsIncr (incr),
- itsMinusEnd (that.itsMinusEnd),
+ itsEndExcl (that.itsEndExcl),
itsLeftClosed (that.itsLeftClosed),
itsRightClosed (that.itsRightClosed),
itsDiscrete (that.itsDiscrete),
@@ -194,7 +194,7 @@
itsStart = 0;
itsEnd = 0;
itsIncr = 0;
- itsMinusEnd = 0;
+ itsEndExcl = False;
itsLeftClosed = isLeftClosed;
itsRightClosed = isRightClosed;
itsDiscrete = False;
@@ -288,8 +288,7 @@
start = new TableExprNodeConstInt (itsStart->getInt (id));
}
if (itsEnd != 0) {
- end = new TableExprNodeConstInt (itsEnd->getInt (id)
- - itsMinusEnd);
+ end = new TableExprNodeConstInt (itsEnd->getInt (id));
}
if (itsIncr != 0) {
incr = new TableExprNodeConstInt (itsIncr->getInt (id));
@@ -300,8 +299,7 @@
start = new TableExprNodeConstDouble (itsStart->getDouble (id));
}
if (itsEnd != 0) {
- end = new TableExprNodeConstDouble (itsEnd->getDouble (id)
- - itsMinusEnd);
+ end = new TableExprNodeConstDouble (itsEnd->getDouble (id));
}
if (itsIncr != 0) {
incr = new TableExprNodeConstDouble (itsIncr->getDouble (id));
@@ -326,8 +324,7 @@
start = new TableExprNodeConstDate (itsStart->getDate (id));
}
if (itsEnd != 0) {
- end = new TableExprNodeConstDate (itsEnd->getDate (id)
- - itsMinusEnd);
+ end = new TableExprNodeConstDate (itsEnd->getDate (id));
}
if (itsIncr != 0) {
incr = new TableExprNodeConstDouble (itsIncr->getDouble (id));
@@ -354,7 +351,7 @@
{
DebugAssert (itsDiscrete, AipsError);
Int64 start = itsStart==0 ? 0 : itsStart->getInt (id);
- Int64 end = itsEnd==0 ? start : itsEnd->getInt (id) - itsMinusEnd;
+ Int64 end = itsEnd==0 ? start : itsEnd->getInt (id);
Int64 incr = itsIncr==0 ? 1 : itsIncr->getInt (id);
if (start > end) {
return;
@@ -367,6 +364,9 @@
for (uInt i=0; i<nval; i++) {
vec(cnt++) = start;
start += incr;
+ if (itsEndExcl && start >= end) {
+ break;
+ }
}
}
void TableExprNodeSetElem::fillVector (Vector<Double>& vec, uInt& cnt,
@@ -374,7 +374,7 @@
{
DebugAssert (itsDiscrete, AipsError);
Double start = itsStart==0 ? 0 : itsStart->getDouble (id);
- Double end = itsEnd==0 ? start : itsEnd->getDouble (id) -
itsMinusEnd;
+ Double end = itsEnd==0 ? start : itsEnd->getDouble (id);
Double incr = itsIncr==0 ? 1 : itsIncr->getDouble (id);
if (start > end) {
return;
@@ -387,6 +387,9 @@
for (uInt i=0; i<nval; i++) {
vec(cnt++) = start;
start += incr;
+ if (itsEndExcl && start >= end) {
+ break;
+ }
}
}
void TableExprNodeSetElem::fillVector (Vector<DComplex>& vec, uInt& cnt,
@@ -414,8 +417,7 @@
{
DebugAssert (itsDiscrete, AipsError);
Double start = itsStart==0 ? 0 : Double(itsStart->getDate (id));
- Double end = itsEnd==0 ? start : Double(itsEnd->getDate (id))
- - itsMinusEnd;
+ Double end = itsEnd==0 ? start : Double(itsEnd->getDate (id));
Double incr = itsIncr==0 ? 1 : itsIncr->getDouble (id);
if (start > end) {
return;
@@ -428,6 +430,9 @@
for (uInt i=0; i<nval; i++) {
vec(cnt++) = start;
start += incr;
+ if (itsEndExcl && start >= end) {
+ break;
+ }
}
}

@@ -466,7 +471,10 @@
match++;
}
} else if (itsDiscrete) {
- end -= start+itsMinusEnd;
+ end -= start;
+ if (itsEndExcl) {
+ end -= 1;
+ }
while (match < lastVal) {
Int64 tmp = *value - start;
if (tmp >= 0 && (itsEnd == 0 || tmp <= end)) {
@@ -511,10 +519,11 @@
match++;
}
} else if (itsDiscrete) {
- end -= start+itsMinusEnd;
+ end -= start;
while (match < lastVal) {
Double tmp = *value - start;
- if (tmp >= 0 && (itsEnd == 0 || tmp <= end)) {
+ if (tmp >= 0 && (itsEnd == 0 || tmp < end ||
+ (!itsEndExcl && tmp==end))) {
if (near(tmp, incr*Int64(tmp/incr + 0.5))) {
*match = True;
}
@@ -606,10 +615,11 @@
match++;
}
} else if (itsDiscrete) {
- end -= start+itsMinusEnd;
+ end -= start;
while (match < lastVal) {
Double tmp = Double(*value) - start;
- if (tmp >= 0 && (itsEnd == 0 || tmp <= end)) {
+ if (tmp >= 0 && (itsEnd == 0 || tmp < end ||
+ (!itsEndExcl && tmp==end))) {
Double div = tmp/incr;
if (int(div) == div) {
*match = True;
@@ -1135,7 +1145,7 @@
// The set should not contain array elements.
if (hasArrays()) {
return new TableExprNodeSet (*this);
-/// throw (TableInvExpr ("A set cannot contain elements having arrays"));
+/// throw a(TableInvExpr ("A set cannot contain elements having arrays"));
}
// A set where elements have different units cannot be turned into an
array.
if (! unit().empty()) {
=======================================
--- /trunk/tables/Tables/ExprNodeSet.h Wed Nov 30 06:43:25 2011
+++ /trunk/tables/Tables/ExprNodeSet.h Wed Jan 4 00:11:03 2012
@@ -213,7 +213,7 @@
TableExprNodeRep* itsStart;
TableExprNodeRep* itsEnd;
TableExprNodeRep* itsIncr;
- Int itsMinusEnd;
+ Bool itsEndExcl;
Bool itsLeftClosed;
Bool itsRightClosed;
Bool itsDiscrete;
=======================================
--- /trunk/tables/Tables/Table.cc Wed Apr 20 04:46:29 2011
+++ /trunk/tables/Tables/Table.cc Wed Jan 4 00:11:03 2012
@@ -274,6 +274,56 @@
}
return *this;
}
+
+Table Table::openTable (const String& tableName,
+ TableOption option,
+ const TSMOption& tsmOption)
+{
+ return openTable (tableName, TableLock(), option, tsmOption);
+}
+
+Table Table::openTable (const String& tableName,
+ const TableLock& lockOptions,
+ TableOption option,
+ const TSMOption& tsmOption)
+{
+ // See if the table can be opened as such.
+ if (Table::isReadable(tableName)) {
+ return Table(tableName, lockOptions, option, tsmOption);
+ }
+ // Try to open the table using subtables by splitting at ::
+ Table tab;
+ String name = tableName;
+ String msg;
+ int j = name.index("::");
+ if (j >= 0) {
+ String tabName (name.before(j));
+ name = name.after(j+1);
+ if (Table::isReadable (tabName)) {
+ tab = Table(tabName, lockOptions, option, tsmOption);
+ while (! name.empty()) {
+ j = name.index("::");
+ if (j >= 0) {
+ tabName = name.before(j);
+ name = name.after(j+1);
+ } else {
+ tabName = name;
+ name = String();
+ }
+ if (! tab.keywordSet().isDefined(tabName)) {
+ msg = " (subtable " + tabName + " is unknown)";
+ tab = Table();
+ break;
+ }
+ tab = tab.keywordSet().asTable (tabName);
+ }
+ }
+ }
+ if (tab.isNull()) {
+ throw TableError ("Table " + tableName + " does not exist" + msg);
+ }
+ return tab;
+}


Block<String> Table::getPartNames (Bool recursive) const
=======================================
--- /trunk/tables/Tables/Table.h Tue Oct 18 00:39:05 2011
+++ /trunk/tables/Tables/Table.h Wed Jan 4 00:11:03 2012
@@ -90,6 +90,10 @@
// <li> Update update existing table
// <li> Delete delete table
// </ul>
+// The function <src>openTable</src> makes it possible to open a subtable
+// of a table in a convenient way, even if the table is only a reference
+// to another table (e.g., a selection).
+//
// Creating a new table requires more work, because columns have
// to be bound to storage managers or virtual column engines.
// Class SetupNewTable is needed for this purpose. The Tables module
@@ -328,6 +332,37 @@
// Assignment (reference semantics).
Table& operator= (const Table&);

+ // Try to open a table. The name of the table can contain subtable
names
+ // using :: as separator. In this way it is possible to directly open a
+ // subtable of a RefTable or ConcatTable, which is not possible if the
+ // table name is specified with slashes.
+ // <br>The open process is as follows:
+ // <ul>
+ // <li> It is tried to open the table with the given name.
+ // <li> If unsuccessful, the name is split into its parts using ::
+ // The first part is the main table which will be opened
temporarily.
+ // The other parts are the successive subtable names (usually
one).
+ // Each subtable is opened by looking it up in the keywords of
the
+ // table above. The final subtable is returned.
+ // </ul>
+ // <br>An exception is thrown if the table cannot be opened.
+ // <example>
+ // Open the ANTENNA subtable of an MS which might be a selection of
+ // a real MS.
+ // <srcblock>
+ // Table tab(Table::openTable ("sel.ms::ANTENNA");
+ // </srcblock>
+ // </example>
+ // <group>
+ static Table openTable (const String& tableName,
+ TableOption = Table::Old,
+ const TSMOption& = TSMOption());
+ static Table openTable (const String& tableName,
+ const TableLock& lockOptions,
+ TableOption = Table::Old,
+ const TSMOption& = TSMOption());
+ // </group>
+
// Get the names of the tables this table consists of.
// For a plain table it returns its name,
// for a RefTable the name of the parent, and
=======================================
--- /trunk/tables/Tables/TableGram.ll Sun Dec 18 05:13:34 2011
+++ /trunk/tables/Tables/TableGram.ll Wed Jan 4 00:11:03 2012
@@ -373,6 +373,8 @@
">" { tableGramPosition() += yyleng; return GT; }
"<=" { tableGramPosition() += yyleng; return LE; }
"<" { tableGramPosition() += yyleng; return LT; }
+"~=" { tableGramPosition() += yyleng; return EQNEAR; }
+"!~=" { tableGramPosition() += yyleng; return NENEAR; }
{BETWEEN} { tableGramPosition() += yyleng; return BETWEEN; }
{EXISTS} { tableGramPosition() += yyleng; return EXISTS; }
{LIKE} { tableGramPosition() += yyleng; return LIKE; }
=======================================
--- /trunk/tables/Tables/TableGram.yy Tue Oct 18 00:39:05 2011
+++ /trunk/tables/Tables/TableGram.yy Wed Jan 4 00:11:03 2012
@@ -165,7 +165,7 @@
/* This defines the precedence order of the operators (low to high) */
%left OR
%left AND
-%nonassoc EQ EQASS GT GE LT LE NE
+%nonassoc EQ EQASS GT GE LT LE NE EQNEAR NENEAR
%left BITOR
%left BITXOR
%left BITAND
@@ -840,6 +840,24 @@
new TaQLBinaryNodeRep (TaQLBinaryNodeRep::B_NE, *$1, *$3));
TaQLNode::theirNodesCreated.push_back ($$);
}
+ | arithexpr EQNEAR arithexpr {
+ TaQLMultiNode set(False);
+ set.add (*$1);
+ set.add (*$3);
+ set.add (TaQLConstNode(new TaQLConstNodeRep(1e-5)));
+ $$ = new TaQLNode (new TaQLFuncNodeRep("NEAR", set));
+ TaQLNode::theirNodesCreated.push_back ($$);
+ }
+ | arithexpr NENEAR arithexpr {
+ TaQLMultiNode set(False);
+ set.add (*$1);
+ set.add (*$3);
+ set.add (TaQLConstNode(new TaQLConstNodeRep(1e-5)));
+ TaQLNode ref (new TaQLFuncNodeRep("NEAR", set));
+ $$ = new TaQLNode(
+ new TaQLUnaryNodeRep (TaQLUnaryNodeRep::U_NOT, ref));
+ TaQLNode::theirNodesCreated.push_back ($$);
+ }
| arithexpr REGEX {
$$ = new TaQLNode(TaQLBinaryNodeRep::handleRegex (*$1, *$2));
TaQLNode::theirNodesCreated.push_back ($$);
=======================================
--- /trunk/tables/Tables/TableParse.cc Mon Dec 19 07:31:36 2011
+++ /trunk/tables/Tables/TableParse.cc Wed Jan 4 00:11:03 2012
@@ -187,7 +187,7 @@
String shand, columnName;
Vector<String> fieldNames;
if (splitName (shand, columnName, fieldNames, name, False)) {
- table = tableKey (shand, columnName, fieldNames, stack);
+ table = tableKey (name, shand, columnName, fieldNames, stack);
} else {
// If no or equal shorthand is given, try to see if the
// given name is already used as a shorthand.
@@ -218,12 +218,13 @@
fromTables_p[0] = TableParse(table, fromTables_p[0].shorthand());
}

-Table TableParseSelect::tableKey (const String& shorthand,
+Table TableParseSelect::tableKey (const String& name,
+ const String& shorthand,
const String& columnName,
const Vector<String>& fieldNames,
const vector<TableParseSelect*>& stack)
{
- //# Find the given shorthand on all levels.
+ //# Try to find the given shorthand on all levels.
for (Int i=stack.size()-1; i>=0; i--) {
Table tab = stack[i]->findTable (shorthand);
if (! tab.isNull()) {
@@ -233,9 +234,9 @@
}
}
}
- throw (TableInvExpr ("Keyword " + columnName + "::" + fieldNames(0) +
- " not found in tables in outer SELECTs"));
- return Table();
+ // Apparently it is no keyword in an outer table.
+ // Try to open the table using subtables by splitting at the ::.
+ return Table::openTable (name);
}

Table TableParseSelect::findTableKey (const Table& table,
@@ -629,6 +630,8 @@
ftype = TableExprFuncNode::nfalsesFUNC;
} else if (funcName == "array") {
ftype = TableExprFuncNode::arrayFUNC;
+ } else if (funcName == "transpose") {
+ ftype = TableExprFuncNode::transposeFUNC;
} else if (funcName == "isnan") {
ftype = TableExprFuncNode::isnanFUNC;
} else if (funcName == "isinf") {
@@ -727,6 +730,8 @@
ftype = TableExprFuncNode::iifFUNC;
} else if (funcName == "angdist" || funcName == "angulardistance") {
ftype = TableExprFuncNode::angdistFUNC;
+ } else if (funcName == "angdistx" || funcName == "angulardistancex") {
+ ftype = TableExprFuncNode::angdistxFUNC;
} else {
// unknown name can be a user-defined function.
ftype = TableExprFuncNode::NRFUNC;
@@ -818,22 +823,32 @@
case TableExprFuncNode::boxanyFUNC:
case TableExprFuncNode::boxallFUNC:
case TableExprFuncNode::arrayFUNC:
- if (arguments.nelements() > axarg) {
+ case TableExprFuncNode::transposeFUNC:
+ if (arguments.nelements() >= axarg) {
TableExprNodeSet parms;
- // Add normal arguments to the parms.
+ // Add first argument(s) to the parms.
for (uInt i=0; i<axarg; i++) {
- parms.add (arguments[i]);
- }
- // Now add the axes arguments.
- // They can be given as one single array or as individual scalars.
+ parms.add (arguments[i]);
+ }
+ // Now handle the axes arguments.
+ // The can be given as a set or as individual scalar values.
Bool axesIsArray = False;
- if (arguments.nelements() == axarg+1
- && arguments[axarg].isSingle()) {
- const TableExprNodeSetElem& arg = arguments[axarg];
- if (arg.start()->valueType() == TableExprNodeRep::VTArray) {
- parms.add (arg);
- axesIsArray = True;
- }
+ if (arguments.nelements() == axarg) {
+ // No axes given. Add default one for transpose.
+ axesIsArray = True;
+ if (ftype == TableExprFuncNode::transposeFUNC) {
+ // Add an empty vector if no transpose arguments given.
+ TableExprNodeSetElem arg((TableExprNode(Vector<Int>())));
+ parms.add (arg);
+ }
+ } else if (arguments.nelements() == axarg+1
+ && arguments[axarg].isSingle()) {
+ // A single set given; see if it is an array.
+ const TableExprNodeSetElem& arg = arguments[axarg];
+ if (arg.start()->valueType() == TableExprNodeRep::VTArray) {
+ parms.add (arg);
+ axesIsArray = True;
+ }
}
if (!axesIsArray) {
// Combine all axes in a single set and add to parms.
@@ -1349,8 +1364,8 @@
// the object.
resultSet_p->link();
if (! TableExprNode(resultSet_p).checkTableSize (origTable, False)) {
- throw (TableInvExpr ("Tables with different sizes used in "
- "GIVING set expression"));
+ throw TableInvExpr ("Tables with different sizes used in "
+ "GIVING set expression (mismatches first table)");
}
TableExprNodeSet set(rownrs_p, *resultSet_p);
return set.setOrArray();
@@ -1452,12 +1467,14 @@
//# A constant expression can be given.
if (! key.node().checkTableSize (origTable, True)) {
throw TableInvExpr ("Table(s) with incorrect size used in the "
- "UPDATE expr of column " + colName);
+ "UPDATE expr of column " + colName +
+ " (mismatches first table)");
}
if (key.indexPtr() != 0) {
if (! key.indexNode().checkTableSize (updTable, True)) {
throw TableInvExpr ("Table(s) with incorrect size used in the "
- "index expr in UPDATE of column " + colName);
+ "index expr in UPDATE of column " + colName +
+ " (mismatches first table)");
}
}
//# This throws an exception for unknown data types (datetime, regex).
@@ -1920,8 +1937,9 @@
const TableParseSort& key = sort_p[i];
//# Check if the correct table is used in the sort key expression.
if (! key.node().checkTableSize (origTable, False)) {
- throw (TableInvExpr ("Table(s) with incorrect size used "
- "in sort key " + String::toString(i)));
+ throw TableInvExpr ("Table(s) with incorrect size used "
+ "in sort key " + String::toString(i) +
+ " (mismatches first table)");
}
//# This throws an exception for unknown data types (datetime, regex).
key.node().getColumnDataType();
@@ -2170,8 +2188,14 @@
Table TableParseSelect::doProjectExpr()
{
// Make a column description for all expressions.
+ // Check if all tables involved have the same nr of rows as the first
one.
TableDesc td;
for (uInt i=0; i<columnExpr_p.nelements(); i++) {
+ if (! columnExpr_p[i].checkTableSize (fromTables_p[0].table(), True)) {
+ throw TableInvExpr ("Table(s) with incorrect size used in "
+ "selected column " + columnNames_p[i] +
+ " (mismatches first table)");
+ }
// If no new name is given, make one (unique).
String newName = columnNames_p[i];
if (newName.empty()) {
@@ -2560,21 +2584,6 @@
}
//# The first table in the list is the source table.
Table table = fromTables_p[0].table();
- //# Check if all selected columns exist.
- for (uInt i=0; i<columnNames_p.nelements(); i++) {
- String nm = columnNames_p[i]; // name in update,insert
- if (columnOldNames_p.nelements() > 0) {
- nm = columnOldNames_p[i]; // possible name in select
- }
- if (! nm.empty()) {
- if (! table.tableDesc().isColumn (nm)) {
- throw (TableError ("TableParse: projected column " +
- nm +
- " does not exist in table " +
- table.tableName()));
- }
- }
- }
//# Determine if we can pre-empt the selection loop.
//# That is possible if a positive limit and offset are given
//# without sorting or select distinct.
=======================================
--- /trunk/tables/Tables/TableParse.h Sun Dec 18 05:14:32 2011
+++ /trunk/tables/Tables/TableParse.h Wed Jan 4 00:11:03 2012
@@ -588,7 +588,8 @@
// Try to find the keyword representing a table in one of the tables
// in any select block (from inner to outer).
// If not found, an exception is thrown.
- static Table tableKey (const String& shorthand, const String& columnName,
+ static Table tableKey (const String& fullName,
+ const String& shorthand, const String& columnName,
const Vector<String>& fieldNames,
const vector<TableParseSelect*>& stack);

=======================================
--- /trunk/tables/Tables/TableProxy.cc Wed Nov 30 06:43:25 2011
+++ /trunk/tables/Tables/TableProxy.cc Wed Jan 4 00:11:03 2012
@@ -75,8 +75,8 @@
const Record& lockOptions,
int option)
{
- table_p = Table (tableName, makeLockOptions(lockOptions),
- Table::TableOption(option));
+ table_p = Table::openTable (tableName, makeLockOptions(lockOptions),
+ Table::TableOption(option));
}

TableProxy::TableProxy (const String& tableName,
=======================================
--- /trunk/tables/Tables/test/tExprNodeSet.cc Wed Jun 16 00:29:13 2010
+++ /trunk/tables/Tables/test/tExprNodeSet.cc Wed Jan 4 00:11:03 2012
@@ -157,6 +157,7 @@
vec[1] = -1;
uInt cnt=2;
tset.fillVector (vec, cnt, 0);
+ vec.resize (cnt, True);
Vector<Int64> exp(51);
indgen (exp, Int64(-3), Int64(2));
AlwaysAssertExit (allEQ(exp, vec));
@@ -171,6 +172,7 @@
Vector<Int64> vec(98);
uInt cnt=0;
tset.fillVector (vec, cnt, 0);
+ vec.resize (cnt, True);
Vector<Int64> exp(98);
indgen (exp, Int64(1));
AlwaysAssertExit (allEQ(exp, vec));
@@ -197,6 +199,7 @@
Vector<Int64> vec;
uInt cnt=0;
tset.fillVector (vec, cnt, 0);
+ vec.resize (cnt, True);
Vector<Int64> exp(100);
indgen (exp);
AlwaysAssertExit (allEQ(exp, vec));
@@ -249,6 +252,7 @@
Vector<Double> vec;
uInt cnt=0;
tset.fillVector (vec, cnt, 0);
+ vec.resize (cnt, True);
Vector<Double> exp(46);
indgen (exp, 1., 0.2);
AlwaysAssertExit (allNear(exp, vec, 1e-13));
@@ -267,7 +271,8 @@
vec[1] = 0.8;
uInt cnt=2;
tset.fillVector (vec, cnt, 0);
- Vector<Double> exp(43);
+ vec.resize (cnt, True);
+ Vector<Double> exp(48);
indgen (exp, 0.6, 0.2);
AlwaysAssertExit (allNear(exp, vec, 1e-13));
}
@@ -281,7 +286,8 @@
Vector<Double> vec;
uInt cnt=0;
tset.fillVector (vec, cnt, 0);
- Vector<Double> exp(9);
+ vec.resize (cnt, True);
+ Vector<Double> exp(10);
indgen (exp, 1., 1.);
AlwaysAssertExit (allNear(exp, vec, 1e-13));
}
@@ -421,6 +427,7 @@
Vector<MVTime> vect;
uInt cnt=0;
tset.fillVector (vect, cnt, 0);
+ vect.resize (cnt, True);
Vector<Double> vec(vect.size());
convertArray (vec, vect);
Vector<Double> exp(32);
@@ -437,6 +444,7 @@
Vector<MVTime> vect;
uInt cnt=0;
tset.fillVector (vect, cnt, 0);
+ vect.resize (cnt, True);
Vector<Double> vec(vect.size());
convertArray (vec, vect);
AlwaysAssertExit (allNear(Vector<Double>(1, 54926.5), vec, 1e-13));
@@ -451,6 +459,7 @@
Vector<MVTime> vect;
uInt cnt=0;
tset.fillVector (vect, cnt, 0);
+ vect.resize (cnt, True);
Vector<Double> vec(vect.size());
convertArray (vec, vect);
AlwaysAssertExit (allNear(Vector<Double>(1, 54926.5), vec, 1e-13));
=======================================
--- /trunk/tables/Tables/test/tTableKeywords.cc Thu Jul 9 18:14:57 2009
+++ /trunk/tables/Tables/test/tTableKeywords.cc Wed Jan 4 00:11:03 2012
@@ -125,6 +125,7 @@

void readFromOtherDir()
{
+ {
// Reconstruct the main table.
// Get the sub table from the keyword .
Table tab("main3data");
@@ -138,6 +139,12 @@
AlwaysAssertExit (subtab2.nrow() == 2);
Table subtab4 = subtab3.keywordSet().asTable ("SubTab4");
AlwaysAssertExit (subtab4.nrow() == 4);
+ }
+ {
+ // Open the table using the :: syntax.
+ Table subtab3 (Table::openTable("main3data::SubTab2"));
+ AlwaysAssertExit (subtab3.nrow() == 3);
+ }
}


=======================================
--- /trunk/tables/apps/taql.cc Wed Nov 30 06:46:21 2011
+++ /trunk/tables/apps/taql.cc Wed Jan 4 00:11:03 2012
@@ -142,6 +142,7 @@
iter != endIter; ++iter) {
if (!firstTime) {
cout << ", ";
+ } else {
firstTime = False;
}
q.setValue (*iter);
@@ -165,6 +166,7 @@
for (Array<double>::const_iterator iter= pos.begin(); iter != endIter;) {
if (!firstTime) {
cout << ", ";
+ } else {
firstTime = False;
}
for (uInt i=0; i<units.size(); ++i) {
@@ -194,6 +196,7 @@
for (Array<double>::const_iterator iter= dir.begin(); iter != endIter;) {
if (!firstTime) {
cout << ", ";
+ } else {
firstTime = False;
}
cout << '[';
@@ -238,6 +241,7 @@
iter != endIter; ++iter) {
if (!firstTime) {
cout << ", ";
+ } else {
firstTime = False;
}
showTime (*iter);

Reply all
Reply to author
Forward
0 new messages