diff options
author | Frederick Muriuki Muriithi | 2022-02-21 16:23:06 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-02-21 16:23:06 +0300 |
commit | a35fce27875d9db80dce1976b6f8ee8c00ecfe0a (patch) | |
tree | 8e8f815a6e3d37348bdb8f253f5ec53f72dc2dbc /tests/unit/computations | |
parent | c84b07b8c5ac0a42c0fab929c75823b30b548191 (diff) | |
download | genenetwork3-a35fce27875d9db80dce1976b6f8ee8c00ecfe0a.tar.gz |
Fix a myriad of linter issues
* Use `with` in place of plain `open`
* Use f-strings in place of `str.format()`
* Remove string interpolation from queries - provide data as query parameters
* other minor fixes
Diffstat (limited to 'tests/unit/computations')
-rw-r--r-- | tests/unit/computations/test_correlation.py | 8 | ||||
-rw-r--r-- | tests/unit/computations/test_dictify_by_samples.py | 26 |
2 files changed, 19 insertions, 15 deletions
diff --git a/tests/unit/computations/test_correlation.py b/tests/unit/computations/test_correlation.py index 69d4c52..267ced3 100644 --- a/tests/unit/computations/test_correlation.py +++ b/tests/unit/computations/test_correlation.py @@ -1,10 +1,10 @@ """Module contains the tests for correlation""" +import math from unittest import TestCase from unittest import mock +from collections import namedtuple import pytest -from collections import namedtuple -import math from numpy.testing import assert_almost_equal from gn3.computations.correlations import normalize_values @@ -58,12 +58,12 @@ class DataBase(QueryableMixin): """expects the expectede results value to be an array""" self.password = password self.db_name = db_name - self.__query_options = None + self.__query_options = None # pylint: disable=[W0238] self.results_generator(expected_results) def execute(self, query_options): """method to execute an sql query""" - self.__query_options = query_options + self.__query_options = query_options # pylint: disable=[W0238] return 1 def cursor(self): diff --git a/tests/unit/computations/test_dictify_by_samples.py b/tests/unit/computations/test_dictify_by_samples.py index 8a1332f..5cd3eca 100644 --- a/tests/unit/computations/test_dictify_by_samples.py +++ b/tests/unit/computations/test_dictify_by_samples.py @@ -1,7 +1,11 @@ +"""Property tests for `gn3.computations.partial_correlations.dictify_by_samples` + function""" from math import isnan -import pytest from collections.abc import Sequence + +import pytest from hypothesis import given, strategies as st + from gn3.computations.partial_correlations import dictify_by_samples @@ -53,22 +57,22 @@ def check_values(samples, values, variances, row): for smp, val, var in zip(samples, values, variances) if smp != "") -non_empty_samples = st.lists( +generated_non_empty_samples = st.lists( st.text(min_size=1, max_size=15).map( lambda s: s.strip())) -empty_samples = st.text( +generated_empty_samples = st.text( alphabet=" \t\n\r\f\v", min_size=1, max_size=15).filter( lambda s: len(s.strip()) == 0) -values = st.lists(st.floats()) -variances = st.lists(st.one_of(st.none(), st.floats())) -other = st.lists(st.integers()) +generated_values = st.lists(st.floats()) +generated_variances = st.lists(st.one_of(st.none(), st.floats())) +generated_other = st.lists(st.integers()) @pytest.mark.unit_test @given(svv=st.tuples( - st.lists(non_empty_samples), - st.lists(values), - st.lists(variances), - st.lists(other))) + st.lists(generated_non_empty_samples), + st.lists(generated_values), + st.lists(generated_variances), + st.lists(generated_other))) def test_dictifify_by_samples_with_nonempty_samples_strings(svv): """ Test for `dictify_by_samples`. @@ -94,7 +98,7 @@ def test_dictifify_by_samples_with_nonempty_samples_strings(svv): @pytest.mark.unit_test @given(svv=st.tuples( st.lists( - st.lists(empty_samples,min_size=1), + st.lists(generated_empty_samples,min_size=1), min_size=1), st.lists(st.lists(st.floats(), min_size=1), min_size=1), st.lists( |