Skip to content
Open
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bb7d854
added BasketballDataset class
not-heavychevy Apr 10, 2025
2abeeff
added BasketballPitchDimensions class
not-heavychevy Apr 10, 2025
bd59522
added graph settings
not-heavychevy Apr 10, 2025
8a83938
added optimized graph converter
not-heavychevy Apr 10, 2025
f5071c6
added ball handling
not-heavychevy Apr 10, 2025
26d6d85
added init files
not-heavychevy Apr 10, 2025
f2d164b
bugfix dataset load() bug
not-heavychevy Apr 10, 2025
d86c0af
added tests
not-heavychevy Apr 10, 2025
d1c0c73
added additional fields computation
not-heavychevy Apr 10, 2025
64f5ee3
BasketballDataset inherits from DefaultDataset
not-heavychevy Apr 12, 2025
835cd59
bugfix
not-heavychevy Apr 12, 2025
98f09ae
files read with kloppy.io
not-heavychevy Apr 19, 2025
0502aa7
added norm parameters
not-heavychevy Apr 19, 2025
d2f6b52
refactor: move get_dataframe to DefaultDataset
not-heavychevy Apr 20, 2025
53ea444
created post_init
not-heavychevy Apr 20, 2025
3482bf9
added self.settings to BasketballDataset
not-heavychevy Apr 20, 2025
51a6657
added add_dummy_labels и add_graph_ids
not-heavychevy Apr 20, 2025
1352f80
rewritten tests for dataset.py
not-heavychevy Apr 21, 2025
b0fc5c1
Refactor BasketballPitchDimensions
not-heavychevy Apr 25, 2025
1e04bfd
added tests for BasketballPitchDimensions
not-heavychevy Apr 25, 2025
627fae8
Refactor BasketballGraphSettings
not-heavychevy Apr 25, 2025
1bdd740
added tests for BasketballGraphSettings
not-heavychevy Apr 25, 2025
7c64156
Merge PitchDimensions and GraphSettings
not-heavychevy Apr 25, 2025
a70739c
graph_settings test update
not-heavychevy Apr 25, 2025
ebe0914
import bugs fix
not-heavychevy Apr 25, 2025
2dcd3fb
graph_converter refactoring
not-heavychevy Apr 26, 2025
4b96024
dataset separator bugfix
not-heavychevy Apr 26, 2025
af3a02a
added tests for graph_converter
not-heavychevy Apr 26, 2025
8a47337
moved the functionality to “features”
not-heavychevy Apr 26, 2025
633afca
tests update
not-heavychevy Apr 26, 2025
7463b1e
tests fix
not-heavychevy Apr 26, 2025
dcfa8e4
Deprecate speed/acceleration thresholds
not-heavychevy Apr 26, 2025
1b5bc3b
unify data/settings access on DefaultDataset
not-heavychevy Apr 26, 2025
7eb2081
Refactor _convert to use polars methods
not-heavychevy Apr 26, 2025
b0b9d72
Add unified graph-export API to GraphConverter
not-heavychevy Apr 26, 2025
e55d30e
added new tests for public export API
not-heavychevy Apr 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added new tests for public export API
  • Loading branch information
not-heavychevy committed Apr 26, 2025
commit e55d30eac373c74f76ee471f389de7392648e28d
56 changes: 56 additions & 0 deletions tests/test_basketball.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,59 @@ def test_compute_smoke(sample_basketball_json):
)
assert df.height == len(unique_frames)

# New tests for new graph-export APIs

def test_to_graph_frames_and_consistency(sample_basketball_json):
"""
to_graph_frames() must return the same information that compute() provides,
but wrapped per-frame in a dict.
"""
# prepare dataset and converter
ds = BasketballDataset(tracking_data=str(sample_basketball_json))
ds.add_graph_ids(by=["game_id", "event_id", "frame_id"], column_name="graph_id")
ds.add_dummy_labels(by=["game_id", "event_id", "frame_id"], column_name="label")
settings = BasketballGraphSettings()
conv = BasketballGraphConverter(dataset=ds, settings=settings)

# run both paths
df_result = conv.compute()
frame_dicts = conv.to_graph_frames()

# basic checks
assert isinstance(frame_dicts, list)
assert len(frame_dicts) == df_result.height

# compare first frame between both outputs
first_d = frame_dicts[0]
first_r = df_result.row(0, named=True)

assert set(first_d.keys()) == {"id", "x", "a", "e", "y"}
assert first_d["id"] == first_r["id"]
assert np.array_equal(first_d["x"], first_r["x"])
assert np.array_equal(first_d["a"], first_r["a"])
assert np.array_equal(first_d["e"], first_r["e"])
assert first_d["y"] == first_r["y"]


def test_to_spektral_graphs(sample_basketball_json):
"""
to_spektral_graphs() must wrap each frame in a valid spektral.data.Graph.
"""
ds = BasketballDataset(tracking_data=str(sample_basketball_json))
ds.add_graph_ids(by=["game_id","event_id","frame_id"], column_name="graph_id")
ds.add_dummy_labels(by=["game_id","event_id","frame_id"], column_name="label")
settings = BasketballGraphSettings()
conv = BasketballGraphConverter(dataset=ds, settings=settings)

graphs = conv.to_spektral_graphs()

from spektral.data import Graph
assert isinstance(graphs, list)
assert all(isinstance(g, Graph) for g in graphs)

# inspect first graph
g0 = graphs[0]
assert g0.x.ndim == 2 # (n_nodes, n_node_features)
assert g0.a.shape[0] == g0.a.shape[1] # square adjacency
assert g0.e.shape[0] == g0.e.shape[1] # edges align with nodes
assert g0.y.shape == (1,) # single label per graph