diff --git a/src/libsemigroups_pybind11/detail/cxx_wrapper.py b/src/libsemigroups_pybind11/detail/cxx_wrapper.py index 1450f77cb..f2d7485be 100644 --- a/src/libsemigroups_pybind11/detail/cxx_wrapper.py +++ b/src/libsemigroups_pybind11/detail/cxx_wrapper.py @@ -19,11 +19,17 @@ from typing import Any, Callable from typing_extensions import Self -from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module - UNDEFINED as _UNDEFINED, -) - -pybind11_type = type(_UNDEFINED) +# We would really like Pybind11Type to point to pybind11_builtins.pybind11_type. +# However, this is not easily importable into python; see the discussions in +# https://github.com/pybind/pybind11/issues/3945 and +# https://github.com/pybind/cmake_example/pull/164. +# A proposed workaround would be to do the following: +# Pybind11Type = TypeVar('Pybind11Type', bound=type(Undefined)) +# but that isn't allowed, since function calls aren't permitted in TypeVar +# expressions. Hence, the next best thing is to use the parent class of +# pybind11_builtins.pybind11_type, which is simply type. Further runtime checks +# can be added latter if required. +Pybind11Type = type def to_cxx(x: Any) -> Any: @@ -49,7 +55,7 @@ def to_py(x: Any, *args) -> Any: _CXX_WRAPPED_TYPE_TO_PY_TYPE = {} -def register_cxx_wrapped_type(cxx_type: pybind11_type, py_type: type) -> None: +def register_cxx_wrapped_type(cxx_type: Pybind11Type, py_type: type) -> None: """ Function for adding to the _CXX_WRAPPED_TYPE_TO_PY_TYPE dictionary. """ @@ -59,7 +65,6 @@ def register_cxx_wrapped_type(cxx_type: pybind11_type, py_type: type) -> None: class CxxWrapper: # pylint: disable=missing-class-docstring - # pylint: disable=protected-access, no-member def __init__( self: Self, *args, @@ -182,7 +187,7 @@ def init_cxx_obj(self: Self, *args) -> None: # TODO proper annotations -def wrap_cxx_mem_fn(cxx_mem_fn: pybind11_type) -> Callable: +def wrap_cxx_mem_fn(cxx_mem_fn: Pybind11Type) -> Callable: """ This function creates a wrapper around the pybind11 c++ member function that automatically wraps and unwraps CxxWrapper types, and @@ -217,7 +222,7 @@ def cxx_mem_fn_wrapper(self, *args): # TODO proper annotations -def wrap_cxx_free_fn(cxx_free_fn: pybind11_type) -> Callable: +def wrap_cxx_free_fn(cxx_free_fn: Pybind11Type) -> Callable: """ This function creates a wrapper around the pybind11 c++ free function that automatically wraps and unwraps CxxWrapper types. The @@ -232,7 +237,7 @@ def cxx_free_fn_wrapper(*args): return cxx_free_fn_wrapper -def copy_cxx_mem_fns(cxx_class: pybind11_type, py_class: CxxWrapper) -> None: +def copy_cxx_mem_fns(cxx_class: Pybind11Type, py_class: CxxWrapper) -> None: """ Copy all the non-special methods of *cxx_class* into methods of *py_class* that call the cxx member function on the _cxx_obj. diff --git a/src/libsemigroups_pybind11/froidure_pin.py b/src/libsemigroups_pybind11/froidure_pin.py index 5ad2eac7f..c9a7c1771 100644 --- a/src/libsemigroups_pybind11/froidure_pin.py +++ b/src/libsemigroups_pybind11/froidure_pin.py @@ -9,18 +9,21 @@ # The module doc string is what appears at the top of the helper function # doc page, and so is omitted. -# pylint: disable=missing-module-docstring +""" +This page contains the documentation for various helper functions for +manipulating :any:`FroidurePin` objects. All such functions +are contained in the submodule ``libsemigroups_pybind11.froidure_pin``. +""" from typing import TypeVar as _TypeVar, Iterator as _Iterator from typing_extensions import Self as _Self -from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module,unused-import +from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module BMat as _BMat, BMat8 as _BMat8, Bipartition as _Bipartition, FroidurePinBMat as _FroidurePinBMat, FroidurePinBMat8 as _FroidurePinBMat8, - FroidurePinBase as _FroidurePinBase, FroidurePinBipartition as _FroidurePinBipartition, FroidurePinIntMat as _FroidurePinIntMat, FroidurePinMaxPlusMat as _FroidurePinMaxPlusMat, @@ -68,7 +71,6 @@ Transf1 as _Transf1, Transf2 as _Transf2, Transf4 as _Transf4, - Undefined as _Undefined, froidure_pin_current_minimal_factorisation as _froidure_pin_current_minimal_factorisation, froidure_pin_current_normal_forms as _froidure_pin_current_normal_forms, froidure_pin_current_position as _froidure_pin_current_position, diff --git a/src/libsemigroups_pybind11/matrix.py b/src/libsemigroups_pybind11/matrix.py index a94f40da9..c03b663ec 100644 --- a/src/libsemigroups_pybind11/matrix.py +++ b/src/libsemigroups_pybind11/matrix.py @@ -15,17 +15,15 @@ from typing_extensions import Self as _Self, Union as _Union -from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module,unused-import +from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module BMat as _BMat, IntMat as _IntMat, MaxPlusMat as _MaxPlusMat, MaxPlusTruncMat as _MaxPlusTruncMat, MinPlusMat as _MinPlusMat, MinPlusTruncMat as _MinPlusTruncMat, - NEGATIVE_INFINITY as _NEGATIVE_INFINITY, NTPMat as _NTPMat, NegativeInfinity as _NegativeInfinity, - POSITIVE_INFINITY as _POSITIVE_INFINITY, PositiveInfinity as _PositiveInfinity, ProjMaxPlusMat as _ProjMaxPlusMat, matrix_row_space_size as _row_space_size, diff --git a/tests/cong_common.py b/tests/cong_common.py index cfa005614..59d29075f 100644 --- a/tests/cong_common.py +++ b/tests/cong_common.py @@ -1,7 +1,4 @@ # -*- coding: utf-8 -*- -# pylint: disable=no-name-in-module, missing-function-docstring -# pylint: disable=missing-class-docstring, invalid-name - # Copyright (c) 2021-2024 J. D. Mitchell # # Distributed under the terms of the GPL license version 3. @@ -13,8 +10,6 @@ CongruenceCommon. """ -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name - from libsemigroups_pybind11 import ( Presentation, congruence_kind, @@ -22,7 +17,9 @@ ) -def check_congruence_common_return_policy(TestType): +def check_congruence_common_return_policy( + TestType, +): # pylint: disable=missing-function-docstring, invalid-name p = Presentation("ab") presentation.add_rule(p, "abab", "a" * 6) presentation.add_rule(p, "ba", "ababbb") diff --git a/tests/runner.py b/tests/runner.py index aab27d975..f4fede094 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -1,7 +1,4 @@ # -*- coding: utf-8 -*- -# pylint: disable=no-name-in-module, missing-function-docstring -# pylint: disable=missing-class-docstring, invalid-name - # Copyright (c) 2021-2024 J. D. Mitchell # # Distributed under the terms of the GPL license version 3. @@ -17,12 +14,14 @@ from libsemigroups_pybind11 import ReportGuard -n = 0 +N = 0 -def check_runner(x, t=timedelta(microseconds=1000)): - global n # pylint: disable=global-statement - n = 0 +def check_runner( + x, t=timedelta(microseconds=1000) +): # pylint: disable=missing-function-docstring + global N # pylint: disable=global-statement + N = 0 ReportGuard(False) assert not x.stopped() @@ -47,9 +46,9 @@ def check_runner(x, t=timedelta(microseconds=1000)): pass def func(): - global n # pylint: disable=global-statement - n += 1 - return n >= 2 + global N # pylint: disable=global-statement + N += 1 + return N >= 2 x.run_until(func) diff --git a/tests/test_action.py b/tests/test_action.py index 4801f8877..5de2e2fbf 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -11,8 +11,7 @@ arising from action.*pp in libsemigroups. """ -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name -# pylint: disable=redefined-outer-name, no-member +# pylint: disable=missing-function-docstring import pytest @@ -30,8 +29,8 @@ from libsemigroups_pybind11.bmat8 import row_space_basis, col_space_basis -@pytest.fixture -def right_actions(): +@pytest.fixture(name="right_actions") +def fixture_right_actions(): seed = row_space_basis( BMat8([[1, 1, 1, 0], [1, 1, 0, 0], [0, 1, 0, 1], [0, 1, 0, 0]]) ) @@ -142,8 +141,8 @@ def right_actions(): return result -@pytest.fixture -def left_actions(): +@pytest.fixture(name="left_actions") +def fixture_left_actions(): seed = col_space_basis( BMat8([[1, 1, 1, 0], [1, 1, 0, 0], [0, 1, 0, 1], [0, 1, 0, 0]]) ) @@ -205,8 +204,8 @@ def left_actions(): return result -@pytest.fixture -def extreme_left_actions(): +@pytest.fixture(name="extreme_left_actions") +def fixture_extreme_left_actions(): result = [] result.append( LeftAction( diff --git a/tests/test_adapters.py b/tests/test_adapters.py index 255f88b60..5be722317 100644 --- a/tests/test_adapters.py +++ b/tests/test_adapters.py @@ -11,7 +11,7 @@ arising from adapters.*pp in libsemigroups. """ -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name +# pylint: disable=missing-function-docstring import pytest @@ -25,25 +25,25 @@ def test_adapters_017(): - A, B, C = bmat8.random(), BMat8(0), bmat8.one() - right = ImageRightAction(point=A, element=A) + a, b, c = bmat8.random(), BMat8(0), bmat8.one() + right = ImageRightAction(point=a, element=a) # Point1, Point2, Element -> Point1 = Point2 ^ Element - B = right(A, C) - assert B == bmat8.row_space_basis(A) + b = right(a, c) + assert b == bmat8.row_space_basis(a) - B = right(C, A) - assert B == bmat8.row_space_basis(A) + b = right(c, a) + assert b == bmat8.row_space_basis(a) - left = ImageLeftAction(point=A, element=A) - B = left(A, C) - assert B == bmat8.col_space_basis(A) + left = ImageLeftAction(point=a, element=a) + b = left(a, c) + assert b == bmat8.col_space_basis(a) - B = left(C, A) - assert B == bmat8.col_space_basis(A) + b = left(c, a) + assert b == bmat8.col_space_basis(a) - B = right(A, A) - C = left(bmat8.transpose(A), bmat8.transpose(A)) - assert B == bmat8.transpose(C) + b = right(a, a) + c = left(bmat8.transpose(a), bmat8.transpose(a)) + assert b == bmat8.transpose(c) def test_image_right_action_pperm_pperm(): diff --git a/tests/test_bipart.py b/tests/test_bipart.py index 0a01b0662..a6a4bff60 100644 --- a/tests/test_bipart.py +++ b/tests/test_bipart.py @@ -10,7 +10,7 @@ This module contains some tests for bipartitions. """ -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name +# pylint: disable=missing-function-docstring, invalid-name from itertools import chain diff --git a/tests/test_bmat8.py b/tests/test_bmat8.py index 2c927c3d3..fa16b3af3 100644 --- a/tests/test_bmat8.py +++ b/tests/test_bmat8.py @@ -11,7 +11,7 @@ arising from bmat8.*pp in libsemigroups. """ -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name +# pylint: disable=missing-function-docstring import pytest from libsemigroups_pybind11 import BMat8, LibsemigroupsError diff --git a/tests/test_cong.py b/tests/test_cong.py index 9bfd6308d..febd19aff 100644 --- a/tests/test_cong.py +++ b/tests/test_cong.py @@ -10,7 +10,7 @@ This file contains tests for Congruence from libsemigroups_pybind11. """ -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name +# pylint: disable=missing-function-docstring from datetime import timedelta diff --git a/tests/test_forest.py b/tests/test_forest.py index dc9405dd9..50f524119 100644 --- a/tests/test_forest.py +++ b/tests/test_forest.py @@ -6,7 +6,7 @@ # # The full license is in the file LICENSE, distributed with this software. -# pylint: disable=missing-function-docstring, redefined-outer-name +# pylint: disable=missing-function-docstring """ This module contains some tests for the libsemigroups_pybind11 functionality @@ -18,13 +18,12 @@ from libsemigroups_pybind11 import Forest, UNDEFINED -@pytest.fixture +@pytest.fixture(name="f") def forest_fixture(): return Forest([UNDEFINED, 0, 1, 2, 3], [UNDEFINED, 0, 0, 0, 0]) -def test_forest_return_policy(forest_fixture): - f = forest_fixture +def test_forest_return_policy(f): assert f.add_nodes(2) is f assert f.init(2) is f assert f.labels() is not f.labels() diff --git a/tests/test_froidure_pin.py b/tests/test_froidure_pin.py index 1feed66aa..202fe7bb0 100644 --- a/tests/test_froidure_pin.py +++ b/tests/test_froidure_pin.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -# pylint: disable=no-name-in-module, missing-function-docstring -# pylint: disable=missing-class-docstring, invalid-name, redefined-outer-name # Copyright (c) 2021-2024 J. D. Mitchell # @@ -12,6 +10,8 @@ This module contains some tests for FroidurePin """ +# pylint: disable=missing-function-docstring, invalid-name + from datetime import timedelta import pytest @@ -285,13 +285,13 @@ def check_froidure_pin_transf2(T): ] -@pytest.fixture -def checks_for_generators(): +@pytest.fixture(name="checks_for_generators") +def fixture_checks_for_generators(): return (check_constructors,) -@pytest.fixture -def checks_for_froidure_pin(): +@pytest.fixture(name="checks_for_froidure_pin") +def fixture_checks_for_froidure_pin(): return ( check_settings, check_mem_compare, diff --git a/tests/test_gabow.py b/tests/test_gabow.py index b313e735a..caa18a604 100644 --- a/tests/test_gabow.py +++ b/tests/test_gabow.py @@ -11,7 +11,7 @@ libsemigroups_pybind11. """ -# pylint: disable=missing-function-docstring, redefined-outer-name +# pylint: disable=missing-function-docstring import pytest @@ -22,7 +22,7 @@ ) -@pytest.fixture +@pytest.fixture(name="wg") def word_graph_fixture(): w = WordGraph(17, 31) for i in range(17): @@ -115,8 +115,7 @@ def test_004(): assert list(g.roots()) == [32, 65, 98, 131, 164, 197, 230, 263, 296, 329] -def test_gabow_return_policy(word_graph_fixture): - wg = word_graph_fixture +def test_gabow_return_policy(wg): g = Gabow(wg) assert g.component(0) is not g.component(0) assert g.component_of(0) is not g.component_of(0) diff --git a/tests/test_matrix.py b/tests/test_matrix.py index 8d4742630..acb5b6434 100644 --- a/tests/test_matrix.py +++ b/tests/test_matrix.py @@ -10,20 +10,16 @@ This module contains some tests for matrices. """ -# pylint: disable=no-name-in-module, missing-function-docstring -# pylint: disable=invalid-name, redefined-outer-name +# pylint: disable=missing-function-docstring, invalid-name import copy import pytest -from libsemigroups_pybind11 import ( # pylint: disable=unused-import - Matrix, - MatrixKind, -) +from libsemigroups_pybind11 import Matrix, MatrixKind -@pytest.fixture -def matrix_kinds(): +@pytest.fixture(name="matrix_kinds") +def fixture_matrix_kinds(): return tuple( getattr(MatrixKind, x) for x in dir(MatrixKind) diff --git a/tests/test_obvinf.py b/tests/test_obvinf.py index 82aa0b370..88758a81f 100644 --- a/tests/test_obvinf.py +++ b/tests/test_obvinf.py @@ -9,7 +9,7 @@ This module contains some tests for the functions is_obviously_infinite. """ -# pylint: disable=missing-function-docstring, duplicate-code +# pylint: disable=missing-function-docstring from libsemigroups_pybind11 import ( Presentation, diff --git a/tests/test_paths.py b/tests/test_paths.py index 7c99d0cac..aed9ae1cf 100644 --- a/tests/test_paths.py +++ b/tests/test_paths.py @@ -9,8 +9,7 @@ libsemigroups_pybind11. """ -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name, -# pylint: disable=duplicate-code, too-many-lines +# pylint: disable=missing-function-docstring import sys import pytest @@ -68,7 +67,7 @@ def test_001(): assert p.count() == 0 -def test_ToString(): +def test_ToString(): # pylint: disable=invalid-name w = WordGraph(0) n = 100 w.add_nodes(n) diff --git a/tests/test_pbr.py b/tests/test_pbr.py index 704f9de86..5fdc11cab 100644 --- a/tests/test_pbr.py +++ b/tests/test_pbr.py @@ -10,8 +10,7 @@ This module contains some tests for PBRs. """ -# pylint: disable= missing-function-docstring, invalid-name -# pylint: disable= comparison-with-itself +# pylint: disable= missing-function-docstring, comparison-with-itself from copy import copy import pytest @@ -36,17 +35,16 @@ def test_ops(): def test_constructors(): - T = PBR - # T.make + # make with pytest.raises(RuntimeError): - T([[1, 1, 2, 16]] * 2) + PBR([[1, 1, 2, 16]] * 2) with pytest.raises(TypeError): - T([1, 1, 2, 16] + list(range(4, 16))) + PBR([1, 1, 2, 16] + list(range(4, 16))) with pytest.raises(TypeError): - T([-1, 1, 2, 6] + list(range(4, 16))) + PBR([-1, 1, 2, 6] + list(range(4, 16))) - # T.__get_item__ + # __get_item__ x = PBR([[0, 1, 2]] * 6) assert x[0] == [0, 1, 2] assert x[1] == x[0] diff --git a/tests/test_present.py b/tests/test_present.py index 2e0209064..a67ebba2c 100644 --- a/tests/test_present.py +++ b/tests/test_present.py @@ -9,8 +9,8 @@ This module contains some tests for the Presentation class. """ -# pylint: disable=fixme, missing-function-docstring, comparison-with-callable -# pylint: disable=missing-class-docstring, invalid-name, too-many-lines +# pylint: disable=missing-function-docstring, invalid-name +# pylint: disable=comparison-with-callable, too-many-lines from typing import Union diff --git a/tests/test_presentation_examples.py b/tests/test_presentation_examples.py index 21ce69775..d944237f5 100644 --- a/tests/test_presentation_examples.py +++ b/tests/test_presentation_examples.py @@ -9,9 +9,7 @@ This module contains some tests for fpsemi-examples. """ -# pylint: disable=fixme, missing-function-docstring -# pylint: disable=missing-class-docstring, invalid-name -# pylint: disable=unused-variable +# pylint: disable=missing-function-docstring, invalid-name from math import factorial import pytest diff --git a/tests/test_schreier_sims.py b/tests/test_schreier_sims.py index 647eda56c..3211c7a9b 100644 --- a/tests/test_schreier_sims.py +++ b/tests/test_schreier_sims.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -# pylint: disable=invalid-name, redefined-outer-name -# pylint: disable=missing-function-docstring # Copyright (c) 2024 Joseph Edwards # @@ -10,6 +8,8 @@ """This file contains test for SchreierSims""" +# pylint: disable=missing-function-docstring, invalid-name + # TODO(0): # * test number_of_strong_generators # * test strong_generator @@ -495,8 +495,8 @@ def check_SchreierSims_001(n): assert S.size() == 177843714048000 -@pytest.fixture -def checks_with_generators(): +@pytest.fixture(name="checks_with_generators") +def fixture_checks_with_generators(): return ( check_constructors, check_generators, @@ -507,8 +507,8 @@ def checks_with_generators(): ) -@pytest.fixture -def checks_with_int(): +@pytest.fixture(name="checks_with_int") +def fixture_checks_with_int(): return ( check_SchreierSims_001, check_one, diff --git a/tests/test_sims.py b/tests/test_sims.py index 141b7bed4..9454f33d8 100644 --- a/tests/test_sims.py +++ b/tests/test_sims.py @@ -11,8 +11,7 @@ arising from sims.*pp in libsemigroups. """ -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name, -# pylint: disable=duplicate-code +# pylint: disable=missing-function-docstring, invalid-name import os diff --git a/tests/test_stephen.py b/tests/test_stephen.py index 561d66e66..a28eaa438 100644 --- a/tests/test_stephen.py +++ b/tests/test_stephen.py @@ -11,8 +11,7 @@ arising from stephen.*pp in libsemigroups. """ -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name, -# pylint: disable=duplicate-code, too-many-lines +# pylint: disable=missing-function-docstring, invalid-name, too-many-lines from itertools import islice from functools import cmp_to_key diff --git a/tests/test_to.py b/tests/test_to.py index f1e05a504..c9afca47e 100644 --- a/tests/test_to.py +++ b/tests/test_to.py @@ -5,7 +5,7 @@ # # The full license is in the file LICENSE, distributed with this software. -# pylint: disable=missing-function-docstring, no-name-in-module, invalid-name +# pylint: disable=missing-function-docstring, invalid-name """ This module contains some tests for the to function. @@ -15,7 +15,7 @@ # TODO(1) be good to remove the imports from _libsemigroups_pybind11, but # couldn't immediately figure out how to. -from _libsemigroups_pybind11 import ( +from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module FroidurePinKBEStringRewriteFromLeft, FroidurePinKBEStringRewriteTrie, FroidurePinKBEWordRewriteFromLeft, diff --git a/tests/test_todd_coxeter.py b/tests/test_todd_coxeter.py index 7f83a0e05..d021ea92e 100644 --- a/tests/test_todd_coxeter.py +++ b/tests/test_todd_coxeter.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name # Copyright (c) 2021-2024 J. D. Mitchell + Maria Tsalakou # @@ -11,6 +10,8 @@ This module contains some tests for the ToddCoxeter class. """ +# pylint: disable=missing-function-docstring, invalid-name + from datetime import timedelta import pytest diff --git a/tests/test_transf.py b/tests/test_transf.py index da5531ef2..482354578 100644 --- a/tests/test_transf.py +++ b/tests/test_transf.py @@ -6,7 +6,7 @@ # # The full license is in the file LICENSE, distributed with this software. -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name +# pylint: disable=missing-function-docstring, invalid-name """ This module contains some tests for transformations, partial perms, and diff --git a/tests/test_ukkonen.py b/tests/test_ukkonen.py index c7c1f9f82..1a29ab303 100644 --- a/tests/test_ukkonen.py +++ b/tests/test_ukkonen.py @@ -10,8 +10,7 @@ ukkonen. """ -# pylint: disable=fixme, missing-function-docstring -# pylint: disable=missing-class-docstring, invalid-name +# pylint: disable=missing-function-docstring import pytest diff --git a/tests/test_word_graph.py b/tests/test_word_graph.py index edb3fbde7..e2d8bf6dd 100644 --- a/tests/test_word_graph.py +++ b/tests/test_word_graph.py @@ -11,8 +11,7 @@ libsemigroups_pybind11. """ -# pylint: disable=no-name-in-module, missing-function-docstring, invalid-name, -# pylint: disable=duplicate-code, too-many-lines, redefined-outer-name +# pylint: disable=no-name-in-module, missing-function-docstring import copy import pytest @@ -36,7 +35,7 @@ import numpy as np -@pytest.fixture +@pytest.fixture(name="word_graphs") def word_graph_fixture(): wg1 = WordGraph(0, 1) word_graph.add_cycle(wg1, 5) @@ -87,8 +86,8 @@ def test_002(): assert w.number_of_edges() == 659 -def test_adjacency_matrix(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_adjacency_matrix(word_graphs): + wg1, _ = word_graphs assert wg1.number_of_edges() == 5 assert wg1.number_of_nodes() == 5 @@ -118,8 +117,8 @@ def test_adjacency_matrix(word_graph_fixture): ) -def test_equal_to(word_graph_fixture): - wg1, wg2 = word_graph_fixture +def test_equal_to(word_graphs): + wg1, wg2 = word_graphs assert wg1 != wg2 assert word_graph.equal_to(wg1, wg2, 0, 5) @@ -127,8 +126,8 @@ def test_equal_to(word_graph_fixture): word_graph.equal_to(wg1, wg2, 1, 6) -def test_follow_path(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_follow_path(word_graphs): + wg1, _ = word_graphs assert word_graph.follow_path(wg1, 0, [0] * 6) == 1 assert word_graph.follow_path(wg1, 0, []) == 0 @@ -139,8 +138,8 @@ def test_follow_path(word_graph_fixture): word_graph.follow_path(wg1, 6, [0]) -def test_is_acyclic(word_graph_fixture): - wg1, wg2 = word_graph_fixture +def test_is_acyclic(word_graphs): + wg1, wg2 = word_graphs assert not word_graph.is_acyclic(wg1) wg1.remove_target(0, 0) assert word_graph.is_acyclic(wg1) @@ -155,14 +154,14 @@ def test_is_acyclic(word_graph_fixture): assert not word_graph.is_acyclic(wg1, 0, 3) -def test_is_compatible(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_is_compatible(word_graphs): + wg1, _ = word_graphs assert word_graph.is_compatible(wg1, 0, 1, [0] * 5, [0] * 10) assert not word_graph.is_compatible(wg1, 0, 1, [0] * 5, [0] * 9) -def test_is_complete(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_is_complete(word_graphs): + wg1, _ = word_graphs assert word_graph.is_complete(wg1) wg1.remove_target(0, 0) @@ -175,8 +174,8 @@ def test_is_complete(word_graph_fixture): word_graph.is_complete(wg1, 1, 10) -def test_is_connected(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_is_connected(word_graphs): + wg1, _ = word_graphs wg1.remove_target(0, 0) wg1.remove_target(4, 0) assert not word_graph.is_connected(wg1) @@ -184,8 +183,8 @@ def test_is_connected(word_graph_fixture): assert word_graph.is_connected(wg1) -def test_is_reachable(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_is_reachable(word_graphs): + wg1, _ = word_graphs assert word_graph.is_reachable(wg1, 0, 1) assert word_graph.is_reachable(wg1, 0, 4) @@ -195,8 +194,8 @@ def test_is_reachable(word_graph_fixture): word_graph.is_reachable(wg1, 0, 10) -def test_is_strictly_cyclic(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_is_strictly_cyclic(word_graphs): + wg1, _ = word_graphs assert word_graph.is_strictly_cyclic(wg1) wg1.remove_target(0, 0) @@ -205,15 +204,15 @@ def test_is_strictly_cyclic(word_graph_fixture): assert not word_graph.is_strictly_cyclic(wg1) -def test_last_node_on_path(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_last_node_on_path(word_graphs): + wg1, _ = word_graphs assert word_graph.last_node_on_path(wg1, 0, []) == (0, 0) assert word_graph.last_node_on_path(wg1, 0, [0]) == (1, 1) assert word_graph.last_node_on_path(wg1, 0, [0] * 7) == (2, 7) -def test_nodes_reachable_from(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_nodes_reachable_from(word_graphs): + wg1, _ = word_graphs wg1.remove_target(4, 0) assert word_graph.nodes_reachable_from(wg1, 0) == {0, 1, 2, 3, 4} @@ -224,8 +223,8 @@ def test_nodes_reachable_from(word_graph_fixture): word_graph.nodes_reachable_from(wg1, 10) -def test_number_of_nodes_reachable_from(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_number_of_nodes_reachable_from(word_graphs): + wg1, _ = word_graphs wg1.remove_target(4, 0) assert word_graph.number_of_nodes_reachable_from(wg1, 0) == 5 assert word_graph.number_of_nodes_reachable_from(wg1, 1) == 4 @@ -235,8 +234,8 @@ def test_number_of_nodes_reachable_from(word_graph_fixture): word_graph.number_of_nodes_reachable_from(wg1, 10) -def test_spanning_tree(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_spanning_tree(word_graphs): + wg1, _ = word_graphs assert word_graph.spanning_tree(wg1, 0) == Forest( [UNDEFINED, 0, 1, 2, 3], [UNDEFINED, 0, 0, 0, 0] @@ -247,8 +246,8 @@ def test_spanning_tree(word_graph_fixture): assert word_graph.spanning_tree(wg1, 0) == f -def test_standardize(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_standardize(word_graphs): + wg1, _ = word_graphs f = Forest(0) assert not word_graph.standardize(wg1, f, Order.shortlex) assert f == word_graph.spanning_tree(wg1, 0) @@ -257,16 +256,16 @@ def test_standardize(word_graph_fixture): assert f == word_graph.spanning_tree(wg1, 0) -def test_topological_sort(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_topological_sort(word_graphs): + wg1, _ = word_graphs assert word_graph.topological_sort(wg1) == [] wg1.remove_target(4, 0) assert word_graph.topological_sort(wg1) == [4, 3, 2, 1, 0] assert word_graph.topological_sort(wg1, 1) == [4, 3, 2, 1] -def test_meeter(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_meeter(word_graphs): + wg1, _ = word_graphs wg1.remove_target(4, 0) meet = Meeter() @@ -283,8 +282,8 @@ def test_meeter(word_graph_fixture): assert meet.is_subrelation(wg1, wg2) -def test_joiner(word_graph_fixture): - wg1, _ = word_graph_fixture +def test_joiner(word_graphs): + wg1, _ = word_graphs wg1.remove_target(0, 0) assert wg1 == WordGraph(5, [[UNDEFINED], [2], [3], [4], [0]]) @@ -301,8 +300,8 @@ def test_joiner(word_graph_fixture): assert join.is_subrelation(wg2, wg1) -def test_str(word_graph_fixture): - wg1, wg2 = word_graph_fixture +def test_str(word_graphs): + wg1, wg2 = word_graphs assert str(wg1) == "WordGraph(5, [[1], [2], [3], [4], [0]])" assert ( str(wg2) @@ -310,8 +309,8 @@ def test_str(word_graph_fixture): ) -def test_copy(word_graph_fixture): - wg1, wg2 = word_graph_fixture +def test_copy(word_graphs): + wg1, wg2 = word_graphs assert wg1.copy() == wg1 assert wg1.copy() is not wg1 assert wg2.copy() == wg2 diff --git a/tests/test_word_range.py b/tests/test_word_range.py index 49f4c7c15..aed6bb2a4 100644 --- a/tests/test_word_range.py +++ b/tests/test_word_range.py @@ -191,7 +191,7 @@ def test_ToWord(): assert twrd.empty() -def test_WordRange_000(): # pylint: disable=invalid-name +def test_WordRange_000(): first = [0] last = [0, 0, 0, 0] words = WordRange() @@ -220,7 +220,7 @@ def test_WordRange_000(): # pylint: disable=invalid-name ] -def test_StringRange_000(): # pylint: disable=invalid-name +def test_StringRange_000(): strings = StringRange() strings.alphabet("ab").first("a").last("aaaa") assert strings.count() == 14 @@ -317,7 +317,7 @@ def test_ToWord_1(): ] -def test_ToWord_2(): # pylint: disable=invalid-name +def test_ToWord_2(): toword = ToWord("BCA") assert not toword.empty() assert toword("BCABACB") == [0, 1, 2, 0, 2, 1, 0]