Skip to content

When writing datasets, some variables are not being forced into a 10 character width  #10

@christianlangevin

Description

@christianlangevin

The following code will show the problem. We are currently using formatter1 for many floats in Python. This can be a problem if the model code is reading fixed format. The problem shows up when using 1.e6 for DT0 for mt3d, for example. I'm working on a fix for this, but it is something to be aware of. formatter2 is better I think, but it is also problematic.

formatter1 = '{:10}'
formatter2 = '{:10f}'

numbers = [1.e6, 1000000000, 1.e30, 1.e-30]

for number in numbers:
n = float(number)
print 10 * '-'
print formatter1.format(n)
print formatter2.format(n)

output:


1000000.0

1000000.000000

1000000000.0

1000000000.000000

 1e+30

1000000000000000019884624838656.000000

 1e-30

0.000000

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions