Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Xavier Thompson
cython
Commits
63fa47af
Commit
63fa47af
authored
May 01, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use f-strings in memoryview code where possible.
parent
9db9509f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
Cython/Utility/MemoryView.pyx
Cython/Utility/MemoryView.pyx
+7
-8
No files found.
Cython/Utility/MemoryView.pyx
View file @
63fa47af
...
...
@@ -151,7 +151,7 @@ cdef class array:
# cdef Py_ssize_t dim, stride
for
idx
,
dim
in
enumerate
(
shape
):
if
dim
<=
0
:
raise
ValueError
(
"Invalid shape in axis %d: %d."
%
(
idx
,
dim
)
)
raise
ValueError
(
f"Invalid shape in axis
{
idx
}
:
{
dim
}
."
)
self
.
_shape
[
idx
]
=
dim
cdef
char
order
...
...
@@ -162,7 +162,7 @@ cdef class array:
order
=
b'C'
self
.
mode
=
u'c'
else
:
raise
ValueError
(
"Invalid mode, expected 'c' or 'fortran', got %s"
%
mode
)
raise
ValueError
(
f"Invalid mode, expected 'c' or 'fortran', got
{
mode
}
"
)
self
.
len
=
fill_contig_strides_array
(
self
.
_shape
,
self
.
_strides
,
itemsize
,
self
.
ndim
,
order
)
...
...
@@ -687,7 +687,7 @@ cdef tuple _unellipsify(object index, int ndim):
have_slices
=
True
else
:
if
not
isinstance
(
item
,
slice
)
and
not
PyIndex_Check
(
item
):
raise
TypeError
(
"Cannot index with type '%s'"
%
type
(
item
)
)
raise
TypeError
(
f"Cannot index with type '
{
type
(
item
)
}
'"
)
have_slices
=
have_slices
or
isinstance
(
item
,
slice
)
result
.
append
(
item
)
...
...
@@ -926,10 +926,10 @@ cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
if
index
<
0
:
index
+=
view
.
shape
[
dim
]
if
index
<
0
:
raise
IndexError
(
"Out of bounds on buffer access (axis %d)"
%
dim
)
raise
IndexError
(
f"Out of bounds on buffer access (axis
{
dim
}
)"
)
if
index
>=
shape
:
raise
IndexError
(
"Out of bounds on buffer access (axis %d)"
%
dim
)
raise
IndexError
(
f"Out of bounds on buffer access (axis
{
dim
}
)"
)
resultp
=
bufp
+
index
*
stride
if
suboffset
>=
0
:
...
...
@@ -1251,8 +1251,7 @@ cdef void *copy_data_to_temp({{memviewslice_name}} *src,
@
cname
(
'__pyx_memoryview_err_extents'
)
cdef
int
_err_extents
(
int
i
,
Py_ssize_t
extent1
,
Py_ssize_t
extent2
)
except
-
1
with
gil
:
raise
ValueError
(
"got differing extents in dimension %d (got %d and %d)"
%
(
i
,
extent1
,
extent2
))
raise
ValueError
(
f"got differing extents in dimension
{
i
}
(got
{
extent1
}
and
{
extent2
}
)"
)
@
cname
(
'__pyx_memoryview_err_dim'
)
cdef
int
_err_dim
(
PyObject
*
error
,
char
*
msg
,
int
dim
)
except
-
1
with
gil
:
...
...
@@ -1487,7 +1486,7 @@ cdef bytes format_from_typeinfo(__Pyx_TypeInfo *type):
fmt
=
__Pyx_TypeInfoToFormat
(
type
)
if
type
.
arraysize
[
0
]:
extents
=
[
unicode
(
type
.
arraysize
[
i
])
for
i
in
range
(
type
.
ndim
)]
result
=
(
u"(%s)"
%
u','
.
join
(
extents
))
.
encode
(
'ascii'
)
+
fmt
.
string
result
=
f"(
{
u','
.
join
(
extents
)
}
)"
.
encode
(
'ascii'
)
+
fmt
.
string
else
:
result
=
fmt
.
string
...
...
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