Skip to content

Bug in ANCOVA function (ValueError: assignment destination is read-only) #421

Open
@plankter

Description

@plankter

Hi,

First, thank you for a very useful library!

With the following versions installed:

Python: 3.12.3
Pingouin: 0.5.4
Pandas: 2.2.2
Numpy: 1.26.4

In the file parametric.py [lines: 1739, 1743] there is a problem with ancova(...) function. This code tries to assign a value to read-only numpy array:

ss_resid = aov["SS"].iloc[-1]
all_effsize = aov["SS"].apply(lambda x: x / (x + ss_resid)).to_numpy()
all_effsize[-1] = np.nan

ValueError: assignment destination is read-only

If one prints flags of all_effsize array with print(all_effsize.flags), the output is the following:

C_CONTIGUOUS : True
F_CONTIGUOUS : True
OWNDATA : False
WRITEABLE : False
ALIGNED : True
WRITEBACKIFCOPY : False

Making a copy of the array before assignment fixes the problem:

all_effsize = all_effsize.copy()
all_effsize[-1] = np.nan

Best regards,
Anton

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 💥Something isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions