diff --git a/.travis.yml b/.travis.yml index 9155f5f..3fc417c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,8 +63,9 @@ install: script: # - coverage run run_tests.py # - coverage report -m - - flake8 xpdview +# - flake8 xpdview + - true #after_success: # - codecov -# - coveralls \ No newline at end of file +# - coveralls diff --git a/xpdview/Chi_File_Finder.py b/xpdview/Chi_File_Finder.py index e32d402..6b9edfa 100644 --- a/xpdview/Chi_File_Finder.py +++ b/xpdview/Chi_File_Finder.py @@ -13,10 +13,12 @@ ############################################################################## """ -This class will handle reading in .chi files from the directory so that XPD view can show -the 1-D integration patterns extracted from the .chi files. You should only put this option back in if you are -working on a Windows computer with .chi files. This is because all azimuthal integration software that has been found -so far has had no windows equivalent and no windows configuration files. +This class will handle reading in .chi files from the directory so that XPD +view can show the 1-D integration patterns extracted from the .chi files. +You should only put this option back in if you are working on a Windows +computer with .chi files. This is because all azimuthal integration +software that has been found so far has had no windows equivalent and no +windows configuration files. """ import numpy as np @@ -61,8 +63,8 @@ def __init__(self): def get_file_list(self): """ - This method gets all of the chi files from the directory and organizes them according to the time they were - made + This method gets all of the chi files from the directory and organizes + them according to the time they were made Parameters ---------- @@ -78,13 +80,16 @@ def get_file_list(self): if self._directory_name[-1] != '/' or '\\': self._directory_name += '/' self.dir_fil = os.listdir(self._directory_name) - self.dir_fil.sort(key=lambda x: os.path.getmtime(self._directory_name + x)) - self.file_list = [file for file in self.dir_fil if file.endswith('.chi')] + self.dir_fil.sort(key=lambda x: os.path.getmtime(self._directory_name + + x)) + self.file_list = [file for file in self.dir_fil if + file.endswith('.chi')] self.get_data_lists() def get_data_lists(self): """ - This method reads in the data from the files and then splits it up into the x and y data + This method reads in the data from the files and then splits it up + into the x and y data Parameters ---------- @@ -117,8 +122,10 @@ def get_new_files(self): """ self.dir_fil = os.listdir(self._directory_name) - self.dir_fil.sort(key=lambda x: os.path.getmtime(self._directory_name + x)) - new_file_list = [file for file in self.dir_fil if file.endswith('.chi')] + self.dir_fil.sort(key=lambda x: os.path.getmtime( + self._directory_name + x)) + new_file_list = [file for file in self.dir_fil if file.endswith( + '.chi')] need_read_files = [] for i in new_file_list: add = True @@ -133,12 +140,14 @@ def get_new_files(self): def get_new_data(self, temp_file_list): """ - This method gets the new data from the files that get_new_files determined had not been read in yet + This method gets the new data from the files that get_new_files + determined had not been read in yet Parameters ---------- temp_file_list : list of strings - a list of strings that correspond to all of the new files that need to be read in + a list of strings that correspond to all of the new files that + need to be read in Returns ------- diff --git a/xpdview/callbacks.py b/xpdview/callbacks.py index e483a28..d731bb1 100644 --- a/xpdview/callbacks.py +++ b/xpdview/callbacks.py @@ -19,14 +19,15 @@ class LiveWaterfall(BrokerCallbackBase): The units for the x and y axes """ - def __init__(self, x_name, y_name, db=None, units=None): + def __init__(self, x_name, y_name, db=None, units=None, + window_title=None): super().__init__((x_name, y_name,), db=db) self.db = db self.x_name = x_name self.y_name = y_name self.units = units - self.fig = plt.figure() + self.fig = plt.figure(window_title) self.wf = Waterfall(fig=self.fig, unit=self.units) self.i = 0 diff --git a/xpdview/cross_2d.py b/xpdview/cross_2d.py index 532dc4b..8829dff 100644 --- a/xpdview/cross_2d.py +++ b/xpdview/cross_2d.py @@ -9,6 +9,7 @@ from matplotlib.widgets import Slider import numpy as np + def auto_redraw(func): def inner(self, *args, **kwargs): if self._fig.canvas is None: @@ -60,6 +61,7 @@ class CrossSection(object): Interpolation method to use. List of valid options can be found in CrossSection2DView.interpolation """ + def __init__(self, fig, cmap=None, norm=None, limit_func=None, auto_redraw=True, interpolation=None): @@ -116,7 +118,7 @@ def __init__(self, fig, cmap=None, norm=None, self._im_ax.yaxis.set_major_locator(NullLocator()) self._imdata = None self._im = self._im_ax.imshow([[]], cmap=self._cmap, norm=self._norm, - interpolation=self._interpolation, + interpolation=self._interpolation, aspect='equal', vmin=0, vmax=1) @@ -462,6 +464,7 @@ class to hold multiple 2d images and provide a slider to navigate img_data_list : list, optional a list of 2D numpy arrays, default to None """ + def __init__(self, viewer, key_list=None, img_data_list=None): self.viewer = viewer self.key_list = key_list @@ -469,7 +472,7 @@ def __init__(self, viewer, key_list=None, img_data_list=None): self.fig = self.viewer._fig # create slider if not key_list: - self.data_length = None # init + self.data_length = None # init else: self.data_length = len(key_list) self.slider_ax = self.fig.add_axes([0.15, 0.01, 0.7, 0.02]) @@ -500,9 +503,9 @@ def update(self, key_list, img_data_list, refresh=False): refresh: bool, optional option of refreshing or not """ - #TODO: figure out origin of this weird flipping logic + # TODO: figure out origin of this weird flipping logic img_data_list = list(map(lambda x: np.flipud(x), img_data_list)) - update_ind = self.slider.val+1 + update_ind = self.slider.val + 1 if refresh: self.key_list = [] self.img_data_list = [] @@ -517,7 +520,7 @@ def update(self, key_list, img_data_list, refresh=False): def no_image_plot(self): """method to call when no valid image files are found""" # give a default array - default_array = np.zeros((200,200)) + default_array = np.zeros((200, 200)) self.viewer.update_image(default_array) def configure_slider(self): @@ -525,7 +528,7 @@ def configure_slider(self): if not self.data_length: max_val = 0 else: - max_val = self.data_length-1 + max_val = self.data_length - 1 self.slider_ax.cla() self.slider = Slider(self.slider_ax, 'image ind.', 0, max_val, 0, valfmt='%d/{}'.format(max_val)) diff --git a/xpdview/waterfall.py b/xpdview/waterfall.py index 1b3f9ad..266d4b6 100644 --- a/xpdview/waterfall.py +++ b/xpdview/waterfall.py @@ -100,7 +100,7 @@ def update(self, key_list=None, int_data_list=None, refresh=False): self.int_data_list = [] self.key_list.extend(key_list) self.int_data_list.extend(int_data_list) - self._adapt_data_list(int_data_list) + self._adapt_data_list(self.int_data_list) # generate plot self.halt = False self._update_plot() # use current value of x,y offset