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

Sphere class added as primitive geometry #31

Closed
wants to merge 1 commit into from
Closed

Conversation

chadqueen
Copy link
Contributor

Stores key configuration via constructor:

origin : Point3D
    Centered origin of the ``Sphere``.
radius: float
    Radius of ``Sphere``.

Stores key configuration via constructor:

    origin : Point3D
        Centered origin of the ``Sphere``.
    radius: float
        Radius of ``Sphere``.
@chadqueen chadqueen linked an issue Aug 31, 2022 that may be closed by this pull request
@github-actions github-actions bot added the enhancement New features or code improvements label Aug 31, 2022

def __ne__(self, other) -> bool:
"""Not equals operator for ``Sphere``."""
return not self.__eq__(other)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick:

There's really no reason to use dunder methods (even internally). IMO, the only reason to ever directly call out a dunder method when calling the base method super().__eq__.

Suggested change
return not self.__eq__(other)
return not self == other

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be across all open PRs, can address them all based upon to be consistent.

def __eq__(self, other: object) -> bool:
"""Equals operator for ``Sphere``."""
if not isinstance(other, Sphere):
raise ValueError(f"Comparison of {self} against {other} is not possible.")
Copy link
Contributor

Choose a reason for hiding this comment

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

These should be type errors.

Suggested change
raise ValueError(f"Comparison of {self} against {other} is not possible.")
raise TypeError(f"Comparison against {type(other)} is not possible. Should be of type {type(self)}")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be across all open PRs, can address them all based upon to be consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or put this in your base class.

self._radius = radius

@property
def origin(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

origin and radius need setters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How common do we implement classes with immutability in python/pyansys? I was hoping to discuss the possibility of making all geometry primitives immutable.

Comment on lines +20 to +21
self._origin = origin
self._radius = radius
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs type checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be across all open PRs, can address them all based upon to be consistent.


@property
def radius(self):
"""Return the radius of the ``Sphere``."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Return the radius of the ``Sphere``."""
"""Radius of the ``Sphere``."""

@RobPasMue RobPasMue marked this pull request as draft September 3, 2022 07:32
@chadqueen
Copy link
Contributor Author

Replaced by #57

@chadqueen chadqueen closed this Sep 5, 2022
@RobPasMue RobPasMue deleted the feat/sphere branch September 6, 2022 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features or code improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add sphere 3D geometry primitive
3 participants