Skip to content

Commit b7bc6f4

Browse files
committed
Closes #239 Adding diffs to tests
test diff has beed added to all mentioned alg tests. cf_reader cxx & python tests are failing (cam5 test in cxx)
1 parent f2fb77a commit b7bc6f4

11 files changed

+203
-59
lines changed

io/teca_cartesian_mesh_writer.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ const_p_teca_dataset teca_cartesian_mesh_writer::execute(
395395
= std::dynamic_pointer_cast<const teca_cartesian_mesh>(
396396
input_data[0]);
397397

398+
std::cerr << "teca_cartesian_mesh_writer::execute -- mesh: " << mesh << std::endl;
399+
398400
// only rank 0 is required to have data
399401
int rank = 0;
400402
#if defined(TECA_HAS_MPI)

test/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,29 @@ teca_add_test(test_cf_reader_cam5
5656
LIBS teca_core teca_data teca_io teca_alg ${teca_test_link}
5757
COMMAND test_cf_reader
5858
-i "${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-[0-9][0-9]-10800\\.nc"
59-
-o "test_cf_reader_%t%.%e%" -s 1,2 -x lon -y lat -t time U850 V850
59+
-o "${TECA_DATA_ROOT}/test_cf_reader_cam5.bin" -s 1,2 -x lon -y lat -t time U850 V850
6060
FEATURES ${TECA_HAS_NETCDF}
6161
REQ_TECA_DATA)
6262

6363
teca_add_test(test_cf_reader_cfsr
6464
COMMAND test_cf_reader
6565
-i "${TECA_DATA_ROOT}/NCEP_CFSR_0\\.5_1979\\.nc"
66-
-o "test_cf_reader_%t%.%e%" -s 1,2 -x longitude -y latitude
66+
-o "${TECA_DATA_ROOT}/test_cf_reader_cfsr.bin" -s 1,2 -x longitude -y latitude
6767
-b 65,110,10,55,0,0 elevation
6868
FEATURES ${TECA_HAS_NETCDF}
6969
REQ_TECA_DATA)
7070

7171
teca_add_test(test_cf_reader_era5
7272
COMMAND test_cf_reader
7373
-i "${TECA_DATA_ROOT}/e5\.oper\.an\.vinteg\.162_072_viwvn.*\.nc"
74-
-o "test_cf_reader_era5_%t%.%e%" -s 0,-1 -x longitude -y latitude -t time VIWVN
74+
-o "${TECA_DATA_ROOT}/test_cf_reader_era5.bin" -s 0,-1 -x longitude -y latitude -t time VIWVN
7575
FEATURES ${TECA_HAS_NETCDF}
7676
REQ_TECA_DATA)
7777

7878
teca_add_test(test_cf_reader_file_time
7979
COMMAND test_cf_reader
8080
-i "${TECA_DATA_ROOT}/ARTMIP_MERRA_2D_20170210_06\.nc"
81-
-o "test_cf_reader_file_time_%t%.%e%" -s 0,-1 -x lon -y lat
81+
-o "test_cf_reader_file_time.bin" -s 0,-1 -x lon -y lat
8282
-n "ARTMIP_MERRA_2D_%Y%m%d_%H.nc" IVT
8383
FEATURES ${TECA_HAS_NETCDF}
8484
REQ_TECA_DATA)
@@ -235,7 +235,7 @@ teca_add_test(test_temporal_average
235235
LIBS teca_core teca_data teca_io teca_alg ${teca_test_link}
236236
COMMAND test_temporal_average
237237
"${TECA_DATA_ROOT}/cam5_1_amip_run2.cam2.h2.1991-10-01-10800.nc"
238-
test_temporal_average_%t%.%e% 0 -1 3 U850
238+
${TECA_DATA_ROOT}/test_temporal_average.bin 0 -1 3 U850
239239
FEATURES ${TECA_HAS_NETCDF}
240240
REQ_TECA_DATA)
241241

@@ -500,7 +500,7 @@ teca_add_test(test_binary_segmentation
500500
SOURCES test_binary_segmentation.cpp
501501
LIBS teca_core teca_data teca_io teca_alg ${teca_test_link}
502502
COMMAND test_binary_segmentation "${TECA_DATA_ROOT}/prw_hus_day_MRI.*\\.nc$"
503-
prw 50 75 "prw_segmentation_50-75_%t%.%e%"
503+
prw 50 75 "${TECA_DATA_ROOT}/prw_segmentation_50-75.bin"
504504
REQ_TECA_DATA)
505505

506506
teca_add_test(test_bayesian_ar_detect_serial

test/python/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
teca_add_test(py_test_cf_reader
22
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_cf_reader.py
33
"${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-0[12]-10800\\.nc"
4-
1 2 "py_test_cf_reader_%t%.vtk" U850 V850
4+
1 2 "${TECA_DATA_ROOT}/py_test_cf_reader.bin" U850 V850
55
FEATURES ${TECA_HAS_NETCDF}
66
REQ_TECA_DATA)
77

@@ -40,7 +40,7 @@ if (TECA_DATA_ROOT AND TECA_HAS_NETCDF)
4040
add_test(NAME py_test_connected_components
4141
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_connected_components.py
4242
"${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-01-10800\\.nc"
43-
"" U850 V850 15 0 0 "py_test_connected_components_%t%.vtk"
43+
"" U850 V850 15 0 0 "${TECA_DATA_ROOT}/py_test_connected_components.bin"
4444
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
4545
endif()
4646

@@ -51,7 +51,7 @@ teca_add_test(py_test_component_area_filter
5151
teca_add_test(py_test_derived_quantity
5252
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_derived_quantity.py
5353
"${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-0[12]-10800\\.nc"
54-
U850 V850 0 0 "py_test_derived_quantity_%t%.vtk"
54+
U850 V850 0 0 "${TECA_DATA_ROOT}/py_test_derived_quantity.bin"
5555
FEATURES ${TECA_HAS_NETCDF}
5656
REQ_TECA_DATA)
5757

@@ -62,14 +62,14 @@ teca_add_test(py_test_latitude_damper
6262
teca_add_test(py_test_programmable_algorithm
6363
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_programmable_algorithm.py
6464
"${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-0[12]-10800\\.nc"
65-
U850 V850 0 0 "py_test_programmable_algorithm_%t%.vtk"
65+
U850 V850 0 0 "${TECA_DATA_ROOT}/py_test_programmable_algorithm.bin"
6666
FEATURES ${TECA_HAS_NETCDF}
6767
REQ_TECA_DATA)
6868

6969
teca_add_test(py_test_vector_ops
7070
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_vector_ops.py
7171
"${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-01-10800\\.nc"
72-
0 0 py_test_vector_ops_%t%.vtk U850 V850
72+
0 0 ${TECA_DATA_ROOT}/py_test_vector_ops.bin U850 V850
7373
FEATURES ${TECA_HAS_NETCDF}
7474
REQ_TECA_DATA)
7575

test/python/test_cf_reader.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from teca import *
2+
import os
23
import sys
34

45
set_stack_trace_on_error()
@@ -34,9 +35,21 @@
3435
exe.set_end_index(end_index)
3536
exe.set_arrays(arrays)
3637

37-
wri = teca_cartesian_mesh_writer.New()
38-
wri.set_input_connection(coords.get_output_port())
39-
wri.set_executive(exe)
40-
wri.set_file_name(out_file)
41-
42-
wri.update()
38+
if os.path.exists(out_file):
39+
rea = teca_cartesian_mesh_reader.New()
40+
rea.set_file_name(out_file)
41+
42+
diff = teca_dataset_diff.New()
43+
diff.set_input_connection(0, rea.get_output_port())
44+
diff.set_input_connection(1, coords.get_output_port())
45+
diff.set_executive(exe)
46+
47+
diff.update()
48+
else:
49+
sys.stderr.write('generating baseline\n')
50+
wri = teca_cartesian_mesh_writer.New()
51+
wri.set_input_connection(coords.get_output_port())
52+
wri.set_executive(exe)
53+
wri.set_file_name(out_file)
54+
55+
wri.update()

test/python/test_connected_components.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from teca import *
2+
import os
23
import sys
34

45
set_stack_trace_on_error()
@@ -58,9 +59,21 @@
5859
exe.set_start_index(first_step)
5960
exe.set_end_index(end_index)
6061

61-
wri = teca_cartesian_mesh_writer.New()
62-
wri.set_input_connection(cc.get_output_port())
63-
wri.set_executive(exe)
64-
wri.set_file_name(out_file)
62+
if os.path.exists(out_file):
63+
rea = teca_cartesian_mesh_reader.New()
64+
rea.set_file_name(out_file)
65+
66+
diff = teca_dataset_diff.New()
67+
diff.set_input_connection(0, rea.get_output_port())
68+
diff.set_input_connection(1, cc.get_output_port())
69+
diff.set_executive(exe)
6570

66-
wri.update()
71+
diff.update()
72+
else:
73+
sys.stderr.write('generating baseline\n')
74+
wri = teca_cartesian_mesh_writer.New()
75+
wri.set_input_connection(cc.get_output_port())
76+
wri.set_executive(exe)
77+
wri.set_file_name(out_file)
78+
79+
wri.update()

test/python/test_derived_quantity.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from teca import *
22
import numpy as np
3+
import os
34
import sys
45

56
set_stack_trace_on_error()
@@ -50,9 +51,21 @@ def execute(port, data_in, req):
5051
exe.set_start_index(first_step)
5152
exe.set_end_index(end_index)
5253

53-
wri = teca_cartesian_mesh_writer.New()
54-
wri.set_input_connection(alg.get_output_port())
55-
wri.set_executive(exe)
56-
wri.set_file_name(out_file)
54+
if os.path.exists(out_file):
55+
rea = teca_cartesian_mesh_reader.New()
56+
rea.set_file_name(out_file)
57+
58+
diff = teca_dataset_diff.New()
59+
diff.set_input_connection(0, rea.get_output_port())
60+
diff.set_input_connection(1, alg.get_output_port())
61+
diff.set_executive(exe)
5762

58-
wri.update()
63+
diff.update()
64+
else:
65+
sys.stderr.write('generating baseline\n')
66+
wri = teca_cartesian_mesh_writer.New()
67+
wri.set_input_connection(alg.get_output_port())
68+
wri.set_executive(exe)
69+
wri.set_file_name(out_file)
70+
71+
wri.update()

test/python/test_programmable_algorithm.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from teca import *
22
import numpy as np
33
import sys
4+
import os
45

56
set_stack_trace_on_error()
67

@@ -65,9 +66,21 @@ def execute(port, data_in, req):
6566
exe.set_start_index(first_step)
6667
exe.set_end_index(end_index)
6768

68-
wri = teca_cartesian_mesh_writer.New()
69-
wri.set_input_connection(alg.get_output_port())
70-
wri.set_executive(exe)
71-
wri.set_file_name(out_file)
69+
if os.path.exists(out_file):
70+
rea = teca_cartesian_mesh_reader.New()
71+
rea.set_file_name(out_file)
72+
73+
diff = teca_dataset_diff.New()
74+
diff.set_input_connection(0, rea.get_output_port())
75+
diff.set_input_connection(1, alg.get_output_port())
76+
diff.set_executive(exe)
7277

73-
wri.update()
78+
diff.update()
79+
else:
80+
sys.stderr.write('generating baseline\n')
81+
wri = teca_cartesian_mesh_writer.New()
82+
wri.set_input_connection(alg.get_output_port())
83+
wri.set_file_name(out_file)
84+
wri.set_executive(exe)
85+
86+
wri.update()

test/python/test_vector_ops.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from teca import *
2+
import os
23
import sys
34

45
set_stack_trace_on_error()
@@ -46,9 +47,21 @@
4647
exe.set_start_index(first_step)
4748
exe.set_end_index(end_index)
4849

49-
wri = teca_cartesian_mesh_writer.New()
50-
wri.set_input_connection(vort.get_output_port())
51-
wri.set_executive(exe)
52-
wri.set_file_name(out_file)
50+
if os.path.exists(out_file):
51+
rea = teca_cartesian_mesh_reader.New()
52+
rea.set_file_name(out_file)
53+
54+
diff = teca_dataset_diff.New()
55+
diff.set_input_connection(0, rea.get_output_port())
56+
diff.set_input_connection(1, vort.get_output_port())
57+
diff.set_executive(exe)
5358

54-
wri.update()
59+
diff.update()
60+
else:
61+
sys.stderr.write('generating baseline\n')
62+
wri = teca_cartesian_mesh_writer.New()
63+
wri.set_input_connection(vort.get_output_port())
64+
wri.set_executive(exe)
65+
wri.set_file_name(out_file)
66+
67+
wri.update()

test/test_binary_segmentation.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
#include "teca_binary_segmentation.h"
44
#include "teca_cartesian_mesh_writer.h"
55
#include "teca_file_util.h"
6+
#include "teca_cartesian_mesh_reader.h"
7+
#include "teca_cartesian_mesh_writer.h"
8+
#include "teca_dataset_diff.h"
9+
#include "teca_mpi_manager.h"
610
#include "teca_system_interface.h"
11+
#include "teca_mpi.h"
712

813
#include <vector>
914
#include <string>
@@ -12,6 +17,9 @@ using namespace std;
1217

1318
int main(int argc, char **argv)
1419
{
20+
teca_mpi_manager mpi_man(argc, argv);
21+
int rank = mpi_man.get_comm_rank();
22+
1523
teca_system_interface::set_stack_trace_on_error();
1624

1725
if (argc != 6)
@@ -26,7 +34,7 @@ int main(int argc, char **argv)
2634
std::string var = argv[2];
2735
double low = atof(argv[3]);
2836
double high = atof(argv[4]);
29-
std::string out_file = argv[5];
37+
std::string baseline = argv[5];
3038

3139
// build the pipeline
3240
p_teca_cf_reader cfr = teca_cf_reader::New();
@@ -39,11 +47,28 @@ int main(int argc, char **argv)
3947
seg->set_threshold_by_percentile();
4048
seg->set_input_connection(cfr->get_output_port());
4149

42-
p_teca_cartesian_mesh_writer wri = teca_cartesian_mesh_writer::New();
43-
wri->set_input_connection(seg->get_output_port());
44-
wri->set_file_name(out_file);
50+
// regression test
51+
if (teca_file_util::file_exists(baseline.c_str()))
52+
{
53+
// run the test
54+
p_teca_cartesian_mesh_reader rea = teca_cartesian_mesh_reader::New();
55+
rea->set_file_name(baseline);
4556

46-
wri->update();
57+
p_teca_dataset_diff diff = teca_dataset_diff::New();
58+
diff->set_input_connection(0, rea->get_output_port());
59+
diff->set_input_connection(1, seg->get_output_port());
60+
diff->update();
61+
}
62+
else
63+
{
64+
// make a baseline
65+
if (rank == 0)
66+
cerr << "generating baseline image " << baseline << endl;
67+
p_teca_cartesian_mesh_writer wri = teca_cartesian_mesh_writer::New();
68+
wri->set_input_connection(seg->get_output_port());
69+
wri->set_file_name(baseline.c_str());
70+
wri->update();
71+
}
4772

4873
return 0;
4974
}

0 commit comments

Comments
 (0)