Aminsinichi / wearable-hrv

A Python package for the validation of heart rate and heart rate variability in wearables
MIT License
11 stars 2 forks source link

Some small comments regarding Code Structure and Code Formatting #3

Open AKuederle opened 9 months ago

AKuederle commented 9 months ago

Overall the code quality looks great, but here are a couple of smaller things that could be improved:

Aminsinichi commented 8 months ago

Thank you @AKuederle for these suggestions. I have a few questions to make sure I grasp this correctly:

In the beginning, define the path like this:

from pathlib import Path 

pp = "P25"
path = Path("COPY-YOUR-ADDRESS-HERE")
conditions = ['sitting', 'arithmetic', 'recovery']
devices = ["kyto", "empatica", "vu"]
criterion = "vu"

Then, I also need modify the functions slightly to incorporate this. For instance, in the individual.import_data() function, instead of path_vu = path + pp + '_' + "vu" + '.txt', I modify it to path_vu = path / f"{pp}_vu.txt".

Is this what you are suggesting to be done?

AKuederle commented 7 months ago

Regarding the path thing:

I would usggest to use Path internally everywhere and all functions that can take a file-path or directory as input, to support both str and Path. So when the user passes as str you convert it to path. This makes sure that you don't have to deal with OS differences internally and you allow the user to also benefit from using Path (but they don't have to)

AKuederle commented 7 months ago

Regarding huge files: While this is a matter of preference, most people structure their functions in multiple smaller files based on categories (e.g. plotting, utils, io, loading, stats, ...). And then depending on the project, the relevant methods are reexported in user facing files to separate the internal structure from the import structures for users. For example see scikit-learn: https://github.com/scikit-learn/scikit-learn/tree/main/sklearn/cluster

Here the implementaiton is split in smaller files to easier find things, but then user facing functions are re-imported in the top-level init to provide more convenient import syntax

Aminsinichi commented 7 months ago