- Notifications
You must be signed in to change notification settings - Fork128
Add N-Dimensional Array Creator snippet#260
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
e8f2b0fd623028e0b2e4c1adf94eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| title: N-Dimensional Array Creator | ||
| description: Creates an N-dimensional array filled with a single element. | ||
| author: Debanjan110d | ||
| tags: numpy, arrays, python, n-dimensional | ||
| --- | ||
| ```py | ||
| import numpy as np | ||
| def create_n_dimensional_array(n, fill_value=1): | ||
| """Creates an N-dimensional NumPy array filled with a given value.""" | ||
| return np.full([1] * n, fill_value) | ||
| # Usage example | ||
| if __name__ == '__main__': | ||
| array = create_n_dimensional_array(n=3, fill_value=10) | ||
| print(array) | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| title: N-Dimensional Array Creator | ||
| description: Creates an N-dimensional array filled with a single element. | ||
| author: Debanjan110d | ||
| tags: numpy, arrays, python, n-dimensional | ||
| --- | ||
| ```py | ||
| import numpy as np | ||
| def create_n_dimensional_array(n, fill_value=1): | ||
| """Creates an N-dimensional NumPy array filled with a given value.""" | ||
| return np.full([1] * n, fill_value) | ||
| # Example usage: | ||
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. the usage comment should be Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Ok | ||
| # arr = create_n_dimensional_array(3) | ||
Debanjan110d marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| # print(arr.ndim) # Output: 3 | ||
| ``` | ||