File tree Expand file tree Collapse file tree 5 files changed +73
-18
lines changed
Expand file tree Collapse file tree 5 files changed +73
-18
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,39 @@ class Attribute :
107107 U get () const ;
108108};
109109
110+ inline std::ostream & operator <<( std::ostream & os, Attribute const & attr )
111+ {
112+ std::visit (
113+ [ &os ]( auto const & val ) {
114+ using Val_t =
115+ std::remove_cv_t < std::remove_reference_t < decltype ( val ) > >;
116+ if constexpr (
117+ auxiliary::IsVector_v< Val_t > ||
118+ auxiliary::IsArray_v< Val_t > )
119+ {
120+ if ( val.empty () )
121+ {
122+ os << " []" ;
123+ }
124+ else
125+ {
126+ os << " [" << val[ 0 ];
127+ for ( size_t i = 1 ; i < val.size (); ++i )
128+ {
129+ os << " , " << val[ i ];
130+ }
131+ os << " ]" ;
132+ }
133+ }
134+ else
135+ {
136+ os << val;
137+ }
138+ },
139+ attr.getResource () );
140+ return os;
141+ }
142+
110143template < typename T, typename U >
111144auto doConvert ( T * pv ) -> U
112145{
Original file line number Diff line number Diff line change @@ -442,6 +442,9 @@ void init_Attributable(py::module &m) {
442442 // C++ pass-through API: Getter
443443 .def (" get_attribute" , []( Attributable & attr, std::string const & key ) {
444444 auto v = attr.getAttribute (key);
445+ std::cout << " Attribute '" << key << " ' has type: " << v.dtype
446+ << std::endl
447+ << " and value: " << v << std::endl;
445448 return v.getResource ();
446449 // TODO instead of returning lists, return all arrays (ndim > 0) as numpy arrays?
447450 })
Original file line number Diff line number Diff line change @@ -99,13 +99,13 @@ namespace detail
9999 cl.def ( py::init<Map const &>() );
100100
101101 // Register stream insertion operator (if possible)
102- py::detail::map_if_insertion_operator<
103- Map,
104- Class_
105- >(
106- cl,
107- name
108- );
102+ // py::detail::map_if_insertion_operator<
103+ // Map,
104+ // Class_
105+ // >(
106+ // cl,
107+ // name
108+ // );
109109
110110 cl.def (
111111 " __bool__" ,
Original file line number Diff line number Diff line change @@ -86,9 +86,16 @@ void init_PatchRecordComponent(py::module &m) {
8686
8787 // allow one-element n-dimensional buffers as well
8888 py::ssize_t numElements = 1 ;
89- if ( buf.ndim > 0 ) {
89+ if ( buf.ndim > 0 )
90+ {
91+ std::cout << " Buffer has dimensionality: " << buf.ndim
92+ << std::endl;
9093 for ( auto d = 0 ; d < buf.ndim ; ++d )
91- numElements *= buf.shape .at (d);
94+ {
95+ std::cout << " Extent of dimensionality " << d << " : "
96+ << buf.shape .at ( d ) << std::endl;
97+ numElements *= buf.shape .at ( d );
98+ }
9299 }
93100
94101 // Numpy: Handling of arrays and scalars
@@ -149,8 +156,10 @@ void init_PatchRecordComponent(py::module &m) {
149156 }
150157 else
151158 {
152- throw std::runtime_error (" store: "
153- " Only scalar values supported!" );
159+ throw std::runtime_error (
160+ " store: "
161+ " Only scalar values supported! (found " +
162+ std::to_string ( numElements ) + " values)" );
154163 }
155164 }, py::arg (" idx" ), py::arg (" data" )
156165 )
Original file line number Diff line number Diff line change @@ -743,9 +743,16 @@ void init_RecordComponent(py::module &m) {
743743
744744 // allow one-element n-dimensional buffers as well
745745 py::ssize_t numElements = 1 ;
746- if ( buf.ndim > 0 ) {
746+ if ( buf.ndim > 0 )
747+ {
748+ std::cout << " Buffer has dimensionality: " << buf.ndim
749+ << std::endl;
747750 for ( auto d = 0 ; d < buf.ndim ; ++d )
748- numElements *= buf.shape .at (d);
751+ {
752+ std::cout << " Extent of dimensionality " << d << " : "
753+ << buf.shape .at ( d ) << std::endl;
754+ numElements *= buf.shape .at ( d );
755+ }
749756 }
750757
751758 // Numpy: Handling of arrays and scalars
@@ -815,14 +822,17 @@ void init_RecordComponent(py::module &m) {
815822 return rc.makeConstant ( *static_cast <std::complex <long double >*>(buf.ptr ) );
816823 break ;
817824 default :
818- throw std::runtime_error (" make_constant: "
819- " Unknown Datatype!" );
820- }
825+ throw std::runtime_error (
826+ " make_constant: "
827+ " Unknown Datatype!" );
828+ }
821829 }
822830 else
823831 {
824- throw std::runtime_error (" make_constant: "
825- " Only scalar values supported!" );
832+ throw std::runtime_error (
833+ " make_constant: "
834+ " Only scalar values supported! (found " +
835+ std::to_string ( numElements ) + " values)" );
826836 }
827837
828838 }, py::arg (" value" )
You can’t perform that action at this time.
0 commit comments