@@ -90,19 +90,14 @@ using Aqua
9090 @test_throws DimensionMismatch MagneticFieldCoefficients (coeffs, tDes, zeros (3 ,2 ))
9191 end
9292
93- @testset " Load data from file" begin
93+ @testset " Load/write data from/to file" begin
9494 ɛ = eps (Float64)
9595
9696 # # measurement data (without coefficients)
9797 filename = " idealGradientField.h5"
9898 field = SphericalHarmonicsDefinedField (filename)
9999 @test isapprox (field[0.01 ,0.01 ,0.01 ], [- 0.01 ,- 0.01 ,0.02 ], atol= ε)
100100
101- # Test field types
102- @test fieldType (field) isa OtherField
103- @test definitionType (field) isa SphericalHarmonicsDataBasedFieldDefinition
104- @test timeDependencyType (field) isa TimeConstant
105-
106101 # get coefficients
107102 coeffsMF, = MPISphericalHarmonics. loadTDesignCoefficients (filename)
108103 @test isapprox (coeffsMF. radius, 0.042 , atol= ε) # radius
@@ -115,6 +110,7 @@ using Aqua
115110 filename2 = " Coeffs.h5"
116111 filename3 = " Coeffs2.h5"
117112 filename4 = " Coeffs3.h5"
113+ filenameW = " CoeffsW.h5"
118114 write (filename2, coeffsMF. coeffs)
119115 # add radius and center
120116 cp (filename2, filename3)
@@ -144,17 +140,30 @@ using Aqua
144140 field = SphericalHarmonicsDefinedField (filename4)
145141 @test isapprox (field[- 0.02 ,0.02 ,- 0.03 ], [0.02 ,- 0.02 ,- 0.06 ], atol= ε)
146142
143+ # test write
144+ MPISphericalHarmonics. write (filenameW, coeffsTest)
145+ coeffsW = MagneticFieldCoefficients (filenameW)
146+ @test isapprox (coeffsW. radius, 0.042 , atol= ε) # radius
147+ @test isapprox (coeffsW. center, zeros (3 ), atol= ε) # center
148+ @test coeffsW. ffp == zeros (3 ,1 ) # FFP
149+
147150 # remove test files
148151 rm (filename2)
149152 rm (filename3)
150153 rm (filename4)
154+ rm (filenameW)
151155 end
152156
153- @testset " Multiple patches" begin
157+ @testset " SphericalHarmonicsDefinedField (multiple patches) " begin
154158 # # Multi-patch setting: Second field with offset
155159 coeffsPatch = hcat (deepcopy (coeffs),deepcopy (coeffs)) # two patches
156160 for j= 1 : 3 coeffsPatch[j,2 ][0 ,0 ] = 0.01 end # set offset
157- field = SphericalHarmonicsDefinedField (func = fastfunc .(coeffsPatch))
161+ field = SphericalHarmonicsDefinedField (coeffsPatch) # test constructor on coefficients
162+
163+ # Test field types
164+ @test fieldType (field) isa OtherField
165+ @test definitionType (field) isa SphericalHarmonicsDataBasedFieldDefinition
166+ @test timeDependencyType (field) isa TimeConstant
158167
159168 # # Test FFPs (for both patches)
160169 # First patch
0 commit comments