Skip to content

Fix bounding box extent #1314

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

Merged
5 commits merged into from
Jul 1, 2022
Merged

Fix bounding box extent #1314

5 commits merged into from
Jul 1, 2022

Conversation

ghost
Copy link

@ghost ghost commented Jun 20, 2022

A comment and a question up front:

  • I welcome comments on the validate_enum_class_value design as I'm not sure if this is particularly pythonic or if there is a standard or better way to do it.
  • Should these setters raise a ValueError or other exception if the validation fails? This is not being done currently and the values not set are silently ignored.

The setters for some SimulationConfiguration properties, including cutout_subdesign_type, radiation_box, sweep_type, and basis_order would never set their property's value because they were checking that the arguments were of a type that would not be passed in. The arguments passed in are integers taken from attributes on the class. I call these "enumeration style" classes.

To fix this, add a new method validate_enum_class_value that takes an enumeration style class "cls" that has valid values from zero to N where the value N is assigned to the class attribute called Invalid and an integer value "value" to validate. The function returns true if "value" is between zero (inclusive) and cls.Invalid (exclusive). Note that the enumeration class must define this Invalid attribute and its value is not itself valid.

I added a test for setting the boundary box extent type which is the case that was reported to me as not working.

Fixes #1313

The configure_hfss_extents method will never set its radiation_box
property because the setter checks that its argument is of type
RadiationBoxType which is just an enumeration-style class for several
constant integer values.  The setter should instead check that the
argument is an integer (and perhaps one of the allowable values).
Introduce a new method to validate "enum class" values from classes like
pyaedt.generic.constants.RadiationBoxType and use it in the setter of
SimulationConfiguration.radiation_box to fix #1313.
@ghost ghost requested review from svandenb-dev and maxcapodi78 June 20, 2022 18:56
@github-actions github-actions bot added the bug Something isn't working label Jun 20, 2022
@codecov
Copy link

codecov bot commented Jun 20, 2022

Codecov Report

Merging #1314 (d071594) into main (30a7b15) will increase coverage by 1.33%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1314      +/-   ##
==========================================
+ Coverage   77.87%   79.20%   +1.33%     
==========================================
  Files          97       97              
  Lines       39443    39824     +381     
==========================================
+ Hits        30716    31543     +827     
+ Misses       8727     8281     -446     

Copy link
Collaborator

@maxcapodi78 maxcapodi78 left a comment

Choose a reason for hiding this comment

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

@isaacansys I like this approach. Since the number of enum in edb is quite high I would probably create a separate module in edb_core folder and have a method also to retrieve the enum value given an int and an edb class. that would be replaced in all the methods that requires it as input

@ghost
Copy link
Author

ghost commented Jun 22, 2022

Thanks all for suggestions, have a busy calendar today but will get these incorporated by tomorrow and ready to merge.

@maxcapodi78
Copy link
Collaborator

@isaacansys if you finalize all agreed changes we can close this PR

Co-authored-by: Kathy Pippert <[email protected]>
Co-authored-by: Maxime Rey <[email protected]>
Replace existing usage of BasisOrder.single with BasisOrder.Single per
the earlier correction to that value's identifier.
@ghost ghost merged commit c570c3d into main Jul 1, 2022
@ghost ghost deleted the fix-bounding-box-extent branch July 1, 2022 18:17
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot set radiation_box and other properties on SimulationConfiguration
4 participants