-
Notifications
You must be signed in to change notification settings - Fork 3
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
Imported module names/function should be correctly passed to qastle. #131
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #131 +/- ##
==========================================
+ Coverage 96.79% 96.81% +0.01%
==========================================
Files 15 15
Lines 1281 1286 +5
==========================================
+ Hits 1240 1245 +5
Misses 41 41
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
The problem of |
If you have something like |
If you have imported
Right, assignment can't appear within a query, but My point is that the |
Maybe this is a better example of what I'm talking about. Say I've made a typo in my query and referred to the wrong variable ( var1 = 1000
query = ds.Select(lambda event: event.Jet_pt / var) If |
As I mentioned in the issue (#127), this type checking is already done by |
Ok, @masonproffitt - I've added a whitelist for types we can capture - the error should be more informative. For example (from the test): ValueError("Do not know how to capture data type \'bogus\' for variable \'my_var\' - only str, int, float, bool, complex, str, bytes are supported." which happens from this test: def test_sensible_error_with_bad_variable_capture():
class bogus:
def __init__(self):
self.my_var = 10
my_var = bogus()
with pytest.raises(ValueError) as e:
parse_as_ast(lambda x: x > my_var)
assert "my_var" in str(e) Does that get to what you are after? |
Passing through
np
and other module names for some functions didn't work ifnp
had already been imported into the namespace. This fixes that and improves error messages around non-standard lambda captures.ModuleType
is now "captured" as just the name you use. Sonp
andnumpy
are both passed down (warning!).np
should no work both if or if it hasn't been imported.str, int, float, bool, complex, str,
andbytes
.numpy
to test install flavor so this functionality could be tested.Fixes #127