cemsbv / pygef

Parse soil measurement data.
https://cemsbv.github.io/pygef
MIT License
31 stars 19 forks source link

Plot error with grouped option #130

Closed breinbaas closed 2 years ago

breinbaas commented 2 years ago

Running the following code

def test_plot_classification_grouped(self):
        gef = Cpt("./tests/test_files/cpt.gef")
        gef.plot(
            show=False,
            classification="three_type_rule",
            do_grouping=True,
            min_thickness=0.2,
            water_level_NAP=-10,
        )

with this cpt

throws an error;


  File "c:\Users\brein\Documents\Development\Python\pygef\.env\lib\site-packages\matplotlib\axes\_axes.py", line 2381, in bar
    bottom = y - height / 2
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "C:\Python310\lib\unittest\case.py", line 59, in testPartExecutor
    yield
  File "C:\Python310\lib\unittest\case.py", line 591, in run
    self._callTestMethod(testMethod)
  File "C:\Python310\lib\unittest\case.py", line 549, in _callTestMethod
    method()
  File "c:\Users\brein\Documents\Development\Python\pygef\tests\test_plot.py", line 45, in test_plot_classification_grouped
    gef.plot(
  File "c:\Users\brein\Documents\Development\Python\pygef\pygef\cpt.py", line 355, in plot
    return plot.plot_cpt(
  File "c:\Users\brein\Documents\Development\Python\pygef\pygef\plot_utils.py", line 119, in plot_cpt
    fig = add_grouped_classification(
  File "c:\Users\brein\Documents\Development\Python\pygef\pygef\plot_utils.py", line 250, in add_grouped_classification
    plt.barh(
  File "c:\Users\brein\Documents\Development\Python\pygef\.env\lib\site-packages\matplotlib\pyplot.py", line 2403, in barh
    return gca().barh(
  File "c:\Users\brein\Documents\Development\Python\pygef\.env\lib\site-packages\matplotlib\axes\_axes.py", line 2551, in barh
    patches = self.bar(x=left, height=height, width=width, bottom=y,
  File "c:\Users\brein\Documents\Development\Python\pygef\.env\lib\site-packages\matplotlib\__init__.py", line 1412, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "c:\Users\brein\Documents\Development\Python\pygef\.env\lib\site-packages\matplotlib\axes\_axes.py", line 2383, in bar
    raise TypeError(f'the dtypes of parameters y ({y.dtype}) '
TypeError: the dtypes of parameters y (object) and height (object) are incompatible```
tversteeg commented 2 years ago

After testing this for a bit @martinapippi figured out this is related to issue #108, something is going wrong in the grouping algorithm.