Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Display numbers in scientific notation.

Project Description

This package expresses numbers in scientific notation, in formatted strings. Its intended use is to make computational results easier to read, especially when using a REPL like IPython. If using IPython, output is color-coded, to visually diferentiate the base and power.

Installation:

pip install scinot

Python 2 is unsupported, due to unicode handling.

Use: Run scinot.start() to format REPL output and printing as scientific notation.

341283875012.238

>> 341283875012.238

import scinot

scinot.start()
341283875012.238

>> 3.413 x 10 11

Call scinot.end() to return to remove parsing:

scinot.end()

341283875012.238

>> 341283875012.238

You can specify the number of significant figures to display with start, and how long the number must be to invoke scientific notation. It defaults to 4 significant figures, and order-of-magnitude 4:

scinot.start(sigfigs=2, thresh=3)
15

>> 15

152

>> 1.5 x 10 2

Call scinot.format() to return a string in scientific notation:

scinot.format(341283875012.238)

>> ‘3.413 x 10 11

You can also specify the number of significant figures to display; it defaults to 3.

scinot.format(-.00000409348, 2)

>> ‘-4.1 x 10 -6

Call scinot.sciprint() instead of scinot.format() to print the result directly, rather than returning a string. format and sciprint both take two arguments: The number, and optionally, the amount of significant figures.

If you’re running Python in a Windows terminal and see squares instead of exponents, try a different font, like Source Code Pro. Scinot’s start() behavior will not work if sympy.init_printing() is activated.

I’ve built this module with my own use-case in mind, and have likely overlooked features that would extend and improve functionality. If you have an idea, please contact me, or submit a pull request.

Note: Color, and the proper times symbol are used in the package, but are not displayed in this readme due to RST limitations.

Release History

This version
History Node

0.0.9

History Node

0.0.8

History Node

0.0.7

History Node

0.0.6

History Node

0.0.5

History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
scinot-0.0.9-py3-none-any.whl
(6.7 kB) Copy SHA256 Hash SHA256
py3 Wheel Jan 18, 2018
scinot-0.0.9.tar.gz
(4.5 kB) Copy SHA256 Hash SHA256
Source Jan 18, 2018

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting