Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benjamin Jakimow
EO Time Series Viewer
Commits
720c5c02
Commit
720c5c02
authored
May 13, 2013
by
Luke Campagnola
Browse files
Fixed handling of non-native dtypes when optimizing with weave
parent
671e624f
Changes
1
Hide whitespace changes
Inline
Side-by-side
pyqtgraph/functions.py
View file @
720c5c02
...
...
@@ -619,7 +619,15 @@ def rescaleData(data, scale, offset, dtype=None):
if
not
USE_WEAVE
:
raise
Exception
(
'Weave is disabled; falling back to slower version.'
)
newData
=
np
.
empty
((
data
.
size
,),
dtype
=
dtype
)
## require native dtype when using weave
if
not
data
.
dtype
.
isnative
():
data
=
data
.
astype
(
data
.
dtype
.
newbyteorder
(
'='
))
if
not
dtype
.
isnative
():
weaveDtype
=
dtype
.
newbyteorder
(
'='
)
else
:
weaveDtype
=
dtype
newData
=
np
.
empty
((
data
.
size
,),
dtype
=
weaveDtype
)
flat
=
np
.
ascontiguousarray
(
data
).
reshape
(
data
.
size
)
size
=
data
.
size
...
...
@@ -631,6 +639,8 @@ def rescaleData(data, scale, offset, dtype=None):
}
"""
scipy
.
weave
.
inline
(
code
,
[
'flat'
,
'newData'
,
'size'
,
'offset'
,
'scale'
],
compiler
=
'gcc'
)
if
dtype
!=
weaveDtype
:
newData
=
newData
.
astype
(
dtype
)
data
=
newData
.
reshape
(
data
.
shape
)
except
:
if
USE_WEAVE
:
...
...
@@ -839,7 +849,6 @@ def makeARGB(data, lut=None, levels=None, scale=None, useRGBA=False):
if
minVal
==
maxVal
:
maxVal
+=
1e-16
data
=
rescaleData
(
data
,
scale
/
(
maxVal
-
minVal
),
minVal
,
dtype
=
int
)
prof
.
mark
(
'2'
)
...
...
@@ -849,7 +858,6 @@ def makeARGB(data, lut=None, levels=None, scale=None, useRGBA=False):
else
:
if
data
.
dtype
is
not
np
.
ubyte
:
data
=
np
.
clip
(
data
,
0
,
255
).
astype
(
np
.
ubyte
)
prof
.
mark
(
'3'
)
...
...
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