Giter VIP home page Giter VIP logo

eseries's Introduction

eseries

The E-series is a system of preferred numbers used with electronic components such as resistors and capacitors. For example, the E6 series contains six values (10, 15, 22, 33, 47, 68) which cover a one-order of magnitude range of values (one decade) from 10 to 99. These base values repeat again to cover the next decade from 100 to 999, as 100, 220, 330, 470, and 680.

This eseries library is useful for selecting values from the standard E3, E6, E12, E24, E48, E96 and E192 decades.

Status

https://coveralls.io/repos/github/rob-smallshire/eseries/badge.svg?branch=master

Installation

The eseries package is available on the Python Package Index (PyPI):

The package supports Python 3 and is compatible to Python 2.7. To install:

$ pip install eseries

Python Interface

For full help:

>>> import eseries
>>> help(eseries)

In the meantime, here are some highlights.

To find the nearest E24 value to 319 use:

>>> from eseries import find_nearest, E24
>>> find_nearest(E24, 319)
330

To find the next value greater-than or equal-to 184 in the E96 series use:

>>> from eseries import find_greater_than_or_equal, E96
>>> find_greater_than_or_equal(E96, 184)
187

To find a few values around the specified value, use:

>>> from eseries import find_nearest_few, E24
>>> find_nearest_few(E24, 5000)
(4700, 5100, 5600)

Command-Line Interface

There's also a handy command-line interface. Run eseries --help to see a list of commands:

 $ eseries --help
 eseries

 Usage: eseries [options] <command> [<args> ...]

 Options:
   -h --help     Show this screen.
   -v --verbose  Use verbose logging

Available commands:
   ge
   gt
   help
   le
   lower-tolerance-limit
   lt
   nearby
   nearest
   range
   series
   tolerance
   tolerance-limits
   upper-tolerance-limit

 See 'eseries help <command>' for help on specific commands.

To find a nearby value, use:

$ eseries nearest E24 37726
39e3

If you prefer an SI exponent symbol, supply --symbol or -s:

$ eseries nearest E24 37726 -s
39 k

To show values around the given value, use the nearby command:

$ eseries nearby E48 52e6 -s
48.7 M
51.1 M
53.6 M

To show the smallest value greater than or equal to the given value, use the ge command:

$ eseries ge E48 52e3 -s
53.6 k

To show the upper and lower tolerance limits of a nominal value, use the tolerance-limits command:

$ eseries tolerance-limits E48 35
34.3
35.7

To show all values in an inclusive range, use the range command:

$ eseries range E6 74e-9 34e-6 --symbol
100 n
150 n
220 n
330 n
470 n
680 n
1 µ
1.5 µ
2.2 µ
3.3 µ
4.7 µ
6.8 µ
10 µ
15 µ
22 µ
33 µ

Testing

Testing is performed for all supported versions using tox. You'll need to ensure that the required Python versions are available in your environment. For example, if you're using pyenv, do:

$ pyenv local 2.7 3.6 3.7 3.8 3.9 3.10 3.11 3.12

before running tox:

$ tox

Deployment to PyPI

$ pip install -e ".[dev]"
$ bumpversion patch
$ python setup.py sdist bdist_wheel
$ twine upload --config-file <path>/credentials.pypirc dist/*
$ git push origin

eseries's People

Contributors

rob-smallshire avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eseries's Issues

Dropping Python2 support?

Looking at the nice and well documented code and seeing the overhead of Python2 support I think Python2 support could be dropped. Going for Python >=3.7 you could use formatted strings and type annotations.

I'm willing to help with a pull request, if this issue will be supported. Otherwise just close this issue.

Class based implementation

I started experimenting with a class based implementation. This is not a proposal to change the API - just wanted do hear what you think. You find the implementation here: https://github.com/semiversus/eseries/tree/class_based

In case of going towards a class based implementation, it would be easy to keep the API backwards compatible by providing wrapper functions:

def find_greater_than_or_equal(series_key, value):
  return series_key.find_greater_than_or_equal(value)

pip command failed

WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000002199753F3D0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/eseries/
ERROR: Could not find a version that satisfies the requirement eseries (from versions: none)
ERROR: No matching distribution found for eseries

cli crashes

When running eseries from cli:

Traceback (most recent call last):
  File "/Users/lkostka/.local/share/virtualenvs/es-T3qevpNt/bin/eseries", line 8, in <module>
    sys.exit(main())
  File "/Users/lkostka/.local/share/virtualenvs/es-T3qevpNt/lib/python3.7/site-packages/eseries/cli.py", line 269, in main
    exit_at_end=False)
TypeError: main() got an unexpected keyword argument 'version'

Python 3.7.7
docopt 0.6.2
docopt-subcommands 4.0.0
eseries 1.1.1

Incompatible with Python 3.12

eseries can be installed, but importing the library, the following error occurs (on python 3.12):

>>> import eseries
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/.local/lib/python3.12/site-packages/eseries/__init__.py", line 5, in <module>
    from future import standard_library
  File "~/.local/lib/python3.12/site-packages/future/standard_library/__init__.py", line 65, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'

The imp module has been deprecated since python 3.12. Maybe the easiest fix is to drop Python 2 support? Tell me, if I can help with a pull request.

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.