Skip to content

Conversation

@mtustin-handy
Copy link
Contributor

What changes were proposed in this pull request?

This special cases 0 and 1 counts to avoid passing 0 degrees of freedom.

How was this patch tested?

Tests run successfully. New test added.

Note:

This recreates #11982 which was closed to due to non-updated diff. @rxin @srowen Commented there.
This also adds tests, reworks the code to perform the special casing (based on @srowen's comments), and adds equality machinery for BoundedDouble, as well as changing how it is transformed to string.

*/
class BoundedDouble(val mean: Double, val confidence: Double, val low: Double, val high: Double) {
override def toString(): String = "[%.3f, %.3f]".format(low, high)
override def toString(): String = "BoundedDouble(%.3f, %.3f, %.3f, %.3f)".format(mean, confidence, low, high)
Copy link
Member

Choose a reason for hiding this comment

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

I was going to say that this can become a case class to get this all for free, but it's part of the API. In theory that doesn't change anything, so you can try a case class and see if MiMa accepts it. Otherwise you can do this, but you'll need to fix up a few little style things. I'd not change the toString, hashCode might be too long a line, and indent on equals is too deep

Copy link
Contributor

Choose a reason for hiding this comment

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

case classes bring extra concerns with binary compatibility (due to pattern matching). I'd minimize its use in public APIs.

@srowen
Copy link
Member

srowen commented Mar 31, 2016

Jenkins retest this please

override def toString(): String =
"BoundedDouble(%.3f, %.3f, %.3f, %.3f)".format(mean, confidence, low, high)

override def hashCode:Int =
Copy link
Member

Choose a reason for hiding this comment

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

(This might fail style checks without a space after : )

@SparkQA
Copy link

SparkQA commented Mar 31, 2016

Test build #54677 has finished for PR 12016 at commit 93bcd99.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member

srowen commented Apr 1, 2016

Jenkins retest this please

@SparkQA
Copy link

SparkQA commented Apr 1, 2016

Test build #54729 has finished for PR 12016 at commit 5db9678.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

test("correct handling of NaN") {

//setup
val counter = new StatCounter(List(1,Double.NaN,2))
Copy link
Member

Choose a reason for hiding this comment

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

Close now. It doesn't like the whitespace at ends of lines, and commas everywhere need a spaceafter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, for some reason sbt scalastyle isn't checking my test code. I'll try to retrigger jenkins in a second.

Copy link
Member

Choose a reason for hiding this comment

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

Try ./dev/lint-scala

@mtustin-handy
Copy link
Contributor Author

Jenkins retest this please

1 similar comment
@srowen
Copy link
Member

srowen commented Apr 2, 2016

Jenkins retest this please

@SparkQA
Copy link

SparkQA commented Apr 2, 2016

Test build #54777 has finished for PR 12016 at commit 5e3c477.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@mtustin-handy
Copy link
Contributor Author

The only failure has been failing since this: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/54771/.

I can pull from master and try again.

@srowen
Copy link
Member

srowen commented Apr 2, 2016

It's unrelated, I've seen it in other tests.

@srowen
Copy link
Member

srowen commented Apr 2, 2016

Jenkins retest this please

@SparkQA
Copy link

SparkQA commented Apr 2, 2016

Test build #54782 has finished for PR 12016 at commit 5e3c477.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

*/
class BoundedDouble(val mean: Double, val confidence: Double, val low: Double, val high: Double) {
override def toString(): String = "[%.3f, %.3f]".format(low, high)
override def toString(): String =
Copy link
Member

Choose a reason for hiding this comment

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

OK, I think this is all good, except I think the toString should be left alone. I forgot to mention this. Not that I really expect anyone to depend on the format, but let's leave it since it's a public class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I definitely can put it back, but the previous toString was just weird - it
only printed the bounds. Anyway, I'll update this in a sec (to go back).
Let me know if you change your mind.

On Saturday, April 2, 2016, Sean Owen notifications@github.com wrote:

In core/src/main/scala/org/apache/spark/partial/BoundedDouble.scala
#12016 (comment):

@@ -21,5 +21,23 @@ package org.apache.spark.partial

  • A Double value with error bars and associated confidence.
    */
    class BoundedDouble(val mean: Double, val confidence: Double, val low: Double, val high: Double) {
    • override def toString(): String = "[%.3f, %.3f]".format(low, high)
    • override def toString(): String =

OK, I think this is all good, except I think the toString should be left
alone. I forgot to mention this. Not that I really expect anyone to depend
on the format, but let's leave it since it's a public class.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/apache/spark/pull/12016/files/5e3c47762f79b89544360c383db10b3d77411109#r58301669

Want to work at Handy? Check out our culture deck and open roles
http://www.handy.com/careers
Latest news http://www.handy.com/press at Handy
Handy just raised $50m
http://venturebeat.com/2015/11/02/on-demand-home-service-handy-raises-50m-in-round-led-by-fidelity/ led
by Fidelity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@srowen
Copy link
Member

srowen commented Apr 3, 2016

Looks good, thank you. Let's give it one more spin

@srowen
Copy link
Member

srowen commented Apr 3, 2016

Jenkins retest this please

@SparkQA
Copy link

SparkQA commented Apr 3, 2016

Test build #54788 has finished for PR 12016 at commit 4040e0e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member

srowen commented Apr 4, 2016

Merged to master, thanks

@asfgit asfgit closed this in 9023015 Apr 4, 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.

4 participants