Skip to content

Implement numpy.size() and numpy.shape() #1457

Open

Description

@certik

And use the ArraySize intrinsic.

Activity

  1. added
    numpyBugs and feature requests regarding NumPy support
    on Jan 24, 2023
  2. certik commented on Jan 24, 2023

    @certik
    ContributorAuthor

    Also shape()

  3. self-assigned this
    on Jan 24, 2023
  4. czgdp1807 commented on Jan 24, 2023

    @czgdp1807
    Collaborator

    Next on my TODO list (after lfortran/lfortran#1210).

  5. faze-geek commented on Feb 16, 2024

    @faze-geek
    Contributor

    numpy.size() has already been completed in this #1777 .

    Also shape()

    I can try to add this. But for shape we would need another intrinsic like ArrayShape right?

  6. certik commented on Feb 16, 2024

    @certik
    ContributorAuthor

    Use the Shape IntrinsicArrayFunction. Here is how LFortran does it:

    integer(8) :: x(2, 2)
    print*, shape(x)
    end

    It gives:

                        [(Print
                            [(IntrinsicArrayFunction
                                Shape
                                [(ArrayPhysicalCast
                                    (Var 2 x)
                                    FixedSizeArray
                                    DescriptorArray
                                    (Array
                                        (Integer 8)
                                        [((IntegerConstant 1 (Integer 4))
                                        (IntegerConstant 2 (Integer 4)))
                                        ((IntegerConstant 1 (Integer 4))
                                        (IntegerConstant 2 (Integer 4)))]
                                        DescriptorArray
                                    )
                                    ()
                                )]
                                0
                                (Array
                                    (Integer 4)
                                    [((IntegerConstant 1 (Integer 4))
                                    (IntegerConstant 2 (Integer 4)))]
                                    FixedSizeArray
                                )
                                (ArrayConstant
                                    [(IntegerConstant 2 (Integer 4))
                                    (IntegerConstant 2 (Integer 4))]
                                    (Array
                                        (Integer 4)
                                        [((IntegerConstant 1 (Integer 4))
                                        (IntegerConstant 2 (Integer 4)))]
                                        FixedSizeArray
                                    )
                                    ColMajor
                                )
                            )]
                            ()
                            ()
                        )]
  7. changed the title [-]Implement numpy.size()[/-] [+]Implement numpy.size() and numpy.shape()[/+] on Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

numpyBugs and feature requests regarding NumPy support

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions