本文整理汇总了Python中iris._data_manager.DataManager.replace方法的典型用法代码示例。如果您正苦于以下问题:Python DataManager.replace方法的具体用法?Python DataManager.replace怎么用?Python DataManager.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iris._data_manager.DataManager
的用法示例。
在下文中一共展示了DataManager.replace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_real_with_real
# 需要导入模块: from iris._data_manager import DataManager [as 别名]
# 或者: from iris._data_manager.DataManager import replace [as 别名]
def test_real_with_real(self):
dm = DataManager(self.real_array * 10)
self.assertFalse(dm.has_lazy_data())
dm.replace(self.real_array)
self.assertFalse(dm.has_lazy_data())
self.assertIs(dm._real_array, self.real_array)
self.assertIs(dm.data, self.real_array)
示例2: test__clear_fill_value_masked
# 需要导入模块: from iris._data_manager import DataManager [as 别名]
# 或者: from iris._data_manager.DataManager import replace [as 别名]
def test__clear_fill_value_masked(self):
fill_value = 1234
dm = DataManager(np.array(0), fill_value=fill_value)
self.assertEqual(dm.fill_value, fill_value)
data = ma.masked_array(1, fill_value=4321)
dm.replace(data)
self.assertIsNone(dm.fill_value)
示例3: test_real_with_real__promote_shape_with_dtype_failure
# 需要导入模块: from iris._data_manager import DataManager [as 别名]
# 或者: from iris._data_manager.DataManager import replace [as 别名]
def test_real_with_real__promote_shape_with_dtype_failure(self):
data = np.array(666)
dm = DataManager(data)
emsg = 'Cannot set realised dtype, no lazy data is available'
with self.assertRaisesRegexp(ValueError, emsg):
dm.replace(np.array([999]),
realised_dtype=np.dtype('float32'))
self.assertArrayEqual(dm.data, data)
示例4: test_real_with_real__realised_dtype_failure
# 需要导入模块: from iris._data_manager import DataManager [as 别名]
# 或者: from iris._data_manager.DataManager import replace [as 别名]
def test_real_with_real__realised_dtype_failure(self):
dm = DataManager(self.real_array)
emsg = 'Cannot set realised dtype, no lazy data is available.'
with self.assertRaisesRegexp(ValueError, emsg):
dm.replace(self.real_array * 10,
realised_dtype=np.dtype('int16'))
self.assertIs(dm._real_array, self.real_array)
self.assertArrayEqual(dm.data, self.real_array)
示例5: test_lazy_with_lazy
# 需要导入模块: from iris._data_manager import DataManager [as 别名]
# 或者: from iris._data_manager.DataManager import replace [as 别名]
def test_lazy_with_lazy(self):
lazy_array = as_lazy_data(self.real_array)
dm = DataManager(lazy_array * 10)
self.assertTrue(dm.has_lazy_data())
dm.replace(lazy_array)
self.assertTrue(dm.has_lazy_data())
self.assertIs(dm._lazy_array, lazy_array)
self.assertArrayEqual(dm.data, self.real_array)
示例6: test_real_with_lazy__realised_dtype_setter_none
# 需要导入模块: from iris._data_manager import DataManager [as 别名]
# 或者: from iris._data_manager.DataManager import replace [as 别名]
def test_real_with_lazy__realised_dtype_setter_none(self):
mask_array = ma.masked_array(self.real_array) * 10
dtype = mask_array.dtype
lazy_array = as_lazy_data(mask_array)
dm = DataManager(self.real_array)
self.assertFalse(dm.has_lazy_data())
self.assertIsNone(dm._realised_dtype)
self.assertEqual(dm.dtype, dtype)
dm.replace(lazy_array, realised_dtype=dtype)
self.assertTrue(dm.has_lazy_data())
self.assertIsNone(dm._realised_dtype)
self.assertEqual(dm.dtype, dtype)
self.assertIs(dm._lazy_array, lazy_array)
self.assertArrayEqual(dm.data, mask_array)
示例7: test_lazy_with_real__realised_dtype_none
# 需要导入模块: from iris._data_manager import DataManager [as 别名]
# 或者: from iris._data_manager.DataManager import replace [as 别名]
def test_lazy_with_real__realised_dtype_none(self):
mask_array = ma.arange(self.size).reshape(self.shape)
dtype = mask_array.dtype
lazy_array = as_lazy_data(mask_array)
dm = DataManager(lazy_array, realised_dtype=dtype)
self.assertTrue(dm.has_lazy_data())
self.assertIsNone(dm._realised_dtype, dtype)
self.assertEqual(dm.dtype, dtype)
dm.replace(mask_array)
self.assertFalse(dm.has_lazy_data())
self.assertIsNone(dm._realised_dtype)
self.assertEqual(dm.dtype, dtype)
self.assertIs(dm._real_array, mask_array)
self.assertIs(dm.data, mask_array)
示例8: test__set_fill_value_failure
# 需要导入模块: from iris._data_manager import DataManager [as 别名]
# 或者: from iris._data_manager.DataManager import replace [as 别名]
def test__set_fill_value_failure(self):
dm = DataManager(np.array(0))
self.assertIsNone(dm.fill_value)
emsg = 'Fill value of .* invalid for dtype'
with self.assertRaisesRegexp(ValueError, emsg):
dm.replace(np.array(1), fill_value=1e+20)
示例9: test__set_fill_value
# 需要导入模块: from iris._data_manager import DataManager [as 别名]
# 或者: from iris._data_manager.DataManager import replace [as 别名]
def test__set_fill_value(self):
fill_value = 1234
dm = DataManager(np.array(0))
self.assertIsNone(dm.fill_value)
dm.replace(np.array(0), fill_value=fill_value)
self.assertEqual(dm.fill_value, fill_value)