astro-otter 0.4.0__tar.gz → 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of astro-otter might be problematic. Click here for more details.

Files changed (32) hide show
  1. {astro_otter-0.4.0/src/astro_otter.egg-info → astro_otter-0.4.1}/PKG-INFO +1 -1
  2. {astro_otter-0.4.0 → astro_otter-0.4.1/src/astro_otter.egg-info}/PKG-INFO +1 -1
  3. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/_version.py +1 -1
  4. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/io/otter.py +4 -4
  5. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/io/transient.py +10 -0
  6. {astro_otter-0.4.0 → astro_otter-0.4.1}/tests/test_otter.py +67 -1
  7. {astro_otter-0.4.0 → astro_otter-0.4.1}/tests/test_transient.py +11 -0
  8. {astro_otter-0.4.0 → astro_otter-0.4.1}/LICENSE +0 -0
  9. {astro_otter-0.4.0 → astro_otter-0.4.1}/README.md +0 -0
  10. {astro_otter-0.4.0 → astro_otter-0.4.1}/pyproject.toml +0 -0
  11. {astro_otter-0.4.0 → astro_otter-0.4.1}/setup.cfg +0 -0
  12. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/astro_otter.egg-info/SOURCES.txt +0 -0
  13. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/astro_otter.egg-info/dependency_links.txt +0 -0
  14. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/astro_otter.egg-info/requires.txt +0 -0
  15. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/astro_otter.egg-info/top_level.txt +0 -0
  16. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/__init__.py +0 -0
  17. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/exceptions.py +0 -0
  18. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/io/__init__.py +0 -0
  19. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/io/data_finder.py +0 -0
  20. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/io/host.py +0 -0
  21. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/plotter/__init__.py +0 -0
  22. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/plotter/otter_plotter.py +0 -0
  23. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/plotter/plotter.py +0 -0
  24. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/schema.py +0 -0
  25. {astro_otter-0.4.0 → astro_otter-0.4.1}/src/otter/util.py +0 -0
  26. {astro_otter-0.4.0 → astro_otter-0.4.1}/tests/test_data_finder.py +0 -0
  27. {astro_otter-0.4.0 → astro_otter-0.4.1}/tests/test_exceptions.py +0 -0
  28. {astro_otter-0.4.0 → astro_otter-0.4.1}/tests/test_host.py +0 -0
  29. {astro_otter-0.4.0 → astro_otter-0.4.1}/tests/test_package.py +0 -0
  30. {astro_otter-0.4.0 → astro_otter-0.4.1}/tests/test_plotter.py +0 -0
  31. {astro_otter-0.4.0 → astro_otter-0.4.1}/tests/test_schema.py +0 -0
  32. {astro_otter-0.4.0 → astro_otter-0.4.1}/tests/test_util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astro-otter
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Author-email: Noah Franz <nfranz@arizona.edu>
5
5
  License: MIT License
6
6
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astro-otter
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Author-email: Noah Franz <nfranz@arizona.edu>
5
5
  License: MIT License
6
6
 
@@ -2,4 +2,4 @@
2
2
  Just define the package version in one place
3
3
  """
4
4
 
5
- __version__ = "0.4.0"
5
+ __version__ = "0.4.1"
@@ -85,9 +85,6 @@ class Otter(Database):
85
85
 
86
86
  self.debug = debug
87
87
 
88
- if gen_summary:
89
- self.generate_summary_table(save=True)
90
-
91
88
  # make sure the data directory exists
92
89
  if not os.path.exists(self.DATADIR):
93
90
  try:
@@ -99,6 +96,9 @@ class Otter(Database):
99
96
  )
100
97
  pass
101
98
 
99
+ if gen_summary:
100
+ self.generate_summary_table(save=True)
101
+
102
102
  connection = Connection(username=username, password=password, arangoURL=url)
103
103
  super().__init__(connection, "otter", **kwargs)
104
104
 
@@ -1531,7 +1531,7 @@ class Otter(Database):
1531
1531
  all_jsons.append(Transient(json))
1532
1532
 
1533
1533
  if db is None:
1534
- db = Otter(datadir=local_outpath)
1534
+ db = Otter(datadir=local_outpath, gen_summary=True)
1535
1535
  else:
1536
1536
  db.DATADIR = local_outpath
1537
1537
 
@@ -432,6 +432,16 @@ class Transient(MutableMapping):
432
432
  if "host" in self:
433
433
  max_hosts = min([max_hosts, len(self["host"])])
434
434
  for h in self["host"][:max_hosts]:
435
+ # only return hosts with their ra and dec stored
436
+ if (
437
+ "host_ra" not in h
438
+ or "host_dec" not in h
439
+ or "host_ra_units" not in h
440
+ or "host_dec_units" not in h
441
+ ):
442
+ continue
443
+
444
+ # now we can construct a host object from this
435
445
  host.append(Host(transient_name=self.default_name, **dict(h)))
436
446
 
437
447
  # then try BLAST
@@ -23,6 +23,18 @@ def test_otter_constructor():
23
23
  db = Otter(url=OTTER_URL, password=OTTER_TEST_PASSWORD)
24
24
  assert isinstance(db, Otter)
25
25
 
26
+ # and using a custom local directory
27
+ otter_test_dir = os.path.join(os.getcwd(), "otter-test")
28
+ db = Otter(
29
+ url=OTTER_URL,
30
+ password=OTTER_TEST_PASSWORD,
31
+ datadir=otter_test_dir,
32
+ gen_summary=True,
33
+ )
34
+
35
+ assert os.path.exists(otter_test_dir) # make sure it was created
36
+ assert isinstance(db, Otter)
37
+
26
38
 
27
39
  def test_get_meta():
28
40
  """
@@ -87,7 +99,7 @@ def test_get_phot():
87
99
  "reference",
88
100
  ]
89
101
 
90
- names = ["2018hyz", "2018zr", "ASASSN-14li"]
102
+ names = ["2018hyz", "2018zr", "ASASSN-14li", "2016fnl", "J123715"]
91
103
 
92
104
  # first with returning an astropy table (the default)
93
105
  allphot = db.get_phot(names=names)
@@ -107,6 +119,10 @@ def test_get_phot():
107
119
  with pytest.raises(FailedQueryError):
108
120
  db.get_phot(names="foo")
109
121
 
122
+ # some other random tests
123
+ with pytest.raises(OSError):
124
+ db.get_phot(names="ASASSN-14li", return_type="foobar")
125
+
110
126
 
111
127
  def test_query():
112
128
  """
@@ -135,3 +151,53 @@ def test_query():
135
151
  # test hasphot and hasspec
136
152
  assert len(db.query(hasspec=True)) == 0
137
153
  assert "ASASSN-20il" not in {t["name/default_name"] for t in db.query(hasphot=True)}
154
+
155
+ # test has_*_phot
156
+ assert len(db.query(has_radio_phot=True)) >= 92
157
+ assert len(db.query(has_xray_phot=True)) >= 35
158
+ assert len(db.query(has_uvoir_phot=True)) >= 120
159
+ assert len(db.query(has_radio_phot=True, has_xray_phot=True)) < len(
160
+ db.query(has_radio_phot=True)
161
+ )
162
+
163
+ # test classification related queries
164
+ assert len(db.query(spec_classed=True)) > 140
165
+ assert len(db.query(unambiguous=True)) > 190
166
+ assert len(db.query(classification="SLSN")) >= 1
167
+
168
+ # check that querying based on references works
169
+ fake_test_bibcodes = ["'tasdfasdf...lkjsfd'", "'asfd...kjasdf...lkjs'"]
170
+ assert len(db.query(refs=fake_test_bibcodes)) == 0
171
+ assert len(db.query(refs=fake_test_bibcodes[0])) == 0
172
+
173
+ # try querying with the fake "private" data
174
+ db2 = Otter(
175
+ url=OTTER_URL,
176
+ password=OTTER_TEST_PASSWORD,
177
+ datadir=os.path.join(
178
+ os.path.dirname(os.path.abspath(__file__)), "private_otter_data"
179
+ ),
180
+ gen_summary=True,
181
+ )
182
+ res = db2.query(names="2018hyz", query_private=True)
183
+ assert res[0].default_name == "2018hyz"
184
+
185
+ # check that some errors are thrown when appropriate
186
+ with pytest.raises(Exception):
187
+ db.query(names=10)
188
+ db.query(refs=10)
189
+
190
+
191
+ def test_from_csvs():
192
+ """
193
+ This tests the "from_csvs" method which allows for interaction with locally
194
+ stored datasets
195
+ """
196
+
197
+ metapath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "meta-test.csv")
198
+ photpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "phot-test.csv")
199
+ outpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "from-csvs-out")
200
+
201
+ db = Otter.from_csvs(metafile=metapath, photfile=photpath, local_outpath=outpath)
202
+
203
+ assert isinstance(db, Otter)
@@ -31,6 +31,13 @@ def test_transient_constructor():
31
31
  assert t.srcmap["2012MNRAS.421.1942W"] == "Wiersema et al. (2012)", srcmap_msg
32
32
  assert t.srcmap["2011ApJ...737..103S"] == "Schlafly & Finkbeiner (2011)", srcmap_msg
33
33
 
34
+ with pytest.raises(AttributeError):
35
+ Transient(d={"name": {"default": "foo"}})
36
+
37
+ del test_json["name"]
38
+ t = Transient(test_json, name="SwJ1644+57")
39
+ assert t.default_name == "SwJ1644+57", "default_name is incorrect!"
40
+
34
41
 
35
42
  def test_getitem():
36
43
  """
@@ -131,6 +138,10 @@ def test_iter():
131
138
  """
132
139
  Test that my __iter__ overwrite works
133
140
  """
141
+ t = Transient({"test1": {"mytest": "nothing to see here", "other": 1}})
142
+
143
+ assert list(iter(t)) == list(iter(t.data))
144
+
134
145
  true_vals = [
135
146
  {"value": "Sw J1644+57", "reference": ["Swift"]},
136
147
  {"value": "GRB 110328A", "reference": [["2011Sci...333..203B"]]},
File without changes
File without changes
File without changes
File without changes