From 033e04fd5a692d9c9954f0f8b093a76868b9bf31 Mon Sep 17 00:00:00 2001 From: Baptiste Bauvin <baptiste.bauvin@lis-lab.fr> Date: Tue, 28 Apr 2020 09:37:53 -0400 Subject: [PATCH] pytest --- docs/source/conf.py | 2 +- multiview_generator/multiple_sub_problems.py | 10 +++--- .../tests/test_multiple_sub_problems.py | 31 +++++++------------ setup.py | 2 +- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 04e6399..5e255ad 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -63,7 +63,7 @@ exclude_patterns = ['_build', '**.ipynb_checkpoints'] # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'groundwork' +html_theme = 'nature' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, diff --git a/multiview_generator/multiple_sub_problems.py b/multiview_generator/multiple_sub_problems.py index 41c6639..895d24a 100644 --- a/multiview_generator/multiple_sub_problems.py +++ b/multiview_generator/multiple_sub_problems.py @@ -2,15 +2,16 @@ import os import h5py import numpy as np +import yaml from sklearn.datasets import make_classification, make_gaussian_quantiles from tabulate import tabulate import pandas as pd import inspect from datetime import datetime -from multiview_generator.utils import format_array, get_config_from_file, \ +from .utils import format_array, get_config_from_file, \ init_random_state, init_error_matrix, init_list -from multiview_generator.base_strs import * +from .base_strs import * class MultiViewSubProblemsGenerator: @@ -217,13 +218,12 @@ class MultiViewSubProblemsGenerator: def gen_view_report(self, view_index): view_string = "\n\n### View "+str(view_index+1) - view_string+="\n\nThis view is generated with {}, with the following configuration : \n```yaml\n".format(self._get_generator(view_index)) - import yaml + view_string+="\n\nThis view is generated with {}, with the following configuration : \n```yaml\n".format(self._get_generator_report(view_index)) view_string += yaml.dump(self.sub_problem_configurations[view_index], line_break="\n",default_flow_style=False) view_string+="```" return view_string - def _get_generator(self, view_index, doc_type=".md"): + def _get_generator_report(self, view_index, doc_type=".md"): if self.sub_problem_types[view_index] in ["make_classification", "base"]: return "[`make_classification`](https://scikit-learn.org/stable/modules/generated/sklearn.datasets.make_classification.html)" elif self.sub_problem_types[view_index]in ["gaussian", "make_gaussian_quantiles"]: diff --git a/multiview_generator/tests/test_multiple_sub_problems.py b/multiview_generator/tests/test_multiple_sub_problems.py index 5230a75..71e00c8 100644 --- a/multiview_generator/tests/test_multiple_sub_problems.py +++ b/multiview_generator/tests/test_multiple_sub_problems.py @@ -1,26 +1,19 @@ import unittest import numpy as np -from ..multiple_sub_problems import MultiViewSubProblemsGenerator +from multiview_generator.multiple_sub_problems import MultiViewSubProblemsGenerator -class Test_MultiVieSubProblemsGenerator(): +class Test_MultiViewSubProblemsGenerator(unittest.TestCase): - def __init__(self): - self.conf = np.array([ - np.array([0.0, 0.1, 0.1, 0.9]), - np.array([0.0, 0.2, 0.1, 0.0]), - np.array([0.0, 0.3, 0.1, 0.0]), - np.array([0.0, 0.4, 0.2, 0.0]), - np.array([0.0, 0.5, 0.2, 0.0]), - np.array([0.0, 0.6, 0.2, 0.0]), - np.array([0.0, 0.7, 0.2, 0.0]), - np.array([0.0, 0.8, 0.1, 0.]), - ]) - self.n_views = 4 - self.n_folds = 10 - self.n_classes = 8 - self.n_samples = 2000 - self.class_sep = 1.5 - self.class_weights = [0.125, 0.1, 0.15, 0.125, 0.01, 0.2, 0.125, 0.125, ] + @classmethod + def setUpClass(cls): + pass + + @classmethod + def tearDownClass(cls): + pass + + def test_simple(self): + gene = MultiViewSubProblemsGenerator() diff --git a/setup.py b/setup.py index 64ee3e3..802799b 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ def setup_package(): here = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(here, 'README.md'), encoding='utf-8') as readme: long_description = readme.read() - group = 'baptiste.bauvin' + group = 'dev' url = 'https://gitlab.lis-lab.fr/{}/{}'.format(group, name) project_urls = { 'Documentation': 'http://{}.pages.lis-lab.fr/{}'.format(group, name), -- GitLab