()
| 2307 | |
| 2308 | |
| 2309 | def test_wrap() -> None: |
| 2310 | # test values are: two words less than width, two words equal to width, |
| 2311 | # two words greater than width, one word less than width, one word |
| 2312 | # equal to width, one word greater than width, multiple tokens with |
| 2313 | # trailing whitespace equal to width |
| 2314 | values = xr.DataArray( |
| 2315 | [ |
| 2316 | "hello world", |
| 2317 | "hello world!", |
| 2318 | "hello world!!", |
| 2319 | "abcdefabcde", |
| 2320 | "abcdefabcdef", |
| 2321 | "abcdefabcdefa", |
| 2322 | "ab ab ab ab ", |
| 2323 | "ab ab ab ab a", |
| 2324 | "\t", |
| 2325 | ] |
| 2326 | ) |
| 2327 | |
| 2328 | # expected values |
| 2329 | expected = xr.DataArray( |
| 2330 | [ |
| 2331 | "hello world", |
| 2332 | "hello world!", |
| 2333 | "hello\nworld!!", |
| 2334 | "abcdefabcde", |
| 2335 | "abcdefabcdef", |
| 2336 | "abcdefabcdef\na", |
| 2337 | "ab ab ab ab", |
| 2338 | "ab ab ab ab\na", |
| 2339 | "", |
| 2340 | ] |
| 2341 | ) |
| 2342 | |
| 2343 | result = values.str.wrap(12, break_long_words=True) |
| 2344 | assert result.dtype == expected.dtype |
| 2345 | assert_equal(result, expected) |
| 2346 | |
| 2347 | # test with pre and post whitespace (non-unicode), NaN, and non-ascii |
| 2348 | # Unicode |
| 2349 | values = xr.DataArray([" pre ", "\xac\u20ac\U00008000 abadcafe"]) |
| 2350 | expected = xr.DataArray([" pre", "\xac\u20ac\U00008000 ab\nadcafe"]) |
| 2351 | result = values.str.wrap(6) |
| 2352 | assert result.dtype == expected.dtype |
| 2353 | assert_equal(result, expected) |
| 2354 | |
| 2355 | |
| 2356 | def test_wrap_kwargs_passed() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…