diff --git a/loopy/statistics.py b/loopy/statistics.py
index d1108dd2aa12003119525c4d01106eca52c5eb2c..a1e8c764857dcaf786f582696e32f22ef71c78e9 100755
--- a/loopy/statistics.py
+++ b/loopy/statistics.py
@@ -64,6 +64,15 @@ class TypeToOpCountMap:
 
     __rmul__ = __mul__
 
+    def __getitem__(self, index):
+        try:
+            return self.dict[index]
+        except KeyError:
+            return isl.PwQPolynomial('{ 0 }')
+
+    def __setitem__(self, index, value):
+        self.dict[index] = value
+
     def __str__(self):
         return str(self.dict)
 
diff --git a/test/test_statistics.py b/test/test_statistics.py
index 54d08a49817f6f0240995a820acec392d651207c..e68700833b4a4b41bef5051b030aed92206622c6 100644
--- a/test/test_statistics.py
+++ b/test/test_statistics.py
@@ -143,7 +143,9 @@ def test_op_counter_bitwise(ctx_factory):
     m = 256
     l = 128
     i32 = poly.dict[np.dtype(np.int32)].eval_with_dict({'n': n, 'm': m, 'l': l})
+    not_there = poly[np.dtype(np.float64)].eval_with_dict({'n': n, 'm': m, 'l': l})
     assert i32 == 3*n*m+n*m*l
+    assert not_there == 0
 
 if __name__ == "__main__":
     if len(sys.argv) > 1: