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

Edited Python Numpy built-in functions .reshape() #5523

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NelsonSanti
Copy link
Contributor

Description

  • Edited Python Numpy built-in functions .reshape()
  • Added a new definition
  • Added a new code block

Issue Solved

Closes issue #5374

Type of Change

  • Editing an existing entry (fixing a typo, bug, issues, etc)

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@NelsonSanti
Copy link
Contributor Author

Hello @mamtawardhani ,

A new PR was launched ☺️
Thank you

@mamtawardhani mamtawardhani self-assigned this Oct 18, 2024
@mamtawardhani mamtawardhani added enhancement New feature or request numpy NumPy entries hacktoberfest-accepted Indicates the PR was approved, merged, and pertains to Hacktoberfest status: under review Issue or PR is currently being reviewed labels Oct 18, 2024
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @NelsonSanti thank you for contributing to Codecademy Docs! 😄

I've suggested a few changes, could you review and modify those at your earliest convenience? Thank you!

Comment on lines 62 to 68
Optionally, a third parameter can be added to the syntax: `order`.

`order` reads the elements from `array` in the current index order and places the elements into the reshaped array using the same index order. It can be set to `'C'`, `'F'`, or `'A'`. `C` means to read/write the elements using C-like index order, or in other words, the elements are placed row by row. The last axis index (columns) changes first (fastest), and the first axis index (rows) changes afterward (slowest). `F` means to read/write the elements using Fortran-like index order, where the elements are placed column by column. Here, the first axis index (rows) changes faster while the last axis index (columns) changes slower. Using `C` or `F` in `.reshape()` means that the function is only reshaping the way that indexes are placed in the array, and not like data physically stored in the computer memory (memory layout). `A` means to read/write the elements in Fortran-like index order if `array` is Fortran contiguous in memory, meaning, in a sequencial and continuous manner without gaps between elements, or in C-like index order otherwise.

```pseudo
numpy.reshape(array, newshape, order = 'C')
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be edited in the ##Syntax section itself. @NelsonSanti What we can do is, go to the ## Syntax section above, modify that syntax by adding the order parameter as well. Then after the syntax, use bullet points to address the parameters. Example:

numpy.reshape(array, newshape, order = 'C')
  • array: Describe this
  • newshape: describe this
  • order: Describe this
    • C: describe
    • F: describe
    • A: descibe

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way a proper structure can be maintained

```pseudo
numpy.reshape(array, newshape, order = 'C')
```

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Codebyte Example


The following example creates an `ndarray` then uses `order` as an optional parameter for `.reshape()` to change its dimensions.

```py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```py
```codebyte/python

Comment on lines 82 to 100
This produces the following output:

```shell
[[10 20 30]
[40 50 60]]


[[10 20]
[30 40]
[50 60]]


[[10 50]
[40 30]
[20 60]]
```

> [!Note]
> The last output just reflects the natural behaviour from Fortran indexation order
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This produces the following output:
```shell
[[10 20 30]
[40 50 60]]
[[10 20]
[30 40]
[50 60]]
[[10 50]
[40 30]
[20 60]]
```
> [!Note]
> The last output just reflects the natural behaviour from Fortran indexation order

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codebyte examples are not to be accompanied by output blocks, so we can remove this

@NelsonSanti
Copy link
Contributor Author

Hello @mamtawardhani ,
All changes were made.
Can you please take a look?
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest-accepted Indicates the PR was approved, merged, and pertains to Hacktoberfest numpy NumPy entries status: review 1️⃣ completed status: waiting for author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants