From d54cb4f03bd49cc6cb333d33fa7162af6c40a926 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Tue, 3 Dec 2024 16:10:09 +1100 Subject: [PATCH 1/3] fix: simple fix for #155 --- map2loop/project.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/map2loop/project.py b/map2loop/project.py index 34359059..77ae392e 100644 --- a/map2loop/project.py +++ b/map2loop/project.py @@ -356,6 +356,21 @@ def set_sampler(self, datatype: Datatype, sampler: Sampler): sampler (Sampler): The sampler to use """ + allowed_samplers = { + Datatype.STRUCTURE: SamplerDecimator, + Datatype.GEOLOGY: SamplerSpacing, + Datatype.FAULT: SamplerSpacing, + Datatype.FOLD: SamplerSpacing, + Datatype.DTM: SamplerSpacing, + } + + # Check for wrong sampler + if datatype in allowed_samplers: + allowed_sampler_type = allowed_samplers[datatype] + if not isinstance(sampler, allowed_sampler_type): + raise ValueError( + f"Got wrong argument for this datatype: {type(sampler).__name__}, please use {allowed_sampler_type.__name__} instead" + ) ## does the enum print the number or the label? logger.info(f"Setting sampler for {datatype} to {sampler.sampler_label}") self.samplers[datatype] = sampler From ebc5e317575623d497490549cd953c3e7972c318 Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Tue, 3 Dec 2024 16:11:24 +1100 Subject: [PATCH 2/3] fix: decimation factor allows floats --- map2loop/sampler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/map2loop/sampler.py b/map2loop/sampler.py index 01600566..2273de29 100644 --- a/map2loop/sampler.py +++ b/map2loop/sampler.py @@ -9,7 +9,7 @@ import pandas import shapely import numpy -from typing import Optional +from typing import Optional, Union class Sampler(ABC): @@ -60,7 +60,7 @@ class SamplerDecimator(Sampler): """ @beartype.beartype - def __init__(self, decimation: int = 1): + def __init__(self, decimation: Union[int, float] = 1): """ Initialiser for decimator sampler From bc6223b8dd0fe5b46a77c39e9a1f51dfcc41830f Mon Sep 17 00:00:00 2001 From: AngRodrigues Date: Thu, 5 Dec 2024 13:29:57 +1100 Subject: [PATCH 3/3] fix: decimation int --- map2loop/sampler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map2loop/sampler.py b/map2loop/sampler.py index 2273de29..77950b13 100644 --- a/map2loop/sampler.py +++ b/map2loop/sampler.py @@ -60,7 +60,7 @@ class SamplerDecimator(Sampler): """ @beartype.beartype - def __init__(self, decimation: Union[int, float] = 1): + def __init__(self, decimation: int = 1): """ Initialiser for decimator sampler