Skip to content

Commit

Permalink
pylint - fix singleton-comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
pavoljuhas committed Oct 4, 2024
1 parent 577cbf3 commit 140bc14
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions examples/quantum_chinese_chess/board_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,16 @@ def test_flying_general_check_classical_cases():
board = Board.from_fen()
# If they are in different columns, the check fails.
board.king_locations = ["d0", "e9"]
assert board.flying_general_check() == False
assert not board.flying_general_check()

# If there are classical pieces between two KINGs, the check fails.
board.king_locations = ["e0", "e9"]
assert board.flying_general_check() == False
assert not board.flying_general_check()

# If there are no pieces between two KINGs, the check successes.
board.board["e3"].reset()
board.board["e6"].reset()
assert board.flying_general_check() == True
assert board.flying_general_check()


def test_flying_general_check_quantum_cases():
Expand Down
4 changes: 2 additions & 2 deletions examples/quantum_chinese_chess/chess_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ def test_update_board_by_sampling(monkeypatch):
game.update_board_by_sampling()
assert board["a0"].type_ == Type.EMPTY
assert board["a0"].color == Color.NA
assert board["a0"].is_entangled == False
assert not board["a0"].is_entangled

board["a1"].is_entangled = True
# Verify that the method would set a1 to classically occupied.
game.update_board_by_sampling()
assert board["a1"].is_entangled == False
assert not board["a1"].is_entangled


def test_undo_single_effect_per_move(monkeypatch):
Expand Down
2 changes: 1 addition & 1 deletion examples/quantum_chinese_chess/enums_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_type_of():
assert Type.type_of("k") == Type.KING
assert Type.type_of("K") == Type.KING
assert Type.type_of("·") == Type.EMPTY
assert Type.type_of("b") == None
assert Type.type_of("b") is None


def test_symbol():
Expand Down
16 changes: 8 additions & 8 deletions examples/quantum_chinese_chess/move_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_move_type():
move_type=MoveType.MERGE_JUMP,
move_variant=MoveVariant.CAPTURE,
)
assert move1.is_split_move() == False
assert not move1.is_split_move()
assert move1.is_merge_move()

move2 = Move(
Expand All @@ -91,16 +91,16 @@ def test_move_type():
move_variant=MoveVariant.BASIC,
)
assert move2.is_split_move()
assert move2.is_merge_move() == False
assert not move2.is_merge_move()

move3 = Move(
world["a1"],
world["b2"],
move_type=MoveType.SLIDE,
move_variant=MoveVariant.CAPTURE,
)
assert move3.is_split_move() == False
assert move3.is_merge_move() == False
assert not move3.is_split_move()
assert not move3.is_merge_move()


def test_to_str():
Expand Down Expand Up @@ -275,10 +275,10 @@ def test_split_jump_classical_source():
assert_fifty_fifty(board_probabilities, locations_to_bitboard(["a3"]))
assert world["a2"].type_ == Type.ROOK
assert world["a2"].color == Color.RED
assert world["a2"].is_entangled == True
assert world["a2"].is_entangled
assert world["a3"].type_ == Type.ROOK
assert world["a3"].color == Color.RED
assert world["a3"].is_entangled == True
assert world["a3"].is_entangled


def test_split_jump_quantum_source():
Expand All @@ -295,8 +295,8 @@ def test_split_jump_quantum_source():
locations_to_bitboard(["a5"]): 0.25,
},
)
assert world["a4"].is_entangled == True
assert world["a5"].is_entangled == True
assert world["a4"].is_entangled
assert world["a5"].is_entangled


def test_merge_jump_perfect_merge():
Expand Down
2 changes: 1 addition & 1 deletion examples/quantum_chinese_chess/piece_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_reset():
p0.reset()
assert p0.type_ == Type.EMPTY
assert p0.color == Color.NA
assert p0.is_entangled == False
assert not p0.is_entangled

p0.reset(p1)
assert p0.type_ == p1.type_
Expand Down
2 changes: 1 addition & 1 deletion unitary/alpha/quantum_world_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_get_object_by_name(compile_to_qubits):
board = alpha.QuantumWorld([light, light2], compile_to_qubits=compile_to_qubits)
assert board.get_object_by_name("test") == light
assert board.get_object_by_name("test2") == light2
assert board.get_object_by_name("test3") == None
assert board.get_object_by_name("test3") is None
assert board["test"] == light
assert board["test2"] == light2
with pytest.raises(KeyError):
Expand Down

0 comments on commit 140bc14

Please sign in to comment.