Partition_into_plates C++ signature error

Hello, I am running into an issue with pygplates (the version for Windows) where one of the functions “partition_into_plates” is throwing an error that seems to indicate a break down in the communication between a C++ script and its Python wrapper (within Boost.Python). A screen shot image of this error is shown and annotated below:

Has anyone run into this kind of error with the “partition_into_plates” function before and been able to fix it? I tried to delve into the Boost.Python documentation to see if there was any obvious (to me anyway but I am new to Python) fix for this issue. Unfortunately, after looking through this documentation I have not been able to perceive a good way forward. Does anyone have any suggestions for troubleshooting this problem?

Best regards,


Hi Vincent,

It’s basically saying that it didn’t like the function arguments you gave it (the Boost.Python wrapper reports any argument conversion issues like this).

Specifically you passed a numpy.int32 value to the reconstruction_time argument of partition_into_plates.

We’ve added support for NumPy scalar types (like numpy.int32) in recent internal versions of pyGPlates but the latest public release (August 2020) does not support it.

So until the next public release, a workaround is to wrap your NumPy integer with float() so that you pass, for example, float(numpy_time) instead of just numpy_time:

partition_into_plates(..., reconstruction_time=float(numpy_time), ...)

The technical details of why you’re getting that error message are…

When you call partition_into_plates(), internally it creates a PlatePartitioner object (this is what the PlatePartitioner.__init__ in your error message means). The first __init__ (between the red lines) is saying that you passed in a FeatureCollection, a RotationModel, a numpy.int32 and a SortPartitioningPlates. Then it shows another two __init__, which are the two alternatives it accepts. These two alternatives are documented at PlatePartitioner where you can see that one of those two __init__ overloads accepts a reconstruction_time argument that can either be a float or a GeoTimeInstant. It’s here that it’s having trouble converting the numpy.int32 that you passed into a float or GeoTimeInstant. And it’s why explicitly converting to float, as mentioned above, is required for the current public release of pyGPlates. However the next public release will have builtin conversions from NumPy scalars to float such that they’re essentially equivalent types as far as pyGPlates is concerned, and this explicit conversion will no longer be required.

Thank you very much John this cleared up the issue. Your help and explanations are appreciated!