Skip to content

Commit

Permalink
formatting!
Browse files Browse the repository at this point in the history
  • Loading branch information
diceroll123 committed Feb 24, 2024
1 parent 3d228c7 commit e8005b6
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 54 deletions.
3 changes: 1 addition & 2 deletions neofoodclub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
__copyright__ = "Copyright 2021-present diceroll123"
__version__ = "0.0.1a"

from .neofoodclub import *

from .arenas import *
from .bets import *
from .chance import *
from .errors import *
from .models import *
from .modifier import *
from .neofoodclub import *
from .nfc import *
from .odds import *
from .odds_change import *
Expand Down
4 changes: 2 additions & 2 deletions neofoodclub/arenas.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Arena:
)

def __init__(
self, *, nfc: NeoFoodClub, arena_id: int, pirate_ids: Sequence[int]
self, *, nfc: NeoFoodClub, arena_id: int, pirate_ids: Sequence[int],
) -> None:
self.nfc: NeoFoodClub = nfc
self._id = arena_id
Expand Down Expand Up @@ -130,7 +130,7 @@ def get_pirate_by_id(self, pirate_id: int, /) -> Pirate:
if p.id == pirate_id:
return p
raise ValueError(
f"Could not find pirate with ID {pirate_id}. Only 1 through 20 are valid."
f"Could not find pirate with ID {pirate_id}. Only 1 through 20 are valid.",
)

def get_pirates_by_id(self, *pirate_ids: int) -> tuple[Pirate, ...]:
Expand Down
16 changes: 9 additions & 7 deletions neofoodclub/bets.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def net_expected(self) -> float:
if np.all(self.bet_amounts > -1000):
return np.sum(
self.bet_amounts * self.nfc._data_dict["ers"][self._indices]
- self.bet_amounts
- self.bet_amounts,
)
return 0.0

Expand Down Expand Up @@ -87,11 +87,11 @@ def bet_amounts(self) -> npt.NDArray[np.int32]:

@bet_amounts.setter
def bet_amounts(
self, val: Sequence[int | None] | npt.NDArray[np.int32] | None
self, val: Sequence[int | None] | npt.NDArray[np.int32] | None,
) -> None:
if val is None:
self._bet_amounts: npt.NDArray[np.int32] = np.array(
[-1000] * self._indices.size
[-1000] * self._indices.size,
)
return

Expand All @@ -102,7 +102,7 @@ def bet_amounts(
# strictly enforcing amount of values provided
if len(val) != self._indices.size:
raise InvalidData(
f"Invalid bet amounts provided. Expected length: {self._indices.size}, but received {len(val)}."
f"Invalid bet amounts provided. Expected length: {self._indices.size}, but received {len(val)}.",
)

amts: npt.NDArray[np.int32] = np.array([v or Math.BET_AMOUNT_MIN for v in val])
Expand Down Expand Up @@ -144,7 +144,7 @@ def __repr__(self) -> str:

@classmethod
def _from_generator(
cls, *, indices: npt.NDArray[np.int16], nfc: NeoFoodClub
cls, *, indices: npt.NDArray[np.int16], nfc: NeoFoodClub,
) -> Bets:
# here is where we will take indices and sort as needed
# to avoid confusion with "manually" making bets
Expand All @@ -160,6 +160,7 @@ def from_binary(cls, *bins: int, nfc: NeoFoodClub) -> Bets:
------
~neofoodclub.InvalidData
Invalid binaries were passed.
"""
np_bins = np.array(bins)
# duplicate bins are removed here
Expand All @@ -171,13 +172,13 @@ def from_binary(cls, *bins: int, nfc: NeoFoodClub) -> Bets:

if intersection.size == 0:
raise InvalidData(
"Bets class requires at least one valid bet binary integer."
"Bets class requires at least one valid bet binary integer.",
)

if intersection.size != np_bins.size:
diff = np.setxor1d(np_bins, intersection)
raise InvalidData(
f"Invalid bet binaries entered: {', '.join([hex(b) for b in diff])}"
f"Invalid bet binaries entered: {', '.join([hex(b) for b in diff])}",
)

return cls(nfc=nfc, indices=intersection)
Expand Down Expand Up @@ -254,6 +255,7 @@ def make_url(
include_domain: :class:`bool`
Whether or not you want the output URL to include the preferred neofoodclub website's domain.
Default = True.
"""
return self.nfc.make_url(self, all_data=all_data, include_domain=include_domain)

Expand Down
1 change: 1 addition & 0 deletions neofoodclub/chance.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Chance:
The sum of the probabilities per Chance where `value` <= this Chance's `value`.
tail: :class:`float`
The difference of the sum of the probabilities per Chance where `value` < this Chance's `value`, from 1.
"""

value: int
Expand Down
9 changes: 5 additions & 4 deletions neofoodclub/modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Modifier:
This flag value flips the algorithms upside-down, essentially giving you the Min TER bets instead of Max TER.
ALL_MODIFIERS: :class:`int`
This value is all of the other flag values, bitwise-or'd together. Only use this if you want true chaos.
"""

__slots__ = (
Expand Down Expand Up @@ -103,7 +104,7 @@ def time(self) -> datetime.time | None:
def time(self, val: datetime.time) -> None:
if not isinstance(val, datetime.time):
raise TypeError(
f"Expected datetime.time but received {val.__class__.__name__}"
f"Expected datetime.time but received {val.__class__.__name__}",
)
self._time = val
if self._nfc:
Expand Down Expand Up @@ -133,18 +134,18 @@ def custom_odds(self) -> dict[int, int]:
def custom_odds(self, val: dict[int, int]) -> None:
if not isinstance(val, dict):
raise TypeError(
f"Expected Dict[int, int] but received {val.__class__.__name__}"
f"Expected Dict[int, int] but received {val.__class__.__name__}",
)

for k, v in val.items():
if k not in range(1, 21):
raise ValueError(
f"Expected int between 1 and 20 for Pirate ID but received {k}"
f"Expected int between 1 and 20 for Pirate ID but received {k}",
)

if v not in range(2, 14):
raise ValueError(
f"Expected int between 2 and 13 for Pirate Odds but received {v}"
f"Expected int between 2 and 13 for Pirate Odds but received {v}",
)

self._custom_odds = val
Expand Down
14 changes: 12 additions & 2 deletions neofoodclub/neofoodclub.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def make_probabilities(
) -> list[list[float]]: ...
@staticmethod
def make_round_dicts(
stds: Sequence[Sequence[float]], odds: tuple[tuple[int, ...], ...]
stds: Sequence[Sequence[float]], odds: tuple[tuple[int, ...], ...],
) -> tuple[
npt.NDArray[np.int_],
npt.NDArray[np.float64],
Expand All @@ -38,6 +38,7 @@ class Math:
The index of the pirate in the arena. Can be 0 to 4. If 0, then there is no pirate.
arena: :class:`int`
The arena's index. Can be 0 to 4.
"""

@staticmethod
Expand All @@ -52,6 +53,7 @@ class Math:
----------
bets_indices: Sequence[:class:`int`]
A sequence of integers from 0 to 4 to represent a bet.
"""

@staticmethod
Expand All @@ -62,6 +64,7 @@ class Math:
----------
bet_binary: :class:`int`
An integer representing a bet.
"""

@staticmethod
Expand All @@ -72,6 +75,7 @@ class Math:
----------
bets_hash: :class:`str`
The hash of bet amounts.
"""

@staticmethod
Expand All @@ -82,18 +86,20 @@ class Math:
----------
bets_hash: :class:`str`
The hash of bet amounts.
"""

@staticmethod
def bets_indices_to_bet_binaries(
bets_indices: Sequence[Sequence[int]], /
bets_indices: Sequence[Sequence[int]], /,
) -> tuple[int, ...]:
"""Tuple[:class:`int`, ...]: Returns the bet-binary representations of the bets indices provided.
Parameters
----------
bets_indices: Sequence[Sequence[:class:`int`]]
A sequence of a sequence of integers from 0 to 4 to represent a bet.
"""

@staticmethod
Expand All @@ -104,6 +110,7 @@ class Math:
----------
bets_hash: :class:`str`
The hash of bet amounts.
"""

@staticmethod
Expand All @@ -116,6 +123,7 @@ class Math:
----------
bet_amounts: Sequence[int]
A sequence of bet amount integers.
"""

@staticmethod
Expand All @@ -126,6 +134,7 @@ class Math:
----------
bets_indices: Sequence[Sequence[:class:`int`]]
A sequence of a sequence of integers from 0 to 4 to represent a bet.
"""

@staticmethod
Expand All @@ -136,6 +145,7 @@ class Math:
----------
amounts_hash: :class:`str`
The hash of bet amounts.
"""
@staticmethod
def build_chance_objects(
Expand Down
Loading

0 comments on commit e8005b6

Please sign in to comment.