-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Base.@kwdef
to all system-related structs
#19
Conversation
Codecov Report
@@ Coverage Diff @@
## main #19 +/- ##
==========================================
+ Coverage 79.59% 80.00% +0.40%
==========================================
Files 2 2
Lines 98 105 +7
==========================================
+ Hits 78 84 +6
- Misses 20 21 +1
|
Closes #7 Needs tests :) |
My plan was to create fake structs using the kwargs and test that they're equal to the ones not using kwargs, but that would require AutoHashEquals... is there another simple way of testing this? |
we just need to test these methods exist perhaps just |
The result was a bit ugly (circa 100 lines of code), but I covered all structs |
Hmm, I think I'll need to do it a bit differently for |
break_points, | ||
penalties, | ||
resistance, | ||
reactance, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should resistance
and reactance
have defaults too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, can't see any specific reason to have default values for these
src/system.jl
Outdated
penalties, | ||
resistance, | ||
reactance, | ||
is_transformer=false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the behaviour of the current constructors is that is_transformer
is true if tap
and angle
are non-missing
perhaps that's the behaviour we should match here too?
perhaps remove is_transformer
as a keyword and have something like
if ismissing(tap) && ismissing(angle)
is_transformer = false
elseif !ismissing(tap) && !ismissing(angle)
is_transformer = true
else
ArgumentError("Transformers must have non-missing values for both `tap` and `angle`. Got `tap=$tap, angle=$angle`.")
?
Alternatively perhaps the constructors here are overly complex and we should check which are used in practice to see if we need them all ?
I suppose an alternative is to update the existing tests to use the new syntax e.g. - zone1 = Zone(1, 1.0, 1.0, 1.0)
+ zone1 = Zone(number=1, regulation=1.0, etc1=1.0, etc2=1.0) |
Does this look good to you now @nickrobinson251? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think of update the existing tests to use the new syntax rather than adding a bunch of more tests?
I also wonder if we should open an issue about reviewing which Brnach constructors are necessary - what do you think?
Otherwise LGTM
I was thinking that the current way covers both cases – but in the end I think we get the same coverage if we update the existing ones? I can do that |
thanks - LGTM! |
Had a test failing due to resistance, reactance having default values, which I'm not sure should be the case. I'll leave this unchanged in this PR; opened #21 to track it |
This makes it easier to keep track of arguments when using these structs, as some of them have many arguments.