Skip to main content

Basic Python Tools; upgraded cdxbasics

Project description

cdxcore documentation

This module contains a number of lightweight tools, developed for managing data analytics and machine learning projects.

Install using:

pip install -U cdxcore

Documentation can be found here: https://quantitative-research.de/docs/cdxcore. cdxcore is best used with Python 3.12 and above, but is tested vs Python 3.10 onwards.

Highlights

  • Dynamic plotting: simple live/animated plots built on Matplotlib.
  • Config management: validated, discoverable configurations with automatic help.
  • Versioning & caching: code-versioned I/O and reproducible hashing for pipelines.
  • PrettyObject: dictionary-like objects that allow attribute access.
  • Utilities: formatting helpers, binary I/O, shared-memory arrays, and more.

Main Functionality

  • cdxcore.dynaplot is a framework for simple dynamic graphs with matplotlib. It has a simple methodology for animated updates for graphs (e.g. during training runs), and allows generation of plot layouts without knowing upfront the number of plots (e.g. for plotting a list of features).

    Aninmated 3D plot

  • cdxcore.config allows robust management of configurations. It automates help, validation checking, and detects misspelled configuration arguments.

    from cdxcore.config import Config, Int, Float
    
    class Network(object):
        def __init__( self, config ):
            self.depth      = config("depth", 1, Int>0, "Depth of the network")
            self.width      = config("width", 1, Int>0, "Width of the network")
            self.activation = config("activation", "selu", str, "Activation function")
            config.done() # see below
    
    config = Config()
    config.network.depth         = 10
    config.network.width         = 100
    config.network.activation    = 'relu'
    
    network = Network(config.network)
    config.done()
    
  • cdxcore.subdir wraps various file and directory functions into convenient objects. Useful if files have common extensions.

    from cdxcore.subdir import SubDir
    import numpy as np
    root   = SubDir("!")   # current temp directory
    subdir = root("test")  # sub-directory 'test'
    subdir.write("data", np.zeros((10,2)))
    data   = subdir.read("data")
    
  • Caching: SubDir supports code-versioned file i/o which is used by @cdxcore.subdir.SubDir.cache for an efficient code-versioned caching protocol for functions and objects:

from cdxcore.subdir import SubDir
cache   = SubDir("!/.cache;*.bin")

@cache.cache("0.1")
def f(x,y):
   return x*y

_ = f(1,2)    # function gets computed and the result cached
_ = f(1,2)    # restore result from cache
_ = f(2,2)    # different parameters: compute and store result
  • Code versioning is implemented in cdxcore.version:

    from cdxbasics.version import version
    
    @version("0.0.1")
    def f(x):
        return x
    
    print( f.version.full )   # -> 0.0.1
    
  • Hashing (which is used for caching above) is implemented in cdxcore.uniquehash:

    class A(object):
        def __init__(self, x):
            self.x = x
            self._y = x*2  # protected member will not be hashed by default
    
    from cdxcore.uniquehash import UniqueHash
    uniqueHash = UniqueHash(length=12)
    a = A(2)
    print( uniqueHash(a) ) # --> "2d1dc3767730"
    
  • cdxcore.pretty provides a PrettyObject class whose objects operate like dictionaries. This is for users who prefer attribute . notation over item access when building structured output.

    from cdxbasics.prettydict import PrettyObject
    pdct = PrettyObject(z=1)
    
    pdct.num_samples = 1000
    pdct.num_batches = 100
    pdct.method = "signature"
    

General purpose utilities

  • cdxcore.verbose provides user-controllable context output for providing progress updates to users.

  • cdxcore.util offers a number of utility functions such as standard formatting for dates, big numbers, lists, dictionaries etc.

  • cdxcore.npio provides a low level binary i/o interface for numpy files.

  • cdxcore.npshm provides shared memory numpy arrays.

Project details


Download files

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

Source Distribution

cdxcore-0.1.79.tar.gz (258.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdxcore-0.1.79-py3-none-any.whl (275.9 kB view details)

Uploaded Python 3

File details

Details for the file cdxcore-0.1.79.tar.gz.

File metadata

  • Download URL: cdxcore-0.1.79.tar.gz
  • Upload date:
  • Size: 258.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for cdxcore-0.1.79.tar.gz
Algorithm Hash digest
SHA256 7362ee6f4618db95e18e308348cfad72cb9c2d1859dae9315ca6d67f47009b2f
MD5 19660b339800a95b86b1057b45f6f257
BLAKE2b-256 7d86ba6b29170e649ed118ecdfc5218b6222639f5e2d80953f9ab5e5a9e6505a

See more details on using hashes here.

File details

Details for the file cdxcore-0.1.79-py3-none-any.whl.

File metadata

  • Download URL: cdxcore-0.1.79-py3-none-any.whl
  • Upload date:
  • Size: 275.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for cdxcore-0.1.79-py3-none-any.whl
Algorithm Hash digest
SHA256 3d3e49f43a37a803877cedf58395350a25184f31608657e5c74bd1f2e99216c4
MD5 70852a5b8cac8e6115eaf2eddac19fcb
BLAKE2b-256 172915e0b175c7a6c53b80382e217949499c3716a492097e76a8c677c6d32ac1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page