From 1b0519e662e0cc21b56cc1fcbfadc06207cee42c Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 24 Mar 2014 21:37:00 +0000 Subject: [PATCH] [ctml_writer] Fix handling of units in some fields When using Python 3, using -1 as the dummy value for density and site_density causes probems, because the (ordered) comparison between a density specified with units (as a tuple) and 0 is not allowed. Instead, use None as the placeholder value. Cherry-pick of trunk commit r2800. --- interfaces/python/ctml_writer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/python/ctml_writer.py b/interfaces/python/ctml_writer.py index df569cd2f..1ad63d341 100644 --- a/interfaces/python/ctml_writer.py +++ b/interfaces/python/ctml_writer.py @@ -2016,7 +2016,7 @@ class incompressible_solid(phase): elements = '', species = '', note = '', - density = -1.0, + density = None, transport = 'None', initial_state = None, options = []): @@ -2025,7 +2025,7 @@ class incompressible_solid(phase): initial_state, options) self._dens = density self._pure = 0 - if self._dens < 0.0: + if self._dens is None: raise CTI_Error('density must be specified.') self._tr = transport @@ -2054,7 +2054,7 @@ class lattice(phase): transport = 'None', initial_state = None, options = [], - site_density = -1.0, + site_density = None, vacancy_species = ''): phase.__init__(self, name, 3, elements, species, note, 'none', initial_state, options) @@ -2066,7 +2066,7 @@ class lattice(phase): raise CTI_Error('sublattice name must be specified') if species == '': raise CTI_Error('sublattice species must be specified') - if site_density < 0.0: + if site_density is None: raise CTI_Error('sublattice '+name +' site density must be specified')