Skip to content

Commit 3571132

Browse files
committed
Merge branch 'wantianqi2009-master'
2 parents a4ed841 + 418625d commit 3571132

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/qha/basic_io/out.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ def save_x_tp(df, t, desired_pressures_gpa, p_sample_gpa, outfile_name):
2424
df = pd.DataFrame(df, index=t, columns=desired_pressures_gpa).iloc[:-4, :]
2525
df.columns.name = "T(K)\P(GPa)"
2626
sample = df.loc[:, df.columns.isin(p_sample_gpa)]
27+
format_str = "%.15e"
2728
with open(outfile_name, "w") as f:
28-
f.write(sample.to_string())
29+
f.write(sample.to_string(float_format=lambda x: format_str % x))
2930

3031

3132
def save_x_pt(df, t, desired_pressures_gpa, t_sample, outfile_name):
@@ -34,34 +35,35 @@ def save_x_pt(df, t, desired_pressures_gpa, t_sample, outfile_name):
3435
df = pd.DataFrame(df[:-4].T, index=desired_pressures_gpa, columns=t[:-4])
3536
df.columns.name = "P(GPa)\T(K)"
3637
sample = df.loc[:, df.columns.isin(t_sample)]
38+
format_str = "%.15e"
3739
with open(outfile_name, "w") as f:
38-
f.write(sample.to_string())
40+
f.write(sample.to_string(float_format=lambda x: format_str % x))
3941

4042

4143
def save_x_vt(x, t, volume_grid, t_sample, outfile_name):
4244
df = pd.DataFrame(x.T, index=volume_grid, columns=t)
4345
df.columns.name = "V(A^3)\T(K)"
4446
sample = df.loc[:, df.columns.isin(t_sample)]
47+
format_str = "%.15e"
4548
with open(outfile_name, "w") as f:
46-
f.write(sample.to_string())
49+
f.write(sample.to_string(float_format=lambda x: format_str % x))
4750

4851

4952
def save_x_tv(x, t, volume_grid, t_sample, outfile_name):
5053
df = pd.DataFrame(x, index=t, columns=volume_grid).iloc[:-4, :]
5154
df.columns.name = "T(K)\V(A^3)"
5255
sample = df.loc[df.index.isin(t_sample[:-4]), :]
56+
format_str = "%.15e"
5357
with open(outfile_name, "w") as f:
54-
f.write(sample.to_string())
58+
f.write(sample.to_string(float_format=lambda x: format_str % x))
5559

5660

5761
def make_starting_string() -> str:
5862
return textwrap.dedent(
5963
"""\
6064
============================================================
6165
Current time: {0:%Y-%m-%d %H:%M:%S}
62-
""".format(
63-
datetime.utcnow()
64-
)
66+
""".format(datetime.utcnow())
6567
)
6668

6769

@@ -72,9 +74,7 @@ def make_tp_info(min_temperature, max_temperature, min_pressure, max_pressure):
7274
Desired T range: {0:6.2f} to {1:6.2f} K
7375
Desired P range: {2:6.2f} to {3:6.2f} GPa
7476
------------------------------------------------------------
75-
""".format(
76-
min_temperature, max_temperature, min_pressure, max_pressure
77-
)
77+
""".format(min_temperature, max_temperature, min_pressure, max_pressure)
7878
)
7979

8080

@@ -85,7 +85,5 @@ def make_ending_string(time_elapsed) -> str:
8585
Total elapsed time is: {0:8.2f} seconds
8686
Thanks for using QHA code, have a nice one :)
8787
============================================================
88-
""".format(
89-
time_elapsed
90-
)
88+
""".format(time_elapsed)
9189
)

0 commit comments

Comments
 (0)