Cleanup tutorial site - #372
Open
VeckoTheGecko wants to merge 4 commits into
Open
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Contributor
|
@ianhi could you take a look at the why-an-index notebook when you can? |
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?) |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cc @eni-awowale @ianhi