Skip to content

Commit

Permalink
Fixed issue zlatko-minev#21 incompatible with pandas 0.25.1
Browse files Browse the repository at this point in the history
pandas.compat is private in the newer versions of pandas so you cant use pandas.compat.StringIo. I used the io library instead which provides a similar functionality.
  • Loading branch information
DanielCohenHillel committed May 5, 2020
1 parent 718cf7a commit fd2b589
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pyEPR/ansys.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import numpy as np
import pandas as pd
from sympy.parsing import sympy_parser
import io

from . import logger

Expand Down Expand Up @@ -1057,6 +1058,7 @@ def get_convergence(self, variation="", pre_fn_args=[], overwrite=True):
Variation should be in the form
variation = "scale_factor='1.2001'" ...
'''
# TODO: (Daniel) I think this data should be store in a more comfortable datatype (dictionary maybe?)
# Write file
temp = tempfile.NamedTemporaryFile()
temp.close()
Expand All @@ -1078,9 +1080,8 @@ def get_convergence(self, variation="", pre_fn_args=[], overwrite=True):
# Parse file
text2 = text.split(r'==================')
if len(text) >= 3:
df = pd.read_csv(pd.compat.StringIO(
text2[3].strip()), sep='|', skipinitialspace=True, index_col=0)
df = df.drop('Unnamed: 3', 1)
df = pd.read_csv(io.StringIO(
text2[3].strip()), sep='|', skipinitialspace=True, index_col=0).drop('Unnamed: 3', 1)
else:
logger.error(f'ERROR IN reading in {temp}:\n{text}')
df = None
Expand Down Expand Up @@ -1293,12 +1294,12 @@ def _readin_Q3D_matrix(path):

s2 = s1[1].split('Conductance Matrix')

df_cmat = pd.read_csv(pd.compat.StringIO(
df_cmat = pd.read_csv(io.StringIO(
s2[0].strip()), delim_whitespace=True, skipinitialspace=True, index_col=0)
units = re.findall(r'C Units:(.*?),', text)[0]

if len(s2) > 1:
df_cond = pd.read_csv(pd.compat.StringIO(
df_cond = pd.read_csv(io.StringIO(
s2[1].strip()), delim_whitespace=True, skipinitialspace=True, index_col=0)
units_cond = re.findall(r'G Units:(.*?)\n', text)[0]
else:
Expand Down

0 comments on commit fd2b589

Please sign in to comment.