def test_descriptor_setitem(self):
     if not netCDF4_is_here: return
     dd = netCDF4_DDesc(self.nc4_file, '/g/a2', mode='a')
     self.assertEqual(dd.dshape, datashape.dshape('2 * 3 * int64'))
     dd[1,2] = 10
     self.assertEqual(ddesc_as_py(dd[1,2]), 10)
     dd[1] = [10, 11, 12]
     self.assertEqual(ddesc_as_py(dd[1]), [10, 11, 12])
 def test_descriptor_getitem_types(self):
     if not netCDF4_is_here: return
     dd = netCDF4_DDesc(self.nc4_file, '/g/a2')
     self.assertEqual(dd.dshape, datashape.dshape('2 * 3 * int64'))
     # Indexing should produce DyND_DDesc instances
     self.assertTrue(isinstance(dd[0], DyND_DDesc))
     self.assertEqual(ddesc_as_py(dd[0]), [1,2,3])
     self.assertTrue(isinstance(dd[1,2], DyND_DDesc))
     self.assertEqual(ddesc_as_py(dd[1,2]), 1)
 def test_basic_object_type(self):
     # For reasons that I ignore, the above decorator is not working for
     # 2.6, so will disable the tests the hard way...
     if not netCDF4_is_here: return
     self.assertTrue(issubclass(netCDF4_DDesc, DDesc))
     dd = netCDF4_DDesc(self.nc4_file, '/a1')
     # Make sure the right type is returned
     self.assertTrue(isinstance(dd, DDesc))
     self.assertEqual(ddesc_as_py(dd), [[1, 2, 3], [4, 5, 6]])
 def test_descriptor_append(self):
     if True: return
     dd = netCDF4_DDesc(self.nc4_file, '/t1', mode='a')
     tshape = datashape.dshape(
         '2 * { f0 : int32, f1 : int64, f2 : float64 }')
     self.assertEqual(dd.dshape, tshape)
     dd.append([(10, 11, 12)])
     dvals = {'f0': 10, 'f1': 11, 'f2': 12.}
     rvals = ddesc_as_py(dd[2])
     is_equal = [(rvals[k] == dvals[k]) for k in dvals]
     self.assertEqual(is_equal, [True]*3)
 def test_descriptor_iter_types(self):
     if not netCDF4_is_here: return
     dd = netCDF4_DDesc(self.nc4_file, '/a1')
     self.assertEqual(dd.dshape, datashape.dshape('2 * 3 * int32'))
     # Iteration should produce DyND_DDesc instances
     vals = []
     for el in dd:
         self.assertTrue(isinstance(el, DyND_DDesc))
         self.assertTrue(isinstance(el, DDesc))
         vals.append(ddesc_as_py(el))
     self.assertEqual(vals, [[1, 2, 3], [4, 5, 6]])