Skip to content

Commit

Permalink
[Fix] Wrong indexing in find_closest_...; error message
Browse files Browse the repository at this point in the history
  • Loading branch information
klieret committed Dec 18, 2019
1 parent 7130725 commit 0619bfa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clusterking/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,10 @@ def find_closest_spoints(self, point: Dict[str, float], n=10) -> "Data":
closest = closest[np.argsort(distances[closest])]

new = self.copy(data=False)
new.df = self.df.loc[closest]
new.df = self.df.iloc[closest]
return new

def find_closest_bpoint(
def find_closest_bpoints(
self, point: Dict[str, float], n=10, bpoint_column="bpoint"
):
""" Given a point in parameter space, find the closest benchmark
Expand All @@ -482,7 +482,7 @@ def find_closest_bpoint(
if not set(point.keys()) == set(self.par_cols):
raise ValueError(
f"Invalid specification of a point: Please give values"
" exactly for the following keys: {', '.join(self.par_cols)}"
f" exactly for the following keys: {', '.join(self.par_cols)}"
)
if n <= 0:
raise ValueError("n has to be an integer >= 1.")
Expand All @@ -505,7 +505,7 @@ def find_closest_bpoint(
closest = closest[np.argsort(distances[closest])]

new = self.copy(data=False)
new.df = self.df.loc[closest]
new.df = self.df[self.df[bpoint_column]].iloc[closest]
return new

# **************************************************************************
Expand Down

0 comments on commit 0619bfa

Please sign in to comment.