Ignore:
Timestamp:
Apr 17, 2017 3:16:39 PM (7 years ago)
Author:
krzywon
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
da8bb53
Parents:
b09095a
git-author:
Jeff Krzywon <krzywon@…> (04/17/17 15:16:39)
git-committer:
krzywon <krzywon@…> (04/17/17 15:16:39)
Message:

Fix indexing issue that broke unit tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/ascii_reader.py

    rb09095a r8ffafd1  
    8585                    self.reset_data_list(len(lines) - line_no) 
    8686 
    87                 candidate_lines += 1 
    88                 # If 5 or more lines, this is considering the set data 
    89                 if candidate_lines >= self.min_data_pts: 
    90                     is_data = True 
    91  
    92                 self.current_dataset.x[candidate_lines - 1] = float(toks[0]) 
    93                 self.current_dataset.y[candidate_lines - 1] = float(toks[1]) 
     87                self.current_dataset.x[candidate_lines] = float(toks[0]) 
     88                self.current_dataset.y[candidate_lines] = float(toks[1]) 
    9489 
    9590                # If a 3rd row is present, consider it dy 
    9691                if new_lentoks > 2: 
    97                     self.current_dataset.dy[candidate_lines - 1] = \ 
     92                    self.current_dataset.dy[candidate_lines] = \ 
    9893                        float(toks[2]) 
    9994                    has_error_dy = True 
     
    10196                # If a 4th row is present, consider it dx 
    10297                if new_lentoks > 3: 
    103                     self.current_dataset.dx[candidate_lines - 1] = \ 
     98                    self.current_dataset.dx[candidate_lines] = \ 
    10499                        float(toks[3]) 
    105100                    has_error_dx = True 
     101 
     102                candidate_lines += 1 
     103                # If 5 or more lines, this is considering the set data 
     104                if candidate_lines >= self.min_data_pts: 
     105                    is_data = True 
    106106 
    107107                # To remember the # of columns on the current line 
     
    143143        if len(self.current_dataset.x) < 1: 
    144144            raise RuntimeError("ascii_reader: could not load file") 
    145             return None 
    146145 
    147146        # Data 
    148         self.current_dataset.x = \ 
    149             self.current_dataset.x[self.current_dataset.x != 0] 
    150         self.current_dataset.y = \ 
    151             self.current_dataset.y[self.current_dataset.x != 0] 
    152         self.current_dataset.dy = \ 
    153             self.current_dataset.dy[self.current_dataset.x != 0] if \ 
    154                 has_error_dy else np.zeros(len(self.current_dataset.y)) 
    155         self.current_dataset.dx = \ 
    156             self.current_dataset.dx[self.current_dataset.x != 0] if \ 
    157                 has_error_dx else np.zeros(len(self.current_dataset.x)) 
     147        x = self.current_dataset.x 
     148        self.current_dataset.x = self.current_dataset.x[x != 0] 
     149        self.current_dataset.y = self.current_dataset.y[x != 0] 
     150        self.current_dataset.dy = self.current_dataset.dy[x != 0] if \ 
     151            has_error_dy else np.zeros(len(self.current_dataset.y)) 
     152        self.current_dataset.dx = self.current_dataset.dx[x != 0] if \ 
     153            has_error_dx else np.zeros(len(self.current_dataset.x)) 
    158154 
    159155        self.current_dataset.xaxis("\\rm{Q}", 'A^{-1}') 
Note: See TracChangeset for help on using the changeset viewer.