Skip to content

Note expected accuracy in space-age description#880

Merged
rpottsoh merged 1 commit intomasterfrom
stkent-patch-1
Aug 17, 2017
Merged

Note expected accuracy in space-age description#880
rpottsoh merged 1 commit intomasterfrom
stkent-patch-1

Conversation

@stkent
Copy link
Copy Markdown
Contributor

@stkent stkent commented Aug 16, 2017

Inspired by exercism/kotlin#100.

Consistent with the rounding policy used by the canonical data.


So if you were told someone were 1,000,000,000 seconds old, you should
be able to say that they're 31 Earth-years old.
be able to say that they're 31.69 Earth-years old. Round all ages to
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'll trust that your math is correct. 😉

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I pulled this from the canonical data, thereby passing the buck 😄

@rpottsoh rpottsoh merged commit 988566a into master Aug 17, 2017
@rpottsoh rpottsoh deleted the stkent-patch-1 branch August 17, 2017 12:27
@petertseng
Copy link
Copy Markdown
Member

petertseng commented Aug 17, 2017 via email

@stkent
Copy link
Copy Markdown
Contributor Author

stkent commented Aug 17, 2017

The canonical data already imposed that requirement.

@petertseng
Copy link
Copy Markdown
Member

petertseng commented Aug 17, 2017 via email

@stkent
Copy link
Copy Markdown
Contributor Author

stkent commented Aug 17, 2017

It seems that explicit rounding would make life much easier for tracks with generated tests. Are there other cases where we use some approximate representation of the actual value you would expect to be computed?

@petertseng
Copy link
Copy Markdown
Member

petertseng commented Aug 17, 2017 via email

@stkent
Copy link
Copy Markdown
Contributor Author

stkent commented Aug 17, 2017

From one of those threads you linked:

It's not a problem if the results should be rounded to two decimal places but I think it should explicitly say that in the problem.

That's the problem solved here, no?

@petertseng
Copy link
Copy Markdown
Member

petertseng commented Aug 17, 2017 via email

@stkent
Copy link
Copy Markdown
Contributor Author

stkent commented Aug 17, 2017

I think I see. There are essentially two main options that would make sense for generated tests:

  1. expect rounding, mention this in the README, and provide the rounded values to match exactly in the data;
  2. do not expected rounding, don't mention rounding in the README, and provide both rounded values to match and a rounding tolerance in the data.

This PR moved us to option 1; you're suggesting that we may want to consider something like option 2 based on the concepts it will introduce (assertions with tolerances, vs explicit rounding in option 1)?

@rpottsoh
Copy link
Copy Markdown
Member

rpottsoh commented Aug 17, 2017

I apologize for merging too soon. This is an interesting discussion.

@stkent
Copy link
Copy Markdown
Contributor Author

stkent commented Aug 17, 2017

I apologize for merging too soon. This is an interesting discussion.

No worries, and agreed r.e. the discussion :) Easy to adjust once a conclusion is reached, if required.

@petertseng
Copy link
Copy Markdown
Member

petertseng commented Aug 18, 2017 via email

@petertseng
Copy link
Copy Markdown
Member

petertseng commented Aug 18, 2017 via email

@stkent
Copy link
Copy Markdown
Contributor Author

stkent commented Aug 18, 2017

So if the option to expect+mention rounding is taken, tolerances may
still be necessary.

This is an excellent point; given this, tracks need to decide on (or use a canonical) equality tolerance for both options I outlined, in which case, it might be better for the README to instead state this tolerance explicitly?

@petertseng
Copy link
Copy Markdown
Member

petertseng commented Aug 18, 2017 via email

petertseng added a commit that referenced this pull request Oct 15, 2017
…946)

This reverts commit 7eb0dc9.

In #880 we
discussed that tracks may need to use a tolerance in their floating
point comparisons.

In light of this, asking students to round the answer seems strangely
arbitrary and theoretically doesn't prevent the need for having a
tolerance. Despite this, I do not currently have an example where
lacking a tolerance would have a false negative or false positive if a
floating point literal of two decimal places is compared to a value that
was rounded to two decimal places. So, then, the primary motivation is
to avoid adding requirements whose reasons are unclear.

Thus, remove the sentence completely. Tracks should add it if it is
relevant for their track.

Closes #945 by
mutual exclusion.

The tracks that currently implement the exercise, and whether their
equality tests have tolerances:

Please excuse me if I miscategorised your track because of my
unfamiliarity with your language (and then correct me).

Exactly equal:

* https://github.com/exercism/csharp/blob/master/exercises/space-age/SpaceAgeTest.cs
* https://github.com/exercism/cfml/blob/master/exercises/space-age/SpaceAgeTest.cfc
* https://github.com/exercism/ecmascript/blob/master/exercises/space-age/space-age.spec.js
* https://github.com/exercism/fsharp/blob/master/exercises/space-age/SpaceAgeTest.fs
* https://github.com/exercism/javascript/blob/master/exercises/space-age/space-age.spec.js
* https://github.com/exercism/kotlin/blob/master/exercises/space-age/src/test/kotlin/SpaceAgeTest.kt
* https://github.com/exercism/lua/blob/master/exercises/space-age/space-age_spec.lua
* https://github.com/exercism/perl5/blob/master/exercises/space-age/space.t
* https://github.com/exercism/perl6/blob/master/exercises/space-age/space-age.t
* https://github.com/exercism/python/blob/master/exercises/space-age/space_age_test.py
* https://github.com/exercism/r/blob/master/exercises/space-age/test_space-age.R
* https://github.com/exercism/scala/blob/master/exercises/space-age/src/test/scala/SpaceAgeTest.scala
* https://github.com/exercism/swift/blob/master/exercises/space-age/Tests/SpaceAgeTests/SpaceAgeTests.swift
* https://github.com/exercism/typescript/blob/master/exercises/space-age/space-age.test.ts

Fixed tolerance 0.5 in either direction (so that the answer rounds to the desired value if rounding to closest integer)

* https://github.com/exercism/elm/blob/master/exercises/space-age/tests/Tests.elm

Fixed tolerance 0.01 in either direction

* https://github.com/exercism/java/blob/master/exercises/space-age/src/test/java/SpaceAgeTest.java
* https://github.com/exercism/objective-c/blob/master/exercises/space-age/SpaceAgeTest.m
* https://github.com/exercism/php/blob/master/exercises/space-age/space-age_test.php
* https://github.com/exercism/ruby/blob/master/exercises/space-age/space_age_test.rb
* https://github.com/exercism/rust/blob/master/exercises/space-age/tests/space-age.rs

Fixed tolerance 0.005 in either direction (so that the answer rounds to the desired value if rounding to two decimal places)

* https://github.com/exercism/cpp/blob/master/exercises/space-age/space_age_test.cpp
* https://github.com/exercism/clojure/blob/master/exercises/space-age/test/space_age_test.clj
* https://github.com/exercism/common-lisp/blob/master/exercises/space-age/space-age-test.lisp
* https://github.com/exercism/elixir/blob/master/exercises/space-age/space_age_test.exs
* https://github.com/exercism/erlang/blob/master/exercises/space-age/test/space_age_tests.erl
* https://github.com/exercism/haskell/blob/master/exercises/space-age/test/Tests.hs
* https://github.com/exercism/lfe/blob/master/exercises/space-age/test/space-age-tests.lfe
* https://github.com/exercism/ocaml/blob/master/exercises/space-age/test.ml
* https://github.com/exercism/prolog/blob/master/exercises/space-age/space_age_tests.plt

Variable tolerances (decided ahead-of-time):

* https://github.com/exercism/c/blob/master/exercises/space-age/test/test_space_age.c
glikson added a commit to glikson/exercism-go that referenced this pull request Nov 15, 2017
The expected age values are specified (in respective canonical-data.json) with 2-digit precision (e.g., 31.69), while the actual result is a float.
Instead of forcing the solution to perform an arbitrary rounding, the test code verifies the result with certain precision (currently same 2-digit, for compatibility - can be eventually added to canonical-data.json itself).
Aligned with the conclusion of the discussion in exercism/problem-specifications#880
ferhatelmas pushed a commit to exercism/go that referenced this pull request Nov 15, 2017
* space-age: do not force rounding of solutions

The expected age values are specified (in respective canonical-data.json) with 2-digit precision (e.g., 31.69), while the actual result is a float.
Instead of forcing the solution to perform an arbitrary rounding, the test code verifies the result with certain precision (currently same 2-digit, for compatibility - can be eventually added to canonical-data.json itself).
Aligned with the conclusion of the discussion in exercism/problem-specifications#880

* space-age: fix formatting
emcoding pushed a commit that referenced this pull request Nov 19, 2018
grains: Fix generator and regenerate tests
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.

3 participants