diff --git a/spatio_temporal_dataset/coordinates/spatial_coordinates/alps_station_3D_coordinates.py b/spatio_temporal_dataset/coordinates/spatial_coordinates/alps_station_3D_coordinates.py index 92e97f8561a65733e2824af11cf6dd7434361c68..0f1df96dcf5f88878616f2b30a1c2f9258a953d3 100644 --- a/spatio_temporal_dataset/coordinates/spatial_coordinates/alps_station_3D_coordinates.py +++ b/spatio_temporal_dataset/coordinates/spatial_coordinates/alps_station_3D_coordinates.py @@ -2,10 +2,10 @@ import os.path as op import pandas as pd -from spatio_temporal_dataset.coordinates.abstract_coordinates import AbstractCoordinates from spatio_temporal_dataset.coordinates.spatial_coordinates.abstract_spatial_coordinates import \ AbstractSpatialCoordinates -from spatio_temporal_dataset.coordinates.transformed_coordinates.transformation.tranformation_3D import AnisotropyTransformation +from spatio_temporal_dataset.coordinates.transformed_coordinates.transformation.tranformation_3D import \ + AnisotropyTransformation from spatio_temporal_dataset.coordinates.transformed_coordinates.transformed_coordinates import TransformedCoordinates from utils import get_full_path diff --git a/spatio_temporal_dataset/coordinates/transformed_coordinates/transformation/abstract_transformation.py b/spatio_temporal_dataset/coordinates/transformed_coordinates/transformation/abstract_transformation.py index 27a83545ea08704697c8d43a045e0301d714ae1e..a328257b66ee0f31b30652ce7c1612a51df51af6 100644 --- a/spatio_temporal_dataset/coordinates/transformed_coordinates/transformation/abstract_transformation.py +++ b/spatio_temporal_dataset/coordinates/transformed_coordinates/transformation/abstract_transformation.py @@ -26,8 +26,6 @@ class AbstractTransformation(object): return pd.DataFrame(data, index=df_coord.index, columns=df_coord.columns) - - class IdentityTransformation(AbstractTransformation): def transform_array(self, coordinate: np.ndarray): @@ -44,5 +42,3 @@ class CenteredScaledNormalization(AbstractTransformation): def transform_array(self, coordinate: np.ndarray): return self.scaler.transform(np.array([coordinate]))[0] - - diff --git a/spatio_temporal_dataset/coordinates/transformed_coordinates/transformation/tranformation_3D.py b/spatio_temporal_dataset/coordinates/transformed_coordinates/transformation/tranformation_3D.py index c05f6436cb7414ac0dca1ba117f3c1c1b9f76c58..cbd4988163f498783313e5bbd0705f1b3672f08e 100644 --- a/spatio_temporal_dataset/coordinates/transformed_coordinates/transformation/tranformation_3D.py +++ b/spatio_temporal_dataset/coordinates/transformed_coordinates/transformation/tranformation_3D.py @@ -6,14 +6,7 @@ import math class Transformation3D(AbstractTransformation): - - def transform_df(self, df_coord: pd.DataFrame) -> pd.DataFrame: - df_coord = super().transform_df(df_coord=df_coord) - normalized_values = self.transform_values(df_coord.values) - return pd.DataFrame(data=normalized_values, index=df_coord.index, columns=df_coord.columns) - - def transform_values(self, coord_arr: np.ndarray) -> np.ndarray: - return coord_arr + pass class AnisotropyTransformation(Transformation3D): @@ -32,7 +25,8 @@ class AnisotropyTransformation(Transformation3D): assert 0 <= self.phi < math.pi assert self.w1 > 0 - def transform_values(self, coord_arr: np.ndarray) -> np.ndarray: + def transform_array(self, coordinate: np.ndarray): + super().transform_array(coordinate) cosinus, sinus = math.cos(self.phi), math.sin(self.phi) inverse_w1 = 1 / self.w1 V = np.array([ @@ -40,6 +34,6 @@ class AnisotropyTransformation(Transformation3D): [inverse_w1 * sinus, inverse_w1 * cosinus, 0], [0, 0, self.w2], ]) - coord_arr = np.transpose(coord_arr) + coord_arr = np.transpose(coordinate) coord_arr = np.dot(V, coord_arr) return np.transpose(coord_arr) diff --git a/test/test_spatio_temporal_dataset/test_coordinates.py b/test/test_spatio_temporal_dataset/test_coordinates.py index feac9162a0b1f8de6582d56d51a94588782b5a96..934269e8713f381fcbdeb5fe9b5bc495f886b045 100644 --- a/test/test_spatio_temporal_dataset/test_coordinates.py +++ b/test/test_spatio_temporal_dataset/test_coordinates.py @@ -37,7 +37,8 @@ class TestSpatialCoordinates(unittest.TestCase): def tearDown(self): if self.DISPLAY: self.coord.visualize() - self.assertTrue(True) + first_coordinate = self.coord.df_all_coordinates.iloc[0, 0] + self.assertFalse(np.isnan(first_coordinate)) def test_unif(self): self.coord = UniformSpatialCoordinates.from_nb_points(nb_points=10)