Skip to content

Commit

Permalink
Merge branch 'develop' into enh/precalculate-barometric-height
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusStano authored Jan 17, 2024
2 parents 6360294 + ee9348d commit 2f70ef3
Show file tree
Hide file tree
Showing 13 changed files with 1,344 additions and 151 deletions.
20 changes: 0 additions & 20 deletions .github/auto-assign.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,2 @@
# Set to true to add reviewers to PRs
addReviewers: true

# Set to 'author' to add PR's author as a assignee
addAssignees: author

# A list of reviewers to be added to PRs (GitHub user name)
reviewers:
- Gui-FernandesBR
- giovaniceotto
- MateusStano
- phmbressan

# A number of reviewers added to the PR
# Set 0 to add all the reviewers (default: 0)
numberOfReviewers: 0

# A list of keywords to be skipped the process if PR's title include it
skipKeywords:
- wip
- work in progress
- draft
35 changes: 35 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
coverage:
status:
project:
default:
# basic
target: auto
threshold: 1%
base: auto
flags:
- unit
paths:
- "rocketpy"
# advanced settings
branches:
- master
- develop
if_ci_failed: error #success, failure, error, ignore
informational: false
only_pulls: false
patch:
default:
# basic
target: auto
threshold: 1%
base: auto
# advanced
branches:
- master
- develop
if_ci_failed: error #success, failure, error, ignore
only_pulls: false
flags:
- "unit"
paths:
- "rocketpy"
2 changes: 1 addition & 1 deletion .github/workflows/lint_black.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python-version: 3.8

- name: Install Python dependencies
run: pip install black
run: pip install black[jupyter]

- name: Run linters
uses: wearerequired/lint-action@v1
Expand Down
104 changes: 61 additions & 43 deletions .github/workflows/test_pytest.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PyTest
name: Tests

on:
pull_request:
Expand All @@ -7,58 +7,76 @@ on:
- "**.py"
- ".github/**"

defaults:
run:
shell: bash

jobs:
fail_if_pr_is_draft:
if: github.event.pull_request.draft == true
runs-on: ubuntu-18.04
steps:
- name: Fails in order to indicate that pull request needs to be marked as ready to review and unit tests workflow needs to pass.
run: exit 1
pytest_and_doctest:
Pytest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
python-version:
- 3.8
- 3.12
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.8, 3.12]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Build RocketPy (without optional dependencies)
run: |
pip install .
- name: Import rocketpy in python and test if it works
run: |
python -c "import sys, rocketpy; print(f'{rocketpy.__name__} running on Python {sys.version}')"
- name: Install optional dependencies
run: |
pip install -r requirements-tests.txt
- name: Test with pytest
run: |
pytest --cov=rocketpy --cov-report=xml
cd rocketpy
pytest --doctest-modules --cov=rocketpy --cov-report=xml
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v3

- name: Cache Python dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-tests.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install rocketpy
run: pip install .

- name: Test importing rocketpy
run: python -c "import sys, rocketpy; print(f'{rocketpy.__name__} running on Python {sys.version}')"

- name: Install test dependencies
run: pip install -r requirements-tests.txt

- name: Run Unit Tests
run: pytest tests/unit --cov=rocketpy

- name: Run Integration Tests
run: pytest $(find tests -maxdepth 1 -name "*.py") --cov=rocketpy --cov-append

- name: Run Documentation Tests
run: pytest rocketpy --doctest-modules --cov=rocketpy --cov-append

- name: Run Acceptance Tests
run: pytest tests/acceptance --cov=rocketpy --cov-append --cov-report=xml

- name: Run pytest --runslow
if: github.ref == 'refs/heads/master'
run: pytest tests -m slow --runslow --cov=rocketpy --cov-append --cov-report=xml

- name: Upload coverage to artifacts
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage.xml

CodecovUpload:
needs: Pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all coverage reports
uses: actions/download-artifact@v2
- name: Upload to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/reports/
env_vars: OS,PYTHON
fail_ci_if_error: true
files: ./coverage.xml, ./rocketpy/coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true
files: |
coverage.xml
29 changes: 29 additions & 0 deletions .github/workflows/upload-to-codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Upload to Codecov

on:
workflow_call:
inputs:
codecov_token:
required: true
type: string
os:
required: true
type: string
python:
required: true
type: string

jobs:
upload:
runs-on: ubuntu-latest
steps:
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ inputs.codecov_token }}
directory: ./coverage/reports/
env_vars: OS,PYTHON
files: ./coverage.xml, ./rocketpy/coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ straightforward as possible.
### Fixed

- ENH: Parachute trigger doesn't work if "Apogee" is used instead of "apogee" [#489](https://github.com/RocketPy-Team/RocketPy/pull/489)
- BUG: fin_flutter_analysis doesn't find any fin set [#510](https://github.com/RocketPy-Team/RocketPy/pull/510)
- FIX: EmptyMotor is breaking the Rocket.draw() method [#516](https://github.com/RocketPy-Team/RocketPy/pull/516)
- BUG: 3D trajectory plot not labeling axes [#533](https://github.com/RocketPy-Team/RocketPy/pull/533)

## [v1.1.4] - 2023-12-07

Expand Down
9 changes: 8 additions & 1 deletion rocketpy/mathutils/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ def to_frequency_domain(self, lower, upper, sampling_frequency, remove_dc=True):
extrapolation="zero",
)

def low_pass_filter(self, alpha):
def low_pass_filter(self, alpha, file_path=None):
"""Implements a low pass filter with a moving average filter
Parameters
Expand All @@ -1097,6 +1097,9 @@ def low_pass_filter(self, alpha):
filtered function returned will match the function the smaller
alpha is, the smoother the filtered function returned will be
(but with a phase shift)
file_path : string
File path or file name of the CSV to save. Don't save any CSV if
if no argument is passed. Initiated to None.
Returns
-------
Expand All @@ -1112,6 +1115,10 @@ def low_pass_filter(self, alpha):
alpha * self.source[i] + (1 - alpha) * filtered_signal[i - 1]
)

# Save the new csv file with filtered data
if isinstance(file_path, str):
np.savetxt(file_path, filtered_signal, delimiter=",")

return Function(
source=filtered_signal,
interpolation=self.__interpolation__,
Expand Down
25 changes: 17 additions & 8 deletions rocketpy/plots/flight_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,16 @@ def trajectory_3d(self):
-------
None
"""

# Get max and min x and y
max_z = max(self.flight.z[:, 1] - self.flight.env.elevation)
min_z = min(self.flight.z[:, 1] - self.flight.env.elevation)
max_x = max(self.flight.x[:, 1])
min_x = min(self.flight.x[:, 1])
max_y = max(self.flight.y[:, 1])
min_y = min(self.flight.y[:, 1])
max_xy = max(max_x, max_y)
min_xy = min(min_x, min_y)

# Create figure
fig1 = plt.figure(figsize=(9, 9))
_ = plt.figure(figsize=(9, 9))
ax1 = plt.subplot(111, projection="3d")
ax1.plot(
self.flight.x[:, 1], self.flight.y[:, 1], zs=0, zdir="z", linestyle="--"
Expand All @@ -99,19 +97,30 @@ def trajectory_3d(self):
self.flight.z[:, 1] - self.flight.env.elevation,
linewidth="2",
)
ax1.scatter(0, 0, 0)
ax1.scatter(
self.flight.x(0),
self.flight.y(0),
self.flight.z(0) - self.flight.env.elevation,
color="black",
)
ax1.scatter(
self.flight.x(self.flight.t_final),
self.flight.y(self.flight.t_final),
self.flight.z(self.flight.t_final) - self.flight.env.elevation,
color="red",
marker="X",
)
ax1.set_xlabel("X - East (m)")
ax1.set_ylabel("Y - North (m)")
ax1.set_zlabel("Z - Altitude Above Ground Level (m)")
ax1.set_title("Flight Trajectory")
ax1.set_zlim3d([0, max_z])
ax1.set_zlim3d([min_z, max_z])
ax1.set_ylim3d([min_xy, max_xy])
ax1.set_xlim3d([min_xy, max_xy])
ax1.view_init(15, 45)
ax1.set_box_aspect(None, zoom=0.95) # 95% for label adjustment
plt.show()

return None

def linear_kinematics_data(self):
"""Prints out all Kinematics graphs available about the Flight
Expand Down
26 changes: 13 additions & 13 deletions rocketpy/plots/rocket_plots.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import matplotlib.pyplot as plt
import numpy as np

from rocketpy.motors import HybridMotor, LiquidMotor, SolidMotor
from rocketpy.motors import EmptyMotor, HybridMotor, LiquidMotor, SolidMotor
from rocketpy.rocket.aero_surface import Fins, NoseCone, Tail


Expand Down Expand Up @@ -332,10 +332,6 @@ def draw(self, vis_args=None):
self.rocket.motor_position + self.rocket.motor.nozzle_position * total_csys
)

nozzle = self.rocket.motor.plots._generate_nozzle(
translate=(nozzle_position, 0), csys=self.rocket._csys
)

# List of motor patches
motor_patches = []

Expand Down Expand Up @@ -414,14 +410,18 @@ def draw(self, vis_args=None):
motor_patches += [tank]

# add nozzle last so it is in front of the other patches
motor_patches += [nozzle]
outline = self.rocket.motor.plots._generate_motor_region(
list_of_patches=motor_patches
)
# add outline first so it is behind the other patches
ax.add_patch(outline)
for patch in motor_patches:
ax.add_patch(patch)
if not isinstance(self.rocket.motor, EmptyMotor):
nozzle = self.rocket.motor.plots._generate_nozzle(
translate=(nozzle_position, 0), csys=self.rocket._csys
)
motor_patches += [nozzle]
outline = self.rocket.motor.plots._generate_motor_region(
list_of_patches=motor_patches
)
# add outline first so it is behind the other patches
ax.add_patch(outline)
for patch in motor_patches:
ax.add_patch(patch)

# Check if nozzle is beyond the last surface, if so draw a tube
# to it, with the radius of the last surface
Expand Down
Loading

0 comments on commit 2f70ef3

Please sign in to comment.