From 4797429bbfca05ea735b9ceb300e79bbba6c8000 Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Wed, 3 Jul 2019 13:45:33 -0700 Subject: [PATCH 1/7] Protect against DMSKY_PATH pointing at a directory without subdirectories --- dmsky/library.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dmsky/library.py b/dmsky/library.py index 77857f4..723cbcc 100644 --- a/dmsky/library.py +++ b/dmsky/library.py @@ -84,7 +84,11 @@ def load_library(cls, paths): for path in paths: # Should use logging print("Using %s for %s" % (path, cls.__name__)) - subdirs = [path] + next(os.walk(path))[1] + try: + subdirs = [path] + next(os.walk(path))[1] + except StopIteration: + print("Path %s does have any subdirectories" % path) + pass for subdir in subdirs: infiles = glob.glob(join(path, subdir) + '/*.yaml') for f in infiles: From 532f12a6b8d91dba9a245312c129aae854b790d7 Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Mon, 8 Jul 2019 15:38:46 -0700 Subject: [PATCH 2/7] Protect against underflow in plotting in test_densities --- tests/test_density.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_density.py b/tests/test_density.py index 6462f76..f435abb 100644 --- a/tests/test_density.py +++ b/tests/test_density.py @@ -26,16 +26,20 @@ # Plot the different profiles def test_densities(): fig,ax = plt.subplots() + y_min = 1e-4 for i,cls in enumerate(classes): if cls == 'DensityProfile': continue dp = dmsky.density.factory(cls) dp.set_rho_r(1,dp.rs) + denp = dp(radius) + y_min = min(y_min, denp.min()) print(dp) # Small offset for visualization epsilon = i*0.2e-1 #epsilon = 0 - plt.plot(radius,dp(radius) * (1+epsilon),'-',label=cls) + plt.plot(radius, denp * (1+epsilon),'-',label=cls) print('') + ax.set_ymin( ax.set_yscale('log') ax.set_xscale('log') plt.xlabel("Radius") From d957a5b2e6b2dcf31ce5f7b5e5881897bd31fd6c Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Mon, 8 Jul 2019 15:44:20 -0700 Subject: [PATCH 3/7] Protect against underflow in plotting in test_densities --- tests/test_density.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_density.py b/tests/test_density.py index f435abb..0cd07d0 100644 --- a/tests/test_density.py +++ b/tests/test_density.py @@ -31,15 +31,13 @@ def test_densities(): if cls == 'DensityProfile': continue dp = dmsky.density.factory(cls) dp.set_rho_r(1,dp.rs) - denp = dp(radius) - y_min = min(y_min, denp.min()) + denp = dp(radius).clip(y_min, np.inf) print(dp) # Small offset for visualization epsilon = i*0.2e-1 #epsilon = 0 plt.plot(radius, denp * (1+epsilon),'-',label=cls) print('') - ax.set_ymin( ax.set_yscale('log') ax.set_xscale('log') plt.xlabel("Radius") From 599dc462fb387cd3d18c1c42a2c41c38ed9c2c00 Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Tue, 9 Jul 2019 08:26:19 -0700 Subject: [PATCH 4/7] Update python versions in .travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fba9eb4..92ec177 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,8 @@ language: python python: - "2.7" - - "3.4" + - "3.5" + - "3.6" # - "nightly" # currently points to 3.6-dev sudo: false From 15a05224192092961f95bd4c49a90753dae04ad5 Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Tue, 9 Jul 2019 08:26:55 -0700 Subject: [PATCH 5/7] Remove extraneous special characters from target yaml files --- dmsky/data/targets/dwarfs/defaults.yaml | 2 +- dmsky/data/targets/dwarfs/koposov2018.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dmsky/data/targets/dwarfs/defaults.yaml b/dmsky/data/targets/dwarfs/defaults.yaml index 8f96d0a..4b63fe4 100644 --- a/dmsky/data/targets/dwarfs/defaults.yaml +++ b/dmsky/data/targets/dwarfs/defaults.yaml @@ -902,7 +902,7 @@ carina_III: name: 'carina_III' color: 'cyan' ra: 114.6298 - dec: −57.8997 + dec: 57.8997 distance: 27.8 dsigma: 0.6 major_axis: 3.75 diff --git a/dmsky/data/targets/dwarfs/koposov2018.yaml b/dmsky/data/targets/dwarfs/koposov2018.yaml index 259dff6..9d6fb36 100644 --- a/dmsky/data/targets/dwarfs/koposov2018.yaml +++ b/dmsky/data/targets/dwarfs/koposov2018.yaml @@ -1,7 +1,7 @@ # https://arxiv.org/abs/1804.06430 hydrus_I: # Table 1 in Koposov et al. 2018 - # log10(J(0.5deg)) = 18.33 [+0.38,−0.34] + # log10(J(0.5deg)) = 18.33 [+0.38,0.34] koposov2018_nfw: j_integ: 2.14e18 j_sigma: 0.36 From af36e244944bd133bfd2404a7dffd173c9dfe69d Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Tue, 9 Jul 2019 08:27:09 -0700 Subject: [PATCH 6/7] Catch exceptions from yaml --- dmsky/utils/tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dmsky/utils/tools.py b/dmsky/utils/tools.py index 827ad01..4ff8093 100644 --- a/dmsky/utils/tools.py +++ b/dmsky/utils/tools.py @@ -14,7 +14,7 @@ def yaml_load(filename): raise Exception('File does not exist: %s' % (filename)) try: ret = yaml.load(open(filename), Loader=yaml.CLoader) - except IOError: + except (IOError, AttributeError): ret = yaml.load(open(filename), Loader=yaml.Loader) return ret @@ -33,7 +33,7 @@ def yaml_dump(x, filename): try: out.write(yaml.dump(x, Dumper=yaml.CDumper)) - except IOError: + except (IOError, AttributeError): out.write(yaml.dump(x, Dumper=yaml.Dumper)) out.close() From d4b89ed5f0fad6ad6af5d7638b79349920ad5e60 Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Tue, 9 Jul 2019 09:06:25 -0700 Subject: [PATCH 7/7] Update .travis.yml --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 92ec177..4f0676f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: python python: - "2.7" - - "3.5" - "3.6" # - "nightly" # currently points to 3.6-dev @@ -31,4 +30,4 @@ script: - export MPLBACKEND=Agg - nosetests -v tests/test_skymap.py - nosetests -v tests/test_density.py - - nosetests -v tests/test_jcalc.py \ No newline at end of file + - nosetests -v tests/test_jcalc.py