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
36 stars 20 forks source link

Use `Base.@kwdef` for `struct LoggingConfiguration` #307

Closed kdheepak closed 1 year ago

kdheepak commented 1 year ago

I was looking at how InfrastructureSystems handles logging, and thought I'd share a small change as a PR.

Julia has a Base.@kwdef that simplifies the keyword only constructors for some structs. I've added an example in this PR for LoggingConfiguration. Julia 1.9 exports @kwdef so you can even drop the Base. if you want to be compat with "julia" >= v"1.9".

codecov[bot] commented 1 year ago

Codecov Report

Merging #307 (aa8f79c) into master (267ea0b) will increase coverage by 0.22%. The diff coverage is 100.00%.

Additional details and impacted files [![Impacted file tree graph](https://codecov.io/gh/NREL-SIIP/InfrastructureSystems.jl/pull/307/graphs/tree.svg?width=650&height=150&src=pr&token=I73yjxYxgn&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-SIIP)](https://codecov.io/gh/NREL-SIIP/InfrastructureSystems.jl/pull/307?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-SIIP) ```diff @@ Coverage Diff @@ ## master #307 +/- ## ========================================== + Coverage 78.03% 78.26% +0.22% ========================================== Files 44 44 Lines 3720 3704 -16 ========================================== - Hits 2903 2899 -4 + Misses 817 805 -12 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `78.26% <100.00%> (+0.22%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-SIIP#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://codecov.io/gh/NREL-SIIP/InfrastructureSystems.jl/pull/307?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-SIIP) | Coverage Δ | | |---|---|---| | [src/utils/logging.jl](https://codecov.io/gh/NREL-SIIP/InfrastructureSystems.jl/pull/307?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-SIIP#diff-c3JjL3V0aWxzL2xvZ2dpbmcuamw=) | `91.45% <100.00%> (-0.09%)` | :arrow_down: | | [src/InfrastructureSystems.jl](https://codecov.io/gh/NREL-SIIP/InfrastructureSystems.jl/pull/307?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-SIIP#diff-c3JjL0luZnJhc3RydWN0dXJlU3lzdGVtcy5qbA==) | `77.77% <0.00%> (-2.23%)` | :arrow_down: | | [src/utils/utils.jl](https://codecov.io/gh/NREL-SIIP/InfrastructureSystems.jl/pull/307?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-SIIP#diff-c3JjL3V0aWxzL3V0aWxzLmps) | `62.25% <0.00%> (-0.39%)` | :arrow_down: | | [src/hdf5\_time\_series\_storage.jl](https://codecov.io/gh/NREL-SIIP/InfrastructureSystems.jl/pull/307?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NREL-SIIP#diff-c3JjL2hkZjVfdGltZV9zZXJpZXNfc3RvcmFnZS5qbA==) | `94.04% <0.00%> (+2.93%)` | :arrow_up: |