Skip to main content

lsdo_function_spaces

Documentation Status Tests Python Version License: LGPL v3

lsdo_function_spaces is a pure-Python library for constructing continuous, high-dimensional, differentiable function representations (B-splines, tensor-product splines, scattered data spaces, and multivariate polynomials) tailored for gradient-based Multidisciplinary Design Optimization (MDO) and scientific computing.

📖 Online Documentation: https://lsdo-function-spaces.readthedocs.io

Developed by the Large-Scale Design Optimization (LSDO) Lab at the University of California, San Diego.


Key Features

  • Differentiable Function Spaces: Unifies Cox-de Boor B-spline curves, surfaces, and volumes, Shepard inverse distance weighting (IDW), radial basis functions (RBF), and multivariate polynomials under an extensible functional abstraction.
  • 100% Pure Python & JAX Accelerated: Zero Cython or C compiler dependencies. High-performance vectorized evaluation and projection algorithms implemented cleanly in NumPy with optional JAX JIT acceleration.
  • Vectorized Inverse Point Projection: Robust, vectorized Gauss-Newton and Levenberg-Marquardt algorithms with active-set bounds handling for projecting point clouds onto parametric spline curves, surfaces, and volumes.
  • End-to-End CSDL Graph Integration: Custom Vector-Jacobian Products (VJPs) and automatic differentiation through csdl_alpha, enabling exact analytic adjoint sensitivities across complex computational graphs.
  • Interactive & Headless 3D Visualization: Native PyVista support for visualizing spline control meshes, evaluated surface geometries, and discrete point clouds.

Architecture Overview

Subpackage Key Classes / Functions Description
lsdo_function_spaces.core.spaces BSplineSpace, FunctionSpace, ShepardSpace, PolynomialSpace, RBFSpace Core function space representations, basis function evaluations, and tensor-product constructions.
lsdo_function_spaces.core.function Function, FunctionSet Concrete functional instances binding coefficient vectors to function spaces, supporting evaluation and composition.
lsdo_function_spaces.core.spaces.non_cython_bsplines project_points_gauss_newton_numpy, project_points_lm_numpy, LMParams Vectorized inverse point projection engines utilizing active-set Levenberg-Marquardt and Gauss-Newton solvers.
lsdo_function_spaces.core.b_spline_csdl_custom_ops Custom CSDL evaluation operations Differentiable computational graph operations providing exact forward and reverse-mode derivative evaluations.

Quickstart

Creating and Evaluating a B-spline Surface

import numpy as np
import csdl_alpha as csdl
from lsdo_function_spaces import BSplineSpace, Function

# 1. Define a 2D B-spline function space (degrees 3x3, 6x6 control points)
space = BSplineSpace(
    num_dimensions=2,
    order=(4, 4),
    num_coefficients=(6, 6),
)

# 2. Assign control point coefficients (e.g. parabolic saddle surface)
u = np.linspace(0, 1, 6)
v = np.linspace(0, 1, 6)
U, V = np.meshgrid(u, v, indexing="ij")
coefficients = np.stack([U, V, U**2 - V**2], axis=-1).reshape(-1, 3)

func = Function(space=space, coefficients=coefficients)

# 3. Evaluate surface at query parametric coordinates
eval_pts = np.array([
    [0.2, 0.3],
    [0.5, 0.5],
    [0.8, 0.9],
])
physical_coords = func.evaluate(eval_pts)
print("Evaluated physical coordinates:\n", physical_coords)

Inverse Parametric Point Projection

import numpy as np
from lsdo_function_spaces.core.spaces.non_cython_bsplines.b_spline_patch_projection_optimized import (
    project_points_lm_numpy,
    LMParams,
)

# Project arbitrary 3D points onto a B-spline surface patch
points = np.array([[0.25, 0.35, 0.1]])
u0s = np.array([[0.5, 0.5]])  # Initial parametric guess

u_opt, converged, lam, res = project_points_lm_numpy(
    points=points,
    u0s=u0s,
    coeffs=coefficients,
    degrees=(3, 3),
    knot_vectors=space.knot_vectors,
    params=LMParams(max_iter=50, tol_grad=1e-8),
)
print("Converged parametric coordinate:", u_opt)

Installation

Prerequisites & Installation

lsdo_function_spaces requires Python $\ge 3.9$ and standard scientific Python packages:

# 1. Install prerequisites
pip install numpy scipy jax networkx
pip install git+https://github.com/LSDOlab/CSDL_alpha.git@dev_andrew

# 2. Install lsdo_function_spaces (User)
pip install lsdo_function_spaces
# Or install development version directly from GitHub:
pip install git+https://github.com/LSDOlab/lsdo_function_spaces.git

For Developers

Clone the repository and install in editable mode with testing and documentation dependencies:

git clone https://github.com/LSDOlab/lsdo_function_spaces.git
cd lsdo_function_spaces
pip install -e ".[test,docs]"

Testing

Run the full test suite with coverage:

pytest -v tests/ --cov=lsdo_function_spaces --cov-report=term-missing

For environments without a physical display (e.g. CI runners), run with xvfb:

xvfb-run --auto-servernum pytest -v tests/

Documentation

Official documentation, API references, tutorials, and mathematical foundations are hosted online at lsdo-function-spaces.readthedocs.io.

To build the HTML documentation locally:

sphinx-build -b html docs docs/_build/html -q -W

View the generated documentation by opening docs/_build/html/index.html in any web browser.


License

This project is licensed under the terms of the GNU Lesser General Public License v3.0 (LGPL-3.0).

Metadata

Release files for lsdo-function-spaces 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lsdo-function-spaces 1.1.0
File Size Uploaded Provenance Actions
lsdo_function_spaces-1.1.0.tar.gz 112.2 kB With provenance Details for lsdo_function_spaces-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lsdo-function-spaces 1.1.0
File Interpreter ABI Platform Actions
lsdo_function_spaces-1.1.0-py3-none-any.whl Python 3 none any Details for lsdo_function_spaces-1.1.0-py3-none-any.whl

Total release size: 224.7 kB

Release files / lsdo_function_spaces-1.1.0.tar.gz

Download URL lsdo_function_spaces-1.1.0.tar.gz
Size 112.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3c6b2e278e2dfdf37a721e7c706a61b6c19d26294e3cb404fa0c16801a4c766d
BLAKE2b-256 checksum
How to use checksums
210f1f4f646913aa016fcd1f56050c3c655b9565fd3f7c92a050bf506b20243c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / lsdo_function_spaces-1.1.0-py3-none-any.whl

Download URL lsdo_function_spaces-1.1.0-py3-none-any.whl
Size 112.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
905db19c50284cf582bfadcd08a9e2ec27d992f2b65fe09e7f4b9b9b7e3f7f0b
BLAKE2b-256 checksum
How to use checksums
0292ce1ab5748b27399b151abad5a643ddbd508a2d503789b3c904777444e42d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Security for lsdo-function-spaces 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lsdo_function_spaces-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page