Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
7c097fa4
Commit
7c097fa4
authored
Feb 21, 2019
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle numpy scalars in python2js_buffer
parent
16580a16
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
src/python2js_buffer.c
src/python2js_buffer.c
+4
-0
test/test_python.py
test/test_python.py
+40
-0
No files found.
src/python2js_buffer.c
View file @
7c097fa4
...
...
@@ -427,6 +427,10 @@ _python2js_shareable_buffer_recursive(Py_buffer* buff,
static
enum
shareable_enum
_python2js_buffer_is_shareable
(
Py_buffer
*
buff
)
{
if
(
buff
->
ndim
==
0
)
{
return
NOT_SHAREABLE
;
}
char
*
invalid_codes
=
">!qQ?"
;
for
(
char
*
i
=
buff
->
format
;
*
i
!=
0
;
++
i
)
{
for
(
char
*
j
=
invalid_codes
;
*
j
!=
0
;
++
j
)
{
...
...
test/test_python.py
View file @
7c097fa4
...
...
@@ -146,6 +146,46 @@ def test_python2js_numpy_dtype(selenium_standalone):
assert
selenium
.
run_js
(
"return pyodide.pyimport('x')[1][1]"
)
==
'string4'
def
test_python2js_numpy_scalar
(
selenium_standalone
):
selenium
=
selenium_standalone
selenium
.
load_package
(
'numpy'
)
selenium
.
run
(
"import numpy as np"
)
for
dtype
in
(
'int8'
,
'uint8'
,
'int16'
,
'uint16'
,
'int32'
,
'uint32'
,
'int64'
,
'uint64'
,
'float32'
,
'float64'
):
selenium
.
run
(
f"""
x = np.
{
dtype
}
(1)
"""
)
assert
selenium
.
run_js
(
"""
return pyodide.pyimport('x') == 1
"""
)
is
True
selenium
.
run
(
"""
x = x.byteswap().newbyteorder()
"""
)
assert
selenium
.
run_js
(
"""
return pyodide.pyimport('x') == 1
"""
)
is
True
def
test_pythonexc2js
(
selenium
):
try
:
selenium
.
run_js
(
'return pyodide.runPython("5 / 0")'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment