Skip to content

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

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

Open
certik opened this issue Jan 24, 2023 · 4 comments
Open

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

certik opened this issue Jan 24, 2023 · 4 comments
Assignees
Labels
numpy Bugs and feature requests regarding NumPy support

Comments

@certik
Copy link
Contributor

certik commented Jan 24, 2023

And use the ArraySize intrinsic.

@certik certik added the numpy Bugs and feature requests regarding NumPy support label Jan 24, 2023
@certik
Copy link
Contributor Author

certik commented Jan 24, 2023

Also shape()

@czgdp1807 czgdp1807 self-assigned this Jan 24, 2023
@czgdp1807
Copy link
Collaborator

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

@faze-geek
Copy link
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?

@certik
Copy link
Contributor Author

certik commented Feb 16, 2024

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
                            )
                        )]
                        ()
                        ()
                    )]

@certik certik changed the title Implement numpy.size() Implement numpy.size() and numpy.shape() Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
numpy Bugs and feature requests regarding NumPy support
Projects
None yet
Development

No branches or pull requests

3 participants