Commit 6c4ce1a2 authored by Yannick DAYER's avatar Yannick DAYER
Browse files

[flake8] Refactor and added flake8 config file

parent 1b70c99e
[flake8]
max-line-length = 88
select = B,C,E,F,W,T4,B9,B950
ignore = E501, W503, E203
from . import algorithm
from . import test
from . import algorithm # noqa: F401
from . import test # noqa: F401
def get_config():
......
......@@ -109,7 +109,7 @@ class GMM(Algorithm):
)
#######################################################
################ UBM training #########################
# UBM training #
def train_ubm(self, array):
......@@ -190,7 +190,7 @@ class GMM(Algorithm):
self.save_ubm(projector_file)
#######################################################
############## GMM training using UBM #################
# GMM training using UBM #
def load_ubm(self, ubm_file):
hdf5file = bob.io.base.HDF5File(ubm_file)
......@@ -265,7 +265,7 @@ class GMM(Algorithm):
return self.enroll_gmm(array)
######################################################
################ Feature comparison ##################
# Feature comparison #
def read_model(self, model_file):
"""Reads the model, which is a GMM machine"""
return bob.learn.em.GMMMachine(bob.io.base.HDF5File(model_file))
......@@ -305,7 +305,7 @@ class GMMRegular(GMM):
)
#######################################################
################ UBM training #########################
# UBM training #
def train_enroller(self, train_features, enroller_file):
"""Computes the Universal Background Model from the training ("world") data"""
......@@ -313,14 +313,14 @@ class GMMRegular(GMM):
return self.train_projector(train_features, enroller_file)
#######################################################
############## GMM training using UBM #################
# GMM training using UBM #
def load_enroller(self, enroller_file):
"""Reads the UBM model from file"""
return self.load_projector(enroller_file)
######################################################
################ Feature comparison ##################
# Feature comparison #
def score(self, model, probe):
"""Computes the score for the given model and the given probe.
The score are Log-Likelihood.
......
......@@ -3,7 +3,6 @@
# Manuel Guenther <Manuel.Guenther@idiap.ch>
import logging
import types
import numpy
......@@ -128,7 +127,7 @@ class ISV(GMM):
self.load_isv(hdf5file)
#######################################################
################ ISV training #########################
# ISV training #
def project_isv(self, projected_ubm):
projected_isv = numpy.ndarray(
shape=(self.ubm.shape[0] * self.ubm.shape[1],), dtype=numpy.float64
......@@ -145,7 +144,7 @@ class ISV(GMM):
return [projected_ubm, projected_isv]
#######################################################
################## ISV model enroll ####################
# ISV model enroll #
def write_feature(self, data, feature_file):
gmmstats = data[0]
......@@ -193,7 +192,7 @@ class ISV(GMM):
return machine
######################################################
################ Feature comparison ##################
# Feature comparison #
def read_model(self, model_file):
"""Reads the ISV Machine that holds the model"""
machine = bob.learn.em.ISVMachine(bob.io.base.HDF5File(model_file))
......
......@@ -342,7 +342,7 @@ class IVector(GMM):
return out_ivector
#######################################################
############## IVector projection #####################
# IVector projection #
def project(self, feature_array):
"""Computes GMM statistics against a UBM, then corresponding Ux vector"""
self._check_feature(feature_array)
......@@ -362,7 +362,7 @@ class IVector(GMM):
return ivector
#######################################################
################## Read / Write I-Vectors ####################
# Read / Write I-Vectors #
def write_feature(self, data, feature_file):
"""Saves the feature, which is the (whitened) I-Vector."""
bob.bio.base.save(data, feature_file)
......@@ -372,7 +372,7 @@ class IVector(GMM):
return bob.bio.base.load(feature_file)
#######################################################
################## Model Enrollment ###################
# Model Enrollment #
def enroll(self, enroll_features):
"""Performs IVector enrollment"""
[self._check_ivector(feature) for feature in enroll_features]
......@@ -385,7 +385,7 @@ class IVector(GMM):
return average_ivector
######################################################
################ Feature comparison ##################
# Feature comparison #
def read_model(self, model_file):
"""Reads the whitened i-vector that holds the model"""
if self.use_plda:
......
......@@ -60,7 +60,7 @@ class JFA(GMM):
self.load_ubm(projector_file)
#######################################################
################ JFA training #########################
# JFA training #
def train_enroller(self, train_features, enroller_file):
# assert that all training features are GMMStatistics
for client_feature in train_features:
......@@ -85,7 +85,7 @@ class JFA(GMM):
self.jfa_base.save(bob.io.base.HDF5File(enroller_file, "w"))
#######################################################
################## JFA model enroll ####################
# JFA model enroll #
def load_enroller(self, enroller_file):
"""Reads the JFA base from file"""
# now, load the JFA base, if it is included in the file
......@@ -108,7 +108,7 @@ class JFA(GMM):
return machine
######################################################
################ Feature comparison ##################
# Feature comparison #
def read_model(self, model_file):
"""Reads the JFA Machine that holds the model"""
machine = bob.learn.em.JFAMachine(bob.io.base.HDF5File(model_file))
......
#!/usr/bin/env python
import numpy
import bob.bio.gmm
algorithm = bob.bio.gmm.algorithm.GMMRegular(number_of_gaussians=512)
#!/usr/bin/env python
import numpy
import bob.bio.gmm
algorithm = bob.bio.gmm.algorithm.JFA(
......
from . import dummy
from . import dummy # noqa: F401
from . import extractor
from . import extractor # noqa: F401
......@@ -18,36 +18,29 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import math
import os
import shutil
import sys
import numpy
import pkg_resources
import bob.bio.gmm
import bob.io.base
import bob.io.base.test_utils
import bob.learn.linear
from nose.plugins.skip import SkipTest
from bob.bio.base.test import utils
logger = logging.getLogger("bob.bio.gmm")
import pkg_resources
regenerate_refs = False
seed_value = 5489
import sys
_mac_os = sys.platform == "darwin"
import scipy.spatial
import bob.bio.gmm
import bob.io.base
import bob.io.base.test_utils
import bob.learn.linear
from bob.bio.base.test import utils
def _compare(
data, reference, write_function=bob.bio.base.save, read_function=bob.bio.base.load
):
......
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
import glob
import os
import sys
import time
import pkg_resources
import sphinx_rtd_theme
# For inter-documentation mapping:
from bob.extension.utils import link_documentation
from bob.extension.utils import load_requirements
# -- General configuration -----------------------------------------------------
......@@ -75,7 +79,6 @@ master_doc = "index"
# General information about the project.
project = u"bob.bio.gmm"
import time
copyright = u"%s, Idiap Research Institute" % time.strftime("%Y")
......@@ -137,8 +140,6 @@ owner = [u"Idiap Research Institute"]
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme
......@@ -235,10 +236,6 @@ autodoc_default_options = {
"show-inheritance": True,
}
# For inter-documentation mapping:
from bob.extension.utils import link_documentation
from bob.extension.utils import load_requirements
sphinx_requirements = "extra-intersphinx.txt"
if os.path.exists(sphinx_requirements):
intersphinx_mapping = link_documentation(
......
......@@ -36,11 +36,11 @@
from setuptools import dist
from setuptools import setup
dist.Distribution(dict(setup_requires=["bob.extension"]))
from bob.extension.utils import find_packages
from bob.extension.utils import load_requirements
dist.Distribution(dict(setup_requires=["bob.extension"]))
install_requires = load_requirements()
# The only thing we do in this file is to call the setup() function with all
......
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