Skip to content

Commit

Permalink
[docs/refact] Change the 'KrigingBase' class attributes & adjust the …
Browse files Browse the repository at this point in the history
…documentation to these changes
  • Loading branch information
pdGruby committed Mar 25, 2024
1 parent d7c895e commit d3739f7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
14 changes: 13 additions & 1 deletion docs/kriging_classes_description.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ Dictionary containing variogram and covariance functions for different models.

**Type:** dict

### `X_loaded`

The original `X` data loaded using the `load` method (no transformation performed on this object).

**Type:** ndarray, GeoDataFrame

### `y_loaded`

The original `y` data loaded using the `load` method (no transformation performed on this object).

**Type:** ndarray, str

### `X`

Input data loaded using the `load` method. If a `GeoDataFrame` object has been loaded, it undergoes transformation and
Expand All @@ -142,7 +154,7 @@ is then stored in this attribute as an `ndarray` object.

### `y`

Dependent variable values.
Dependent variable values. The values here are transformed by the `scaler` object.

**Type:** ndarray, str

Expand Down
21 changes: 18 additions & 3 deletions geokrige/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@ class KrigingBase(KrigingDrafter):
VARIOGRAM_MODEL_FUNCTIONS : dict
Dictionary containing variogram and covariance functions for different models.
X_loaded : Union[np.ndarray, GeoDataFrame]
The original 'X' data loaded using the 'load' method (no transformation
performed on this object).
y_loaded : Union[np.ndarray, str]
The original 'y' data loaded using the 'load' method (no transformation
performed on this object).
X : Union[ndarray]
Input data loaded using the 'load' method. If a GeoDataFrame object has been
loaded, it undergoes transformation and is then stored in this attribute as
an ndarray object.
y : Union[ndarray, str]
Dependent variable values.
Dependent variable values. The values here are transformed by the 'scaler'
object.
scaler : StandardScaler
StandardScaler object for data scaling.
Expand Down Expand Up @@ -125,8 +134,11 @@ class KrigingBase(KrigingDrafter):
def __init__(self):
super().__init__()

self.X: Optional[Union[np.ndarray, GeoDataFrame, list]] = None
self.y: Optional[Union[np.ndarray, str, list]] = None
self.X_loaded: Optional[Union[np.ndarray, GeoDataFrame]] = None
self.y_loaded: Optional[Union[np.ndarray, str]] = None

self.X: Optional[np.ndarray] = None
self.y: Optional[Union[np.ndarray, str]] = None
self.scaler: Optional[StandardScaler] = None

self.bins: Optional[int] = None
Expand Down Expand Up @@ -180,6 +192,9 @@ def load(self, X: Union[np.ndarray, GeoDataFrame], y: Union[np.ndarray, str]) ->
if isinstance(X, GeoDataFrame) and not isinstance(y, str):
raise TypeError("The 'X' argument is of type 'GeoDataFrame', so the 'y' argument must be of type 'str'.")

self.X_loaded = copy.deepcopy(X)
self.y_loaded = copy.deepcopy(y)

if isinstance(X, GeoDataFrame):
y = X.loc[:, y].to_numpy()
X = self._convert_gdf_coords_to_ndarray(X)
Expand Down

0 comments on commit d3739f7

Please sign in to comment.