Skip to content

Commit

Permalink
fix issue #155 (simple fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
AngRodrigues committed Nov 28, 2024
1 parent 6267dc8 commit 9503884
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 16 additions & 1 deletion map2loop/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,22 @@ def set_sampler(self, datatype: Datatype, sampler: Sampler):
sampler (Sampler):
The sampler to use
"""
## does the enum print the number or the label?
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"
)

logger.info(f"Setting sampler for {datatype} to {sampler.sampler_label}")
self.samplers[datatype] = sampler

Expand Down
4 changes: 2 additions & 2 deletions map2loop/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pandas
import shapely
import numpy
from typing import Optional
from typing import Optional, Union


class Sampler(ABC):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9503884

Please sign in to comment.