diff --git a/.github/workflows/run_pytest.yml b/.github/workflows/run_pytest.yml index d22d83c..274e176 100644 --- a/.github/workflows/run_pytest.yml +++ b/.github/workflows/run_pytest.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.9", "3.11", "3.12", "3.13"] #future: "3.14" steps: - name: Set Swap Space uses: pierotofy/set-swap-space@master diff --git a/setup.py b/setup.py index fa9a3fa..724c010 100644 --- a/setup.py +++ b/setup.py @@ -46,9 +46,9 @@ "Development Status :: 5 - Production/Stable", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Operating System :: Unix", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", diff --git a/stemflow/model/AdaSTEM.py b/stemflow/model/AdaSTEM.py index e6b7645..a46ada7 100644 --- a/stemflow/model/AdaSTEM.py +++ b/stemflow/model/AdaSTEM.py @@ -944,13 +944,13 @@ def find_belonged_points_and_predict(df, st_indexes_df, X_df): "stixel_calibration_point_transformed_upper_bound", ] ] - .groupby(["ensemble_index", "unique_stixel_id"], as_index=False) + .groupby(["ensemble_index", "unique_stixel_id"], as_index=False, group_keys=False) .pipe(lambda x: x[x.obj.columns]) # Explicitly select all the columns in the original df to include. To overcome the include_groups=True deprecation warning .apply(find_belonged_points_and_predict, st_indexes_df=window_X_df_indexes_only, X_df=window_X_df, include_groups=False) # although ["ensemble_index", "unique_stixel_id"] will be passed into `find_belonged_points` due to `.pipe(lambda x: x[x.obj.columns])`, the output will not have them so we still set `as_index=True` in `groupby` ) - if len(res)>0: - res = res.droplevel(0) # If using as_index=False duing groupby, pandas will automatically generate a group indexing column, so drop the indexing of the new groups + # if len(res)>0: + # res = res.droplevel(0) # If using as_index=False duing groupby, pandas will automatically generate a group indexing column, so drop the indexing of the new groups window_prediction_list.append(res) diff --git a/stemflow/model/SphereAdaSTEM.py b/stemflow/model/SphereAdaSTEM.py index 3000a9b..0624f05 100644 --- a/stemflow/model/SphereAdaSTEM.py +++ b/stemflow/model/SphereAdaSTEM.py @@ -513,17 +513,18 @@ def find_belonged_points(df, st_indexes_df, X_df): window_prediction = ( query_results .dropna(subset="unique_stixel_id") - .groupby("unique_stixel_id", as_index=False) + .groupby("unique_stixel_id", as_index=False, group_keys=False) .pipe(lambda x: x[x.obj.columns]) .apply(lambda stixel: self.stixel_predict(stixel), include_groups=False) - .droplevel(0) ) # print('window_prediction:',window_prediction) window_prediction_list.append(window_prediction) if any([i is not None for i in window_prediction_list]): ensemble_prediction = pd.concat(window_prediction_list, axis=0) - ensemble_prediction = ensemble_prediction.groupby("index").mean().reset_index(drop=False) + ensemble_prediction = ensemble_prediction.groupby(level=0).mean() + ensemble_prediction.index.name = "index" + ensemble_prediction = ensemble_prediction.reset_index(drop=False) else: ensmeble_index = list(window_single_ensemble_df["ensemble_index"])[0] warnings.warn(f"No prediction for this ensemble: {ensmeble_index}")