diff numerics/reduce.py @ 127:c9ae21955ca5

how to make this really small
author Jeff Hammel <k0scist@gmail.com>
date Mon, 16 Mar 2015 20:00:43 -0700
parents 575c8e44227c
children
line wrap: on
line diff
--- a/numerics/reduce.py	Mon Mar 16 19:55:41 2015 -0700
+++ b/numerics/reduce.py	Mon Mar 16 20:00:43 2015 -0700
@@ -18,13 +18,14 @@
 class ReduceParser(FloatParser):
     """CLI option parser"""
 
-    # reducing function
-    function = lambda x: raise NotImplemented("Abstract base class")
+    def __init__(self, function, **kwargs):
+        """
+        function -- reducing function
+        """
 
-    def __init__(self, **kwargs):
+        self.function = function
         kwargs.setdefault('description', __doc__)
-        argparse.ArgumentParser.__init__(self, **kwargs)
-        self.options = None
+        FloatParser.__init__(self, **kwargs)
 
     def __call__(self, *args):
 
@@ -37,8 +38,8 @@
             self.error("No data given")
 
         # calculate scalars
-        data = [self.function(column) for column in column]
+        data = [self.function(column) for column in columns]
 
         # write CSV
-        writer = CSVWriter(options.output)
+        writer = CSVWriter(self.options.output)
         writer.write([data])