cbrnr / sleepecg

Sleep stage detection using ECG
BSD 3-Clause "New" or "Revised" License
93 stars 25 forks source link

add structure to python scripts? (e.g. `if __name__ == "__main__":`) #165

Closed tompollard closed 1 year ago

tompollard commented 1 year ago

This is a quick issue relating to the JOSS review comments at: https://github.com/openjournals/joss-reviews/issues/5411#issuecomment-1548163405

The scripts (e.g. examples/benchmark/plot_benchmark_results.py) are missing structure that I think can be helpful (e.g. if __name__ == "__main__":).

Minor thing and not necessary, but might be worth adding some of this structure (e.g. to prevent them running when imported and for ease of running at the command line)?

This is the outline that I use: https://www.annasyme.com/docs/python_structure.html

cbrnr commented 1 year ago

Personally, I don't like adding boilerplate unless it is absolutely necessary. In my experience, stuff like if __name__ == "__main__": and putting code into a main function can be very confusing for (new) users, and I would like to keep our examples as simple as possible. I don't think this would impact running the examples from the command line either, but please let me know if I'm missing something.

tompollard commented 1 year ago

Personally, I don't like adding boilerplate unless it is absolutely necessary. In my experience, stuff like if name == "main": and putting code into a main function can be very confusing for (new) users, and I would like to keep our examples as simple as possible.

That's fair, you make a good point, so I'll close this issue.

My feeling is that scripts aren't especially straightforward for beginners, boilerplate or not, because they aren't straightforward to step through, modify, and explore. For this, I think notebooks are the best option, especially if there is an option to open in the cloud.

cbrnr commented 1 year ago

Yes, that's true, some basic knowledge of Python, including installing, configuring, and running code is required. Notebooks have their pros and cons, in some situations they are quite useful indeed. I'll keep that in mind, maybe we can add notebooks as examples at a later point.