Improve Clarity and Modernization of _Observing Events_ Example Code
- Dominant language
- Python
- Stars
- 497
- Forks
- 77
- Avg merge
- 22h 37m
- Merged PRs (30d)
- 45
Description
This issue pertains to the [_Observing Events_](https://fluent.docs.pyansys.com/version/stable/user_guide/events.html) example in the PyFluent documentation.
#### **Current Example Code:**
```python
@execute_in_event_loop_threadsafe
def initialize_call_back(session, event_info: SolutionInitializedEventInfo | DataLoadedEventInfo):
pyvista_windows_manager.refresh_windows(session.id, ["contour-1", "contour-2"])
matplot_windows_manager.refresh_windows("", ["residual"])
callback_init_id = solver.events.register_callback(SolverEvent.SOLUTION_INITIALIZED, initialize_call_back)
```
#### **Proposed Improvements:**
1. **Avoid referencing old-style visualization interactions.**
- The example currently references `pyvista_windows_manager` and `matplot_windows_manager`, which may not align with the modern API direction. If visualization is necessary in the example, consider a more generic, high-level approach.
2. **Rename `initialize_call_back()` for clarity.**
- The function name should describe its purpose. A more intuitive name, such as `refresh_windows()`, would improve readability.
3. **Use `callback=` explicitly in `register_callback()`.**
- Instead of `solver.events.register_callback(SolverEvent.SOLUTION_INITIALIZED, initialize_call_back)`, write:
```python
solver.events.register_callback(SolverEvent.SOLUTION_INITIALIZED, callback=refresh_windows)
```
- This makes it clearer that the second argument is the callback function.
4. **Remove `callback_init_id` if unused.**
- Since `callback_init_id` is not used after assignment, it should be omitted to avoid confusion.
Contributor guide
Research direction
Open the linked Observing Events documentation page and locate the shown callback example. Review the current visualization references, callback name, register_callback call, and unused callback_init_id against the requested improvements. Done means the example uses a modern or generic visualization approach, a clearer callback name, an explicit callback= argument, and no unused assignment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100