os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir)) # Add the directory containing the 'grendel_tests' package to sys.path sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) from grendel_tests import long_test from grendel import * from grendel.util.strings import indented from grendel.differentiation.finite_difference import Differentiable, FiniteDifferenceVariable, FiniteDifferenceFunction, FiniteDifferenceDerivative #--------------------------------------------------------------------------------# # Polynomial class to test finite difference derivatives with # #--------------------------------------------------------------------------------# Differentiable.register(Fraction) FiniteDifferenceVariable.register(str) class Polynomial(FiniteDifferenceFunction): ################# # Inner classes # ################# class Term(object): ############## # Attributes # ############## powers = None
else: deltas = Displacement.get_default_deltas(self.representation) increments = [] for i in self.disp_vect/deltas: if abs(i - int(i)) > 1e-8: raise RuntimeError("the deltas given are not the original deltas used.") increments.append(int(i)) self._increments = tuple(increments) return self._increments ################### # Private Methods # ################### def _compute_displacement(self, tol=None, maxiter=None): self._displaced_molecule, self._displaced_representation = self.representation.displaced_by(self, tol, maxiter) self._displaced_molecule.displacement = self return FiniteDifferenceVariable.register(Coordinate) ##################### # Dependent Imports # ##################### from grendel.representations.representation import Representation from grendel.representations.internal_representation import InternalRepresentation from grendel.representations.cartesian_representation import CartesianRepresentation
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir)) # Add the directory containing the 'grendel_tests' package to sys.path sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) from grendel_tests import long_test from grendel import * from grendel.util.strings import indented from grendel.differentiation.finite_difference import Differentiable, FiniteDifferenceVariable, FiniteDifferenceFunction, FiniteDifferenceDerivative #--------------------------------------------------------------------------------# # Polynomial class to test finite difference derivatives with # #--------------------------------------------------------------------------------# Differentiable.register(Fraction) FiniteDifferenceVariable.register(str) class Polynomial(FiniteDifferenceFunction): ################# # Inner classes # ################# class Term(object): ############## # Attributes # ############## powers = None coeff = None