Skip to content

Commit

Permalink
Add a correct way to input a numpy array
Browse files Browse the repository at this point in the history
  • Loading branch information
rjanvier committed Feb 4, 2024
1 parent 134d3fe commit b4c88d4
Show file tree
Hide file tree
Showing 8 changed files with 1,537 additions and 1,140 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools"]
requires = ["wheel","setuptools", "oldest-supported-numpy"]
build-backend = "setuptools.build_meta"
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 b4c88d4

Please sign in to comment.