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

DefaultFormatter is removed, no replacement? #491

Open
netvl opened this issue Sep 28, 2021 · 8 comments
Open

DefaultFormatter is removed, no replacement? #491

netvl opened this issue Sep 28, 2021 · 8 comments

Comments

@netvl
Copy link

netvl commented Sep 28, 2021

Documentation still says that there is an API for formatting in the best unit, via DefaultFormater. Yet, it appears that it was removed in the latest version. I couldn't find any public discussions or tickets about it and reasoning for its removal, and there is no indication that there is a replacement. Does this mean that I cannot upgrade to the latest version if I want this functionality?

@netvl
Copy link
Author

netvl commented Sep 28, 2021

I found that this PR just dropped the entirety of experimental, with no replacement as it seems. I understand that experimental API is just that, experimental and subject for removal at any time, but I would've expected at least some explanation somewhere why it is done, and hopefully a pointer to a replacement (and updated docs too, because currently both readme and official site squants.com still have the old information).

@cquiroz
Copy link
Collaborator

cquiroz commented Sep 28, 2021

I dropped theexperimental api when upgrading to scala 3 simply due to lack of time to update it at the same time.
I don't think there are any users of the experimental api so should have been safe

@netvl
Copy link
Author

netvl commented Sep 29, 2021

I don't think there are any users of the experimental api so should have been safe

Sorry but how did you figure this out? Experimental API was explicitly documented on the primary documentation page and readme, and it did provide very useful features. Right now, missing functionality of DefaultFormatter is something which prevents me from upgrading, for example. I doubt I’m the only such user.

Again, since this API is experimental, it is all right to drop it for whatever reason, burden of maintenance included, but it is quite jarring that it was done without any explanations or notes, and documentation is misleading now :(

@cquiroz
Copy link
Collaborator

cquiroz commented Sep 29, 2021

You can see how the decision was reached in the PR
#454

In that PR support for scala 3 was added and some sacrifices were made (also no scala-native) or most likely there wouldn't be scala 3 support at all.

As for documentation, I don't have access to the orginal website nor rights to update it. We may want to update the README to be in sync with the current code. PRs are certainly welcome in documentation and/or to restore the removed functionality

@garyKeorkunian
Copy link
Contributor

NOTE - the website at squants.com is a GitHub page that displays the current README.

@axb21
Copy link

axb21 commented Mar 10, 2023

The current README still discusses the non-existent experimental package. I just spent a good hour trying to find it, thinking I'd done something wrong or missed a dependency.

Can you please at least update the README and spare other people the trouble and headscratching I just went through?

@axb21
Copy link

axb21 commented Mar 10, 2023

For what it's worth, if you're using scala 3 you can more or less copy-paste the DefaultFormatter code from an earlier version (e.g. 1.7.0 has it) and it works fine. You're going to need UnitGroup too and to either make your own or to use the ones implemented there. You can use an extension method to add inBestUnit to whichever Dimension you want, once you've created a formatter; e.g.,

val powerFormatter = new DefaultFormatter(PowerUnitGroup)
extension(power: Power) def inBestUnit = powerFormatter.inBestUnit(power)

where PowerUnitGroup is

object PowerUnitGroup extends UnitGroup[Power]:
   val units: Set[UnitOfMeasure[Power]] = Set(Watts, Kilowatts, Megawatts, Gigawatts)

(for instance).

With the above in place you can do stuff like

scala> Kilowatts(1000).inBestUnit
val res2: squants.energy.Power = 1.0 MW
                                                                                                                                                                                    
scala> Kilowatts(1000000).inBestUnit
val res3: squants.energy.Power = 1.0 GW

@KannarFr
Copy link

KannarFr commented Apr 6, 2023

I don't think there are any users of the experimental api so should have been safe

Huh?!

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

No branches or pull requests

5 participants