Skip to main content

tools for common operations in a module

Project description

olutils

Introduction

The module olutils provide common tools to simplify project creation. It includes:

  • class with logger
  • parameter management
  • object management (copy, saving, loading)
  • plotting (if matplotlib available)

Installation

One can install olutils using pip install command:

```bash
pip install olutils
```

Usage

Use of temporal converters and deep defaultdict:

import olutils

# Building a deep default dict with datetimes as values
flights = olutils.deepdefaultdict(lambda x: None, depth=2)

# Filling it
flights['Paris-NY']['departure'] = olutils.str2dt("2019-01-15 08:00+01:00")
flights['Paris-NY']['arrival'] = olutils.str2dt("2019-01-15 10:30-05:00")
flights['NY-Paris']['departure'] = olutils.str2dt("2019-01-17 23:00-05:00")
flights['NY-Paris']['arrival'] = olutils.str2dt("2019-01-15 11:00+01:00")

flights.pprint()

File reading and object storing:

import olutils

my_dict = {'key_1': "value_1", 'key_2': 2}
my_rows = [{'col_1': 11, 'col_2': 21}, {'col_1': 21, 'col_2': 22}]

# Saving objects in output directory (automatically created)
olutils.save(my_dict, "output/my_dict.json")
olutils.save(my_rows, "output/my_rows.csv")
olutils.save(my_rows, "output/my_rows.unknown", mthd="json")

# Loading objects from save outputs
my_loaded_dict = olutils.load("output/my_dict.json")
my_loaded_rows = olutils.load("output/my_rows.csv")
my_loaded_rows_ = olutils.load("output/my_rows.unknown", mthd="json")

Multi-plotting

import matplotlib.pyplot as plt
import numpy as np

from olutils import plotiter

for i in plotiter(range(5), n_cols=3):
    x = [i + k/10 for k in range(10)]
    y = [np.sin(xk) for xk in x]
    plt.plot(x, y)

For developers

Download the project

Clone repository:

git clone https://github.com/OctaveLauby/olutils.git
cd olutils

One can make an editable code installation:

pip install -e .

Virtual Environment

python -m venv venv
source venv/Scripts/activate
python -m pip install -r requirements.txt
...
deactivate

matplotlib does not have to be imported: plotting submodule is not loaded in that case

Distribution

  1. Install distribution libraries

    pip install check-manifest
    pip install twine
    pip install wheel
    
  2. Building manifest file:

    check-manifest --create
    
  3. Building the wheel:

    python setup.py bdist_wheel
    
  4. Building the source distribution:

    python setup.py sdist
    
  5. Publishing:

    python setup.py bdist_wheel sdist
    twine upload dist/*
    

For TestPyPi publication: twine upload --repository-url https://test.pypi.org/legacy/ dist/*

Not working on Git terminal for some reason

Testing

python -m pytest olutils -vv
python -m pylint olutils --ignore-patterns=test*

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

olutils-1.1.0.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

olutils-1.1.0-py3-none-any.whl (39.2 kB view details)

Uploaded Python 3

File details

Details for the file olutils-1.1.0.tar.gz.

File metadata

  • Download URL: olutils-1.1.0.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for olutils-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7cf4f061010f38281515dc729a84ec46c773f0d3416125e8d7479b007e69aeab
MD5 54a3d394302e31643c5dfc7118c1a376
BLAKE2b-256 04259c0a564dcc796912d0852c84b312befb4f286923d9f6111f865143786677

See more details on using hashes here.

File details

Details for the file olutils-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: olutils-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 39.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for olutils-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4e29647e22739a0cbf66bd3b5ffb4e76639f983850077a3cb3992b1a134456d
MD5 978869c1da3d27a24b2f7277b043e8c3
BLAKE2b-256 c6a2260da982567926eaa5502ae68db502f6669674200c1c8b1ae304d3595d52

See more details on using hashes here.

Supported by

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