Skip to content

Commit

Permalink
MRG: Merge pull request #11 from AndreaBlengino/dev
Browse files Browse the repository at this point in the history
v0.7.1
  • Loading branch information
AndreaBlengino authored Apr 10, 2024
2 parents e9c5697 + 4fa8e29 commit 3956a89
Show file tree
Hide file tree
Showing 28 changed files with 378 additions and 252 deletions.
35 changes: 31 additions & 4 deletions .github/workflows/linux_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,46 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies

- name: Install building tools
run: |
pip install build twine
- name: Build package
run: |
pip install -r requirements/common.txt
pip install -r requirements/tests.txt
python -m build
- name: Install build package
run: |
pip install .[test]
- name: Package differences computation
run: |
if [[ $(diff -r ./gearpy ./build/lib/gearpy | grep -v __pycache__ | wc -m) == 0 ]]; then
echo "packages_are_equal=true" >> $GITHUB_ENV
else
echo "packages_are_equal=false" >> $GITHUB_ENV
fi
- name: Condition check
if: env.packages_are_equal == 'false'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Compiled package different from source package.')
- name: Fetch
uses: actions/checkout@master
- name: Test

- name: Run tests
run: |
python -m pytest --verbose --disable-pytest-warnings --cov=gearpy --cov-report=xml:linux_coverage.xml -nauto
- name: Upload
uses: codecov/codecov-action@v2
with:
Expand Down
35 changes: 31 additions & 4 deletions .github/workflows/macos_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,46 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies

- name: Install building tools
run: |
pip install build twine
- name: Build package
run: |
pip install -r requirements/common.txt
pip install -r requirements/tests.txt
python -m build
- name: Install build package
run: |
pip install .[test]
- name: Package differences computation
run: |
if [[ $(diff -r ./gearpy ./build/lib/gearpy | grep -v __pycache__ | wc -m) == 0 ]]; then
echo "packages_are_equal=true" >> $GITHUB_ENV
else
echo "packages_are_equal=false" >> $GITHUB_ENV
fi
- name: Condition check
if: env.packages_are_equal == 'false'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Compiled package different from source package.')
- name: Fetch
uses: actions/checkout@master
- name: Test

- name: Run tests
run: |
python -m pytest --verbose --disable-pytest-warnings --cov=gearpy --cov-report=xml:macos_coverage.xml -nauto
- name: Upload
uses: codecov/codecov-action@v2
with:
Expand Down
57 changes: 31 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
name: Release

on:
release:
types: [created]

jobs:
release-job:
runs-on: ubuntu-latest
env:
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install release tooling
run: |
pip install -r requirements/dev.txt
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Publish to PyPI
run: |
twine check dist/*
twine upload --repository pypi --username __token__ --password ${PYPI_TOKEN} dist/*
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install building tools
run: |
pip install build twine
- name: Build package
run: |
python -m build
- name: Publish to PyPI
run: |
twine check dist/*
twine upload --repository pypi --username __token__ --password ${PYPI_TOKEN} dist/*
test-install-job:
needs: release-job
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '>=3.9 <=3.12'
- name: Give PyPI a chance to update the index
run: sleep 150
- name: Install from PyPI
run: |
pip install gearpy
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '>=3.9 <=3.12'

- name: Give PyPI a chance to update the index
run: sleep 150

- name: Install from PyPI
run: |
pip install gearpy
35 changes: 31 additions & 4 deletions .github/workflows/windows_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,46 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies

- name: Install building tools
run: |
pip install build twine
- name: Build package
run: |
pip install -r requirements/common.txt
pip install -r requirements/tests.txt
python -m build
- name: Install build package
run: |
pip install .[test]
- name: Package differences computation
run: |
if [[ $(diff -r ./gearpy ./build/lib/gearpy | grep -v __pycache__ | wc -m) == 0 ]]; then
echo "packages_are_equal=true" >> $GITHUB_ENV
else
echo "packages_are_equal=false" >> $GITHUB_ENV
fi
- name: Condition check
if: env.packages_are_equal == 'false'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Compiled package different from source package.')
- name: Fetch
uses: actions/checkout@master
- name: Test

- name: Run tests
run: |
python -m pytest --verbose --disable-pytest-warnings --cov=gearpy --cov-report=xml:windows_coverage.xml -nauto
- name: Upload
uses: codecov/codecov-action@v2
with:
Expand Down
9 changes: 5 additions & 4 deletions gearpy/mechanical_objects/dc_motor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations
from gearpy.units import AngularPosition, AngularSpeed, AngularAcceleration, Current, InertiaMoment, Torque, UnitBase
from .mechanical_object_base import RotatingObject, MotorBase
from typing import Dict, List, Union, Optional
from typing import Optional


class DCMotor(MotorBase):
Expand Down Expand Up @@ -618,7 +619,7 @@ def electric_current(self, electric_current: Current):
self.__electric_current = electric_current

@property
def time_variables(self) -> Dict[str, List[UnitBase]]:
def time_variables(self) -> dict[str, list[UnitBase]]:
"""Time variables of the DC motor. Each time variable is stored as a dictionary key-value pair. The available
time variables are:
Expand Down Expand Up @@ -662,7 +663,7 @@ def update_time_variables(self) -> None:
self.time_variables['pwm'].append(self.pwm)

@property
def pwm(self) -> Union[float, int]:
def pwm(self) -> float | int:
"""Pulse Width Modulation duty cycle of the supply voltage of the DC motor. \n
It must be a :py:class:`float` or an :py:class:`int` within ``-1`` and ``1``. \n
In general the duty cycle can be between ``0`` and ``1``, but :py:attr:`pwm` can be between ``-1`` and ``1``, in
Expand Down Expand Up @@ -698,7 +699,7 @@ def pwm(self) -> Union[float, int]:
return self.__pwm

@pwm.setter
def pwm(self, pwm: Union[float, int]):
def pwm(self, pwm: float | int):
if not isinstance(pwm, float) and not isinstance(pwm, int):
raise TypeError("Parameter 'pwm' must be a float or an integer.")

Expand Down
6 changes: 3 additions & 3 deletions gearpy/mechanical_objects/flywheel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations
from gearpy.units import AngularPosition, AngularSpeed, AngularAcceleration, InertiaMoment, Torque, UnitBase
from .mechanical_object_base import RotatingObject
from typing import Dict, List, Union


class Flywheel(RotatingObject):
Expand Down Expand Up @@ -313,7 +313,7 @@ def master_gear_ratio(self, master_gear_ratio: float):
self.__master_gear_ratio = master_gear_ratio

@property
def master_gear_efficiency(self) -> Union[float, int]:
def master_gear_efficiency(self) -> float | int:
"""Efficiency of the fixed joint between the flywheel and its driving rotating object. Since the relation
between the flywheel and its neighbor elements in the powertrain elements is always a fixed joint, the
efficiency is always equal to ``1`` and cannot be overwritten. \n
Expand Down Expand Up @@ -346,7 +346,7 @@ def inertia_moment(self) -> InertiaMoment:
return super().inertia_moment

@property
def time_variables(self) -> Dict[str, List[UnitBase]]:
def time_variables(self) -> dict[str, list[UnitBase]]:
"""Time variables of the flywheel. Each time variable is stored as a dictionary key-value pair. The available
time variables are:
Expand Down
9 changes: 5 additions & 4 deletions gearpy/mechanical_objects/helical_gear.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations
from gearpy.units import AngularPosition, AngularSpeed, AngularAcceleration, Angle, Force, InertiaMoment, Length, \
Stress, Time, Torque, UnitBase
from math import sqrt, atan
from .mechanical_object_base import RotatingObject, lewis_factor_function, Role
from .mating_roles import MatingMaster, MatingSlave
from .spur_gear import SpurGear
from typing import Callable, Dict, List, Union, Optional
from typing import Callable, Optional


class HelicalGear(SpurGear):
Expand Down Expand Up @@ -416,7 +417,7 @@ def master_gear_ratio(self, master_gear_ratio: float):
super(HelicalGear, type(self)).master_gear_ratio.fset(self, master_gear_ratio)

@property
def master_gear_efficiency(self) -> Union[float, int]:
def master_gear_efficiency(self) -> float | int:
"""Efficiency of the gear mating between the gear and its driving gear. It must be a :py:class:`float` or an
:py:class:`int` within ``0`` and ``1``. \n
To set this property use :py:func:`add_gear_mating <gearpy.utils.relations.add_gear_mating>` or
Expand All @@ -438,7 +439,7 @@ def master_gear_efficiency(self) -> Union[float, int]:
return super().master_gear_efficiency

@master_gear_efficiency.setter
def master_gear_efficiency(self, master_gear_efficiency: Union[float, int]):
def master_gear_efficiency(self, master_gear_efficiency: float | int):
super(HelicalGear, type(self)).master_gear_efficiency.fset(self, master_gear_efficiency)

@property
Expand Down Expand Up @@ -951,7 +952,7 @@ def external_torque(self, external_torque: Callable[[AngularPosition, AngularSpe
super(HelicalGear, type(self)).external_torque.fset(self, external_torque)

@property
def time_variables(self) -> Dict[str, List[UnitBase]]:
def time_variables(self) -> dict[str, list[UnitBase]]:
"""Time variables of the gear. Each time variable is stored as a dictionary key-value pair. The available time
variables are:
Expand Down
9 changes: 5 additions & 4 deletions gearpy/mechanical_objects/mechanical_object_base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from abc import ABC, abstractmethod
from . import gear_data
from gearpy.units import Angle, AngularPosition, AngularSpeed, AngularAcceleration, Force, InertiaMoment, Length, \
Expand All @@ -6,7 +7,7 @@
from inspect import signature
import pandas as pd
from scipy.interpolate import interp1d
from typing import Callable, Dict, List, Union
from typing import Callable


LEWIS_FACTOR_DATA_FILE = (imp_resources.files(gear_data) / 'lewis_factor_table.csv')
Expand Down Expand Up @@ -187,7 +188,7 @@ def inertia_moment(self) -> InertiaMoment:

@property
@abstractmethod
def time_variables(self) -> Dict[str, List[UnitBase]]:
def time_variables(self) -> dict[str, list[UnitBase]]:
return self.__time_variables

@abstractmethod
Expand Down Expand Up @@ -432,12 +433,12 @@ def master_gear_ratio(self, master_gear_ratio: float):

@property
@abstractmethod
def master_gear_efficiency(self) -> Union[float, int]:
def master_gear_efficiency(self) -> float | int:
return self.__master_gear_efficiency

@master_gear_efficiency.setter
@abstractmethod
def master_gear_efficiency(self, master_gear_efficiency: Union[float, int]):
def master_gear_efficiency(self, master_gear_efficiency: float | int):
if not isinstance(master_gear_efficiency, float) and not isinstance(master_gear_efficiency, int):
raise TypeError("Parameter 'master_gear_efficiency' must be a float or an integer.")

Expand Down
Loading

0 comments on commit 3956a89

Please sign in to comment.