Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part. #45

Open
dirknbr opened this issue May 20, 2024 · 7 comments

Comments

@dirknbr
Copy link
Contributor

dirknbr commented May 20, 2024

when I run

gps_point = gps.point_estimate(np.array([1]))

I get this error

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

the model was trained with continours treatment in pandas format

@ronikobrosly
Copy link
Owner

Hi @dirknbr , can you include data and code to replicate this? The data can be mock/random data if that helps

@dirknbr
Copy link
Contributor Author

dirknbr commented May 20, 2024

sure

n = 200
df = pd.DataFrame()
df['X'] = np.random.normal(10, 1, n)
df['Tr'] = 10 + df.X + np.random.normal(0, 1, n)
df['Y'] = 10 + df.X + df.Tr + np.random.normal(0, 1, n)
gps = GPS_Regressor(treatment_grid_num = 20, random_seed = 512)
gps.fit(T = df['Tr'], X = df['X'], y = df['Y'])
gps_point = gps.point_estimate(np.array([1]))

@ronikobrosly
Copy link
Owner

Ok thanks @dirknbr , I'll take a look soon and get back to you 👍

@ronikobrosly
Copy link
Owner

Well @dirknbr , in short, numpy introduced a breaking change in some recent version. I can confirm that 3 unit tests in this package are now broken with the most recent version of numpy. Thanks for catching this!

Two options. The quicker one: I recommend you create a new virtual environment for your project work and force install a version of numpy < 1.20. This will have a cascading effect on the other dependencies and they'll end up being older versions too. The slightly more challenging one: could I get your help in patching causal-curve to work with the latest version of numpy?

@dirknbr
Copy link
Contributor Author

dirknbr commented May 21, 2024

ok will have a look whether I can fix it

@dirknbr
Copy link
Contributor Author

dirknbr commented May 21, 2024

fixed it locally and will now try to upload it, pytest passes

dirknbr added a commit to dirknbr/causal-curve that referenced this issue May 21, 2024
dirknbr added a commit to dirknbr/causal-curve that referenced this issue May 21, 2024
This was referenced May 21, 2024
ronikobrosly pushed a commit that referenced this issue May 23, 2024
ronikobrosly pushed a commit that referenced this issue May 23, 2024
@abhijeetdhakane
Copy link

Will this fix be available in the latest Numpy version (stable)? I am also encountering the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants