From a4badc6a728dd88546281ddfed969c970d7ffc98 Mon Sep 17 00:00:00 2001 From: Tim Ohliger Date: Sat, 31 Aug 2024 18:40:57 +0200 Subject: [PATCH] Changed Tensor.arange signature to be like in numpy. --- cpp/pybind/core/tensor.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/cpp/pybind/core/tensor.cpp b/cpp/pybind/core/tensor.cpp index fb2929fc54d..b68ab54c4c2 100644 --- a/cpp/pybind/core/tensor.cpp +++ b/cpp/pybind/core/tensor.cpp @@ -393,22 +393,22 @@ void pybind_core_tensor_definitions(py::module& m) { }, "Create a 1D tensor with evenly spaced values in the given " "interval.", - "stop"_a, "dtype"_a = py::none(), "device"_a = py::none()); + "stop"_a, py::pos_only(), py::kw_only(), "dtype"_a = py::none(), + "device"_a = py::none()); tensor.def_static( "arange", - [](utility::optional start, int64_t stop, - utility::optional step, utility::optional dtype, + [](int64_t start, int64_t stop, utility::optional step, + utility::optional dtype, utility::optional device) { return Tensor::Arange( - start.has_value() ? start.value() : 0, stop, - step.has_value() ? step.value() : 1, + start, stop, step.has_value() ? step.value() : 1, dtype.has_value() ? dtype.value() : core::Int64, device.has_value() ? device.value() : Device("CPU:0")); }, "Create a 1D tensor with evenly spaced values in the given " "interval.", - "start"_a = py::none(), "stop"_a, "step"_a = py::none(), - "dtype"_a = py::none(), "device"_a = py::none()); + "start"_a, "stop"_a, "step"_a = py::none(), "dtype"_a = py::none(), + py::kw_only(), "device"_a = py::none()); // Tensor creation from arange for float. tensor.def_static( @@ -422,22 +422,22 @@ void pybind_core_tensor_definitions(py::module& m) { }, "Create a 1D tensor with evenly spaced values in the given " "interval.", - "stop"_a, "dtype"_a = py::none(), "device"_a = py::none()); + "stop"_a, py::pos_only(), py::kw_only(), "dtype"_a = py::none(), + "device"_a = py::none()); tensor.def_static( "arange", - [](utility::optional start, double stop, - utility::optional step, utility::optional dtype, + [](double start, double stop, utility::optional step, + utility::optional dtype, utility::optional device) { return Tensor::Arange( - start.has_value() ? start.value() : 0.0, stop, - step.has_value() ? step.value() : 1.0, + start, stop, step.has_value() ? step.value() : 1.0, dtype.has_value() ? dtype.value() : core::Float64, device.has_value() ? device.value() : Device("CPU:0")); }, "Create a 1D tensor with evenly spaced values in the given " "interval.", - "start"_a = py::none(), "stop"_a, "step"_a = py::none(), - "dtype"_a = py::none(), "device"_a = py::none()); + "start"_a, "stop"_a, "step"_a = py::none(), "dtype"_a = py::none(), + py::kw_only(), "device"_a = py::none()); tensor.def( "append",