Skip to content

Commit 227e59a

Browse files
authored
fix: issue 155 (#158)
* fix: simple fix for #155 * fix: decimation factor allows floats * fix: decimation int
1 parent add4692 commit 227e59a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

map2loop/project.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,21 @@ def set_sampler(self, datatype: Datatype, sampler: Sampler):
357357
sampler (Sampler):
358358
The sampler to use
359359
"""
360+
allowed_samplers = {
361+
Datatype.STRUCTURE: SamplerDecimator,
362+
Datatype.GEOLOGY: SamplerSpacing,
363+
Datatype.FAULT: SamplerSpacing,
364+
Datatype.FOLD: SamplerSpacing,
365+
Datatype.DTM: SamplerSpacing,
366+
}
367+
368+
# Check for wrong sampler
369+
if datatype in allowed_samplers:
370+
allowed_sampler_type = allowed_samplers[datatype]
371+
if not isinstance(sampler, allowed_sampler_type):
372+
raise ValueError(
373+
f"Got wrong argument for this datatype: {type(sampler).__name__}, please use {allowed_sampler_type.__name__} instead"
374+
)
360375
## does the enum print the number or the label?
361376
logger.info(f"Setting sampler for {datatype} to {sampler.sampler_label}")
362377
self.samplers[datatype] = sampler

map2loop/sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pandas
1010
import shapely
1111
import numpy
12-
from typing import Optional
12+
from typing import Optional, Union
1313

1414

1515
class Sampler(ABC):

0 commit comments

Comments
 (0)