changeset 111:c4d26ef63d8e

fix error in convert and i think this works sorta well enouigh for now
author Jeff Hammel <k0scist@gmail.com>
date Sun, 15 Mar 2015 15:38:12 -0700
parents 5790bcb30bd8
children 7578313b9fbf
files numerics/convert.py numerics/manipulate.py
diffstat 2 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/numerics/convert.py	Sun Mar 15 15:28:15 2015 -0700
+++ b/numerics/convert.py	Sun Mar 15 15:38:12 2015 -0700
@@ -38,11 +38,18 @@
     cast to `to_type` if possible;
     otherwise just throw away
     """
-    raise NotImplementedError('TODO') # -> record TODO items
+    retval = []
+    for value in values:
+        try:
+            retval.append(to_type(value))
+        except ValueError:
+            continue
+    return retval
+
 
 def float_or_orig(*values):
     return cast(float, *values)
-
+    # convenience function ; do we need this?
 
 def column_type(values, types=default_cast):
     """determine the type of a column"""
@@ -55,7 +62,6 @@
         else:
             return t
 
-    raise NotImplementedError('TODO') # -> record TODO items
 
 def cast_columns(columns, types=default_cast):
     """
@@ -63,8 +69,8 @@
     """
     column_types = [column_type(column, types=types)
                     for column in columns]
-    return [[column_type(row) for row in column]
-            for column_type, column in zip(column_types, columns)]
+    return [[_type(row) for row in column]
+            for _type, column in zip(column_types, columns)]
 
 
 def main(args=sys.argv[1:]):
--- a/numerics/manipulate.py	Sun Mar 15 15:28:15 2015 -0700
+++ b/numerics/manipulate.py	Sun Mar 15 15:38:12 2015 -0700
@@ -34,6 +34,7 @@
     def process(self):
         return transpose(self.typed_data())
 
+
 def main(args=sys.argv[1:]):
     """CLI"""