Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
1cd905b4
Unverified
Commit
1cd905b4
authored
Aug 23, 2024
by
Peter Eastman
Committed by
GitHub
Aug 23, 2024
Browse files
Support numpy 2 (#4622)
* Support numpy 2 * Debugging * Removed debugging code
parent
75d4f299
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
72 deletions
+78
-72
devtools/ci/gh-actions/conda-envs/build-macos-13.yml
devtools/ci/gh-actions/conda-envs/build-macos-13.yml
+1
-1
devtools/ci/gh-actions/conda-envs/build-macos-latest.yml
devtools/ci/gh-actions/conda-envs/build-macos-latest.yml
+1
-1
devtools/ci/gh-actions/conda-envs/build-ubuntu-latest.yml
devtools/ci/gh-actions/conda-envs/build-ubuntu-latest.yml
+1
-1
devtools/ci/gh-actions/conda-envs/build-ubuntu-pypy.yml
devtools/ci/gh-actions/conda-envs/build-ubuntu-pypy.yml
+1
-1
devtools/ci/gh-actions/conda-envs/build-windows-latest.yml
devtools/ci/gh-actions/conda-envs/build-windows-latest.yml
+1
-1
devtools/ci/gh-actions/conda-envs/docs.yml
devtools/ci/gh-actions/conda-envs/docs.yml
+1
-1
wrappers/python/src/swig_doxygen/swig_lib/python/typemaps.i
wrappers/python/src/swig_doxygen/swig_lib/python/typemaps.i
+72
-66
No files found.
devtools/ci/gh-actions/conda-envs/build-macos-13.yml
View file @
1cd905b4
...
@@ -10,7 +10,7 @@ dependencies:
...
@@ -10,7 +10,7 @@ dependencies:
-
python
-
python
-
cython
-
cython
-
swig
-
swig
-
numpy
<2.0
-
numpy
-
doxygen 1.8.14
-
doxygen 1.8.14
# test
# test
-
pytest
-
pytest
...
...
devtools/ci/gh-actions/conda-envs/build-macos-latest.yml
View file @
1cd905b4
...
@@ -10,7 +10,7 @@ dependencies:
...
@@ -10,7 +10,7 @@ dependencies:
-
python
-
python
-
cython
-
cython
-
swig
-
swig
-
numpy
<2.0
-
numpy
-
doxygen 1.8.14
-
doxygen 1.8.14
# test
# test
-
pytest
-
pytest
...
...
devtools/ci/gh-actions/conda-envs/build-ubuntu-latest.yml
View file @
1cd905b4
...
@@ -12,7 +12,7 @@ dependencies:
...
@@ -12,7 +12,7 @@ dependencies:
-
python
-
python
-
cython
-
cython
-
swig
-
swig
-
numpy
<2.0
-
numpy
-
ocl-icd-system
-
ocl-icd-system
-
doxygen 1.8.14
-
doxygen 1.8.14
# test
# test
...
...
devtools/ci/gh-actions/conda-envs/build-ubuntu-pypy.yml
View file @
1cd905b4
...
@@ -12,7 +12,7 @@ dependencies:
...
@@ -12,7 +12,7 @@ dependencies:
-
pypy
-
pypy
-
cython
-
cython
-
swig
-
swig
-
numpy
<2.0
-
numpy
-
ocl-icd-system
-
ocl-icd-system
-
doxygen 1.8.14
-
doxygen 1.8.14
# test
# test
...
...
devtools/ci/gh-actions/conda-envs/build-windows-latest.yml
View file @
1cd905b4
...
@@ -12,7 +12,7 @@ dependencies:
...
@@ -12,7 +12,7 @@ dependencies:
-
python
-
python
-
cython
-
cython
-
swig
-
swig
-
numpy
<2.0
-
numpy
-
doxygen 1.8.14
-
doxygen 1.8.14
-
khronos-opencl-icd-loader
-
khronos-opencl-icd-loader
# test
# test
...
...
devtools/ci/gh-actions/conda-envs/docs.yml
View file @
1cd905b4
...
@@ -8,7 +8,7 @@ dependencies:
...
@@ -8,7 +8,7 @@ dependencies:
# host
# host
-
python
-
python
-
pip
-
pip
-
numpy
<2.0
-
numpy
-
cython
-
cython
-
swig
-
swig
-
doxygen 1.8.14
-
doxygen 1.8.14
...
...
wrappers/python/src/swig_doxygen/swig_lib/python/typemaps.i
View file @
1cd905b4
...
@@ -161,39 +161,42 @@ int Py_SequenceToVecDouble(PyObject* obj, std::vector<double>& out) {
...
@@ -161,39 +161,42 @@ int Py_SequenceToVecDouble(PyObject* obj, std::vector<double>& out) {
PyObject
*
item1
=
NULL
;
PyObject
*
item1
=
NULL
;
if
(
isNumpyAvailable
())
{
if
(
isNumpyAvailable
())
{
if
(
PyArray_Check
(
stripped
)
&
&
PyArray_ISCARRAY_RO(stripped)
&
&
PyArray_NDIM(stripped)
==
1
)
{
if
(
PyArray_Check
(
stripped
))
{
int
type
=
PyArray_TYPE
(
stripped
)
;
const
PyArrayObject
*
array
=
(
PyArrayObject
*
)
stripped
;
int
length
=
PyArray_SIZE
(
stripped
)
;
if
(
PyArray_ISCARRAY_RO
(
array
)
&
&
PyArray_NDIM(array)
==
1
)
{
void
*
data
=
PyArray_DATA
((
PyArrayObject
*
)
stripped
)
;
int
type
=
PyArray_TYPE
(
array
)
;
if
(
type
==
NPY_DOUBLE
)
{
int
length
=
PyArray_SIZE
(
array
)
;
out
.
resize
(
length
)
;
void
*
data
=
PyArray_DATA
(
array
)
;
memcpy
(
&
out[0],
data,
sizeof(double)*length);
if
(
type
==
NPY_DOUBLE
)
{
Py_DECREF
(
stripped
)
;
out
.
resize
(
length
)
;
return
SWIG_OK
;
memcpy
(
&
out[0],
data,
sizeof(double)*length);
}
Py_DECREF
(
array
)
;
if
(
type
==
NPY_FLOAT
)
{
return
SWIG_OK
;
out
.
resize
(
length
)
;
}
float
*
floatData
=
(
float
*
)
data
;
if
(
type
==
NPY_FLOAT
)
{
for
(
int
i
=
0
;
i
<
length
;
i
++
)
out
.
resize
(
length
)
;
out
[
i
]
=
floatData
[
i
]
;
float
*
floatData
=
(
float
*
)
data
;
Py_DECREF
(
stripped
)
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
return
SWIG_OK
;
out
[
i
]
=
floatData
[
i
]
;
}
Py_DECREF
(
array
)
;
if
(
type
==
NPY_INT32
)
{
return
SWIG_OK
;
out
.
resize
(
length
)
;
}
int
*
intData
=
(
int
*
)
data
;
if
(
type
==
NPY_INT32
)
{
for
(
int
i
=
0
;
i
<
length
;
i
++
)
out
.
resize
(
length
)
;
out
[
i
]
=
intData
[
i
]
;
int
*
intData
=
(
int
*
)
data
;
Py_DECREF
(
stripped
)
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
return
SWIG_OK
;
out
[
i
]
=
intData
[
i
]
;
}
Py_DECREF
(
array
)
;
if
(
type
==
NPY_INT64
)
{
return
SWIG_OK
;
out
.
resize
(
length
)
;
}
long
long
*
longData
=
(
long
long
*
)
data
;
if
(
type
==
NPY_INT64
)
{
for
(
int
i
=
0
;
i
<
length
;
i
++
)
out
.
resize
(
length
)
;
out
[
i
]
=
longData
[
i
]
;
long
long
*
longData
=
(
long
long
*
)
data
;
Py_DECREF
(
stripped
)
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
return
SWIG_OK
;
out
[
i
]
=
longData
[
i
]
;
Py_DECREF
(
array
)
;
return
SWIG_OK
;
}
}
}
}
}
}
}
...
@@ -233,39 +236,42 @@ int Py_SequenceToVecDouble(PyObject* obj, std::vector<double>& out) {
...
@@ -233,39 +236,42 @@ int Py_SequenceToVecDouble(PyObject* obj, std::vector<double>& out) {
int
Py_SequenceToVecVec3
(
PyObject
*
obj
,
std
::
vector
<
Vec3
>
&
out
)
{
int
Py_SequenceToVecVec3
(
PyObject
*
obj
,
std
::
vector
<
Vec3
>
&
out
)
{
PyObject
*
stripped
=
Py_StripOpenMMUnits
(
obj
)
;
// new reference
PyObject
*
stripped
=
Py_StripOpenMMUnits
(
obj
)
;
// new reference
if
(
isNumpyAvailable
())
{
if
(
isNumpyAvailable
())
{
if
(
PyArray_Check
(
stripped
)
&
&
PyArray_ISCARRAY_RO(stripped)
&
&
PyArray_NDIM(stripped)
==
2
&
&
PyArray_DIM(stripped,
1
)
==
3
)
{
if
(
PyArray_Check
(
stripped
))
{
int
type
=
PyArray_TYPE
(
stripped
)
;
const
PyArrayObject
*
array
=
(
PyArrayObject
*
)
stripped
;
int
length
=
PyArray_DIM
(
stripped
,
0
)
;
if
(
PyArray_ISCARRAY_RO
(
array
)
&
&
PyArray_NDIM(array)
==
2
&
&
PyArray_DIM(array,
1
)
==
3
)
{
void
*
data
=
PyArray_DATA
((
PyArrayObject
*
)
stripped
)
;
int
type
=
PyArray_TYPE
(
array
)
;
if
(
type
==
NPY_DOUBLE
)
{
int
length
=
PyArray_DIM
(
array
,
0
)
;
out
.
resize
(
length
)
;
void
*
data
=
PyArray_DATA
((
PyArrayObject
*
)
array
)
;
memcpy
(
&
out[0][0],
data,
3
*sizeof(double)*length);
if
(
type
==
NPY_DOUBLE
)
{
Py_DECREF
(
stripped
)
;
out
.
resize
(
length
)
;
return
SWIG_OK
;
memcpy
(
&
out[0][0],
data,
3
*sizeof(double)*length);
}
Py_DECREF
(
array
)
;
if
(
type
==
NPY_FLOAT
)
{
return
SWIG_OK
;
out
.
resize
(
length
)
;
}
float
*
floatData
=
(
float
*
)
data
;
if
(
type
==
NPY_FLOAT
)
{
for
(
int
i
=
0
;
i
<
length
;
i
++
)
out
.
resize
(
length
)
;
out
[
i
]
=
Vec3
(
floatData
[
3
*
i
],
floatData
[
3
*
i
+
1
],
floatData
[
3
*
i
+
2
])
;
float
*
floatData
=
(
float
*
)
data
;
Py_DECREF
(
stripped
)
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
return
SWIG_OK
;
out
[
i
]
=
Vec3
(
floatData
[
3
*
i
],
floatData
[
3
*
i
+
1
],
floatData
[
3
*
i
+
2
])
;
}
Py_DECREF
(
array
)
;
if
(
type
==
NPY_INT32
)
{
return
SWIG_OK
;
out
.
resize
(
length
)
;
}
int
*
intData
=
(
int
*
)
data
;
if
(
type
==
NPY_INT32
)
{
for
(
int
i
=
0
;
i
<
length
;
i
++
)
out
.
resize
(
length
)
;
out
[
i
]
=
Vec3
(
intData
[
3
*
i
],
intData
[
3
*
i
+
1
],
intData
[
3
*
i
+
2
])
;
int
*
intData
=
(
int
*
)
data
;
Py_DECREF
(
stripped
)
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
return
SWIG_OK
;
out
[
i
]
=
Vec3
(
intData
[
3
*
i
],
intData
[
3
*
i
+
1
],
intData
[
3
*
i
+
2
])
;
}
Py_DECREF
(
array
)
;
if
(
type
==
NPY_INT64
)
{
return
SWIG_OK
;
out
.
resize
(
length
)
;
}
long
long
*
longData
=
(
long
long
*
)
data
;
if
(
type
==
NPY_INT64
)
{
for
(
int
i
=
0
;
i
<
length
;
i
++
)
out
.
resize
(
length
)
;
out
[
i
]
=
Vec3
(
longData
[
3
*
i
],
longData
[
3
*
i
+
1
],
longData
[
3
*
i
+
2
])
;
long
long
*
longData
=
(
long
long
*
)
data
;
Py_DECREF
(
stripped
)
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
return
SWIG_OK
;
out
[
i
]
=
Vec3
(
longData
[
3
*
i
],
longData
[
3
*
i
+
1
],
longData
[
3
*
i
+
2
])
;
Py_DECREF
(
array
)
;
return
SWIG_OK
;
}
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment