Skip to content

Commit

Permalink
Merge pull request #33 from SHADE-AI/32-extra-parentheses-in-and-and-orr
Browse files Browse the repository at this point in the history
fix: extra parentheses for AND ORR
  • Loading branch information
byung-o authored Nov 10, 2022
2 parents 1fa7ebf + 49fd618 commit d5a2d5e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Example:
```python3
>>> from daidepp import AND, PRP, PCE
>>> str(AND(PRP(PCE("AUS")), PRP(PCE("AUS", "ENG"))))
`AND ( ( PRP ( PCE ( AUS ) ) ) ( PRP ( PCE ( AUS ENG ) ) ) ( PRP ( PCE ( AUS ENG FRA ) ) ) )`
`AND ( PRP ( PCE ( AUS ) ) ) ( PRP ( PCE ( AUS ENG ) ) ) ( PRP ( PCE ( AUS ENG FRA ) ) )`
```
Each class in `keywords.py` uses different parameters for instantiation, so it is recommended to carefully follow the type hints or checkout `tests/test_keywords.py`, which provides examples for each class.

Expand Down
4 changes: 2 additions & 2 deletions src/daidepp/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def __init__(self, *arrangements):

def __str__(self):
arr_str = ["( " + str(arr) + " )" for arr in self.arrangments]
return f"AND ( " + " ".join(arr_str) + " )"
return f"AND " + " ".join(arr_str)


@dataclass
Expand All @@ -312,7 +312,7 @@ def __init__(self, *arrangements):

def __str__(self):
arr_str = ["( " + str(arr) + " )" for arr in self.arrangments]
return f"ORR ( " + " ".join(arr_str) + " )"
return f"ORR " + " ".join(arr_str)


@dataclass
Expand Down
8 changes: 4 additions & 4 deletions tests/test_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,23 +256,23 @@ def test_DMZ():

def test_AND():
and_1 = AND(PRP(PCE("AUS")), PRP(PCE("AUS", "ENG")))
assert str(and_1) == "AND ( ( PRP ( PCE ( AUS ) ) ) ( PRP ( PCE ( AUS ENG ) ) ) )"
assert str(and_1) == "AND ( PRP ( PCE ( AUS ) ) ) ( PRP ( PCE ( AUS ENG ) ) )"

and_2 = AND(PRP(PCE("AUS")), PRP(PCE("AUS", "ENG")), PRP(PCE("AUS", "ENG", "FRA")))
assert (
str(and_2)
== "AND ( ( PRP ( PCE ( AUS ) ) ) ( PRP ( PCE ( AUS ENG ) ) ) ( PRP ( PCE ( AUS ENG FRA ) ) ) )"
== "AND ( PRP ( PCE ( AUS ) ) ) ( PRP ( PCE ( AUS ENG ) ) ) ( PRP ( PCE ( AUS ENG FRA ) ) )"
)


def test_ORR():
orr_1 = ORR(PRP(PCE("AUS")), PRP(PCE("AUS", "ENG")))
assert str(orr_1) == "ORR ( ( PRP ( PCE ( AUS ) ) ) ( PRP ( PCE ( AUS ENG ) ) ) )"
assert str(orr_1) == "ORR ( PRP ( PCE ( AUS ) ) ) ( PRP ( PCE ( AUS ENG ) ) )"

orr_2 = ORR(PRP(PCE("AUS")), PRP(PCE("AUS", "ENG")), PRP(PCE("AUS", "ENG", "FRA")))
assert (
str(orr_2)
== "ORR ( ( PRP ( PCE ( AUS ) ) ) ( PRP ( PCE ( AUS ENG ) ) ) ( PRP ( PCE ( AUS ENG FRA ) ) ) )"
== "ORR ( PRP ( PCE ( AUS ) ) ) ( PRP ( PCE ( AUS ENG ) ) ) ( PRP ( PCE ( AUS ENG FRA ) ) )"
)


Expand Down

0 comments on commit d5a2d5e

Please sign in to comment.