[Scipy-svn] r3923 - trunk/scipy/stats/models

scipy-svn@scip... scipy-svn@scip...
Tue Feb 12 14:26:41 CST 2008


Author: jonathan.taylor
Date: 2008-02-12 14:26:33 -0600 (Tue, 12 Feb 2008)
New Revision: 3923

Modified:
   trunk/scipy/stats/models/formula.py
Log:
clarifying docstring, enforcing unique keys for ordinal factors


Modified: trunk/scipy/stats/models/formula.py
===================================================================
--- trunk/scipy/stats/models/formula.py	2008-02-12 19:47:39 UTC (rev 3922)
+++ trunk/scipy/stats/models/formula.py	2008-02-12 20:26:33 UTC (rev 3923)
@@ -139,7 +139,11 @@
         Factor is initialized with keys, representing all valid
         levels of the factor.
 
-        If ordinal is True, the order is taken from the keys.
+        If ordinal is False, keys can have repeats: set(keys) is what is
+        used.
+
+        If ordinal is True, the order is taken from the keys, and
+        there should be no repeats.
         """
 
         if not ordinal:
@@ -147,6 +151,8 @@
             self.keys.sort()
         else:
             self.keys = keys
+            if len(set(keys)) != len(list(keys)):
+                raise ValueError, 'keys for ordinal Factor should be unique, in increasing order'
         self._name = termname
         self.termname = termname
         self.ordinal = ordinal



More information about the Scipy-svn mailing list