Skip to content

Conversation

pluAtAnsys
Copy link
Collaborator

@pluAtAnsys pluAtAnsys commented Aug 5, 2025

Description

  • radiant flux
  • luminous flux
  • luminous_intensity
    need some testing and proper definition

Add properties to SourceLuminaire:

  • radiant flux
  • luminous flux
  • intensity file
  • axissystem

add properties to SourceRayfile:

  • rayfile_url
  • radiant flux
  • luminous flux
  • axissystem

add properties to SourceSurface

  • add properties to exitance class
    • XMP file URL
    • axissystem
  • radiant flux
  • luminous flux
  • luminous_intensity
  • Constant exitance class + Geometry property

Issue linked

Refactor source #684

Checklist

  • I have tested my changes locally.
  • I have added necessary documentation or updated existing documentation.
  • I have followed the coding style guidelines of this project.
  • I have added appropriate tests (unit, integration, system).
  • I have reviewed my changes before submitting this pull request.
  • I have linked the issue or issues that are solved by the PR if any.
  • I have assigned this PR to myself.
  • I have made sure that the title of my PR follows Conventional commits style (e.g. feat: add optical property)
  • I have agreed with the Contributor License Agreement (CLA).

@pluAtAnsys pluAtAnsys linked an issue Aug 5, 2025 that may be closed by this pull request
@pluAtAnsys pluAtAnsys self-assigned this Aug 5, 2025
@pluAtAnsys pluAtAnsys removed a link to an issue Aug 5, 2025
This was linked to issues Aug 5, 2025
@pluAtAnsys pluAtAnsys changed the title wip: refactor source class feat: refactor source class Aug 6, 2025
@pluAtAnsys pluAtAnsys removed a link to an issue Aug 6, 2025
Copy link

codecov bot commented Aug 6, 2025

Codecov Report

❌ Patch coverage is 90.94923% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.70%. Comparing base (64087ca) to head (823781c).

Files with missing lines Patch % Lines
src/ansys/speos/core/source.py 86.63% 29 Missing ⚠️
src/ansys/speos/core/spectrum.py 91.78% 6 Missing ⚠️
src/ansys/speos/core/generic/constants.py 95.29% 4 Missing ⚠️
src/ansys/speos/core/sensor.py 97.43% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

StefanThoene
StefanThoene previously approved these changes Sep 4, 2025
Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Collaborator Author

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.

Copy link
Collaborator

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],
Copy link
Collaborator

Choose a reason for hiding this comment

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

bool or None?

Copy link
Collaborator Author

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,
Copy link
Collaborator

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:
Copy link
Collaborator

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],
Copy link
Collaborator

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

Comment on lines +877 to +897
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
Copy link
Collaborator

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

Copy link
Contributor

@SMoraisAnsys SMoraisAnsys left a 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, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor source Refactor SPectrum
5 participants