FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Cleanup tutorial site by VeckoTheGecko · Pull Request #372 · xarray-contrib/xarray-tutorial · GitHub

Cleanup tutorial site - #372

Open
VeckoTheGecko wants to merge 4 commits into
mainfrom
update-scipy
Open

Cleanup tutorial site#372
VeckoTheGecko wants to merge 4 commits into
mainfrom
update-scipy

Conversation

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown

Check out this pull request on 

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Copy Markdown
Contributor

@ianhi could you take a look at the why-an-index notebook when you can?

Copy link
Copy Markdown
Contributor Author

Posted #376 .

In order to get the build to pass here (and in main) we should either fix this notebook or exclude it from executing during build.

Unfortunately I've been really struggling to do the latter.

# config.yaml

execute:
  execute_notebooks: 'cache'
+  exclude_patterns: ["intermediate/indexing/why-an-index.ipynb"]

doesn't work despite it being valid config (perhaps its due to us using v1 of jupyterbook which is in maintenance mode?)

VeckoTheGecko commented Aug 18, 2026
edited
Loading

Copy link
Copy Markdown
Contributor Author

Seems like a bug in Jupyterbook - if you have time to look at the original notebook @ianhi that would be great :)

claude suggested a fix of

     def sel(self, labels, method=None, tolerance=None):
-        # labels : {coord_name: query}   e.g. .sel(angle=370) -> {"angle": 370}
-        # return : IndexSelResult({dim_name: [position]})   position = int row into the axis
-        print("sel received:", labels)
-        # the stored labels (one period) are self._index.index.to_numpy()
-        pos = 0  # <- replace: circular distance -> nearest position
-        return IndexSelResult({self._index.dim: [pos]})
+        (name, label), = labels.items()
+        base = self._index.index.to_numpy()
+        q = np.asarray(label, dtype=float)
+        if q.ndim == 0:
+            d = np.abs((q - base + self.period / 2) % self.period - self.period / 2)
+            pos = int(d.argmin())
+            return IndexSelResult({self._index.dim: [pos]})
+        else:
+            positions = []
+            for qi in q:
+                d = np.abs((qi - base + self.period / 2) % self.period - self.period / 2)
+                positions.append(int(d.argmin()))
+            return IndexSelResult({self._index.dim: positions})

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL