home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1466127429

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/7619#issuecomment-1466127429 https://api.github.com/repos/pydata/xarray/issues/7619 1466127429 IC_kwDOAMm_X85XY1RF 14808389 2023-03-13T13:15:40Z 2023-03-13T13:15:40Z MEMBER

this happens with any code that calls polyval on coefficients with int32 dtypes. The example from the docs: ```python In [19]: import xarray as xr ...: ...: x = xr.DataArray(np.arange(10), dims=["x"], name="x") ...: a = xr.DataArray(3 + 4 * x, dims=["x"], coords={"x": x}) ...: out = a.polyfit(dim="x", deg=1, full=True) ...: out Out[19]: <xarray.Dataset> Dimensions: (degree: 2) Coordinates: * degree (degree) int64 1 0 Data variables: x_matrix_rank int64 2 x_singular_values (degree) float64 1.358 0.3963 polyfit_coefficients (degree) float64 4.0 3.0 polyfit_residuals float64 4.522e-28

In [20]: xr.polyval(coord=x, coeffs=out.assign_coords(degree=out.degree.astype("int64"))) Out[20]: <xarray.Dataset> Dimensions: (x: 10) Dimensions without coordinates: x Data variables: x_matrix_rank (x) int64 2 4 6 8 10 12 14 16 18 20 x_singular_values (x) float64 0.3963 1.754 3.111 ... 9.899 11.26 12.61 polyfit_coefficients (x) float64 3.0 7.0 11.0 15.0 ... 27.0 31.0 35.0 39.0 polyfit_residuals (x) float64 4.522e-28 9.044e-28 ... 4.07e-27 4.522e-27

In [21]: xr.polyval(coord=x, coeffs=out.assign_coords(degree=out.degree.astype("int32")))

ValueError Traceback (most recent call last) Cell In[21], line 1 ----> 1 xr.polyval(coord=x, coeffs=out.assign_coords(degree=out.degree.astype("int32")))

File .../xarray/core/computation.py:1972, in polyval(coord, coeffs, degree_dim) 1968 raise ValueError( 1969 f"Dimension {degree_dim} should be a coordinate variable with labels." 1970 ) 1971 if not np.issubdtype(coeffs[degree_dim].dtype, int): -> 1972 raise ValueError( 1973 f"Dimension {degree_dim} should be of integer dtype. Received {coeffs[degree_dim].dtype} instead." 1974 ) 1975 max_deg = coeffs[degree_dim].max().item() 1976 coeffs = coeffs.reindex( 1977 {degree_dim: np.arange(max_deg + 1)}, fill_value=0, copy=False 1978 )

ValueError: Dimension degree should be of integer dtype. Received int32 instead. ```

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