Skip to content

Commit 13c2ccf

Browse files
author
Miguel de la Varga
committed
[BUG] initialization of Grid class
[TEST] Fix a gempy_subsurface test
1 parent 73180cd commit 13c2ccf

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Goals
2+
3+
- [ ] 1. Fixing 2024.2.0 for whatever version of python that is not working
4+
5+
6+
## TODO:
7+
8+
- [x] Analyze error:
9+
- [x] Set up environment 3.11
10+
- [x] Fixing the lines of code
11+
- [ ] Test the code
12+
- [ ] Release hot fix
13+
14+
## Extra points:
15+
- [ ] Setting up github actions
16+
- [ ] Categories for the tests like I did in subsurface
17+
- [ ] Run tests in python 3.10, 3.11 and 3.12

gempy/core/data/grid.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .grid_modules.topography import Topography
1313

1414

15-
@dataclasses.dataclass
15+
@dataclasses.dataclass(init=True)
1616
class Grid:
1717
class GridTypes(enum.Flag):
1818
OCTREE = 2 ** 0
@@ -25,25 +25,30 @@ class GridTypes(enum.Flag):
2525

2626
# ? What should we do with the extent?
2727

28+
values: np.ndarray
29+
length: np.ndarray
30+
2831
_octree_grid: Optional[RegularGrid] = None
2932
_dense_grid: Optional[RegularGrid] = None
3033
_custom_grid: Optional[CustomGrid] = None
3134
_topography: Optional[Topography] = None
3235
_sections: Optional[Sections] = None
3336
_centered_grid: Optional[CenteredGrid] = None
3437

35-
values: np.ndarray = dataclasses.field(default_factory=lambda: np.empty((0, 3)))
36-
length: np.ndarray = dataclasses.field(default_factory=lambda: np.empty(0))
37-
3838
_active_grids = GridTypes.NONE
3939
_transform: Optional[Transform] = None
4040

4141
_octree_levels: int = -1
4242

4343
def __init__(self, extent=None, resolution=None):
44+
45+
self.values = np.empty((0, 3))
46+
self.length = np.empty(0)
47+
4448
# Init basic grid empty
4549
if extent is not None and resolution is not None:
4650
self.dense_grid = RegularGrid(extent, resolution)
51+
4752

4853
@classmethod
4954
def init_octree_grid(cls, extent, octree_levels):

test/conftest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# import pytest
2-
# import gempy.gempy_api as gempy
3-
# import gempy as gp
41
import enum
52
import os
63

test/test_modules/test_gempy_subsurface.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
import gempy as gp
44
import gempy_viewer as gpv
55
import subsurface.core.structs.unstructured_elements.triangular_surface
6-
from conftest import Requirements, REQUIREMENT_LEVEL
76
from gempy.core.data.enumerators import ExampleModel
87

98
import numpy as np
109

10+
from ..conftest import REQUIREMENT_LEVEL, Requirements
11+
1112
pytestmark = pytest.mark.skipif(
1213
condition=REQUIREMENT_LEVEL.value < Requirements.DEV.value and False,
1314
reason="This test needs higher requirements."

0 commit comments

Comments
 (0)