Skip to content

Commit

Permalink
update repr, str, and dir
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyAndroulakis committed Apr 13, 2023
1 parent 25bf0fa commit 1163432
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 34 deletions.
30 changes: 4 additions & 26 deletions examples/introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -18,36 +18,14 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0cb78531b52b44b18079b3b1e7e3d006",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Niivue(back_color=[0.0, 0.0, 0.0, 1.0], clip_plane_color=[1.0, 1.0, 1.0, 0.5], crosshair_color=[0.0, 1.0, 0.0,…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"nv = ipyniivue.Niivue(crosshair_color=[0,1,0,1])\n",
"nv.add_volume('https://niivue.github.io/niivue/images/mni152.nii.gz')\n",
"nv"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -66,7 +44,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.11.3"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
2 changes: 1 addition & 1 deletion ipyniivue/_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"""

module_name = "ipyniivue"
module_version = "^1.0.1"
module_version = "^1.0.2"
18 changes: 14 additions & 4 deletions ipyniivue/niivue.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ def __init__(self, *args, **kwargs):
super(Niivue, self).__init__(*args, **kwargs)
self.on_msg(self._handle_frontend_msg)

def __str__(self):
return f'Niivue {self._model_id}'

def __repr__(self):
return f'ipyniivue.{super().__repr__()}'

def __dir__(self):
default = super().__dir__()
return [d for d in default if d not in dir(DOMWidget)]

def _handle_frontend_msg(self, _, content, buffers):
event_data = content.get('event', [None])
if event_data[0] == 'customCodeResult':
Expand Down Expand Up @@ -979,7 +989,7 @@ def get_frame_4D(self, ID):
Parameters:
-----------
ID: str
the ID of the 4D image
the ID of the 4D image
Returns:
--------
Expand Down Expand Up @@ -1008,7 +1018,7 @@ def get_overlay_index_by_ID(self, ID):
Parameters:
-----------
ID: str
the ID of the overlay
the ID of the overlay
Returns:
--------
Expand All @@ -1033,7 +1043,7 @@ def get_volume_index_by_ID(self, ID):
Parameters:
-----------
ID: str
the ID of the volume
the ID of the volume
Returns:
--------
Expand All @@ -1048,7 +1058,7 @@ def is_mesh_ext(self, url):
Parameters:
-----------
url: str
the url or filepath of the mesh
the url or filepath of the mesh
Returns:
--------
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ipyniivue",
"version": "1.0.1",
"version": "1.0.2",
"description": "Jupyter-Niivue bridge",
"keywords": [
"jupyter",
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies = [
"ipywidgets>=7.0.0",
"jupyter_ui_poll>=0.2.2"
]
version = "1.0.1"
version = "1.0.2"

[project.optional-dependencies]
docs = [
Expand Down Expand Up @@ -105,7 +105,7 @@ file = [
]

[tool.tbump.version]
current = "1.0.1"
current = "1.0.2"
regex = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)((?P<channel>a|b|rc|.dev)(?P<release>\\d+))?"

[tool.tbump.git]
Expand Down

0 comments on commit 1163432

Please sign in to comment.