-
Notifications
You must be signed in to change notification settings - Fork 370
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
[WIP] No subclasses refactor v2 #437
base: master
Are you sure you want to change the base?
Conversation
Hey @dorisjlee, I created this new PR which aims at a cleaner refactor in that it does as few modifications possible to the existing structure e.g. doesn't mess with imports. It has the following differences with the previous:
This time I am starting bottom up in that I created a new test file called Next Steps
|
Thanks @cgarciae! This makes sense, we can slowly add the tests back in to test a subset of the functionality one at a time. |
lux/patch/frame.py
Outdated
for attr in self._metadata: | ||
groupby_obj.__dict__[attr] = getattr(self, attr, None) | ||
if history_flag: | ||
groupby_obj._history = groupby_obj._history.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic has to change since groupby_obj
no longer has ._history
.
Hey @dorisjlee! I've been fixing tests and solving bugs. |
@dorisjlee In this test, after def test_metadata_propogate_invalid_intent():
df = pd.read_csv(
"https://raw.githubusercontent.com/lux-org/lux-datasets/master/data/employee.csv")
df.lux.intent = ["Attrition"]
new_df = df.groupby("BusinessTravel").mean()
assert new_df.lux.intent[0].attribute == "Attrition", "User-specified intent is retained"
assert new_df.lux._inferred_intent == [], "Invalid inferred intent is cleared"
new_df._ipython_display_()
assert new_df.lux.current_vis == [] # <<--- not being emptied |
Just as a recap, I ran all the tests an dcurrently these are the results:
|
Hey @cgarciae, The current_vis is cleared when we call clear_intent, which calls set_intent. Inside the set_intent, when we do |
Co-authored-by: Doris Lee <dorisjunglinlee@gmail.com>
The idea of this PR is to:
LuxDataFrame
,LuxSeries
, etcpandas.DataFrame
class (and all other internal references to it) with their Lux counterpart e.g.:Current behaviour can be surprising to the user and it makes supporting new versions harder as you might have to deal with more edge cases because the impact of the modifications is so large. Instead the idea is to some lightweight monkey patching of fiew core methods (which mostly do bookkeeping) and move the rest to out of the DataFrame class to avoid possible conflicts. A lot of discussion and possible iteration is needed. These are the current efforts:
Ongoing changes
LuxDataFrame
as a class is removed, instead key methods of interest formpandas.DataFrame
are patched.LuxDataFrame
is now aProtocol
that is there only for possible validation and type inference purposes.@patch(cls)
decorator, this replaces the method on the class but the original method is still available as._super_{method_name}
, e.g:.lux
property that includes all lux extension methods is created. Its very similar to the existing.str
and.dt
functionality already present in pandas, here is an example usage: