Commit 196e47a9 authored by Anthony Larcher's avatar Anthony Larcher
Browse files

refactoring

parent ae14ad83
......@@ -34,7 +34,6 @@ import os
import sys
# Read environment variable if it exists
SIDEKIT_CONFIG={"libsvm":True,
"mpi":False,
......
......@@ -40,7 +40,6 @@ import torch
import warnings
import sidekit.frontend
from ..sidekit_io import init_logging
from ..sidekit_wrappers import check_path_existance
__license__ = "LGPL"
......
This diff is collapsed.
......@@ -418,7 +418,7 @@ def h5merge(output_filename, input_filename_list):
fo.create_dataset(key, data=value)
def init_logging(level=logging.INFO, filename=None):
def init_logging(level=logging.DEBUG, filename=None):
"""
Initialize a logger
......@@ -426,18 +426,35 @@ def init_logging(level=logging.INFO, filename=None):
:param filename: name of the output file
"""
numpy.set_printoptions(linewidth=250, precision=4)
frm = '%(asctime)s - %(levelname)s - %(message)s'
root = logging.getLogger()
if root.handlers:
for handler in root.handlers:
root.removeHandler(handler)
logging.basicConfig(format=frm, level=level)
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename='./myapp.log',
filemode='w')
if filename is not None:
fh = logging.FileHandler(filename)
fh.setFormatter(logging.Formatter(frm))
fh.setFormatter(logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s'))
fh.setLevel(level)
root.addHandler(fh)
console = logging.StreamHandler()
console.setLevel(logging.INFO)
# set a format which is simpler for console use
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
# tell the handler to use this format
console.setFormatter(formatter)
# add the handler to the root logger
logging.getLogger('').addHandler(console)
def write_matrix_hdf5(M, filename):
with h5py.File(filename, "w") as h5f:
......
Supports Markdown
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