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

[GSProcessing] Fix isinstance check for numerical features #955

Merged
merged 3 commits into from
Aug 10, 2024
Merged
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,11 @@ def write_processed_feature(
}
node_type_feature_metadata[feat_name] = node_feature_metadata_dict

feat_val = single_feature_df.take(1)[0].asDict().get(feat_name, None)
nfeat_size = 1 if isinstance(feat_val, (int, float)) else len(feat_val)
thvasilo marked this conversation as resolved.
Show resolved Hide resolved
feat_val = single_feature_df.take(1)[0].asDict().get(feat_name)
assert isinstance(
feat_val, (list, numbers.Number)
), "We expect features to either be scalars or lists of scalars."
thvasilo marked this conversation as resolved.
Show resolved Hide resolved
nfeat_size = 1 if isinstance(feat_val, numbers.Number) else len(feat_val)
ntype_feat_sizes.update({feat_name: nfeat_size})

self.timers[f"{transformer.get_transformation_name()}-{node_type}-{feat_name}"] = (
Expand Down Expand Up @@ -1561,6 +1564,9 @@ def write_feature(self, feat_name, single_feature_df, edge_type, transformer_nam
edge_feature_metadata_dicts[feat_name] = edge_feature_metadata_dict

feat_val = single_feature_df.take(1)[0].asDict().get(feat_name, None)
assert isinstance(
feat_val, (list, numbers.Number)
), "We expect features to either be scalars or lists of scalars."
efeat_size = 1 if isinstance(feat_val, numbers.Number) else len(feat_val)
etype_feat_sizes.update({feat_name: efeat_size})

Expand Down
Loading