Skip to content

Error on running #12

@safwatonline

Description

@safwatonline

I just downloaded statopt and trying to run the default example, I get this error

File E:..\Python\statopt-python-main\userSettingsObjects.py:23
20 def init(self, val: float = float("nan")):
21 self.value = val
---> 23 @DataClass
24 class valueList:
25 value: ndarray = empty(0)
27 class nothing:

File ~\anaconda3\Lib\dataclasses.py:1305, in dataclass(cls, init, repr, eq, order, unsafe_hash, frozen, match_args, kw_only, slots, weakref_slot)
1302 return wrap
1304 # We're called as @DataClass without parens.
-> 1305 return wrap(cls)

File ~\anaconda3\Lib\dataclasses.py:1295, in dataclass..wrap(cls)
1294 def wrap(cls):
-> 1295 return _process_class(cls, init, repr, eq, order, unsafe_hash,
1296 frozen, match_args, kw_only, slots,
1297 weakref_slot)

File ~\anaconda3\Lib\dataclasses.py:1008, in _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, match_args, kw_only, slots, weakref_slot)
1005 kw_only = True
1006 else:
1007 # Otherwise it's a field of some type.
-> 1008 cls_fields.append(_get_field(cls, name, type, kw_only))
1010 for f in cls_fields:
1011 fields[f.name] = f

File ~\anaconda3\Lib\dataclasses.py:860, in _get_field(cls, a_name, a_type, default_kw_only)
856 # For real fields, disallow mutable defaults. Use unhashable as a proxy
857 # indicator for mutability. Read the hash attribute from the class,
858 # not the instance.
859 if f._field_type is _FIELD and f.default.class.hash is None:
--> 860 raise ValueError(f'mutable default {type(f.default)} for field '
861 f'{f.name} is not allowed: use default_factory')
863 return f

ValueError: mutable default <class 'numpy.ndarray'> for field value is not allowed: use default_factory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions