fastcubicspline


Namefastcubicspline JSON
Version 1.1.5 PyPI version JSON
download
home_pagehttps://github.com/cimatosa/fcSpline
SummaryA fast cubic spline interpolator for real and complex data.
upload_time2023-09-01 11:16:42
maintainer
docs_urlNone
authorRichard Hartmann
requires_python>=3.9,<4.0
licenseBSD (3 clause)
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fastcubicspline
a fast cubic spline interpolator for equally spaced values and complex data

# Why not using scipy's Cubic Spline?

There are two reasons why fcSpline should be used instead 
of [scipy.interpolate.CubicSpline](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.CubicSpline.html#scipy.interpolate.CubicSpline).

1) When called in a loop, fcSpline it 3 to 5 time faster than CubicSpline (see `fcs_timing.py`).
2) Natively handles complex data.

What are the drawbacks? Well, fcSpline works on equally spaced data only.
At the moment it supports 64-floats and 128-bit compex-values 
(however, generalization should be trivial).

# Example

```python
from fastcubicspline import FCS
# set up x-limits
x_low = 1
x_high = 5

# set up the y-data, here complex values
y_data = [9+9j, 4+4j, 0, 6+6j, 2+2j]

# class init
fcs = FCS(x_low, x_high, y_data)

# simply call the FCS-object like a regular function
# to get interpolated values
print(fcs(2.5))
# (0.921875+0.921875j)
```

For convenience, this package also provides a polynomial interpolator.
Note that the NPointPoly class is not intended for time crucial applications.
```python
from fastcubicspline import NPointPoly
# the x and y values
x = [1, 2, 4, 5, 8]
y = [9 + 9j, 4 + 4j, 0, 6 + 6j, 2 + 2j]

npp = NPointPoly(x, y)
# call the NPointPoly-object to get interpolated value at any x
print(npp(2.5))
```

(see also `examples/examples.py`)

# Documentation

There is not much of an API, so there is no extra documentation page.
Everything is, however, documented by means of function annotations and doc-strings
within the code and should be visible when developing in a modern IDE.


# Install

`fastcubicspline` is on PyPi. So you can simply install the latest release with

    pip install fastcubicspline

## From Source

Fetch the latest version (or check any previous stage) 
by cloning from https://github.com/cimatosa/fcSpline.

### pip

Make sure [pip](https://pip.pypa.io/en/stable/installation/) is installed.
Change into the fcSpline package directory and run:

    python -m pip install .

See the option `--user` if you don't have the appropriate permission
for an installation to the standard location.

### poetry

Change into the fcSpline package directory.
Install `fastcubicspline` and its dependencies into a virtual environment with

    poetry install

and spawn a shell using that environment `poetry shell`.
Now you can check if the tests pass with `pytest`.
`poetry install` should build the cython extension which you cen check with `pytest -v -k cython`. 

In case of poetry errors, you might want to get the latest poetry version
with `poetry self update`.

### Manually Build Cython Extension

Some distutils magic is contained in `build_ext.py` so you can simply call

    python3 build_ext.py

to build the Cython extension inplace.
Run `pytest -v -k cython` to verify that the Cython extension is available.

Clean the build files by calling

    python3 build_ext.py clean


# Testing

Run and list all tests with

    pytest -v

# References

    * Press, W.H., Teukolsky, S.A., Vetterling, W.T., Flannery, B.P., 2007.
      Numerical Recipes 3rd Edition: The Art of Scientific Computing,
      Auflage: 3. ed. Cambridge University Press, Cambridge, UK; New York.

    * Wikipedia, Retrieved September 1, 2023, from 
      https://en.wikipedia.org/wiki/Finite_difference_coefficient#Forward_finite_difference

# MIT licence
Copyright (c) 2023 Richard Hartmann

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cimatosa/fcSpline",
    "name": "fastcubicspline",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Richard Hartmann",
    "author_email": "richard.hartmann@tu-dresden.de",
    "download_url": "https://files.pythonhosted.org/packages/17/83/6202c8b21a91c861b2da50845d79fa045461f4fb258b535088531dc79d1b/fastcubicspline-1.1.5.tar.gz",
    "platform": null,
    "description": "# fastcubicspline\na fast cubic spline interpolator for equally spaced values and complex data\n\n# Why not using scipy's Cubic Spline?\n\nThere are two reasons why fcSpline should be used instead \nof [scipy.interpolate.CubicSpline](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.CubicSpline.html#scipy.interpolate.CubicSpline).\n\n1) When called in a loop, fcSpline it 3 to 5 time faster than CubicSpline (see `fcs_timing.py`).\n2) Natively handles complex data.\n\nWhat are the drawbacks? Well, fcSpline works on equally spaced data only.\nAt the moment it supports 64-floats and 128-bit compex-values \n(however, generalization should be trivial).\n\n# Example\n\n```python\nfrom fastcubicspline import FCS\n# set up x-limits\nx_low = 1\nx_high = 5\n\n# set up the y-data, here complex values\ny_data = [9+9j, 4+4j, 0, 6+6j, 2+2j]\n\n# class init\nfcs = FCS(x_low, x_high, y_data)\n\n# simply call the FCS-object like a regular function\n# to get interpolated values\nprint(fcs(2.5))\n# (0.921875+0.921875j)\n```\n\nFor convenience, this package also provides a polynomial interpolator.\nNote that the NPointPoly class is not intended for time crucial applications.\n```python\nfrom fastcubicspline import NPointPoly\n# the x and y values\nx = [1, 2, 4, 5, 8]\ny = [9 + 9j, 4 + 4j, 0, 6 + 6j, 2 + 2j]\n\nnpp = NPointPoly(x, y)\n# call the NPointPoly-object to get interpolated value at any x\nprint(npp(2.5))\n```\n\n(see also `examples/examples.py`)\n\n# Documentation\n\nThere is not much of an API, so there is no extra documentation page.\nEverything is, however, documented by means of function annotations and doc-strings\nwithin the code and should be visible when developing in a modern IDE.\n\n\n# Install\n\n`fastcubicspline` is on PyPi. So you can simply install the latest release with\n\n    pip install fastcubicspline\n\n## From Source\n\nFetch the latest version (or check any previous stage) \nby cloning from https://github.com/cimatosa/fcSpline.\n\n### pip\n\nMake sure [pip](https://pip.pypa.io/en/stable/installation/) is installed.\nChange into the fcSpline package directory and run:\n\n    python -m pip install .\n\nSee the option `--user` if you don't have the appropriate permission\nfor an installation to the standard location.\n\n### poetry\n\nChange into the fcSpline package directory.\nInstall `fastcubicspline` and its dependencies into a virtual environment with\n\n    poetry install\n\nand spawn a shell using that environment `poetry shell`.\nNow you can check if the tests pass with `pytest`.\n`poetry install` should build the cython extension which you cen check with `pytest -v -k cython`. \n\nIn case of poetry errors, you might want to get the latest poetry version\nwith `poetry self update`.\n\n### Manually Build Cython Extension\n\nSome distutils magic is contained in `build_ext.py` so you can simply call\n\n    python3 build_ext.py\n\nto build the Cython extension inplace.\nRun `pytest -v -k cython` to verify that the Cython extension is available.\n\nClean the build files by calling\n\n    python3 build_ext.py clean\n\n\n# Testing\n\nRun and list all tests with\n\n    pytest -v\n\n# References\n\n    * Press, W.H., Teukolsky, S.A., Vetterling, W.T., Flannery, B.P., 2007.\n      Numerical Recipes 3rd Edition: The Art of Scientific Computing,\n      Auflage: 3. ed. Cambridge University Press, Cambridge, UK; New York.\n\n    * Wikipedia, Retrieved September 1, 2023, from \n      https://en.wikipedia.org/wiki/Finite_difference_coefficient#Forward_finite_difference\n\n# MIT licence\nCopyright (c) 2023 Richard Hartmann\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n",
    "bugtrack_url": null,
    "license": "BSD (3 clause)",
    "summary": "A fast cubic spline interpolator for real and complex data.",
    "version": "1.1.5",
    "project_urls": {
        "Homepage": "https://github.com/cimatosa/fcSpline",
        "Repository": "https://github.com/cimatosa/fcSpline"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b7ceb9afac2564dbdfc510446e663cbdfb5fa6650f0d134306c232e68887dd82",
                "md5": "d442785e5a827b331253c062c769ac9d",
                "sha256": "cce5056ebc0623d2ce41689c22a5c47a1a84f6c3ce1e77240a4f80e4a0957091"
            },
            "downloads": -1,
            "filename": "fastcubicspline-1.1.5-cp311-cp311-manylinux_2_36_x86_64.whl",
            "has_sig": false,
            "md5_digest": "d442785e5a827b331253c062c769ac9d",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.9,<4.0",
            "size": 293863,
            "upload_time": "2023-09-01T11:16:40",
            "upload_time_iso_8601": "2023-09-01T11:16:40.525733Z",
            "url": "https://files.pythonhosted.org/packages/b7/ce/b9afac2564dbdfc510446e663cbdfb5fa6650f0d134306c232e68887dd82/fastcubicspline-1.1.5-cp311-cp311-manylinux_2_36_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "17836202c8b21a91c861b2da50845d79fa045461f4fb258b535088531dc79d1b",
                "md5": "63143a6a92b01781fc86431a7342f0cc",
                "sha256": "7b83ac18d1c06f0c1197ae6c628c9b74f0b55aae3f62c253165cb351f3354c73"
            },
            "downloads": -1,
            "filename": "fastcubicspline-1.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "63143a6a92b01781fc86431a7342f0cc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 164692,
            "upload_time": "2023-09-01T11:16:42",
            "upload_time_iso_8601": "2023-09-01T11:16:42.360630Z",
            "url": "https://files.pythonhosted.org/packages/17/83/6202c8b21a91c861b2da50845d79fa045461f4fb258b535088531dc79d1b/fastcubicspline-1.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-01 11:16:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cimatosa",
    "github_project": "fcSpline",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "fastcubicspline"
}
        
Elapsed time: 0.11886s