Skip to content

Commit 3b0c5ca

Browse files
committed
Merge branch 'fix/docs_and_cleanup' of github.com:Loop3D/LoopStructural into fix/docs_and_cleanup
2 parents e895af5 + 9cfa132 commit 3b0c5ca

26 files changed

+112
-85
lines changed

.github/workflows/linter.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: "✅ Linter"
22

33
on:
44
push:
5-
branches:
6-
- master
75
paths:
86
- '**.py'
97

@@ -47,6 +45,6 @@ jobs:
4745
ruff check ${{env.PROJECT_FOLDER}} --fix
4846
- uses: stefanzweifel/git-auto-commit-action@v5
4947
with:
50-
push_options: --force
48+
push_options:
5149
commit_message: "style: style fixes by ruff and autoformatting by black"
5250

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"LoopStructural": "1.6.6"
2+
"LoopStructural": "1.6.7"
33
}

LoopStructural/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [1.6.7](https://github.com/Loop3D/LoopStructural/compare/v1.6.6...v1.6.7) (2025-02-03)
4+
5+
6+
### Bug Fixes
7+
8+
* fault orientation init as empty df rather than nan ([c004d9f](https://github.com/Loop3D/LoopStructural/commit/c004d9f84e65a636faa0566c26797749a42da577))
9+
* update matplotlib cmap for deprecation ([#215](https://github.com/Loop3D/LoopStructural/issues/215)) ([8d7e9f9](https://github.com/Loop3D/LoopStructural/commit/8d7e9f9e6f873befd705473dcacbec0492f85187))
10+
311
## [1.6.6](https://github.com/Loop3D/LoopStructural/compare/v1.6.5...v1.6.6) (2025-01-23)
412

513

LoopStructural/datatypes/_bounding_box.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def structured_grid(
470470
_cell_data = copy.deepcopy(cell_data)
471471
_vertex_data = copy.deepcopy(vertex_data)
472472
return StructuredGrid(
473-
origin=self.global_origin+self.origin,
473+
origin=self.global_origin + self.origin,
474474
step_vector=self.step_vector,
475475
nsteps=self.nsteps,
476476
cell_properties=_cell_data,

LoopStructural/datatypes/_point.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dataclasses import dataclass
1+
from dataclasses import dataclass, field
22
import numpy as np
33

44
from typing import Optional, Union
@@ -10,9 +10,9 @@
1010

1111
@dataclass
1212
class ValuePoints:
13-
locations: np.ndarray
14-
values: np.ndarray
15-
name: str
13+
locations: np.ndarray = field(default_factory=lambda: np.array([[0, 0, 0]]))
14+
values: np.ndarray = field(default_factory=lambda: np.array([0]))
15+
name: str = "unnamed"
1616
properties: Optional[dict] = None
1717

1818
def to_dict(self):
@@ -108,9 +108,9 @@ def from_dict(cls, d, flatten=False):
108108

109109
@dataclass
110110
class VectorPoints:
111-
locations: np.ndarray
112-
vectors: np.ndarray
113-
name: str
111+
locations: np.ndarray = field(default_factory=lambda: np.array([[0, 0, 0]]))
112+
vectors: np.ndarray = field(default_factory=lambda: np.array([[0, 0, 0]]))
113+
name: str = "unnamed"
114114
properties: Optional[dict] = None
115115

116116
def to_dict(self):

LoopStructural/datatypes/_structured_grid.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
from typing import Dict
22
import numpy as np
3-
from dataclasses import dataclass
3+
from dataclasses import dataclass, field
44
from LoopStructural.utils import getLogger
55

66
logger = getLogger(__name__)
77

88

99
@dataclass
1010
class StructuredGrid:
11-
origin: np.ndarray
12-
step_vector: np.ndarray
13-
nsteps: np.ndarray
14-
cell_properties: Dict[str, np.ndarray]
15-
properties: Dict[str, np.ndarray]
16-
name: str
11+
origin: np.ndarray = field(default_factory=lambda: np.array([0, 0, 0]))
12+
step_vector: np.ndarray = field(default_factory=lambda: np.array([1, 1, 1]))
13+
nsteps: np.ndarray = field(default_factory=lambda: np.array([10, 10, 10]))
14+
cell_properties: Dict[str, np.ndarray] = field(default_factory=dict)
15+
properties: Dict[str, np.ndarray] = field(default_factory=dict)
16+
name: str = "default_grid"
1717

1818
def to_dict(self):
1919
return {
@@ -44,9 +44,9 @@ def vtk(self):
4444
z,
4545
)
4646
for name, data in self.properties.items():
47-
grid[name] = data.reshape((grid.n_points,-1),order="F")
47+
grid[name] = data.reshape((grid.n_points, -1), order="F")
4848
for name, data in self.cell_properties.items():
49-
grid.cell_data[name] = data.reshape((grid.n_cells,-1),order="F")
49+
grid.cell_data[name] = data.reshape((grid.n_cells, -1), order="F")
5050
return grid
5151

5252
def plot(self, pyvista_kwargs={}):
@@ -88,8 +88,9 @@ def nodes(self):
8888
x = np.linspace(self.origin[0], self.maximum[0], self.nsteps[0])
8989
y = np.linspace(self.origin[1], self.maximum[1], self.nsteps[1])
9090
z = np.linspace(self.origin[2], self.maximum[2], self.nsteps[2])
91-
x, y, z = np.meshgrid(x, y, z,indexing="ij")
91+
x, y, z = np.meshgrid(x, y, z, indexing="ij")
9292
return np.vstack([x.flatten(order='f'), y.flatten(order='f'), z.flatten(order='f')]).T
93+
9394
def merge(self, other):
9495
if not np.all(np.isclose(self.origin, other.origin)):
9596
raise ValueError("Origin of grids must be the same")

LoopStructural/datatypes/_surface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dataclasses import dataclass
1+
from dataclasses import dataclass, field
22
from typing import Optional
33
import numpy as np
44
import io
@@ -9,8 +9,8 @@
99

1010
@dataclass
1111
class Surface:
12-
vertices: np.ndarray
13-
triangles: np.ndarray
12+
vertices: np.ndarray = field(default_factory=lambda: np.array([[0, 0, 0]]))
13+
triangles: np.ndarray = field(default_factory=lambda: np.array([[0, 0, 0]]))
1414
normals: Optional[np.ndarray] = None
1515
name: str = 'surface'
1616
values: Optional[np.ndarray] = None

LoopStructural/export/geoh5.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ def add_structured_grid_to_geoh5(filename, structured_grid, overwrite=True, grou
7878
if structured_grid.cell_properties is not None:
7979
for k, v in structured_grid.cell_properties.items():
8080
data[k] = {
81-
'association': "CELL",
82-
"values": np.flipud(np.rot90(v.reshape(structured_grid.nsteps - 1, order="F"))).flatten(),
81+
"association": "CELL",
82+
"values": np.flipud(
83+
np.rot90(v.reshape(structured_grid.nsteps - 1, order="F"), 1)
84+
).flatten(),
8385
}
8486
block = geoh5py.objects.BlockModel.create(
8587
workspace,

LoopStructural/interpolators/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,5 @@ class InterpolatorType(IntEnum):
115115

116116
from ._interpolator_factory import InterpolatorFactory
117117
from ._interpolator_builder import InterpolatorBuilder
118+
118119
# from ._api import LoopInterpolator

LoopStructural/interpolators/_finite_difference_interpolator.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from LoopStructural.utils import getLogger
1212

1313
logger = getLogger(__name__)
14+
15+
1416
def compute_weighting(grid_points, gradient_constraint_points, alpha=10.0, sigma=1.0):
1517
"""
1618
Compute weights for second derivative regularization based on proximity to gradient constraints.
@@ -29,12 +31,13 @@ def compute_weighting(grid_points, gradient_constraint_points, alpha=10.0, sigma
2931

3032
# Find the distance from each grid point to the nearest gradient constraint
3133
distances, _ = tree.query(grid_points, k=1)
32-
34+
3335
# Compute weighting function (higher weight for nearby points)
3436
weights = 1 + alpha * np.exp(-(distances**2) / (2 * sigma**2))
3537

3638
return weights
3739

40+
3841
class FiniteDifferenceInterpolator(DiscreteInterpolator):
3942
def __init__(self, grid, data={}):
4043
"""
@@ -67,6 +70,7 @@ def __init__(self, grid, data={}):
6770

6871
self.type = InterpolatorType.FINITE_DIFFERENCE
6972
self.use_regularisation_weight_scale = False
73+
7074
def setup_interpolator(self, **kwargs):
7175
"""
7276
@@ -294,11 +298,11 @@ def add_gradient_constraints(self, w=1.0):
294298
self.add_constraints_to_least_squares(A, B, idc[inside, :], w=w, name="gradient")
295299
A = np.einsum("ij,ijk->ik", dip_vector.T, T)
296300
self.add_constraints_to_least_squares(A, B, idc[inside, :], w=w, name="gradient")
297-
self.regularisation_scale += compute_weighting(
298-
self.support.nodes,
299-
points[inside, : self.support.dimension],
300-
sigma=self.support.nsteps[0] * 10,
301-
)
301+
self.regularisation_scale += compute_weighting(
302+
self.support.nodes,
303+
points[inside, : self.support.dimension],
304+
sigma=self.support.nsteps[0] * 10,
305+
)
302306
if np.sum(inside) <= 0:
303307
logger.warning(
304308
f" {np.sum(~inside)} \
@@ -356,7 +360,7 @@ def add_norm_constraints(self, w=1.0):
356360
# indexes = self.support.global_node_indices(indexes)
357361
# self.regularisation_scale[indexes] =10
358362

359-
self.regularisation_scale += compute_weighting(
363+
self.regularisation_scale += compute_weighting(
360364
self.support.nodes,
361365
points[inside, : self.support.dimension],
362366
sigma=self.support.nsteps[0] * 10,
@@ -499,7 +503,11 @@ def assemble_inner(self, operator, w, name='regularisation'):
499503
a[inside, :],
500504
B[inside],
501505
idc[inside, :],
502-
w=self.regularisation_scale[idc[inside, 13].astype(int)] * w if self.use_regularisation_weight_scale else w,
506+
w=(
507+
self.regularisation_scale[idc[inside, 13].astype(int)] * w
508+
if self.use_regularisation_weight_scale
509+
else w
510+
),
503511
name=name,
504512
)
505513
return

0 commit comments

Comments
 (0)