Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
master_doc = 'index'

# General information about the project.
project = u'py_sonicvisualiser'
copyright = u'2014, David Doukhan'
project = 'py_sonicvisualiser'
copyright = '2014, David Doukhan'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -193,8 +193,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'py_sonicvisualiser.tex', u'py\\_sonicvisualiser Documentation',
u'David Doukhan', 'manual'),
('index', 'py_sonicvisualiser.tex', 'py\\_sonicvisualiser Documentation',
'David Doukhan', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -223,8 +223,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'py_sonicvisualiser', u'py_sonicvisualiser Documentation',
[u'David Doukhan'], 1)
('index', 'py_sonicvisualiser', 'py_sonicvisualiser Documentation',
['David Doukhan'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -237,8 +237,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'py_sonicvisualiser', u'py_sonicvisualiser Documentation',
u'David Doukhan', 'py_sonicvisualiser', 'One line description of project.',
('index', 'py_sonicvisualiser', 'py_sonicvisualiser Documentation',
'David Doukhan', 'py_sonicvisualiser', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
2 changes: 1 addition & 1 deletion examples/example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# append a continuous annotation layer corresponding to a sinusoidal signal
# on the spectrogram view previously defined
x = np.array(range(10000, 20000, 5)) / 1000.
x = np.array(list(range(10000, 20000, 5))) / 1000.
sve.add_continuous_annotations(x, 1 + 3 * np.sin(2 * x), view=specview)

# append a labelled interval annotation layer on a new view
Expand Down
6 changes: 3 additions & 3 deletions py_sonicvisualiser/SVContentHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import xml.sax as sax
import xml.dom.minidom as minidom
from SVDataset import SVDataset2D, SVDataset3D
from .SVDataset import SVDataset2D, SVDataset3D

class SVContentHandler(sax.ContentHandler):
"""
Expand All @@ -43,7 +43,7 @@ def startElement(self, name, attrs):
if name in ['model', 'dataset', 'layer']:
self.nbdata += 1

if name == 'model' and attrs.has_key('mainModel') and attrs.getValue('mainModel') == 'true':
if name == 'model' and 'mainModel' in attrs and attrs.getValue('mainModel') == 'true':
self.samplerate = int(attrs.getValue('sampleRate'))
self.nframes = int(attrs.getValue('end'))
self.mediafile = attrs.getValue('file')
Expand Down Expand Up @@ -72,7 +72,7 @@ def startElement(self, name, attrs):
elif name == 'window':
self.defwidth = int(attrs.getValue('width'))

for at, val in attrs.items():
for at, val in list(attrs.items()):
node.setAttribute(at, val)
self.curnode = node

Expand Down
10 changes: 5 additions & 5 deletions py_sonicvisualiser/SVDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ def set_data_from_iterable(self, frames, values, labels=None):
:type y: iterable
"""
if not isinstance(frames, collections.Iterable):
raise TypeError, "frames must be an iterable"
raise TypeError("frames must be an iterable")
if not isinstance(values, collections.Iterable):
raise TypeError, "values must be an iterable"
raise TypeError("values must be an iterable")
assert(len(frames) == len(values))
self.frames = frames
self.values = values
if labels is None:
self.label2int['New Point'] = 0
self.int2label[0] = 'New Point'
self.labels = [0 for i in xrange(len(frames))]
self.labels = [0 for i in range(len(frames))]
else:
if not isinstance(labels, collections.Iterable):
raise TypeError, "labels must be an iterable"
raise TypeError("labels must be an iterable")
for l in labels:
if l not in self.label2int:
self.label2int[l] = len(self.label2int)
Expand Down Expand Up @@ -111,7 +111,7 @@ def __init__(self, domdoc, datasetid, samplerate):
def set_data_from_iterable(self, frames, values, durations, labels=None):
SVDataset2D.set_data_from_iterable(self, frames, values, labels)
if not isinstance(durations, collections.Iterable):
raise TypeError, "durations must be an iterable"
raise TypeError("durations must be an iterable")
assert(len(self.frames) == len(durations))
self.durations = durations

Expand Down
10 changes: 5 additions & 5 deletions py_sonicvisualiser/SVEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
from os.path import basename
#import wave
import numpy as np
from SVDataset import SVDataset2D, SVDataset3D
from SVContentHandler import SVContentHandler
from .SVDataset import SVDataset2D, SVDataset3D
from .SVContentHandler import SVContentHandler
import scipy.io.wavfile as SW
import wave

Expand Down Expand Up @@ -186,7 +186,7 @@ def add_continuous_annotations(self, x, y, colourName='Purple', colour='#c832ff'
# datasetnode.set_data_from_iterable(map(int, np.array(x) * self.samplerate), y)
# data = dataset.appendChild(datasetnode)
dataset = self.data.appendChild(SVDataset2D(self.doc, str(imodel), self.samplerate))
dataset.set_data_from_iterable(map(int, np.array(x) * self.samplerate), y)
dataset.set_data_from_iterable(list(map(int, np.array(x) * self.samplerate)), y)
self.nbdata += 2

###### add layers
Expand Down Expand Up @@ -246,7 +246,7 @@ def add_interval_annotations(self, temp_idx, durations, labels, values=None, col
dataset = self.data.appendChild(SVDataset3D(self.doc, str(imodel), self.samplerate))
if values is None:
values = ([0] * len(temp_idx))
dataset.set_data_from_iterable(map(int, np.array(temp_idx) * self.samplerate), values, map(int, np.array(durations) * self.samplerate), labels)
dataset.set_data_from_iterable(list(map(int, np.array(temp_idx) * self.samplerate)), values, list(map(int, np.array(durations) * self.samplerate)), labels)


# dataset = self.data.appendChild(self.doc.createElement('dataset'))
Expand Down Expand Up @@ -444,7 +444,7 @@ def __add_spectrogram(self, model):

# append a continuous annotation layer corresponding to a sinusoidal signal
# on the spectrogram view previously defined
x = np.array(range(10000, 20000, 5)) / 1000.
x = np.array(list(range(10000, 20000, 5))) / 1000.
sve.add_continuous_annotations(x, 1 + 3 * np.sin(2 * x), view=specview)

# append a labelled interval annotation layer on a new view
Expand Down
2 changes: 1 addition & 1 deletion py_sonicvisualiser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
__version__ = get_versions()['version']
del get_versions

from SVEnv import SVEnv
from .SVEnv import SVEnv
20 changes: 10 additions & 10 deletions py_sonicvisualiser/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
if e.errno == errno.ENOENT:
continue
if verbose:
print("unable to run %s" % args[0])
print(("unable to run %s" % args[0]))
print(e)
return None
else:
if verbose:
print("unable to find command, tried %s" % (commands,))
print(("unable to find command, tried %s" % (commands,)))
return None
stdout = p.communicate()[0].strip()
if sys.version >= '3':
stdout = stdout.decode()
if p.returncode != 0:
if verbose:
print("unable to run %s (error)" % args[0])
print(("unable to run %s (error)" % args[0]))
return None
return stdout

Expand Down Expand Up @@ -97,15 +97,15 @@ def versions_from_expanded_variables(variables, tag_prefix, verbose=False):
# "stabilization", as well as "HEAD" and "master".
tags = set([r for r in refs if re.search(r'\d', r)])
if verbose:
print("discarding '%s', no digits" % ",".join(refs-tags))
print(("discarding '%s', no digits" % ",".join(refs-tags)))
if verbose:
print("likely tags: %s" % ",".join(sorted(tags)))
print(("likely tags: %s" % ",".join(sorted(tags))))
for ref in sorted(tags):
# sorting will prefer e.g. "2.0" over "2.0rc1"
if ref.startswith(tag_prefix):
r = ref[len(tag_prefix):]
if verbose:
print("picking %s" % r)
print(("picking %s" % r))
return { "version": r,
"full": variables["full"].strip() }
# no suitable tags, so we use the full revision id
Expand All @@ -122,7 +122,7 @@ def versions_from_vcs(tag_prefix, root, verbose=False):

if not os.path.exists(os.path.join(root, ".git")):
if verbose:
print("no .git in %s" % root)
print(("no .git in %s" % root))
return {}

GITS = ["git"]
Expand All @@ -134,7 +134,7 @@ def versions_from_vcs(tag_prefix, root, verbose=False):
return {}
if not stdout.startswith(tag_prefix):
if verbose:
print("tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix))
print(("tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix)))
return {}
tag = stdout[len(tag_prefix):]
stdout = run_command(GITS, ["rev-parse", "HEAD"], cwd=root)
Expand All @@ -152,8 +152,8 @@ def versions_from_parentdir(parentdir_prefix, root, verbose=False):
dirname = os.path.basename(root)
if not dirname.startswith(parentdir_prefix):
if verbose:
print("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" %
(root, dirname, parentdir_prefix))
print(("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" %
(root, dirname, parentdir_prefix)))
return None
return {"version": dirname[len(parentdir_prefix):], "full": ""}

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
long_description = open('README.md').read(),
author = "David Doukhan",
author_email = "[email protected]",
# version = '0.0.1',
version = '0.3.2',

# versioneer
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
#version=versioneer.get_version(),
#cmdclass=versioneer.get_cmdclass(),

install_requires = [
'setuptools',
Expand Down
Loading