Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
33fdd4f
Add feature specs definition to graph converter
MihirT906 Feb 19, 2025
4598ef5
Add error handling for feature_specs
MihirT906 Feb 19, 2025
60e5255
Bug fix
MihirT906 Feb 19, 2025
82c87eb
Add default structure
MihirT906 Feb 19, 2025
71b53d0
add normalized node features
MihirT906 Feb 20, 2025
838687b
Complete node features implementation
MihirT906 Feb 20, 2025
79d96e7
Remove redundant code
MihirT906 Feb 20, 2025
9a27cb1
Add flexible edge features
MihirT906 Feb 21, 2025
e2f306e
Add comments
MihirT906 Feb 21, 2025
04eea9b
Reformatted with black
MihirT906 Feb 25, 2025
264c04e
Fix comments
MihirT906 Feb 25, 2025
c22d151
black reformatting
MihirT906 Feb 25, 2025
c387d54
Modify initialisation of feature spec to take None
MihirT906 Feb 25, 2025
e0bf15c
Add error handling at initialisation for node features
MihirT906 Mar 11, 2025
08e9c2a
Modified node features to use default feature function map
MihirT906 Mar 16, 2025
9ac758c
Add edge feature error handling
MihirT906 Mar 16, 2025
2266156
Handle edge cases
MihirT906 Mar 17, 2025
8115e38
Add tests for flexible implementation
MihirT906 Mar 17, 2025
40f330d
Reformatting
MihirT906 Mar 17, 2025
203a4b9
Add function to save configuration
MihirT906 Mar 17, 2025
471c58d
Reformatted
MihirT906 Mar 17, 2025
6658862
Add graph settings and dataset features to save functionality
MihirT906 Mar 29, 2025
4b0b535
Complete save functionality
MihirT906 Mar 31, 2025
a1cdc2a
Fix dataset feature save
MihirT906 Apr 1, 2025
07a7978
Add version check code for load
MihirT906 Apr 1, 2025
241a7b7
Ball ID Type Bug Fix
MihirT906 Apr 1, 2025
50fdadc
Reformat
MihirT906 Apr 1, 2025
842b106
Complete JSON load function
MihirT906 Apr 1, 2025
48a5c33
Add test for save and load functionality
MihirT906 Apr 2, 2025
ca6f587
Complete save and load tests
MihirT906 Apr 3, 2025
f4f508a
Add function descriptions
MihirT906 Apr 3, 2025
52924e1
clean post_init
MihirT906 Apr 10, 2025
dcaeaa5
Fix default feature_specs
MihirT906 Apr 10, 2025
e0779c6
Modify to take None argument
MihirT906 Apr 10, 2025
b460478
Remove value type check
MihirT906 Apr 10, 2025
6ef5351
Change feature spec definition to take None
MihirT906 Apr 10, 2025
59a400e
Bug Fixes
MihirT906 Apr 10, 2025
d289228
Changed to take null
MihirT906 Apr 10, 2025
a0ff803
Validate dataset features and graph columns
MihirT906 Apr 10, 2025
41286c6
Remove redundancy
MihirT906 Apr 12, 2025
5c4d879
Add from_json
MihirT906 Apr 12, 2025
4b30912
Use FileLike
MihirT906 Apr 12, 2025
4366c75
Allow boolean parameters in feature specs
MihirT906 Apr 12, 2025
a08c1af
Revert to previous test
MihirT906 Apr 12, 2025
e8b4a35
Remove print statement
MihirT906 Apr 12, 2025
521137e
Add orientation check
MihirT906 Apr 12, 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
Next Next commit
Handle edge cases
  • Loading branch information
MihirT906 committed Mar 17, 2025
commit 2266156badf84434e520c4a8749624d8d3fffa85
1 change: 1 addition & 0 deletions unravel/soccer/graphs/features/node_feature_func_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class NodeFeatureDefaults(TypedDict):
value: float
max_value: Optional[float]
min_value: Optional[float]
max_distance: Optional[float]
team: Optional[int]
ball_id: Optional[int]
s: Optional[Union[float, np.ndarray]]
Expand Down
20 changes: 19 additions & 1 deletion unravel/soccer/graphs/graph_converter_pl.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __post_init__(self):
else:
self.dataset = self._remove_incomplete_frames()

if self.feature_specs == None:
if self.feature_specs == None or self.feature_specs == {}:
self.feature_specs = {
"node_features": {
"x_normed": {},
Expand Down Expand Up @@ -108,6 +108,22 @@ def __post_init__(self):
},
}

for key in self.feature_specs.keys():
if key not in ["node_features", "edge_features"]:
raise ValueError(
f"feature_specs should only contain 'node_features' or 'edge_features' as keys. You provided {key}"
)

if 'node_features' not in self.feature_specs:
self.feature_specs['node_features'] = {}
if 'edge_features' not in self.feature_specs:
self.feature_specs['edge_features'] = {}

if self.feature_specs["node_features"] == {} and self.feature_specs["edge_features"] == {}:
raise ValueError(
"Please provide feature_specs for either 'node_features' or 'edge_features' or both..."
)

self._validate_feature_specs(
self.feature_specs,
get_node_feature_func_map,
Expand All @@ -126,6 +142,8 @@ def _validate_feature_specs(
self, feature_specs: dict, feature_func, feature_defaults, feature_tag
):
# validate features
if feature_tag not in feature_specs:
return
feature_map = feature_func(settings=self.settings)
for feature in feature_specs[feature_tag]:
if feature not in feature_map:
Expand Down