def test_boolean(self): ptype = 'boolean' encoding = 'int8' fill_value = 'false' context = self.get_context(ptype, encoding, fill_value) paramval = self.get_pval(context) paramval[:] = context.fill_value [self.assertEquals(paramval[i], context.fill_value) for i in xrange(20)] paramval[:] = [1] * 20 [self.assertTrue(paramval[i]) for i in xrange(20)] self.assertEquals(get_fill_value('true',encoding), 1, ptype) self.rdt_to_granule(context, [1] * 20, [True] * 20)
def test_range_type(self): ptype = 'range<quantity>' encoding = 'int32' fill_value = '(-9999, -9998)' context = self.get_context(ptype, encoding, fill_value) paramval = self.get_pval(context) print '>>>>>>' print context.fill_value print type(context.fill_value) print type(get_fill_value(fill_value, encoding, context.param_type)) [self.assertEquals(paramval[i], context.fill_value) for i in xrange(20)] paramval[:] = (0,1000) [self.assertEquals(paramval[i], (0,1000)) for i in xrange(20)] self.rdt_to_granule(context, (0,1000), (0,1000))
def test_boolean(self): ptype = 'boolean' encoding = 'int8' fill_value = 'false' context = self.get_context(ptype, encoding, fill_value) paramval = self.get_pval(context) paramval[:] = context.fill_value [ self.assertEquals(paramval[i], context.fill_value) for i in xrange(20) ] paramval[:] = [1] * 20 [self.assertTrue(paramval[i]) for i in xrange(20)] self.assertEquals(get_fill_value('true', encoding), 1, ptype) self.rdt_to_granule(context, [1] * 20, [True] * 20)
def test_range_type(self): ptype = 'range<quantity>' encoding = 'int32' fill_value = '(-9999, -9998)' context = self.get_context(ptype, encoding, fill_value) paramval = self.get_pval(context) print '>>>>>>' print context.fill_value print type(context.fill_value) print type(get_fill_value(fill_value, encoding, context.param_type)) [ self.assertEquals(paramval[i], context.fill_value) for i in xrange(20) ] paramval[:] = (0, 1000) [self.assertEquals(paramval[i], (0, 1000)) for i in xrange(20)] self.rdt_to_granule(context, (0, 1000), (0, 1000))
def get_context(self, ptype, encoding, fill_value, codeset=None): ptype = get_parameter_type(ptype, encoding, codeset) context = ParameterContext(name='test', param_type=ptype) context.fill_value = get_fill_value(fill_value, encoding, ptype) return context