Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ci #296

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11"] #, "3.12-dev"]
python-version: ["3.11", "3.12"]
go-version: ["1.18", "1.19", "1.20"]
steps:
- name: Checkout awpy library
Expand Down Expand Up @@ -65,12 +65,12 @@ jobs:
- name: Lint with ruff
uses: chartboost/ruff-action@v1
with:
version: 0.0.291
version: 0.1.11

- name: Typecheck with pyright
uses: jakebailey/pyright-action@v1
with:
version: 1.1.329
version: 1.1.344

- name: Thorough check with pylint
run: pylint awpy
Expand Down
16 changes: 11 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
exclude: docs/
repos:
- repo: https://github.com/JanEricNitschke/pymend
rev: "v1.0.10"
hooks:
- id: pymend
language: python
args: ["--write", "--check", "--output-style=google"]
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-yaml
language: python
Expand All @@ -26,19 +32,19 @@ repos:
- id: check-builtin-literals
language: python
- repo: 'https://github.com/charliermarsh/ruff-pre-commit'
rev: v0.0.291
rev: v0.1.11
hooks:
- id: ruff
args:
- '--fix'
- '--exit-non-zero-on-fix'
- repo: 'https://github.com/psf/black'
rev: 23.9.1
rev: 23.12.1
hooks:
- id: black
language: python
- repo: https://github.com/crate-ci/typos
rev: v1.16.13
rev: v1.17.0
hooks:
- id: typos
args: []
Expand All @@ -64,7 +70,7 @@ repos:
"-sn", # Don't display the score
]
- repo: https://github.com/golangci/golangci-lint
rev: v1.54.2
rev: v1.55.2
hooks:
- id: golangci-lint
entry: bash -c 'cd awpy/parser && golangci-lint run --new-from-rev HEAD --fix'
42 changes: 21 additions & 21 deletions awpy/analytics/map_control.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Functions for calculating map control values and metrics.

A team's map control can be thought of as the sum of it's
individual player's control.
A team's map control can be thought of as the sum of it's
individual player's control.

Example notebook:
Example notebook:

https://github.com/pnxenopoulos/awpy/blob/main/examples/05_Map_Control_Calculations_And_Visualizations.ipynb
https://github.com/pnxenopoulos/awpy/blob/main/examples/05_Map_Control_Calculations_And_Visualizations.ipynb
"""

from collections import defaultdict, deque
Expand Down Expand Up @@ -45,13 +45,14 @@ def _approximate_neighbors(
map_name (str): Map for source_tile_id
source_tile_id (TileId): TileId for source tile
n_neighbors (int): Number of closest tiles/approximated neighbors wanted
(Default value = 5)

Returns:
List of TileDistanceObjects for n_neighbors closest tiles
list[DistanceObject]: List of TileDistanceObjects for n_neighbors closest tiles

Raises:
ValueError: If source_tile_id is not in awpy.data.NAV[map_name]
If n_neighbors <= 0
ValueError: If n_neighbors <= 0
"""
if source_tile_id not in NAV[map_name]:
msg = "Tile ID not found."
Expand Down Expand Up @@ -85,13 +86,13 @@ def _bfs(

Args:
map_name (str): Map for current_tiles
current_tiles (TileId): List of source tiles for bfs iteration(s)
current_tiles (list[TileId]): List of source tiles for bfs iteration(s)
area_threshold (float): Percentage representing amount of map's total
navigable area which is the max cumulative tile
area for each bfs algorithm
navigable area which is the max cumulative tile
area for each bfs algorithm (Default value = 1 / 20)

Returns:
TeamMapControlValues containing map control values
TeamMapControlValues: Map control values

Raises:
ValueError: If area_threshold <= 0
Expand Down Expand Up @@ -158,11 +159,11 @@ def _calc_frame_map_control_tile_values(

Args:
map_name (str): Map for other arguments
ct_tiles (list): List of CT-occupied tiles
t_tiles (list): List of T-occupied tiles
ct_tiles (list[TileId]): List of CT-occupied tiles
t_tiles (list[TileId]): List of T-occupied tiles

Returns:
FrameMapControlValues object containing each team's map control values
FrameMapControlValues: Each team's map control values
"""
return FrameMapControlValues(
t_values=_bfs(map_name, t_tiles),
Expand All @@ -189,7 +190,7 @@ def calc_parsed_frame_map_control_values(
(player positions, etc.). Expects extract_team_metadata output format

Returns:
FrameMapControlValues object containing each team's map control values
FrameMapControlValues: Each team's map control values

Raises:
ValueError: If map_name is not in awpy.data.NAV
Expand Down Expand Up @@ -228,7 +229,7 @@ def calc_frame_map_control_values(
frame (GameFrame): Awpy frame object for map control calculations

Returns:
FrameMapControlValues object containing each team's map control values
FrameMapControlValues: Each team's map control values

Raises:
ValueError: If map_name is not in awpy.data.NAV
Expand All @@ -252,7 +253,7 @@ def _extract_team_metadata(
side_data (TeamFrameInfo): Object with metadata for side's players.

Returns:
TeamMetadata with metadata on team's players
TeamMetadata: Metadata on team's players
"""
alive_players: list[PlayerPosition] = [
(player["x"], player["y"], player["z"])
Expand All @@ -273,8 +274,7 @@ def extract_teams_metadata(
containing relevant data for both sides

Returns:
FrameTeamMetadata containing team metadata (player
positions, etc.)
FrameTeamMetadata: Team metadata (player positions, etc.)
"""
return FrameTeamMetadata(
t_metadata=_extract_team_metadata(frame["t"]),
Expand Down Expand Up @@ -304,7 +304,7 @@ def _calc_map_control_metric_from_dict(
Expected format that of calc_frame_map_control_values output

Returns:
Map Control Metric
float: Map Control Metric
"""
current_map_control_value: list[float] = []
tile_areas: list[float] = []
Expand Down Expand Up @@ -342,7 +342,7 @@ def calc_frame_map_control_metric(
frame (GameFrame): awpy frame to calculate map control metric for

Returns:
Map Control metric for given frame
float: Map Control metric for given frame

Raises:
ValueError: If map_name is not in awpy.data.NAV
Expand Down Expand Up @@ -376,7 +376,7 @@ def calculate_round_map_control_metrics(
round_data (GameRound): awpy round to calculate map control metrics

Returns:
List of map control metric values for given round
list[float]: List of map control metric values for given round

Raises:
ValueError: If map_name is not in awpy.data.NAV
Expand Down