Commit a36ad180 authored by Yuxin Wu's avatar Yuxin Wu

Improve TOC style and fix some documentations

parent ce7e4892
...@@ -30,7 +30,7 @@ $(function (){ ...@@ -30,7 +30,7 @@ $(function (){
if(groupName in obj) { if(groupName in obj) {
obj[groupName].append(entry); obj[groupName].append(entry);
} else { } else {
var ul = $('<ul>'); var ul = $('<ul style="margin-bottom: 12px;">');
ul.append(entry); ul.append(entry);
obj[groupName] = ul; obj[groupName] = ul;
} }
...@@ -50,9 +50,9 @@ $(function (){ ...@@ -50,9 +50,9 @@ $(function (){
return; return;
var obj = createList(selected); var obj = createList(selected);
var block = $('<div style="min-width: 300px;">'); var block = $('<div style="min-width: 300px; margin-bottom: 2em;">');
for(var key in obj) { for(var key in obj) {
var a = $('<h5>'); var a = $('<h6 style="margin-bottom: 0;">');
a.html(key + ':'); a.html(key + ':');
block.append(a); block.append(a);
block.append(obj[key]); block.append(obj[key]);
......
...@@ -8,9 +8,6 @@ tensorpack.dataflow package ...@@ -8,9 +8,6 @@ tensorpack.dataflow package
<script type="text/javascript" src='../_static/build_toc_group.js'></script> <script type="text/javascript" src='../_static/build_toc_group.js'></script>
DataFlow
---------------
.. automodule:: tensorpack.dataflow .. automodule:: tensorpack.dataflow
:members: :members:
:undoc-members: :undoc-members:
......
tensorpack.tfutils package tensorpack.tfutils package
========================== ==========================
.. container:: custom-index
.. raw:: html
<script type="text/javascript" src='../_static/build_toc_group.js'></script>
tensorpack.tfutils.collection module tensorpack.tfutils.collection module
------------------------------------ ------------------------------------
...@@ -25,14 +31,6 @@ tensorpack.tfutils.gradproc module ...@@ -25,14 +31,6 @@ tensorpack.tfutils.gradproc module
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
tensorpack.tfutils.model_utils module
--------------------------------------
.. automodule:: tensorpack.tfutils.model_utils
:members:
:undoc-members:
:show-inheritance:
tensorpack.tfutils.scope_utils module tensorpack.tfutils.scope_utils module
-------------------------------------- --------------------------------------
......
...@@ -82,12 +82,3 @@ tensorpack.utils.viz module ...@@ -82,12 +82,3 @@ tensorpack.utils.viz module
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
Module contents
---------------
.. automodule:: tensorpack.utils
:members:
:undoc-members:
:show-inheritance:
termcolor termcolor
numpy numpy
tqdm tqdm
tensorflow
Sphinx>=1.6 Sphinx>=1.6
recommonmark==0.4.0 recommonmark==0.4.0
sphinx_rtd_theme sphinx_rtd_theme
mock mock
tensorflow
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# File: _test.py # File: _test.py
# Author: Yuxin Wu <ppwwyyxx@gmail.com> # Author: Yuxin Wu <ppwwyyxx@gmail.com>
import logging
import tensorflow as tf import tensorflow as tf
import unittest import unittest
...@@ -33,7 +34,7 @@ if __name__ == '__main__': ...@@ -33,7 +34,7 @@ if __name__ == '__main__':
import tensorpack import tensorpack
from tensorpack.utils import logger from tensorpack.utils import logger
from . import * from . import *
logger.disable_logger() logger.setLevel(logging.CRITICAL)
subs = tensorpack.models._test.TestModel.__subclasses__() subs = tensorpack.models._test.TestModel.__subclasses__()
for cls in subs: for cls in subs:
run_test_case(cls) run_test_case(cls)
...@@ -83,8 +83,8 @@ class Distribution(object): ...@@ -83,8 +83,8 @@ class Distribution(object):
@class_scope @class_scope
def entropy(self, x, theta): def entropy(self, x, theta):
r""" Entropy of this distribution parameterized by theta, r"""
estimated from a batch of samples. Entropy of this distribution parameterized by theta, estimated from a batch of samples.
.. math:: .. math::
......
...@@ -50,6 +50,7 @@ def graph_memoized(func): ...@@ -50,6 +50,7 @@ def graph_memoized(func):
kwargs.pop(GRAPH_ARG_NAME) kwargs.pop(GRAPH_ARG_NAME)
return func(*args, **kwargs) return func(*args, **kwargs)
@functools.wraps(func)
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
assert GRAPH_ARG_NAME not in kwargs, "No Way!!" assert GRAPH_ARG_NAME not in kwargs, "No Way!!"
graph = tf.get_default_graph() graph = tf.get_default_graph()
......
...@@ -11,7 +11,7 @@ from datetime import datetime ...@@ -11,7 +11,7 @@ from datetime import datetime
from six.moves import input from six.moves import input
import sys import sys
__all__ = ['set_logger_dir', 'disable_logger', 'auto_set_dir'] __all__ = ['set_logger_dir', 'auto_set_dir']
class _MyFormatter(logging.Formatter): class _MyFormatter(logging.Formatter):
...@@ -46,9 +46,10 @@ _LOGGING_METHOD = ['info', 'warning', 'error', 'critical', 'warn', 'exception', ...@@ -46,9 +46,10 @@ _LOGGING_METHOD = ['info', 'warning', 'error', 'critical', 'warn', 'exception',
# export logger functions # export logger functions
for func in _LOGGING_METHOD: for func in _LOGGING_METHOD:
locals()[func] = getattr(_logger, func) locals()[func] = getattr(_logger, func)
__all__.append(func)
def get_time_str(): def _get_time_str():
return datetime.now().strftime('%m%d-%H%M%S') return datetime.now().strftime('%m%d-%H%M%S')
...@@ -61,7 +62,7 @@ _FILE_HANDLER = None ...@@ -61,7 +62,7 @@ _FILE_HANDLER = None
def _set_file(path): def _set_file(path):
global _FILE_HANDLER global _FILE_HANDLER
if os.path.isfile(path): if os.path.isfile(path):
backup_name = path + '.' + get_time_str() backup_name = path + '.' + _get_time_str()
shutil.move(path, backup_name) shutil.move(path, backup_name)
info("Log file '{}' backuped to '{}'".format(path, backup_name)) # noqa: F821 info("Log file '{}' backuped to '{}'".format(path, backup_name)) # noqa: F821
hdl = logging.FileHandler( hdl = logging.FileHandler(
...@@ -97,13 +98,13 @@ If you're resuming from a previous run you can choose to keep it.""") ...@@ -97,13 +98,13 @@ If you're resuming from a previous run you can choose to keep it.""")
action = input().lower().strip() action = input().lower().strip()
act = action act = action
if act == 'b': if act == 'b':
backup_name = dirname + get_time_str() backup_name = dirname + _get_time_str()
shutil.move(dirname, backup_name) shutil.move(dirname, backup_name)
info("Directory '{}' backuped to '{}'".format(dirname, backup_name)) # noqa: F821 info("Directory '{}' backuped to '{}'".format(dirname, backup_name)) # noqa: F821
elif act == 'd': elif act == 'd':
shutil.rmtree(dirname) shutil.rmtree(dirname)
elif act == 'n': elif act == 'n':
dirname = dirname + get_time_str() dirname = dirname + _get_time_str()
info("Use a new log directory {}".format(dirname)) # noqa: F821 info("Use a new log directory {}".format(dirname)) # noqa: F821
elif act == 'k': elif act == 'k':
pass pass
...@@ -117,12 +118,6 @@ If you're resuming from a previous run you can choose to keep it.""") ...@@ -117,12 +118,6 @@ If you're resuming from a previous run you can choose to keep it.""")
_set_file(os.path.join(dirname, 'log.log')) _set_file(os.path.join(dirname, 'log.log'))
def disable_logger():
""" Disable all logging ability from this moment"""
for func in _LOGGING_METHOD:
globals()[func] = lambda x: None
def auto_set_dir(action=None, name=None): def auto_set_dir(action=None, name=None):
""" """
Use :func:`logger.set_logger_dir` to set log directory to Use :func:`logger.set_logger_dir` to set log directory to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment