Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@hprodh

Description

@hprodh

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 πŸ‘.

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