<commit_before>import OpenPNM
from os.path import join
import scipy as sp
from OpenPNM.Utilities import topology
mgr = OpenPNM.Base.Workspace()
topo = topology()


def test_subdivide():
    pn = OpenPNM.Network.Cubic(shape=[5, 5, 5],
                               spacing=0.001,
                               name='micro_net')
    pn['pore.micro'] = True
    nano_pores = [2, 13, 14, 15]
    pn.subdivide(pores=nano_pores, shape=[4, 4, 4], labels='nano')
    assert pn.Np == (125+4*64-4)
    assert pn.Nt == (300+(4*144)-16+15*16+16)


def test_subdivide_boundary():
    pn = OpenPNM.Network.Cubic(shape=[5, 5, 5],
                               spacing=0.001)
    pn.add_boundaries()
    pn['pore.micro'] = True
    nano_pores = [2, 13, 126, 15]
    try:
        pn.subdivide(pores=nano_pores, shape=[4, 4, 4], labels='nano')
    except Exception:
        pass
    nano_pores = [2, 13, 14, 15]
    pn.subdivide(pores=nano_pores, shape=[4, 4, 4], labels='nano')
    assert pn.Np == (275+4*64-4)
    assert pn.Nt == (450+(4*144)-16+24*16-16-(2+3+2))


def test_subdivide_consecutive():
    pn = OpenPNM.Network.Cubic(shape=[5, 5, 5],
                               spacing=0.001)
    pn['pore.micro'] = True
    nano_pores = [2, 13, 14, 15]
    pn.subdivide(pores=nano_pores, shape=[4, 4, 4], labels='nano')
    assert pn.Np == (125+4*64-4)
    assert pn.Nt == (300+(4*144)-16+15*16+16)
    nano_pores = [7, 11]
    try:
        pn.subdivide(pores=nano_pores, shape=[4, 4, 4], labels='nano')
    except Exception:
        pass
    assert (pn._subdivide_flag)


def test_clone_and_trim():
    mgr.clear()
    pn = OpenPNM.Network.Cubic(shape=[5, 5, 5], name='net')<commit_msg>minor changes in the unit tests of subdivide<commit_after>import OpenPNM
from os.path import join
import scipy as sp
import pytest
from OpenPNM.Utilities import topology
mgr = OpenPNM.Base.Workspace()
topo = topology()


def test_subdivide():
    pn = OpenPNM.Network.Cubic(shape=[5, 5, 5],
                               spacing=0.001,
                               name='micro_net')
    pn['pore.micro'] = True
    nano_pores = [2, 13, 14, 15]
    pn.subdivide(pores=nano_pores, shape=[4, 4, 4], labels='nano')
    assert pn.Np == (125+4*64-4)
    assert pn.Nt == (300+(4*144)-16+15*16+16)


def test_subdivide_boundary():
    pn = OpenPNM.Network.Cubic(shape=[5, 5, 5],
                               spacing=0.001)
    pn.add_boundaries()
    pn['pore.micro'] = True
    nano_pores = [2, 13, 126, 15]
    with pytest.raises(Exception):
        pn.subdivide(pores=nano_pores, shape=[4, 4, 4], labels='nano')
    nano_pores = [2, 13, 14, 15]
    pn.subdivide(pores=nano_pores, shape=[4, 4, 4], labels='nano')
    assert pn.Np == (275+4*64-4)
    assert pn.Nt == (450+(4*144)-16+24*16-16-(2+3+2))


def test_subdivide_consecutive():
    pn = OpenPNM.Network.Cubic(shape=[5, 5, 5],
                               spacing=0.001)
    pn['pore.micro'] = True
    nano_pores = [2, 13, 14, 15]
    pn.subdivide(pores=nano_pores, shape=[4, 4, 4], labels='nano')
    assert pn.Np == (125+4*64-4)
    assert pn.Nt == (300+(4*144)-16+15*16+16)
    nano_pores = [7, 11]
    with pytest.raises(Exception):
        pn.subdivide(pores=nano_pores, shape=[4, 4, 4], labels='nano')
    assert (pn._subdivide_flag)


def test_clone_and_trim():
    mgr.clear()
    pn = OpenPNM.Network.Cubic(shape=[5, 5, 5], name='net')
{'fraction_non_alphanumeric': 0.1663213968629772, 'fraction_numerical': 0.08286475288546907, 'mean_word_length': 2.6899563318777293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5038584', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1363, 'n_words': 266}