How to use the porespy.generators.insert_shape function in porespy

To help you get started, we’ve selected a few porespy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PMEAL / porespy / test / unit / test_generators.py View on Github external
def test_insert_shape_center_defaults(self):
        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, center=[5, 5])
        assert sp.sum(im) == sp.prod(shape.shape)

        im = sp.zeros([11, 11])
        shape = sp.ones([4, 4])
        with pytest.raises(Exception):
            im = ps.generators.insert_shape(im, element=shape, center=[5, 5])
github PMEAL / porespy / test / unit / test_generators.py View on Github external
def test_insert_shape_corner_outside_im(self):
        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, corner=[-1, -1])
        assert sp.sum(im) == 4

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, corner=[-1, 1])
        assert sp.sum(im) == 6

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, corner=[-3, -3])
        assert sp.sum(im) == 0

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, corner=[10, 9])
        assert sp.sum(im) == 2

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, corner=[13, 13])
        assert sp.sum(im) == 0
github PMEAL / porespy / test / unit / test_generators.py View on Github external
assert sp.sum(im) == 2

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, center=[10, 10])
        assert sp.sum(im) == 4

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, center=[14, 14])
        assert sp.sum(im) == 0

        im = sp.zeros([11, 11])
        shape = sp.ones([4, 4])
        with pytest.raises(Exception):
            im = ps.generators.insert_shape(im, element=shape, center=[10, 10])

        im = sp.zeros([11, 11])
        shape = sp.ones([4, 3])
        with pytest.raises(Exception):
            im = ps.generators.insert_shape(im, element=shape, center=[10, 10])
github PMEAL / porespy / test / unit / test_generators.py View on Github external
def test_insert_shape_corner_overwrite(self):
        im = sp.ones([10, 10])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, corner=[5, 5],
                                        value=1.0, mode='overlay')
        assert sp.sum(im) == (sp.prod(im.shape) + sp.prod(shape.shape))
        assert im[5, 5] == 2
        assert im[4, 5] == 1 and im[5, 4] == 1
github PMEAL / porespy / test / unit / test_generators.py View on Github external
def test_insert_shape_center_overlay(self):
        im = sp.ones([10, 10])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, center=[5, 5],
                                        value=1.0, mode='overlay')
        assert sp.sum(im) == (sp.prod(im.shape) + sp.prod(shape.shape))
github PMEAL / porespy / test / unit / test_generators.py View on Github external
def test_insert_shape_center_defaults(self):
        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, center=[5, 5])
        assert sp.sum(im) == sp.prod(shape.shape)

        im = sp.zeros([11, 11])
        shape = sp.ones([4, 4])
        with pytest.raises(Exception):
            im = ps.generators.insert_shape(im, element=shape, center=[5, 5])
github PMEAL / porespy / test / unit / test_generators.py View on Github external
def test_insert_shape_center_outside_im(self):
        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, center=[-1, -1])
        assert sp.sum(im) == 1

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, center=[0, -1])
        assert sp.sum(im) == 2

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, center=[10, 10])
        assert sp.sum(im) == 4

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, center=[14, 14])
        assert sp.sum(im) == 0

        im = sp.zeros([11, 11])
        shape = sp.ones([4, 4])
        with pytest.raises(Exception):
            im = ps.generators.insert_shape(im, element=shape, center=[10, 10])
github PMEAL / porespy / test / unit / test_generators.py View on Github external
im = ps.generators.insert_shape(im, element=shape, corner=[-3, -3])
        assert sp.sum(im) == 0

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, corner=[10, 9])
        assert sp.sum(im) == 2

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 3])
        im = ps.generators.insert_shape(im, element=shape, corner=[13, 13])
        assert sp.sum(im) == 0

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 4])
        im = ps.generators.insert_shape(im, element=shape, corner=[9, 9])
        assert sp.sum(im) == 4

        im = sp.zeros([11, 11])
        shape = sp.ones([3, 4])
        im = ps.generators.insert_shape(im, element=shape, corner=[0, -1])
        assert sp.sum(im) == 9