-
Notifications
You must be signed in to change notification settings - Fork 108
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
Make the tolerance class a singleton #1348
Conversation
|
||
self._is_inited = True | ||
|
||
if unit is not None: |
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.
not important.... but i guess unit will never be None because it has a default "M", no?
src/compas/tolerance.py
Outdated
@@ -108,8 +114,9 @@ class Tolerance(Data): | |||
""" | |||
|
|||
def __new__(cls, *args, **kwargs): | |||
if not hasattr(cls, "_instance"): | |||
cls._instance = super(Tolerance, cls).__new__(cls) | |||
if not isinstance(cls._instance, cls): |
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.
mmm... not sure I understand here, under what scenario is this condition triggered? Is it equivalent for if cls._instance is None
, or it has some wider purposes?
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.
is it intended for inherited classes?
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.
I mean the only possible types for _instance
are Tolerance
and NoneType
, no?
btw would it be relevant to mention angular unit ? |
@Licini there are indeed more things that have to be added to the tolerance object but perhaps we can already merge the switch to the singleton? |
What type of change is this?
Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.CHANGELOG.md
file in theUnreleased
section under the most fitting heading (e.g.Added
,Changed
,Removed
).invoke test
).invoke lint
).compas.datastructures.Mesh
.