-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored project setup, added tests to CI, updated Cython.
- Loading branch information
1 parent
2cd206d
commit 5878963
Showing
13 changed files
with
200 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a | ||
# variety of Python versions For more information see: | ||
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: test | ||
|
||
on: | ||
push: | ||
branches: [ "main"] | ||
pull_request: | ||
branches: [ "main"] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/scripts && ./setup.sh | ||
- name: Run unit tests | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/scripts && ./test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[build-system] | ||
requires = ["setuptools", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = 'pyzeo' | ||
version = '0.1.6' | ||
description = 'Python interface to Zeo++' | ||
readme = "README.md" | ||
authors = [{ name = "Lauri Himanen" }] | ||
license = { file = "LICENSE" } | ||
requires-python = ">=3.8" | ||
dependencies = [] | ||
classifiers = [ | ||
"Development Status :: 3 - Alpha", | ||
"Programming Language :: C++", | ||
"Programming Language :: Cython", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Intended Audience :: Science/Research", | ||
"Topic :: Scientific/Engineering" | ||
] | ||
keywords = ['zeo++', 'porous', 'materials', 'science'] | ||
|
||
[project.urls] | ||
Source = "https://github.com/nomad-coe/pyzeo" | ||
|
||
[project.optional-dependencies] | ||
dev = [ | ||
"pytest", | ||
] | ||
|
||
[tool.setuptools.package-dir] | ||
"" = "src" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cd .. | ||
python -m pip install --upgrade pip | ||
pip install .[dev] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
cd ../tests | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
from pyzeo.netstorage import AtomNetwork | ||
from pyzeo.area_volume import volume, surface_area | ||
def test_areavol(): | ||
from pyzeo.netstorage import AtomNetwork | ||
from pyzeo.area_volume import volume, surface_area | ||
|
||
atmnet = AtomNetwork.read_from_CSSR("MgO_vac1.cssr", rad_file="MgO.rad") | ||
vol_str = volume(atmnet, 0.1, 0.05, 20000) | ||
lines = vol_str.decode("utf-8").split('\n') | ||
for line in lines: | ||
if "Number_of_pockets" in line: | ||
print('---------') | ||
print(line) | ||
print('---------') | ||
vol_str, ha_atmnet = volume(atmnet, 0.1, 0.05, 7000, True) | ||
lines = vol_str.decode("utf-8").split('\n') | ||
for line in lines: | ||
if "Number_of_pockets" in line: | ||
print('---------') | ||
print(line) | ||
print('---------') | ||
#print("--------") | ||
#print(vol_str) | ||
#print("--------") | ||
sa_str = surface_area(atmnet, 0.1, 0.05, 7000, False) | ||
lines = sa_str.decode("utf-8").split('\n') | ||
for line in lines: | ||
if "Number_of_pockets" in line: | ||
print('---------') | ||
print(line.split()) | ||
print('---------') | ||
#print("--------") | ||
#print(sa_str) | ||
#print("--------") | ||
atmnet = AtomNetwork.read_from_CSSR("MgO_vac1.cssr", rad_file="MgO.rad") | ||
vol_str = volume(atmnet, 0.1, 0.05, 20000) | ||
lines = vol_str.decode("utf-8").split('\n') | ||
for line in lines: | ||
if "Number_of_pockets" in line: | ||
print('---------') | ||
print(line) | ||
print('---------') | ||
vol_str, ha_atmnet = volume(atmnet, 0.1, 0.05, 7000, True) | ||
lines = vol_str.decode("utf-8").split('\n') | ||
for line in lines: | ||
if "Number_of_pockets" in line: | ||
print('---------') | ||
print(line) | ||
print('---------') | ||
#print("--------") | ||
#print(vol_str) | ||
#print("--------") | ||
sa_str = surface_area(atmnet, 0.1, 0.05, 7000, False) | ||
lines = sa_str.decode("utf-8").split('\n') | ||
for line in lines: | ||
if "Number_of_pockets" in line: | ||
print('---------') | ||
print(line.split()) | ||
print('---------') | ||
#print("--------") | ||
#print(sa_str) | ||
#print("--------") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
from pyzeo.netstorage import AtomNetwork | ||
from pyzeo.cluster import pruned_highaccuracy_voronoi_network, \ | ||
get_nearest_largest_diameter_highaccuracy_vornode | ||
def test_cluster(): | ||
from pyzeo.netstorage import AtomNetwork | ||
from pyzeo.cluster import pruned_highaccuracy_voronoi_network, \ | ||
get_nearest_largest_diameter_highaccuracy_vornode | ||
|
||
atmnet = AtomNetwork.read_from_CSSR("MgO.cssr", rad_file="MgO.rad") | ||
vornet,ecs,fcs = atmnet.perform_voronoi_decomposition() | ||
vornet.analyze_writeto_XYZ('mgo_low', 0.4, atmnet) | ||
atmnet = AtomNetwork.read_from_CSSR("MgO.cssr", rad_file="MgO.rad") | ||
vornet, ecs, fcs = atmnet.perform_voronoi_decomposition() | ||
vornet.analyze_writeto_XYZ('mgo_low', 0.4, atmnet) | ||
|
||
# Pruned high accuracy voronoi network | ||
ha_vornet = pruned_highaccuracy_voronoi_network(atmnet, 0.7) | ||
ha_vornet.analyze_writeto_XYZ('mgo_high_prune', 0.4, atmnet) | ||
# Pruned high accuracy voronoi network | ||
ha_vornet = pruned_highaccuracy_voronoi_network(atmnet, 0.7) | ||
ha_vornet.analyze_writeto_XYZ('mgo_high_prune', 0.4, atmnet) | ||
|
||
# Reduced high accuracy voronoi network | ||
ha_red_vornet = get_nearest_largest_diameter_highaccuracy_vornode(atmnet) | ||
ha_red_vornet.analyze_writeto_XYZ('mgo_high_red', 0.4, atmnet) | ||
# Reduced high accuracy voronoi network | ||
ha_red_vornet = get_nearest_largest_diameter_highaccuracy_vornode(atmnet) | ||
ha_red_vornet.analyze_writeto_XYZ('mgo_high_red', 0.4, atmnet) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
import sys | ||
from pyzeo.netstorage import AtomNetwork | ||
from pyzeo.cycle import compute_centroid_4cycles, compute_face_centers | ||
def test_cycle(): | ||
from pyzeo.netstorage import AtomNetwork | ||
from pyzeo.cycle import compute_centroid_4cycles, compute_face_centers | ||
|
||
atmnet = AtomNetwork.read_from_CSSR("MgO.cssr", rad_file="MgO.rad") | ||
compute_face_centers(atmnet) | ||
sys.exit() | ||
atmnet = AtomNetwork.read_from_CSSR("MgO.cssr", rad_file="MgO.rad") | ||
compute_face_centers(atmnet) | ||
|
||
vornet = atmnet.perform_voronoi_decomposition() | ||
oh_interstitials = compute_centroid_4cycles(vornet) | ||
vornet, _, _ = atmnet.perform_voronoi_decomposition() | ||
oh_interstitials = compute_centroid_4cycles(vornet) | ||
|
||
ids_set = set() | ||
i = 0 | ||
while i < len(oh_interstitials): | ||
node_ids = frozenset(oh_interstitials[i]['ids']) | ||
if node_ids not in ids_set: | ||
ids_set.add(node_ids) | ||
i = i+1 | ||
else: | ||
oh_interstitials.pop(i) | ||
|
||
print(len(oh_interstitials)) | ||
for inter in oh_interstitials: | ||
node_ids = inter['ids'] | ||
print(node_ids) | ||
coord = inter['coords'] | ||
print(coord.x, coord.y, coord.z) | ||
ids_set = set() | ||
i = 0 | ||
while i < len(oh_interstitials): | ||
node_ids = frozenset(oh_interstitials[i]['ids']) | ||
if node_ids not in ids_set: | ||
ids_set.add(node_ids) | ||
i = i+1 | ||
else: | ||
oh_interstitials.pop(i) | ||
print(len(oh_interstitials)) | ||
for inter in oh_interstitials: | ||
node_ids = inter['ids'] | ||
print(node_ids) | ||
coord = inter['coords'] | ||
print(coord.x, coord.y, coord.z) | ||
|
||
|
Oops, something went wrong.