Skip to content

Commit

Permalink
Updated hash algorithm to use json instead of repr.
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisamarshall committed Jul 4, 2016
1 parent def9207 commit 9acf4c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ionize/Ion/BaseIon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np
import contextlib
from math import sqrt
import json

from .fixed_state import fixed_state
from ..Solvent import Aqueous
Expand Down Expand Up @@ -33,7 +34,7 @@ class BaseIon(object):
def __repr__(self):
"""Return an unambiguous string representation."""
inner = []
for prop in self._state:
for prop in sorted(self._state):
prop = str(prop) # convert unicode to string
value = getattr(self, prop)
if isinstance(value, np.ndarray):
Expand All @@ -49,7 +50,7 @@ def __str__(self):

def __hash__(self):
"""Return the hash value for the object."""
return hash(repr(self))
return hash(json.dumps(self._state))

def __eq__(self, other):
"""Test equality between two ions."""
Expand Down
3 changes: 1 addition & 2 deletions ionize/Solvent.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def dissociation(self, ionic_strength, temperature):
def debye(self, ionic_strength, temperature):
"""Return the Debye length of the solvent."""
dielectric = self.dielectric(temperature)
viscosity = self.viscosity(temperature)
lamda = (dielectric * permittivity * boltzmann * kelvin(temperature) /
elementary_charge**2. /
(ionic_strength * lpm3) / avogadro) ** .5
Expand Down Expand Up @@ -144,7 +143,7 @@ def dielectric(self, temperature):
def viscosity(self, temperature):
"""Return the viscosity of water at the specified temperature.
Correlation is based on Fox and McDonald's Intro to FLuid Mechanics.
Correlation is based on Fox and McDonald's Intro to Fluid Mechanics.
"""
temperature = kelvin(temperature)
viscosity_ = 2.414e-5 * 10**(247.8 / (temperature - 140))
Expand Down

0 comments on commit 9acf4c3

Please sign in to comment.