Describe the bug
The unit tests for TestBasisSet::test_functions_by_shell and TestBasisSet::test_primitives_by_shell are failing. After some digging it seems that it might be from a difference in the data type of the index (int and 'categorical').
I noticed that there is a self.groupby in the BasisSet.functions_by_shell and BasisSet.primitives_by_shell methods. What I'm thinking is that the 'categorical' data type persists through the groupby and is causing this issue.
I propose that we add the line obj = self._revert_categories(inplace=False) in both methods and change the code in the DataFrame._revert_categories to
def _revert_categories(self, inplace=True):
"""
Inplace conversion to categories.
"""
if inplace:
for column, dtype in self._categories.items():
if column in self.columns:
self[column] = self[column].astype(dtype)
else:
copy = self.copy()
for column, dtype in copy._categories.items():
if column in copy.columns:
copy[column] = copy[column].astype(dtype)
return copy
Essentially adding a kwarg so the replacement is not done inplace. I think this is a better way so that we don't have to run _revert categories and _set_categories for such a simple thing.
Describe the bug The unit tests for
TestBasisSet::test_functions_by_shell
andTestBasisSet::test_primitives_by_shell
are failing. After some digging it seems that it might be from a difference in the data type of the index (int
and'categorical'
).I noticed that there is a
self.groupby
in theBasisSet.functions_by_shell
andBasisSet.primitives_by_shell
methods. What I'm thinking is that the'categorical'
data type persists through thegroupby
and is causing this issue.I propose that we add the line
obj = self._revert_categories(inplace=False)
in both methods and change the code in theDataFrame._revert_categories
toEssentially adding a kwarg so the replacement is not done inplace. I think this is a better way so that we don't have to run
_revert categories
and_set_categories
for such a simple thing.