Skip to content

Commit

Permalink
fix shape_mat to print data on std output or proper files when -o is …
Browse files Browse the repository at this point in the history
…requested
  • Loading branch information
abelcarreras committed Jun 4, 2023
1 parent 3d7a55f commit 38d26c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 4 additions & 5 deletions cosymlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def get_path_parameters(self, shape_label1, shape_label2, central_atom=0):

def print_minimum_distortion_path_shape(self, shape_label1, shape_label2, central_atom=0,
min_dev=None, max_dev=None, min_gco=None, max_gco=None,
num_points=20, output=None):
num_points=20, output=sys.stdout):
"""
Print the minimum distortion path
Expand All @@ -916,15 +916,14 @@ def print_minimum_distortion_path_shape(self, shape_label1, shape_label2, centra
:type output1: hook
"""

if output is not None:
if output is not sys.stdout:
output_name, file_extension = os.path.splitext(output.name)
output1 = open(output_name + '_pth.csv', 'w')
output2 = open(output_name + '_pth.xyz', 'w')
output3 = output
else:
output1 = sys.stdout
output2 = sys.stdout
output3 = sys.stdout
devnull = open(os.devnull, 'w')
output1 = output2 = output3 = devnull

csm, devpath, gen_coord = self.get_path_parameters(shape_label1, shape_label2, central_atom=central_atom)

Expand Down
6 changes: 5 additions & 1 deletion scripts/shape_map
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ if args.m_1 or args.m_custom_1:
num_points=args.n_points,
output=common_output)

plt.savefig('shape_map.png')
if args.output_name is None:
plt.show()
else:
import os
output_name, file_extension = os.path.splitext(args.output_name)

plt.savefig('{}_map.png'.format(output_name))

print_footer(common_output)

0 comments on commit 38d26c1

Please sign in to comment.