-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feature/update float3d example #450
Conversation
Reviewer's Guide by SourceryThis PR refactors the 3D volume example by consolidating the Updated class diagram for VolumeSweepclassDiagram
class VolumeSweep {
FloatSweep x
FloatSweep y
FloatSweep z
ResultVar value
ResultVar occupancy
ResultVar interesting
list interesting_vec
list interesting_vec_and_occ
+__call__(**kwargs) dict
+update_params_from_kwargs(**kwargs)
}
note for VolumeSweep "Consolidated from VolumeSample and VolumeResult"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @blooop - I've reviewed your changes - here's some feedback:
Overall Comments:
- The docstring in
__call__
still refers to the old function signature withpoint
parameter - it should be updated to reflect the new kwargs-based interface
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
import bencher as bch | ||
|
||
|
||
class VolumeSample(bch.ParametrizedSweep): | ||
class VolumeSweep(bch.ParametrizedSweep): |
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.
issue (complexity): Consider separating input parameters and results into distinct classes to improve code organization
The merged VolumeSweep class combines input parameters with results, making the code harder to maintain. Here's how to achieve the same fluent API while maintaining better separation of concerns:
class VolumeSample(bch.ParametrizedSweep):
x = bch.FloatSweep(default=0, bounds=[-1.0, 1.0], doc="x coordinate", samples=4)
y = bch.FloatSweep(default=0, bounds=[-1.0, 1.0], doc="y coordinate", samples=5)
z = bch.FloatSweep(default=0, bounds=[-1.0, 1.0], doc="z coordinate", samples=6)
def compute(self, **kwargs) -> 'VolumeResult':
self.update_params_from_kwargs(**kwargs)
result = VolumeResult()
result.value = np.linalg.norm(np.array([self.x, self.y, self.z]))
# ... set other result fields ...
return result
def to_bench(self, **kwargs) -> bch.Bench:
return bch.Bench(
compute_fn=self.compute,
param_cls=self.__class__,
**kwargs
)
class VolumeResult(bch.ParametrizedSweep):
value = bch.ResultVar("ul", doc="The scalar value of the 3D volume field")
# ... other result fields ...
This approach:
- Maintains clear separation between inputs and outputs
- Preserves type safety in plot_sweep() calls
- Keeps the fluent API benefits
- Makes the data flow more explicit
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #450 +/- ##
==========================================
- Coverage 90.48% 90.48% -0.01%
==========================================
Files 61 61
Lines 3384 3383 -1
==========================================
- Hits 3062 3061 -1
Misses 322 322 ☔ View full report in Codecov by Sentry. |
Summary by Sourcery
Enhancements: