USACE / go-consequences

A lightweight consequences computational engine written in Go
MIT License
14 stars 11 forks source link

Compund hazard in DamageFunctionFamily yields inconsistent results #90

Closed HenryGeorgist closed 2 years ago

HenryGeorgist commented 2 years ago

Describe the bug I observed that i get different damage functions from the Damage function family in testing for the same hazard parameter.

It seems that compound parameters may not behave exactly as expected.

To Reproduce Steps to reproduce the behavior:

  1. Go to jsonocctypeprovider_test.go Test_JsonReading
  2. Click on debug test
  3. Scroll down to debug console, sometimes it prints "HEC-FIA damage function (galveston) - expected result, and sometimes it prints NACCS combined curves for commercial structures (unexpected result - that should be for depth|salinity)

Expected behavior either the dictionary is being improperly loaded - or the dictionary query on multiple hazards is improper.

HenryGeorgist commented 2 years ago

wrote a test:

func Test_OccupancyType_COM1(t *testing.T) {
    o := com1()
    fmt.Println(o.ComponentDamageFunctions["contents"].DamageFunctions[hazards.Depth].Source)
    b, err := json.Marshal(o)
    if err != nil {
        panic(err)
    }
    var o2 OccupancyTypeStochastic
    err = json.Unmarshal(b, &o2)
    if err != nil {
        panic(err)
    }
    fmt.Println(o2.ComponentDamageFunctions["contents"].DamageFunctions[hazards.Depth].Source)
}

unmarshal is the culprit.

HenryGeorgist commented 2 years ago

was splitting on "," rather than ", "