-
Notifications
You must be signed in to change notification settings - Fork 21
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
Refactor ptable
plotters and add ptable_heatmap
with diagonally-split tiles
#131
Conversation
…bench_perovskites_eda.ipynb
for more information, see https://pre-commit.ci
Can you please give me some comments so far @janosh ? Thanks a lot! Not sure why |
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.
impressive work! thanks so much @DanielYang59. 🙏 several comments below
i think the SVG compression action is failing because of this unaddressed limitation
actions/checkout#694
I think we're almost there @janosh. A few issues left:
|
@janosh. Can you please review this? Sorry to say but I'm feeling that I'm currently making this PR too huge for me to efficiently work on. Can we merge this first and I would chop up the remaining work into (multiple) follow-up PRs. Update: summary moved to the top for visibility. |
@janosh In case this PR get lost. Thanks for your time! |
sorry for the delay. i'll try to get on this today. |
No worries at all. No pressure. Thanks! |
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.
i think everything in this PR looks great. you left some todos which IIUC you prefer to leave for subsqeuent PRs?
My intention was to make everything modular (grouped by objects of course, colorbar/colormap/element symbol/or such) so that it becomes clearer for users (contrary to packing all args into a single plotter call), and make it easier for us to maintain.
I think by separating everything by object, the args are more self-explanatory. Instead of:
i take your point! i'm still a bit reluctant about the PTableProjector
class but maybe you're right. i was originally thinking to extract common logic between ptable_...
functions into helper functions like data_preprocessor
and handle_missing_and_anomaly
and then give each ptable_...
function kwargs for each helper function:
ptable_heatmap(data, data_preproces_kwargs=dict(...), handle_missing_kwargs=dict(...), ...)
to simplify the function signature and make it less overwhelming. users could jump between the helper functions to only see the keywords they currently care about while keeping everything as pure functions. maybe worth considering if PTableProjector
could be rewritten that way?
Yes. There are too many changes to make for a single PR, I would address them shortly in a follow up PR.
I understand your intention here and I'm not sure which one would be easier for the user though. I think by packing everything into the |
self.cmap: Colormap = colormap | ||
|
||
# Preprocess data | ||
self.data: pd.DataFrame = data | ||
|
||
# Initialize periodic table canvas | ||
n_periods = df_ptable.row.max() | ||
n_groups = df_ptable.column.max() | ||
|
||
# Set figure size | ||
plot_kwargs = plot_kwargs or {} | ||
plot_kwargs.setdefault("figsize", (0.75 * n_groups, 0.75 * n_periods)) | ||
|
||
self.fig, self.axes = plt.subplots(n_periods, n_groups, **plot_kwargs) |
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.
I think both should work almost the same because in my class, there isn't much (if any) shared states at all.
i would consider any self.<attribute>
as state. but rather than belabor the point, let's merge this PR as is and refactor later if needed.
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.
thanks a lot @DanielYang59, this is a huge PR.
Thanks for reviewing! I would try to finish the remaining several TODOs soon.
Yes but nearly zero states are "shared". So it should be pretty easy if we really wish to refactor it. |
closes #130
Summary
Good news first
Breaking changes
ptable_plots
replaced byptable_lines
andptable_scatters
with the new implementation, kind of good news :)*_kwargs
over*_kwds
for consistency, previously a random mixture of both were used.Urgently needed fixes:
ptable_lines
andptable_scatters
doesn't support colormap (yet). I would certainly implement the support forptable_scatters
, but as we discussed previously in Refactorptable
plotters and addptable_heatmap
with diagonally-split tiles #131 (comment), I'm not sure if we want to support colored symbols forptable_lines
.mace_pair_repulsion.py
is certainly broken as colormap is not supported byptable_lines
anymore.Not-so-urgent fixes/enhancement:
data_preprocessor
doesn't support missing value/infinity handling yet.