Git Product home page Git Product logo

dimana's People

Contributors

nejucomo avatar

Watchers

 avatar

dimana's Issues

Add a value parser which is the inverse of __repr__.

It would be convenient to have parsers for both a unit specification and a complete value.

These would look something like:

>>> Watt = dimana.parse_unit('KG * M^2 / SEC^3')
>>> x = Watt(3)
>>> x
3 [KG * M^2 / SEC^3]
>>> x == dimana.parse('3.000 [KG * M^2 / SEC^3]')
True

failed to figure out how to multiple unity number by unitless number

I had a unity number stored in a variable named T1, and then I did this::

>>> from decimal import Decimal
>>> D=Decimal
>>> D('0.16') * T1 - O1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for *: 'Decimal' and 'Dimensional_Units_1'

I had expected it to multiple T1 by the (dimensionless) 0.16 for me.

Allegedly there is a way to do this in dimana, using dimana.Dimensional('0.16) instead of Decimal('0.16'). So I have several requests/suggestions:

  1. The initial docs for dimana should mention how to create dimensionless numbers.
  2. Waitaminute, the way to create a dimensionless number is with a constructor named Dimensional? That sounds wrong.
  3. Is there a reason not to promote Decimals automatically to Dimensionlesses? I guess there's a risk that a user would have a number stored in a Decimal when they intended it to be a dimensioned number, like the number of Frobs, and forcing them to explicitly put Dimensionless('0.19') would let them realize that they actually need Dimensional.get_dimension('Frobs'). But I'm skeptical—why does Dimensionless('0.19') help them notice that any better than Decimal('0.19') helps them notice?

Clarify type policy and rename Dimensional to Dimana.

In #1 @zooko considers it confusing that Dimensional('1.0') is unitless, and also asks why not automatically coerce Decimals to unitless Dimensionals.

The docs should clarify the type checking philosophy of dimana, which is to always require application code to be explicit, and never to coerce values.

Rather than justify to users why a value without dimensional units is still considered "dimensional", just rename the class to Dimana to reinforce the fact that it's a particular abstraction with a particular API, and to avoid different assumptions different users may have depending on their backgrounds.

Add explicit unit test coverage for dimensionless units.

The unittests only exercise dimensionless units by dint of being the result of raising a dimensional quantity to the zero-th power. It would be nice to have more tests which use dimensionless quantities, such as ratios, and zero powers.

Note: This is related to a user experience in #1.

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.