Skip to content

A cookbook for the python developer connoisseur πŸπŸ§‘πŸ½β€πŸ³πŸ·

License

Notifications You must be signed in to change notification settings

astromancer/recipes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

recipes

A cookbook for the python developer connoisseur 🐍 πŸ“– 🍾

This project contains a curated collection of convenient utility functions that are useful across many projects. The library extends many of the python builtin modules' functionalities, and is therefore similarly structured.

Below are some highlights of the available modules and their functionality:

Recipes extending builtins

  • strings : _substitution, character deletion, affix editing, case switching, pluralization, similarity matching, bracket parsing, and more ...
  • lists : co-sorting, multi-indexing, conditional splitting, deduplication.
  • dicts
    • core : Attribute dicts, many-to-one maps, autovivification, tree-like mappings, ordered defaultdict, pretty printing, and various other mapping utilities.
    • node : A powerful dictionary node object for creating and manipulating data trees.
  • sets : Ordered sets
  • op : Drop in replacement for the builtin operator module with added support for default values. And then some.

Iterators / Generators

  • iter : Additional iteration utilities: co-filtering, conditional indexing.

Functional programming

  • functionals : Funtional utilities: Factory for creating callables with any signature; partial functions definitions via parameter placeholder syntax.
  • decorators : Extensible decorators for: Control flow (catching exceptions, fallback values), parameter/return value tracing, line profiling.
  • caching : Performant functional memoization.

Object Oriented Tools

  • oo : Cached property decorator (with optional dependencies), property forwarding for nested objects, constructors for objects employing __slots__, context manager for temporary attribute setting.
    • meta : Tools for building classes, function tagging.

API and Development helpers

  • api
    • synonyms : Intelligent parameter name autocorrect decorator for building flexible APIs.
  • pprint : pretty printing!
  • logging : logging mixin for explicitly tracing class functionality.

Input / Output

  • io : File tree iteration, context managers for safe input/output with file backups, flexible (de)serialization wrappers.

Code Introspection

  • introspect : Inspect python objects.
    • imports : Refactor (sort, merge, split, relativize, (de)localize etc.) import statements in python source code.

Math

  • transforms : Transforms to and from Cartesian, Spherical, Cylindrical coordinates.

Arrays

  • array
    • fold : Array folding (windowing) with minimal memory duplication.

Install

python -m pip install https://github.com/astromancer/recipes

Test

The test suite contains further examples of how recipes can be used. Testing is done with pytest:

pytest recipes

Contribute

Contributions are welcome!

  1. Fork it!
  2. Create your feature branch
    git checkout -b feature/rad
  3. Commit your changes
    git commit -am 'Add some cool feature 😎'
  4. Push to the branch
    git push origin feature/rad
  5. Create a new Pull Request

Contact

License

About

A cookbook for the python developer connoisseur πŸπŸ§‘πŸ½β€πŸ³πŸ·

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages