Skip to main content

An extensible mini-language to generate mathematical notation for executable and testable Python.

Project description

     ##### /
  ######  /
 /#   /  /
/    /  /
    /  /
   ## ##              /##    ### /### /###    ### /### /###       /###
   ## ##             / ###    ##/ ###/ /##  /  ##/ ###/ /##  /   / ###  /
   ## ##            /   ###    ##  ###/ ###/    ##  ###/ ###/   /   ###/
   ## ##           ##    ###   ##   ##   ##     ##   ##   ##   ##    ##
   ## ##           ########    ##   ##   ##     ##   ##   ##   ##    ##
   #  ##           #######     ##   ##   ##     ##   ##   ##   ##    ##
      /            ##          ##   ##   ##     ##   ##   ##   ##    ##
  /##/           / ####    /   ##   ##   ##     ##   ##   ##   ##    /#
 /  ############/   ######/    ###  ###  ###    ###  ###  ###   ####/ ##
/     #########      #####      ###  ###  ###    ###  ###  ###   ###   ##
#
 ##

PyPI version

An extensible mini-language to generate mathematical notation for executable and testable Python.

TL;DR:

  1. Write your mathematical formula with Lemma
  2. Execute them from Python code
  3. Output formula definitions in LaTeX maths notation
  4. Ensures your implementation and documentation match
  5. Great for reproducible research and teaching/learning

Le Quick Start

Follow the tutorial on Binder:

Binder

Then check out:

Le Features

  • Define mathematical formulae that can be formatted as LaTeX and executed as functions.
  • Check all of the steps in your equation transformations produce the same results in software.
  • Runs on Python - you can use defined formulae in your existing Python projects, and use Python libraries from your formulae.
  • Fully extensible - built with Hy (a Lisp running on Python) to provide powerful tools for defining your own mathematical operations.

Le Use Cases

  • Supports reproducible research by ensuring the notation in your paper matches the behaviour of your (testable) code.
  • Enables developers to work through math in a more exploratory way. Use an equation to record the steps in your step-by-step algebraic transformations, and write test-cases to check your working. Then, get the LaTeX to document your work.
  • Bridges the gap between mathematical notation and code to simplify teaching in domains that depend on both.

Le Similar Projects

  • handcalcs
    • handcalcs has a similar goal of producing LaTeX notation for your Python code, but it takes the approach of directly interpreting Python syntax. It supports some common mathematical notation, but does not appear to have the same focus on user extensibility (to new math domains) and customisability (for fine-grained control of generated notation) that Lemma does.
  • Mathematica/Wolfram Language
    • The Wolfram Language has similar motivations to Lemma around bridging the gap between mathematical notation and executable code. You can generate LaTeX from your code, but it's a proprietary language. Also, because Lemma is built on top of Python, it can work with your existing Python code and libraries.
  • SymPy
    • Like the Wolfram Language, SymPy is designed for symbolic computation. You can generate LaTeX from your expressions, but it seems that control over the notation is limited (expressions are automatically simplified, and LaTeX formatting options are controlled by keyword arguments that apply to the entire expression). Lemma is designed to be extensible so that you can define exactly how you want the LaTeX to be generated for your use case, and so that you can provide notation for any Python code you like (not just symbolic computation). A library for using SymPy's symbolic computation powers from Lemma would be a good extension though...
  • pytexit
    • Translates a string of Python code to LaTeX. Limited features supported, and requires managing Python code in strings.
  • LaTeXCalc
    • Interprets and executes LaTeX math notation. Limited library of math functions available.
  • Penrose
    • While Penrose is a math language for generating diagrams, while Lemma generates LaTeX notation and executable code.

Le TODO

  • Write tutorial
  • Add more operators to algebra.hy
  • Add unit tests

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

lemma-1.0.3.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

lemma-1.0.3-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file lemma-1.0.3.tar.gz.

File metadata

  • Download URL: lemma-1.0.3.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for lemma-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a0fa990b997e50596a2c30b438249c40d4c4be8dfc70e99b0542358ba8c3e7bc
MD5 b5cf6926cb4d888f1fa8a10abb4e1dd5
BLAKE2b-256 853978aa9df544900bea4824605dfd00740372f1255f81585a1009865d2a0763

See more details on using hashes here.

File details

Details for the file lemma-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: lemma-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for lemma-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7846ae399fe57e06138b9df6bc02630d00e75d57033b3ab210523db91f6f450d
MD5 4054ed5c8e565c0115c09212dc135492
BLAKE2b-256 f1bbd4a2d91c27538393c33141af5380e98cf21ea6ab42d8f28b7f8cdde1250d

See more details on using hashes here.

Supported by

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