| 14 | using namespace nb::literals; |
| 15 | |
| 16 | struct PrintOptionsContext { |
| 17 | mx::PrintOptions old_options; |
| 18 | mx::PrintOptions new_options; |
| 19 | PrintOptionsContext(mx::PrintOptions p) : new_options(p) {} |
| 20 | PrintOptionsContext& enter() { |
| 21 | old_options = mx::get_global_formatter().format_options; |
| 22 | mx::set_printoptions(new_options); |
| 23 | return *this; |
| 24 | } |
| 25 | void exit(nb::args) { |
| 26 | mx::set_printoptions(old_options); |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | void init_print(nb::module_& m) { |
| 31 | // Set Python print formatting options |
no test coverage detected