Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 8, 2025

  • Understand the issue: Sphere.scaled() and Cylinder.scaled() fail because they call scale(x=x, y=y, z=z) but the overridden scale() methods only accept a single factor parameter
  • Reproduce the issue with both Sphere and Cylinder
  • Analyze how Box solves this problem (it overrides both scale() and scaled())
  • Add scaled() override to Sphere class that calls its scale(factor) method with uniform scaling
  • Add scaled() override to Cylinder class that calls its scale(factor) method with uniform scaling
  • Discover and fix the same issue in Capsule class
  • Create tests to validate the fix for all three shapes
  • Run tests to ensure no regressions
  • Run broader test suite to ensure no side effects - all 12 scale-related tests pass
  • Add CHANGELOG.md entry documenting the fix

Summary

Fixed the broken scaled() behavior in Sphere, Cylinder, and Capsule classes by overriding the scaled() method to accept only a single factor parameter (uniform scaling). This matches the signature of their scale() methods and follows the same pattern used in the Box class.

The fix resolves the TypeError: scale() got an unexpected keyword argument 'x' error that occurred when calling scaled() on these shapes.

Added CHANGELOG.md entry under "Unreleased > Changed" section.

Original prompt

This section details on the original issue you should resolve

<issue_title>Broken behaviour with Sphere.scaled()</issue_title>
<issue_description>Sphere.scaled() calls the scale() function with keyword arguments for x,y and z. However, the inbuilt Sphere.scale() method requires only a factor for uniform scaling of the self.radius. This makes it not possible to use the scaled() method at all. I suspect similar behaviour in the Cylinder class due to similar implementation of scale.

To replicate, create any sphere and apply scaling:
c = Sphere(10)
scaled_c = c.scaled(0.5,10,10)

  File "C:\Users\akango\Documents\github\compas_introduction_2025\.venv\lib\site-packages\compas\geometry\geometry.py", line 173, in scaled
    geometry.scale(x=x, y=y, z=z)
TypeError: scale() got an unexpected keyword argument 'x'

Is there a reason why most Shape objects have their own transformation methods which are different from the methods it could inherit from Geometry?

</issue_description>

<agent_instructions>Please provide a fix to this, the problem seems to be that scaled will internally call scale, and Sphere overrides scale() with different params, so, scaled should probably also be overriden with a Sphere-specific method</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #1488

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: gonzalocasas <933277+gonzalocasas@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Fix broken behaviour with Sphere.scaled() method Fix broken behavior with Sphere.scaled(), Cylinder.scaled(), and Capsule.scaled() Oct 8, 2025
Copilot finished work on behalf of gonzalocasas October 8, 2025 23:35
@Copilot Copilot AI requested a review from gonzalocasas October 8, 2025 23:35
Copy link

codecov bot commented Oct 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.02%. Comparing base (b8cef0d) to head (bd0252b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1489      +/-   ##
==========================================
+ Coverage   62.00%   62.02%   +0.02%     
==========================================
  Files         208      208              
  Lines       22427    22439      +12     
==========================================
+ Hits        13905    13917      +12     
  Misses       8522     8522              

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

Copy link
Member

@gonzalocasas gonzalocasas left a comment

Choose a reason for hiding this comment

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

Looking good! But @copilot : please add a CHANGELOG.md entry

@gonzalocasas
Copy link
Member

@copilot please address the review finding above

Co-authored-by: gonzalocasas <933277+gonzalocasas@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 9, 2025

@copilot please address the review finding above

Added CHANGELOG.md entry in commit eb9d62e.

@Copilot Copilot AI requested a review from gonzalocasas October 9, 2025 00:10
Copilot finished work on behalf of gonzalocasas October 9, 2025 00:11
@gonzalocasas gonzalocasas marked this pull request as ready for review October 9, 2025 06:01
Copy link
Member

@gonzalocasas gonzalocasas left a comment

Choose a reason for hiding this comment

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

Lgtm

@gonzalocasas
Copy link
Member

@tomvanmele does this look good to you as a fix?

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.

Broken behaviour with Sphere.scaled()

2 participants