File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
python/pyarrow/src/arrow/python Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -96,10 +96,14 @@ Result<uint16_t> PyFloat_AsHalf(PyObject* obj) {
96
96
}
97
97
98
98
Result<std::shared_ptr<Array>> Arange (int64_t start, int64_t stop, int64_t step) {
99
- double delta = static_cast <double >(stop - start);
100
- double size = std::ceil (delta / step);
101
-
102
- if (ARROW_PREDICT_FALSE (step == 0 || size <= 0 )) {
99
+ int64_t size;
100
+ if (step > 0 && stop > start) {
101
+ // Ceiling division for positive step
102
+ size = (stop - start + step - 1 ) / step;
103
+ } else if (step < 0 && stop < start) {
104
+ // Ceiling division for negative step
105
+ size = (start - stop - step - 1 ) / (-step);
106
+ } else {
103
107
return MakeEmptyArray (int64 ());
104
108
}
105
109
std::shared_ptr<Buffer> data_buffer;
You can’t perform that action at this time.
0 commit comments