Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Fix filename and dirname creation floating point formatting #232

Merged

Commits on Jun 28, 2024

  1. STYLE: Fix filename and dirname creation floating point formatting

    Fix formatting of numbers that can be floats when creating filenames and
    dirnames: when transitioning to f-strings (commit ac6040f), it was
    assumed that `sigma` and `nonrigid_grid_resolution` would be integers,
    based on the existing formatting. However, these attributes can be set
    to non-integer values. The pre-f-string transition solution, e.g.:
    ```
    "iteration_%05d_sigma_%05d" % (self.total_iterations, self.sigma)
    ```
    
    trimmed the decimal part, and thus, for e.g. `total_iterations` 20 and
    `sigma` 7.5, it would produce:
    ```
    'iteration_00020_sigma_00007'
    ```
    
    With the introduction of f-strings, i.e.
    ```
    f"iteration_{self.total_iterations:05d}_sigma_{self.sigma:05d}"
    ```
    
    this would produce an error, since the `sigma` floating point value
    cannot be formatted as an integer:
    ```
    {ValueError}ValueError("Unknown format code 'd' for object of type
    'float'")
    ```
    
    This patch set fixes the error by adopting the previous behavior: it
    trims the decimal part.
    jhlegarreta committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    d7c6bd8 View commit details
    Browse the repository at this point in the history