Skip to content

Commit 6b5e071

Browse files
Merge pull request #67 from hande-qmc/bug_fix/pyhande_pandas_1.0_cherrp
Bug fix/pyhande pandas 1.0 cherrp
2 parents 4efb802 + a66ef80 commit 6b5e071

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

tools/pyhande/pyhande/analysis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def projected_energy(reblock_data, covariance, data_length,
5353
:func:`pyblock.pd_utils.reblock` for producing the input parameters.
5454
'''
5555

56-
proje_sum = reblock_data.ix[:, sum_key]
57-
ref_pop = reblock_data.ix[:, ref_key]
56+
proje_sum = reblock_data[sum_key]
57+
ref_pop = reblock_data[ref_key]
5858
proje_ref_cov = covariance.xs(ref_key, level=1)[sum_key]
5959
proje = pyblock.error.ratio(proje_sum, ref_pop, proje_ref_cov, data_length)
6060
proje.columns = pd.MultiIndex.from_tuples(
@@ -90,7 +90,7 @@ def qmc_summary(data, keys=('\sum H_0j N_j', 'N_0', 'Shift', 'Proj. Energy'),
9090
(opt_data, no_opt) = ([], [])
9191
for col in keys:
9292
if col in data:
93-
summary = pyblock.pd_utils.reblock_summary(data.ix[:, col])
93+
summary = pyblock.pd_utils.reblock_summary(data[col])
9494
if summary.empty:
9595
no_opt.append(col)
9696
else:

tools/pyhande/pyhande/lazy.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def find_starting_iteration_mser_min(data, md, start_max_frac=0.9, n_blocks=100,
6868
if end is None:
6969
end = data['iterations'].iloc[-1]
7070
before_end_indx = data['iterations'] <= end
71-
data_before_end = data.ix[before_end_indx]
71+
data_before_end = data[before_end_indx]
7272

7373
list = data_before_end['Proj. Energy']
7474
n_data=len(list)
@@ -128,16 +128,16 @@ def lazy_hybrid(calc, md, start=0, end=None, batch_size=1):
128128
if end is None:
129129
end = calc['iterations'].iloc[-1]
130130
before_end_indx = calc['iterations'] <= end
131-
data_before_end = calc.ix[before_end_indx]
131+
data_before_end = calc[before_end_indx]
132132

133133
after_start_indx = data_before_end['iterations'] >= start
134134
calc_tr = data_before_end[after_start_indx]
135135

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

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

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

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

641641
# Find the point the shift began to vary.
642642
variable_shift = data_before_end['Shift'] != data_before_end['Shift'].iloc[0]

tools/pyhande/pyhande/testcode.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ def extract_test_data(fname, underscore=True):
4646
# Compare all bar the first entry (which contains a legitimate
4747
# NaN in the standard error, which is not handled well by
4848
# testcode).
49-
indxs = range(len(data))[1:]
50-
test_data = data.ix[indxs]
49+
test_data = data.iloc[1:]
5150
output[metadata['calc_type'] + calc_ind] = test_data
5251
elif len(data) > 10:
5352
# Compare every 1/4 of (non-trivial) QMC calculation...
5453
indxs = [0] + [int((i*len(data))/4)-1 for i in range(1,5)]
55-
test_data = data.ix[indxs]
54+
test_data = data.iloc[indxs]
5655
output[metadata['calc_type'] + calc_ind] = test_data
5756
else:
5857
output[metadata['calc_type'] + calc_ind] = data

0 commit comments

Comments
 (0)