From 64b988782fa3e4a780a720934334bcc3f7ec1636 Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Sun, 2 Jun 2019 18:51:26 -0400 Subject: [PATCH] Add test to check that the vector can be print in a format readable by numpy --- tests/lac/la_vector_print.cc | 44 ++++++++++++++++++++++++++++++++ tests/lac/la_vector_print.output | 3 +++ 2 files changed, 47 insertions(+) create mode 100644 tests/lac/la_vector_print.cc create mode 100644 tests/lac/la_vector_print.output diff --git a/tests/lac/la_vector_print.cc b/tests/lac/la_vector_print.cc new file mode 100644 index 0000000000..c7f2317730 --- /dev/null +++ b/tests/lac/la_vector_print.cc @@ -0,0 +1,44 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Check that print_numpy_array works + +#include + +#include "../tests.h" + + +template +void +print_vector() +{ + const unsigned int size = 20; + LinearAlgebra::Vector vec(size); + for (unsigned int i = 0; i < size; ++i) + vec(i) = static_cast(i); + + vec.print_numpy_array(deallog.get_file_stream()); +} + + +int +main() +{ + initlog(); + + print_vector(); + print_vector(); +} diff --git a/tests/lac/la_vector_print.output b/tests/lac/la_vector_print.output new file mode 100644 index 0000000000..8468fc46eb --- /dev/null +++ b/tests/lac/la_vector_print.output @@ -0,0 +1,3 @@ + +0.00000000 1.00000000 2.00000000 3.00000000 4.00000000 5.00000000 6.00000000 7.00000000 8.00000000 9.00000000 10.0000000 11.0000000 12.0000000 13.0000000 14.0000000 15.0000000 16.0000000 17.0000000 18.0000000 19.0000000 +0.00000000 1.00000000 2.00000000 3.00000000 4.00000000 5.00000000 6.00000000 7.00000000 8.00000000 9.00000000 10.0000000 11.0000000 12.0000000 13.0000000 14.0000000 15.0000000 16.0000000 17.0000000 18.0000000 19.0000000 -- 2.39.5