Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipython integration: autocompletion #1070

Merged
merged 6 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

## [Unreleased]

## Added
- iPython integration: autocomplete includes axis, variable, and channel names

### Fixed
- `kit.fft`: fixed bug where Fourier coefficients were off by a scalar factor.

Expand Down
7 changes: 7 additions & 0 deletions WrightTools/collection/_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ def __repr__(self):
self.natural_name, self.item_names, "::".join([self.filepath, self.name])
)

def __dir__(self) -> list:
default = object.__dir__(self)
return default + list(self._ipython_key_completions_())

def _ipython_key_completions_(self) -> list:
return list(self.item_names)

def __getitem__(self, key):
if isinstance(key, int):
key = self.item_names[key]
Expand Down
10 changes: 10 additions & 0 deletions WrightTools/data/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ def __repr__(self) -> str:
self.natural_name, str(self.axis_names), "::".join([self.filepath, self.name])
)

def __dir__(self) -> list:
default = object.__dir__(self)
axes = [ax.natural_name for ax in self.axes]
return default + axes + self._ipython_key_completions_()

def _ipython_key_completions_(self) -> list:
channels = [ch.natural_name for ch in self.channels]
variables = [v.natural_name for v in self.variables]
return channels + variables

@property
def axes(self) -> tuple:
return tuple(self._axes)
Expand Down