Skip to content

Commit 587076c

Browse files
committed
adding better comments to the damage function family test
1 parent a54d3b0 commit 587076c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

nsi/nsi-api_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ func TestNsi_FL_FoundationTypes(t *testing.T) {
6767
} else {
6868
foundationTypes[str.Properties.FoundType] = 1
6969
}
70-
7170
})
7271
}
7372
fmt.Println(foundationTypes)

structures/occupancytypes_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,39 @@ import (
88
)
99

1010
func TestDamageFunctionFamily(t *testing.T) {
11+
//a map of hazard to damage function
1112
m := make(map[hazards.Parameter]paireddata.ValueSampler)
12-
13+
//a set of different hazard types.
1314
cep := hazards.Depth | hazards.Salinity | hazards.WaveHeight
1415
dep := hazards.Depth
1516
ce2p := hazards.Depth | hazards.WaveHeight
1617

18+
//a fake deterministic damage function for coastal event with salinity
1719
cexs := []float64{1, 2, 3}
1820
ceys := []float64{1, 2, 3}
1921
var cedf = paireddata.PairedData{Xvals: cexs, Yvals: ceys}
2022
m[cep] = cedf
2123

24+
//a fake deterministic damage function for a depth only event
2225
dexs := []float64{1, 2, 3}
2326
deys := []float64{2, 4, 6}
2427
var dedf = paireddata.PairedData{Xvals: dexs, Yvals: deys}
2528
m[dep] = dedf
2629

30+
//a fake deterministic damage function for an event with depth and wave, but no salinity...
2731
ce2xs := []float64{1, 2, 3}
2832
ce2ys := []float64{3, 6, 9}
2933
var ce2df = paireddata.PairedData{Xvals: ce2xs, Yvals: ce2ys}
3034
m[ce2p] = ce2df
35+
36+
//assign the fake damage function map as a family of damage functions.
3137
var df = DamageFunctionFamily{DamageFunctions: m}
38+
39+
//fake instances of hazards (to match the hazard types.)
3240
ce := hazards.CoastalEvent{Depth: 2, Salinity: true, WaveHeight: 3.4}
3341
de := hazards.DepthEvent{Depth: 2}
3442
ce2 := hazards.CoastalEvent{Depth: 2, Salinity: false, WaveHeight: 3.4}
43+
//confirm that for each hazard the correct damage function is pulled when requested and the proper damage value is computed.
3544
cv := df.DamageFunctions[ce.Parameters()].SampleValue(ce.Depth)
3645
if cv != 2 {
3746
t.Errorf("Expected 2")

0 commit comments

Comments
 (0)