Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11_abseil
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11_abseil
Commits
edf26928
Commit
edf26928
authored
Feb 16, 2022
by
Ken Oslund
Committed by
Copybara-Service
Feb 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Internal change
PiperOrigin-RevId: 429078279
parent
6a4bf933
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
pybind11_abseil/tests/absl_test.py
+17
-9
No files found.
pybind11_abseil/tests/absl_test.py
View file @
edf26928
...
@@ -8,6 +8,7 @@ from __future__ import absolute_import
...
@@ -8,6 +8,7 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
print_function
import
array
import
datetime
import
datetime
import
sys
import
sys
...
@@ -221,20 +222,27 @@ def make_srided_numpy_array(stride):
...
@@ -221,20 +222,27 @@ def make_srided_numpy_array(stride):
class
AbslNumericSpanTest
(
parameterized
.
TestCase
):
class
AbslNumericSpanTest
(
parameterized
.
TestCase
):
# The check_span* functions use signed ints. Arrays with different numeric
# types and all non-array types (eg native sequence types) require converting.
CONVERTED_NUMERIC_LISTS
=
(
(
'array_wrong_dtype'
,
array
.
array
(
'b'
,
[
9
,
8
,
7
])),
(
'numpy_wrong_dtype'
,
np
.
array
([
7
,
8
,
9
],
dtype
=
np
.
uint16
)),
(
'tuple'
,
(
1
,
2
,
3
)),
(
'list'
,
[
4
,
5
,
6
]),
)
NOT_CONVERTED_NUMERIC_LISTS
=
(
(
'array_matching_dtype'
,
array
.
array
(
'i'
,
[
9
,
8
,
7
])),
(
'numpy_matching_dtype'
,
np
.
array
([
7
,
8
,
9
],
dtype
=
np
.
int32
)),
)
NUMERIC_LISTS
=
CONVERTED_NUMERIC_LISTS
+
NOT_CONVERTED_NUMERIC_LISTS
def
test_return_span
(
self
):
def
test_return_span
(
self
):
values
=
[
1
,
2
,
3
,
4
]
values
=
[
1
,
2
,
3
,
4
]
container
=
absl_example
.
VectorContainer
()
container
=
absl_example
.
VectorContainer
()
self
.
assertSequenceEqual
(
container
.
make_span
(
values
),
values
)
self
.
assertSequenceEqual
(
container
.
make_span
(
values
),
values
)
CONVERTED_NUMERIC_LISTS
=
((
'numpy_wrong_dtype'
,
np
.
array
([
7
,
8
,
9
],
dtype
=
np
.
uint16
)),
(
'tuple'
,
(
1
,
2
,
3
)),
(
'list'
,
[
4
,
5
,
6
]))
NOT_CONVERTED_NUMERIC_LISTS
=
((
'numpy_matching_dtype'
,
np
.
array
([
7
,
8
,
9
],
dtype
=
np
.
int32
)),)
NUMERIC_LISTS
=
CONVERTED_NUMERIC_LISTS
+
NOT_CONVERTED_NUMERIC_LISTS
@parameterized.named_parameters
(
*
NUMERIC_LISTS
)
@parameterized.named_parameters
(
*
NUMERIC_LISTS
)
def
test_pass_span_from
(
self
,
values
):
def
test_pass_span_from
(
self
,
values
):
# Pass values twice- one will be converted to a span, the other to a vector
# Pass values twice- one will be converted to a span, the other to a vector
...
...
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