Skip to main content

justbases-string

Purpose

A small library for generating a human readable string value from a number with an arbitrary base. The number is represented by five elements:

  • a sign

    -1, 1, or 0 as appropriate

  • an integer part

    a list of non-negative ints, where each element is less than the base value

  • a non repeating fractional part

    a list of non-negative ints, where each element is less than the base value

  • a repeating fractional part

    a list of non-negative ints, where each element is less than the base value

  • a base

    the base of the number, must be an integer greater than 1.

Usage

>>> from justbases_string import *
>>> xformer = String(DisplayConfig(), 2)
>>> xformer.xform(-1, [1, 0, 1], [], [1, 0], 0)
'-101.(10)_2'
>>> xformer.xform(0, [], [0, 0], [], 0)
'0_2'

An exception is raised if the parts of the number do not conform to the necessary constraints:

>>> xformer.xform(1, [2], [0, 0], [], 0)
Traceback (most recent call last):
...

>>> xformer.xform(1, [-1], [0, 0], [], 0)
Traceback (most recent call last):
...

There are numerous options for configuring the string result:

>>> digits_config = DigitsConfig(use_letters=False)
>>> xformer = String(DisplayConfig(digits_config=digits_config), 1024)
>>> xformer.xform(1, [2], [2, 4, 256], [], 0)
'2.2~4~256_1024'

>>> digits_config = DigitsConfig(use_caps=True)
>>> xformer = String(DisplayConfig(digits_config=digits_config), 16)
>>> xformer.xform(1, [], [0, 13], [], 0)
'0.0D_16'

The final argument is the relation of the value being displayed to the value it represents:

>>> xformer.xform(1, [2], [2, 4, 256], [], Fraction(1, 3))
'< 2.2~4~256_1024'

Metadata

Release files for justbases-string 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for justbases-string 0.1
File Size Uploaded Provenance
justbases-string-0.1.tar.gz 14.3 kB Without provenance Details

Release files / justbases-string-0.1.tar.gz

Download URL justbases-string-0.1.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4d6f3260cd80c30b2396a9a034a858726a3922c0ab83610e1294da616e5e1ede
BLAKE2b-256 checksum
How to use checksums
9d9676a4b4b30e37b911e3804cdecbd1a95ea9ea7da6b1f9a3ac3577587d0bfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for justbases-string 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page