Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Split Field.fromDouble to enable reuse. #190

Merged
merged 2 commits into from
Nov 30, 2016

Conversation

denisrosset
Copy link
Contributor

e.g. in Spire DivisionRing. The code is quite heavy in bit tricks that are difficult to verify, so I'd like to avoid duplication.

@codecov-io
Copy link

codecov-io commented Nov 30, 2016

Current coverage is 67.63% (diff: 0.00%)

Merging #190 into master will decrease coverage by 0.26%

@@             master       #190   diff @@
==========================================
  Files            36         36          
  Lines           757        760     +3   
  Methods         703        707     +4   
  Messages          0          0          
  Branches         54         53     -1   
==========================================
  Hits            514        514          
- Misses          243        246     +3   
  Partials          0          0          

Powered by Codecov. Last update 3da2b61...24fe85a

* probably significantly less efficient than can be done with a specific
* type. So, it is recommended to specialize this general method.
*/
def fromDouble[A](a: Double)(implicit ringA: Ring[A], mgA: MultiplicativeGroup[A]): A =
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I like this in Ring, since it can't actually be used with only a Ring. I think we should rename this to defaultFromDouble too, since we want to encourage folks to use the fromDouble on, eg, Field, which may be overridden to be faster.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just noticed this was in algebra, not spire! So, yeah, I guess Ring isn't too bad here. But I still think we should rename this defaultFromDouble.

@johnynek
Copy link
Contributor

👍

@non
Copy link
Contributor

non commented Nov 30, 2016

Seems reasonable to me. 👍

@non
Copy link
Contributor

non commented Nov 30, 2016

@denisrosset Do you want to add a test that calls this method? Or should we merge and worry about coverage later?

EDIT: We just merged another PR with a test, so maybe this is fine.

@non non merged commit baa32ef into typelevel:master Nov 30, 2016
@tixxit
Copy link
Contributor

tixxit commented Nov 30, 2016

@non Yeah, that PR will exercise this code through Rat, which uses the default implementation of fromDouble.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants