Skip to content

Julia code returns lists with Blender's numpy #2

@paulmelis

Description

@paulmelis

Comparing the returned values of the subdivide() in catmull-clark.jl call under Blender and from regular Python I noticed the following. This is based on the code in test/subdiv.py, which is also stored in test.blend under (text) in the Blender Text Editor.

Python 3.8.5 (command-line)

melis@juggle 20:46:~/concepts/blender-julia-test/test$ python subdiv.py
/usr/lib/python3.8/site-packages/numpy/__init__.py
1.19.1
/home/melis/.local/lib/python3.8/site-packages/julia/__init__.py
0.5.4
Initializing Julia (this might take a moment the first time)...
Done!
(Julia) Building half edges done in 1.533ms
(Julia) Input: 8 vertices, 6 polygons, 12 polygon edges
(Julia) Output: 26 vertices, 24 quads
(Julia) Subdivision done in 21.688ms
<class 'numpy.ndarray'>
[-0.5555556  -0.5555556  -0.5555556  -0.50617284 -0.50617284  0.6049383
 -0.50617284  0.6049383  -0.50617284 -0.4458162   0.5665295   0.5665295
  0.6049383  -0.50617284 -0.50617284  0.5665295  -0.4458162   0.5665295
  0.5665295   0.5665295  -0.4458162   0.5208048   0.52080476  0.52080476
 -1.          0.          0.          0.          1.          0.
  1.          0.          0.          0.         -1.          0.
  0.          0.         -1.          0.          0.          1.
 -0.75       -0.75        0.         -0.75        0.          0.75
 -0.75        0.75        0.         -0.75        0.         -0.75
  0.          0.75        0.75        0.75        0.75        0.
  0.          0.75       -0.75        0.75        0.          0.75
  0.75       -0.75        0.          0.75        0.         -0.75
  0.         -0.75        0.75        0.         -0.75       -0.75      ]
<class 'numpy.ndarray'>
[ 1  5  9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93]
<class 'numpy.ndarray'>
[4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4]
<class 'numpy.ndarray'>
[15  2 16  9 16  4 17  9 17  3 18  9 18  1 15  9 17  4 19 10 19  8 20 10
 20  7 21 10 21  3 17 10 20  8 22 11 22  6 23 11 23  5 24 11 24  7 20 11
 23  6 25 12 25  2 15 12 15  1 26 12 26  5 23 12 21  7 24 13 24  5 26 13
 26  1 18 13 18  3 21 13 19  4 16 14 16  2 25 14 25  6 22 14 22  8 19 14]

Blender 2.90 (Run script from UI)

/home/melis/software/blender-2.90.0-linux64/2.90/python/lib/python3.7/site-packages/numpy/__init__.py
1.17.5
/home/melis/software/blender-2.90.0-linux64/2.90/python/lib/python3.7/site-packages/julia/__init__.py
0.5.4
Initializing Julia (this might take a moment the first time)...
Done!
(Julia) Building half edges done in 0.018ms
(Julia) Input: 8 vertices, 6 polygons, 12 polygon edges
(Julia) Output: 26 vertices, 24 quads
(Julia) Subdivision done in 0.127ms
<class 'list'>
[-0.5555555820465088, -0.5555555820465088, -0.5555555820465088, -0.5061728358268738, -0.5061728358268738, 0.6049383282661438, -0.5061728358268738, 0.6049383282661438, -0.5061728358268738, -0.44581618905067444, 0.5665295124053955, 0.5665295124053955, 0.6049383282661438, -0.5061728358268738, -0.5061728358268738, 0.5665295124053955, -0.44581618905067444, 0.5665295124053955, 0.5665295124053955, 0.5665295124053955, -0.44581618905067444, 0.5208048224449158, 0.520804762840271, 0.520804762840271, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, -0.75, -0.75, 0.0, -0.75, 0.0, 0.75, -0.75, 0.75, 0.0, -0.75, 0.0, -0.75, 0.0, 0.75, 0.75, 0.75, 0.75, 0.0, 0.0, 0.75, -0.75, 0.75, 0.0, 0.75, 0.75, -0.75, 0.0, 0.75, 0.0, -0.75, 0.0, -0.75, 0.75, 0.0, -0.75, -0.75]
<class 'list'>
[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93]
<class 'list'>
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
<class 'list'>
[15, 2, 16, 9, 16, 4, 17, 9, 17, 3, 18, 9, 18, 1, 15, 9, 17, 4, 19, 10, 19, 8, 20, 10, 20, 7, 21, 10, 21, 3, 17, 10, 20, 8, 22, 11, 22, 6, 23, 11, 23, 5, 24, 11, 24, 7, 20, 11, 23, 6, 25, 12, 25, 2, 15, 12, 15, 1, 26, 12, 26, 5, 23, 12, 21, 7, 24, 13, 24, 5, 26, 13, 26, 1, 18, 13, 18, 3, 21, 13, 19, 4, 16, 14, 16, 2, 25, 14, 25, 6, 22, 14, 22, 8, 19, 14]

Summary

Python 3.8.5 (command-line):

  • subdivide() returns a tuple of 4 numpy.ndarray values, as expected
  • NumPy version 1.19.1
  • PyJulia version 0.5.4

Blender 2.90 (UI):

  • subdivide() returns a tuple of 4 lists
  • Python 3.7.7 (as included in Blender)
  • NumPy 1.17.5
  • PyJulia 0.5.4

So the differences are probably caused by a different version for Python and/or NumPy.

Rebuilding PyCall from within Blender ((rebuild pycall) text tab) makes no difference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions