Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixed adsorbate-adsorbate interaction + backward python 2.7 compatibility #127

Merged
merged 2 commits into from
Nov 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion catmap/analyze/analysis_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from mpl_toolkits.axes_grid1 import make_axes_locatable

plt = catmap.plt
pickle= catmap.pickle
pickle = catmap.pickle
np = catmap.np
spline = catmap.spline
mtransforms = catmap.mtransforms
Expand Down
24 changes: 13 additions & 11 deletions catmap/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import re
from .data import regular_expressions
string2symbols = catmap.string2symbols
pickle = catmap.pickle
plt = catmap.plt


Expand Down Expand Up @@ -278,19 +277,20 @@ def Axb_solver(A, b):
for attr in dir(self):
if (not attr.startswith('_') and
not callable(getattr(self, attr)) and
attr not in self._classes):
attr not in self._classes and
not inspect.ismodule(getattr(self,attr))):
if (len(repr(getattr(self, attr))) >
self._max_log_line_length):
# Line is too long for logfile -> put into pickle
self._pickle_attrs.append(attr)
pickled_data = {}
for attr in self._pickle_attrs:
pickled_data[attr] = getattr(self, attr)
try:
pickle.dump(pickled_data, open(self.data_file, 'w'))
except:
if sys.version_info[0]<3:
catmap.pickle.dump(pickled_data, open(self.data_file, 'w'))
else:
# Fallback workaround for Py3
pickle.dump(pickled_data, open(self.data_file, 'wb'))
catmap.pickle.dump(pickled_data, open(self.data_file, 'wb',2))

# Make logfile
log_txt = self._log_imports
Expand Down Expand Up @@ -380,8 +380,8 @@ def load(self, setup_file): #

globs = {}
locs = defaults

exec(compile(open(setup_file, 'r').read(), '<string>', 'exec'), globs, locs)
exec(compile(open(setup_file, 'rb').read(), '<string>', 'exec'), globs, locs)
for var in locs.keys():
if var in self._classes:
#black magic to auto-import classes
Expand Down Expand Up @@ -437,9 +437,9 @@ def load_data_file(self, overwrite=False):
"""
if os.path.exists(self.data_file):
try:
pickled_data = pickle.load(open(self.data_file, 'r'))
pickled_data = catmap.pickle.load(open(self.data_file, 'r'))
except:
pickled_data = pickle.load(open(self.data_file, 'rb'))
pickled_data = catmap.pickle.load(open(self.data_file, 'rb'))
for attr in pickled_data:
if not overwrite:
if getattr(self, attr, None) is None: # Don't over-write
Expand Down Expand Up @@ -1155,7 +1155,9 @@ def _header(self,exclude_outputs=[],re_parse=False):
for attr in dir(self):
if (not attr.startswith('_') and
not callable(getattr(self,attr)) and
attr not in self._classes):
attr not in self._classes and
not inspect.ismodule(getattr(self,attr))):
print(attr)
val = repr(getattr(self,attr))
new_line = ''
if attr not in self._pickle_attrs:
Expand Down
5 changes: 3 additions & 2 deletions catmap/thermodynamics/first_order_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ def sync_with_species_defs(fitting_info,surf_id):
if cvg_Ed_Eint_i not in required_params_dict[reqd]:
required_params_dict[reqd] += [cvg_Ed_Eint_i]

for key in required_params_dict.keys():
for key in list(required_params_dict.keys()):
print(key)
keylist = eval(key)
cvgs = required_params_dict[key]
if len(keylist) == 1:
Expand Down Expand Up @@ -332,7 +333,7 @@ def sync_with_species_defs(fitting_info,surf_id):

for key in cross_keys_3:
params = eval(key)
params = [pi for pi in params if pi not in fitting_info.keys()+user_inputs]
params = [pi for pi in params if pi not in list(fitting_info.keys())+user_inputs]
assert len(params) <= 1 #if not then something is very weird.
if params:
param = params[0]
Expand Down