-
-
Notifications
You must be signed in to change notification settings - Fork 385
Add numpy support to OCC array types; fixes in Qt backend #1381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's Guide by SourceryThis PR implements numpy array support for OCC array types and adds fast evaluation methods for geometric objects. The implementation is done through SWIG interface files and includes comprehensive test coverage. Additionally, it fixes two issues in the Qt backend related to logging and application instance handling. Class diagram for updated OCC array types with numpy supportclassDiagram
class NCollection_Array1 {
+int Lower()
+int Upper()
+int Length()
+T Value(int index)
+void SetValue(int index, T value)
+void AddDataFromNumpyArray(array_dtype* numpyArray1, int nRows1)
+void BuildNumpyArray(array_dtype* numpyArray1Argout, int nRows1Argout)
+from_numpy_array(cls, arr)
+to_numpy_array()
}
class NCollection_Array2 {
+void AddDataFromNumpyArray(array_dtype* numpyArray2, int nRows2, int nCols2)
+void BuildNumpyArray(array_dtype* numpyArray2Argout, int aSizeArgout, int nRows2Argout, int nCols2Argout)
+from_numpy_array(cls, arr)
+to_numpy_array()
}
class Geom_Curve {
+void evalNumpy(double* numpyArrayU, int nRowsU, double* numpyArrayResultArgout, int aSizeArgout, int nDimsResult)
+void evalDerivativeNumpy(double* numpyArrayU, int nRowsU, double* numpyArrayResultArgout, int aSizeArgout, int nDimsResult, int nU)
+eval_numpy_array(u_arr)
+eval_derivative_numpy_array(u_arr, n_u)
}
class Geom_Surface {
+void evalNumpy(double* numpyArrayUV, int nRowsUV, int nColUV, double* numpyArrayResultArgout, int aSizeArgout, int nDimsResult)
+void evalDerivativeNumpy(double* numpyArrayUV, int nRowsUV, int nColUV, double* numpyArrayResultArgout, int aSizeArgout, int nDimsResult, int nU, int nV)
+eval_numpy_array(u_arr)
+eval_derivative_numpy_array(u_arr, n_u)
}
NCollection_Array1 <|-- NCollection_Array2
Geom_Curve <|-- Geom_Surface
Class diagram for Qt backend fixesclassDiagram
class QApplication {
+instance()
+QApplication(sys.argv)
}
class MainWindow {
+resize(int width, int height)
+show()
}
class Logger {
+setLevel(logging.DEBUG)
}
QApplication <|-- MainWindow
Logger <|-- QApplication
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jnwalther - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
wonderful contribution @jnwalther!! |
Thanks @jf---. I hope everything will work out. I'm slightly concerned about the issues reported by codacy. As far as I'm aware assert statements are common practice in pytest-style tests. |
Ok, so it seems there is an issue with the new display tests on the Ubuntu machines. I tried to reproduce the error running on my personal Linux laptop (not Ubuntu but Arch), but I couldn't, so I doubt it's a general Linux issue. From the error message I gather that it has something to do with the way Qt is set up on the system. My suggestion would be to simply skip the tests for linux platform. I couldn't find any indication that the previously existing core_display_* unittests were running, so I'm not even sure if the tests would have worked in the first place. What do you guys think? To fix the assert topic this looks promising. |
Thank you for this huge work @jnwalther I need time to review your contribution and add it as a rule to the pythonocc-generator |
Thank you @tpaviot, please take your time. Let me know if you have any questions. |
This PR adds support to convert selcted OCC array types to numpy and vice versa. Array types covered are found on the Poly, TColgp, TColStd and TShort modules in OCC.Core. The interface is implenented via the
from_numpy_array
andto_numpy_array
methods. Additionally, fast evaluation of Geom[2d]_Curve and Geom_Surface objects using numpy is provided, via theeval_numpy_array
method.Tests for the numpy interfaces are provided in test/test_core_numpy.py.
Furthermore, two minor fixes to the Qt backend are supplied related to #1363 and a side-effect where the global log level is inadvertently changed.
Tests are provided in test/test_display_sideeffects.py.
Summary by Sourcery
Introduce numpy support for selected OCC array types and enhance Geom[2d]_Curve and Geom_Surface evaluation with numpy. Fix minor issues in the Qt backend and add corresponding tests.
New Features:
Bug Fixes:
Tests: