- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: expand encoders implementation to support full flights.
MNT: Add encoding feature to CHANGELOG. BUG: add dill to the requirements file.
1 parent
2218f0f
commit 07032f3
Showing
8 changed files
with
161 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ netCDF4>=1.6.4 | |
requests | ||
pytz | ||
simplekml | ||
dill |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import json | ||
|
||
import pytest | ||
|
||
from rocketpy._encoders import RocketPyEncoder | ||
|
||
# TODO: this tests should be improved with better validation and decoding | ||
|
||
|
||
@pytest.mark.parametrize("flight_name", ["flight_calisto", "flight_calisto_robust"]) | ||
def test_encode_flight(flight_name, request): | ||
"""Test encoding a ``rocketpy.Flight``. | ||
Parameters | ||
---------- | ||
flight_name : str | ||
Name flight fixture to encode. | ||
request : pytest.FixtureRequest | ||
Pytest request object. | ||
""" | ||
flight = request.getfixturevalue(flight_name) | ||
|
||
json_encoded = json.dumps(flight, cls=RocketPyEncoder) | ||
|
||
flight_dict = json.loads(json_encoded) | ||
|
||
assert json_encoded is not None | ||
assert flight_dict is not None | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"function_name", ["lambda_quad_func", "spline_interpolated_func"] | ||
) | ||
def test_encode_function(function_name, request): | ||
"""Test encoding a ``rocketpy.Function``. | ||
Parameters | ||
---------- | ||
function_name : str | ||
Name of the function to encode. | ||
request : pytest.FixtureRequest | ||
Pytest request object. | ||
""" | ||
function = request.getfixturevalue(function_name) | ||
|
||
json_encoded = json.dumps(function, cls=RocketPyEncoder) | ||
|
||
function_dict = json.loads(json_encoded) | ||
|
||
assert json_encoded is not None | ||
assert function_dict is not None |