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
MMCV
Commits
657f03ad
"torchvision/vscode:/vscode.git/clone" did not exist on "07cbb46aba8569f0fac95667d57421391e6d36e9"
Unverified
Commit
657f03ad
authored
Jun 17, 2020
by
Kai Chen
Committed by
GitHub
Jun 17, 2020
Browse files
replace DeprecationWarning with UserWarning (#353)
parent
79942100
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
8 deletions
+7
-8
mmcv/utils/registry.py
mmcv/utils/registry.py
+1
-2
tests/test_registry.py
tests/test_registry.py
+6
-6
No files found.
mmcv/utils/registry.py
View file @
657f03ad
...
@@ -63,8 +63,7 @@ class Registry:
...
@@ -63,8 +63,7 @@ class Registry:
warnings
.
warn
(
warnings
.
warn
(
'The old API of register_module(module, force=False) '
'The old API of register_module(module, force=False) '
'is deprecated and will be removed, please use the new API '
'is deprecated and will be removed, please use the new API '
'register_module(name=None, force=False, module=None) instead.'
,
'register_module(name=None, force=False, module=None) instead.'
)
DeprecationWarning
)
if
cls
is
None
:
if
cls
is
None
:
return
partial
(
self
.
deprecated_register_module
,
force
=
force
)
return
partial
(
self
.
deprecated_register_module
,
force
=
force
)
self
.
_register_module
(
cls
,
force
=
force
)
self
.
_register_module
(
cls
,
force
=
force
)
...
...
tests/test_registry.py
View file @
657f03ad
...
@@ -82,15 +82,15 @@ def test_registry():
...
@@ -82,15 +82,15 @@ def test_registry():
pass
pass
# begin: test old APIs
# begin: test old APIs
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
CATS
.
register_module
(
SphynxCat
)
CATS
.
register_module
(
SphynxCat
)
assert
CATS
.
get
(
'SphynxCat'
).
__name__
==
'SphynxCat'
assert
CATS
.
get
(
'SphynxCat'
).
__name__
==
'SphynxCat'
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
CATS
.
register_module
(
SphynxCat
,
force
=
True
)
CATS
.
register_module
(
SphynxCat
,
force
=
True
)
assert
CATS
.
get
(
'SphynxCat'
).
__name__
==
'SphynxCat'
assert
CATS
.
get
(
'SphynxCat'
).
__name__
==
'SphynxCat'
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
@
CATS
.
register_module
@
CATS
.
register_module
class
NewCat
:
class
NewCat
:
...
@@ -98,11 +98,11 @@ def test_registry():
...
@@ -98,11 +98,11 @@ def test_registry():
assert
CATS
.
get
(
'NewCat'
).
__name__
==
'NewCat'
assert
CATS
.
get
(
'NewCat'
).
__name__
==
'NewCat'
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
CATS
.
deprecated_register_module
(
SphynxCat
,
force
=
True
)
CATS
.
deprecated_register_module
(
SphynxCat
,
force
=
True
)
assert
CATS
.
get
(
'SphynxCat'
).
__name__
==
'SphynxCat'
assert
CATS
.
get
(
'SphynxCat'
).
__name__
==
'SphynxCat'
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
@
CATS
.
deprecated_register_module
@
CATS
.
deprecated_register_module
class
CuteCat
:
class
CuteCat
:
...
@@ -110,7 +110,7 @@ def test_registry():
...
@@ -110,7 +110,7 @@ def test_registry():
assert
CATS
.
get
(
'CuteCat'
).
__name__
==
'CuteCat'
assert
CATS
.
get
(
'CuteCat'
).
__name__
==
'CuteCat'
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
@
CATS
.
deprecated_register_module
(
force
=
True
)
@
CATS
.
deprecated_register_module
(
force
=
True
)
class
NewCat2
:
class
NewCat2
:
...
...
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