diff --git a/convert_gui.py b/convert_gui.py index ad32003..615c7cf 100644 --- a/convert_gui.py +++ b/convert_gui.py @@ -8,16 +8,18 @@ author: Rohan Isaac """ +# pylint: disable=too-many-instance-attributes, invalid-name from __future__ import division, absolute_import, unicode_literals, print_function -from Tkinter import Tk, StringVar, DISABLED, NORMAL, END, W, E, N, S +from Tkinter import Tk, StringVar, W, E, N, S from ttk import Frame, Label, Button, Radiobutton, Entry import tkFileDialog -import spc import os +import spc + -class ConvertSPC: +class ConvertSPC(object): def __init__(self, master): self.master = master master.title("Convert SPC files") diff --git a/spc/spc.py b/spc/spc.py index 0baadca..a1a6239 100644 --- a/spc/spc.py +++ b/spc/spc.py @@ -4,16 +4,17 @@ author: Rohan Isaac """ +# pylint: disable=too-many-instance-attributes, invalid-name from __future__ import division, absolute_import, unicode_literals, print_function import struct import numpy as np -from .sub import subFile, subFileOld +from .sub import SubFile, SubFileOld from .global_fun import read_subheader, flag_bits -class File: +class File(object): """ Starts loading the data from a .SPC spectral file using data from the header. Stores all the attributes of a spectral file: @@ -166,10 +167,9 @@ def __init__(self, filename): # if global x data is given x_dat_pos = self.head_siz x_dat_end = self.head_siz + (4 * self.fnpts) - self.x = np.array( - [struct.unpack_from( - 'f', content[x_dat_pos:x_dat_end], 4 * i)[0] - for i in range(0, self.fnpts)]) + content_to_unpack = content[x_dat_pos:x_dat_end] + unpack = lambda i: struct.unpack_from('f', content_to_unpack, 4 * i)[0] + self.x = np.array([unpack(i) for i in range(0, self.fnpts)]) sub_pos = x_dat_end else: # otherwise generate them @@ -183,10 +183,11 @@ def __init__(self, filename): self.directory = True # loop over entries in directory for i in range(0, self.fnsub): - ssfposn, ssfsize, ssftime = struct.unpack( - '