From ac80bb21661a5d26ee19162d632e8d27f9a6da89 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Tue, 2 Nov 2021 17:14:54 +0000 Subject: [PATCH 1/2] remove torch --- environment.yml | 3 --- nowcasting_dataset/data_sources/gsp/gsp_data_source.py | 4 +--- nowcasting_dataset/data_sources/pv/pv_data_source.py | 4 +--- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/environment.yml b/environment.yml index 36a12961..5fefc45f 100644 --- a/environment.yml +++ b/environment.yml @@ -26,9 +26,6 @@ dependencies: - boto3 - moto - # Machine learning - - pytorch::pytorch # explicitly specify pytorch channel to prevent conda from using conda-forge for pytorch, and hence installing the CPU-only version. - # PV & Geospatial - pvlib - pyproj diff --git a/nowcasting_dataset/data_sources/gsp/gsp_data_source.py b/nowcasting_dataset/data_sources/gsp/gsp_data_source.py index 8868eb1f..2fe0ff6b 100644 --- a/nowcasting_dataset/data_sources/gsp/gsp_data_source.py +++ b/nowcasting_dataset/data_sources/gsp/gsp_data_source.py @@ -11,7 +11,6 @@ import numpy as np import pandas as pd -import torch import xarray as xr import nowcasting_dataset.filesystem.utils as nd_fs_utils @@ -62,8 +61,7 @@ def __post_init__(self, image_size_pixels: int, meters_per_pixel: int): Set random seed and load data """ super().__post_init__(image_size_pixels, meters_per_pixel) - seed = torch.initial_seed() - self.rng = np.random.default_rng(seed=seed) + self.rng = np.random.default_rng() self.load() def check_input_paths_exist(self) -> None: diff --git a/nowcasting_dataset/data_sources/pv/pv_data_source.py b/nowcasting_dataset/data_sources/pv/pv_data_source.py index 2738286f..481e749c 100644 --- a/nowcasting_dataset/data_sources/pv/pv_data_source.py +++ b/nowcasting_dataset/data_sources/pv/pv_data_source.py @@ -12,7 +12,6 @@ import fsspec import numpy as np import pandas as pd -import torch import xarray as xr import nowcasting_dataset.filesystem.utils as nd_fs_utils @@ -49,8 +48,7 @@ class PVDataSource(ImageDataSource): def __post_init__(self, image_size_pixels: int, meters_per_pixel: int): """ Post Init """ super().__post_init__(image_size_pixels, meters_per_pixel) - seed = torch.initial_seed() - self.rng = np.random.default_rng(seed=seed) + self.rng = np.random.default_rng() self.load() def check_input_paths_exist(self) -> None: From 1c7eae0d6130051f53ef251955bcefa83c44926e Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Tue, 2 Nov 2021 17:20:30 +0000 Subject: [PATCH 2/2] remove more torch imports --- README.md | 9 --------- nowcasting_dataset/consts.py | 3 +-- nowcasting_dataset/utils.py | 3 --- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/README.md b/README.md index acb5a5d5..3a3513ba 100644 --- a/README.md +++ b/README.md @@ -32,15 +32,6 @@ conda activate nowcasting_dataset pip install -e . ``` -Note you can install the [pytorch](https://github.com/pytorch/pytorch) -and [pytorch_lightning](https://github.com/PyTorchLightning/pytorch-lightning) using -```shell -pip install -e .[torch] -``` -but it is only used to create a dataloader for machine learning models, and will not be necessary -soon (when the dataloader is moved to `nowcasting_dataloader`). - - ### `pip` A (probably older) version is also available through `pip install nowcasting-dataset` diff --git a/nowcasting_dataset/consts.py b/nowcasting_dataset/consts.py index f392d709..d3d65f8f 100644 --- a/nowcasting_dataset/consts.py +++ b/nowcasting_dataset/consts.py @@ -3,7 +3,6 @@ from typing import Union import numpy as np -import torch import xarray as xr # DEFAULT PATHS @@ -24,7 +23,7 @@ NWP_FILENAME = "gs://" + str(BUCKET / "NWP/UK_Met_Office/UKV_zarr") # Typing -Array = Union[xr.DataArray, np.ndarray, torch.Tensor] +Array = Union[xr.DataArray, np.ndarray] PV_SYSTEM_ID: str = "pv_system_id" PV_SYSTEM_ROW_NUMBER = "pv_system_row_number" PV_SYSTEM_X_COORDS = "pv_system_x_coords" diff --git a/nowcasting_dataset/utils.py b/nowcasting_dataset/utils.py index a60fd08d..2924a9ab 100644 --- a/nowcasting_dataset/utils.py +++ b/nowcasting_dataset/utils.py @@ -9,7 +9,6 @@ import gcsfs import numpy as np import pandas as pd -import torch import xarray as xr import nowcasting_dataset @@ -117,8 +116,6 @@ def to_numpy(value): value = np.int32(value.timestamp()) elif isinstance(value, np.ndarray) and np.issubdtype(value.dtype, np.datetime64): value = value.astype("datetime64[s]").astype(np.int32) - elif isinstance(value, torch.Tensor): - value = value.numpy() return value