Skip to content

Commit

Permalink
Merge pull request #67 from hande-qmc/bug_fix/pyhande_pandas_1.0_cherrp
Browse files Browse the repository at this point in the history
Bug fix/pyhande pandas 1.0 cherrp
  • Loading branch information
verena-neufeld authored May 1, 2020
2 parents 4efb802 + a66ef80 commit 6b5e071
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions tools/pyhande/pyhande/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def projected_energy(reblock_data, covariance, data_length,
:func:`pyblock.pd_utils.reblock` for producing the input parameters.
'''

proje_sum = reblock_data.ix[:, sum_key]
ref_pop = reblock_data.ix[:, ref_key]
proje_sum = reblock_data[sum_key]
ref_pop = reblock_data[ref_key]
proje_ref_cov = covariance.xs(ref_key, level=1)[sum_key]
proje = pyblock.error.ratio(proje_sum, ref_pop, proje_ref_cov, data_length)
proje.columns = pd.MultiIndex.from_tuples(
Expand Down Expand Up @@ -90,7 +90,7 @@ def qmc_summary(data, keys=('\sum H_0j N_j', 'N_0', 'Shift', 'Proj. Energy'),
(opt_data, no_opt) = ([], [])
for col in keys:
if col in data:
summary = pyblock.pd_utils.reblock_summary(data.ix[:, col])
summary = pyblock.pd_utils.reblock_summary(data[col])
if summary.empty:
no_opt.append(col)
else:
Expand Down
14 changes: 7 additions & 7 deletions tools/pyhande/pyhande/lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def find_starting_iteration_mser_min(data, md, start_max_frac=0.9, n_blocks=100,
if end is None:
end = data['iterations'].iloc[-1]
before_end_indx = data['iterations'] <= end
data_before_end = data.ix[before_end_indx]
data_before_end = data[before_end_indx]

list = data_before_end['Proj. Energy']
n_data=len(list)
Expand Down Expand Up @@ -128,16 +128,16 @@ def lazy_hybrid(calc, md, start=0, end=None, batch_size=1):
if end is None:
end = calc['iterations'].iloc[-1]
before_end_indx = calc['iterations'] <= end
data_before_end = calc.ix[before_end_indx]
data_before_end = calc[before_end_indx]

after_start_indx = data_before_end['iterations'] >= start
calc_tr = data_before_end[after_start_indx]

#list = calc_tr['Proj. Energy'].as_matrix()
#n_data = len(list)

list_org = calc_tr['Proj. Energy'].as_matrix()
n_data = len(list_org) / batch_size
list_org = calc_tr['Proj. Energy'].values
n_data = len(list_org) // batch_size
list = [0]*n_data
for i in range(n_data):
list[i] = numpy.mean(list_org[i*batch_size:(i+1)*batch_size])
Expand Down Expand Up @@ -392,7 +392,7 @@ def lazy_block(calc, md, start=0, end=None, select_function=None,
if extract_rep_loop_time:
to_block.append('time')

mc_data = calc.ix[indx, to_block]
mc_data = calc.loc[indx, to_block]
if mc_data['Shift'].iloc[0] == mc_data['Shift'].iloc[1]:
if calc['Shift'][~indx].iloc[-1] == mc_data['Shift'].iloc[0]:
warnings.warn('The blocking analysis starts from before the shift '
Expand All @@ -417,7 +417,7 @@ def lazy_block(calc, md, start=0, end=None, select_function=None,
if calc_inefficiency:
# Calculate quantities needed for the inefficiency.
dtau = md['qmc']['tau']
reblocked_iters = calc.ix[indx, 'iterations']
reblocked_iters = calc.loc[indx, 'iterations']
N = reblocked_iters.iloc[-1] - reblocked_iters.iloc[0]

# This returns a data frame with inefficiency data from the
Expand Down Expand Up @@ -636,7 +636,7 @@ def find_starting_iteration(data, md, frac_screen_interval=300,
# Default end is the last iteration.
end = data['iterations'].iloc[-1]
before_end_indx = data['iterations'] <= end
data_before_end = data.ix[before_end_indx]
data_before_end = data[before_end_indx]

# Find the point the shift began to vary.
variable_shift = data_before_end['Shift'] != data_before_end['Shift'].iloc[0]
Expand Down
5 changes: 2 additions & 3 deletions tools/pyhande/pyhande/testcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ def extract_test_data(fname, underscore=True):
# Compare all bar the first entry (which contains a legitimate
# NaN in the standard error, which is not handled well by
# testcode).
indxs = range(len(data))[1:]
test_data = data.ix[indxs]
test_data = data.iloc[1:]
output[metadata['calc_type'] + calc_ind] = test_data
elif len(data) > 10:
# Compare every 1/4 of (non-trivial) QMC calculation...
indxs = [0] + [int((i*len(data))/4)-1 for i in range(1,5)]
test_data = data.ix[indxs]
test_data = data.iloc[indxs]
output[metadata['calc_type'] + calc_ind] = test_data
else:
output[metadata['calc_type'] + calc_ind] = data
Expand Down

0 comments on commit 6b5e071

Please sign in to comment.