def test_source_fromMask_binary(self): """ (SourceConstruction) from mask """ mask = zeros((10, 10)) mask[5, 5] = 1 mask[5, 6] = 1 mask[5, 7] = 1 s = Source.fromMask(mask) assert(isinstance(s, Source)) assert(isinstance(s.coordinates, ndarray)) assert(array_equal(s.coordinates, array([[5, 5], [5, 6], [5, 7]]))) assert(array_equal(s.mask((10, 10), binary=True), mask)) assert(array_equal(s.mask((10, 10), binary=False), mask))
def test_source_fromMask_values(self): """ (SourceConstruction) from mask with values """ mask = zeros((10, 10)) mask[5, 5] = 0.5 mask[5, 6] = 0.6 mask[5, 7] = 0.7 s = Source.fromMask(mask) assert(isinstance(s, Source)) assert(isinstance(s.coordinates, ndarray)) assert(isinstance(s.values, ndarray)) assert(array_equal(s.coordinates, array([[5, 5], [5, 6], [5, 7]]))) assert(array_equal(s.values, array([0.5, 0.6, 0.7]))) assert(array_equal(s.mask((10, 10), binary=False), mask))