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
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
Hide 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:
warnings
.
warn
(
'The old API of register_module(module, force=False) '
'is deprecated and will be removed, please use the new API '
'register_module(name=None, force=False, module=None) instead.'
,
DeprecationWarning
)
'register_module(name=None, force=False, module=None) instead.'
)
if
cls
is
None
:
return
partial
(
self
.
deprecated_register_module
,
force
=
force
)
self
.
_register_module
(
cls
,
force
=
force
)
...
...
tests/test_registry.py
View file @
657f03ad
...
...
@@ -82,15 +82,15 @@ def test_registry():
pass
# begin: test old APIs
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
CATS
.
register_module
(
SphynxCat
)
assert
CATS
.
get
(
'SphynxCat'
).
__name__
==
'SphynxCat'
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
CATS
.
register_module
(
SphynxCat
,
force
=
True
)
assert
CATS
.
get
(
'SphynxCat'
).
__name__
==
'SphynxCat'
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
@
CATS
.
register_module
class
NewCat
:
...
...
@@ -98,11 +98,11 @@ def test_registry():
assert
CATS
.
get
(
'NewCat'
).
__name__
==
'NewCat'
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
CATS
.
deprecated_register_module
(
SphynxCat
,
force
=
True
)
assert
CATS
.
get
(
'SphynxCat'
).
__name__
==
'SphynxCat'
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
@
CATS
.
deprecated_register_module
class
CuteCat
:
...
...
@@ -110,7 +110,7 @@ def test_registry():
assert
CATS
.
get
(
'CuteCat'
).
__name__
==
'CuteCat'
with
pytest
.
warns
(
Deprecation
Warning
):
with
pytest
.
warns
(
User
Warning
):
@
CATS
.
deprecated_register_module
(
force
=
True
)
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