Skip to content

Commit

Permalink
linting, start of viz module
Browse files Browse the repository at this point in the history
  • Loading branch information
pnxenopoulos committed May 23, 2024
1 parent d32fd6f commit 63d9a37
Show file tree
Hide file tree
Showing 23 changed files with 249 additions and 8 deletions.
1 change: 1 addition & 0 deletions awpy/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Module to hold Counter-Strike 2 data."""
126 changes: 126 additions & 0 deletions awpy/data/map_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
"""Dictionary that holds map data for Counter-Strike 2."""

# pos_x is upper left world coordinate
MAP_DATA = {
"ar_baggage": {
"pos_x": -1316,
"pos_y": 1288,
"scale": 2.539062,
"rotate": 1,
"zoom": 1.3,
"selections": [
{"name": "default", "altitude_max": 10000, "altitude_min": -5},
{"name": "lower", "altitude_max": -5, "altitude_min": -10000},
],
},
"ar_shoots": {
"pos_x": -1368,
"pos_y": 1952,
"scale": 2.687500,
"rotate": None,
"zoom": None,
"selections": [],
},
"cs_office": {
"pos_x": -1838,
"pos_y": 1858,
"scale": 4.1,
"rotate": None,
"zoom": None,
"selections": [],
},
"cs_italy": {
"pos_x": -2647,
"pos_y": 2592,
"scale": 4.6,
"rotate": 1,
"zoom": 1.5,
"selections": [],
},
"de_ancient": {
"pos_x": -2953,
"pos_y": 2164,
"scale": 5,
"rotate": 0,
"zoom": 0,
"selections": [],
},
"de_anubis": {
"pos_x": -2796,
"pos_y": 3328,
"scale": 5.22,
"rotate": None,
"zoom": None,
"selections": [],
},
"de_dust": {
"pos_x": -2850,
"pos_y": 4073,
"scale": 6,
"rotate": 1,
"zoom": 1.3,
"selections": [],
},
"de_dust2": {
"pos_x": -2476,
"pos_y": 3239,
"scale": 4.4,
"rotate": 1,
"zoom": 1.1,
"selections": [],
},
"de_inferno": {
"pos_x": -2087,
"pos_y": 3870,
"scale": 4.9,
"rotate": None,
"zoom": None,
"selections": [],
},
"de_inferno_s2": {
"pos_x": -2087,
"pos_y": 3870,
"scale": 4.9,
"rotate": None,
"zoom": None,
"selections": [],
},
"de_mirage": {
"pos_x": -3230,
"pos_y": 1713,
"scale": 5,
"rotate": 0,
"zoom": 0,
"selections": [],
},
"de_nuke": {
"pos_x": -3453,
"pos_y": 2887,
"scale": 7,
"rotate": None,
"zoom": None,
"selections": [
{"name": "default", "altitude_max": 10000, "altitude_min": -495},
{"name": "lower", "altitude_max": -495, "altitude_min": -10000},
],
},
"de_overpass": {
"pos_x": -4831,
"pos_y": 1781,
"scale": 5.2,
"rotate": 0,
"zoom": 0,
"selections": [],
},
"de_vertigo": {
"pos_x": -3168,
"pos_y": 1762,
"scale": 4,
"rotate": None,
"zoom": None,
"selections": [
{"name": "default", "altitude_max": 20000, "altitude_min": 11700},
{"name": "lower", "altitude_max": 11700, "altitude_min": -10000},
],
},
}
1 change: 1 addition & 0 deletions awpy/data/maps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains map radar image files."""
Binary file added awpy/data/maps/ar_baggage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/ar_baggage_lower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/ar_shoots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/cs_italy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/cs_office.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/de_ancient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/de_anubis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/de_dust2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/de_inferno.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/de_mirage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/de_nuke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/de_nuke_lower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/de_overpass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/de_vertigo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added awpy/data/maps/de_vertigo_lower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions awpy/viz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Awpy visualization module."""

SIDE_COLORS = {"ct": "#5d79ae", "t": "#de9b35"}
SUPPORTED_MAPS = ["de_dust2"]
36 changes: 36 additions & 0 deletions awpy/viz/plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Module for plotting Counter-Strike data."""

import importlib.resources

import matplotlib.image as mpimg

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11)

Import "matplotlib.image" could not be resolved (reportMissingImports)

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10)

Import "matplotlib.image" could not be resolved (reportMissingImports)

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12)

Import "matplotlib.image" could not be resolved (reportMissingImports)

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12)

Import "matplotlib.image" could not be resolved (reportMissingImports)

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11)

Import "matplotlib.image" could not be resolved (reportMissingImports)

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10)

Import "matplotlib.image" could not be resolved (reportMissingImports)

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9)

Import "matplotlib.image" could not be resolved (reportMissingImports)

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9)

Import "matplotlib.image" could not be resolved (reportMissingImports)

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12)

Import "matplotlib.image" could not be resolved (reportMissingImports)

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9)

Import "matplotlib.image" could not be resolved (reportMissingImports)

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10)

Import "matplotlib.image" could not be resolved (reportMissingImports)

Check failure on line 5 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11)

Import "matplotlib.image" could not be resolved (reportMissingImports)
import matplotlib.pyplot as plt

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)

Check failure on line 6 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11)

Import "matplotlib.pyplot" could not be resolved (reportMissingImports)
from matplotlib.axes import Axes

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11)

Import "matplotlib.axes" could not be resolved (reportMissingImports)

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10)

Import "matplotlib.axes" could not be resolved (reportMissingImports)

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12)

Import "matplotlib.axes" could not be resolved (reportMissingImports)

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12)

Import "matplotlib.axes" could not be resolved (reportMissingImports)

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11)

Import "matplotlib.axes" could not be resolved (reportMissingImports)

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10)

Import "matplotlib.axes" could not be resolved (reportMissingImports)

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9)

Import "matplotlib.axes" could not be resolved (reportMissingImports)

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9)

Import "matplotlib.axes" could not be resolved (reportMissingImports)

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12)

Import "matplotlib.axes" could not be resolved (reportMissingImports)

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9)

Import "matplotlib.axes" could not be resolved (reportMissingImports)

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10)

Import "matplotlib.axes" could not be resolved (reportMissingImports)

Check failure on line 7 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11)

Import "matplotlib.axes" could not be resolved (reportMissingImports)
from matplotlib.figure import Figure

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11)

Import "matplotlib.figure" could not be resolved (reportMissingImports)

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10)

Import "matplotlib.figure" could not be resolved (reportMissingImports)

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12)

Import "matplotlib.figure" could not be resolved (reportMissingImports)

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12)

Import "matplotlib.figure" could not be resolved (reportMissingImports)

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11)

Import "matplotlib.figure" could not be resolved (reportMissingImports)

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10)

Import "matplotlib.figure" could not be resolved (reportMissingImports)

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9)

Import "matplotlib.figure" could not be resolved (reportMissingImports)

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9)

Import "matplotlib.figure" could not be resolved (reportMissingImports)

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12)

Import "matplotlib.figure" could not be resolved (reportMissingImports)

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9)

Import "matplotlib.figure" could not be resolved (reportMissingImports)

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10)

Import "matplotlib.figure" could not be resolved (reportMissingImports)

Check failure on line 8 in awpy/viz/plot.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11)

Import "matplotlib.figure" could not be resolved (reportMissingImports)


def plot_map(map_name: str, *, lower: bool = False) -> tuple[Figure, Axes]:
"""Plot a Counter-Strike map.
Args:
map_name (str): Name of the map to plot.
lower (bool, optional): Allows plotting the lower layer. Defaults to False.
Raises:
FileNotFoundError: Raises a FileNotFoundError if the map image is not found.
Returns:
tuple[Figure, Axes]: Matplotlib Figure and Axes objects.
"""
if lower is True:
map_name += "_lower"

with importlib.resources.path("awpy.data.maps", f"{map_name}.png") as map_img_path:
if not map_img_path.exists():
map_img_not_found_msg = f"Map image not found: {map_img_path}"
raise FileNotFoundError(map_img_not_found_msg)

map_bg = mpimg.imread(map_img_path)

figure, axes = plt.subplots()
axes.imshow(map_bg, zorder=0)
return figure, axes
76 changes: 76 additions & 0 deletions awpy/viz/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""Utilities for plotting and visualization."""

from typing import Literal

from awpy.data.map_data import MAP_DATA


# Position function courtesy of PureSkill.gg
def position_transform_axis(
map_name: str, position: float, axis: Literal["x", "y"]
) -> float:
"""Transforms an X or Y-axis value.
Args:
map_name (str): Map to search
position (float): X or Y coordinate
axis (str): Either "x" or "y"
Returns:
float: Transformed position
Raises:
ValueError: Raises a ValueError if axis not 'x' or 'y'
"""
axis = axis.lower()

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)

Check failure on line 25 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11)

Expression of type "LiteralString" is incompatible with declared type "Literal['x', 'y']"   Type "LiteralString" is incompatible with type "Literal['x', 'y']"     "LiteralString" is incompatible with type "Literal['x']"     "LiteralString" is incompatible with type "Literal['y']" (reportAssignmentType)
if axis not in ["x", "y"]:
msg = f"'axis' has to be 'x' or 'y', not {axis}"
raise ValueError(msg)
start = MAP_DATA[map_name]["pos_" + axis]
scale = MAP_DATA[map_name]["scale"]

if axis == "x":
return (position - start) / scale

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)

Check failure on line 33 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11)

Operator "-" not supported for types "float" and "int | float | list[dict[str, str | int]] | None"   Operator "-" not supported for types "float" and "list[dict[str, str | int]]"   Operator "-" not supported for types "float" and "None" (reportOperatorIssue)
return (start - position) / scale

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)

Check failure on line 34 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11)

Operator "-" not supported for types "int | float | list[dict[str, str | int]] | None" and "float"   Operator "-" not supported for types "list[dict[str, str | int]]" and "float"   Operator "-" not supported for types "None" and "float" (reportOperatorIssue)


def position_transform(
map_name: str, position: tuple[float, float, float]
) -> tuple[float, float, float]:
"""Transforms an single coordinate (X,Y,Z).
Args:
map_name (str): Map to transform coordinates.
position (tuple): (X,Y,Z) coordinates.
Returns:
Tuple[float, float, float]: Transformed coordinates (X,Y,Z).
"""
return (
position_transform_axis(map_name, position[0], "x"),
position_transform_axis(map_name, position[1], "y"),
position[2],
)


def is_position_on_lower_level(
map_name: str, position: tuple[float, float, float]
) -> bool:
"""Check if a position is on a lower level of a map.
Args:
map_name (str): Map to check the position level.
position (Tuple[float, float, float]): (X,Y,Z) coordinates.
Returns:
bool: True if the position on the lower level, False otherwise.
"""
metadata = MAP_DATA[map_name]
if len(metadata["selections"]) == 0:

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)

Check failure on line 69 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11)

Argument of type "int | float | list[dict[str, str | int]] | None" cannot be assigned to parameter "obj" of type "Sized" in function "len"   Type "int | float | list[dict[str, str | int]] | None" is incompatible with type "Sized"     "float" is incompatible with protocol "Sized"       "__len__" is not present (reportArgumentType)
return False

for level in metadata["selections"]:

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.11)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.10)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.12)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.12)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.11)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.10)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 3.9)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (macos-latest, 3.9)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.12)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.9)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.10)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11)

Object of type "None" cannot be used as iterable value (reportOptionalIterable)

Check failure on line 72 in awpy/viz/utils.py

View workflow job for this annotation

GitHub Actions / build (windows-latest, 3.11)

"int" is not iterable   "__iter__" method not defined (reportGeneralTypeIssues)
if position[2] > level["altitude_max"] and position[2] <= level["altitude_min"]:
return True

return False
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ classifiers = [
]
dependencies = [
"loguru>=0.7.2",
"matplotlib>=3.9.0",
"numpy>=1.26.3",
"pandas>=2.2.2",
"setuptools>=69.2.0",
Expand All @@ -40,11 +41,7 @@ include-package-data = true

[tool.setuptools.package-data]
"*" = [
"data/map/*.png",
"data/map/*.json",
"data/nav/*.txt",
"data/nav/*.csv",
"data/nav/*.json",
"data/maps/*.png"
]

[tool.ruff]
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Global test configuration."""
"""Awpy test configuration."""

import json
import os
Expand All @@ -22,12 +22,12 @@ def teardown(): # noqa: PT004, ANN201
"""Cleans testing environment by deleting all .dem and .json files."""
yield
for file in os.listdir():
if file.endswith(".json"):
if file.endswith((".json", ".dem")):
os.remove(file)


def _get_demofile(demo_link: str, demo_name: str) -> None:
"""Sends a request to get a demofile from MediaFire.
"""Sends a request to get a demofile from the object storage.
Args:
demo_link (str): Link to demo.
Expand Down

0 comments on commit 63d9a37

Please sign in to comment.