msg<<"Incompatible strides: "<<strides<<" (got) vs "<<strides_from_dimensions_and_item_size(dims,info.itemsize)<<" (expected). Make sure your buffer is C contiguous."<<std::endl;
// .def("__float__", [](const Tensor &_self){ return value_t(_self); }) //TODO: does not work! use implicitly_convertible<Tensor, internal::IndexedTensorReadOnly<TensorNetwork>>();
.def("__float__",[](constTensor&_self){
if(_self.order()!=0){
throwvalue_error("order must be 0");
}
returnvalue_t(_self());
})
;
}
// NOTE The following code (when defined globally) would cast every xerus::Tensor to a numpy.ndarray.
// This would allow for cleaner code like the following:
// tt = xe.TTTensor([3])
// tt.set_component(0, np.arange(3)[None,:,None])
/* namespace pybind11 { namespace detail { */
/* template <> struct type_caster<Tensor> */
/* { */
/* public: */
/* PYBIND11_TYPE_CASTER(Tensor, _("Tensor")); */
/* // Conversion part 1 (Python -> C++) */
/* bool load(handle src, bool convert) */
/* { */
/* if ( !convert and !array_t<value_t>::check_(src) ) */
/* return false; */
/* auto buf = array_t<value_t, array::c_style | array::forcecast>::ensure(src); */
// .def("degrees_of_freedom", static_cast<size_t (TTTensor::*)() const>(&TTTensor::degrees_of_freedom)) // NOTE overloading a method with both static and instance methods is not supported
/* .def("degrees_of_freedom", static_cast<size_t (TTTensor::*)() const>(&TTTensor::degrees_of_freedom)) // NOTE overloading a method with both static and instance methods is not supported */