Skip to content

ENH: give me a scissor or apply Function.clip and Function.crop #546

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

Open
2 tasks
Gui-FernandesBR opened this issue Feb 6, 2024 · 8 comments · May be fixed by #817
Open
2 tasks

ENH: give me a scissor or apply Function.clip and Function.crop #546

Gui-FernandesBR opened this issue Feb 6, 2024 · 8 comments · May be fixed by #817
Labels
Enhancement New feature or request, including adjustments in current codes Function Everything related to the Function class Good first issue Good for newcomers

Comments

@Gui-FernandesBR
Copy link
Member

Is your feature request related to a problem? Please describe.

Mutating Function objects is magical because sometimes we need to do some particular operations with them.
This issue requests two new methods to create new Function objects from other array-based Function objects.

Describe the solution you'd like

Please implement the following:

  • Function.clip : limits the y_array to a certain range, for instance, limit the sin function to be constrained between -1 an 1. This should delete any datapoint with the y value out of the range.
  • Function.crop : limits the x_array to a certain range, for instance, limit the domain of a R1->R1 function to be limited by x=0 and x=1. This should delete any datapoint with the x values out of the range.

Some considerations:

  • The methods should take the array source of the Function, remove the undesired data, return
  • Once we remove data from the array and recreate a function object, all the interpolation coefficients will be recalculated. Should that be a problem?

I'm not sure how we would do (if possible) the same operations in non array-based Functions, so I'm leaving them out of the scope here.

Additional context

@Gui-FernandesBR Gui-FernandesBR added the Enhancement New feature or request, including adjustments in current codes label Feb 6, 2024
@Gui-FernandesBR Gui-FernandesBR added this to the Release v1.X.0 milestone Feb 6, 2024
@Gui-FernandesBR Gui-FernandesBR added the Good first issue Good for newcomers label Jun 29, 2024
@Gui-FernandesBR Gui-FernandesBR added the Function Everything related to the Function class label May 1, 2025
@Rickisterr
Copy link

Good day, I was wondering if this issue is still under consideration and if so, may I work on it?

@Gui-FernandesBR
Copy link
Member Author

Good day, I was wondering if this issue is still under consideration and if so, may I work on it?

yes it is, but there's a lot already done here: https://github.com/RocketPy-Team/RocketPy/tree/enh/liq

Can you openup a PR?

@Rickisterr
Copy link

understood; then I will refer to and use the linked branch's implementation and finish this feature up and submit a PR as soon as I finish

Also, for further clarification, the methods should also clip the functions themselves for when source is a callable lambda function as well, right? Not just when it has a set of discrete values that are to be clipped?

Thank you!

@Gui-FernandesBR
Copy link
Member Author

understood; then I will refer to and use the linked branch's implementation and finish this feature up and submit a PR as soon as I finish

Also, for further clarification, the methods should also clip the functions themselves for when source is a callable lambda function as well, right? Not just when it has a set of discrete values that are to be clipped?

Thank you!

yes they should.

@Rickisterr Rickisterr linked a pull request May 12, 2025 that will close this issue
4 tasks
@Rickisterr
Copy link

Good day, I just wanted to notify that I have opened up a PR regarding this. Thank you so much!

@Gui-FernandesBR
Copy link
Member Author

Good day, I just wanted to notify that I have opened up a PR regarding this. Thank you so much!

Amazing work, @Rickisterr !!

@Rickisterr
Copy link

Thank you so much! I really appreciate all the help and being able to work on this and hope I can contribute even more!

@Gui-FernandesBR
Copy link
Member Author

Thank you so much! I really appreciate all the help and being able to work on this and hope I can contribute even more!

If you want to pick another open issue to work on, please feel free to do so.
I believe your PR should be merged son, the review will probably be quite smooth.

@Gui-FernandesBR Gui-FernandesBR linked a pull request May 16, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request, including adjustments in current codes Function Everything related to the Function class Good first issue Good for newcomers
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

2 participants