Skip to content

Commit

Permalink
improve facade pattern implementation (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoffrin authored Dec 20, 2022
1 parent 448df71 commit 83e3900
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
PowerWaterModels.jl Change Log
=======================
==============================

### staged
- nothing

### v0.3.1
- Improve facade pattern implementation

### v0.3.0
- Update documentation.
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "PowerWaterModels"
uuid = "7f4f7f52-2f44-4c87-b9ed-462dc784f1b2"
authors = ["Byron Tasseff", "Russell Bent", "Carleton Coffrin"]
repo = "https://github.com/lanl-ansi/PowerWaterModels.jl"
version = "0.3.0"
version = "0.3.1"

[deps]
InfrastructureModels = "2030c09a-7f63-5d83-885d-db604e0e9cc0"
Expand Down
14 changes: 4 additions & 10 deletions src/core/helpers.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
function _get_powermodel_from_powerwatermodel(pwm::AbstractPowerWaterModel)
# Determine the PowerModelsDistribution modeling type.
pmd_type = typeof(pwm).parameters[1]

function _get_powermodel_from_powerwatermodel(pwm::AbstractPowerWaterModel{PMDT,WMT}) where {PMDT,WMT}
# Power-only variables and constraints.
return pmd_type(pwm.model, pwm.data, pwm.setting, pwm.solution,
return PMDT(pwm.model, pwm.data, pwm.setting, pwm.solution,
pwm.ref, pwm.var, pwm.con, pwm.sol, pwm.sol_proc, pwm.ext)
end


function _get_watermodel_from_powerwatermodel(pwm::AbstractPowerWaterModel)
# Determine the WaterModels modeling type.
wm_type = typeof(pwm).parameters[2]

function _get_watermodel_from_powerwatermodel(pwm::AbstractPowerWaterModel{PMDT,WMT}) where {PMDT,WMT}
# Water-only variables and constraints.
return wm_type(pwm.model, pwm.data, pwm.setting, pwm.solution,
return WMT(pwm.model, pwm.data, pwm.setting, pwm.solution,
pwm.ref, pwm.var, pwm.con, pwm.sol, pwm.sol_proc, pwm.ext)
end
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ const Memento = _IM.Memento

# Suppress warnings during testing.
Memento.setlevel!(Memento.getlogger(_IM), "error")
Memento.setlevel!(Memento.getlogger(_PMD), "error")
Memento.setlevel!(Memento.getlogger(_PM), "error")
Memento.setlevel!(Memento.getlogger(_WM), "error")
PowerWaterModels.logger_config!("error")
_PMD.silence!()

import HiGHS
import Ipopt
Expand Down

2 comments on commit 83e3900

@ccoffrin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v0.3.1 @JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/74384

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" 83e3900eff578fc5ffce0fb96330c3e97dc1f2f4
git push origin v0.3.1

Please sign in to comment.