-
-
Notifications
You must be signed in to change notification settings - Fork 194
Function Comparison and Identity Map #353
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
Conversation
It seems that an atmospheric file is not available due to server clutter, then the tests do not pass. It will likely return shortly. |
dc137b4
to
a9f746d
Compare
One particular issue regarding
|
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.
Just two final comments:
- Like
min
andmax
are cached properties, perhaps so shouldxArray
,yArray
,xinitial
,xfinal
, etc be. - It worries me that some new methods, such as
min
andmax
, have no handling of 2D Functions. They are rarely used for now tho, so this is not a deal breaker.
self.setInterpolation(self.__interpolation__) | ||
self.setExtrapolation(self.__extrapolation__) |
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 don't remember discussing this, but I may have forgotten.
From what I see, we have to different behaviors:
- Keeping interpolation and extrapolation unchanged when discretizing.
- Using the interpolation and extrapolation of the model Function.
Could you point out the pros and cons of each? How would the first option work in case self originally has a callable source?
Feel free to keep the proposed solution if you find it the best option. However, make sure to document this behavior.
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.
Both ways are possible, however, during coding with this method, I found that keeping the self
properties is usually more useful:
- In general, the Model Function was used only to ensure the same discretization as other in order to perform arithmetic operations. Therefore, the main point was to make the
xArray
equally discretized; - Due the fact that the arithmetic operations now no longer require the same interpolation for array computations, it seems unnecessary to force
self
into the same interpolation of the model Function. That may cause issues if an "exact" extrapolation (such as linear (i.e. natural)) is substituted by an "inaccurate" extrapolation (such as polynomial)".
As an example of the latter, the IdentityMap is based on accurate linear extrapolation, is one discretizes it based on a model Function of another kind (e.g. something really common) great inaccuracies may appear.
Co-authored-by: Giovani Hidalgo Ceotto <[email protected]>
Here is a to-do list before merging this PR:
The last two are suggestions, thus optional. @phmbressan let me know if you prefer to skip them. |
Pull request type
Please check the type of change your PR introduces:
Pull request checklist
Please check if your PR fulfills the following requirements, depending on the type of PR:
Code base additions (for bug fixes / features):
black rocketpy
) has passed locally and any fixes were madepytest --runslow
) have passed locallyWhat is the current behavior?
The Function class currently lacks basic methods of comparison and identity map.
What is the new behavior?
The comparison works in a very similar way to comparing arrays in numpy. When this comparison cannot be performed, an error is raised. The identity map is basically an implementation of the function$f(x) = x$ that follows the same discretization as the instance.
Does this introduce a breaking change?