Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9d576c8

Browse files
committed
🎨 Migrate to Pytest
1 parent5971827 commit9d576c8

File tree

37 files changed

+1347
-1419
lines changed

37 files changed

+1347
-1419
lines changed

‎pyformlang/cfg/cfg.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" A context free grammar """
22
importstring
33
fromcopyimportdeepcopy
4-
fromtypingimportAbstractSet,Iterable,Tuple,Dict,Any
4+
fromtypingimportAbstractSet,Iterable,Tuple,Dict,Any,Union
55

66
importnetworkxasnx
77

@@ -56,9 +56,9 @@ class CFG:
5656
# pylint: disable=too-many-instance-attributes
5757

5858
def__init__(self,
59-
variables:AbstractSet[Variable]=None,
60-
terminals:AbstractSet[Terminal]=None,
61-
start_symbol:Variable=None,
59+
variables:AbstractSet[Union[Variable,str]]=None,
60+
terminals:AbstractSet[Union[Terminal,str]]=None,
61+
start_symbol:Union[Variable,str]=None,
6262
productions:Iterable[Production]=None):
6363
ifvariablesisnotNone:
6464
variables= {to_variable(x)forxinvariables}
@@ -706,10 +706,10 @@ def is_empty(self) -> bool:
706706
def__bool__(self):
707707
returnnotself.is_empty()
708708

709-
def__contains__(self,word:Iterable[Terminal])->bool:
709+
def__contains__(self,word:Iterable[Union[Terminal,str]])->bool:
710710
returnself.contains(word)
711711

712-
defcontains(self,word:Iterable[Terminal])->bool:
712+
defcontains(self,word:Iterable[Union[Terminal,str]])->bool:
713713
""" Gives the membership of a word to the grammar
714714
715715
Parameters

‎pyformlang/cfg/cyk_table.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CYKTable:
1212
Parameters
1313
----------
1414
cfg : A context-free grammar
15-
word :tuple of Terminals
15+
word :iterable of Terminals
1616
The word from which we construct the CYK table
1717
"""
1818

‎pyformlang/cfg/terminal.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44

55

66
classTerminal(CFGObject):# pylint: disable=too-few-public-methods
7-
""" An terminal in a CFG
8-
9-
Parameters
10-
-----------
11-
value : any
12-
The value of the terminal
13-
"""
7+
""" A terminal in a CFG """
148

159
def__eq__(self,other):
1610
returnisinstance(other,Terminal)andself.value==other.value

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp