Skip to content

Commit

Permalink
code style tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
diceroll123 committed Jan 30, 2024
1 parent 434231c commit 1e4e90c
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion neofoodclub/bets.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def _iterator(self) -> Generator[int, None, None]:
def __iter__(self) -> Generator[int, None, None]:
return self._iterator()

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
return (
isinstance(other, self.__class__)
and self.bets_hash == other.bets_hash
Expand Down
5 changes: 0 additions & 5 deletions neofoodclub/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@ class FoodClubException(Exception):
"""Base exception class for neofoodclub.py."""



class InvalidData(FoodClubException):
"""An exception that is thrown when improper data is passed into creating NFC objects."""



class NoPositiveArenas(FoodClubException):
"""An exception that is thrown when there are no positive arenas while creating a bustproof set."""



class InvalidBetHash(FoodClubException):
"""An exception that is thrown when an improper string is used to create bets from a hash."""



class InvalidAmountHash(FoodClubException):
"""An exception that is thrown when an improper string is used to create bet amounts from a hash."""

2 changes: 1 addition & 1 deletion neofoodclub/food_adjustments.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __new__(
*,
one: tuple[int, ...] | None = None,
two: tuple[int, ...] | None = None,
) -> DefaultDict[int, int]:
) -> defaultdict[int, int]:
data: dict[int, int] = {}

for fa_value, values in zip((1, 2), (one, two)):
Expand Down
4 changes: 2 additions & 2 deletions neofoodclub/modifier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import datetime
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from neofoodclub.nfc import NeoFoodClub
Expand Down Expand Up @@ -181,7 +181,7 @@ def letters(self) -> str:
if self._has_flag(1 << bit)
)

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
return (
isinstance(other, self.__class__)
and self.value == other.value
Expand Down
2 changes: 1 addition & 1 deletion neofoodclub/odds_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def arena(self) -> str:
def __repr__(self) -> str:
return f"<OddsChange arena={self.arena_index!r} index={self.index!r} pirate={self.pirate!r} old={self.old!r} new={self.new!r} timestamp={self.timestamp!r}>"

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
return isinstance(other, self.__class__) and self._data == other.data

def __iter__(self) -> Iterator[tuple[str, Any]]:
Expand Down
2 changes: 1 addition & 1 deletion neofoodclub/pirates.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def won(self) -> bool:
def __int__(self) -> int:
return self._bin

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
return isinstance(other, self.__class__) and int(self) == int(other)

def __repr__(self) -> str:
Expand Down
50 changes: 26 additions & 24 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# as some of the tests rely on specific qualities
# that this round provides, such as arena ratios,
# bets winning, etc.
@pytest.fixture
@pytest.fixture()
def test_round_data() -> Dict[str, Any]:
return {
"currentOdds": [
Expand Down Expand Up @@ -80,64 +80,64 @@ def test_round_data() -> Dict[str, Any]:
}


@pytest.fixture
@pytest.fixture()
def test_round_url() -> str:
return "/#round=7956&pirates=[[2,8,14,11],[20,7,6,10],[19,4,12,15],[3,1,5,13],[17,16,18,9]]&openingOdds=[[1,2,13,3,5],[1,4,2,4,5],[1,3,13,7,2],[1,13,2,3,3],[1,12,2,6,13]]&currentOdds=[[1,2,13,3,5],[1,4,2,4,6],[1,3,13,7,2],[1,13,2,3,3],[1,8,2,4,12]]&foods=[[26,25,4,9,21,1,33,11,7,10],[12,9,14,35,25,6,21,19,40,37],[17,30,21,39,37,15,29,40,31,10],[10,18,35,9,34,23,27,32,28,12],[11,20,9,33,7,14,4,23,31,26]]&winners=[1,3,4,2,4]&timestamp=2021-02-16T23:47:37+00:00"


@pytest.fixture
@pytest.fixture()
def test_round_url_invalid_opening_odds() -> str:
return "/#round=7956&pirates=[[2,8,14,11],[20,7,6,10],[19,4,12,15],[3,1,5,13],[17,16,18,9]]&openingOdds=[[1,1,13,3,5],[1,4,2,4,5],[1,3,13,7,2],[1,13,2,3,3],[1,12,2,6,13]]&currentOdds=[[1,2,13,3,5],[1,4,2,4,6],[1,3,13,7,2],[1,13,2,3,3],[1,8,2,4,12]]&foods=[[26,25,4,9,21,1,33,11,7,10],[12,9,14,35,25,6,21,19,40,37],[17,30,21,39,37,15,29,40,31,10],[10,18,35,9,34,23,27,32,28,12],[11,20,9,33,7,14,4,23,31,26]]&winners=[1,3,4,2,4]&timestamp=2021-02-16T23:47:37+00:00"


@pytest.fixture
@pytest.fixture()
def test_round_url_no_opening_odds() -> str:
return "/#round=7956&pirates=[[2,8,14,11],[20,7,6,10],[19,4,12,15],[3,1,5,13],[17,16,18,9]]&currentOdds=[[1,2,13,3,5],[1,4,2,4,6],[1,3,13,7,2],[1,13,2,3,3],[1,8,2,4,12]]&foods=[[26,25,4,9,21,1,33,11,7,10],[12,9,14,35,25,6,21,19,40,37],[17,30,21,39,37,15,29,40,31,10],[10,18,35,9,34,23,27,32,28,12],[11,20,9,33,7,14,4,23,31,26]]&winners=[1,3,4,2,4]&timestamp=2021-02-16T23:47:37+00:00"


@pytest.fixture
@pytest.fixture()
def test_round_url_no_current_odds() -> str:
return "/#round=7956&pirates=[[2,8,14,11],[20,7,6,10],[19,4,12,15],[3,1,5,13],[17,16,18,9]]&openingOdds=[[1,2,13,3,5],[1,4,2,4,5],[1,3,13,7,2],[1,13,2,3,3],[1,12,2,6,13]]&foods=[[26,25,4,9,21,1,33,11,7,10],[12,9,14,35,25,6,21,19,40,37],[17,30,21,39,37,15,29,40,31,10],[10,18,35,9,34,23,27,32,28,12],[11,20,9,33,7,14,4,23,31,26]]&winners=[1,3,4,2,4]&timestamp=2021-02-16T23:47:37+00:00"


@pytest.fixture
@pytest.fixture()
def test_round_url_invalid_pirates() -> str:
return "/#round=7956&pirates=0&openingOdds=[[1,2,13,3,5],[1,4,2,4,5],[1,3,13,7,2],[1,13,2,3,3],[1,12,2,6,13]]&currentOdds=[[1,2,13,3,5],[1,4,2,4,6],[1,3,13,7,2],[1,13,2,3,3],[1,8,2,4,12]]&foods=[[26,25,4,9,21,1,33,11,7,10],[12,9,14,35,25,6,21,19,40,37],[17,30,21,39,37,15,29,40,31,10],[10,18,35,9,34,23,27,32,28,12],[11,20,9,33,7,14,4,23,31,26]]&winners=[1,3,4,2,4]&timestamp=2021-02-16T23:47:37+00:00"


@pytest.fixture
@pytest.fixture()
def test_round_url_no_pirates() -> str:
return "/#round=7956&openingOdds=[[1,2,13,3,5],[1,4,2,4,5],[1,3,13,7,2],[1,13,2,3,3],[1,12,2,6,13]]&currentOdds=[[1,2,13,3,5],[1,4,2,4,6],[1,3,13,7,2],[1,13,2,3,3],[1,8,2,4,12]]&foods=[[26,25,4,9,21,1,33,11,7,10],[12,9,14,35,25,6,21,19,40,37],[17,30,21,39,37,15,29,40,31,10],[10,18,35,9,34,23,27,32,28,12],[11,20,9,33,7,14,4,23,31,26]]&winners=[1,3,4,2,4]&timestamp=2021-02-16T23:47:37+00:00"


@pytest.fixture
@pytest.fixture()
def test_round_url_no_round() -> str:
return "/#pirates=[[2,8,14,11],[20,7,6,10],[19,4,12,15],[3,1,5,13],[17,16,18,9]]&openingOdds=[[1,2,13,3,5],[1,4,2,4,5],[1,3,13,7,2],[1,13,2,3,3],[1,12,2,6,13]]&currentOdds=[[1,2,13,3,5],[1,4,2,4,6],[1,3,13,7,2],[1,13,2,3,3],[1,8,2,4,12]]&foods=[[26,25,4,9,21,1,33,11,7,10],[12,9,14,35,25,6,21,19,40,37],[17,30,21,39,37,15,29,40,31,10],[10,18,35,9,34,23,27,32,28,12],[11,20,9,33,7,14,4,23,31,26]]&winners=[1,3,4,2,4]&timestamp=2021-02-16T23:47:37+00:00"


@pytest.fixture
@pytest.fixture()
def test_round_url_no_food() -> str:
return "/#round=7956&pirates=[[2,8,14,11],[20,7,6,10],[19,4,12,15],[3,1,5,13],[17,16,18,9]]&openingOdds=[[1,2,13,3,5],[1,4,2,4,5],[1,3,13,7,2],[1,13,2,3,3],[1,12,2,6,13]]&currentOdds=[[1,2,13,3,5],[1,4,2,4,6],[1,3,13,7,2],[1,13,2,3,3],[1,8,2,4,12]]&winners=[1,3,4,2,4]&timestamp=2021-02-16T23:47:37+00:00"


@pytest.fixture
@pytest.fixture()
def test_round_url_no_winners() -> str:
return "/#round=7956&pirates=[[2,8,14,11],[20,7,6,10],[19,4,12,15],[3,1,5,13],[17,16,18,9]]&openingOdds=[[1,2,13,3,5],[1,4,2,4,5],[1,3,13,7,2],[1,13,2,3,3],[1,12,2,6,13]]&currentOdds=[[1,2,13,3,5],[1,4,2,4,6],[1,3,13,7,2],[1,13,2,3,3],[1,8,2,4,12]]&timestamp=2021-02-16T23:47:37+00:00"


@pytest.fixture
@pytest.fixture()
def test_max_ter_15_bets() -> str:
return "/15/#round=7956&pirates=[[2,8,14,11],[20,7,6,10],[19,4,12,15],[3,1,5,13],[17,16,18,9]]&openingOdds=[[1,2,13,3,5],[1,4,2,4,5],[1,3,13,7,2],[1,13,2,3,3],[1,12,2,6,13]]&currentOdds=[[1,2,13,3,5],[1,4,2,4,6],[1,3,13,7,2],[1,13,2,3,3],[1,8,2,4,12]]&foods=[[26,25,4,9,21,1,33,11,7,10],[12,9,14,35,25,6,21,19,40,37],[17,30,21,39,37,15,29,40,31,10],[10,18,35,9,34,23,27,32,28,12],[11,20,9,33,7,14,4,23,31,26]]&winners=[1,3,4,2,4]&timestamp=2021-02-16T23:47:37+00:00&b=eukucjuoycaulucepkyreynycyakacfulxcefk"


# crazy bets mean(all arenas have a pirate bet)
# the crazy bet methods here all correspond to the exact same set!
@pytest.fixture
@pytest.fixture()
def crazy_test_hash() -> str:
return "ltqvqwgimhqtvrnywrwvijwnn"


@pytest.fixture
@pytest.fixture()
def crazy_test_indices() -> Tuple[Tuple[int, ...], ...]:
return (
(2, 1, 3, 4, 3),
Expand All @@ -153,7 +153,7 @@ def crazy_test_indices() -> Tuple[Tuple[int, ...], ...]:
)


@pytest.fixture
@pytest.fixture()
def crazy_test_binaries() -> Tuple[int, ...]:
return (
0x48212,
Expand All @@ -169,7 +169,7 @@ def crazy_test_binaries() -> Tuple[int, ...]:
)


@pytest.fixture
@pytest.fixture()
def gambit_test_binaries() -> Tuple[int, ...]:
# just a random gambit set
return (
Expand All @@ -186,43 +186,45 @@ def gambit_test_binaries() -> Tuple[int, ...]:
)


@pytest.fixture
@pytest.fixture()
def nfc(test_round_data: Dict[str, Any]) -> NeoFoodClub:
return NeoFoodClub(test_round_data)


@pytest.fixture
@pytest.fixture()
def nfc_no_cache(test_round_data: Dict[str, Any]) -> NeoFoodClub:
return NeoFoodClub(test_round_data, cache=False)


@pytest.fixture
@pytest.fixture()
def nfc_with_bet_amount(test_round_data: Dict[str, Any]) -> NeoFoodClub:
return NeoFoodClub(test_round_data, bet_amount=8000)


@pytest.fixture
@pytest.fixture()
def nfc_with_bet_amount_logit_model(test_round_data: Dict[str, Any]) -> NeoFoodClub:
return NeoFoodClub(
test_round_data, bet_amount=8000, probability_model=MultinomialLogitModel
test_round_data,
bet_amount=8000,
probability_model=MultinomialLogitModel,
)


@pytest.fixture
@pytest.fixture()
def nfc_from_url(test_round_url) -> NeoFoodClub:
return NeoFoodClub.from_url(test_round_url)


@pytest.fixture
@pytest.fixture()
def nfc_no_foods(test_round_url_no_food: str) -> NeoFoodClub:
return NeoFoodClub.from_url(test_round_url_no_food)


@pytest.fixture
@pytest.fixture()
def crazy_bets(nfc: NeoFoodClub, crazy_test_hash: str) -> Bets:
return nfc.make_bets_from_hash(crazy_test_hash)


@pytest.fixture
@pytest.fixture()
def gambit_bets(nfc: NeoFoodClub, gambit_test_binaries: Tuple[int, ...]) -> Bets:
return nfc.make_bets_from_binaries(*gambit_test_binaries)

0 comments on commit 1e4e90c

Please sign in to comment.