Code Monkey home page Code Monkey logo

Comments (3)

keilw avatar keilw commented on June 27, 2024

Dimension.getBaseDimensions() returns a Map<Unit,Integer>; (3) Dimension.pow() and Unit.pow() accept only int as argument.

This is not really a problem because either Integer.intValue() or a cast between Integer and int should both work.
@SebHess Was this the only concern, or are there significant examples for e.g. floating-point dimensions?

from unit-api.

desruisseaux avatar desruisseaux commented on June 27, 2024

This is not really a problem because either Integer.intValue() or a cast between Integer and int should both work. Was this the only concern, or are there significant examples for e.g. floating-point dimensions?

In my understanding, he wished that Map<Unit,Integer> would have been something like Map<Unit,Fraction> instead (Fraction does not exist in the JDK, I'm using that only for expressing the intend). The example given is spectral densities with units of s^−½.

Map<Unit,Integer> cannot be changed without compatibility break. Furthermore there is no clear alternative to Integer in the standard JDK: Fraction does not exist, and Float or Double may be too flexible. While this issue is not impossible to resolve, it is not an easy one neither.

from unit-api.

SebHess avatar SebHess commented on June 27, 2024

@desruisseaux Yes, that is exactly what I had in mind. Note that there are empirical laws in physics and chemisty that are expressed as an arbitrary (real) power of a quantity, thus implying real power of units.

An example is the electron emission from a metal by electric and thermal effects: if the metal is cold, the current is given by the Fowler-Nordheim law and implies fractional powers of the field, while for warmer metal, the empirical thermo-field law applies, with real powers of the temperature and field.

Thus for completeness, Integer should be replaced by either Float or Double.

It is true that this issue breaks the existing API, but one solution could be replacing Map<Unit, Integer> by Map<Unit, ? extends Number> ? This would be OK API-wise and should not break existing implementation, although it would allow them to evolve toward non-integer powers of unit.

from unit-api.

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.