Skip to content
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

Implement 1D animations #36

Merged
merged 26 commits into from
Oct 24, 2019
Merged

Implement 1D animations #36

merged 26 commits into from
Oct 24, 2019

Conversation

johnomotani
Copy link
Collaborator

Could probably make this fancier, e.g. to allow over-plotting of multiple lines, but it works!

@pep8speaks
Copy link

pep8speaks commented Jul 15, 2019

Hello @johnomotani! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 22:58: E261 at least two spaces before inline comment

Line 171:74: E231 missing whitespace after ','
Line 171:76: E231 missing whitespace after ','
Line 171:78: E231 missing whitespace after ','
Line 200:43: E231 missing whitespace after ','
Line 200:45: E231 missing whitespace after ','
Line 200:47: E231 missing whitespace after ','
Line 231:54: E231 missing whitespace after ','
Line 231:56: E231 missing whitespace after ','
Line 231:58: E231 missing whitespace after ','
Line 250:28: E251 unexpected spaces around keyword / parameter equals
Line 250:30: E251 unexpected spaces around keyword / parameter equals
Line 341:90: E501 line too long (90 > 89 characters)

Comment last updated at 2019-10-23 16:04:00 UTC

@TomNicholas
Copy link
Collaborator

TomNicholas commented Jul 15, 2019

Thanks!

I will have a look at this properly later, but you will be interested in this PR to xarray, which I hope one day can can supplant this.

xbout/plotting/animate.py Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Jul 16, 2019

Codecov Report

Merging #36 into master will decrease coverage by 4.3%.
The diff coverage is 3.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #36      +/-   ##
==========================================
- Coverage   48.03%   43.72%   -4.31%     
==========================================
  Files           6        6              
  Lines         254      279      +25     
  Branches       51       59       +8     
==========================================
  Hits          122      122              
- Misses        122      147      +25     
  Partials       10       10
Impacted Files Coverage Δ
xbout/boutdataarray.py 26.66% <ø> (ø) ⬆️
xbout/plotting/animate.py 9.23% <3.44%> (-5.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc503e7...317420e. Read the comment docs.

xbout/plotting/animate.py Outdated Show resolved Hide resolved
@johnomotani
Copy link
Collaborator Author

Note the test failures seem to be due to an xarray bug pydata/xarray#3401

@johnomotani
Copy link
Collaborator Author

Thanks to @rdoyle45, the xarray issue causing the test failures is now fixed in xarray/master, so the tests should pass once the next xarray release comes out (whenever that is). In the meantime, the tests pass on my computer with the older xarray/1.3.0, so I think this PR is ready for review/merge.

I guess we could change the test environment to use a specific version of xarray that works, but I think it's good to keep using the latest version to pick up issues like this, so I'm in favour of leaving the test setup as-is, and just verifying the checks manually.

TomNicholas
TomNicholas previously approved these changes Oct 21, 2019
@johnomotani
Copy link
Collaborator Author

I need to update the test data files in xbout/tests/data/dump_files to add jyseps1_2, etc. to get the tests to pass. The files are ~21MB - I think it might be better to remove the .nc files and replace them with a simple python script/function to generate the required files. Thoughts?

@TomNicholas
Copy link
Collaborator

TomNicholas commented Oct 21, 2019 via email

@johnomotani
Copy link
Collaborator Author

Do they need to be 21MB?

Not sure, I don't know why they were originally created with the structure they have. But there are 32 files in the tests/data/dump_files/along_x directory, which seems like a lot, so I'd guess they could be cut down.

@TomNicholas
Copy link
Collaborator

TomNicholas commented Oct 21, 2019 via email

@johnomotani
Copy link
Collaborator Author

makes sense, but I'll try and replace by using the create_bout_ds_list function so we can get rid of the binary files. If that works out, it might even be worth deleting the binary files from the history (while there are still not so many users) to make the xBOUT download smaller, I think those files are like 90% of the disk space used.

@johnomotani
Copy link
Collaborator Author

Actually, because create_bout_ds_list uses xarray (and because I mostly wrote the script already), I'm tempted to put in a function written with just numpy and netCDF4.Dataset to create the 'reference' data files. It seems to me like that minimises the dependence on the tools that we want to test, when creating the test data.

@TomNicholas
Copy link
Collaborator

I like the create_bout_ds_list function, but I'm unsure why you would ever use netCDF4.Dataset when xarray exists? xarray wraps netCDF, you should be able to accomplish the same thing in fewer lines with one less explicit dependency.

@johnomotani
Copy link
Collaborator Author

My thinking is that we depend strongly on xarray, so maybe it's better not to use xarray to generate test input. netCDF4 is independent and probably more stable. So we're testing xarray as well as xBOUT. Maybe that's the wrong point of view - instead we should trust xarray's tests, and say we're specifically testing xBOUT so it's fine to use xarray to generate input. Any thoughts @ZedThree?

@rdoyle45
Copy link
Collaborator

A slight digression gents; on the errors thrown by the checks of a4ad8b7, those in in Python 3.6 have been solved in xarray and will be in the next release as mentioned by @johnomotani earlier. Whereas those thrown by Python 3.5, relating to the path passed to the generate_test_data function, are specific to Python 3.5.

I don't believe this is of the greatest importance, but should more recent releases of python be used for test? Maybe 3.6 and 3.7 instead (with a possible inclusion of 3.8) or is the backwards compatibility of xBOUT to 3.5 of greater importance? @TomNicholas

Copy link
Collaborator

@rdoyle45 rdoyle45 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should solve the problem with python 3.5 test.

@TomNicholas
Copy link
Collaborator

TomNicholas commented Oct 22, 2019 via email

@johnomotani
Copy link
Collaborator Author

Thanks @rdoyle45!
Seems like the error in Python-3.5 is a known issue with pathlib and pytest, which is resolved in Python-3.6.
https://stackoverflow.com/questions/40784950/pathlib-path-and-py-test-localpath
As pathib.join() is nicer than converting to string (should be more cross-platform compatible), I'd agree that it's best to just require Python-3.6.

@rdoyle45
Copy link
Collaborator

Agreed on both counts. @johnomotani

Makes test files more similar to BOUT++ dump files.
Use the file number as a seed for the random number generation so that
all files are different.
Previously was ('x','y','z','t'). The new order matches the way BOUT++
stores data.
Instead generate the input files in a temporary directory using
test_load.create_bout_ds_list().
@johnomotani
Copy link
Collaborator Author

Discussion on Slack agreed with @TomNicholas, so I've removed the generate_test_data() function that used netCDF4.Dataset, and instead used test_load.create_bout_ds_list(). I've also extended create_bout_ds/create_bout_ds_list a bit to create files that are more similar to BOUT++ output.

In Python-3.5 there is an incompatibility between pathlib.Path and
pytest.LocalPath, which is fixed in Python-3.6.
Copy link
Collaborator

@TomNicholas TomNicholas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great - thanks both of you.

@TomNicholas TomNicholas merged commit af57e24 into master Oct 24, 2019
@johnomotani johnomotani deleted the 1d-animations branch October 25, 2019 17:16
johnomotani pushed a commit that referenced this pull request Dec 11, 2019
Implement 1D animations, and refactor generation of test data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants