home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 277825984

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/pull/1252#issuecomment-277825984 https://api.github.com/repos/pydata/xarray/issues/1252 277825984 MDEyOklzc3VlQ29tbWVudDI3NzgyNTk4NA== 6628425 2017-02-06T21:53:00Z 2017-02-06T21:53:00Z MEMBER

@MaximilianR 6496458 contains an updated version of the file containing the tests, updated to use pytest. I ended up using the ids keyword in places to clean up the test names that are output when running the tests in verbose mode, but I agree it's not super necessary.

Overall pytest seems to clean things up pretty nicely. One problem that I wish I had a better solution for happens when I am testing indexing operations in DataArrays, Series, and DataFrames. There are multiple ways of getting the same answer, which makes these tests a good candidate for using pytest.mark.parametrize; however, one of those ways, using netcdftime._netcdftime.datetime objects directly, depends on the date_type used.

For instance, it would be great if I could write something like: python @pytest.mark.parametrize('sel_arg', [ '0001', slice('0001-01-01', '0001-12-30'), [True, True, False, False], slice(date_type(1, 1, 1), date_type(1, 12, 30)), [date_type(1, 1, 1), date_type(1, 2, 1)] ], ids=['string', 'string-slice', 'bool-list', 'date-slice', 'date-list']) def test_sel(da, index, sel_arg): expected = xr.DataArray([1, 2], coords=[index[:2]], dims=['time']) result = da.sel(time=sel_arg) assert_identical(result, expected)

But I can't use date_type, which is a fixture in my current setup, in an argument to parametrize. Right now I've worked around this by resorting back to manually iterating over the cases by writing separate methods, but that's pretty verbose; might you happen to know of a cleaner way of setting things up in this case?

In any event, when you get a chance, please let me know if you have any comments / suggestions on my latest push. Thanks again for your help.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  205473898
Powered by Datasette · Queries took 0.621ms · About: xarray-datasette