Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

pandas warning + aleph_output #297

Open
wants to merge 1 commit into
base: v1.1
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion sandy/aleph2/output_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,15 @@ def parse_table_nuclide(text, index="ZAM", data_row=3, **kwargs):
if len(lines[begin:]) == 0:
df = pd.DataFrame(columns=columns)
else:
# NEW IN ALEPH_2.9.2, energy is reported in decay heat table
start = 2 if "E (MeV)"in lines[begin-1] else 1
string = io.StringIO("\n".join(lines[begin:]))
df = pd.read_csv(
string,
sep="\s+",
header=None,
index_col=index_col,
).iloc[:, 1:]
).iloc[:, start:]
df.index.name = index
df.columns = columns
return df.T
Expand Down
3 changes: 2 additions & 1 deletion sandy/core/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def iterate_xs_samples(self):
df = self.data.unstack(level=levels)

# -- Iterate over samples
for n, p in df.groupby(axis=1, level=self._columnsname):
for n, p_ in df.T.groupby(level=self._columnsname):
p = p_.T
s = p.droplevel(self._columnsname, axis=1)
adds = []
for mat in s.columns.get_level_values("MAT").unique():
Expand Down
5 changes: 3 additions & 2 deletions sandy/core/xs.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ def reconstruct_sums(self, drop=True):
>>> assert xsr.data[(9543, 4)].equals(xsr.data[9543].loc[:, 50:91].sum(axis=1))
"""
df = self.data.copy()
for mat, group in df.groupby("MAT", axis=1):
# for mat, group in df.groupby("MAT", axis=1):
for mat, group in df.T.groupby(level="MAT"):

# starting from the lat redundant cross section, find daughters and sum them
for parent, daughters in sorted(sandy.redundant_xs.items(), reverse=True):
Expand All @@ -426,7 +427,7 @@ def reconstruct_sums(self, drop=True):

# keep only mts present in the original file
if drop:
keep = group[mat].columns
keep = group[mat].index
todrop = df[mat].columns.difference(keep)
df.drop(
pd.MultiIndex.from_product([[mat], todrop]),
Expand Down
Loading