File tree 5 files changed +73
-18
lines changed
5 files changed +73
-18
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,39 @@ class Attribute :
107
107
U get () const ;
108
108
};
109
109
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
+
110
143
template < typename T, typename U >
111
144
auto doConvert ( T * pv ) -> U
112
145
{
Original file line number Diff line number Diff line change @@ -442,6 +442,9 @@ void init_Attributable(py::module &m) {
442
442
// C++ pass-through API: Getter
443
443
.def (" get_attribute" , []( Attributable & attr, std::string const & key ) {
444
444
auto v = attr.getAttribute (key);
445
+ std::cout << " Attribute '" << key << " ' has type: " << v.dtype
446
+ << std::endl
447
+ << " and value: " << v << std::endl;
445
448
return v.getResource ();
446
449
// TODO instead of returning lists, return all arrays (ndim > 0) as numpy arrays?
447
450
})
Original file line number Diff line number Diff line change @@ -99,13 +99,13 @@ namespace detail
99
99
cl.def ( py::init<Map const &>() );
100
100
101
101
// 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
+ // );
109
109
110
110
cl.def (
111
111
" __bool__" ,
Original file line number Diff line number Diff line change @@ -86,9 +86,16 @@ void init_PatchRecordComponent(py::module &m) {
86
86
87
87
// allow one-element n-dimensional buffers as well
88
88
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;
90
93
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
+ }
92
99
}
93
100
94
101
// Numpy: Handling of arrays and scalars
@@ -149,8 +156,10 @@ void init_PatchRecordComponent(py::module &m) {
149
156
}
150
157
else
151
158
{
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)" );
154
163
}
155
164
}, py::arg (" idx" ), py::arg (" data" )
156
165
)
Original file line number Diff line number Diff line change @@ -743,9 +743,16 @@ void init_RecordComponent(py::module &m) {
743
743
744
744
// allow one-element n-dimensional buffers as well
745
745
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;
747
750
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
+ }
749
756
}
750
757
751
758
// Numpy: Handling of arrays and scalars
@@ -815,14 +822,17 @@ void init_RecordComponent(py::module &m) {
815
822
return rc.makeConstant ( *static_cast <std::complex<long double >*>(buf.ptr ) );
816
823
break ;
817
824
default :
818
- throw std::runtime_error (" make_constant: "
819
- " Unknown Datatype!" );
820
- }
825
+ throw std::runtime_error (
826
+ " make_constant: "
827
+ " Unknown Datatype!" );
828
+ }
821
829
}
822
830
else
823
831
{
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)" );
826
836
}
827
837
828
838
}, py::arg (" value" )
You can’t perform that action at this time.
0 commit comments