Giter Site home page Giter Site logo

Custom radix about quantiphy HOT 8 CLOSED

kenkundert avatar kenkundert commented on June 6, 2024
Custom radix

from quantiphy.

Comments (8)

KenKundert avatar KenKundert commented on June 6, 2024

Oh my! That is quite a blunder. I'll get to work on fixing it.

from quantiphy.

KenKundert avatar KenKundert commented on June 6, 2024

Okay, I have fixed the version in github. New version is 2.8.3. I'll probably update pypi in the next few days.

Is it possible for you to check out the github version and try it out? You can let me know if you notice anything else I forgot.

from quantiphy.

zjeff222 avatar zjeff222 commented on June 6, 2024

Thanks for the fix.
The output is now working as expected, but the input is not.

from quantiphy import Quantity
Quantity.set_prefs(radix=',')
t= Quantity('3,123','m')
print(t.render())

yields 3,123 km

so we do have a comma in the output as wanted but since the quantity is now in km, it shows that the input comma was interpreted as a thousand seperator and not a radix. Maybe I was not clear in the last message - in comma radix systems, the comma is used exclusively as a radix. So 3,123 m should be equivalent to 3.123 m. Desired behavior: when radix is set to comma, reading a comma is the same as reading a point.

from quantiphy.

KenKundert avatar KenKundert commented on June 6, 2024

Actually, I had not implemented radix,comma support on the input; only on the output. However, I have updated it again and now the latest version should work. Please try the new version: 2.8.4. But you will need to set both radix and comma. By only setting radix, you still had ',' as the comma, and commas are stripped from the number.

from quantiphy.

KenKundert avatar KenKundert commented on June 6, 2024

I have updated again. It is now an error for radix and comma to be the same.

>>> from quantiphy import Quantity, QuantiPhyError                               
                                                                                 
>>> try:                                                                         
...     with Quantity.prefs(radix=','):                                          
...         q = Quantity('3,123','m')                                            
...         print(q.render())                                                    
... except QuantiPhyError as e:                                                  
...     print(e.render())                                                        
comma and radix must differ.                                                                   
                                                                                 
>>> try:                                                                         
...     with Quantity.prefs(radix=',', comma='.'):                               
...         q = Quantity('3,123','m')                                            
...         print(q.render())                                                    
... except QuantiPhyError as e:                                                  
...     print(e.render())                                                        
3,123 m                                                                          

Version is now 2.8.5.

from quantiphy.

zjeff222 avatar zjeff222 commented on June 6, 2024

Great. I did limited testing and now it works as expected for comma radix standard. Also, I noticed that when input is set with radix=',', comma=' ' (official/ISO standard in my region), the input with a dot will still work - and I think it is a good thing because not everyone uses the local standard.

thanks again

from quantiphy.

KenKundert avatar KenKundert commented on June 6, 2024

Thank you. I really appreciate you reporting these issues.
I have updated the documentation and the version, it is no 2.8.6. The additions to the documentation can be found here. I will try to update pypi to in the next few days.

from quantiphy.

KenKundert avatar KenKundert commented on June 6, 2024

I have released the fixed version (vers 2.9) on pypi.

from quantiphy.

Related Issues (19)

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.