From 770d77da3ce9d91dd5fd2bca548797d67cd79989 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 20 Feb 2017 21:13:01 +0800 Subject: Fix errors in acispy/region.py and scripts/calc_centroid.py --- acispy/region.py | 2 +- scripts/calc_centroid.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/acispy/region.py b/acispy/region.py index 09e42fa..dd98d20 100644 --- a/acispy/region.py +++ b/acispy/region.py @@ -210,7 +210,7 @@ class Regions: def __init__(self, regfile=None): if regfile: - self.regions = self.load(regfile) + self.load(regfile) else: self.regions = [] diff --git a/scripts/calc_centroid.py b/scripts/calc_centroid.py index 2f4606f..6d8ba33 100755 --- a/scripts/calc_centroid.py +++ b/scripts/calc_centroid.py @@ -20,7 +20,7 @@ from _context import acispy from acispy.manifest import get_manifest from acispy.pfiles import setup_pfiles from acispy.ds9 import ds9_view -from acispy.regions import Regions +from acispy.region import Regions def smooth_image(infile, outfile=None, @@ -177,7 +177,8 @@ def main(): radius=radius) print("Done!", file=sys.stderr) - open(args.outfile, "w").write("point(%f,%f)\n" % centroid).close() + with open(args.outfile, "w") as f: + f.write("point(%f,%f)\n" % centroid) print("Saved centroid to file:", args.outfile, file=sys.stderr) if args.view: ds9_view(img_smoothed, regfile=args.outfile) -- cgit v1.2.2