<commit_before>import openpnm as op
import numpy as np
import openpnm.models as mods
import pytest
from testfixtures import LogCapture


class ModelsTest:

    def setup_class(self):
        self.net = op.network.Cubic(shape=[3, 3, 3])
        self.geo = op.geometry.StickAndBall(network=self.net,
                                            pores=self.net.Ps,
                                            throats=self.net.Ts)

    def teardown_class(self):
        ws = op.core.Workspace()
        ws.clear()

    def test_models_dict_print(self):
        s = self.geo.models.__str__().split('\n')
        assert len(s) == 56
        assert s.count('―'*78) == 13

    def test_regenerate_models(self):
        a = len(self.geo.props())
        assert a == 11
        self.geo.clear(mode='props')
        a = len(self.geo.props())
        assert a == 0
        self.geo.regenerate_models()
        a = len(self.geo.props())
        assert a == 11

    def test_dependency_list(self):
        prj=self.net.project
        prj.purge_object(self.geo)
        geom = op.geometry.GenericGeometry(network=self.net,
                                           pores=self.net.Ps)

        geom.add_model(propname='pore.volume',
                       model=mods.geometry.pore_volume.sphere,
                       pore_diameter='pore.diameter')

        geom.add_model(propname='pore.diameter',
                       model=mods.misc.product,
                       prop1='pore.max_size',
                       prop2='pore.seed')

        geom.add_model(propname='pore.area',
                       model=mods.geometry.pore_area.sphere,
                       pore_diameter='pore.diameter')

        geom.add_model(propname='pore.seed',
                       model=mods.misc.random,
                       element='pore',
                       num_range=[0, 0.1],
                       seed=None)
        tree = np.asarray(geom.models.dependency_list())<commit_msg>Fixed ModelsTest (since StickAndBall was changed)<commit_after>import openpnm as op
import numpy as np
import openpnm.models as mods
import pytest
from testfixtures import LogCapture


class ModelsTest:

    def setup_class(self):
        self.net = op.network.Cubic(shape=[3, 3, 3])
        self.geo = op.geometry.StickAndBall(network=self.net,
                                            pores=self.net.Ps,
                                            throats=self.net.Ts)

    def teardown_class(self):
        ws = op.core.Workspace()
        ws.clear()

    def test_models_dict_print(self):
        s = self.geo.models.__str__().split('\n')
        assert len(s) == 67
        assert s.count('―'*78) == 15

    def test_regenerate_models(self):
        a = len(self.geo.props())
        assert a == 17
        self.geo.clear(mode='props')
        a = len(self.geo.props())
        assert a == 0
        self.geo.regenerate_models()
        a = len(self.geo.props())
        assert a == 17

    def test_dependency_list(self):
        prj=self.net.project
        prj.purge_object(self.geo)
        geom = op.geometry.GenericGeometry(network=self.net,
                                           pores=self.net.Ps)

        geom.add_model(propname='pore.volume',
                       model=mods.geometry.pore_volume.sphere,
                       pore_diameter='pore.diameter')

        geom.add_model(propname='pore.diameter',
                       model=mods.misc.product,
                       prop1='pore.max_size',
                       prop2='pore.seed')

        geom.add_model(propname='pore.area',
                       model=mods.geometry.pore_area.sphere,
                       pore_diameter='pore.diameter')

        geom.add_model(propname='pore.seed',
                       model=mods.misc.random,
                       element='pore',
                       num_range=[0, 0.1],
                       seed=None)
        tree = np.asarray(geom.models.dependency_list())
{'fraction_non_alphanumeric': 0.112797167425392, 'fraction_numerical': 0.009610520991401113, 'mean_word_length': 1.5681818181818181, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5299237', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1145, 'n_words': 182}