Repository: pydap/pydap

Issue:
enable infinity for float attributes
enable infinity for float attributes

Discussion:

Patch:
diff --git a/src/pydap/parsers/das.py b/src/pydap/parsers/das.py
index 1618e89..72820d2 100644
--- a/src/pydap/parsers/das.py
+++ b/src/pydap/parsers/das.py
@@ -81,6 +81,10 @@ class DASParser(SimpleParser):
                 value = str(value).strip('"')
             elif value.lower() in ['nan', 'nan.', '-nan']:
                 value = float('nan')
+            elif value.lower() in ['inf', 'inf.']:
+                value = float('inf')
+            elif value.lower() in ['-inf', '-inf.']:
+                value = float('-inf')
             else:
                 value = ast.literal_eval(value)
 


Test patch:
diff --git a/src/pydap/tests/test_parsers_das.py b/src/pydap/tests/test_parsers_das.py
index 69aedee..b597670 100644
--- a/src/pydap/tests/test_parsers_das.py
+++ b/src/pydap/tests/test_parsers_das.py
@@ -26,6 +26,12 @@ DAS = """Attributes {
         Float32 COADSX 1e20;
         String COADSY "zero";
     }
+    floats {
+        Float64 a nan;
+        Float64 b -inf;
+        Float64 c inf;
+        Float64 d 17;
+    }
 }"""
 
 # It is important to add attributes that have the same
@@ -69,3 +75,10 @@ class TestParseDAS(unittest.TestCase):
         self.assertEqual(self.dataset.SPEH.attributes['TIME'], 0)
         self.assertEqual(self.dataset.SPEH.attributes['COADSX'], 1e20)
         self.assertEqual(self.dataset.SPEH.attributes['COADSY'], "zero")
+
+    def test_float_attributes(self):
+        """Test various values of float attributes."""
+        self.assertTrue(np.isnan(self.dataset.floats["a"]))
+        self.assertEqual(self.dataset.floats["b"], float("-inf"))
+        self.assertEqual(self.dataset.floats["c"], float("inf"))
+        self.assertEqual(self.dataset.floats["d"], 17.)