Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • N NIFTy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 23
    • Issues 23
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 16
    • Merge requests 16
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
    • Model experiments
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ift
  • NIFTy
  • Issues
  • #355
Closed
Open
Issue created Dec 08, 2022 by Gordian Edenhofer@gedenhofMaintainer

Let's allow `assert`s again

asserts in python are advertised as quick-and-easy checking tool to assert self-consistency within a program. They are used all over the place in the python eco-system and can help code be more readable (by making assumptions explicit) and avoid errors. The latter being the main reason for their existence.

However, asserts are also sometimes misused to validate user-input. This is bad because asserts can be disabled via a python optimization flag. To error on the side of caution, we decided to ban the use of asserts in NIFTy.

I would like to revert this decision. I think the two upsides already mentioned - improved readability and avoiding errors - far outweigh the potential harm (basically no one enables these python optimizations [1]). I use a lot of asserts in my own code base and on multiple occasions had to remove asserts from code submitted to NIFTy to conform with this policy. In short: IMHO NIFTy does not get better by disallowing asserts.

@all What are you thoughts on this?

[1] python -O enables basic optimization and removes all asserts. With the -O flag, python yields .pyo files instead of .pyc files. On my machine (with many, many python packages) not a single package installed a .pyo file.

Edited Dec 08, 2022 by Gordian Edenhofer
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking