Skip to content

Commit

Permalink
🎨 Migrate to Pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
Aunsiels committed Oct 22, 2024
1 parent 5971827 commit 9d576c8
Show file tree
Hide file tree
Showing 37 changed files with 1,347 additions and 1,419 deletions.
12 changes: 6 additions & 6 deletions pyformlang/cfg/cfg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" A context free grammar """
import string
from copy import deepcopy
from typing import AbstractSet, Iterable, Tuple, Dict, Any
from typing import AbstractSet, Iterable, Tuple, Dict, Any, Union

import networkx as nx

Expand Down Expand Up @@ -56,9 +56,9 @@ class CFG:
# pylint: disable=too-many-instance-attributes

def __init__(self,
variables: AbstractSet[Variable] = None,
terminals: AbstractSet[Terminal] = None,
start_symbol: Variable = None,
variables: AbstractSet[Union[Variable, str]] = None,
terminals: AbstractSet[Union[Terminal, str]] = None,
start_symbol: Union[Variable, str] = None,
productions: Iterable[Production] = None):
if variables is not None:
variables = {to_variable(x) for x in variables}
Expand Down Expand Up @@ -706,10 +706,10 @@ def is_empty(self) -> bool:
def __bool__(self):
return not self.is_empty()

def __contains__(self, word: Iterable[Terminal]) -> bool:
def __contains__(self, word: Iterable[Union[Terminal, str]]) -> bool:
return self.contains(word)

def contains(self, word: Iterable[Terminal]) -> bool:
def contains(self, word: Iterable[Union[Terminal, str]]) -> bool:
""" Gives the membership of a word to the grammar
Parameters
Expand Down
2 changes: 1 addition & 1 deletion pyformlang/cfg/cyk_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CYKTable:
Parameters
----------
cfg : A context-free grammar
word : tuple of Terminals
word : iterable of Terminals
The word from which we construct the CYK table
"""

Expand Down
8 changes: 1 addition & 7 deletions pyformlang/cfg/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@


class Terminal(CFGObject): # pylint: disable=too-few-public-methods
""" An terminal in a CFG
Parameters
-----------
value : any
The value of the terminal
"""
""" A terminal in a CFG """

def __eq__(self, other):
return isinstance(other, Terminal) and self.value == other.value
Expand Down
Loading

1 comment on commit 9d576c8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
pyformlang
   __init__.py10100% 
pyformlang/cfg
   __init__.py70100% 
   cfg.py5500100% 
   cfg_object.py100100% 
   cyk_table.py720100% 
   epsilon.py60100% 
   llone_parser.py15622 99%
   parse_tree.py6211 98%
   pda_object_creator.py310100% 
   production.py330100% 
   recursive_decent_parser.py5611 98%
   set_queue.py140100% 
   terminal.py150100% 
   utils.py100100% 
   utils_cfg.py250100% 
   variable.py260100% 
pyformlang/cfg/tests
   __init__.py00100% 
   test_cfg.py59922 99%
   test_llone_parser.py11711 99%
   test_production.py210100% 
   test_recursive_decent_parser.py2611 96%
   test_terminal.py180100% 
   test_variable.py150100% 
pyformlang/fcfg
   __init__.py40100% 
   fcfg.py11711 99%
   feature_production.py260100% 
   feature_structure.py19133 98%
   state.py350100% 
pyformlang/fcfg/tests
   __init__.py00100% 
   test_fcfg.py1230100% 
   test_feature_structure.py1590100% 
pyformlang/finite_automaton
   __init__.py100100% 
   deterministic_finite_automaton.py20722 99%
   doubly_linked_list.py340100% 
   doubly_linked_node.py150100% 
   epsilon.py100100% 
   epsilon_nfa.py3720100% 
   finite_automaton.py1620100% 
   finite_automaton_object.py100100% 
   hopcroft_processing_list.py220100% 
   nondeterministic_finite_automaton.py200100% 
   nondeterministic_transition_function.py500100% 
   partition.py360100% 
   regexable.py160100% 
   state.py150100% 
   symbol.py110100% 
   transition_function.py5111 98%
pyformlang/finite_automaton/tests
   __init__.py00100% 
   test_deterministic_finite_automaton.py2610100% 
   test_epsilon.py90100% 
   test_epsilon_nfa.py6210100% 
   test_nondeterministic_finite_automaton.py930100% 
   test_nondeterministic_transition_function.py600100% 
   test_state.py270100% 
   test_symbol.py260100% 
   test_transition_function.py6055 92%
pyformlang/fst
   __init__.py20100% 
   fst.py2420100% 
pyformlang/fst/tests
   __init__.py00100% 
   test_fst.py1650100% 
pyformlang/indexed_grammar
   __init__.py70100% 
   consumption_rule.py340100% 
   duplication_rule.py300100% 
   end_rule.py300100% 
   indexed_grammar.py25722 99%
   production_rule.py320100% 
   reduced_rule.py250100% 
   rule_ordering.py700100% 
   rules.py690100% 
pyformlang/indexed_grammar/tests
   __init__.py00100% 
   test_indexed_grammar.py2240100% 
   test_rules.py350100% 
pyformlang/pda
   __init__.py60100% 
   cfg_variable_converter.py6744 94%
   epsilon.py40100% 
   pda.py3080100% 
   stack_symbol.py160100% 
   state.py180100% 
   symbol.py140100% 
   transition_function.py460100% 
   utils.py360100% 
pyformlang/pda/tests
   __init__.py00100% 
   test_pda.py2450100% 
pyformlang/regular_expression
   __init__.py40100% 
   python_regex.py26666 98%
   regex.py1430100% 
   regex_objects.py790100% 
   regex_reader.py16044 98%
pyformlang/regular_expression/tests
   __init__.py00100% 
   test_python_regex.py2730100% 
   test_regex.py2520100% 
pyformlang/rsa
   __init__.py30100% 
   box.py522525 52%
   recursive_automaton.py731010 86%
pyformlang/rsa/tests
   __init__.py00100% 
   test_rsa.py390100% 
pyformlang/tests
   __init__.py00100% 
TOTAL80497199% 

Tests Skipped Failures Errors Time
274 0 💤 0 ❌ 0 🔥 6.699s ⏱️

Please sign in to comment.