"gallery/transforms/plot_transforms_getting_started.py" did not exist on "59b27ed64cf126357d60e8f2944d204f83075e2e"
Unverified Commit 79cffd57 authored by Rex Ying's avatar Rex Ying Committed by GitHub
Browse files

out of range exception catching (#227)

parent 0172aeb3
...@@ -117,10 +117,12 @@ sample(const torch::Tensor &colptr, const torch::Tensor &row, ...@@ -117,10 +117,12 @@ sample(const torch::Tensor &colptr, const torch::Tensor &row,
inline bool satisfy_time(const c10::Dict<node_t, torch::Tensor> &node_time_dict, inline bool satisfy_time(const c10::Dict<node_t, torch::Tensor> &node_time_dict,
const node_t &src_node_type, int64_t dst_time, const node_t &src_node_type, int64_t dst_time,
int64_t src_node) { int64_t src_node) {
try { // Check whether src -> dst obeys the time constraint: try {
// Check whether src -> dst obeys the time constraint
const torch::Tensor &src_node_time = node_time_dict.at(src_node_type); const torch::Tensor &src_node_time = node_time_dict.at(src_node_type);
return src_node_time.data_ptr<int64_t>()[src_node] <= dst_time; return src_node_time.data_ptr<int64_t>()[src_node] <= dst_time;
} catch (int err) { // If no time is given, fall back to normal sampling: } catch (const std::out_of_range& e) {
// If no time is given, fall back to normal sampling
return true; return true;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment