aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/matplotlib/py2/src/array.h
diff options
context:
space:
mode:
authorAlexander Smirnov <alex@ydb.tech>2025-05-14 00:51:55 +0000
committerAlexander Smirnov <alex@ydb.tech>2025-05-14 00:51:55 +0000
commitb2d03716ee053cd32dccb8dd189d0b4bc3540d90 (patch)
treed329b3f92d5f80b8a76cac17d9e30bd1c8dc4b06 /contrib/python/matplotlib/py2/src/array.h
parent645c59acc8ced6d89eb8559e26a7405d42ae9fb4 (diff)
parent0bf9db6399352012396e7791bcfd762e944b33c2 (diff)
downloadydb-b2d03716ee053cd32dccb8dd189d0b4bc3540d90.tar.gz
Merge branch 'rightlib' into merge-libs-250514-0050
Diffstat (limited to 'contrib/python/matplotlib/py2/src/array.h')
-rw-r--r--contrib/python/matplotlib/py2/src/array.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/contrib/python/matplotlib/py2/src/array.h b/contrib/python/matplotlib/py2/src/array.h
new file mode 100644
index 00000000000..8056366a1c9
--- /dev/null
+++ b/contrib/python/matplotlib/py2/src/array.h
@@ -0,0 +1,80 @@
+/* -*- mode: c++; c-basic-offset: 4 -*- */
+
+/* Utilities to create scalars and empty arrays that behave like the
+ Numpy array wrappers in numpy_cpp.h */
+
+#ifndef _SCALAR_H_
+#define _SCALAR_H_
+
+namespace array
+{
+
+template <typename T, int ND>
+class scalar
+{
+ public:
+ T m_value;
+
+ scalar(const T value) : m_value(value)
+ {
+ }
+
+ T &operator()(int i, int j = 0, int k = 0)
+ {
+ return m_value;
+ }
+
+ const T &operator()(int i, int j = 0, int k = 0) const
+ {
+ return m_value;
+ }
+
+ int dim(size_t i)
+ {
+ return 1;
+ }
+
+ size_t size()
+ {
+ return 1;
+ }
+};
+
+template <typename T>
+class empty
+{
+ public:
+ typedef empty<T> sub_t;
+
+ empty()
+ {
+ }
+
+ T &operator()(int i, int j = 0, int k = 0)
+ {
+ throw std::runtime_error("Accessed empty array");
+ }
+
+ const T &operator()(int i, int j = 0, int k = 0) const
+ {
+ throw std::runtime_error("Accessed empty array");
+ }
+
+ sub_t operator[](int i) const
+ {
+ return empty<T>();
+ }
+
+ int dim(size_t i) const
+ {
+ return 0;
+ }
+
+ size_t size() const
+ {
+ return 0;
+ }
+};
+}
+
+#endif