nd::string::string(const nd::array& rhs) { if (!rhs.is_null()) { if (rhs.is_immutable() && rhs.get_type().get_type_id() == string_type_id && rhs.get_type().extended<ndt::string_type>()->get_encoding() == string_encoding_utf_8) { // It's already immutable and the right type m_value = rhs; } else if (rhs.get_type().value_type().get_kind() == string_kind) { m_value = rhs.ucast(ndt::make_string()).eval_immutable(); } else { stringstream ss; ss << "Cannot implicitly convert nd::array of type " << rhs.get_type().value_type() << " to string"; throw type_error(ss.str()); } } }
dynd::nd::array pydynd::array_ucast(const dynd::nd::array &n, const ndt::type &dt, intptr_t replace_ndim) { return n.ucast(dt, replace_ndim); }
dynd::nd::array pydynd::array_ucast(const dynd::nd::array& n, const ndt::type& dt, intptr_t replace_ndim, PyObject *assign_error_obj) { return n.ucast(dt, replace_ndim, pyarg_error_mode(assign_error_obj)); }