Skip to content

Commit

Permalink
Fixes issue #10
Browse files Browse the repository at this point in the history
  • Loading branch information
tlorieul committed May 13, 2022
1 parent dbee677 commit 5266fa7
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 19 deletions.
11 changes: 7 additions & 4 deletions data_loading/common.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from __future__ import annotations
from pathlib import Path
from typing import Optional, Union
from typing import Optional, Union, TYPE_CHECKING

import numpy as np
import numpy.typing as npt
from PIL import Image
import tifffile

Patches = npt.NDArray
if TYPE_CHECKING:
import numpy.typing as npt

Patches = npt.NDArray


def load_patch(
Expand All @@ -15,7 +18,7 @@ def load_patch(
*,
data: Union[str, list[str]] = "all",
landcover_mapping: Optional[npt.NDArray] = None,
return_arrays: bool = True
return_arrays: bool = True,
) -> list[Patches]:
"""Loads the patch data associated to an observation id
Expand Down
13 changes: 8 additions & 5 deletions data_loading/environmental_raster.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
from __future__ import annotations
import warnings
from pathlib import Path
from typing import Any, Optional, Union
from typing import Any, Optional, Union, TYPE_CHECKING

import matplotlib.pyplot as plt
import numpy as np
import numpy.typing as npt
import rasterio

if TYPE_CHECKING:
import numpy.typing as npt

Coordinates = tuple[float, float]
Patch = npt.NDArray[np.float32]


# fmt: off
bioclimatic_raster_names = [
Expand All @@ -22,9 +28,6 @@
raster_names = bioclimatic_raster_names + pedologic_raster_names
# fmt: on

Coordinates = tuple[float, float]
Patch = npt.NDArray[np.float32]


class Raster(object):
"""
Expand Down
8 changes: 4 additions & 4 deletions data_loading/pytorch_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
from typing import Callable, Optional, Union, TYPE_CHECKING

import numpy as np
import numpy.typing as npt
import pandas as pd

from torch.utils.data import Dataset

from .common import load_patch, Patches
from .common import load_patch

if TYPE_CHECKING:
import numpy.typing as npt
from .common import Patches
from .environmental_raster import PatchExtractor


Targets = npt.NDArray[np.int64]
Targets = npt.NDArray[np.int64]


class GeoLifeCLEF2022Dataset(Dataset):
Expand Down
7 changes: 5 additions & 2 deletions metrics.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from __future__ import annotations
import numbers
import warnings
from typing import Optional
from typing import Optional, TYPE_CHECKING

import numpy as np
import numpy.typing as npt

if TYPE_CHECKING:
import numpy.typing as npt


def generic_validation(
Expand Down
2 changes: 1 addition & 1 deletion plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from collections.abc import Collection

import numpy as np
import numpy.typing as npt
import matplotlib.pyplot as plt
from matplotlib.patches import Patch

if TYPE_CHECKING:
import numpy.typing as npt
import pandas as pd


Expand Down
7 changes: 6 additions & 1 deletion spatial_split/spatial_split_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from __future__ import annotations
from typing import TYPE_CHECKING

import numpy as np
import numpy.typing as npt
from geopy import distance

if TYPE_CHECKING:
import numpy.typing as npt

WGS84_EQUATOR_CIRCUMFERENCE = 40075.017 # km
WGS84_MERIDIAN_CIRCUMFERENCE = 40007.863 # km

Expand Down
7 changes: 5 additions & 2 deletions submission.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from typing import Iterable
from __future__ import annotations
from typing import Iterable, TYPE_CHECKING

import numpy.typing as npt
import pandas as pd

if TYPE_CHECKING:
import numpy.typing as npt


def generate_submission_file(
filename: str,
Expand Down

0 comments on commit 5266fa7

Please sign in to comment.