Skip to content

Commit

Permalink
adaptations to numpy2
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldorman committed Sep 9, 2024
1 parent 4f124ea commit b4c5fc1
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 6 deletions.
4 changes: 0 additions & 4 deletions 03-spatial-operations.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -970,10 +970,6 @@ elev.astype(int)**2

Now we get correct results.

::: callout-note
**numpy** has the special data types `np.int_` and `np.float_`, which refer to "default" `int` and `float` data types. These are platform dependent, but typically resolve to `np.int64` and `np.float64`. Furthermore, the standard Python types `int` and `float` refer to those same two **numpy** types, respectively. Therefore, for example, either of the three objects `np.int64`, `np.int_` and `int` can be passed to `.astype` in the above example, with identical result. We've used the shortest one, `int`.
:::

@fig-raster-local-operations demonstrates the result of the last two examples (`elev+elev` and `elev.astype(int)**2`), and two other ones (`np.log(elev)` and `elev>5`).

```{python}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b4c5fc1

Please sign in to comment.