-
Notifications
You must be signed in to change notification settings - Fork 5
feat: refactor source class #690
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #690 +/- ##
========================================
Coverage 88.69% 88.70%
========================================
Files 39 39
Lines 5653 5994 +341
========================================
+ Hits 5014 5317 +303
- Misses 639 677 +38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
get the data from the default parameters
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.
get test results from parameters classe
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.
Only rayfile, luminaire default parameters implemented. No parameters implemented for for sensor class.
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.
get default values from defaults class
def __init__( | ||
self, | ||
flux: source_pb2, | ||
default_values: Union[bool, SourceRayfileParameters, SourceLuminaireParameters], |
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.
bool or None?
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.
bool is needed.
case 1: DefaultParameters instance provided -> create based on values provided from parameter instance (it can be default instance or user-defined instance)
case 2: None or True -> use the default parameter instance from constants.py class.
case 3: False -> use the back-end property when loading an existing object
metadata: Optional[Mapping[str, str]] = None, | ||
source_instance: Optional[ProtoScene.SourceInstance] = None, | ||
default_values: bool = True, | ||
default_values: Optional[bool, SourceLuminaireParameters] = None, |
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.
seee above
# Default values | ||
self.set_flux_from_intensity_file().set_spectrum().set_incandescent() | ||
self.set_axis_system() | ||
if default_values is not 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.
is not None?
def __init__( | ||
self, | ||
rayfile_props: scene_pb2.RayFileProperties, | ||
default_values: Optional[bool, SourceRayfileParameters], |
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.
why not use None and source ray file what happens,
maybe rename: default parameters?
if None Default will be taken expept if source is created from file
valid for all inits
if default_values is not False: # True, SourceRayfileParameters as default | ||
if not isinstance(default_values, SourceRayfileParameters): # True as default | ||
default_values = SourceRayfileParameters() | ||
# Default values | ||
self.set_spectrum_from_ray_file() | ||
self.ray_file_uri = default_values.ray_file_uri | ||
match default_values.flux_type: | ||
case FluxType.LUMINOUS: | ||
self.set_flux().set_luminous() | ||
self.set_flux().value = default_values.flux_value | ||
case FluxType.RADIANT: | ||
self.set_flux().set_radiant() | ||
self.set_flux().value = default_values.flux_value | ||
case FluxType.FROM_FILE: | ||
self.set_flux_from_ray_file() | ||
case _: | ||
raise ValueError( | ||
f"Unsupported flux type: {type(default_values.flux_type).__name__}" | ||
) | ||
self.axis_system = default_values.axis_system | ||
self.set_exit_geometries().geometries = default_values.exit_geometry |
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.
Check for instances to just catch the relevant part and the if None but no instance create parameters
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.
Not sure about the current status of the PR but do you want to proceed with classes containing a single attribute (I would encourage to avoid that if possible) ? See classes SOURCE, LUMINOUS, ...
Description
need some testing and proper definition
Add properties to SourceLuminaire:
add properties to SourceRayfile:
add properties to SourceSurface
Issue linked
Refactor source #684
Checklist
feat: add optical property
)