Giter Club home page Giter Club logo

Comments (10)

rage-shadowman avatar rage-shadowman commented on May 24, 2024

This would require adding "Ah" as a unit. We can't simply guess what the combined units mean or we would have issues with things like "mm" (millimeters? or meter*meter?).

from js-quantities.

gentooboontoo avatar gentooboontoo commented on May 24, 2024

Disambiguating theses cases could be supported by choosing a conventional way to parse them.

For cases represented by joined characters with no separators (other cases are not ambiguous), the first character could be always considered as a prefix (if compatible of course) and the remaining characters would be parsed as raw units. If this convention is followed, we have:

'mm': milli, meter
'm m': meter, meter

'mN: milli, newton
'Nm: newton, meter
'm*N': meter, newton
'm N': meter, newton
'mmN': milli, meter, newton
'mNm': milli, newton, meter

'Ah', // ampere, hour
'hA', // hecto, ampere
'mAh', // milli, ampere, hour

Like so, it seems to follow the principle of least surprise.

from js-quantities.

rage-shadowman avatar rage-shadowman commented on May 24, 2024

To play devil's advocate here, I would argue that hecto isn't very commonly used and thus hA not being hour*ampere might be more surprising than you would expect (and the same goes for yocto, maybe less so for deci).

from js-quantities.

rage-shadowman avatar rage-shadowman commented on May 24, 2024

However, when I first started using this library, I was also surprised that this guess-work was not happening. But after looking into it and seeing the ambiguity I decided that wasn't such an issue for me.

from js-quantities.

gentooboontoo avatar gentooboontoo commented on May 24, 2024

Two arguments in favor of considering "hA" as hecto, ampere:

  • Ampere-hour is often, if not always, denoted Ah so considering to parse "hA" as hecto, ampere should not be a real problem for anybody.
  • Ruby-units parses "hA" as hecto, ampere and it would be desirable to have the same behavior.

That said, I really appreciate your opinions @rage-shadowman. It is a great help.

from js-quantities.

rage-shadowman avatar rage-shadowman commented on May 24, 2024

Q: Does ruby-units pars "Ah" as ampere*hour?

If ruby-units does the guess work in this manner, then I agree with you (especially since I see no mention of "Ah" specifically in the ruby-units source). I do not have a running ruby environment to test it out on though.

from js-quantities.

gentooboontoo avatar gentooboontoo commented on May 24, 2024

No. Ironically it fails to parse it. But it is not surprising because js-quantities regexps were originally the same than Ruby-units ones. However, I would like to fix it because it is a bug.

from js-quantities.

rage-shadowman avatar rage-shadowman commented on May 24, 2024

Are you sure they consider it a bug in ruby-units? How would you define "hrs" then? hour or hour*second? There are likely many less obvious examples of ambiguity due to all of the aliases that are allowed for each unit. When I looked into making this change I gave up after I found a few that I couldn't state empirically should always go one way.

from js-quantities.

rage-shadowman avatar rage-shadowman commented on May 24, 2024

I do agree that "Ah" is a commonly used unit and thus may deserve its own unit definition. But I personally think that guess-work which results in direct answers to ambiguous questions is a bad idea.

from js-quantities.

bombledmonk avatar bombledmonk commented on May 24, 2024

I don't really have any authority in this matter, but given the conversation it does seem rage-shadowman's suggestion to give "Ah" its own definition is the solution with the least risk.

from js-quantities.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.