Skip to content

Commit

Permalink
Merge pull request #75 from HenryRLee/bug-object-is-not-subscriptable
Browse files Browse the repository at this point in the history
Fix `'type' object is not subscriptable` in Python
  • Loading branch information
HenryRLee authored Mar 10, 2023
2 parents 238632a + 8eeac71 commit 0d16808
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 50 deletions.
75 changes: 39 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,41 @@ jobs:
./cpp_example
./omaha_example
./unit_tests
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v1.3.0
with:
version: master
- name: zig build -Drelease-fast
run: |
cd cpp
zig build -Drelease-fast
- name: zig build -Ddynamic -Drelease-fast
run: |
cd cpp
zig build -Ddynamic -Drelease-fast
- name: zig build -Dtarget=x86_64-windows -Drelease-fast
run: |
cd cpp
zig build -Dtarget=x86_64-windows -Drelease-fast
- name: zig build -Domaha -Drelease-fast
run: |
cd cpp
zig build -Domaha -Drelease-fast
- name: zig build -Domaha -Ddynamic -Drelease-fast
run: |
cd cpp
zig build -Domaha -Ddynamic -Drelease-fast
- name: zig build -Domaha -Ddynamic -Dtarget=x86_64-windows -Drelease-fast
run: |
cd cpp
zig build -Domaha -Ddynamic -Dtarget=x86_64-windows -Drelease-fast
- name: zig build and run examples
run: |
cd cpp
zig build examples
zig-out/bin/c_example
# FIXME: zig-out/bin/cpp_example
# FIXME: zig-out/bin/omaha_example
# - name: Setup Zig
# uses: goto-bus-stop/setup-zig@v1.3.0
# with:
# version: master
# - name: zig build -Drelease-fast
# run: |
# cd cpp
# zig build -Drelease-fast
# - name: zig build -Ddynamic -Drelease-fast
# run: |
# cd cpp
# zig build -Ddynamic -Drelease-fast
# - name: zig build -Dtarget=x86_64-windows -Drelease-fast
# run: |
# cd cpp
# zig build -Dtarget=x86_64-windows -Drelease-fast
# - name: zig build -Domaha -Drelease-fast
# run: |
# cd cpp
# zig build -Domaha -Drelease-fast
# - name: zig build -Domaha -Ddynamic -Drelease-fast
# run: |
# cd cpp
# zig build -Domaha -Ddynamic -Drelease-fast
# - name: zig build -Domaha -Ddynamic -Dtarget=x86_64-windows -Drelease-fast
# run: |
# cd cpp
# zig build -Domaha -Ddynamic -Dtarget=x86_64-windows -Drelease-fast
# - name: zig build and run examples
# run: |
# cd cpp
# zig build examples
# zig-out/bin/c_example
# zig-out/bin/cpp_example
# zig-out/bin/omaha_example
cpp_benchmark:
name: C++ Benchmark
runs-on: ubuntu-latest
Expand All @@ -76,12 +76,15 @@ jobs:
python-test:
name: Python test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: "3.9"
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
cd python
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2016-2021 Henry Lee
Copyright 2016-2023 Henry Lee

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.14)

project(PokerHandEvaluator VERSION 0.5.1)
project(PokerHandEvaluator VERSION 0.5.2)

set(CMAKE_BUILD_TYPE "Release")

Expand Down
2 changes: 1 addition & 1 deletion python/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2016-2021 Henry Lee
Copyright 2016-2023 Henry Lee

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion python/phevaluator/evaluator_omaha.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def evaluate_omaha_cards(*cards: Union[int, str, Card]) -> int:
return _evaluate_omaha_cards(community_cards, hole_cards)


def _evaluate_omaha_cards(community_cards: list[int], hole_cards: list[int]) -> int:
def _evaluate_omaha_cards(community_cards: [int], hole_cards: [int]) -> int:
value_flush = 10000
value_noflush = 10000
suit_count_board = [0] * 4
Expand Down
4 changes: 2 additions & 2 deletions python/phevaluator/hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from .tables import CHOOSE, DP


def hash_quinary(quinary: list[int], num_cards: int) -> int:
def hash_quinary(quinary: [int], num_cards: int) -> int:
"""Hash list of cards.
Args:
quinary (list[int]): List of the count of the cards.
quinary ([int]): List of the count of the cards.
num_cards (int): The number of cards.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion python/phevaluator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
import random


def sample_cards(size: int) -> list[int]:
def sample_cards(size: int) -> [int]:
"""Sample random cards with size."""
return random.sample(range(52), k=size)
4 changes: 2 additions & 2 deletions python/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = phevaluator
version = 0.5.1
version = 0.5.2
description = PH Evaluator - an efficient Poker Hand Evaluator based on a Perfect Hash algorithm
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -32,7 +32,7 @@ project_urls =
Source = https://github.com/HenryRLee/PokerHandEvaluator/tree/master/python

[options]
python_requires= >=3.6, <4
python_requires= >=3.7, <4
packages = find:
install_requires =
numpy
Expand Down
4 changes: 2 additions & 2 deletions python/tests/table_tests/test_hashtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class TestFlushTable(unittest.TestCase):
VISIT = [0] * len(FLUSH)
CUR_RANK = 1

CACHE: list[int] = []
BINARIES: list[int] = []
CACHE: [int] = []
BINARIES: [int] = []

@classmethod
def setUpClass(cls):
Expand Down
4 changes: 2 additions & 2 deletions python/tests/table_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


class BaseTestNoFlushTable(unittest.TestCase):
TABLE: list[int] = NotImplemented
VISIT: list[int] = NotImplemented
TABLE: [int] = NotImplemented
VISIT: [int] = NotImplemented
NUM_CARDS: int = NotImplemented

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_evalator_omaha.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)


def evaluate_omaha_exhaustive(community_cards: list[int], hole_cards: list[int]) -> int:
def evaluate_omaha_exhaustive(community_cards: [int], hole_cards: [int]) -> int:
"""Evaluate omaha cards with `_evaluate_cards`."""
best_rank = min(
_evaluate_cards(c1, c2, c3, h1, h2)
Expand Down

0 comments on commit 0d16808

Please sign in to comment.