Skip to content

improved docstring and generalised _rescale_minmax#228

Closed
kvyh wants to merge 8 commits intoastropy:masterfrom
kvyh:minmax_rescale
Closed

improved docstring and generalised _rescale_minmax#228
kvyh wants to merge 8 commits intoastropy:masterfrom
kvyh:minmax_rescale

Conversation

@kvyh
Copy link
Contributor

@kvyh kvyh commented Aug 9, 2016

In the case that a user wants to create a Constraint that is non-boolean, they will want to use _rescale_minmax or a similar function. This PR is trying to make the function more general and understandable by changing variable names and adding a docstring.

Any ideas for variable names, or better descriptions for the docstring are welcome.

what is returned for ``vals`` beyond the ``best_val``
worse_than : 0 or 1
what is returned for ``vals`` beyond the ``worst_val``

Copy link
Contributor

@bmorris3 bmorris3 Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you include an example or two demonstrating how it works? Here's an example to refer to for the format. For example, you could use altitude = [0, 10, 20] and airmass = [3, 2, 1] and show how the outputs match what you'd expect.

@kvyh
Copy link
Contributor Author

kvyh commented Aug 9, 2016

I added some examples as well as some tests for it.

below 35 and 1 above 60.
>>> from astroplan.constraints import _rescale_minmax
>>> import numpy as np
>>> airmasses = np.array([20, 30, 40, 45, 55, 70])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean altitudes rather than airmasses here (and in the line below). Also – would you use a complete sentence in the description above, without repeating the variable definitions verbatim?

@kvyh
Copy link
Contributor Author

kvyh commented Aug 10, 2016

@bmorris3, do you have any idea why https://travis-ci.org/astropy/astroplan/jobs/151028147#L751 might be happening?

@bmorris3
Copy link
Contributor

I don't, but the error goes away if I restart the build.

@kvyh
Copy link
Contributor Author

kvyh commented Aug 10, 2016

That's good, now I just need to find a fix for the Quantity/TimeDelta comparison.

above = rescaled > 1
rescaled[below] = 0
rescaled[above] = 1
def _rescale_minmax(vals, worst_val, best_val, better_than=1, worse_than=0):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function should be public (remove the leading _, added to __all__) since it will be used in custom constraints.

@kvyh
Copy link
Contributor Author

kvyh commented Aug 12, 2016

Ok, I changed it to a public function and changed the description.

@kvyh
Copy link
Contributor Author

kvyh commented Aug 15, 2016

With #232's changes, this now passes.

@kvyh kvyh mentioned this pull request Aug 17, 2016
@kvyh
Copy link
Contributor Author

kvyh commented Aug 18, 2016

It appears that this will be replaced by #236.

@kvyh kvyh closed this Aug 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants