-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check Table in angular_separation functions #191
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportBase: 90.97% // Head: 91.45% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #191 +/- ##
==========================================
+ Coverage 90.97% 91.45% +0.47%
==========================================
Files 40 40
Lines 1685 1720 +35
==========================================
+ Hits 1533 1573 +40
+ Misses 152 147 -5
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Regarding no. 2: Checking for |
I would say if your function expects a QTable later on, you should just explicitly cast the input table to QTable in the function, def my_func(table : Table):
qtable = QTable(table) # then use qtable later in the function That way you don't have to check for two different ways to access the columns, and then you also don't require QTables to be used as input (which lose access to some column metadata) Edit: the metadata loss seems to be fixed now in astropy, so casting back and forth between Table and QTable now results in the same metadata (as long as you cast back to Table before writing). So casting to what you want to use seems to be the best solution and you do not lose anything in the process. |
bce3f80
to
6ae3395
Compare
Hi there,
I spent too much time figuring out why my angular resolution was as bad as it was. I found out it was because of how
astropy.coordinates.angular_separation
behaves when given floats and quantities (i.e. one in deg, the other in rad).angular_separation
is what is used in ourpyirf.utils.calculate_theta
.The problem was giving a
Table
instead of aQTable
, where the columns are no quantities, thus the values get interpreted as floats and thus radians instead of degree (if they were in degree of course).check_table
function to the functions that useangular_separation
..unit
beingNone
, thus filtering out also the case where aTable
ist passed (instead of aQTable
). This fails with some "Column ... has incompatible unit None, expected ...". Here we could decide on checkingisinstance(events, QTable)
.The thing with these changes is, that incorrect usage before just yields wrong results, where the error (on the user side) is not obvious, after these changes incorrect usage fails.