File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -130,15 +130,22 @@ namespace
130130 py::class_< SM > py_sm (m, sm_name.c_str ());
131131 py_sm
132132 .def (" __repr__" ,
133- [sm_name](SM const &) {
134- return " <amrex." + sm_name + " >" ;
135- }
136- )
137- .def (" __str__" ,
138- [sm_name](SM const & sm) {
133+ [](SM const & sm) {
134+ // similar look & feel like numpy.ndarray.__repr__
139135 std::stringstream ss;
140- ss << sm;
141- return ss.str ();
136+ for (int i = sm.starting_index ; i < sm.row_size + sm.starting_index ; ++i) {
137+ if (i > sm.starting_index ) { ss << " ,\n " ; }
138+ ss << " [" ;
139+ ss << sm (i, sm.starting_index );
140+ for (int j = 1 + sm.starting_index ; j < sm.column_size + sm.starting_index ; ++j) {
141+ ss << " , " << sm (i, j);
142+ }
143+ ss << " ]" ;
144+ }
145+ using namespace std ::string_literals;
146+ return " SmallMatrix([" s +
147+ ss.str () +
148+ " ])" s;
142149 }
143150 )
144151
You can’t perform that action at this time.
0 commit comments