Skip to content

Commit

Permalink
Fix docstring (#913)
Browse files Browse the repository at this point in the history
* Fix docstring

* fix
  • Loading branch information
zhouzaida committed Feb 13, 2023
1 parent c712070 commit ad0b296
Show file tree
Hide file tree
Showing 20 changed files with 92 additions and 89 deletions.
22 changes: 11 additions & 11 deletions mmengine/fileio/file_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class FileClient:
Args:
backend (str, optional): The storage backend type. Options are "disk",
"memcached", "lmdb", "http" and "petrel". Default: None.
"memcached", "lmdb", "http" and "petrel". Defaults to None.
prefix (str, optional): The prefix of the registered storage backend.
Options are "s3", "http", "https". Default: None.
Options are "s3", "http", "https". Defaults to None.
Examples:
>>> # only set backend
Expand Down Expand Up @@ -163,9 +163,9 @@ def infer_client(cls,
Args:
file_client_args (dict, optional): Arguments to instantiate a
FileClient. Default: None.
FileClient. Defaults to None.
uri (str | Path, optional): Uri to be parsed that contains the file
prefix. Default: None.
prefix. Defaults to None.
Examples:
>>> uri = 's3://path/of/your/file'
Expand Down Expand Up @@ -263,7 +263,7 @@ def get_text(self, filepath):
force (bool, optional): Whether to override the backend if the name
has already been registered. Defaults to False.
prefixes (str or list[str] or tuple[str], optional): The prefixes
of the registered storage backend. Default: None.
of the registered storage backend. Defaults to None.
`New in version 1.3.15.`
"""
if backend is not None:
Expand Down Expand Up @@ -302,7 +302,7 @@ def get_text(self, filepath: Union[str, Path], encoding='utf-8') -> str:
Args:
filepath (str or Path): Path to read data.
encoding (str): The encoding format used to open the ``filepath``.
Default: 'utf-8'.
Defaults to 'utf-8'.
Returns:
str: Expected text reading from ``filepath``.
Expand Down Expand Up @@ -333,7 +333,7 @@ def put_text(self, obj: str, filepath: Union[str, Path]) -> None:
obj (str): Data to be written.
filepath (str or Path): Path to write data.
encoding (str, optional): The encoding format used to open the
`filepath`. Default: 'utf-8'.
`filepath`. Defaults to 'utf-8'.
"""
self.client.put_text(obj, filepath)

Expand Down Expand Up @@ -442,12 +442,12 @@ def list_dir_or_file(self,
Args:
dir_path (str | Path): Path of the directory.
list_dir (bool): List the directories. Default: True.
list_file (bool): List the path of files. Default: True.
list_dir (bool): List the directories. Defaults to True.
list_file (bool): List the path of files. Defaults to True.
suffix (str or tuple[str], optional): File suffix
that we are interested in. Default: None.
that we are interested in. Defaults to None.
recursive (bool): If set to True, recursively scan the
directory. Default: False.
directory. Defaults to False.
Yields:
Iterable[str]: A relative path to ``dir_path``.
Expand Down
4 changes: 2 additions & 2 deletions mmengine/fileio/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,8 @@ def generate_presigned_url(
Args:
url (str): Url of video stream.
client_method (str): Method of client, 'get_object' or
'put_object'. Default: 'get_object'.
expires_in (int): expires, in seconds. Default: 3600.
'put_object'. Defaults to 'get_object'.
expires_in (int): expires, in seconds. Defaults to 3600.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. Defaults to None.
Expand Down
2 changes: 1 addition & 1 deletion mmengine/hooks/logger_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class LoggerHook(Hook):
by epoch. It can be true when running in epoch based runner.
If set to True, `after_val_epoch` will set `step` to self.epoch in
`runner.visualizer.add_scalars`. Otherwise `step` will be
self.iter. Default to True.
self.iter. Defaults to True.
backend_args (dict, optional): Arguments to instantiate the
preifx of uri corresponding backend. Defaults to None.
New in v0.2.0.
Expand Down
4 changes: 2 additions & 2 deletions mmengine/hooks/naive_visualization_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class NaiveVisualizationHook(Hook):
Args:
interval (int): Visualization interval. Defaults to 1.
draw_gt (bool): Whether to draw the ground truth. Default to True.
draw_gt (bool): Whether to draw the ground truth. Defaults to True.
draw_pred (bool): Whether to draw the predicted result.
Default to True.
Defaults to True.
"""
priority = 'NORMAL'

Expand Down
2 changes: 1 addition & 1 deletion mmengine/optim/optimizer/default_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DefaultOptimWrapperConstructor:
rate for parameters of offset layer in the deformable convs
of a model.
- ``bypass_duplicate`` (bool): If true, the duplicate parameters
would not be added into optimizer. Default: False.
would not be added into optimizer. Defaults to False.
Note:
Expand Down
2 changes: 1 addition & 1 deletion mmengine/optim/optimizer/optimizer_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class OptimWrapper:
``'inf'`` for infinity norm.
- error_if_nonfinite (bool): If True, an error is thrown if
the total norm of the gradients from :attr:`parameters` is
``nan``, ``inf``, or ``-inf``. Default: False (will switch
``nan``, ``inf``, or ``-inf``. Defaults to False (will switch
to True in the future)
If the key ``type`` is set to "value", the accepted keys are as
Expand Down
12 changes: 6 additions & 6 deletions mmengine/optim/scheduler/lr_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,20 @@ class OneCycleLR(LRSchedulerMixin, OneCycleParamScheduler):
total_steps (int): The total number of steps in the cycle. Note that
if a value is not provided here, then it must be inferred by
providing a value for epochs and steps_per_epoch.
Default to None.
Defaults to None.
pct_start (float): The percentage of the cycle (in number of steps)
spent increasing the learning rate.
Default to 0.3
Defaults to 0.3
anneal_strategy (str): {'cos', 'linear'}
Specifies the annealing strategy: "cos" for cosine annealing,
"linear" for linear annealing.
Default to 'cos'
Defaults to 'cos'
div_factor (float): Determines the initial learning rate via
initial_param = eta_max/div_factor
Default to 25
Defaults to 25
final_div_factor (float): Determines the minimum learning rate via
eta_min = initial_param/final_div_factor
Default to 1e4
Defaults to 1e4
three_phase (bool): If ``True``, use a third phase of the schedule to
annihilate the learning rate according to 'final_div_factor'
instead of modifying the second phase (the first two phases will be
Expand Down Expand Up @@ -308,7 +308,7 @@ class CosineRestartLR(LRSchedulerMixin, CosineRestartParamScheduler):
Defaults to None.
eta_min_ratio (float, optional): The ratio of minimum parameter value
to the base parameter value. Either `min_lr` or `min_lr_ratio`
should be specified. Default: None.
should be specified. Defaults to None.
begin (int): Step at which to start updating the parameters.
Defaults to 0.
end (int): Step at which to stop updating the parameters.
Expand Down
2 changes: 1 addition & 1 deletion mmengine/optim/scheduler/momentum_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class CosineRestartMomentum(MomentumSchedulerMixin,
Defaults to None.
eta_min_ratio (float, optional): The ratio of minimum parameter value
to the base parameter value. Either `min_lr` or `min_lr_ratio`
should be specified. Default: None.
should be specified. Defaults to None.
begin (int): Step at which to start updating the parameters.
Defaults to 0.
end (int): Step at which to stop updating the parameters.
Expand Down
10 changes: 5 additions & 5 deletions mmengine/optim/scheduler/param_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,20 +924,20 @@ class OneCycleParamScheduler(_ParamScheduler):
for each parameter group.
total_steps (int): The total number of steps in the cycle. Note that
if a value is not provided here, then it will be equal to
``end - begin``. Default to None
``end - begin``. Defaults to None
pct_start (float): The percentage of the cycle (in number of steps)
spent increasing the learning rate.
Default to 0.3
Defaults to 0.3
anneal_strategy (str): {'cos', 'linear'}
Specifies the annealing strategy: "cos" for cosine annealing,
"linear" for linear annealing.
Default to 'cos'
Defaults to 'cos'
div_factor (float): Determines the initial learning rate via
initial_param = eta_max/div_factor
Default to 25
Defaults to 25
final_div_factor (float): Determines the minimum learning rate via
eta_min = initial_param/final_div_factor
Default to 1e4
Defaults to 1e4
three_phase (bool): If ``True``, use a third phase of the schedule to
annihilate the learning rate according to 'final_div_factor'
instead of modifying the second phase (the first two phases will be
Expand Down
2 changes: 1 addition & 1 deletion mmengine/registry/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def register_module(
name (str or list of str, optional): The module name to be
registered. If not specified, the class name will be used.
force (bool): Whether to override an existing class with the same
name. Default to False.
name. Defaults to False.
module (type, optional): Module class or function to be registered.
Defaults to None.
Expand Down
2 changes: 1 addition & 1 deletion mmengine/registry/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def traverse_registry_tree(registry: Registry, verbose: bool = True) -> list:
Args:
registry (Registry): a registry node in the registry tree.
verbose (bool): Whether to print log. Default: True
verbose (bool): Whether to print log. Defaults to True
Returns:
list: Statistic results of all modules in each node of the registry
Expand Down
21 changes: 11 additions & 10 deletions mmengine/runner/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def load_state_dict(module, state_dict, strict=False, logger=None):
state_dict (OrderedDict): Weights.
strict (bool): whether to strictly enforce that the keys
in :attr:`state_dict` match the keys returned by this module's
:meth:`~torch.nn.Module.state_dict` function. Default: ``False``.
:meth:`~torch.nn.Module.state_dict` function. Defaults to False.
logger (:obj:`logging.Logger`, optional): Logger to log the error
message. If not specified, print function will be used.
"""
Expand Down Expand Up @@ -285,7 +285,7 @@ def load_checkpoint(cls, filename, map_location=None, logger='current'):
Args:
filename (str): checkpoint file name with given prefix
map_location (str, optional): Same as :func:`torch.load`.
Default: None
Defaults to None
logger (str): The logger for message. Defaults to 'current'.
Returns:
Expand Down Expand Up @@ -332,7 +332,7 @@ def load_from_http(filename,
torchvision prefix
map_location (str, optional): Same as :func:`torch.load`.
model_dir (string, optional): directory in which to save the object,
Default: None
Defaults to None
Returns:
dict or OrderedDict: The loaded checkpoint.
Expand Down Expand Up @@ -364,7 +364,7 @@ def load_from_pavi(filename, map_location=None):
Args:
filename (str): checkpoint file path with pavi prefix
map_location (str, optional): Same as :func:`torch.load`.
Default: None
Defaults to None
Returns:
dict or OrderedDict: The loaded checkpoint.
Expand Down Expand Up @@ -443,7 +443,7 @@ def load_from_openmmlab(filename, map_location=None):
filename (str): checkpoint file path with open-mmlab or
openmmlab prefix
map_location (str, optional): Same as :func:`torch.load`.
Default: None
Defaults to None
Returns:
dict or OrderedDict: The loaded checkpoint.
Expand Down Expand Up @@ -504,9 +504,9 @@ def _load_checkpoint(filename, map_location=None, logger=None):
``open-mmlab://xxx``. Please refer to ``docs/model_zoo.md`` for
details.
map_location (str, optional): Same as :func:`torch.load`.
Default: None.
Defaults to None.
logger (:mod:`logging.Logger`, optional): The logger for error message.
Default: None
Defaults to None
Returns:
dict or OrderedDict: The loaded checkpoint. It can be either an
Expand All @@ -524,7 +524,8 @@ def _load_checkpoint_with_prefix(prefix, filename, map_location=None):
filename (str): Accept local filepath, URL, ``torchvision://xxx``,
``open-mmlab://xxx``. Please refer to ``docs/model_zoo.md`` for
details.
map_location (str | None): Same as :func:`torch.load`. Default: None.
map_location (str | None): Same as :func:`torch.load`.
Defaults to None.
Returns:
dict or OrderedDict: The loaded checkpoint.
Expand Down Expand Up @@ -594,7 +595,7 @@ def load_checkpoint(model,
logger (:mod:`logging.Logger` or None): The logger for error message.
revise_keys (list): A list of customized keywords to modify the
state_dict in checkpoint. Each item is a (pattern, replacement)
pair of the regular expression operations. Default: strip
pair of the regular expression operations. Defaults to strip
the prefix 'module.' by [(r'^module\\.', '')].
Returns:
Expand Down Expand Up @@ -668,7 +669,7 @@ def get_state_dict(module, destination=None, prefix='', keep_vars=False):
module.
prefix (str): Prefix of the key.
keep_vars (bool): Whether to keep the variable property of the
parameters. Default: False.
parameters. Defaults to False.
Returns:
dict: A dictionary containing a whole state of the module.
Expand Down
2 changes: 1 addition & 1 deletion mmengine/runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ def load_checkpoint(self,
the model and checkpoint.
revise_keys (list): A list of customized keywords to modify the
state_dict in checkpoint. Each item is a (pattern, replacement)
pair of the regular expression operations. Default: strip
pair of the regular expression operations. Defaults to strip
the prefix 'module.' by [(r'^module\\.', '')].
"""
checkpoint = _load_checkpoint(filename, map_location=map_location)
Expand Down
4 changes: 2 additions & 2 deletions mmengine/runner/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def set_random_seed(seed: Optional[int] = None,
deterministic (bool): Whether to set the deterministic option for
CUDNN backend, i.e., set `torch.backends.cudnn.deterministic`
to True and `torch.backends.cudnn.benchmark` to False.
Default: False.
Defaults to False.
diff_rank_seed (bool): Whether to add rank number to the random seed to
have different random seed in different threads. Default: False.
have different random seed in different threads. Defaults to False.
"""
if seed is None:
seed = sync_random_seed()
Expand Down
6 changes: 3 additions & 3 deletions mmengine/utils/dl_utils/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ def load_url(url,
map_location (optional): a function or a dict specifying how to
remap storage locations (see torch.load)
progress (bool, optional): whether or not to display a progress bar
to stderr. Default: True
to stderr. Defaults to True
check_hash(bool, optional): If True, the filename part of the URL
should follow the naming convention ``filename-<sha256>.ext``
where ``<sha256>`` is the first eight or more digits of the
SHA256 hash of the contents of the file. The hash is used to
ensure unique names and to verify the contents of the file.
Default: False
Defaults to False
file_name (str, optional): name for the downloaded file. Filename
from ``url`` will be used if not set. Default: None.
from ``url`` will be used if not set. Defaults to None.
Example:
>>> url = ('https://s3.amazonaws.com/pytorch/models/resnet18-5c106'
... 'cde.pth')
Expand Down
2 changes: 1 addition & 1 deletion mmengine/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def import_modules_from_strings(imports, allow_failed_imports=False):
Args:
imports (list | str | None): The given module names to be imported.
allow_failed_imports (bool): If True, the failed imports will return
None. Otherwise, an ImportError is raise. Default: False.
None. Otherwise, an ImportError is raise. Defaults to False.
Returns:
list[module] | module | None: The imported modules.
Expand Down
6 changes: 3 additions & 3 deletions mmengine/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def scandir(dir_path, suffix=None, recursive=False, case_sensitive=True):
Args:
dir_path (str | :obj:`Path`): Path of the directory.
suffix (str | tuple(str), optional): File suffix that we are
interested in. Default: None.
interested in. Defaults to None.
recursive (bool, optional): If set to True, recursively scan the
directory. Default: False.
directory. Defaults to False.
case_sensitive (bool, optional) : If set to False, ignore the case of
suffix. Default: True.
suffix. Defaults to True.
Returns:
A generator for all the interested files with relative paths.
Expand Down
2 changes: 1 addition & 1 deletion mmengine/utils/version_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def digit_version(version_str: str, length: int = 4):
Args:
version_str (str): The version string.
length (int): The maximum number of version levels. Default: 4.
length (int): The maximum number of version levels. Defaults to 4.
Returns:
tuple[int]: The version info in digits (integers).
Expand Down
Loading

0 comments on commit ad0b296

Please sign in to comment.