-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(transform-io): add generated python
- Loading branch information
Showing
95 changed files
with
3,111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
test/ | ||
emscripten-build/ | ||
python/ | ||
wasi-build/ | ||
typescript/dist | ||
typescript/src/version.ts | ||
|
23 changes: 23 additions & 0 deletions
23
packages/transform-io/python/itkwasm-transform-io-emscripten/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# itkwasm-transform-io-emscripten | ||
|
||
[![PyPI version](https://badge.fury.io/py/itkwasm-transform-io-emscripten.svg)](https://badge.fury.io/py/itkwasm-transform-io-emscripten) | ||
|
||
Input and output for scientific and medical coordinate transform file formats. Emscripten implementation. | ||
|
||
This package provides the Emscripten WebAssembly implementation. It is usually not called directly. Please use the [`itkwasm-transform-io`](https://pypi.org/project/itkwasm-transform-io/) instead. | ||
|
||
|
||
## Installation | ||
|
||
```sh | ||
import micropip | ||
await micropip.install('itkwasm-transform-io-emscripten') | ||
``` | ||
|
||
## Development | ||
|
||
```sh | ||
pip install hatch | ||
hatch run download-pyodide | ||
hatch run test | ||
``` |
18 changes: 18 additions & 0 deletions
18
...orm-io/python/itkwasm-transform-io-emscripten/itkwasm_transform_io_emscripten/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated file. To retain edits, remove this comment. | ||
|
||
"""itkwasm-transform-io-emscripten: Input and output for scientific and medical coordinate transform file formats. Emscripten implementation.""" | ||
|
||
from .hdf5_read_transform_async import hdf5_read_transform_async | ||
from .hdf5_write_transform_async import hdf5_write_transform_async | ||
from .mat_read_transform_async import mat_read_transform_async | ||
from .mat_write_transform_async import mat_write_transform_async | ||
from .mnc_read_transform_async import mnc_read_transform_async | ||
from .mnc_write_transform_async import mnc_write_transform_async | ||
from .txt_read_transform_async import txt_read_transform_async | ||
from .txt_write_transform_async import txt_write_transform_async | ||
from .wasm_read_transform_async import wasm_read_transform_async | ||
from .wasm_write_transform_async import wasm_write_transform_async | ||
from .wasm_zstd_read_transform_async import wasm_zstd_read_transform_async | ||
from .wasm_zstd_write_transform_async import wasm_zstd_write_transform_async | ||
|
||
from ._version import __version__ |
1 change: 1 addition & 0 deletions
1
...orm-io/python/itkwasm-transform-io-emscripten/itkwasm_transform_io_emscripten/_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.1.0" |
60 changes: 60 additions & 0 deletions
60
...wasm-transform-io-emscripten/itkwasm_transform_io_emscripten/hdf5_read_transform_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Generated file. To retain edits, remove this comment. | ||
|
||
from pathlib import Path | ||
import os | ||
from typing import Dict, Tuple, Optional, List, Any | ||
|
||
from .js_package import js_package | ||
|
||
from itkwasm.pyodide import ( | ||
to_js, | ||
to_py, | ||
js_resources | ||
) | ||
from itkwasm import ( | ||
InterfaceTypes, | ||
BinaryFile, | ||
Transform, | ||
) | ||
|
||
async def hdf5_read_transform_async( | ||
serialized_transform: os.PathLike, | ||
float_parameters: bool = False, | ||
) -> Tuple[Any, Transform]: | ||
"""Read an transform file format and convert it to the ITK-Wasm transform file format | ||
:param serialized_transform: Input transform serialized in the file format | ||
:type serialized_transform: os.PathLike | ||
:param float_parameters: Use float for the parameter value type. The default is double. | ||
:type float_parameters: bool | ||
:return: Whether the input could be read. If false, the output transform is not valid. | ||
:rtype: Any | ||
:return: Output transform | ||
:rtype: Transform | ||
""" | ||
js_module = await js_package.js_module | ||
web_worker = js_resources.web_worker | ||
|
||
kwargs = {} | ||
if float_parameters: | ||
kwargs["floatParameters"] = to_js(float_parameters) | ||
|
||
outputs = await js_module.hdf5ReadTransform(to_js(BinaryFile(serialized_transform)), webWorker=web_worker, noCopy=True, **kwargs) | ||
|
||
output_web_worker = None | ||
output_list = [] | ||
outputs_object_map = outputs.as_object_map() | ||
for output_name in outputs.object_keys(): | ||
if output_name == 'webWorker': | ||
output_web_worker = outputs_object_map[output_name] | ||
else: | ||
output_list.append(to_py(outputs_object_map[output_name])) | ||
|
||
js_resources.web_worker = output_web_worker | ||
|
||
if len(output_list) == 1: | ||
return output_list[0] | ||
return tuple(output_list) |
67 changes: 67 additions & 0 deletions
67
...asm-transform-io-emscripten/itkwasm_transform_io_emscripten/hdf5_write_transform_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Generated file. To retain edits, remove this comment. | ||
|
||
from pathlib import Path | ||
import os | ||
from typing import Dict, Tuple, Optional, List, Any | ||
|
||
from .js_package import js_package | ||
|
||
from itkwasm.pyodide import ( | ||
to_js, | ||
to_py, | ||
js_resources | ||
) | ||
from itkwasm import ( | ||
InterfaceTypes, | ||
Transform, | ||
BinaryFile, | ||
) | ||
|
||
async def hdf5_write_transform_async( | ||
transform: Transform, | ||
serialized_transform: str, | ||
float_parameters: bool = False, | ||
use_compression: bool = False, | ||
) -> Tuple[Any]: | ||
"""Write an ITK-Wasm transform file format converted to a transform file format | ||
:param transform: Input transform | ||
:type transform: Transform | ||
:param serialized_transform: Output transform serialized in the file format. | ||
:type serialized_transform: str | ||
:param float_parameters: Use float for the parameter value type. The default is double. | ||
:type float_parameters: bool | ||
:param use_compression: Use compression in the written file | ||
:type use_compression: bool | ||
:return: Whether the input could be written. If false, the output transform is not valid. | ||
:rtype: Any | ||
""" | ||
js_module = await js_package.js_module | ||
web_worker = js_resources.web_worker | ||
|
||
kwargs = {} | ||
if float_parameters: | ||
kwargs["floatParameters"] = to_js(float_parameters) | ||
if use_compression: | ||
kwargs["useCompression"] = to_js(use_compression) | ||
|
||
outputs = await js_module.hdf5WriteTransform(to_js(transform), to_js(serialized_transform), webWorker=web_worker, noCopy=True, **kwargs) | ||
|
||
output_web_worker = None | ||
output_list = [] | ||
outputs_object_map = outputs.as_object_map() | ||
for output_name in outputs.object_keys(): | ||
if output_name == 'webWorker': | ||
output_web_worker = outputs_object_map[output_name] | ||
else: | ||
output_list.append(to_py(outputs_object_map[output_name])) | ||
|
||
js_resources.web_worker = output_web_worker | ||
|
||
if len(output_list) == 1: | ||
return output_list[0] | ||
return tuple(output_list) |
8 changes: 8 additions & 0 deletions
8
...m-io/python/itkwasm-transform-io-emscripten/itkwasm_transform_io_emscripten/js_package.py
Large diffs are not rendered by default.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
...kwasm-transform-io-emscripten/itkwasm_transform_io_emscripten/mat_read_transform_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Generated file. To retain edits, remove this comment. | ||
|
||
from pathlib import Path | ||
import os | ||
from typing import Dict, Tuple, Optional, List, Any | ||
|
||
from .js_package import js_package | ||
|
||
from itkwasm.pyodide import ( | ||
to_js, | ||
to_py, | ||
js_resources | ||
) | ||
from itkwasm import ( | ||
InterfaceTypes, | ||
BinaryFile, | ||
Transform, | ||
) | ||
|
||
async def mat_read_transform_async( | ||
serialized_transform: os.PathLike, | ||
float_parameters: bool = False, | ||
) -> Tuple[Any, Transform]: | ||
"""Read an transform file format and convert it to the ITK-Wasm transform file format | ||
:param serialized_transform: Input transform serialized in the file format | ||
:type serialized_transform: os.PathLike | ||
:param float_parameters: Use float for the parameter value type. The default is double. | ||
:type float_parameters: bool | ||
:return: Whether the input could be read. If false, the output transform is not valid. | ||
:rtype: Any | ||
:return: Output transform | ||
:rtype: Transform | ||
""" | ||
js_module = await js_package.js_module | ||
web_worker = js_resources.web_worker | ||
|
||
kwargs = {} | ||
if float_parameters: | ||
kwargs["floatParameters"] = to_js(float_parameters) | ||
|
||
outputs = await js_module.matReadTransform(to_js(BinaryFile(serialized_transform)), webWorker=web_worker, noCopy=True, **kwargs) | ||
|
||
output_web_worker = None | ||
output_list = [] | ||
outputs_object_map = outputs.as_object_map() | ||
for output_name in outputs.object_keys(): | ||
if output_name == 'webWorker': | ||
output_web_worker = outputs_object_map[output_name] | ||
else: | ||
output_list.append(to_py(outputs_object_map[output_name])) | ||
|
||
js_resources.web_worker = output_web_worker | ||
|
||
if len(output_list) == 1: | ||
return output_list[0] | ||
return tuple(output_list) |
67 changes: 67 additions & 0 deletions
67
...wasm-transform-io-emscripten/itkwasm_transform_io_emscripten/mat_write_transform_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Generated file. To retain edits, remove this comment. | ||
|
||
from pathlib import Path | ||
import os | ||
from typing import Dict, Tuple, Optional, List, Any | ||
|
||
from .js_package import js_package | ||
|
||
from itkwasm.pyodide import ( | ||
to_js, | ||
to_py, | ||
js_resources | ||
) | ||
from itkwasm import ( | ||
InterfaceTypes, | ||
Transform, | ||
BinaryFile, | ||
) | ||
|
||
async def mat_write_transform_async( | ||
transform: Transform, | ||
serialized_transform: str, | ||
float_parameters: bool = False, | ||
use_compression: bool = False, | ||
) -> Tuple[Any]: | ||
"""Write an ITK-Wasm transform file format converted to a transform file format | ||
:param transform: Input transform | ||
:type transform: Transform | ||
:param serialized_transform: Output transform serialized in the file format. | ||
:type serialized_transform: str | ||
:param float_parameters: Use float for the parameter value type. The default is double. | ||
:type float_parameters: bool | ||
:param use_compression: Use compression in the written file | ||
:type use_compression: bool | ||
:return: Whether the input could be written. If false, the output transform is not valid. | ||
:rtype: Any | ||
""" | ||
js_module = await js_package.js_module | ||
web_worker = js_resources.web_worker | ||
|
||
kwargs = {} | ||
if float_parameters: | ||
kwargs["floatParameters"] = to_js(float_parameters) | ||
if use_compression: | ||
kwargs["useCompression"] = to_js(use_compression) | ||
|
||
outputs = await js_module.matWriteTransform(to_js(transform), to_js(serialized_transform), webWorker=web_worker, noCopy=True, **kwargs) | ||
|
||
output_web_worker = None | ||
output_list = [] | ||
outputs_object_map = outputs.as_object_map() | ||
for output_name in outputs.object_keys(): | ||
if output_name == 'webWorker': | ||
output_web_worker = outputs_object_map[output_name] | ||
else: | ||
output_list.append(to_py(outputs_object_map[output_name])) | ||
|
||
js_resources.web_worker = output_web_worker | ||
|
||
if len(output_list) == 1: | ||
return output_list[0] | ||
return tuple(output_list) |
60 changes: 60 additions & 0 deletions
60
...kwasm-transform-io-emscripten/itkwasm_transform_io_emscripten/mnc_read_transform_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Generated file. To retain edits, remove this comment. | ||
|
||
from pathlib import Path | ||
import os | ||
from typing import Dict, Tuple, Optional, List, Any | ||
|
||
from .js_package import js_package | ||
|
||
from itkwasm.pyodide import ( | ||
to_js, | ||
to_py, | ||
js_resources | ||
) | ||
from itkwasm import ( | ||
InterfaceTypes, | ||
BinaryFile, | ||
Transform, | ||
) | ||
|
||
async def mnc_read_transform_async( | ||
serialized_transform: os.PathLike, | ||
float_parameters: bool = False, | ||
) -> Tuple[Any, Transform]: | ||
"""Read an transform file format and convert it to the ITK-Wasm transform file format | ||
:param serialized_transform: Input transform serialized in the file format | ||
:type serialized_transform: os.PathLike | ||
:param float_parameters: Use float for the parameter value type. The default is double. | ||
:type float_parameters: bool | ||
:return: Whether the input could be read. If false, the output transform is not valid. | ||
:rtype: Any | ||
:return: Output transform | ||
:rtype: Transform | ||
""" | ||
js_module = await js_package.js_module | ||
web_worker = js_resources.web_worker | ||
|
||
kwargs = {} | ||
if float_parameters: | ||
kwargs["floatParameters"] = to_js(float_parameters) | ||
|
||
outputs = await js_module.mncReadTransform(to_js(BinaryFile(serialized_transform)), webWorker=web_worker, noCopy=True, **kwargs) | ||
|
||
output_web_worker = None | ||
output_list = [] | ||
outputs_object_map = outputs.as_object_map() | ||
for output_name in outputs.object_keys(): | ||
if output_name == 'webWorker': | ||
output_web_worker = outputs_object_map[output_name] | ||
else: | ||
output_list.append(to_py(outputs_object_map[output_name])) | ||
|
||
js_resources.web_worker = output_web_worker | ||
|
||
if len(output_list) == 1: | ||
return output_list[0] | ||
return tuple(output_list) |
Oops, something went wrong.