[rkward-cvs] SF.net SVN: rkward: [848] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Oct 11 18:52:23 UTC 2006


Revision: 848
          http://svn.sourceforge.net/rkward/?rev=848&view=rev
Author:   tfry
Date:     2006-10-11 11:52:13 -0700 (Wed, 11 Oct 2006)

Log Message:
-----------
Most of the newly introduced bugs regarding RKVariable storage mode should be fixed, now

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/TODO
    trunk/rkward/rkward/core/rkvariable.cpp
    trunk/rkward/rkward/core/rkvariable.h
    trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2006-10-11 17:32:19 UTC (rev 847)
+++ trunk/rkward/ChangeLog	2006-10-11 18:52:13 UTC (rev 848)
@@ -1,3 +1,4 @@
+- invalid values are stored in a separate attribute instead of changing the storage mode back and forth -> TODO
 - storage mode for RKWard meta data was changed -> TODO
 - RMB option to search help on objects from packages in object browser
 - show tooltip information on objects in object browser

Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO	2006-10-11 17:32:19 UTC (rev 847)
+++ trunk/rkward/TODO	2006-10-11 18:52:13 UTC (rev 848)
@@ -69,12 +69,9 @@
 
 Internal stuff:
 	RKVariable:
-		- the storage mechanism for invalid values (and the type detection) is flawed. The following should be done instead:
-			- R storage type is always == RKWard data type.
-			- Invalid values are stored in a list in an attribute of the variable in question
-			- The corresponding "real" fields are set to NA
-			- Need to add a conversion script. See .rk.get.meta (). Both should be changed at the same time.
-				- Not really, it's already broken, currently, after save / reload
+		- 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
 	- 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

Modified: trunk/rkward/rkward/core/rkvariable.cpp
===================================================================
--- trunk/rkward/rkward/core/rkvariable.cpp	2006-10-11 17:32:19 UTC (rev 847)
+++ trunk/rkward/rkward/core/rkvariable.cpp	2006-10-11 18:52:13 UTC (rev 848)
@@ -39,6 +39,7 @@
 RKVariable::RKVariable (RContainerObject *parent, const QString &name) : RObject (parent, name) {
 	RK_TRACE (OBJECTS);
 	type = Variable;
+	setDataType (RObject::DataNumeric);
 }
 
 RKVariable::~RKVariable () {
@@ -160,12 +161,19 @@
 			RK_ASSERT ((invalids_length % 2) == 0);
 			unsigned int invalids_count = invalids_length / 2;
 			for (unsigned int i=0; i < invalids_count; ++i) {
-				int row = invalids->getStringVector ()[i].toInt ();
+				int row = invalids->getStringVector ()[i].toInt () - 1;
 				if (myData ()->cell_states[row] & RKVarEditData::NA) {
 					setText (row, invalids->getStringVector ()[invalids_count + i]);
 				}
 			}
 		}
+
+		ChangeSet *set = new ChangeSet;
+		set->from_index = 0;
+		set->to_index = getLength ();
+		RKGlobals::tracker ()->objectDataChanged (this, set);
+		RKGlobals::tracker ()->objectMetaChanged (this);
+		setSyncing (true);
 	} else {
 		RK_ASSERT (false);
 	}
@@ -204,6 +212,10 @@
 	myData ()->invalid_fields.setAutoDelete (true);
 	
 	extendToLength (getLength ());
+
+	for (int i = 0; i < getLength (); ++i) {
+		myData ()->cell_states[i] = RKVarEditData::NA;
+	}
 }
 
 // virtual
@@ -213,7 +225,7 @@
 	
 	if (to_empty) {
 		for (int row=0; row < getLength (); ++row) {
-			myData ()->cell_states[row] = RKVarEditData::Unknown;
+			myData ()->cell_states[row] = RKVarEditData::NA;
 		}
 	} else {
 		RKGlobals::rInterface ()->issueCommand (".rk.get.vector.data (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetStructuredData, QString::null, this, GET_DATA_COMMAND);
@@ -461,15 +473,13 @@
 	RK_TRACE (OBJECTS);
 	RK_ASSERT (row < getLength ());
 
-	if (myData ()->cell_states[row] & ValueInvalid) {
+	if (myData ()->cell_states[row] & RKVarEditData::Invalid) {
 		myData ()->cell_states[row] = RKVarEditData::UnsyncedInvalidState;
 		myData ()->invalid_fields.remove (row);
 	} else {
 		myData ()->cell_states[row] = 0;
 	}
 
-	qDebug ("%d, %s", row, text.latin1 ());
-
 	if (text.isNull ()) {
 		myData ()->cell_states[row] |= RKVarEditData::NA;
 	} else {
@@ -489,25 +499,21 @@
 				myData ()->cell_states[row] |= RKVarEditData::Invalid | RKVarEditData::UnsyncedInvalidState;
 			}
 		} else {
-			qDebug ("1");
 			RK_ASSERT (myData ()->cell_doubles != 0);
 			bool ok;
-			myData ()->cell_doubles[row] = text.toDouble (&ok);
-			if (!ok) {
-				if (text.isEmpty ()) {
-					myData ()->cell_states[row] |= RKVarEditData::NA;
+			if (text.isEmpty ()) {
+				myData ()->cell_states[row] |= RKVarEditData::NA;
+			} else {
+				myData ()->cell_doubles[row] = text.toDouble (&ok);
+				if (ok) {
+					myData ()->cell_states[row] |= RKVarEditData::Valid;
 				} else {
 					myData ()->invalid_fields.replace (row, new QString (text));
 					myData ()->cell_states[row] |= RKVarEditData::Invalid | RKVarEditData::UnsyncedInvalidState;
 				}
-			} else {
-				qDebug ("here");
-				myData ()->cell_states[row] |= RKVarEditData::Valid;
 			}
 		}
 	}
-
-	qDebug ("new cell state %d: %d", row, myData ()->cell_states[row]);
 	cellChanged (row);
 }
 
@@ -557,8 +563,9 @@
 				myData ()->cell_states[row] |= RKVarEditData::NA;
 			} else {
 				myData ()->cell_states[row] |= RKVarEditData::Valid;
-				myData ()->cell_doubles[row] = data[i++];
+				myData ()->cell_doubles[row] = data[i];
 			}
+			++i;
 		}
 	}
 	cellsChanged (from_row, to_row);
@@ -655,12 +662,12 @@
 }
 
 void RKVariable::insertRows (int row, int count) {
-//	int old_len = getLength ();
+	int old_len = getLength ();
 	extendToLength (getLength () + count);
 
-/*	for (int i=old_len; i <= row+count; ++i) {
+	for (int i=old_len; i <= row+count; ++i) {
 		myData ()->cell_states[i] = RKVarEditData::NA;
-	} */
+	}
 
 	if (row >= getLength () && (count == 1)) {		// important special case
 		if (myData ()->cell_strings) myData ()->cell_strings[row+count] = myData ()->cell_strings[row];

Modified: trunk/rkward/rkward/core/rkvariable.h
===================================================================
--- trunk/rkward/rkward/core/rkvariable.h	2006-10-11 17:32:19 UTC (rev 847)
+++ trunk/rkward/rkward/core/rkvariable.h	2006-10-11 18:52:13 UTC (rev 848)
@@ -144,7 +144,7 @@
 			Invalid=1,
 			NA=2,
 			Valid=4,
-			UnsyncedInvalidState=4
+			UnsyncedInvalidState=8
 		};
 		int *cell_states;
 

Modified: trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp	2006-10-11 17:32:19 UTC (rev 847)
+++ trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp	2006-10-11 18:52:13 UTC (rev 848)
@@ -162,12 +162,10 @@
 	command = getObject ()->getFullName ();
 	command.append (" <- data.frame (");
 	
-	QString na_vector = "=rep (NA, " + QString::number (getColObject (0)->getLength ()) + ")";
+	QString na_vector = "=as.numeric (rep (NA, " + QString::number (getColObject (0)->getLength ()) + "))";
 	for (int col=0; col < table->numTrueCols (); col++) {
+		if (col != 0) command.append (", ");
 		command.append (getColObject (col)->getShortName () + na_vector);
-		if (col < (table->numTrueCols ()-1)) {
-			command.append (", ");
-		}
 	}
 	command.append (")");
 

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2006-10-11 17:32:19 UTC (rev 847)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2006-10-11 18:52:13 UTC (rev 848)
@@ -293,9 +293,9 @@
 		} else {
 			type <- 32
 			if (is.factor (x)) type <- type + 32768			# 2 << 14
-			else if (is.logical (x)) type <- type + 65536		# 4 << 14
 			else if (is.numeric (x)) type <- type + 16384		# 1 << 14
 			else if (is.character (x)) type <- type + 49152		# 3 << 14
+			else if (is.logical (x)) type <- type + 65536		# 4 << 14
 		}
 	}
 	if (!is.null (attr (x, ".rk.meta"))) type = type + 4096


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