Skip to content

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

@VeckoTheGecko

Copy link
Copy Markdown
Contributor

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@eni-awowale

Copy link
Copy Markdown
Contributor

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

@VeckoTheGecko

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

VeckoTheGecko commented Aug 18, 2026

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})

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