Replaced set_naively with set(normalize=False).
authorEevee <ferrox@veekun.com>
Wed, 17 Dec 2008 08:44:09 +0000 (00:44 -0800)
committerEevee <ferrox@veekun.com>
Wed, 17 Dec 2008 08:44:09 +0000 (00:44 -0800)
pseudoku/grid/__init__.py

index 9370dd6..94d0833 100644 (file)
@@ -63,18 +63,14 @@ class Cell(object):
         self._values = range(self._grid.size)
         self._normalized = False
 
-    def set_naively(self, value):
-        """Sets the value of this cell, WITHOUT eliminating the value from
-        every other cell in its row/column/box.
+    def set(self, value, normalize=True):
+        """Sets the value of this cell.  If `normalize` is True or omitted, the
+        grid will be updated accordingly.
         """
-
         self._values = [value]
-
-    def set(self, value):
-        """Sets the value of this cell and adjusts the grid accordingly."""
-        self.set_naively(value)
-        self._normalized = False
-        self.normalize()
+        if normalize:
+            self._normalized = False
+            self.normalize()
 
 
 
@@ -214,7 +210,7 @@ class Grid(object):
                 value = rows[row][col]
                 if not value:
                     continue
-                self.cell(row, col).set_naively(value - 1)
+                self.cell(row, col).set(value - 1, normalize=False)
 
         return self
 
@@ -253,7 +249,7 @@ class Grid(object):
                 ch = grid[ self._cellidx(row, col) ]
                 if ch == '0':
                     continue
-                self.cell(row, col).set_naively(symbols.index(ch))
+                self.cell(row, col).set(symbols.index(ch), normalize=False)
 
         return self