Skip to content

Commit

Permalink
Fix warning about concatenating empty or NA data frames
Browse files Browse the repository at this point in the history
  • Loading branch information
dhadka committed Sep 6, 2024
1 parent 2e94224 commit 5150f3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 10 additions & 10 deletions prim/prim_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,16 +404,16 @@ def update(self, box_lims, indices):
self._box_lims.append(box_lims)
coi = self.prim.determine_coi(self.yi)

stats = {"coverage" : coi/self.prim.t_coi,
"density" : coi/y.shape[0],
"mean" : np.mean(y),
"res dim" : determine_nr_restricted_dims(
self._box_lims[-1],
self.prim._box_init),
"mass" : y.shape[0]/self.prim.n}

self.peeling_trajectory = pd.concat([self.peeling_trajectory, pd.DataFrame([stats])],
ignore_index=True)
print(self.prim.t_coi, y.shape[0], self.prim.n)

stats = pd.DataFrame([{"coverage": coi/self.prim.t_coi,
"density": coi/y.shape[0],
"mean": np.mean(y),
"res dim": determine_nr_restricted_dims(self._box_lims[-1], self.prim._box_init),
"mass": y.shape[0]/self.prim.n}])

self.peeling_trajectory = stats if self.peeling_trajectory.empty else \
pd.concat([self.peeling_trajectory, stats], ignore_index=True)

self._cur_box = len(self.peeling_trajectory)-1

Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ test = ["pytest", "mock"]

[tool.setuptools.dynamic]
version = {attr = "prim.__version__"}

[tool.pytest.ini_options]
addopts = "-rA -Werror"
testpaths = ["prim"]

0 comments on commit 5150f3d

Please sign in to comment.