|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +from dataclasses import fields |
3 | 4 | from datetime import datetime, timedelta |
4 | 5 | from pathlib import Path |
5 | 6 |
|
@@ -55,17 +56,17 @@ def example_solution() -> Solution: |
55 | 56 | { |
56 | 57 | 'p_min': xa.DataArray( |
57 | 58 | data=rng.random((1, 3, 2, 3)), |
58 | | - dims=["focal_point_index", "x", "y", "z"], |
| 59 | + dims=["focal_point_index", "lat", "ele", "ax"], |
59 | 60 | attrs={'units': "Pa"} |
60 | 61 | ), |
61 | 62 | 'p_max': xa.DataArray( |
62 | 63 | data=rng.random((1, 3, 2, 3)), |
63 | | - dims=["focal_point_index", "x", "y", "z"], |
| 64 | + dims=["focal_point_index", "lat", "ele", "ax"], |
64 | 65 | attrs={'units': "Pa"} |
65 | 66 | ), |
66 | 67 | 'intensity': xa.DataArray( |
67 | 68 | data=rng.random((1, 3, 2, 3)), |
68 | | - dims=["focal_point_index", "x", "y", "z"], |
| 69 | + dims=["focal_point_index", "lat", "ele", "ax"], |
69 | 70 | attrs={'units': "W/cm^2"} |
70 | 71 | ) |
71 | 72 | }, |
@@ -136,6 +137,17 @@ def test_json_serialize_deserialize_solution_analysis(compact_representation: bo |
136 | 137 | analysis_reconstructed = SolutionAnalysis.from_json(analysis_json) |
137 | 138 | assert dataclasses_are_equal(analysis_reconstructed, analysis) |
138 | 139 |
|
| 140 | +def test_solution_analyze_data_types(example_solution:Solution, example_transducer:Transducer): |
| 141 | + """Test that solution analysis field are all floats or lists of floats as expected""" |
| 142 | + analysis = example_solution.analyze(example_transducer) |
| 143 | + for f in fields(analysis): |
| 144 | + value = getattr(analysis, f.name) |
| 145 | + if not isinstance(value, float): |
| 146 | + assert isinstance(value, list) |
| 147 | + if len(value) > 0: |
| 148 | + assert isinstance(value[0], float) |
| 149 | + |
| 150 | + |
139 | 151 | def test_solution_created_date(): |
140 | 152 | """Test that created date is recent when a solution is created.""" |
141 | 153 | tolerance = timedelta(seconds=2) |
|
0 commit comments