PHuN representations
This is a fun and computationally efficient Python package for computing persistent homology using nets (PHuN) representations of nanoporous materials. It enables the extraction of topological information for use as machine learning descriptors.
Installation Guide
Prerequisites
PHuN requires the CrystalNets.jl Julia interface, which is used to identify and extract the topological nets of crystalline structures.
Install phun_reps using pip
pip install phun_reps
This package was built and tested with Python 3.10.13,
and will automatically install its dependencies:
ase==3.26.0, Cython==3.2.0, juliacall==0.9.28, pandas==2.3.3, ripser==0.6.12 and gudhi==3.11.0
Usage
PHuN provides tools to compute persistent homology diagrams for nanoporous materials using either:
-
Atomic coordinates
-
Topological nets derived from CrystalNets.jl.
It integrates with Ripser and Gudhi to compute persistence diagrams and can extract topological descriptors that can be used in machine learning.
PHuN can be used to:
-
Generate persistent diagrams/images from CIF files
-
Visualize persistence diagrams/images
-
Extract vectorized topological descriptors (persistent image features and persistent statistics features
For a complete example of usage, see the Example Usage section below.
Example Usage
Initial setup
# Folder containing .cif files to process
folder = "test-cif"
Load .cif files
import phun_reps.calc_presistent_diagram as cp
# Load .cif files from the specified folder
files = cp.get_cif_files(folder)
Extract point clouds for .cif
import phun_reps.topology as tp
# Initate point cloud extraction. This class handles the conversion of .cif files to point clouds and topological net identification.
# This is used to generate the point cloud representations for persistent homology and to determine the topological net labels for each structure.
extractor = tp.PointCloudExtractor()
# Build CrystalNets.jl topology analysis options
options = extractor.build_options(
structure="MOF", # Structure type
clusterings=["SingleNodes"], # Clustering strategy
export_input=False, # Do not export CrystalNets input
export_net=False, # Do not export identified net files
export_subnets=False, # Do not export subnet files
detect_organiccycles=True # Detect organic cycles/rings
)
# Generate point cloud representation for topological net
# CrystalNets.jl is used to determine the topological net
dataset, name = extractor.get_PHuN_points(file,options=options, supercell=None, subnet_mode="full")
# The name of the topological net can also be determined
top_net = extractor.determine_topology( file, options=options)
The atomic coordinates of the .cif can also be used to generate a point cloud.
dataset, name = extractor.get_ACPH_points(file, supercell=None)
Compute persistent diagrams
import phun_reps.calc_presistent_diagram as cp
# Compute persistent homology diagrams from the dataset
diagrams = cp.calc_persistent_diagrams(
dataset,
file=name,
top_net=top_net,
maxdim=2, # Compute H0, H1, and H2
coeff=2, # Z2 coefficients
complex_type="alpha", # Alpha complex
)
The persistent diagrams can be plotted and save
# Save all persistent diagrams as a pickle file
cp.save_diagrams("persistent_diagrams.pkl", diagrams_list)
# Export persistent diagram figures
cp.plot_persistent_diagrams(diagrams_list, export_folder="diagrams")
Extract persistent image features from diagrams using persim
import phun_reps.feature_extraction as fe
image_features_df = fe.get_persistent_image_features(
diagrams_list,
output_size=(30, 30), # Persistent image resolution
savefig=True, # Save persistent image figures
export_folder="test_images",
)
Extract statistical features from persistent diagrams
import phun_reps.feature_extraction as fe
stats_features_df = fe.get_persistent_stats_features(diagrams_list)
The examples folder contains a full example script along with example inputs and outputs.
Metadata
Release files for phun-reps 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| phun_reps-0.1.4.tar.gz | 11.9 kB | Without provenance | Details for phun_reps-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| phun_reps-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for phun_reps-0.1.4-py3-none-any.whl |
Total release size: 23.3 kB
Release files / phun_reps-0.1.4.tar.gz
| Download URL | phun_reps-0.1.4.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb8d49decde47fc2a9ec0d1065ca92509137c87152605d3c3bd2e5525d8c5e62
|
|
BLAKE2b-256 checksum How to use checksums |
17afff1fed668e57294b42314a149f501cf1d7c63d411f797e4bd0e6ffbb4e85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.13
|
Release files / phun_reps-0.1.4-py3-none-any.whl
| Download URL | phun_reps-0.1.4-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86ad118514a1402a47142c4080c06acc0a5a9b228cee65b04b43560a3550e6fd
|
|
BLAKE2b-256 checksum How to use checksums |
6af93266efb554cfae9604f8d4311f1e806188d1097f2e6c1d9a13b40ccf15c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.13
|
Security for phun-reps 0.1.4
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.