Skip to content

Commit

Permalink
Improving output csv
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanacquah committed Nov 24, 2023
1 parent 72fd35d commit 5c904de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
16 changes: 6 additions & 10 deletions src/stepcount/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,14 @@ def fn(chunk):
X, return_step_timings=return_step_timings, **kwargs
)

Y = pd.Series(Y, index=T)

step_timings = (
pd.Series(
flatten(
[
T[i]
+ np.array(
[
pd.Timedelta(seconds=elem)
for elem in batch_step_timings[i]
]
)
for i in range(len(batch_step_timings))
[T[i] + pd.Timedelta(seconds=timing) for timing in step_timings]
for i, step_timings in enumerate(batch_step_timings)
]
)
)
Expand Down Expand Up @@ -802,8 +798,8 @@ def calibrate(yp, yt, pnr=1.0, precision_tol=0.9, recall_tol=0.9):
return results


def flatten(l):
return [item for sublist in l for item in sublist]
def flatten(lst):
return [item for sublist in lst for item in sublist]


def print_report():
Expand Down
4 changes: 3 additions & 1 deletion src/stepcount/stepcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def main():

# Save the timings of each step if returned
if step_timings is not None:
step_timings.to_csv(f"{outdir}/{basename}-StepTimings.csv")
step_timings.to_csv(
f"{outdir}/{basename}-StepTimings.csv", header=False, index=False
)

# Summary
summary = summarize(Y, model.steptol)
Expand Down

0 comments on commit 5c904de

Please sign in to comment.