- silence java warnings

- renam View -> Imread in Python
This commit is contained in:
w.pomp
2026-08-07 15:26:12 +02:00
parent a0d2359e55
commit b950f4a39d
4 changed files with 82 additions and 87 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ os.environ["RUST_BACKTRACE"] = "full"
os.environ["COLORBT_SHOW_HIDDEN"] = "1"
from . import ndbioimage_rs as rs # noqa
from .ndbioimage_rs import View as Imread
from .ndbioimage_rs import Imread
from .transforms import Transform, Transforms # noqa: F401
try:
+64 -64
View File
@@ -10,53 +10,13 @@ import numpy
import numpy.typing
__all__ = [
"Imread",
"Shape",
"View",
"batch_to_tiff",
"main",
]
class Shape:
@property
def c(self) -> builtins.int: ...
@property
def z(self) -> builtins.int: ...
@property
def t(self) -> builtins.int: ...
@property
def y(self) -> builtins.int: ...
@property
def x(self) -> builtins.int: ...
@property
def axes(self) -> builtins.str: ...
def __new__(
cls,
order: builtins.str,
c: builtins.int = 1,
z: builtins.int = 1,
t: builtins.int = 1,
y: builtins.int = 1,
x: builtins.int = 1,
) -> Shape: ...
def __str__(self) -> builtins.str: ...
def __repr__(self) -> builtins.str: ...
def __getnewargs__(
self,
) -> tuple[
builtins.str,
builtins.int,
builtins.int,
builtins.int,
builtins.int,
builtins.int,
]: ...
def __getitem__(
self, idx: str | int | None | Ellipsis | slice | list[int] | tuple[int]
) -> typing.Optional[int | list[int]]: ...
def __len__(self) -> builtins.int: ...
def to_list(self) -> builtins.list[builtins.int]: ...
class View:
class Imread:
r"""
class to read image files, while taking good care of important metadata,
currently optimized for .czi files, but can open anything that bioformats can handle
@@ -123,7 +83,7 @@ class View:
the number of dimensions in the view
"""
@property
def T(self) -> View: ...
def T(self) -> Imread: ...
@property
def dtype(self) -> numpy.dtype: ...
@property
@@ -174,17 +134,17 @@ class View:
def tube_lens_name(self) -> typing.Optional[builtins.str]: ...
def __new__(
cls,
path: str | pathlib.Path | View | bytes,
path: str | pathlib.Path | Imread | bytes,
dtype: numpy.typing.DTypeLike = None,
axes: builtins.str = "cztyx",
reader: typing.Optional[builtins.str] = None,
) -> View:
) -> Imread:
r"""
new view on a file at path, open series #, open as dtype: (u)int(8/16/32) or float(32/64)
"""
@staticmethod
def get_positions(
path: str | pathlib.Path | View | bytes,
path: str | pathlib.Path | Imread | bytes,
) -> builtins.set[builtins.int]: ...
@staticmethod
def kill_vm() -> None:
@@ -198,17 +158,17 @@ class View:
drift: builtins.bool = False,
file: typing.Optional[typing.Any] = None,
bead_files: typing.Optional[typing.Any] = None,
) -> View: ...
) -> Imread: ...
def squeeze(self) -> numpy.ndarray | int | float: ...
def close(self) -> None:
r"""
close the file: does nothing as this is handled automatically
"""
def as_type(self, dtype: numpy.typing.DTypeLike) -> View:
def as_type(self, dtype: numpy.typing.DTypeLike) -> Imread:
r"""
change the data type of the view: (u)int(8/16/32) or float(32/64)
"""
def astype(self, dtype: numpy.typing.DTypeLike) -> View:
def astype(self, dtype: numpy.typing.DTypeLike) -> Imread:
r"""
change the data type of the view: (u)int(8/16/32) or float(32/64)
"""
@@ -256,7 +216,7 @@ class View:
def __pos__(self) -> typing.Any: ...
def __abs__(self) -> typing.Any: ...
def __invert__(self) -> typing.Any: ...
def __enter__(self) -> View: ...
def __enter__(self) -> Imread: ...
def __exit__(
self,
exc_type: typing.Optional[typing.Any] = None,
@@ -264,10 +224,10 @@ class View:
exc_tb: typing.Optional[typing.Any] = None,
) -> None: ...
def __getnewargs__(self) -> tuple[builtins.list[builtins.int]]: ...
def __copy__(self) -> View: ...
def __deepcopy__(self) -> View: ...
def copy(self) -> View: ...
def __iter__(self) -> View: ...
def __copy__(self) -> Imread: ...
def __deepcopy__(self) -> Imread: ...
def copy(self) -> Imread: ...
def __iter__(self) -> Imread: ...
def __next__(self) -> typing.Optional[typing.Any]: ...
def __len__(self) -> builtins.int: ...
def __repr__(self) -> builtins.str: ...
@@ -285,13 +245,13 @@ class View:
r"""
find the position of an axis
"""
def swap_axes(self, ax0: int | str, ax1: int | str) -> View:
def swap_axes(self, ax0: int | str, ax1: int | str) -> Imread:
r"""
swap two axes
"""
def transpose(
self, axes: typing.Optional[typing.Sequence[int | str]] = None
) -> View:
) -> Imread:
r"""
permute the order of the axes
"""
@@ -317,14 +277,14 @@ class View:
"""
@staticmethod
def get_available_series(
path: str | pathlib.Path | View, reader: typing.Optional[builtins.str] = None
path: str | pathlib.Path | Imread, reader: typing.Optional[builtins.str] = None
) -> builtins.set[builtins.int]:
r"""
get all series contained in the file
"""
@staticmethod
def get_available_positions(
path: str | pathlib.Path | View,
path: str | pathlib.Path | Imread,
series: builtins.int,
reader: typing.Optional[builtins.str] = None,
) -> builtins.set[builtins.int]:
@@ -355,13 +315,13 @@ class View:
"""
def __pow__(
self,
other: View | numpy.typing.NDArray | int | float,
other: Imread | numpy.typing.NDArray | int | float,
mod: typing.Any = None,
/,
) -> numpy.typing.NDArray: ...
def __rpow__(
self,
other: View | numpy.typing.NDArray | int | float,
other: Imread | numpy.typing.NDArray | int | float,
mod: typing.Any = None,
/,
) -> numpy.typing.NDArray: ...
@@ -373,7 +333,7 @@ class View:
keepdims: bool = False,
initial: int | float = None,
where: bool = True,
) -> View | numpy.typing.NDArray | int | float:
) -> Imread | numpy.typing.NDArray | int | float:
r"""
Return the maximum along a given axis. Arguments beyond axis are not implemented
"""
@@ -385,7 +345,7 @@ class View:
keepdims: bool = False,
initial: int | float = None,
where: bool = True,
) -> View | numpy.typing.NDArray | int | float:
) -> Imread | numpy.typing.NDArray | int | float:
r"""
Return the minimum along a given axis. Arguments beyond axis are not implemented
"""
@@ -395,7 +355,7 @@ class View:
dtype: numpy.typing.DTypeLike = None,
out: typing.Any = None,
keepdims: bool = False,
) -> View | numpy.typing.NDArray | int | float:
) -> Imread | numpy.typing.NDArray | int | float:
r"""
Return the mean along a given axis. Arguments beyond axis are not implemented
"""
@@ -407,11 +367,51 @@ class View:
keepdims: bool = False,
initial: int | float = None,
where: bool = True,
) -> View | numpy.typing.NDArray | int | float:
) -> Imread | numpy.typing.NDArray | int | float:
r"""
Return the sum along a given axis. Arguments beyond axis are not implemented
"""
class Shape:
@property
def c(self) -> builtins.int: ...
@property
def z(self) -> builtins.int: ...
@property
def t(self) -> builtins.int: ...
@property
def y(self) -> builtins.int: ...
@property
def x(self) -> builtins.int: ...
@property
def axes(self) -> builtins.str: ...
def __new__(
cls,
order: builtins.str,
c: builtins.int = 1,
z: builtins.int = 1,
t: builtins.int = 1,
y: builtins.int = 1,
x: builtins.int = 1,
) -> Shape: ...
def __str__(self) -> builtins.str: ...
def __repr__(self) -> builtins.str: ...
def __getnewargs__(
self,
) -> tuple[
builtins.str,
builtins.int,
builtins.int,
builtins.int,
builtins.int,
builtins.int,
]: ...
def __getitem__(
self, idx: str | int | None | Ellipsis | slice | list[int] | tuple[int]
) -> typing.Optional[int | list[int]]: ...
def __len__(self) -> builtins.int: ...
def to_list(self) -> builtins.list[builtins.int]: ...
def batch_to_tiff(
files_in: typing.Sequence[builtins.str | os.PathLike | pathlib.Path],
files_out: typing.Sequence[builtins.str | os.PathLike | pathlib.Path],
+13 -13
View File
@@ -80,7 +80,7 @@ impl From<crate::error::Error> for PyErr {
#[pyclass(
subclass,
from_py_object,
name = "View",
name = "Imread",
module = "ndbioimage.ndbioimage_rs"
)]
#[derive(Clone, Debug, Serialize, Deserialize)]
@@ -176,7 +176,7 @@ impl PyView {
fn new<'py>(
py: Python<'py>,
#[gen_stub(
override_type(type_repr="str | pathlib.Path | View | bytes", imports=("pathlib"))
override_type(type_repr="str | pathlib.Path | Imread | bytes", imports=("pathlib"))
)]
path: Bound<'py, PyAny>,
#[gen_stub(override_type(type_repr = "numpy.typing.DTypeLike", imports=("numpy", "numpy.typing")
@@ -233,7 +233,7 @@ impl PyView {
fn get_positions<'py>(
py: Python,
#[gen_stub(
override_type(type_repr="str | pathlib.Path | View | bytes", imports=("pathlib"))
override_type(type_repr="str | pathlib.Path | Imread | bytes", imports=("pathlib"))
)]
path: Bound<'py, PyAny>,
) -> PyResult<HashSet<usize>> {
@@ -761,7 +761,7 @@ impl PyView {
) -> PyResult<Bound<'py, PyAny>> {
if r#mod.is_some() {
return Err(PyNotImplementedError::new_err(
"cannot use pow or ** on View with mod != None",
"cannot use pow or ** on Imread with mod != None",
));
}
let np = PyModule::import(py, "numpy")?;
@@ -779,7 +779,7 @@ impl PyView {
) -> PyResult<Bound<'py, PyAny>> {
if r#mod.is_some() {
return Err(PyNotImplementedError::new_err(
"cannot use pow or ** on View with mod != None",
"cannot use pow or ** on Imread with mod != None",
));
}
let np = PyModule::import(py, "numpy")?;
@@ -1681,7 +1681,7 @@ impl PyView {
#[pyo3(signature = (path, reader = None))]
fn get_available_series<'py>(
py: Python<'py>,
#[gen_stub(override_type(type_repr="str | pathlib.Path | View", imports=("pathlib")))]
#[gen_stub(override_type(type_repr="str | pathlib.Path | Imread", imports=("pathlib")))]
path: Bound<'py, PyAny>,
reader: Option<&str>,
) -> PyResult<HashSet<usize>> {
@@ -1707,7 +1707,7 @@ impl PyView {
#[pyo3(signature = (path, series, reader = None))]
fn get_available_positions<'py>(
py: Python<'py>,
#[gen_stub(override_type(type_repr="str | pathlib.Path | View", imports=("pathlib")))]
#[gen_stub(override_type(type_repr="str | pathlib.Path | Imread", imports=("pathlib")))]
path: Bound<'py, PyAny>,
series: usize,
reader: Option<&str>,
@@ -1810,19 +1810,19 @@ submit! {
import numpy.typing
class PyView:
def __pow__(other: View | numpy.typing.NDArray | int | float, mod: typing.Any = None, /) -> numpy.typing.NDArray: ...
def __rpow__(other: View | numpy.typing.NDArray | int | float, mod: typing.Any = None, /) -> numpy.typing.NDArray: ...
def __pow__(other: Imread | numpy.typing.NDArray | int | float, mod: typing.Any = None, /) -> numpy.typing.NDArray: ...
def __rpow__(other: Imread | numpy.typing.NDArray | int | float, mod: typing.Any = None, /) -> numpy.typing.NDArray: ...
def max(axis: int | str = None, dtype: numpy.typing.DTypeLike = None, out: typing.Any = None, keepdims: bool = False, initial: int | float = None, where: bool = True) -> View | numpy.typing.NDArray | int | float:
def max(axis: int | str = None, dtype: numpy.typing.DTypeLike = None, out: typing.Any = None, keepdims: bool = False, initial: int | float = None, where: bool = True) -> Imread | numpy.typing.NDArray | int | float:
""" Return the maximum along a given axis. Arguments beyond axis are not implemented """
def min(axis: int | str = None, dtype: numpy.typing.DTypeLike = None, out: typing.Any = None, keepdims: bool = False, initial: int | float = None, where: bool = True) -> View | numpy.typing.NDArray | int | float:
def min(axis: int | str = None, dtype: numpy.typing.DTypeLike = None, out: typing.Any = None, keepdims: bool = False, initial: int | float = None, where: bool = True) -> Imread | numpy.typing.NDArray | int | float:
""" Return the minimum along a given axis. Arguments beyond axis are not implemented """
def mean(axis: int | str = None, dtype: numpy.typing.DTypeLike = None, out: typing.Any = None, keepdims: bool = False) -> View | numpy.typing.NDArray | int | float:
def mean(axis: int | str = None, dtype: numpy.typing.DTypeLike = None, out: typing.Any = None, keepdims: bool = False) -> Imread | numpy.typing.NDArray | int | float:
""" Return the mean along a given axis. Arguments beyond axis are not implemented """
def sum(axis: int | str = None, dtype: numpy.typing.DTypeLike = None, out: typing.Any = None, keepdims: bool = False, initial: int | float = None, where: bool = True) -> View | numpy.typing.NDArray | int | float:
def sum(axis: int | str = None, dtype: numpy.typing.DTypeLike = None, out: typing.Any = None, keepdims: bool = False, initial: int | float = None, where: bool = True) -> Imread | numpy.typing.NDArray | int | float:
""" Return the sum along a given axis. Arguments beyond axis are not implemented """
"#
}
+4 -9
View File
@@ -108,16 +108,11 @@ fn jvm() -> Rc<Jvm> {
let j = JvmBuilder::new()
.skip_setting_native_lib()
.with_base_path(class_path.to_str().unwrap())
.java_opt(JavaOpt::new("-XX:+IgnoreUnrecognizedVMOptions"))
.java_opt(JavaOpt::new("--enable-native-access=ALL-UNNAMED"))
.build();
let j = match j {
Ok(j) => j,
Err(_) => JvmBuilder::new()
.skip_setting_native_lib()
.with_base_path(class_path.to_str().unwrap())
.build()
.expect("Failed to build JVM"),
};
.java_opt(JavaOpt::new("--sun-misc-unsafe-memory-access=allow"))
.build()
.expect("Failed to build JVM");
if let Ok(e) = InvocationArg::try_from("ERROR") {
let _ = j.invoke_static(
"loci.common.DebugTools",