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

Request : Provide squeeze function, or possibility to squeeze with rearrange. #19

Open
hprodh opened this issue Feb 7, 2025 · 0 comments

Comments

@hprodh
Copy link

hprodh commented Feb 7, 2025

Current ways of squeezing an array on a given dimension using rearrange are :

vals_squeezed = einx.rearrange('a 1 c -> a c', vals)  # dim 'k' is not named here
vals_squeezed = einx.rearrange('a b c -> (a b) c', vals)  # this is difficult to understand

Side note : trying to squeeze an array by providing b=1 raises an error :

vals_squeezed = einx.rearrange('a b c -> a c', vals, b=1)
# RuntimeError: Failed to find assignment between input and output expressions

Making rearrange be able to squeeze dimensions when their size is given as 1 could be convenient.
Yet, possibly providing a squeeze function would be more meaningful :

vals_squeezed = einx.squeeze('a b c -> a c', vals)

And btw ... thank you einx developers to help me make my array dimensions readable all along my code 👍.

@hprodh hprodh changed the title Request : Provide ability to squeeze with rearrange Request : Provide squeeze function Feb 8, 2025
@hprodh hprodh changed the title Request : Provide squeeze function Request : Provide squeeze function, or possibility to squeeze with rearrange. Feb 8, 2025
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

1 participant