Skip to content

Conversation

@waltsims
Copy link
Owner

This pull request introduces enhancements to the kWaveGrid class, including new factory methods and utility properties. It also refactors grid initialization and usage in the at_circular_piston_3D and at_focused_bowl_3D examples, improving code readability and reusability by leveraging new factory methods in the kWaveGrid class. It also

Enhancements to kWaveGrid Class:

  • New Factory Methods:

    • Added from_geometry and from_domain class methods to simplify the creation of kWaveGrid instances based on physical domain dimensions, acoustic properties, and resolution requirements. These methods encapsulate grid spacing and size calculations.
  • Utility Properties:

    • Introduced x_max, y_max, and z_max properties to provide easy access to the maximum extents of the grid in each dimension.

Refactoring in Example Scripts:

  • Simplified Grid Initialization:

    • Replaced manual grid size and spacing calculations with the new kWaveGrid.from_domain factory method in at_circular_piston_3D.py and at_focused_bowl_3D.py. This reduces redundant code and ensures consistency in grid creation. [1] [2]
  • Improved Input Handling:

    • Enhanced the __init__ method to handle single-element spacing inputs more gracefully by broadcasting them to match the grid dimensionality.

- Implemented `from_geometry` method to create a kWaveGrid based on domain size and minimum element width.
- Implemented `from_domain` method to create a kWaveGrid using physical dimensions and acoustic properties.
- Added input validation for parameters in both methods to ensure positive values.
- Updated the grid creation process to utilize the new `from_domain` method for better clarity and efficiency.
- Adjusted sensor mask and data reshaping to align with the new grid structure.
- Ensured consistent usage of grid properties throughout the example for improved readability and maintainability.
- Updated the grid creation to use the new `from_domain` method for improved clarity and efficiency.
- Adjusted sensor mask and data reshaping to utilize properties from the kWaveGrid instance.
- Enhanced consistency in grid property usage throughout the example for better readability and maintainability.
@waltsims waltsims marked this pull request as draft April 28, 2025 00:48
@codecov
Copy link

codecov bot commented Apr 28, 2025

Codecov Report

Attention: Patch coverage is 29.26829% with 29 lines in your changes missing coverage. Please review.

Project coverage is 73.35%. Comparing base (b24bfa1) to head (dbbde27).

Files with missing lines Patch % Lines
kwave/kgrid.py 29.26% 29 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #597      +/-   ##
==========================================
- Coverage   73.61%   73.35%   -0.27%     
==========================================
  Files          50       50              
  Lines        6929     6970      +41     
  Branches     1315     1323       +8     
==========================================
+ Hits         5101     5113      +12     
- Misses       1283     1312      +29     
  Partials      545      545              
Flag Coverage Δ
3.10 73.35% <29.26%> (-0.27%) ⬇️
3.11 73.35% <29.26%> (-0.27%) ⬇️
3.12 73.35% <29.26%> (-0.27%) ⬇️
3.13 73.35% <29.26%> (-0.27%) ⬇️
macos-latest 73.32% <29.26%> (-0.27%) ⬇️
ubuntu-latest 73.32% <29.26%> (-0.27%) ⬇️
windows-latest 73.34% <29.26%> (-0.27%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@waltsims waltsims requested a review from Copilot April 28, 2025 00:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request enhances the kWaveGrid class by adding two new factory methods and utility properties, and refactoring example scripts to simplify grid creation and improve code consistency.

  • Introduces factory methods: from_geometry and from_domain in kWaveGrid
  • Adds utility properties: x_max, y_max, and z_max
  • Refactors grid initialization in at_circular_piston_3D.py and at_focused_bowl_3D.py to use the new factory methods

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
kwave/kgrid.py Adds new factory methods and utility properties; broadcasts spacing if single-element
examples/at_focused_bowl_3D/at_focused_bowl_3D.py Replaces manual grid creation with kWaveGrid.from_domain and updates sensor mask and data reshaping
examples/at_circular_piston_3D/at_circular_piston_3D.py Refactors grid initialization to use kWaveGrid.from_domain and updates grid-based indices

waltsims and others added 2 commits April 27, 2025 17:55
Co-authored-by: Copilot <[email protected]>
- Removed redundant properties for x_max, y_max, and z_max from kWaveGrid to streamline the class.
- Updated the at_focused_bowl_3D example to define position vectors more clearly, improving readability and maintainability.
- Introduced a new x_ref calculation for better accuracy in grid representation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants