Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor: copy is notebook function from hubble sdk
Signed-off-by: anna-charlotte <[email protected]>
  • Loading branch information
anna-charlotte committed Feb 15, 2023
commit 05d8461b94ad1074392a0d7fa19a975ddf783045
2 changes: 1 addition & 1 deletion docarray/typing/url/url_3d/point_cloud_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from docarray.typing.tensor.abstract_tensor import AbstractTensor
from docarray.typing.tensor.ndarray import NdArray
from docarray.typing.url.url_3d.url_3d import Url3D
from docarray.utils.misc import is_notebook

T = TypeVar('T', bound='PointCloud3DUrl')

Expand Down Expand Up @@ -82,7 +83,6 @@ def _display_point_cloud(
shape (n_points, 3) or (n_points, 4).
"""
import trimesh
from hubble.utils.notebook import is_notebook
from IPython.display import display

if colors is None:
Expand Down
26 changes: 26 additions & 0 deletions docarray/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,29 @@ def is_torch_available():

def is_tf_available():
return tf_imported


def is_notebook() -> bool:
"""
Check if we're running in a Jupyter notebook, using magic command
`get_ipython` that only available in Jupyter.

:return: True if run in a Jupyter notebook else False.
"""

try:
shell = get_ipython().__class__.__name__ # noqa: F821
except NameError:
return False

if shell == 'ZMQInteractiveShell':
return True

elif shell == 'Shell':
return True

elif shell == 'TerminalInteractiveShell':
return False

else:
return False