incubator-nuvem-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r1069715 - in /incubator/nuvem/trunk/nuvem-parallel: empty.py environment.py filter_.py first.py foreach.py list_.py reference.py rest.py test.py
Date Fri, 11 Feb 2011 09:01:17 GMT
Author: jsdelfino
Date: Fri Feb 11 09:01:16 2011
New Revision: 1069715

URL: http://svn.apache.org/viewvc?rev=1069715&view=rev
Log:
Starting to add components to work with lists, mapping and filtering.

Added:
    incubator/nuvem/trunk/nuvem-parallel/empty.py
      - copied, changed from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py
    incubator/nuvem/trunk/nuvem-parallel/environment.py
      - copied, changed from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py
    incubator/nuvem/trunk/nuvem-parallel/filter_.py
      - copied, changed from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py
    incubator/nuvem/trunk/nuvem-parallel/first.py
      - copied, changed from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py
    incubator/nuvem/trunk/nuvem-parallel/foreach.py
      - copied, changed from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py
    incubator/nuvem/trunk/nuvem-parallel/list_.py
      - copied, changed from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py
    incubator/nuvem/trunk/nuvem-parallel/rest.py
      - copied, changed from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py
Modified:
    incubator/nuvem/trunk/nuvem-parallel/reference.py
    incubator/nuvem/trunk/nuvem-parallel/test.py

Copied: incubator/nuvem/trunk/nuvem-parallel/empty.py (from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py)
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-parallel/empty.py?p2=incubator/nuvem/trunk/nuvem-parallel/empty.py&p1=incubator/nuvem/trunk/nuvem-parallel/reference.py&r1=1069698&r2=1069715&rev=1069715&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-parallel/reference.py (original)
+++ incubator/nuvem/trunk/nuvem-parallel/empty.py Fri Feb 11 09:01:16 2011
@@ -15,24 +15,6 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-# Mockup component references for testing
-
-class reference:
-    def __init__(self, name, l):
-        self.name = name
-        self.l = l
-
-    def __call__(self, *args):
-        return self.l(*args)
-
-    def __getattr__(self, name):
-        if name == "get":
-            return self
-        raise AttributeError()
-
-    def __repr__(self):
-        return repr((self.name, self.l))
-
-def mkref(name, l):
-    return reference(name, l)
+def get(id):
+    return ()
 

Copied: incubator/nuvem/trunk/nuvem-parallel/environment.py (from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py)
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-parallel/environment.py?p2=incubator/nuvem/trunk/nuvem-parallel/environment.py&p1=incubator/nuvem/trunk/nuvem-parallel/reference.py&r1=1069698&r2=1069715&rev=1069715&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-parallel/reference.py (original)
+++ incubator/nuvem/trunk/nuvem-parallel/environment.py Fri Feb 11 09:01:16 2011
@@ -15,24 +15,23 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-# Mockup component references for testing
+# Mockup request environment variable for testing
 
-class reference:
-    def __init__(self, name, l):
+class environment:
+    def __init__(self, name):
         self.name = name
-        self.l = l
+        self.value = None
 
-    def __call__(self, *args):
-        return self.l(*args)
+    def get(self, id):
+        return self.value
 
-    def __getattr__(self, name):
-        if name == "get":
-            return self
-        raise AttributeError()
+    def put(self, id, value):
+        self.value = value
+        return True
 
     def __repr__(self):
-        return repr((self.name, self.l))
+        return repr((self.name, self.value))
 
-def mkref(name, l):
-    return reference(name, l)
+def mkenv(name):
+    return environment(name)
 

Copied: incubator/nuvem/trunk/nuvem-parallel/filter_.py (from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py)
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-parallel/filter_.py?p2=incubator/nuvem/trunk/nuvem-parallel/filter_.py&p1=incubator/nuvem/trunk/nuvem-parallel/reference.py&r1=1069698&r2=1069715&rev=1069715&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-parallel/reference.py (original)
+++ incubator/nuvem/trunk/nuvem-parallel/filter_.py Fri Feb 11 09:01:16 2011
@@ -15,24 +15,10 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-# Mockup component references for testing
+def get(id, var, cond, l):
+    def cfun(i):
+        var.put(('var',), i)
+        return cond.get(())
 
-class reference:
-    def __init__(self, name, l):
-        self.name = name
-        self.l = l
-
-    def __call__(self, *args):
-        return self.l(*args)
-
-    def __getattr__(self, name):
-        if name == "get":
-            return self
-        raise AttributeError()
-
-    def __repr__(self):
-        return repr((self.name, self.l))
-
-def mkref(name, l):
-    return reference(name, l)
+    return tuple(filter(cfun, l.get(())))
 

Copied: incubator/nuvem/trunk/nuvem-parallel/first.py (from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py)
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-parallel/first.py?p2=incubator/nuvem/trunk/nuvem-parallel/first.py&p1=incubator/nuvem/trunk/nuvem-parallel/reference.py&r1=1069698&r2=1069715&rev=1069715&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-parallel/reference.py (original)
+++ incubator/nuvem/trunk/nuvem-parallel/first.py Fri Feb 11 09:01:16 2011
@@ -15,24 +15,6 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-# Mockup component references for testing
-
-class reference:
-    def __init__(self, name, l):
-        self.name = name
-        self.l = l
-
-    def __call__(self, *args):
-        return self.l(*args)
-
-    def __getattr__(self, name):
-        if name == "get":
-            return self
-        raise AttributeError()
-
-    def __repr__(self):
-        return repr((self.name, self.l))
-
-def mkref(name, l):
-    return reference(name, l)
+def get(id, l):
+    return l.get(())[0]
 

Copied: incubator/nuvem/trunk/nuvem-parallel/foreach.py (from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py)
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-parallel/foreach.py?p2=incubator/nuvem/trunk/nuvem-parallel/foreach.py&p1=incubator/nuvem/trunk/nuvem-parallel/reference.py&r1=1069698&r2=1069715&rev=1069715&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-parallel/reference.py (original)
+++ incubator/nuvem/trunk/nuvem-parallel/foreach.py Fri Feb 11 09:01:16 2011
@@ -15,24 +15,10 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-# Mockup component references for testing
+def get(id, var, transform, l):
+    def tfun(i):
+        var.put(('var',), i)
+        return transform.get(())
 
-class reference:
-    def __init__(self, name, l):
-        self.name = name
-        self.l = l
-
-    def __call__(self, *args):
-        return self.l(*args)
-
-    def __getattr__(self, name):
-        if name == "get":
-            return self
-        raise AttributeError()
-
-    def __repr__(self):
-        return repr((self.name, self.l))
-
-def mkref(name, l):
-    return reference(name, l)
+    return tuple(map(tfun, l.get(())))
 

Copied: incubator/nuvem/trunk/nuvem-parallel/list_.py (from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py)
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-parallel/list_.py?p2=incubator/nuvem/trunk/nuvem-parallel/list_.py&p1=incubator/nuvem/trunk/nuvem-parallel/reference.py&r1=1069698&r2=1069715&rev=1069715&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-parallel/reference.py (original)
+++ incubator/nuvem/trunk/nuvem-parallel/list_.py Fri Feb 11 09:01:16 2011
@@ -15,24 +15,9 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-# Mockup component references for testing
-
-class reference:
-    def __init__(self, name, l):
-        self.name = name
-        self.l = l
-
-    def __call__(self, *args):
-        return self.l(*args)
-
-    def __getattr__(self, name):
-        if name == "get":
-            return self
-        raise AttributeError()
-
-    def __repr__(self):
-        return repr((self.name, self.l))
-
-def mkref(name, l):
-    return reference(name, l)
+def get(id, first, rest):
+    r = rest.get(())
+    if r is None:
+        return (first.get(()),)
+    return (first.get(()),) + r
 

Modified: incubator/nuvem/trunk/nuvem-parallel/reference.py
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-parallel/reference.py?rev=1069715&r1=1069714&r2=1069715&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-parallel/reference.py (original)
+++ incubator/nuvem/trunk/nuvem-parallel/reference.py Fri Feb 11 09:01:16 2011
@@ -26,7 +26,7 @@ class reference:
         return self.l(*args)
 
     def __getattr__(self, name):
-        if name == "get":
+        if name == "get" or name == "put":
             return self
         raise AttributeError()
 

Copied: incubator/nuvem/trunk/nuvem-parallel/rest.py (from r1069698, incubator/nuvem/trunk/nuvem-parallel/reference.py)
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-parallel/rest.py?p2=incubator/nuvem/trunk/nuvem-parallel/rest.py&p1=incubator/nuvem/trunk/nuvem-parallel/reference.py&r1=1069698&r2=1069715&rev=1069715&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-parallel/reference.py (original)
+++ incubator/nuvem/trunk/nuvem-parallel/rest.py Fri Feb 11 09:01:16 2011
@@ -15,24 +15,6 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-# Mockup component references for testing
-
-class reference:
-    def __init__(self, name, l):
-        self.name = name
-        self.l = l
-
-    def __call__(self, *args):
-        return self.l(*args)
-
-    def __getattr__(self, name):
-        if name == "get":
-            return self
-        raise AttributeError()
-
-    def __repr__(self):
-        return repr((self.name, self.l))
-
-def mkref(name, l):
-    return reference(name, l)
+def get(id, l):
+    return l.get(())[1:]
 

Modified: incubator/nuvem/trunk/nuvem-parallel/test.py
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-parallel/test.py?rev=1069715&r1=1069714&r2=1069715&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-parallel/test.py (original)
+++ incubator/nuvem/trunk/nuvem-parallel/test.py Fri Feb 11 09:01:16 2011
@@ -21,6 +21,7 @@
 import unittest
 from property import *
 from reference import *
+from environment import *
 
 import true_
 import false_
@@ -36,6 +37,12 @@ import not_
 import equals
 import lesser
 import greater
+import list_
+import empty
+import first
+import rest
+import foreach
+import filter_
 
 def testValues():
     assert true_.get(()) == True
@@ -61,6 +68,20 @@ def testValues():
     assert greater.get((), mkref('a', lambda id: 'abc'), mkref('b', lambda id: 'abc')) ==
False
     assert greater.get((), mkref('a', lambda id: 'def'), mkref('b', lambda id: 'abc')) ==
True
 
+    assert list_.get((), mkref('first', lambda id: 'abc'), mkref('rest', lambda id: None))
== ('abc',)
+    assert list_.get((), mkref('first', lambda id: 'abc'), mkref('rest', lambda id: ()))
== ('abc',)
+    assert list_.get((), mkref('first', lambda id: 'abc'), mkref('rest', lambda id: ('def',)))
== ('abc','def')
+    assert list_.get((), mkref('first', lambda id: 'abc'), mkref('rest', lambda id: ('def',
'ghi'))) == ('abc','def', 'ghi')
+    assert empty.get(()) == ()
+    assert first.get((), mkref('l', lambda id: ('abc', 'def'))) == 'abc'
+    assert rest.get((), mkref('l', lambda id: ('abc', 'def', 'ghi'))) == ('def', 'ghi')
+    assert rest.get((), mkref('l', lambda id: ('abc',))) == ()
+
+    foreachenv = mkenv('foreach')
+    assert foreach.get((), foreachenv, mkref('transform', lambda id: foreachenv.get(()) *
2), mkref('list', lambda id: (1, 2, 3))) == (2, 4, 6)
+
+    filterenv = mkenv('filter')
+    assert filter_.get((), filterenv, mkref('transform', lambda id: filterenv.get(()) % 2
== 0), mkref('list', lambda id: (1, 2, 3, 4))) == (2, 4)
     return True
 
 if __name__ == '__main__':



Mime
View raw message