Skip to content

Commit

Permalink
add installation and example to readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengp0 committed Aug 4, 2023
1 parent c9ac1e3 commit dfe9d45
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 3 deletions.
60 changes: 60 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,63 @@ XSpline
=======

Advanced spline package that provides b-spline bases, their derivatives and integrals.


Installation
------------

XSpline can be install via

.. code-block:: bash
pip install xspline>=0.1.0
Requirements
------------

XSpline requires python 3.10 or higher. XSpline only depends on ``numpy>=1.25.1``.


Usage
-----

There are two main use-cases.

.. code-block:: python
import numpy as np
import matplotlib.pyplot as plt
from xspline import XSpline
spline = XSpline(knots=[0, 0.25, 0.5, 0.75, 1], degree=3)
x = np.arange(0, 1.01, 0.01)
one is to use XSpline as a univariate function. In this case, user must provide
coefficients for the spline bases.

.. code-block:: python
np.random.seed(123)
spline.coef = np.random.randn(len(spline))
y = spline(x)
fig, ax = plt.subplots(figsize=(8, 3))
ax.plot(x, y)
ax.set_title("Usecase 1", loc="left")
.. image:: images/readme_usage_0.png
:alt: usecase_1

The other is to obtain the design matrix for other modeling uses.

.. code-block:: python
design_mat = spline.get_design_mat(x)
fig, ax = plt.subplots(figsize=(8, 3))
ax.plot(x, design_mat)
.. image:: images/readme_usage_1.png
:alt: usecase_2
Binary file added images/readme_usage_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/readme_usage_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ build-backend = "setuptools.build_meta"

[project]
name = "xspline"
version = "1.0.0"
version = "0.1.0"
description = "Advanced spline package that provides b-spline bases, their derivatives and integrals"
readme = "REDME.rst"
requires-python = ">=3.10"
license = { file = "LICENSE" }
authors = [
{ name = "IHME Math Sciences", email = "ihme.math.sciences@gmail.com" },
]
dependencies = ["numpy"]
dependencies = ["numpy>=1.25.1"]

[project.optional-dependencies]
test = ["pytest"]
Expand All @@ -25,4 +25,4 @@ github = "https://github.com/zhengp0/xspline"
project = "xspline"
author = "IHME Math Sciences"
copyright = "2023, IHME Math Sciences"
version = "1.0.0"
version = "0.1.0"

0 comments on commit dfe9d45

Please sign in to comment.