Skip to content

Commit

Permalink
change precision to n_decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
daico007 committed Aug 28, 2023
1 parent 344d573 commit 24be7e1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gmso/formats/gro.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def read_gro(filename):


@saves_as(".gro")
def write_gro(top, filename, precision=3, shift_coord=False):
def write_gro(top, filename, n_decimals=3, shift_coord=False):
"""Write a topology to a gro file.
The Gromos87 (gro) format is a common plain text structure file used
Expand All @@ -119,7 +119,7 @@ def write_gro(top, filename, precision=3, shift_coord=False):
The `topology` to write out to the gro file.
filename : str or file object
The location and name of file to save to disk.
precision : int, optional, default=3
n_decimals : int, optional, default=3
The number of sig fig to write out the position in.
shift_coord : bool, optional, default=False
If True, shift the coordinates of all sites by the minimum position
Expand Down Expand Up @@ -147,7 +147,7 @@ def write_gro(top, filename, precision=3, shift_coord=False):
)
)
out_file.write("{:d}\n".format(top.n_sites))
out_file.write(_prepare_atoms(top, pos_array, precision))
out_file.write(_prepare_atoms(top, pos_array, n_decimals))
out_file.write(_prepare_box(top))


Expand All @@ -166,7 +166,7 @@ def _validate_positions(pos_array):
return pos_array


def _prepare_atoms(top, updated_positions, precision):
def _prepare_atoms(top, updated_positions, n_decimals):
out_str = str()
warnings.warn(
"Residue information is parsed from site.molecule,"
Expand Down Expand Up @@ -226,8 +226,8 @@ def _prepare_atoms(top, updated_positions, precision):
atom_id = atom_id % max_val
res_id = res_id % max_val

varwidth = 5 + precision
crdfmt = f"{{:{varwidth}.{precision}f}}"
varwidth = 5 + n_decimals
crdfmt = f"{{:{varwidth}.{n_decimals}f}}"

# preformat pos str
crt_x = crdfmt.format(pos[0].in_units(u.nm).value)[:varwidth]
Expand Down

0 comments on commit 24be7e1

Please sign in to comment.