Skip to content

Commit

Permalink
Sort and remove unused mports
Browse files Browse the repository at this point in the history
  • Loading branch information
Erin Wild committed Feb 19, 2019
1 parent 81a1e94 commit 5318d92
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 44 deletions.
5 changes: 1 addition & 4 deletions sompy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

from logging.config import dictConfig
import matplotlib

import matplotlib
#matplotlib.use('Agg') # Use whatever backend is available

dictConfig({
Expand All @@ -25,7 +24,5 @@
}
})



from .sompy import SOMFactory
from .visualization import *
4 changes: 2 additions & 2 deletions sompy/codebook.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import numpy as np
import scipy as sp

from sklearn.decomposition import PCA
#from sklearn.decomposition import RandomizedPCA# (randomizedpca is deprecated)

from .decorators import timeit


Expand All @@ -13,6 +12,7 @@ class InvalidNodeIndexError(Exception):
class InvalidMapsizeError(Exception):
pass


def generate_hex_lattice(n_rows, n_columns):
x_coord = []
y_coord = []
Expand Down
3 changes: 2 additions & 1 deletion sompy/neighborhood.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
import inspect
import sys

import numpy as np

small = .000000000001


Expand Down
5 changes: 3 additions & 2 deletions sompy/normalization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import sys
import inspect
import sys

import numpy as np


class NormalizerFactory(object):
Expand Down
16 changes: 7 additions & 9 deletions sompy/sompy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,21 @@
# Contributor: Sebastian Packmann ([email protected])


import tempfile
import os
import itertools
import logging
import os
import tempfile
from multiprocessing import cpu_count
from multiprocessing.dummy import Pool
from time import time

import numpy as np

from time import time
from multiprocessing.dummy import Pool
from multiprocessing import cpu_count
from scipy.sparse import csr_matrix
from sklearn import neighbors
from sklearn.externals.joblib import Parallel, delayed, load, dump
import sys
from sklearn.externals.joblib import dump, load

from .decorators import timeit
from .codebook import Codebook
from .decorators import timeit
from .neighborhood import NeighborhoodFactory
from .normalization import NormalizerFactory

Expand Down
4 changes: 1 addition & 3 deletions sompy/visualization/bmuhits.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from matplotlib import pyplot as plt

from .mapview import MapView

from sompy.visualization.plot_tools import plot_hex_map

from .plot_tools import plot_hex_map


class BmuHitsView(MapView):
Expand Down
5 changes: 3 additions & 2 deletions sompy/visualization/dotmap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .view import MatplotView
from matplotlib import pyplot as plt
import numpy as np
from matplotlib import pyplot as plt

from .view import MatplotView


class DotMapView(MatplotView):
Expand Down
8 changes: 4 additions & 4 deletions sompy/visualization/histogram.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from .view import MatplotView
from matplotlib import pyplot as plt
from matplotlib import cm
from matplotlib.colors import LogNorm
import numpy as np
from matplotlib import cm, pyplot as plt
from matplotlib.colors import LogNorm

from .view import MatplotView


class Hist2d(MatplotView):
Expand Down
6 changes: 2 additions & 4 deletions sompy/visualization/hitmap.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from .view import MatplotView
from sompy.visualization.plot_tools import plot_hex_map
from matplotlib import pyplot as plt
import numpy as np
from matplotlib import pyplot as plt

from .mapview import MapView

from .plot_tools import plot_hex_map


class HitMapView(MapView):
Expand Down
9 changes: 3 additions & 6 deletions sompy/visualization/mapview.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from matplotlib import colors
import matplotlib
import numpy as np
from matplotlib import pyplot as plt

from sompy.visualization.plot_tools import plot_hex_map
from .plot_tools import plot_hex_map
from .view import MatplotView
from matplotlib import pyplot as plt
import numpy as np


class MapView(MatplotView):
Expand Down Expand Up @@ -188,5 +187,3 @@ def show(self, som, what='codebook', which_dim='all', cmap=None,
plt.plot(mp, '-k', linewidth=0.8)

#plt.show()


16 changes: 9 additions & 7 deletions sompy/visualization/umatrix.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from .view import MatplotView
from matplotlib import pyplot as plt
from pylab import imshow, contour
from math import sqrt

import numpy as np
import pylab
import scipy
from matplotlib import pyplot as plt

from .view import MatplotView


class UMatrixView(MatplotView):
Expand Down Expand Up @@ -36,16 +38,16 @@ def show(self, som, distance2=1, row_normalized=False, show_data=True,
coord = som.bmu_ind_to_xy(proj)

self._fig, ax = plt.subplots(1, 1)
imshow(umat, cmap=plt.cm.get_cmap('RdYlBu_r'), alpha=1)
pylab.imshow(umat, cmap=plt.cm.get_cmap('RdYlBu_r'), alpha=1)

if contooor:
mn = np.min(umat.flatten())
mx = np.max(umat.flatten())
std = np.std(umat.flatten())
md = np.median(umat.flatten())
mx = md + 0 * std
contour(umat, np.linspace(mn, mx, 15), linewidths=0.7,
cmap=plt.cm.get_cmap('Blues'))
pylab.contour(umat, np.linspace(mn, mx, 15), linewidths=0.7,
cmap=plt.cm.get_cmap('Blues'))

if show_data:
plt.scatter(coord[:, 1], coord[:, 0], s=2, alpha=1., c='Gray',
Expand Down Expand Up @@ -76,7 +78,7 @@ def show(self, som, distance2=1, row_normalized=False, show_data=True,
# 'Laplacian of Gaussian'
blobs = blob_log(image, max_sigma=5, num_sigma=4, threshold=.152)
blobs[:, 2] = blobs[:, 2] * sqrt(2)
imshow(umat, cmap=plt.cm.get_cmap('RdYlBu_r'), alpha=1)
pylab.imshow(umat, cmap=plt.cm.get_cmap('RdYlBu_r'), alpha=1)
sel_points = list()

for blob in blobs:
Expand Down

0 comments on commit 5318d92

Please sign in to comment.