Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
1be7afd6
Unverified
Commit
1be7afd6
authored
Dec 08, 2021
by
Philip Meier
Committed by
GitHub
Dec 08, 2021
Browse files
rename TestWeights to appease pytest (#5054)
parent
cca452f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
test/test_prototype_models.py
test/test_prototype_models.py
+9
-9
No files found.
test/test_prototype_models.py
View file @
1be7afd6
...
@@ -203,7 +203,7 @@ def test_smoke():
...
@@ -203,7 +203,7 @@ def test_smoke():
# With this filter, every unexpected warning will be turned into an error
# With this filter, every unexpected warning will be turned into an error
@
pytest
.
mark
.
filterwarnings
(
"error"
)
@
pytest
.
mark
.
filterwarnings
(
"error"
)
class
TestHandleLegacyInterface
:
class
TestHandleLegacyInterface
:
class
Test
Weights
(
WeightsEnum
):
class
Model
Weights
(
WeightsEnum
):
Sentinel
=
Weights
(
url
=
"https://pytorch.org"
,
transforms
=
lambda
x
:
x
,
meta
=
dict
())
Sentinel
=
Weights
(
url
=
"https://pytorch.org"
,
transforms
=
lambda
x
:
x
,
meta
=
dict
())
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
...
@@ -211,11 +211,11 @@ class TestHandleLegacyInterface:
...
@@ -211,11 +211,11 @@ class TestHandleLegacyInterface:
[
[
pytest
.
param
(
dict
(),
id
=
"empty"
),
pytest
.
param
(
dict
(),
id
=
"empty"
),
pytest
.
param
(
dict
(
weights
=
None
),
id
=
"None"
),
pytest
.
param
(
dict
(
weights
=
None
),
id
=
"None"
),
pytest
.
param
(
dict
(
weights
=
Test
Weights
.
Sentinel
),
id
=
"Weights"
),
pytest
.
param
(
dict
(
weights
=
Model
Weights
.
Sentinel
),
id
=
"Weights"
),
],
],
)
)
def
test_no_warn
(
self
,
kwargs
):
def
test_no_warn
(
self
,
kwargs
):
@
handle_legacy_interface
(
weights
=
(
"pretrained"
,
self
.
Test
Weights
.
Sentinel
))
@
handle_legacy_interface
(
weights
=
(
"pretrained"
,
self
.
Model
Weights
.
Sentinel
))
def
builder
(
*
,
weights
=
None
):
def
builder
(
*
,
weights
=
None
):
pass
pass
...
@@ -223,7 +223,7 @@ class TestHandleLegacyInterface:
...
@@ -223,7 +223,7 @@ class TestHandleLegacyInterface:
@
pytest
.
mark
.
parametrize
(
"pretrained"
,
(
True
,
False
))
@
pytest
.
mark
.
parametrize
(
"pretrained"
,
(
True
,
False
))
def
test_pretrained_pos
(
self
,
pretrained
):
def
test_pretrained_pos
(
self
,
pretrained
):
@
handle_legacy_interface
(
weights
=
(
"pretrained"
,
self
.
Test
Weights
.
Sentinel
))
@
handle_legacy_interface
(
weights
=
(
"pretrained"
,
self
.
Model
Weights
.
Sentinel
))
def
builder
(
*
,
weights
=
None
):
def
builder
(
*
,
weights
=
None
):
pass
pass
...
@@ -232,7 +232,7 @@ class TestHandleLegacyInterface:
...
@@ -232,7 +232,7 @@ class TestHandleLegacyInterface:
@
pytest
.
mark
.
parametrize
(
"pretrained"
,
(
True
,
False
))
@
pytest
.
mark
.
parametrize
(
"pretrained"
,
(
True
,
False
))
def
test_pretrained_kw
(
self
,
pretrained
):
def
test_pretrained_kw
(
self
,
pretrained
):
@
handle_legacy_interface
(
weights
=
(
"pretrained"
,
self
.
Test
Weights
.
Sentinel
))
@
handle_legacy_interface
(
weights
=
(
"pretrained"
,
self
.
Model
Weights
.
Sentinel
))
def
builder
(
*
,
weights
=
None
):
def
builder
(
*
,
weights
=
None
):
pass
pass
...
@@ -242,12 +242,12 @@ class TestHandleLegacyInterface:
...
@@ -242,12 +242,12 @@ class TestHandleLegacyInterface:
@
pytest
.
mark
.
parametrize
(
"pretrained"
,
(
True
,
False
))
@
pytest
.
mark
.
parametrize
(
"pretrained"
,
(
True
,
False
))
@
pytest
.
mark
.
parametrize
(
"positional"
,
(
True
,
False
))
@
pytest
.
mark
.
parametrize
(
"positional"
,
(
True
,
False
))
def
test_equivalent_behavior_weights
(
self
,
pretrained
,
positional
):
def
test_equivalent_behavior_weights
(
self
,
pretrained
,
positional
):
@
handle_legacy_interface
(
weights
=
(
"pretrained"
,
self
.
Test
Weights
.
Sentinel
))
@
handle_legacy_interface
(
weights
=
(
"pretrained"
,
self
.
Model
Weights
.
Sentinel
))
def
builder
(
*
,
weights
=
None
):
def
builder
(
*
,
weights
=
None
):
pass
pass
args
,
kwargs
=
((
pretrained
,),
dict
())
if
positional
else
((),
dict
(
pretrained
=
pretrained
))
args
,
kwargs
=
((
pretrained
,),
dict
())
if
positional
else
((),
dict
(
pretrained
=
pretrained
))
with
pytest
.
warns
(
UserWarning
,
match
=
f
"weights=
{
self
.
Test
Weights
.
Sentinel
if
pretrained
else
None
}
"
):
with
pytest
.
warns
(
UserWarning
,
match
=
f
"weights=
{
self
.
Model
Weights
.
Sentinel
if
pretrained
else
None
}
"
):
builder
(
*
args
,
**
kwargs
)
builder
(
*
args
,
**
kwargs
)
def
test_multi_params
(
self
):
def
test_multi_params
(
self
):
...
@@ -256,7 +256,7 @@ class TestHandleLegacyInterface:
...
@@ -256,7 +256,7 @@ class TestHandleLegacyInterface:
@
handle_legacy_interface
(
@
handle_legacy_interface
(
**
{
**
{
weights_param
:
(
pretrained_param
,
self
.
Test
Weights
.
Sentinel
)
weights_param
:
(
pretrained_param
,
self
.
Model
Weights
.
Sentinel
)
for
weights_param
,
pretrained_param
in
zip
(
weights_params
,
pretrained_params
)
for
weights_param
,
pretrained_param
in
zip
(
weights_params
,
pretrained_params
)
}
}
)
)
...
@@ -271,7 +271,7 @@ class TestHandleLegacyInterface:
...
@@ -271,7 +271,7 @@ class TestHandleLegacyInterface:
@
handle_legacy_interface
(
@
handle_legacy_interface
(
weights
=
(
weights
=
(
"pretrained"
,
"pretrained"
,
lambda
kwargs
:
self
.
Test
Weights
.
Sentinel
if
kwargs
[
"flag"
]
else
None
,
lambda
kwargs
:
self
.
Model
Weights
.
Sentinel
if
kwargs
[
"flag"
]
else
None
,
)
)
)
)
def
builder
(
*
,
weights
=
None
,
flag
):
def
builder
(
*
,
weights
=
None
,
flag
):
...
...
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