Skip to content

Commit

Permalink
Merge pull request #55 from rjanvier/rjanvier_numpy_compat
Browse files Browse the repository at this point in the history
Add a correct way to input a numpy array
  • Loading branch information
jianboqi authored Mar 14, 2024
2 parents 134d3fe + cada007 commit 449c7ba
Show file tree
Hide file tree
Showing 9 changed files with 1,567 additions and 1,151 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macOS-11]
os: [ubuntu-22.04, windows-2022, macOS-12]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# Used to host cibuildwheel
- uses: actions/setup-python@v3
- uses: actions/setup-python@v5

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.12.2
run: python -m pip install cibuildwheel==2.16.5

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
Expand All @@ -40,9 +40,9 @@ jobs:
#Only publish to PyPI when a commit is tagged
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v3
- uses: actions/setup-python@v5

- uses: actions/download-artifact@v3
with:
Expand All @@ -55,7 +55,8 @@ jobs:
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
# construct the source package and upload src and wheels to PiPy
run: |
python -m pip install twine
python setup.py sdist
python -m pip install --upgrade pip
python -m pip install twine build
python -m build --sdist
twine upload dist/*
twine upload wheelhouse/*.whl
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
requires = ["wheel","setuptools", "oldest-supported-numpy"]
build-backend = "setuptools.build_meta"

[tool.cibuildwheel]
build = "cp3{8,9,10,11,12}-*"
6 changes: 6 additions & 0 deletions python/CSF/CSF.i
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

%include "std_string.i"
%include "std_vector.i"
%include "numpy.i"

%init %{
import_array();
%}

namespace std
{
Expand All @@ -16,4 +21,5 @@ namespace std
%template(VecDouble) vector<double>;
}

%apply (double* IN_ARRAY2, int DIM1, int DIM2) {(double *points, int rows, int cols)};
%include "../src/CSF.h"
23 changes: 17 additions & 6 deletions python/CSF/CSF.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.1.1
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing - modify
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.

from sys import version_info as _swig_python_version_info
if _swig_python_version_info < (2, 7, 0):
raise RuntimeError("Python 2.7 or later required")

# Import the low-level C/C++ module
if __package__ or "." in __name__:
from . import _CSF
Expand All @@ -26,10 +29,10 @@ def _swig_repr(self):

def _swig_setattr_nondynamic_instance_variable(set):
def set_instance_attr(self, name, value):
if name == "this":
set(self, name, value)
elif name == "thisown":
if name == "thisown":
self.this.own(value)
elif name == "this":
set(self, name, value)
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
set(self, name, value)
else:
Expand Down Expand Up @@ -118,6 +121,7 @@ def __iter__(self):

# Register SwigPyIterator in _CSF:
_CSF.SwigPyIterator_swigregister(SwigPyIterator)

class VecInt(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
Expand Down Expand Up @@ -223,6 +227,7 @@ def capacity(self):

# Register VecInt in _CSF:
_CSF.VecInt_swigregister(VecInt)

class VecFloat(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
Expand Down Expand Up @@ -328,6 +333,7 @@ def capacity(self):

# Register VecFloat in _CSF:
_CSF.VecFloat_swigregister(VecFloat)

class VecVecFloat(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
Expand Down Expand Up @@ -433,6 +439,7 @@ def capacity(self):

# Register VecVecFloat in _CSF:
_CSF.VecVecFloat_swigregister(VecVecFloat)

class VecDouble(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
Expand Down Expand Up @@ -538,6 +545,7 @@ def capacity(self):

# Register VecDouble in _CSF:
_CSF.VecDouble_swigregister(VecDouble)

class Params(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
Expand All @@ -554,6 +562,7 @@ def __init__(self):

# Register Params in _CSF:
_CSF.Params_swigregister(Params)

class CSF(object):
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
Expand Down Expand Up @@ -588,3 +597,5 @@ def do_cloth_export(self):
# Register CSF in _CSF:
_CSF.CSF_swigregister(CSF)



Loading

0 comments on commit 449c7ba

Please sign in to comment.