File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,8 @@ bool ShapeMatchGuard::check(PyObject* value) {
141
141
return false ;
142
142
}
143
143
for (size_t i = 0 ; i < shape.size (); ++i) {
144
- if (shape[i] <= 0 || shape[i] != expected_[i]) {
144
+ if (expected_[i] == -1 && shape[i] >= 1 ) continue ;
145
+ if (shape[i] != expected_[i]) {
145
146
return false ;
146
147
}
147
148
}
Original file line number Diff line number Diff line change @@ -159,7 +159,11 @@ class ShapeMatchGuard : public GuardBase {
159
159
explicit ShapeMatchGuard (const std::vector<py::object>& shape) {
160
160
expected_.reserve (shape.size ());
161
161
for (const auto & s : shape) {
162
- expected_.push_back (s.cast <int64_t >());
162
+ if (py::isinstance<py::int_>(s)) {
163
+ expected_.push_back (s.cast <int64_t >());
164
+ } else {
165
+ expected_.push_back (-1 );
166
+ }
163
167
}
164
168
}
165
169
You can’t perform that action at this time.
0 commit comments