NREL-Sienna / InfrastructureSystems.jl

Utility package for Sienna's simulation infrastructure
https://nrel-sienna.github.io/InfrastructureSystems.jl/
BSD 3-Clause "New" or "Revised" License
39 stars 21 forks source link

Ignore UUIDs by default in compare_values #245

Closed daniel-thom closed 3 years ago

daniel-thom commented 3 years ago

This PR adds flexibility to the compare_values function. The default behavior is now to ignore UUIDs by default. We still use this to compare all values during serialization/deserialization.

This is step 1 in addressing https://github.com/NREL-SIIP/PowerSystems.jl/issues/604

The use case this addresses is the following (PowerSystems example):

sys1 = PSB.build_system(PSB.PSITestSystems, "test_RTS_GMLC_sys")
sys2 = PSB.build_system(PSB.PSITestSystems, "test_RTS_GMLC_sys")

gen1 = first(get_components(ThermalStandard, sys1))
gen2 = first(get_components(ThermalStandard, sys2))

set_active_power!(gen1, get_active_power(gen1) + 0.1)
IS.compare_values(gen1, gen2)
┌ Error: values do not match
│   T = ThermalStandard
│   name = :active_power
│   val1 = 0.65
│   val2 = 0.55
└ @ PowerSystems ~/sandboxes/PowerSystems.jl/src/base.jl:1694

I decided against implementing == for these reasons:

codecov[bot] commented 3 years ago

Codecov Report

Merging #245 (f649962) into master (0568609) will increase coverage by 0.81%. The diff coverage is 76.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #245      +/-   ##
==========================================
+ Coverage   75.58%   76.39%   +0.81%     
==========================================
  Files          43       43              
  Lines        3141     3152      +11     
==========================================
+ Hits         2374     2408      +34     
+ Misses        767      744      -23     
Flag Coverage Δ
unittests 76.39% <76.31%> (+0.81%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/in_memory_time_series_storage.jl 72.38% <0.00%> (ø)
src/utils/test.jl 56.66% <ø> (+6.66%) :arrow_up:
src/utils/utils.jl 66.80% <62.50%> (+5.20%) :arrow_up:
src/system_data.jl 86.26% <75.00%> (-0.06%) :arrow_down:
src/components.jl 90.07% <90.90%> (-0.01%) :arrow_down:
src/hdf5_time_series_storage.jl 93.52% <100.00%> (ø)
src/internal.jl 77.55% <100.00%> (+3.08%) :arrow_up:
src/utils/lazy_dict_from_iterator.jl 96.15% <0.00%> (-0.15%) :arrow_down:
src/serialization.jl 52.47% <0.00%> (+1.98%) :arrow_up:
... and 2 more