pitivi r1174 - in branches/SOC_2008_BLEWIS: . pitivi tests



Author: blewis
Date: Wed Jul 16 23:23:21 2008
New Revision: 1174
URL: http://svn.gnome.org/viewvc/pitivi?rev=1174&view=rev

Log:
* pitivi/pitivi.py:
made the args paramerter to PiTiVi optional, since my previous commit
broke a lot of test cases.
* pitivi/utils.py:
added a modified binary search algorithm
* tests/testcomplex.py:
* tests/testHList.py:
moved here from UI
* tests/runtests.py:
ignores the UI test files, since they are not unit tests


Added:
   branches/SOC_2008_BLEWIS/tests/testHList.py
      - copied unchanged from r1171, /branches/SOC_2008_BLEWIS/pitivi/ui/testHList.py
   branches/SOC_2008_BLEWIS/tests/testcomplex.py
      - copied unchanged from r1171, /branches/SOC_2008_BLEWIS/pitivi/ui/testcomplex.py
Modified:
   branches/SOC_2008_BLEWIS/ChangeLog
   branches/SOC_2008_BLEWIS/pitivi/pitivi.py
   branches/SOC_2008_BLEWIS/pitivi/utils.py
   branches/SOC_2008_BLEWIS/tests/runtests.py

Modified: branches/SOC_2008_BLEWIS/pitivi/pitivi.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/pitivi.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/pitivi.py	Wed Jul 16 23:23:21 2008
@@ -90,7 +90,7 @@
                        ( ))
         }
 
-    def __init__(self, args, use_ui=True):
+    def __init__(self, args=[], use_ui=True):
         """
         initialize pitivi with the command line arguments
         """

Modified: branches/SOC_2008_BLEWIS/pitivi/utils.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/utils.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/utils.py	Wed Jul 16 23:23:21 2008
@@ -36,3 +36,26 @@
         if isinstance(elt, gst.Bin) and bin_contains(elt, element):
             return True
     return False
+
+# Python re-implementation of binary search found here:
+# http://en.wikipedia.org/wiki/Binary_search
+#
+# This is the iterative version without the early termination branch, which
+# also tells us the element of A that are nearest to Value, if the element we want
+# is not found. This is useful for implementing edge snaping in the UI, where
+# we repeatedly search through a list of control points for the one closes to
+# the cursor. Because we don't care whether the cursor position matches the
+# list, this function returns the element closest to value in the array.
+
+def binary_search(A, value):
+    low = 0
+    high = len(A)
+    while (low < high): 
+        mid = (low + high)/2
+        if (A[mid] < value):
+            low = mid + 1
+        else:
+            #can't be high = mid-1: here A[mid] >= value,
+            #so high can't be < mid if A[mid] == value
+            high = mid; 
+    return low

Modified: branches/SOC_2008_BLEWIS/tests/runtests.py
==============================================================================
--- branches/SOC_2008_BLEWIS/tests/runtests.py	(original)
+++ branches/SOC_2008_BLEWIS/tests/runtests.py	Wed Jul 16 23:23:21 2008
@@ -3,7 +3,7 @@
 import sys
 import unittest
 
-SKIP_FILES = ['common', 'runtests']
+SKIP_FILES = ['common', 'runtests', 'testcomplex', 'testHList', 'testdrag']
 
 def gettestnames(which):
     if not which:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]