Skip to main content

This package wraps the C functions in hdcms

Project description

hdcms-bindings

This is a wrapper for the hdcms C source. It is not meant to be used as a standalone package. Use hdcms instead.

The current dependency graph for the projects is as follows:

hdcms (C files source + binary) -> hdcms-bindings (C-extension/.so file) -> hdcms (python functions)

This project (the middle one) isn't meant to be used as a standalone project, but I couldn't get python to generate the C-extension and export python functionality in the same package which is why I split it up. If you would like to use it however, it is available at pypi here.

Examples

import hdcms_bindings as hdcbind
c9 = hdcbind.filenames_to_stats_1d("data/CM1_9_1.txt,data/CM1_9_2.txt,data/CM1_9_3.txt")
c10 = hdcbind.filenames_to_stats_1d("data/CM1_10_1.txt,data/CM1_10_2.txt,data/CM1_10_3.txt")
c3 = hdcbind.filenames_to_stats_1d("data/CM1_3_1.txt,data/CM1_3_2.txt,data/CM1_3_3.txt")
print(hdcbind.compare_compound_1d(c10, c8), "\n")
print(hdcbind.compare_all_1d([c10,c8,c9]))

You can also use the 2d functions by changing the _1d suffix to _2d.

Extending

If you extend this code, think carefully about who has owner ship over the data in a vector/matrix and the numpy reference count. The only way this would be tricky is if a matrix struct exists in two functions, and you can't tell one of the function's matrix that it doesn't own the data anymore, and you give the data to a NUMPY function and it get garbage collected and frees its data (now the matrix struct thinks it has valid data when it doesn't). I'm pretty sure I don't make this mistake, but it would be easy to make in the future. The fix is just to copy the data (which will make it slightly inefficient, but that's okay).

References

check pointer types example

Official documentation

https://docs.python.org/3/c-api/arg.html#other-objects https://docs.python.org/3/extending/extending.html#building-arbitrary-values https://numpy.org/doc/stable/user/c-info.how-to-extend.html https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_SimpleNew https://numpy.org/doc/stable/reference/c-api/dtype.html

Changelog

0.1.1 Rename package

0.1.0 Add documentation

0.0.8 Add keyword args: adding desingularization and max_peaks to the filenames_to_stats functions, and start, end, and num_bins to the comparison functions. They all are initalized with the default args they had before.

0.0.7 Change strlcpy to strncpy for Linux

0.0.6 Ignore headers in data files

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

hdcms-bindings-0.1.1.tar.gz (24.7 kB view hashes)

Uploaded Source

Built Distribution

hdcms_bindings-0.1.1-cp38-cp38-macosx_11_0_arm64.whl (24.4 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

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