Skip to content
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

propagate NM in reducers #7

Merged
merged 5 commits into from
May 23, 2014
Merged

propagate NM in reducers #7

merged 5 commits into from
May 23, 2014

Conversation

dwhjames
Copy link
Contributor

after discussion with @tixxit, NM should have similar semantics to NaN in floating point arithmetic and so should propagate similarly.

after discussion with @tixxit, `NM` should have similar semantics to `NaN` in floating point arithmetic and so should propagate similarly.
@@ -15,6 +15,8 @@ abstract class SimpleReducer[A: ClassTag, B] extends Reducer[A, B] {
val row = indices(i)
if (column.exists(row)) {
bldr += column.value(row)
} else if (column.missing(row) == NM) {
return NM
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 don’t know if you feel that non-local return is abhorrent… I’m happy to rewrite the cfor explicitly as a while with the appropriate termination condition.

Copy link
Owner

Choose a reason for hiding this comment

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

As long as it isn't compiling down to a throw, I'm OK with returns where they make things clearer/faster :) I am unsure about using them in a cfor - cfor used rewrite to a tail-recursive method, but I think it is now a while. However, I wouldn't bank on that. May be worth rewriting as a while.

- the Mean reducer returns NM if it encounters an NM
- fix tests accordingly
@dwhjames dwhjames changed the title propagate NM in simple reducers propagate NM in reducers May 21, 2014
@dwhjames
Copy link
Contributor Author

@tixxit,

  • Count returns Value[Int], however, should it return Cell[Int] and NM if it encounters one?
  • Current has an outstanding TODO for non values.
  • First and Last propagate NM correctly.
  • Max does not check for NM, but following the rules, it should?
  • MonoidReducer propagates NM correctly.
  • SemigroupReducer propagates NM correctly.
  • Unique returns Value[Set[Int]], however, it should return Cell[Set[Int]] and NM if it encounters one?

@tixxit
Copy link
Owner

tixxit commented May 22, 2014

I'd say all of those should return NMs in the situation you mentioned. I mean, an NM may be a value, so the count won't be correct with an NM. Same for max/min. I think I'm going to fix up "Current" a bit in another PR. It doesn't need to be date specific.

@tixxit
Copy link
Owner

tixxit commented May 22, 2014

Actually, Current is a bit weird. I need to see where we are using it in content. It is basically Max, but uses only the first argument of a tuple and specializes it on LocalDate. So, we can just use Max, with an Order that does the same. So, I think Current should be removed entirely.

Conflicts:
	modules/pframe/src/main/scala/pellucid/pframe/reduce/Mean.scala
	modules/pframe/src/main/scala/pellucid/pframe/reduce/SimpleReducer.scala
- the reducers returns NM if they encounter an NM
- fix tests accordingly
@dwhjames
Copy link
Contributor Author

Count, Max, and Unique have been updated in 2860a2f. I’ve left Current, do you want to remove that in this pull request or tie it into the other work of date specific reductions (7a9e8b3)?

@tixxit
Copy link
Owner

tixxit commented May 22, 2014

Just remove it for now. It can literally be replaced with reduce.Current -> reduce.Max(Order.by(_._1)).

following discussion at #7 (comment) this reducer is equivalent to `Max(Order.by(_._1))`
@tixxit tixxit merged commit 88f4183 into tixxit:master May 23, 2014
@dwhjames dwhjames deleted the topic/simplereducer-NM branch May 24, 2014 01:59
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