-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
ENH: Expansion of Encoders Implementation for Full Flights. #679
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #679 +/- ##
===========================================
+ Coverage 75.87% 75.96% +0.08%
===========================================
Files 85 85
Lines 10085 10110 +25
===========================================
+ Hits 7652 7680 +28
+ Misses 2433 2430 -3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to complain about, good work.
@@ -5,3 +5,4 @@ netCDF4>=1.6.4 | |||
requests | |||
pytz | |||
simplekml | |||
dill |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you searched about this lib before adding it to the requirements? is this stable enough?
Also, you must edit the pyproject.toml file otherwise this change is useless.
} | ||
|
||
@classmethod | ||
def from_dict(cls, func_dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I`d like to see an example of you loading a class from the dict.
@@ -186,3 +186,18 @@ def sort_by_position(self, reverse=False): | |||
None | |||
""" | |||
self._components.sort(key=lambda x: x.position, reverse=reverse) | |||
|
|||
def to_dict(self): | |||
"""Return a dictionary representation of the components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Youre gonna have to make a lot of
to_dict` methods. My recommendation is to avoid documenting all of them.
It's still experimental feature, so let's be "lazy" this time.
Pull request type
Checklist
black rocketpy/ tests/
) has passed locallypytest tests -m slow --runslow
) have passed locallyCHANGELOG.md
has been updated (if relevant)Current behavior
Currently the
_encoding
module is just a stub and cannot still encode full simulations into a JSON like format.New behavior
This PR expand this module bringing the following:
to_dict
;Function
encoding.Breaking change
Additional information
There is much to discuss here on the implementation and maintainability side of things. Main discussion points:
to_dict
and (in the future) afrom_dict
method to some (or all) rocketpy classes?_encoders
private.simplejson
: brings some more types and speed into encoding, but does not help much with custom types;jsonpickle
: really great for the typing handler (already writes by default each object type) and is able to serialize. The problem is that is does not handlefunctions/lambdas
and I did not find a good way to implement custom handlers for our use case;pickle / dill
: the most plug and play solution, however the output is not human readable and not generally compatible between different rocketpy versions.Of course, this is what I understood upon researching and testing, feel free to make any comments or suggest other modules.