-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add options to enforce min/max exclusion #73
Comments
As noted in Slack, these changes sound good. I don't think Range is used in performance-critical areas, so adding the options object should be totally fine (and helps for code readability).
Yup, seems somewhat unavoidable. Generally the client should round values as necessary, and it's best to NOT round in range checks. Can always use |
Thanks for the best practices info @jonathanolson, I'll be sure to add that in the doc. |
After some review and discussion with @zepumph, I opted to create a new type The primary question left is how to handle |
Unit tests added as well in the above commit. |
This looks really nice thanks for doing that! |
Thanks @zepumph! I think I can close this. |
Reopening. The documentation header on OpenRangeTests looks like a copy-paste error. Should be "OpenRange tests" with /**
* Bounds2 tests
*
* @author Jonathan Olson (PhET Interactive Simulations)
* @author Sam Reid (PhET Interactive Simulations)
*/ And there's dead code at the bottom of the file: // QUnit.test( 'assertion failures', function( assert ) {
// debugger;
// assert.throws( new OpenRange( 1, 1, minHalfOpenOptions ), 'min open range with min === max throws an error' );
// assert.throws( new OpenRange( 1, 1, maxHalfOpenOptions ), 'max open range with min === max throws an error' );
// assert.throws( new OpenRange( 1, 1 ), 'full open range with min === max throws an error' );
// } ); |
Thanks @pixelzoom. Code uncommented, annotations updated, and tests passing. Assigning to you to close. |
👍 Closing. |
Reopening. OpenRangeTests is failing CT:
|
@zepumph helped in making a check that |
All dot tests are passing with and without |
The range type doesn't currently support arbitrarily set closed/open/half-open intervals. This feature may be useful in various settings (it arose when mapping alert text to non-zero input values in phetsims/molecules-and-light#180).
I'm mildly concerned about how JS handles certain floating point situations (e.g.
var x = 0.1 * 0.2 = 0.020000000000000004
) and how they would interact with an exclusiveRange( 0.02, 0.03 )
. In that case,x
should not be included in the Range.Proposal is to implement closed intervals by default, add option keys (
excludeMin
andexcludeMax
) for closed behavior, and create tests to ensure these additions don't break current usages.The text was updated successfully, but these errors were encountered: