From 9b60455d8ca9e8b3ab5dc35a8c4b8821a2f14bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jouni=20K=2E=20Sepp=C3=A4nen?= Date: Thu, 15 Oct 2015 15:28:32 +0300 Subject: [PATCH] Make array_view.size return 0 for empty arrays --- src/numpy_cpp.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/numpy_cpp.h b/src/numpy_cpp.h index 0bc2d5c03854..128482c669ec 100644 --- a/src/numpy_cpp.h +++ b/src/numpy_cpp.h @@ -481,7 +481,17 @@ class array_view : public detail::array_view_accessors size_t size() const { - return (size_t)dim(0); + bool empty = (ND == 0); + for (size_t i = 0; i < ND; i++) { + if (m_shape[i] == 0) { + empty = true; + } + } + if (empty) { + return 0; + } else { + return (size_t)dim(0); + } } bool empty() const pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy