~freecad-community/freecad-extras/assembly2

« back to all changes in this revision

Viewing changes to solverLib.py

  • Committer: looooo
  • Date: 2017-04-29 20:45:27 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: git-v1:b1dec62143dc055898bad6a73fb53e87cb9f68e2
py3: exceptions + dict.has_key
except Error msg: --> except Error as msg:
dict.has_key(value) --> value in dict

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
            b = numpy.array([b])
128
128
        try:
129
129
            x_c, residuals, rank, s = numpy.linalg.lstsq( A, b)
130
 
        except ValueError, msg:
131
 
            printF('  solve_via_Newtons_method numpy.linalg.lstsq failed: %s.  Setting x_c = x' % str(msg)) 
 
130
        except ValueError as e:
 
131
            printF('  solve_via_Newtons_method numpy.linalg.lstsq failed: %s.  Setting x_c = x' % str(e)) 
132
132
            x_c = x
133
133
        if debugPrintLevel > 1:
134
134
            if singleEq:
172
172
        return self.f_x[-1]
173
173
    def addNote(self, note):
174
174
        key = len(self.x)
175
 
        assert not self.notes.has_key(key)
 
175
        assert key not in self.notes
176
176
        self.notes[key] = note
177
177
    def __repr__(self):
178
178
        return '<SearchAnalyticsWrapper %i calls made>' % len(self.x)
186
186
        gradApprox = False
187
187
        for i in range(len(self.x)):
188
188
            y = norm( self.f_x[i] ) + 10**-9
189
 
            if self.notes.has_key(i):
 
189
            if i in self.notes:
190
190
                if self.notes[i] == 'starting gradient approximation':
191
191
                    gradApprox = True
192
192
                if self.notes[i] == 'finished gradient approximation':