gempy-project / gempy_engine

European Union Public License 1.2
1 stars 0 forks source link

ValueError on import #6

Closed banesullivan-kobold closed 2 months ago

banesullivan-kobold commented 2 months ago

Excited to try out the latest version of GemPy that was just released, but I'm having some trouble immediately upon import: ValueError: mutable default <class 'slice'> for field slice_feature is not allowed: use default_factory

>>> import gempy
Setting Backend To: AvailableBackends.PYTORCH
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/python/lib/python3.11/site-packages/gempy/__init__.py", line 10, in <module>
    from .core import data
  File "/python/lib/python3.11/site-packages/gempy/core/data/__init__.py", line 1, in <module>
    from .geo_model import GeoModel
  File "/python/lib/python3.11/site-packages/gempy/core/data/geo_model.py", line 8, in <module>
    import gempy_engine.core.data.engine_grid
  File "/python/lib/python3.11/site-packages/gempy_engine/__init__.py", line 1, in <module>
    from gempy_engine.API.model.model_api import compute_model
  File "/python/lib/python3.11/site-packages/gempy_engine/API/model/model_api.py", line 6, in <module>
    from ...core.data.interp_output import InterpOutput
  File "/python/lib/python3.11/site-packages/gempy_engine/core/data/__init__.py", line 3, in <module>
    from .kernel_classes.surface_points import SurfacePoints, SurfacePointsInternals
  File "/python/lib/python3.11/site-packages/gempy_engine/core/data/kernel_classes/surface_points.py", line 13, in <module>
    @dataclass(frozen=False)
     ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 1220, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 958, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'slice'> for field slice_feature is not allowed: use default_factory

Please let me know if there are addition packages or context you'd like me to provide, my system imformation is generally:

>>> from scooby import Report
>>> Report(['gempy', 'gempy_engine', 'numpy'])

--------------------------------------------------------------------------------
  Date: Fri Apr 19 04:41:48 2024 GMT

                OS : Linux
            CPU(s) : 16
           Machine : x86_64
      Architecture : 64bit
               RAM : 61.5 GiB
       Environment : Python

  Python 3.11.8 (main, Mar 12 2024, 11:52:02) [GCC 12.2.0]

             gempy : 2024.1.0
      gempy_engine : 2024.1.1
             numpy : 1.23.5
             scipy : 1.10.1
           IPython : 8.12.0
        matplotlib : 3.7.1
            scooby : 0.8.0
--------------------------------------------------------------------------------
Freiberg110 commented 2 months ago

I had meet the same problem too. I also can't solve it . I think it is a bug . Maybe we can wait a new version.

Leguark commented 2 months ago

HI @banesullivan-kobold and @Freiberg110 thank you for the comments. This was a weird interaction between dataclasses and slice that gave different behaviors in Python 3.10, 3.11 and 3.12.

It was fixed on #7 , now (gempy 2024.1.2 and engine .3) those 3 versions of Python should be compatible. Let me know if you find anything similar

Freiberg110 commented 1 month ago

Hello,Thanks for your answer,now Gempy works fine.        Forgive my ignorance as I am a beginner to Gempy. I have another question. The tutorials all use surface points and orientation to construct models. But I want to directly read the drilling data to construct models(For example the borehole data type that will be modeled in leapfrog.). to construct the model.Can you provide a tutorial or tell me how to convert drilling data(For example the borehole data type that will be modeled in leapfrog.) into input data surface points and orientation?Thank you for reading .Looking forward to your reply.Thanks!---- Replied Message ----FromMiguel de la @.>Date5/2/2024 @.>@.>@.>SubjectRe: [gempy-project/gempy_engine] ValueError on import (Issue #6)Closed #6 as completed.—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>