Skip to content
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

Positions with incorrect type should raise a TypeError #796

Closed
victorpoughon opened this issue Nov 21, 2024 · 2 comments
Closed

Positions with incorrect type should raise a TypeError #796

victorpoughon opened this issue Nov 21, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@victorpoughon
Copy link

As of 0.7.0 this code runs without error, and the sketch is not moved but stays at 0, 0:

from build123d import *

sketch = Pos(0, "blip") * Circle(5)
sketch

We should add some type checking to raise a TypeError here. This can happens quite easily if the coordinate comes from another data type like numpy or such. It can pretty easily be wrapped into a np.array or something, then it's really confusing why no transform is applied.

gumyr added a commit that referenced this issue Jan 14, 2025
@gumyr gumyr added the enhancement New feature or request label Jan 14, 2025
@gumyr gumyr added this to the Gating Release 1.0.0 milestone Jan 14, 2025
@gumyr
Copy link
Owner

gumyr commented Jan 14, 2025

The tests cover the following now:

        with self.assertRaises(TypeError):
            Pos(0, "foo")
        self.assertEqual(Pos(1, 2, 3).position, Vector(1, 2, 3))
        self.assertEqual(Pos((1, 2, 3)).position, Vector(1, 2, 3))
        self.assertEqual(Pos(v=(1, 2, 3)).position, Vector(1, 2, 3))
        self.assertEqual(Pos(X=1, Y=2, Z=3).position, Vector(1, 2, 3))
        self.assertEqual(Pos(Vector(1, 2, 3)).position, Vector(1, 2, 3))
        self.assertEqual(Pos(1, Y=2, Z=3).position, Vector(1, 2, 3))

@gumyr
Copy link
Owner

gumyr commented Jan 14, 2025

The interfaces on the base classes have been improved somewhat but there is no guarantee of generalized type checking. If there are examples like this please raise another issue.

@gumyr gumyr closed this as completed Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants