Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
6b0fcbbf
Unverified
Commit
6b0fcbbf
authored
Sep 26, 2025
by
Cyrus Leung
Committed by
GitHub
Sep 25, 2025
Browse files
[Misc] Simplify `test_argsort_mm_positions` (#25690)
Signed-off-by:
DarkLight1337
<
tlleungac@connect.ust.hk
>
parent
0fa673af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
26 deletions
+21
-26
tests/multimodal/test_utils.py
tests/multimodal/test_utils.py
+21
-26
No files found.
tests/multimodal/test_utils.py
View file @
6b0fcbbf
...
...
@@ -5,7 +5,6 @@ import base64
import
mimetypes
import
os
from
tempfile
import
NamedTemporaryFile
,
TemporaryDirectory
from
typing
import
TYPE_CHECKING
,
NamedTuple
import
numpy
as
np
import
pytest
...
...
@@ -15,9 +14,6 @@ from vllm.multimodal.image import convert_image_mode
from
vllm.multimodal.inputs
import
PlaceholderRange
from
vllm.multimodal.utils
import
MediaConnector
,
argsort_mm_positions
if
TYPE_CHECKING
:
from
vllm.multimodal.inputs
import
MultiModalPlaceholderDict
# Test different image extensions (JPG/PNG) and formats (gray/RGB/RGBA)
TEST_IMAGE_ASSETS
=
[
"2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
,
# "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
...
...
@@ -218,18 +214,13 @@ async def test_fetch_video_http_with_dynamic_loader(
assert
metadata_sync
[
"video_backend"
]
==
"opencv_dynamic"
# Used for `test_argsort_mm_positions`.
class
TestCase
(
NamedTuple
):
mm_positions
:
"MultiModalPlaceholderDict"
expected_modality_idxs
:
list
[
tuple
[
str
,
int
]]
def
test_argsort_mm_positions
():
test_cases
=
[
# yapf: disable
@
pytest
.
mark
.
parametrize
(
"case"
,
[
# Single modality
## Internally sorted
TestCase
(
dict
(
mm_positions
=
{
"image"
:
[
PlaceholderRange
(
offset
=
0
,
length
=
2
),
...
...
@@ -242,7 +233,7 @@ def test_argsort_mm_positions():
],
),
## Internally unsorted
TestCase
(
dict
(
mm_positions
=
{
"image"
:
[
PlaceholderRange
(
offset
=
3
,
length
=
2
),
...
...
@@ -257,7 +248,7 @@ def test_argsort_mm_positions():
# Two modalities
## Internally sorted
TestCase
(
dict
(
mm_positions
=
{
"image"
:
[
PlaceholderRange
(
offset
=
7
,
length
=
4
),
...
...
@@ -276,7 +267,7 @@ def test_argsort_mm_positions():
],
),
## Interleaved, internally sorted
TestCase
(
dict
(
mm_positions
=
{
"image"
:
[
PlaceholderRange
(
offset
=
0
,
length
=
4
),
...
...
@@ -295,7 +286,7 @@ def test_argsort_mm_positions():
],
),
## Interleaved, internally unsorted
TestCase
(
dict
(
mm_positions
=
{
"image"
:
[
PlaceholderRange
(
offset
=
8
,
length
=
2
),
...
...
@@ -316,7 +307,7 @@ def test_argsort_mm_positions():
# Three modalities
## Internally sorted
TestCase
(
dict
(
mm_positions
=
{
"image"
:
[
PlaceholderRange
(
offset
=
15
,
length
=
7
),
...
...
@@ -341,7 +332,7 @@ def test_argsort_mm_positions():
],
),
## Interleaved, internally sorted
TestCase
(
dict
(
mm_positions
=
{
"image"
:
[
PlaceholderRange
(
offset
=
0
,
length
=
2
),
...
...
@@ -363,8 +354,8 @@ def test_argsort_mm_positions():
(
"image"
,
2
),
],
),
## Interleaved, internally
s
unorted
TestCase
(
## Interleaved, internally un
s
orted
dict
(
mm_positions
=
{
"image"
:
[
PlaceholderRange
(
offset
=
0
,
length
=
2
),
...
...
@@ -386,9 +377,13 @@ def test_argsort_mm_positions():
(
"image"
,
1
),
],
),
]
],
)
# yapf: enable
def
test_argsort_mm_positions
(
case
):
mm_positions
=
case
[
"mm_positions"
]
expected_modality_idxs
=
case
[
"expected_modality_idxs"
]
for
mm_positions
,
expected_modality_idxs
in
test_cases
:
modality_idxs
=
argsort_mm_positions
(
mm_positions
)
modality_idxs
=
argsort_mm_positions
(
mm_positions
)
assert
modality_idxs
==
expected_modality_idxs
assert
modality_idxs
==
expected_modality_idxs
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