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

feat: Configure angle as dimension #309

Merged
merged 41 commits into from
Nov 7, 2024

Conversation

hpohekar
Copy link
Collaborator

@hpohekar hpohekar commented Nov 5, 2024

closes #307,

  1. Configure ANGLE and SOLID_ANGLE as dimension using PYANSYS_UNITS_ANGLE_AS_DIMENSION env var

Dimensions without angle

>>> import ansys.units as pyunits
>>> degree = pyunits.Quantity(1.0, "degree")
>>> degree.is_dimensionless
True
>>> degree + 1
Quantity (58.29577951308232, "degree")
>>>

image

image

------------------------------------------------------------------------------

>>> radian = pyunits.Quantity(1.0, "radian")
>>> radian.is_dimensionless
True
>>> (radian + 1).to("degree")
Quantity (114.59155902616465, "degree")
>>>

image

image

Dimension with angle - set env var PYANSYS_UNITS_ANGLE_AS_DIMENSION

>>> import os
>>> os.environ["PYANSYS_UNITS_ANGLE_AS_DIMENSION"] = "1"
>>> import ansys.units as pyunits
>>> degree = pyunits.Quantity(1.0, "degree")
>>> degree.is_dimensionless
False
>>> degree + 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Repos\pyansys-units\src\ansys\units\quantity.py", line 378, in __add__
    return self._relative_unit_check(__value)
  File "D:\Repos\pyansys-units\src\ansys\units\quantity.py", line 280, in _relative_unit_check
    new_units, other_units = op(self.units, __value.units) or (
  File "D:\Repos\pyansys-units\src\ansys\units\unit.py", line 289, in __add__
    return self._temp_precheck(__value)
  File "D:\Repos\pyansys-units\src\ansys\units\unit.py", line 231, in _temp_precheck
    raise IncorrectUnits(self, other_unit)
ansys.units.unit.IncorrectUnits: 'radian' and '' must match for this operation.
>>>
>>> radian = pyunits.Quantity(1.0, "radian")
>>> radian.is_dimensionless
False
>>> radian + 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Repos\pyansys-units\src\ansys\units\quantity.py", line 378, in __add__
    return self._relative_unit_check(__value)
  File "D:\Repos\pyansys-units\src\ansys\units\quantity.py", line 280, in _relative_unit_check
    new_units, other_units = op(self.units, __value.units) or (
  File "D:\Repos\pyansys-units\src\ansys\units\unit.py", line 289, in __add__
    return self._temp_precheck(__value)
  File "D:\Repos\pyansys-units\src\ansys\units\unit.py", line 231, in _temp_precheck
    raise IncorrectUnits(self, other_unit)
ansys.units.unit.IncorrectUnits: 'radian' and '' must match for this operation.
>>>

@hpohekar hpohekar linked an issue Nov 5, 2024 that may be closed by this pull request
@github-actions github-actions bot added the enhancement New features or code improvements label Nov 5, 2024
@github-actions github-actions bot added the testing Anything related to tests label Nov 5, 2024
@github-actions github-actions bot added documentation Improvements or additions to documentation maintenance Package and maintenance related labels Nov 5, 2024
@hpohekar hpohekar linked an issue Nov 5, 2024 that may be closed by this pull request
@hpohekar hpohekar linked an issue Nov 5, 2024 that may be closed by this pull request
@hpohekar hpohekar changed the title feat: Remove angle as dimension feat: Configure angle as dimension Nov 5, 2024
@hpohekar hpohekar marked this pull request as ready for review November 5, 2024 09:14
@hpohekar hpohekar requested a review from a team as a code owner November 5, 2024 09:14
Copy link
Collaborator

@seanpearsonuk seanpearsonuk left a comment

Choose a reason for hiding this comment

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

I think this needs to be discussed and completely reworked.

@seanpearsonuk
Copy link
Collaborator

@hpohekar Please could you create a separate pull request for the other changes?

@hpohekar
Copy link
Collaborator Author

hpohekar commented Nov 6, 2024

@hpohekar Please could you create a separate pull request for the other changes?

@seanpearsonuk Done. #313

Copy link
Collaborator

@seanpearsonuk seanpearsonuk left a comment

Choose a reason for hiding this comment

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

The tests look good so I will approve at this point, thanks.

@hpohekar
Copy link
Collaborator Author

hpohekar commented Nov 7, 2024

The tests look good so I will approve at this point, thanks.

We are going to add some more tests, then we will merge this PR. Thank you.

@hpohekar hpohekar merged commit d9c4ef2 into main Nov 7, 2024
28 of 29 checks passed
@hpohekar hpohekar deleted the feat/configure_angles_as_dimensions branch November 7, 2024 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New features or code improvements maintenance Package and maintenance related testing Anything related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure angle as dimension
3 participants