-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update main branch See merge request ricos/machine_learning/phlower!46
- Loading branch information
Showing
178 changed files
with
10,505 additions
and
1,262 deletions.
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
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
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,6 @@ | ||
[tool.poetry] | ||
name = "phlower" | ||
version = "0.1.1" | ||
version = "0.2.0" | ||
description = "This is a Python package which helps you handle GNN especially for physics problems." | ||
authors = ["sakamoto <[email protected]>"] | ||
readme = "README.md" | ||
|
@@ -22,13 +22,14 @@ pipe = "^2.2" | |
pyvista = "^0.43.10" | ||
tqdm = "^4.66.4" | ||
pandas = "^2.2.2" | ||
einops = "^0.8.0" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "^8.0.2" | ||
mypy = "^1.8.0" | ||
pytest-cov = "^4.1.0" | ||
ruff = "^0.4.10" | ||
hypothesis = "^6.108.2" | ||
hypothesis = {extras = ["numpy"], version = "^6.115.3"} | ||
|
||
|
||
[tool.poetry.group.docs.dependencies] | ||
|
@@ -44,6 +45,7 @@ addopts = [ | |
] | ||
markers = [ | ||
"e2e_test: marks tests as End-to-End test (deselect with '-m not e2e_test')", | ||
"gpu_test: marks tests as test using GPUs (deselect with '-m not gpu_test')", | ||
"need_multicore: marks tests which need multiple cores" | ||
] | ||
|
||
|
@@ -52,7 +54,7 @@ requires = ["poetry-core"] | |
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.ruff] | ||
src = ["src", "tests"] | ||
include = ["pyproject.toml", "src/**/*.py", "tests/**/*.py"] | ||
|
||
# Exclude a variety of commonly ignored directories. | ||
exclude = [ | ||
|
@@ -103,8 +105,9 @@ select = [ | |
"B", # flake8-bugbear | ||
"C4", # flake8-comprehensions | ||
"UP", # pyupgrade | ||
"ANN", # flake8-annotations | ||
] | ||
ignore = [] | ||
ignore = ["ANN003", "ANN101", "ANN102", "ANN204"] | ||
|
||
# Allow fix for all enabled rules (when `--fix`) is provided. | ||
fixable = ["ALL"] | ||
|
@@ -113,8 +116,12 @@ unfixable = [] | |
# Allow unused variables when underscore-prefixed. | ||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" | ||
|
||
[tool.ruff.lint.flake8-annotations] | ||
suppress-none-returning = true | ||
|
||
[tool.ruff.lint.per-file-ignores] | ||
"__init__.py" = ["F401"] | ||
"src/phlower/_base/**/*.py" = ["ANN401"] | ||
|
||
[tool.ruff.format] | ||
# Like Black, use double quotes for strings. | ||
|
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
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
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
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
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
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,19 +1,43 @@ | ||
# flake8: noqa | ||
from logging import getLogger | ||
from typing import get_args | ||
|
||
import numpy as np | ||
|
||
from phlower._base import PhysicalDimensions | ||
from phlower._base.array import dense, sparse | ||
from phlower._base.array._interface_wrapper import IPhlowerArray | ||
from phlower.utils.typing import ArrayDataType, DenseArrayType, SparseArrayType | ||
|
||
_logger = getLogger(__name__) | ||
|
||
|
||
def phlower_array(data: ArrayDataType | IPhlowerArray) -> IPhlowerArray: | ||
def phlower_array( | ||
data: ArrayDataType | IPhlowerArray, | ||
is_time_series: bool = False, | ||
is_voxel: bool = False, | ||
dimensions: PhysicalDimensions | None = None, | ||
) -> IPhlowerArray: | ||
if isinstance(data, IPhlowerArray): | ||
_logger.warning( | ||
"phlower_array function is called for PhlowerArray." | ||
"time_series and is_voxel in arguments are ignored." | ||
) | ||
return data | ||
|
||
if isinstance(data, DenseArrayType): | ||
return dense.NdArrayWrapper(data) | ||
return dense.NdArrayWrapper( | ||
data, | ||
is_time_series=is_time_series, | ||
is_voxel=is_voxel, | ||
dimensions=dimensions, | ||
) | ||
|
||
if isinstance(data, get_args(SparseArrayType)): | ||
return sparse.SparseArrayWrapper(data) | ||
if is_time_series or is_voxel: | ||
raise ValueError( | ||
"Sparse Array cannot have time series flag and voxel flag." | ||
) | ||
|
||
return sparse.SparseArrayWrapper(data, dimensions=dimensions) | ||
|
||
raise ValueError(f"Unsupported data type: {data.__class__}, {type(data)}") |
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
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
Oops, something went wrong.