Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:26:15

0001 // Copyright Jim Bosch 2010-2012.
0002 // Copyright Stefan Seefeld 2016.
0003 // Distributed under the Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef boost_python_numpy_scalars_hpp_
0008 #define boost_python_numpy_scalars_hpp_
0009 
0010 /**
0011  *  @brief Object managers for array scalars (currently only numpy.void is implemented).
0012  */
0013 
0014 #include <boost/python.hpp>
0015 #include <boost/python/numpy/numpy_object_mgr_traits.hpp>
0016 #include <boost/python/numpy/dtype.hpp>
0017 
0018 namespace boost { namespace python { namespace numpy {
0019 
0020 /**
0021  *  @brief A boost.python "object manager" (subclass of object) for numpy.void.
0022  *
0023  *  @todo This could have a lot more functionality.
0024  */
0025 class BOOST_NUMPY_DECL void_ : public object
0026 {
0027   static python::detail::new_reference convert(object_cref arg, bool align);
0028 public:
0029 
0030   /**
0031    *  @brief Construct a new array scalar with the given size and void dtype.
0032    *
0033    *  Data is initialized to zero.  One can create a standalone scalar object
0034    *  with a certain dtype "dt" with:
0035    *  @code
0036    *  void_ scalar = void_(dt.get_itemsize()).view(dt);
0037    *  @endcode
0038    */
0039   explicit void_(Py_ssize_t size);
0040 
0041   BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(void_, object);
0042 
0043   /// @brief Return a view of the scalar with the given dtype.
0044   void_ view(dtype const & dt) const;
0045 
0046   /// @brief Copy the scalar (deep for all non-object fields).
0047   void_ copy() const;
0048 
0049 };
0050 
0051 } // namespace boost::python::numpy
0052 
0053 namespace converter 
0054 {
0055 NUMPY_OBJECT_MANAGER_TRAITS(numpy::void_);
0056 }}} // namespace boost::python::converter
0057 
0058 #endif