Closed strempfer closed 3 years ago
This pull request introduces 2 alerts when merging 2875fec4465a0ca4e29444d11ecc175dd32738bc into f0a294dfde6c712ee89243e1250a1fa4dae0c452 - view on LGTM.com
new alerts:
Merging #46 (541c7dd) into main (f0a294d) will decrease coverage by
1.12%
. The diff coverage is59.34%
.
@@ Coverage Diff @@
## main #46 +/- ##
==========================================
- Coverage 45.93% 44.80% -1.13%
==========================================
Files 7 6 -1
Lines 947 973 +26
==========================================
+ Hits 435 436 +1
- Misses 512 537 +25
Impacted Files | Coverage Δ | |
---|---|---|
polartools/diffraction.py | 0.00% <0.00%> (ø) |
|
polartools/load_data.py | 71.71% <63.47%> (-25.79%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update f0a294d...541c7dd. Read the comment docs.
I think you don't need to check the exit status. Just check if the baseline stream exists, and print it if it does.
How do you check on the baseline if it does not exist without raising a ValueError?
It's fine for a value error to pop up if the stream doesn't exist, but it'd be good to have a good message for what the problem is, so I think this would be best done in load_databroker
:
def load_databroker(scan_id, db, stream="primary", query=None, use_db_v1=True):
"""
Load data of the first scan with the provided scan_id.
Currently defaults to databroker.v1 because it is faster. See issue #28.
For further details, refer to the `databroker` `documentation`_.
.. _documentation: https://blueskyproject.io/databroker/
Parameters
----------
scan_id : int
Scan_id of the scan to be retrieved
db :
`databroker` database
stream : string, optional
Selects the stream from which data will be loaded.
query : dict, optional
Dictionary with search parameters for the database.
use_db_v1 : bool, optional
Chooses databroker API version between 'v1' or 'v2', defaults to 'v1'.
Returns
-------
data : pandas.DataFrame
Table with the data from the primary stream.
"""
_db = db_query(db, query) if query else db
if use_db_v1:
if stream in _db.v1[scan_id].stream_names:
return _db.v1[scan_id].table(stream_name=stream)
else:
raise ValueError(f"The stream {stream} does not exist in scan {scan_id}.")
else:
try:
return getattr(_db.v2[scan_id], stream).read().to_dataframe()
except AttributeError:
raise ValueError(f"The stream {stream} does not exist in scan {scan_id}.")
great suggestion. This simplifies things a lot.
This pull request introduces 1 alert when merging b93d74c277da32efb25eff1765e3432f24f643d6 into f0a294dfde6c712ee89243e1250a1fa4dae0c452 - view on LGTM.com
new alerts:
implement new function to read baseline devices