Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

lace/blmath

Repository files navigation

blmath

version license python versions

Collection of math-related utilities developed at Body Labs.

This library is deprecated. The following libraries were broken out from this package and now are maintained on their own:

  • vg is a vector-geometry toolbelt for 3D points and vectors.
    • Was blmath.numerics.vector_shortcuts
  • polliwog provides low-level functions for working with 2D and 3D geometry, optimized for cloud computation.
    • Was blmath.geometry
  • ounce is a simple package for manipulating units of measure.
    • Was blmath.units
  • entente provides functions for working with meshes and pointclouds having vertexwise correspondence.
    • Includes blmath.geometry.transform.find_rigid_transform

Also related is lacecore (the primary successor to lace) which provides polygonal meshes optimized for cloud computation.

Special mention is given to hyla, a TypeScript counterpart to polliwog.

Installation

Install dependencies

On macOS:

brew install homebrew/science/suite-sparse
brew install homebrew/science/opencv --without-numpy

On Linux:

sudo apt-get install python-opencv libsuitesparse-dev

Install the library

pip install blmath

And import it just like the upstream library:

from blmath.numerics import vx

A collection of math related utilities used by many bits of BodyLabs' code.

blmath.numerics

Functions for manipulating numeric arrays, numbers, and linear algebra.

The most commonly used of these are directly imported into blmath.numerics.

  • blmath.numerics.vx is a namespace of common linear algebra operations. These are easily expressed in numpy, but abstracted for readability purposes.
  • blmath.numerics.coercion contains a validation function as_numeric_array, which produces useful error messages up front on bad inputs, in place of cryptic messages like "cannot broadcast..." later on.
  • blmath.numerics.operations contains basic numerical operations such as zero_safe_divide.
  • blmath.numerics.predicates contains functions like isnumeric.
  • blmath.numerics.rounding contains functions including "round to nearest" and roundedlist.
  • blmath.numerics.numpy_ext contains numpy utility functions.
  • blmath.numerics.matlab contains some matlab shortcuts which have no numpy equivalent. At MPI the fitting code was originally written in Matlab before it was ported to Python.

blmath.numerics.linalg contains linear algebra operations.

blmath.geometry

Geometric operations, transforms, and primitives, in 2D and 3D.

The most commonly used of these are directly imported into blmath.geometry.

blmath.geometry.transform includes code for 3D transforms.

Other modules:

blmath.value

Class for wrapping and manipulating value/units pairs.

blmath.units

TODO write something here

blmath.console

Development

pip install -r requirements_dev.txt
pip install -e .  # builds the native extension
rake unittest
rake lint

Tests are configured to run in both python 2.7 and 3.6 locally via tox as well as in CircleCI. To run tests in multiple versions of python, run tox:

pip install -r requirements_dev.txt
tox

You need to make sure that python2.7 and python3.6 are valid commands; this can be done in pyenv via pyenv global 3.6.5 2.7.15

Acknowledgements

This collection was developed at Body Labs and includes a combination of code developed at Body Labs, from legacy code and significant new portions by Eric Rachlin, Alex Weiss, and Paul Melnikow. It was extracted from the Body Labs codebase and open-sourced by Alex Weiss. In 2018 it was forked by Paul Melnikow and published as metablmath. Thanks to a repository and package transfer from Body Labs, the fork has been merged back into the original.

License

The project is licensed under the two-clause BSD license.