-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Looked more into why we get back Python lists under Blender, but not …
…when running the same code under plain Python (where it returns numpy arrays). No clear cause found, see #2 for details
- Loading branch information
Showing
7 changed files
with
104 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,38 @@ | ||
import time, gc | ||
import numpy | ||
|
||
from julia.api import Julia | ||
from julia import Main | ||
|
||
jl = Julia(compiled_modules=False) | ||
jl.eval('include("fn.jl")') | ||
jl.eval(""" | ||
include("fn.jl") | ||
import numpy | ||
import Base.convert | ||
""") | ||
|
||
print('allocating') | ||
|
||
print(gc.get_stats()) | ||
|
||
x = numpy.ones(200*1024*1024, 'float32') | ||
|
||
#x = numpy.array([1,2,3,4,5,6], dtype=numpy.float32) | ||
#print(x) | ||
|
||
time.sleep(5) | ||
|
||
print('calling into Julia') | ||
Main.fn(x) | ||
|
||
print('Back in Python') | ||
time.sleep(5) | ||
|
||
print('Attempting to clean up') | ||
del x | ||
print(gc.get_stats()) | ||
|
||
x = numpy.array([[1,2,3], [4,5,6]], dtype=np.float32) | ||
time.sleep(5) | ||
|
||
print(x) | ||
res = Main.fn(x) | ||
print(x) | ||
#print(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
|
||
function fn(x::Array{Float32}) | ||
println("array size: $(size(x))"); | ||
println("max element: $(maximum(x))") | ||
println("min element: $(minimum(x))") | ||
x[1,1] = 123 | ||
#return 2x | ||
|
||
sleep(5) | ||
x[1:3] .= -1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import time, gc | ||
import numpy | ||
|
||
from julia.api import Julia | ||
from julia import Main | ||
|
||
jl = Julia(compiled_modules=False) | ||
jl.eval(""" | ||
include("return_array.jl") | ||
""") | ||
|
||
print('calling into Julia') | ||
res = Main.fn(123) | ||
|
||
print('Back in Python') | ||
for v in res: | ||
print(type(v)) | ||
print(v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using InteractiveUtils | ||
|
||
function fn(n) | ||
a = Array{Float32}(undef, 5) | ||
a .= n | ||
b = Array{UInt32}([n, n, n, n, n]) | ||
c = Array{UInt32}([n, n, n, n, n]) | ||
d = Array{UInt32}([n, n, n, n, n]) | ||
return a, b, c, d | ||
end | ||
|
||
code_warntype(fn, (UInt32,)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import numpy | ||
print(numpy.__file__) | ||
print(numpy.__version__) | ||
|
||
import julia | ||
print(julia.__file__) | ||
print(julia.__version__) | ||
from julia.api import Julia | ||
|
||
print('Initializing Julia (this might take a moment the first time)...') | ||
jl = Julia(compiled_modules=False) | ||
print('Done!') | ||
|
||
# Needs to come after the creation of the Julia instance above | ||
from julia import Main | ||
|
||
jl.eval('include("../catmull-clark.jl")') | ||
|
||
vertices = numpy.array([-1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0], 'float32') | ||
loop_start = numpy.array([0x00000001, 0x00000005, 0x00000009, 0x0000000d, 0x00000011, 0x00000015], 'uint32') | ||
loop_total = numpy.array([0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000004], 'uint32') | ||
loops = numpy.array([0x00000001, 0x00000002, 0x00000004, 0x00000003, 0x00000003, 0x00000004, 0x00000008, 0x00000007, 0x00000007, 0x00000008, 0x00000006, 0x00000005, 0x00000005, 0x00000006, 0x00000002, 0x00000001, 0x00000003, 0x00000007, 0x00000005, 0x00000001, 0x00000008, 0x00000004, 0x00000002, 0x00000006], 'uint32') | ||
|
||
res = Main.subdivide(vertices, loop_start, loop_total, loops) | ||
|
||
for v in res: | ||
print(type(v)) | ||
print(v) |