Code Monkey home page Code Monkey logo

vunits's Introduction

Virtual Kinetic Laboratory Units (VUnits)

The Virtual Kinetic Laboratory Units(VUnits) is a Python library for unit conversion and constants developed by the Vlachos Research Group at the University of Delaware. This code supports Python-based Virutal Kinetic Laboratory software and aims to be lightweight.

image

Documentation

See our documentation page for examples, equations used, and docstrings.

Developers

Dependencies

  • Python3
  • Numpy: Used for vector and matrix operations
  • Pandas: (Optional) Used by testing suite to read Excel spreadsheets
  • xlrd: (Optional) Used by testing suite to read Excel spreadsheets

Getting Started

  1. Install using pip (see documentation for more thorough instructions):

    pip install vunits

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Contributing

If you have a suggestion or find a bug, please post to our Issues page with the enhancement_label or bug_label tag respectively.

Finally, if you would like to add to the body of code, please:

  • fork the development branch
  • make the desired changes
  • write the appropriate unit tests
  • submit a pull request.

Questions

If you are having issues, please post to our Issues page with the help_wanted_label or question_label tag. We will do our best to assist.

Funding

This material is based upon work supported by the Department of Energy's Office of Energy Efficient and Renewable Energy's Advanced Manufacturing Office under Award Number DE-EE0007888-9.5.

Special Thanks

  • Jaynell Keely (Logo design)

vunits's People

Contributors

jonlym avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vunits's Issues

Remove mentions of pMuTT

Most of the package was derived from pMuTT's constants module. That being said, there are some remnants of pMuTT that still need to be removed.

Saving unit database as JSON file

Currently, VUnits stores the unit database in its code, which is imported whenever the vunits.db module is accessed. However, prefixes and suffixes are added during the import process, which can slow down the initialization of the database.

One option is to save the database as a JSON file, which will probably load faster and can be updated whenever necessary.

Create more sophisticated objects to handle units

Currently, units are handled in a very simple way where inputted strings are looked up in a dictionary to produce the output (usually a float). There are several limitations, including:

  • prefix unit conversions are not robust
  • it becomes cumbersome to list all the possible unit combinations.

A (lightweight) class could be developed to handle units. A unit parser that can convert units to its fundamental SI equivalent would be useful.

Quantity's __div__ operator

The following script:

from vunits.quantity import Quantity

length = Quantity.from_units(units='m')
time = Quantity.from_units(units='s')
speed = length/time

produces the following error:

Traceback (most recent call last):
File "c:/Users/jonat/Desktop/test_qty.py", line 5, in
speed = length/time
TypeError: unsupported operand type(s) for /: 'Quantity' and 'Quantity'

This should be handled by __div__ magic method.

Plural units

Currently, VUnits only attaches an 's' to the end of long units to create the plural form. This simple approach leads to incorrect words, like "inchs".

Instead of the boolean attribute plural_allowed, units should have a string attribute indicating the suffix to use.

Add NumPy Function Compatibility

Currently, Quantity objects can hold NumPy arrays and perform unit conversions with them. For example:

>>> import numpy as np
>>> from vunits.quantity import Quantity
>>> time = Quantity.from_units(np.array([0., 1., 2.]), 'hr') 
>>> time('min') 
array([  0.,  60., 120.])

However, more complex operations (for example, taking a sum of the array) is not possible.

>>> np.sum(time)
<vunits.quantity.Quantity object at 0x000001C1EB142190>

Perhaps implementing the magic methods suggested on NumPy's Dispatch page can increase Quantity object's utility.

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.