Skip to content

Commit

Permalink
Merge pull request #39 from MiraGeoscience/release/0.1.0
Browse files Browse the repository at this point in the history
Release/0.1.0: address pylint warnings on top of v0.1.0
  • Loading branch information
sebhmg authored Jun 17, 2024
2 parents e6fa884 + cab1e0b commit c7acbb0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "octree-creation"
release = "0.1.0"
release = "0.1.1"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion octree_creation_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from geoapps_utils.importing import assets_path as assets_path_impl

__version__ = "0.1.0"
__version__ = "0.1.1"


def assets_path() -> Path:
Expand Down
46 changes: 38 additions & 8 deletions octree_creation_app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def create_octree_from_octrees(meshes: list[Octree | TreeMesh]) -> TreeMesh:
- mesh.max_level
+ mesh.cell_levels_by_index(np.arange(mesh.nC))
)
else:
raise TypeError(
f"All meshes must be Octree or TreeMesh, not {type(mesh)} "
"and must have octree cells defined."
)

treemesh.insert_cells(centers, levels, finalize=False)

Expand All @@ -86,10 +91,17 @@ def collocate_octrees(global_mesh: Octree, local_meshes: list[Octree]):
attributes = get_octree_attributes(global_mesh)
cell_size = attributes["cell_size"]

if global_mesh.octree_cells is not None:
u_grid = global_mesh.octree_cells["I"] * global_mesh.u_cell_size
v_grid = global_mesh.octree_cells["J"] * global_mesh.v_cell_size
w_grid = global_mesh.octree_cells["K"] * global_mesh.w_cell_size
if (
global_mesh.octree_cells is None
or global_mesh.u_cell_size is None
or global_mesh.v_cell_size is None
or global_mesh.w_cell_size is None
):
raise ValueError("Global mesh must have octree_cells and cell sizes.")

u_grid = global_mesh.octree_cells["I"] * global_mesh.u_cell_size
v_grid = global_mesh.octree_cells["J"] * global_mesh.v_cell_size
w_grid = global_mesh.octree_cells["K"] * global_mesh.w_cell_size

xyz = np.c_[u_grid, v_grid, w_grid] + attributes["origin"]
tree = cKDTree(xyz)
Expand Down Expand Up @@ -128,6 +140,10 @@ def densify_curve(curve: Curve, increment: float) -> np.ndarray:
if curve.cells is not None and curve.vertices is not None:
logic = curve.parts == part
cells = curve.cells[np.all(logic[curve.cells], axis=1)]

if len(cells) == 0:
continue

vert_ind = np.r_[cells[:, 0], cells[-1, 1]]
locs = curve.vertices[vert_ind, :]
locations.append(resample_locations(locs, increment))
Expand Down Expand Up @@ -220,12 +236,26 @@ def octree_2_treemesh( # pylint: disable=too-many-locals
:return: Resulting TreeMesh.
"""
if mesh.octree_cells is None:
if (
mesh.octree_cells is None
or mesh.u_count is None
or mesh.v_count is None
or mesh.w_count is None
):
return None

small_cell = [mesh.u_cell_size, mesh.v_cell_size, mesh.w_cell_size]
n_cell_dim = [mesh.u_count, mesh.v_count, mesh.w_count]
cell_sizes = [np.ones(nr) * sz for nr, sz in zip(n_cell_dim, small_cell)]
n_cell_dim, cell_sizes = [], []
for ax in "uvw":
if (
getattr(mesh, f"{ax}_cell_size") is None
or getattr(mesh, f"{ax}_count") is None
):
raise ValueError(f"Cell size in {ax} direction is not defined.")

n_cell_dim.append(getattr(mesh, f"{ax}_count"))
cell_sizes.append(
np.ones(getattr(mesh, f"{ax}_count")) * getattr(mesh, f"{ax}_cell_size")
)

if any(np.any(cell_size < 0) for cell_size in cell_sizes):
raise NotImplementedError("Negative cell sizes not supported.")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "octree-creation-app"
version = "0.1.0"
version = "0.1.1"
license = "MIT"
description = "Octree creation app."
authors = ["Mira Geoscience <[email protected]>"]
Expand Down

0 comments on commit c7acbb0

Please sign in to comment.