Skip to content

Commit

Permalink
v2.0.0b3 (#347)
Browse files Browse the repository at this point in the history
* add visibility notebook, usd docs

* heatmap

* test plot

* finnicky

* plotting finally

* remove dust2 gif

* adding prerelease to readme, fixing ruff stuff

* remove 3.9

* no more 3.9

* add USD download links

* update usd and ticks

* Revert
  • Loading branch information
pnxenopoulos authored Jul 24, 2024
1 parent 03f4250 commit 6748bb6
Show file tree
Hide file tree
Showing 20 changed files with 859 additions and 171 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11"] # Add 3.12 when pxr updates
python-version: ["3.10", "3.11"] # Add 3.12 when pxr updates
timeout-minutes: 15
steps:
- name: Checkout awpy library
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"

- name: Install Poetry
uses: abatilo/actions-poetry@v2
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

## Installation

To install Awpy, you can run
To install Awpy (it is currently in beta), you can run

```
pip install awpy
pip install --pre awpy
```

> [!NOTE]
> `awpy` requires [Python](https://www.python.org/downloads/) >= 3.9. To update the library, just run `pip install --upgrade awpy`. To check your current version, run `pip freeze | grep awpy`.
> `awpy` requires [Python](https://www.python.org/downloads/) >= 3.10. To update the library, just run `pip install --upgrade awpy`. To check your current version, run `pip freeze | grep awpy`.
> [!TIP]
> Don't worry if you get stuck, visit us [our Discord](https://discord.gg/W34XjsSs2H) for help.
Expand Down
2 changes: 1 addition & 1 deletion awpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

from awpy.demo import Demo

__version__ = "2.0.0-alpha"
__version__ = "2.0.0b3"
__all__ = ["Demo"]
10 changes: 9 additions & 1 deletion awpy/data/usd_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@
"""

USD_LINKS = {"de_dust2": "https://figshare.com/ndownloader/files/47199475"}
USD_LINKS = {
"de_ancient": "https://figshare.com/ndownloader/files/47861659",
"de_anubis": "https://figshare.com/ndownloader/files/47861695",
"de_dust2": "https://figshare.com/ndownloader/files/47199475",
"de_inferno": "https://figshare.com/ndownloader/files/47861707",
"de_mirage": "https://figshare.com/ndownloader/files/47861734",
"de_nuke": "https://figshare.com/ndownloader/files/47861782",
"de_overpass": "https://figshare.com/ndownloader/files/47861788",
}
18 changes: 14 additions & 4 deletions awpy/parsers/clock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Module for time and clock parsing functions."""

import math
from typing import Literal, Union
from typing import Literal, Optional, Union

import pandas as pd

Expand All @@ -14,6 +14,7 @@ def parse_clock(
seconds_since_phase_change: int,
max_time_ticks: Union[Literal["start", "freeze", "bomb"], int],
tick_rate: int = 64,
timings: Optional[dict] = None,
) -> str:
"""Parse the remaining time in a round or phase to a clock string.
Expand All @@ -22,16 +23,25 @@ def parse_clock(
max_time_ticks (Union[Literal['start', 'freeze', 'bomb'], int]): The maximum
time in ticks for the phase.
tick_rate (int, optional): The tick rate of the server. Defaults to 64.
timings (dict, optional): The timings for the round. Default dictionary is
a dictionary of preset constants.
Returns:
str: The remaining time in MM:SS format.
"""
if timings is None:
timings = {
"start": ROUND_START_DEFAULT_TIME_IN_SECS,
"freeze": FREEZE_DEFAULT_TIME_IN_SECS,
"bomb": BOMB_DEFAULT_TIME_IN_SECS,
}

if max_time_ticks == "start":
max_time_ticks = ROUND_START_DEFAULT_TIME_IN_SECS * tick_rate
max_time_ticks = timings["start"] * tick_rate
elif max_time_ticks == "freeze":
max_time_ticks = FREEZE_DEFAULT_TIME_IN_SECS * tick_rate
max_time_ticks = timings["freeze"] * tick_rate
elif max_time_ticks == "bomb":
max_time_ticks = BOMB_DEFAULT_TIME_IN_SECS * tick_rate
max_time_ticks = timings["bomb"] * tick_rate

# Calculate the remaining time in ticks
remaining_ticks = max_time_ticks - seconds_since_phase_change
Expand Down
12 changes: 12 additions & 0 deletions awpy/parsers/ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ def remove_nonplay_ticks(parsed_df: pd.DataFrame) -> pd.DataFrame:
error_msg = f"{col} not found in dataframe."
raise ValueError(error_msg)

# Fill in missing values
for col in [
"is_freeze_period",
"is_warmup_period",
"is_terrorist_timeout",
"is_ct_timeout",
"is_technical_timeout",
"is_waiting_for_resume",
"is_match_started",
]:
parsed_df[col] = parsed_df[col].fillna(value=False)

# Remove records which do not occur in-play
parsed_df = parsed_df[
(~parsed_df["is_freeze_period"])
Expand Down
33 changes: 31 additions & 2 deletions awpy/plot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
"""Awpy plotting module."""

SIDE_COLORS = {"ct": "#5d79ae", "t": "#de9b35"}
SUPPORTED_MAPS = ["de_dust2"]
PLOT_SETTINGS = {
"ct": {
"marker": "o",
"color": "tab:cyan",
"size": 8,
},
"t": {
"marker": "o",
"color": "tab:olive",
"size": 8,
},
"bomb": {
"marker": "x",
"color": "tab:orange",
"size": 8,
},
"smoke": {
"marker": "o",
"color": "tab:gray",
"size": 12,
},
"fire": {
"marker": "o",
"color": "tab:red",
"size": 12,
},
}

from awpy.plot.plot import gif, heatmap, plot

__all__ = ["gif", "heatmap", "plot"]
Loading

0 comments on commit 6748bb6

Please sign in to comment.