<commit_before># -*- coding: utf-8 -*-
"""
Tests the describe module

:author: philippkraft
"""
from __future__ import unicode_literals, absolute_import, division, print_function
import sys
import unittest
sys.path.insert(0, '.')

import spotpy
from spotpy.parameter import Uniform
from io import StringIO

import inspect

class SpotSetup(object):
    """
    Just a fun setup using non ASCIÎ letters to chällenge describe in Python 2
    """
    a = Uniform(-1, 1, doc='α parameter')
    beta = Uniform(-1, 1, doc='β parameter')

    @staticmethod
    def simulation(par):
        return [par.a + par.beta]

    @staticmethod
    def evaluation():
        return [0]

    @staticmethod
    def objectivefunction(simulation, evaluation):
        return abs(simulation[0] - evaluation[0])


class TestDescribe(unittest.TestCase):

    def test_setup(self):
        t = spotpy.describe.setup(SpotSetup())
        io = StringIO()
        io.write(t)
        self.assertGreaterEqual(io.getvalue().count('\n'), 6)

    def sampler_test(self, sampler=None):
        if not sampler:
            return
        t = spotpy.describe.describe(sampler)
        io = StringIO()
        io.write(t)
        line_count = io.getvalue().count('\n')
        self.assertGreaterEqual(line_count, 14, '<{}> description to short ({} lines, but >14 expected)'
                                .format(sampler, line_count))

    def test_mc_sampler(self):
        sampler = spotpy.algorithms.mc(spot_setup=SpotSetup(), dbformat='ram', dbname='äöü')
        self.sampler_test(sampler)

    def test_rope_sampler(self):
        sampler = spotpy.algorithms.rope(spot_setup=SpotSetup(), dbformat='ram', dbname='äöü')
        self.sampler_test(sampler)


    def test_all_algorithms(self):
        for sname, scls in inspect.getmembers(spotpy.algorithms, inspect.isclass):
            if not sname.startswith('_'):
                model = SpotSetup()
                sampler = scls(spot_setup=model, dbformat='ram', dbname='äöü')
                self.sampler_test(sampler)


class TestDescribeRst(unittest.TestCase):

    def test_setup_rst(self):
        setup = SpotSetup()
        rst = spotpy.describe.rst(setup)


    def test_sampler_rst(self):
        for sname, scls in inspect.getmembers(spotpy.algorithms, inspect.isclass):
            if not sname.startswith('_'):
                print(sname)
                model = SpotSetup()
                sampler = scls(spot_setup=model, dbformat='ram', dbname='äöü')
                rst = spotpy.describe.rst(sampler)
                rst.as_html()

if __name__ == '__main__':
    unittest.main()<commit_msg>Removed rst from describe in this branch<commit_after># -*- coding: utf-8 -*-
"""
Tests the describe module

:author: philippkraft
"""
from __future__ import unicode_literals, absolute_import, division, print_function
import sys
import unittest
sys.path.insert(0, '.')

import spotpy
from spotpy.parameter import Uniform
from io import StringIO

import inspect

class SpotSetup(object):
    """
    Just a fun setup using non ASCIÎ letters to chällenge describe in Python 2
    """
    a = Uniform(-1, 1, doc='α parameter')
    beta = Uniform(-1, 1, doc='β parameter')

    @staticmethod
    def simulation(par):
        return [par.a + par.beta]

    @staticmethod
    def evaluation():
        return [0]

    @staticmethod
    def objectivefunction(simulation, evaluation):
        return abs(simulation[0] - evaluation[0])


class TestDescribe(unittest.TestCase):

    def test_setup(self):
        t = spotpy.describe.setup(SpotSetup())
        io = StringIO()
        io.write(t)
        self.assertGreaterEqual(io.getvalue().count('\n'), 6)

    def sampler_test(self, sampler=None):
        if not sampler:
            return
        t = spotpy.describe.describe(sampler)
        io = StringIO()
        io.write(t)
        line_count = io.getvalue().count('\n')
        self.assertGreaterEqual(line_count, 14, '<{}> description to short ({} lines, but >14 expected)'
                                .format(sampler, line_count))

    def test_mc_sampler(self):
        sampler = spotpy.algorithms.mc(spot_setup=SpotSetup(), dbformat='ram', dbname='äöü')
        self.sampler_test(sampler)

    def test_rope_sampler(self):
        sampler = spotpy.algorithms.rope(spot_setup=SpotSetup(), dbformat='ram', dbname='äöü')
        self.sampler_test(sampler)


    def test_all_algorithms(self):
        for sname, scls in inspect.getmembers(spotpy.algorithms, inspect.isclass):
            if not sname.startswith('_'):
                model = SpotSetup()
                sampler = scls(spot_setup=model, dbformat='ram', dbname='äöü')
                self.sampler_test(sampler)


if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.11869747899159663, 'fraction_numerical': 0.0063025210084033615, 'mean_word_length': 2.745869394177813, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5088171', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1451, 'n_words': 332}