From 4ccf0a65467355b42ddcfdf746a6e5e54708253c Mon Sep 17 00:00:00 2001 From: hspark1212 Date: Tue, 28 Nov 2023 09:55:47 +0000 Subject: [PATCH] v0.1.13 --- .github/workflows/build_wheels.yml | 26 ++++++++++++++++++++++++++ fast_grid/calculate_grid.py | 13 +++++++++---- setup.py | 13 ++++++++++--- 3 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/build_wheels.yml diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml new file mode 100644 index 0000000..3ba981d --- /dev/null +++ b/.github/workflows/build_wheels.yml @@ -0,0 +1,26 @@ +name: Build and upload to PyPI + +on: [push, pull_request] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04, macos-11, windows-2019] + + steps: + - uses: actions/checkout@v4 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.2 + env: + # Build wheels for CPython only, skipping PyPy + CIBW_BUILD: "cp*" + CIBW_SKIP: "*-pp*" + + - uses: actions/upload-artifact@v3 + with: + name: artifact-name + path: ./wheelhouse/*.whl \ No newline at end of file diff --git a/fast_grid/calculate_grid.py b/fast_grid/calculate_grid.py index e4a92a1..330adc3 100644 --- a/fast_grid/calculate_grid.py +++ b/fast_grid/calculate_grid.py @@ -30,7 +30,7 @@ def calculate_grid( float16: bool = False, emax: float = 5000.0, emin: float = -5000.0, - output_shape_grid: bool = False, + return_dict: bool = False, ) -> np.array: """Calculate the energy grid for a given structure and force field. It takes a structure (ase Atoms object or cif file path) and returns the energy grid. @@ -54,7 +54,7 @@ def calculate_grid( :param float16: use float16 to save memory, defaults to False :param emax: clip energy values for better visualization, defaults to 5000.0 :param emin: clip energy values for better visualization, defaults to -5000.0 - :param output_shape_grid: output shape of energy grid, defaults to False + :param return_dict: return a dictionary of outputs, defaults to False :return: energy grid """ # read structure @@ -140,8 +140,13 @@ def calculate_grid( print(f"Visualizing energy grid | supercell {supercell}...") visualize_grid(pos_grid, pos_atoms, calculated_grid, emax, emin) - if output_shape_grid: - return calculated_grid.reshape(grid_size) + if return_dict: + return { + "atoms": atoms, # supercelled atoms + "supercell": supercell, + "pos_grid": pos_grid, + "calculated_grid": calculated_grid, + } return calculated_grid diff --git a/setup.py b/setup.py index 8e7cd21..59b610e 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name="fast-grid", - version="0.1.12", + version="0.1.13", description="Fast grid calculation", author="Hyunsoo Park", author_email="hpark@ic.ac.uk", @@ -23,13 +23,20 @@ package_data={"fast_grid": ["assets/*.csv"]}, include_package_data=True, python_requires=">=3.9", + # readme + # long_description=open("README.md").read(), + # long_description_content_type="text/markdown", # cython - setup_requires=["cython"], + setup_requires=["cython", "numpy"], ext_modules=cythonize( [ "fast_grid/libs/distance_matrix.pyx", "fast_grid/libs/potential.pyx", - ] + ], + compiler_directives={"language_level": "3"}, ), include_dirs=[np.get_include()], + extras_require={ + "pypy": ["pypy-cffi"] + }, # Additional configurations for PyPy compatibility )