[rkward-cvs] SF.net SVN: rkward: [849] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Wed Oct 11 20:27:03 UTC 2006
Revision: 849
http://svn.sourceforge.net/rkward/?rev=849&view=rev
Author: tfry
Date: 2006-10-11 13:26:53 -0700 (Wed, 11 Oct 2006)
Log Message:
-----------
More data handling bug fixes
Modified Paths:
--------------
trunk/rkward/TODO
trunk/rkward/rkward/core/rkvariable.cpp
trunk/rkward/rkward/rbackend/rembedinternal.cpp
trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
trunk/rkward/rkward/rbackend/rthread.cpp
Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO 2006-10-11 18:52:13 UTC (rev 848)
+++ trunk/rkward/TODO 2006-10-11 20:26:53 UTC (rev 849)
@@ -72,6 +72,8 @@
- Need to add a conversion script. See .rk.get.meta (). Both should be changed at the same time.
-Or was it already broken, before?
- True Support for Logicals
+ - In the current design, RKVariable would not handle storage mode changes from outside well at all
+ - use QIntDict instead of string-map for value-labels / factor levels? Qt4: QHash
- maybe we can do stuff like auto-printing, (toplevel handlers: no, not those, they are not called in R_ReplDLLdo1 ()), syntax error information by using R_ReplDLLdo1 () for user/console commands. The command-text would be fed in via R_ReadConsole (would need to keep a buffer).
- How to differentiate readline calls to get new command data from readline calls to get user info?! The prompt may not be realiable enough. Is there other info?
- the hist parameter may be a hint, but is also set in do_browser
@@ -111,8 +113,6 @@
- I've changed the simple RInterface::issueCommand (QString, ...) command to return a pointer to the RCommand created. This will allow for lots of small cleanups. Do them.
- well, on second thought, it might be better to rely more on RCommand::id () instead of pointers. Why? The id is unique (until integer overflow). The pointer may be reused after a delete -> potential problem when trying to cancel command which is actually already deleted (and potentially other cases)
- let's set this back for a while
- - RKVariable:
- - use QIntDict instead of string-map for value-labels / factor levels? Qt4: QHash
- give informative feedback on syntax errors (line numbers, etc.)!
- .rk.get.available.packages ()
- use external (file) storage for cache to save mem
Modified: trunk/rkward/rkward/core/rkvariable.cpp
===================================================================
--- trunk/rkward/rkward/core/rkvariable.cpp 2006-10-11 18:52:13 UTC (rev 848)
+++ trunk/rkward/rkward/core/rkvariable.cpp 2006-10-11 20:26:53 UTC (rev 849)
@@ -115,6 +115,7 @@
RK_ASSERT (command->getDataType () == RData::StructureVector);
RK_ASSERT (command->getDataLength () == 3);
+ command->printStructure ("");
RData *data = command->getStructureVector ()[0];
RData *levels = command->getStructureVector ()[1];
@@ -130,7 +131,7 @@
// no levels
} else {
for (unsigned int i=0; i < levels_len; ++i) {
- myData ()->value_labels->insert (QString::number (i+1), command->getStringVector ()[i]);
+ myData ()->value_labels->insert (QString::number (i+1), levels->getStringVector ()[i]);
}
}
@@ -142,21 +143,21 @@
} else if (data->getDataType () == RData::RealVector) {
setNumeric (0, getLength () - 1, data->getRealVector ());
} else if (data->getDataType () == RData::IntVector) {
- RK_ASSERT (false); // not a problem, but I'd like to know if / when this happens
- double *dd = new double[getLength ()];
unsigned int len = getLength ();
+ double *dd = new double[len];
for (unsigned int i = 0; i < len; ++i) {
- dd[i] = data->getIntVector ()[i];
+ if (data->getIntVector ()[i] == INT_MIN) dd[i] = NAN;
+ else dd[i] = (double) data->getIntVector ()[i];
}
setNumeric (0, getLength () - 1, dd);
delete [] dd;
}
// now set the invalid fields (only if they are still NAs in the R data)
- RK_ASSERT (invalids->getDataType () == RData::StringVector);
- if (invalids->getDataLength () == 1) {
+ if (invalids->getDataLength () <= 1) {
// no invalids
} else {
+ RK_ASSERT (invalids->getDataType () == RData::StringVector);
unsigned int invalids_length = invalids->getDataLength ();
RK_ASSERT ((invalids_length % 2) == 0);
unsigned int invalids_count = invalids_length / 2;
@@ -528,6 +529,7 @@
}
double *RKVariable::getNumeric (int from_row, int to_row) {
+ RK_TRACE (OBJECTS);
if (to_row >= getLength ()) {
RK_ASSERT (false);
return 0;
@@ -540,6 +542,7 @@
}
void RKVariable::setNumeric (int from_row, int to_row, double *data) {
+ RK_TRACE (OBJECTS);
RK_ASSERT (to_row < getLength ());
if (getDataType () == DataCharacter) {
@@ -551,7 +554,16 @@
} else if (getDataType () == DataFactor) {
int i = 0;
for (int row=from_row; row <= to_row; ++row) {
- setText (row, QString::number (data[i++], 'g', MAX_PRECISION));
+ if (myData ()->cell_states[row] & RKVarEditData::Invalid) myData ()->cell_states[row] = RKVarEditData::UnsyncedInvalidState;
+ else myData ()->cell_states[row] = 0;
+
+ if (isnan (data[i]) || (!myData ()->value_labels) || (!myData ()->value_labels->contains (QString::number (data[i])))) {
+ myData ()->cell_states[row] |= RKVarEditData::NA;
+ } else {
+ myData ()->cell_states[row] |= RKVarEditData::Valid;
+ myData ()->cell_doubles[row] = data[i];
+ }
+ ++i;
}
} else {
int i = 0;
@@ -560,6 +572,7 @@
else myData ()->cell_states[row] = 0;
if (isnan (data[i])) {
+ qDebug ("nan");
myData ()->cell_states[row] |= RKVarEditData::NA;
} else {
myData ()->cell_states[row] |= RKVarEditData::Valid;
@@ -572,6 +585,7 @@
}
QString *RKVariable::getCharacter (int from_row, int to_row) {
+ RK_TRACE (OBJECTS);
if (to_row >= getLength ()) {
RK_ASSERT (false);
return 0;
@@ -590,6 +604,7 @@
}
void RKVariable::setCharacter (int from_row, int to_row, QString *data) {
+ RK_TRACE (OBJECTS);
RK_ASSERT (to_row < getLength ());
if (getDataType () == DataCharacter) {
@@ -601,7 +616,7 @@
if (data[i].isNull ()) myData ()->cell_states[row] |= RKVarEditData::NA;
else myData ()->cell_states[row] |= RKVarEditData::Valid;
- myData ()->cell_strings[row] = QString (data[i++]);
+ myData ()->cell_strings[row] = data[i++];
}
} else {
int i=0;
@@ -614,6 +629,7 @@
}
void RKVariable::setUnknown (int from_row, int to_row) {
+ RK_TRACE (OBJECTS);
RK_ASSERT (to_row < getLength ());
if ((from_row < 0)) from_row = 0;
@@ -632,10 +648,12 @@
}
void RKVariable::removeRow (int row) {
+ RK_TRACE (OBJECTS);
removeRows (row, row);
}
void RKVariable::removeRows (int from_row, int to_row) {
+ RK_TRACE (OBJECTS);
for (int row = from_row; row <= to_row; ++row) {
myData ()->invalid_fields.remove (row);
}
@@ -658,10 +676,12 @@
}
void RKVariable::insertRow (int row) {
+ RK_TRACE (OBJECTS);
insertRows (row, 1);
}
void RKVariable::insertRows (int row, int count) {
+ RK_TRACE (OBJECTS);
int old_len = getLength ();
extendToLength (getLength () + count);
Modified: trunk/rkward/rkward/rbackend/rembedinternal.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rembedinternal.cpp 2006-10-11 18:52:13 UTC (rev 848)
+++ trunk/rkward/rkward/rbackend/rembedinternal.cpp 2006-10-11 20:26:53 UTC (rev 849)
@@ -358,6 +358,7 @@
integers = new int[*count];
for (unsigned int i = 0; i < *count; ++i) {
integers[i] = INTEGER (from_exp)[i];
+ if (integers[i] == R_NaInt) integers[i] = INT_MIN; // this has no effect for now, but if R ever chnages it's R_NaInt, then it will
}
return integers;
}
@@ -413,6 +414,11 @@
}
data->datatype = RData::StructureVector;
break;
+/* case NILSXP:
+ data->data = 0;
+ data->datatype = RData::NoData;
+ count = 0;
+ break; */
case STRSXP:
default:
data->data = SEXPToStringList (from_exp, &count);
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R 2006-10-11 18:52:13 UTC (rev 848)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R 2006-10-11 20:26:53 UTC (rev 849)
@@ -256,12 +256,12 @@
".rk.get.vector.data" <- function (x) {
ret <- list ();
- ret$data <- as.vector (x);
+ ret$data <- as.vector (unclass (x));
ret$levels <- levels (x)
if (is.null (ret$levels)) ret$levels <- ""
- i <- attr (x, ".rk.invalid.fields");
+ i <- attr (x, ".rk.invalid.fields")
ret$invalids <- as.character (c (names (i), i));
- if (is.null (ret$invalids)) ret$invalid <- ""
+ if (length (ret$invalids) == 0) ret$invalids <- ""
ret
}
Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp 2006-10-11 18:52:13 UTC (rev 848)
+++ trunk/rkward/rkward/rbackend/rthread.cpp 2006-10-11 20:26:53 UTC (rev 849)
@@ -401,10 +401,6 @@
startR (argc, argv);
- for (--argc; argc >= 0; --argc) {
- delete argv[argc];
- }
-
connectCallbacks ();
RKWardRError error;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list