-
-
Notifications
You must be signed in to change notification settings - Fork 409
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
Integrate custom abundance widget as a full module #1751
Integrate custom abundance widget as a full module #1751
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1751 +/- ##
==========================================
- Coverage 62.65% 58.40% -4.25%
==========================================
Files 65 66 +1
Lines 6036 6631 +595
==========================================
+ Hits 3782 3873 +91
- Misses 2254 2758 +504
Continue to review full report at Codecov.
|
Before a pull request is accepted, it must meet the following criteria:
|
8435789
to
d68db9d
Compare
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
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.
Very nice work. I haven't looked at the code itself in detail because I have a few comments regarding bugs/design.
- Need units for the density in the plot. It should be g/cm3
- The description of the 'apply to other shells' function should be more descriptive. It looks like it only applies whichever ones are locked, is that true?
- The edit density functionality didn't work for me. The plot never updated to show the new density I had put in. This is true for editing the density of a single shell and using different functions to calculate the densities in multiple shells
- If I have more than 10 elements, the colours in the plot start to repeat, which makes it difficult to tell them apart. Can we have a different colour scheme? Maybe a gradient? Although even with a gradient, it'll be difficult to tell apart if there are many elements. Basically, I don't have a good solution to this.
- When calculating and plotting the densities, there must be some t0 assumed. This should also be the default value in the box where it asks you to put in a t0 and stated somewhere. Perhaps the y label should be 'Density at XX' where XX = t0.
- I think it makes sense to keep the points in the plot because then you can easily see where the cells change. If there are no points and I have a constant fractional abundance, then I can't see where each cell begins and ends
- There is still an issue with adding cells below the boundary. This is raised in issue Density calculated below photosphere for Branch W7 density #1734. Not sure what to do about it in the mean time.
- I think the output functionality should add the file extension. e.g. if I save file path = 'test' then it should save as 'test.csvy'
- If I overwrite existing cells and therefore change the number of cells in the model, the shell number box doesn't update to reflect that. For example, say I have a model with 20 cells as in the example and I highlight cell 2 in the plot. Then I update the model to overwrite all cells into one big cell. In this case I get an index error and it crashes
This may seem like a lot, but overall it's very impressive, good job!
@yuyizheng1112 black check workflow is failing. Also have you added changes we discussed to widget layout - I'm planning to review once that is done? |
@MarkMageeAstro |
aaaca06
to
8cc5f88
Compare
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 would also suggest that we use the json schemas to see what types of density profiles exist.
YAML_DELIMITER = "---" | ||
|
||
|
||
class CustomYAML(yaml.YAMLObject): |
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.
why do we need a new YAML file?
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.
This class generates a YAML object for writing YAML portion when saving the model file.
CustomAbundanceWidget | ||
""" | ||
csvy_model_config, csvy_model_data = load_csvy(fpath) | ||
base_dir = os.path.abspath(os.path.dirname(__file__)) |
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.
lets use tardis.__path__
here as BASE_DIR
at the beginning of the file.
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.
and use pathlib
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.
@wkerzendorf I think I can use pathlib
when writing CSVY output file, but why should we use pathlib
in from_csvy
method?
|
||
# Add YAML delimiter | ||
splits = yaml_output.split("\n") | ||
splits[0] = splits[-1] = YAML_DELIMITER |
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.
not clear what that line does (it might be right - just don't understand it)
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.
It replaces the first and the last line with ---
in the CSVY file.
The original first line is a YAML tag: !!python/object:tardis.visualization.widgets.custom_abundance.CustomYAML
and the original last line is blank, so I add this line to replace them and add yaml delimiter.
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.
@yuyizheng1112 probably it'll be better to rename splits
as yaml_output_snippets
@wkerzendorf Can I do this in another new PR? |
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.
This is a very excellent work @yuyizheng1112 - congratulations on writing such a huge module single-handedly. 🎉
Your code organisation is nice, you have righlty splitted functionality in appropriate methods, and I really liked the pattern you followed in naming so many widget components. The code documentation is also fairly good except for few changes that I commented. The docs also look great with the examples.
My comment count is really high 😅 but they are mostly small nitpicky requests that shouldn't take much time to address. Feel free to let me know if anything is unclear
docs/io/visualization/index.rst
Outdated
abundance_widget |
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.
Generating Widgets in a Notebook <generating_widgets> | |
abundance_widget | |
Generating Custom Abundance Widget <abundance_widget> | |
Generating Data Exploration Widgets <generating_widgets> |
For now let's keep it this way.
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.
Also can you edit the title of generating_widgets.ipynb to same?
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 edit the title of both generating_widgets.ipynb
and abundance_widget.ipynb
. I also clear the output and commented the cell that generates shell_info_widget
from HDF file. Please tell me if you don't want to do that.
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.
Since you edited the title there was no need of mentioning explicit title in TOC but NVM
Co-authored-by: Jaladh Singhal <[email protected]>
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.
Thank you for addressing all of my comments - docstrings look much better now.
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.
This is an extremely well-structured piece of code @yuyizheng1112 - fantastic work! I have no issues with merging this
This PR integrates the codes of custom abundance widget from notebook to .py module. The notebook is in pr #1626.
Description
custom_abundance.py
module to create widget object.using_widgets.rst
to demonstrate how to use the widget. See the documentation page here.abundance_widget.ipynb
notebook to demonstrate how to generate the widget. See the documentation page here.Type of change
Checklist