Coder Social home page Coder Social logo

Comments (7)

yuqli avatar yuqli commented on August 30, 2024

I have the exact same problem since last night! Have to learn some Cython but still, this error seems to be in the assert lines you quoted.

Since this library is updated three months ago and we both seem to be running into trouble since last night, maybe it's some changes in the Cython library. It could be a cdef int is no longer a Python int. I'm not sure why we need these lines either, though.

from triangle.

drufat avatar drufat commented on August 30, 2024

These assertions just make sure that assumptions about the number of dimensions of arrays in the C library and the python wrapper are actually correct. Do you think you can provide the contents of the P and S variables in the call

triangle.triangulate({'vertices': P[:,:2], 'segments': S}, "p")

which results in the assertion failure? Or I can extract them from the example you have given once I get back to my desk a little later.

from triangle.

yuqli avatar yuqli commented on August 30, 2024

These assertions just make sure that assumptions about the number of dimensions of arrays in the C library and the python wrapper are actually correct. Do you think you can provide the contents of the P and S variables in the call

triangle.triangulate({'vertices': P[:,:2], 'segments': S}, "p")

which results in the assertion failure? Or I can extract them from the example you have given once I get back to my desk a little later.

Thanks for the prompted reply. If it helps, this is the data I used as inputs to the triangulate function which lead to the exact same error. Is it because my data points are 3D instead of 2D?

Code:

   poly = {'vertices': np.array(newpolypoints), 'segments': np.array(segments)}
    print(poly)
    # print poly
    # -- Triangulate
    t = triangle.triangulate(poly, "p")

Output:


{'vertices': array([[  9.24246154,  -2.02496154,  -8.79692308],
       [  6.71146154,  -4.45896154,  -8.79692308],
       [  2.78446154,  -8.23696154,  -8.79692308],
       [  1.91946154,  -9.06896154,  -8.79692308],
       [-11.00953846,   4.26003846,  -8.79692308],
       [ -3.68553846,  11.30403846,  -8.79692308]]), 'segments': array([[0, 1],
       [1, 2],
       [2, 3],
       [3, 4],
       [4, 5],
       [5, 0]])}
Traceback (most recent call last):
  File "triangulation.py", line 201, in <module>
    main()
  File "triangulation.py", line 195, in main
    res = my_triangulation(face_with_points[0])
  File "triangulation.py", line 146, in my_triangulation
    t = triangle.triangulate(poly, "p")
AttributeError: module 'triangle' has no attribute 'triangulate'

from triangle.

yuqli avatar yuqli commented on August 30, 2024

I revised my code and when inputs are 2D arrays the assertionError no longer occurred. Thanks for the help! It could be a coincidence that @rougier and I have the exact same error at roughly the same time... I'm not sure about her/his exact issue though.

from triangle.

drufat avatar drufat commented on August 30, 2024

@yuqli
Yes, vertices need to be a 2D array containing the x, y coordinates of each vertex.

from triangle.

drufat avatar drufat commented on August 30, 2024

@rougier I think this pull request for glumpy should fix the issue with the assertion error.
glumpy/glumpy#216

from triangle.

rougier avatar rougier commented on August 30, 2024

@drufat Oh nice, many thanks.

from triangle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.