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

DRAFT: proof of principle bringing microvis model to ndv #113

Closed
wants to merge 12 commits into from
Closed
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
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ disallow_any_generics = false
disallow_subclassing_any = false
show_error_codes = true
pretty = true
# sometimes experiencing a pydantic mypy plugin bug
# dealing with recursive models, like ndv.models._scene.nodes.Node
plugins = ["pydantic.mypy"]

[[tool.mypy.overrides]]
Expand Down
25 changes: 25 additions & 0 deletions src/ndv/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from enum import Enum, IntFlag, auto
from typing import TYPE_CHECKING, Annotated, Any, NamedTuple, cast

import numpy.typing as npt
from pydantic import PlainSerializer, PlainValidator
from typing_extensions import TypeAlias

Expand Down Expand Up @@ -107,3 +108,27 @@
CursorType.BDIAG_ARROW: Qt.CursorShape.SizeBDiagCursor,
CursorType.FDIAG_ARROW: Qt.CursorShape.SizeFDiagCursor,
}[self]


class CameraType(str, Enum):
"""Camera type."""

ARCBALL = "arcball"
PANZOOM = "panzoom"

def __str__(self) -> str:
return self.value

Check warning on line 120 in src/ndv/_types.py

View check run for this annotation

Codecov / codecov/patch

src/ndv/_types.py#L120

Added line #L120 was not covered by tests


ArrayLike: TypeAlias = npt.NDArray


class ImageInterpolation(str, Enum):
"""Image interpolation options."""

LINEAR = "linear"
NEAREST = "nearest"
BICUBIC = "bicubic"

def __str__(self) -> str:
return self.value

Check warning on line 134 in src/ndv/_types.py

View check run for this annotation

Codecov / codecov/patch

src/ndv/_types.py#L134

Added line #L134 was not covered by tests
3 changes: 2 additions & 1 deletion src/ndv/controllers/_array_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def __init__(
stacklevel=2,
)
self._data_model = _ArrayDataDisplayModel(
data_wrapper=data, display=display_model or ArrayDisplayModel(**kwargs)
data_wrapper=data,
display=display_model or ArrayDisplayModel(**kwargs),
)

app = _app.gui_frontend()
Expand Down
2 changes: 2 additions & 0 deletions src/ndv/models/_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ def _new(*args: Any, **kwargs: Any) -> ValidatedEventedDict[_KT, _VT]:

def _get_schema(hint: Any, handler: GetCoreSchemaHandler) -> core_schema.CoreSchema:
# check if the hint already has a core schema attached to it.
# this helps to avoid `Definitions error: definition `___` was never filled`
# for recursive types.
if hasattr(hint, "__pydantic_core_schema__"):
return cast("core_schema.CoreSchema", hint.__pydantic_core_schema__)
# otherwise, call the handler to get the core schema.
Expand Down
14 changes: 14 additions & 0 deletions src/ndv/models/_scene/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from ._transform import Transform
from .canvas import Canvas
from .nodes import Camera, Image, Node, Scene
from .view import View

Check warning on line 4 in src/ndv/models/_scene/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/ndv/models/_scene/__init__.py#L1-L4

Added lines #L1 - L4 were not covered by tests

__all__ = [

Check warning on line 6 in src/ndv/models/_scene/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/ndv/models/_scene/__init__.py#L6

Added line #L6 was not covered by tests
"Camera",
"Canvas",
"Image",
"Node",
"Scene",
"Transform",
"View",
]
Loading
Loading