-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
glossary.html
1063 lines (868 loc) · 67.5 KB
/
glossary.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" data-content_root="./" data-theme="light">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Glossary — NumPy v2.3.dev0 Manual</title>
<script data-cfasync="false">
document.documentElement.dataset.mode = localStorage.getItem("mode") || "light";
document.documentElement.dataset.theme = localStorage.getItem("theme") || "light";
</script>
<!--
this give us a css class that will be invisible only if js is disabled
-->
<noscript>
<style>
.pst-js-only { display: none !important; }
</style>
</noscript>
<!-- Loaded before other Sphinx assets -->
<link href="_static/styles/theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />
<link href="_static/styles/pydata-sphinx-theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=a746c00c" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=eafc0fe6" />
<link rel="stylesheet" type="text/css" href="_static/plot_directive.css" />
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-design.min.css?v=95c83b7e" />
<link rel="stylesheet" type="text/css" href="_static/numpy.css?v=f033eccb" />
<!-- So that users can add custom icons -->
<script src="_static/scripts/fontawesome.js?digest=8878045cc6db502f8baf"></script>
<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
<script src="_static/documentation_options.js?v=cab28203"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
<script src="_static/copybutton.js?v=30646c52"></script>
<script src="_static/design-tabs.js?v=f930bc37"></script>
<script>DOCUMENTATION_OPTIONS.pagename = 'glossary';</script>
<script>
DOCUMENTATION_OPTIONS.theme_version = '0.16.1';
DOCUMENTATION_OPTIONS.theme_switcher_json_url = 'https://numpy.org/doc/_static/versions.json';
DOCUMENTATION_OPTIONS.theme_switcher_version_match = 'devdocs';
DOCUMENTATION_OPTIONS.show_version_warning_banner =
true;
</script>
<link rel="icon" href="_static/favicon.ico"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Release notes" href="release.html" />
<link rel="prev" title="Interoperability with NumPy" href="user/basics.interoperability.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
<meta name="docsearch:version" content="2.3.dev0" />
<meta name="docbuild:last-update" content="Dec 30, 2024"/>
</head>
<body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="light">
<div id="pst-skip-link" class="skip-link d-print-none"><a href="#main-content">Skip to main content</a></div>
<div id="pst-scroll-pixel-helper"></div>
<button type="button" class="btn rounded-pill" id="pst-back-to-top">
<i class="fa-solid fa-arrow-up"></i>Back to top</button>
<dialog id="pst-search-dialog">
<form class="bd-search d-flex align-items-center"
action="search.html"
method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search"
class="form-control"
name="q"
placeholder="Search the docs ..."
aria-label="Search the docs ..."
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"/>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
</form>
</dialog>
<div class="pst-async-banner-revealer d-none">
<aside id="bd-header-version-warning" class="d-none d-print-none" aria-label="Version warning"></aside>
</div>
<header class="bd-header navbar navbar-expand-lg bd-navbar d-print-none">
<div class="bd-header__inner bd-page-width">
<button class="pst-navbar-icon sidebar-toggle primary-toggle" aria-label="Site navigation">
<span class="fa-solid fa-bars"></span>
</button>
<div class="col-lg-3 navbar-header-items__start">
<div class="navbar-item">
<a class="navbar-brand logo" href="index.html">
<img src="_static/numpylogo.svg" class="logo__image only-light" alt="NumPy v2.3.dev0 Manual - Home"/>
<img src="_static/numpylogo_dark.svg" class="logo__image only-dark pst-js-only" alt="NumPy v2.3.dev0 Manual - Home"/>
</a></div>
</div>
<div class="col-lg-9 navbar-header-items">
<div class="me-auto navbar-header-items__center">
<div class="navbar-item">
<nav>
<ul class="bd-navbar-elements navbar-nav">
<li class="nav-item current active">
<a class="nav-link nav-internal" href="user/index.html">
User Guide
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="reference/index.html">
API reference
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="building/index.html">
Building from source
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="dev/index.html">
Development
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="release.html">
Release notes
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-external" href="https://numpy.org/numpy-tutorials/">
Learn
</a>
</li>
<li class="nav-item dropdown">
<button class="btn dropdown-toggle nav-item" type="button"
data-bs-toggle="dropdown" aria-expanded="false"
aria-controls="pst-nav-more-links">
More
</button>
<ul id="pst-nav-more-links" class="dropdown-menu">
<li class=" ">
<a class="nav-link dropdown-item nav-external" href="https://numpy.org/neps">
NEPs
</a>
</li>
</ul>
</li>
</ul>
</nav></div>
</div>
<div class="navbar-header-items__end">
<div class="navbar-item">
<button class="btn btn-sm pst-navbar-icon search-button search-button__button pst-js-only" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass fa-lg"></i>
</button></div>
<div class="navbar-item">
<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button pst-js-only" aria-label="Color mode" data-bs-title="Color mode" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="theme-switch fa-solid fa-sun fa-lg" data-mode="light" title="Light"></i>
<i class="theme-switch fa-solid fa-moon fa-lg" data-mode="dark" title="Dark"></i>
<i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto" title="System Settings"></i>
</button></div>
<div class="navbar-item">
<div class="version-switcher__container dropdown pst-js-only">
<button id="pst-version-switcher-button-2"
type="button"
class="version-switcher__button btn btn-sm dropdown-toggle"
data-bs-toggle="dropdown"
aria-haspopup="listbox"
aria-controls="pst-version-switcher-list-2"
aria-label="Version switcher list"
>
Choose version <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</button>
<div id="pst-version-switcher-list-2"
class="version-switcher__menu dropdown-menu list-group-flush py-0"
role="listbox" aria-labelledby="pst-version-switcher-button-2">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div></div>
<div class="navbar-item"><ul class="navbar-icon-links"
aria-label="Icon Links">
<li class="nav-item">
<a href="https://github.com/numpy/numpy" title="GitHub" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><i class="fa-brands fa-square-github fa-lg" aria-hidden="true"></i>
<span class="sr-only">GitHub</span></a>
</li>
</ul></div>
</div>
</div>
</div>
</header>
<div class="bd-container">
<div class="bd-container__inner bd-page-width">
<dialog id="pst-primary-sidebar-modal"></dialog>
<div id="pst-primary-sidebar" class="bd-sidebar-primary bd-sidebar">
<div class="sidebar-header-items sidebar-primary__section">
<div class="sidebar-header-items__center">
<div class="navbar-item">
<nav>
<ul class="bd-navbar-elements navbar-nav">
<li class="nav-item current active">
<a class="nav-link nav-internal" href="user/index.html">
User Guide
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="reference/index.html">
API reference
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="building/index.html">
Building from source
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="dev/index.html">
Development
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-internal" href="release.html">
Release notes
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-external" href="https://numpy.org/numpy-tutorials/">
Learn
</a>
</li>
<li class="nav-item ">
<a class="nav-link nav-external" href="https://numpy.org/neps">
NEPs
</a>
</li>
</ul>
</nav></div>
</div>
<div class="sidebar-header-items__end">
<div class="navbar-item">
<button class="btn btn-sm pst-navbar-icon search-button search-button__button pst-js-only" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass fa-lg"></i>
</button></div>
<div class="navbar-item">
<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button pst-js-only" aria-label="Color mode" data-bs-title="Color mode" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="theme-switch fa-solid fa-sun fa-lg" data-mode="light" title="Light"></i>
<i class="theme-switch fa-solid fa-moon fa-lg" data-mode="dark" title="Dark"></i>
<i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto" title="System Settings"></i>
</button></div>
<div class="navbar-item">
<div class="version-switcher__container dropdown pst-js-only">
<button id="pst-version-switcher-button-3"
type="button"
class="version-switcher__button btn btn-sm dropdown-toggle"
data-bs-toggle="dropdown"
aria-haspopup="listbox"
aria-controls="pst-version-switcher-list-3"
aria-label="Version switcher list"
>
Choose version <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</button>
<div id="pst-version-switcher-list-3"
class="version-switcher__menu dropdown-menu list-group-flush py-0"
role="listbox" aria-labelledby="pst-version-switcher-button-3">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div></div>
<div class="navbar-item"><ul class="navbar-icon-links"
aria-label="Icon Links">
<li class="nav-item">
<a href="https://github.com/numpy/numpy" title="GitHub" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><i class="fa-brands fa-square-github fa-lg" aria-hidden="true"></i>
<span class="sr-only">GitHub</span></a>
</li>
</ul></div>
</div>
</div>
<div class="sidebar-primary-items__start sidebar-primary__section">
<div class="sidebar-primary-item">
<nav class="bd-docs-nav bd-links"
aria-label="Section Navigation">
<p class="bd-links__title" role="heading" aria-level="1">Section Navigation</p>
<div class="bd-toc-item navbar-nav"><p aria-level="2" class="caption" role="heading"><span class="caption-text">Getting started</span></p>
<ul class="nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="user/whatisnumpy.html">What is NumPy?</a></li>
<li class="toctree-l1"><a class="reference external" href="https://numpy.org/install/">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="user/quickstart.html">NumPy quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="user/absolute_beginners.html">NumPy: the absolute basics for beginners</a></li>
</ul>
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Fundamentals and usage</span></p>
<ul class="nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="user/basics.html">NumPy fundamentals</a></li>
</ul>
<ul class="nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="user/numpy-for-matlab-users.html">NumPy for MATLAB users</a></li>
<li class="toctree-l1"><a class="reference external" href="https://numpy.org/numpy-tutorials/">NumPy tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="user/howtos_index.html">NumPy how-tos</a></li>
</ul>
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Advanced usage and interoperability</span></p>
<ul class="nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="user/c-info.html">Using NumPy C-API</a></li>
<li class="toctree-l1"><a class="reference internal" href="f2py/index.html">F2PY user guide and reference manual</a></li>
<li class="toctree-l1"><a class="reference internal" href="dev/underthehood.html">Under-the-hood documentation for developers</a></li>
<li class="toctree-l1"><a class="reference internal" href="user/basics.interoperability.html">Interoperability with NumPy</a></li>
</ul>
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Extras</span></p>
<ul class="current nav bd-sidenav">
<li class="toctree-l1 current active"><a class="current reference internal" href="#">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="release.html">Release notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="numpy_2_0_migration_guide.html">NumPy 2.0 migration guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="license.html">NumPy license</a></li>
</ul>
</div>
</nav></div>
</div>
<div class="sidebar-primary-items__end sidebar-primary__section">
<div class="sidebar-primary-item">
<div id="ethical-ad-placement"
class="flat"
data-ea-publisher="readthedocs"
data-ea-type="readthedocs-sidebar"
data-ea-manual="true">
</div></div>
</div>
</div>
<main id="main-content" class="bd-main" role="main">
<div class="bd-content">
<div class="bd-article-container">
<div class="bd-header-article d-print-none">
<div class="header-article-items header-article__inner">
<div class="header-article-items__start">
<div class="header-article-item">
<nav aria-label="Breadcrumb" class="d-print-none">
<ul class="bd-breadcrumbs">
<li class="breadcrumb-item breadcrumb-home">
<a href="index.html" class="nav-link" aria-label="Home">
<i class="fa-solid fa-home"></i>
</a>
</li>
<li class="breadcrumb-item"><a href="user/index.html" class="nav-link">NumPy user guide</a></li>
<li class="breadcrumb-item active" aria-current="page"><span class="ellipsis">Glossary</span></li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<div id="searchbox"></div>
<article class="bd-article">
<section id="glossary">
<h1>Glossary<a class="headerlink" href="#glossary" title="Link to this heading">#</a></h1>
<dl class="glossary">
<dt id="term-n">(<em class="xref py py-obj">n</em>,)<a class="headerlink" href="#term-n" title="Link to this term">#</a></dt><dd><p>A parenthesized number followed by a comma denotes a tuple with one
element. The trailing comma distinguishes a one-element tuple from a
parenthesized <code class="docutils literal notranslate"><span class="pre">n</span></code>.</p>
</dd>
<dt id="term-1">-1<a class="headerlink" href="#term-1" title="Link to this term">#</a></dt><dd><ul>
<li><p><strong>In a dimension entry</strong>, instructs NumPy to choose the length
that will keep the total number of array elements the same.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">12</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">shape</span>
<span class="go">(4, 3)</span>
</pre></div>
</div>
</li>
<li><p><strong>In an index</strong>, any negative value
<a class="reference external" href="https://docs.python.org/dev/faq/programming.html#what-s-a-negative-index">denotes</a>
indexing from the right.</p></li>
</ul>
</dd>
<dt id="term-.-.-.">…<a class="headerlink" href="#term-.-.-." title="Link to this term">#</a></dt><dd><p>An <a class="reference external" href="https://docs.python.org/3/library/constants.html#Ellipsis" title="(in Python v3.13)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Ellipsis</span></code></a>.</p>
<ul>
<li><p><strong>When indexing an array</strong>, shorthand that the missing axes, if they
exist, are full slices.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">24</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span><span class="p">[</span><span class="o">...</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span>
<span class="go">(2, 3, 4)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span><span class="p">[</span><span class="o">...</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span>
<span class="go">(2, 3)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="o">...</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span>
<span class="go">(3, 4)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="o">...</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span>
<span class="go">(3,)</span>
</pre></div>
</div>
<p>It can be used at most once; <code class="docutils literal notranslate"><span class="pre">a[...,0,...]</span></code> raises an <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#IndexError" title="(in Python v3.13)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IndexError</span></code></a>.</p>
</li>
<li><p><strong>In printouts</strong>, NumPy substitutes <code class="docutils literal notranslate"><span class="pre">...</span></code> for the middle elements of
large arrays. To see the entire array, use <a class="reference internal" href="reference/generated/numpy.printoptions.html#numpy.printoptions" title="numpy.printoptions"><code class="xref py py-obj docutils literal notranslate"><span class="pre">numpy.printoptions</span></code></a></p></li>
</ul>
</dd>
<dt id="term-0">:<a class="headerlink" href="#term-0" title="Link to this term">#</a></dt><dd><p>The Python <a class="reference external" href="https://docs.python.org/3/glossary.html#term-slice" title="(in Python v3.13)"><span>slice</span></a>
operator. In ndarrays, slicing can be applied to every
axis:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">24</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">a</span>
<span class="go">array([[[ 0, 1, 2, 3],</span>
<span class="go"> [ 4, 5, 6, 7],</span>
<span class="go"> [ 8, 9, 10, 11]],</span>
<span class="go"> [[12, 13, 14, 15],</span>
<span class="go"> [16, 17, 18, 19],</span>
<span class="go"> [20, 21, 22, 23]]])</span>
<span class="gp">>>> </span><span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">:,</span><span class="o">-</span><span class="mi">2</span><span class="p">:,:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="go">array([[[16, 17, 18],</span>
<span class="go"> [20, 21, 22]]])</span>
</pre></div>
</div>
<p>Trailing slices can be omitted:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">,:,:]</span>
<span class="go">array([[ True, True, True, True],</span>
<span class="go"> [ True, True, True, True],</span>
<span class="go"> [ True, True, True, True]])</span>
</pre></div>
</div>
<p>In contrast to Python, where slicing creates a copy, in NumPy slicing
creates a <a class="reference internal" href="#term-view"><span class="xref std std-term">view</span></a>.</p>
<p>For details, see <a class="reference internal" href="user/basics.indexing.html#combining-advanced-and-basic-indexing"><span class="std std-ref">Combining advanced and basic indexing</span></a>.</p>
</dd>
<dt id="term-2"><<a class="headerlink" href="#term-2" title="Link to this term">#</a></dt><dd><p>In a dtype declaration, indicates that the data is
<a class="reference internal" href="#term-little-endian"><span class="xref std std-term">little-endian</span></a> (the bracket is big on the right).</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dt</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="s1">'<f'</span><span class="p">)</span> <span class="c1"># little-endian single-precision float</span>
</pre></div>
</div>
</dd>
<dt id="term-3">><a class="headerlink" href="#term-3" title="Link to this term">#</a></dt><dd><p>In a dtype declaration, indicates that the data is
<a class="reference internal" href="#term-big-endian"><span class="xref std std-term">big-endian</span></a> (the bracket is big on the left).</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dt</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="s1">'>H'</span><span class="p">)</span> <span class="c1"># big-endian unsigned short</span>
</pre></div>
</div>
</dd>
<dt id="term-advanced-indexing">advanced indexing<a class="headerlink" href="#term-advanced-indexing" title="Link to this term">#</a></dt><dd><p>Rather than using a <a class="reference internal" href="reference/arrays.scalars.html"><span class="doc">scalar</span></a> or slice as
an index, an axis can be indexed with an array, providing fine-grained
selection. This is known as <a class="reference internal" href="user/basics.indexing.html#advanced-indexing"><span class="std std-ref">advanced indexing</span></a>
or “fancy indexing”.</p>
</dd>
<dt id="term-along-an-axis">along an axis<a class="headerlink" href="#term-along-an-axis" title="Link to this term">#</a></dt><dd><p>An operation <em class="xref py py-obj">along axis n</em> of array <code class="docutils literal notranslate"><span class="pre">a</span></code> behaves as if its argument
were an array of slices of <code class="docutils literal notranslate"><span class="pre">a</span></code> where each slice has a successive
index of axis <em class="xref py py-obj">n</em>.</p>
<p>For example, if <code class="docutils literal notranslate"><span class="pre">a</span></code> is a 3 x <em class="xref py py-obj">N</em> array, an operation along axis 0
behaves as if its argument were an array containing slices of each row:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">((</span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">,:],</span> <span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">,:],</span> <span class="n">a</span><span class="p">[</span><span class="mi">2</span><span class="p">,:]))</span>
</pre></div>
</div>
<p>To make it concrete, we can pick the operation to be the array-reversal
function <a class="reference internal" href="reference/generated/numpy.flip.html#numpy.flip" title="numpy.flip"><code class="xref py py-func docutils literal notranslate"><span class="pre">numpy.flip</span></code></a>, which accepts an <code class="docutils literal notranslate"><span class="pre">axis</span></code> argument. We
construct a 3 x 4 array <code class="docutils literal notranslate"><span class="pre">a</span></code>:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">12</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">a</span>
<span class="go">array([[ 0, 1, 2, 3],</span>
<span class="go"> [ 4, 5, 6, 7],</span>
<span class="go"> [ 8, 9, 10, 11]])</span>
</pre></div>
</div>
<p>Reversing along axis 0 (the row axis) yields</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">flip</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="go">array([[ 8, 9, 10, 11],</span>
<span class="go"> [ 4, 5, 6, 7],</span>
<span class="go"> [ 0, 1, 2, 3]])</span>
</pre></div>
</div>
<p>Recalling the definition of <em class="xref py py-obj">along an axis</em>, <code class="docutils literal notranslate"><span class="pre">flip</span></code> along axis 0 is
treating its argument as if it were</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">((</span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">,:],</span> <span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">,:],</span> <span class="n">a</span><span class="p">[</span><span class="mi">2</span><span class="p">,:]))</span>
<span class="go">array([[ 0, 1, 2, 3],</span>
<span class="go"> [ 4, 5, 6, 7],</span>
<span class="go"> [ 8, 9, 10, 11]])</span>
</pre></div>
</div>
<p>and the result of <code class="docutils literal notranslate"><span class="pre">np.flip(a,axis=0)</span></code> is to reverse the slices:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">((</span><span class="n">a</span><span class="p">[</span><span class="mi">2</span><span class="p">,:],</span><span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">,:],</span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">,:]))</span>
<span class="go">array([[ 8, 9, 10, 11],</span>
<span class="go"> [ 4, 5, 6, 7],</span>
<span class="go"> [ 0, 1, 2, 3]])</span>
</pre></div>
</div>
</dd>
<dt id="term-array">array<a class="headerlink" href="#term-array" title="Link to this term">#</a></dt><dd><p>Used synonymously in the NumPy docs with <a class="reference internal" href="#term-ndarray"><span class="xref std std-term">ndarray</span></a>.</p>
</dd>
<dt id="term-array_like">array_like<a class="headerlink" href="#term-array_like" title="Link to this term">#</a></dt><dd><p>Any <a class="reference internal" href="reference/arrays.scalars.html"><span class="doc">scalar</span></a> or
<a class="reference external" href="https://docs.python.org/3/glossary.html#term-sequence" title="(in Python v3.13)"><span>sequence</span></a>
that can be interpreted as an ndarray. In addition to ndarrays
and scalars this category includes lists (possibly nested and with
different element types) and tuples. Any argument accepted by
<a class="reference internal" href="reference/generated/numpy.array.html"><span class="doc">numpy.array</span></a>
is array_like.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="p">(</span><span class="mi">1</span><span class="o">+</span><span class="mi">1</span><span class="n">j</span><span class="p">,</span> <span class="mf">3.</span><span class="p">)])</span>
<span class="gp">>>> </span><span class="n">a</span>
<span class="go">array([[1.+0.j, 2.+0.j],</span>
<span class="go"> [0.+0.j, 0.+0.j],</span>
<span class="go"> [1.+1.j, 3.+0.j]])</span>
</pre></div>
</div>
</dd>
<dt id="term-array-scalar">array scalar<a class="headerlink" href="#term-array-scalar" title="Link to this term">#</a></dt><dd><p>An <a class="reference internal" href="reference/arrays.scalars.html"><span class="doc">array scalar</span></a> is an instance of the types/classes float32, float64,
etc.. For uniformity in handling operands, NumPy treats a scalar as
an array of zero dimension. In contrast, a 0-dimensional array is an <a class="reference internal" href="reference/arrays.ndarray.html"><span class="doc">ndarray</span></a> instance
containing precisely one value.</p>
</dd>
<dt id="term-axis">axis<a class="headerlink" href="#term-axis" title="Link to this term">#</a></dt><dd><p>Another term for an array dimension. Axes are numbered left to right;
axis 0 is the first element in the shape tuple.</p>
<p>In a two-dimensional vector, the elements of axis 0 are rows and the
elements of axis 1 are columns.</p>
<p>In higher dimensions, the picture changes. NumPy prints
higher-dimensional vectors as replications of row-by-column building
blocks, as in this three-dimensional vector:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">12</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">a</span>
<span class="go">array([[[ 0, 1, 2],</span>
<span class="go"> [ 3, 4, 5]],</span>
<span class="go"> [[ 6, 7, 8],</span>
<span class="go"> [ 9, 10, 11]]])</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">a</span></code> is depicted as a two-element array whose elements are 2x3 vectors.
From this point of view, rows and columns are the final two axes,
respectively, in any shape.</p>
<p>This rule helps you anticipate how a vector will be printed, and
conversely how to find the index of any of the printed elements. For
instance, in the example, the last two values of 8’s index must be 0 and
2. Since 8 appears in the second of the two 2x3’s, the first index must
be 1:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">2</span><span class="p">]</span>
<span class="go">8</span>
</pre></div>
</div>
<p>A convenient way to count dimensions in a printed vector is to
count <code class="docutils literal notranslate"><span class="pre">[</span></code> symbols after the open-parenthesis. This is
useful in distinguishing, say, a (1,2,3) shape from a (2,3) shape:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">a</span><span class="o">.</span><span class="n">ndim</span>
<span class="go">2</span>
<span class="gp">>>> </span><span class="n">a</span>
<span class="go">array([[0, 1, 2],</span>
<span class="go"> [3, 4, 5]])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">a</span><span class="o">.</span><span class="n">ndim</span>
<span class="go">3</span>
<span class="gp">>>> </span><span class="n">a</span>
<span class="go">array([[[0, 1, 2],</span>
<span class="go"> [3, 4, 5]]])</span>
</pre></div>
</div>
</dd>
<dt id="term-.base">.base<a class="headerlink" href="#term-.base" title="Link to this term">#</a></dt><dd><p>If an array does not own its memory, then its
<a class="reference internal" href="reference/generated/numpy.ndarray.base.html"><span class="doc">base</span></a> attribute returns
the object whose memory the array is referencing. That object may be
referencing the memory from still another object, so the owning object
may be <code class="docutils literal notranslate"><span class="pre">a.base.base.base...</span></code>. Some writers erroneously claim that
testing <code class="docutils literal notranslate"><span class="pre">base</span></code> determines if arrays are <a class="reference internal" href="#term-view"><span class="xref std std-term">view</span></a>s. For the
correct way, see <a class="reference internal" href="reference/generated/numpy.shares_memory.html#numpy.shares_memory" title="numpy.shares_memory"><code class="xref py py-func docutils literal notranslate"><span class="pre">numpy.shares_memory</span></code></a>.</p>
</dd>
<dt id="term-big-endian">big-endian<a class="headerlink" href="#term-big-endian" title="Link to this term">#</a></dt><dd><p>See <a class="reference external" href="https://en.wikipedia.org/wiki/Endianness">Endianness</a>.</p>
</dd>
<dt id="term-BLAS">BLAS<a class="headerlink" href="#term-BLAS" title="Link to this term">#</a></dt><dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms">Basic Linear Algebra Subprograms</a></p>
</dd>
<dt id="term-broadcast">broadcast<a class="headerlink" href="#term-broadcast" title="Link to this term">#</a></dt><dd><p><em>broadcasting</em> is NumPy’s ability to process ndarrays of
different sizes as if all were the same size.</p>
<p>It permits an elegant do-what-I-mean behavior where, for instance,
adding a scalar to a vector adds the scalar value to every element.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">a</span>
<span class="go">array([0, 1, 2])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">+</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span>
<span class="go">array([3, 4, 5])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">+</span> <span class="mi">3</span>
<span class="go">array([3, 4, 5])</span>
</pre></div>
</div>
<p>Ordinarily, vector operands must all be the same size, because NumPy
works element by element – for instance, <code class="docutils literal notranslate"><span class="pre">c</span> <span class="pre">=</span> <span class="pre">a</span> <span class="pre">*</span> <span class="pre">b</span></code> is</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">c</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">b</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span>
<span class="n">c</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">b</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">]</span>
<span class="o">...</span>
</pre></div>
</div>
<p>But in certain useful cases, NumPy can duplicate data along “missing”
axes or “too-short” dimensions so shapes will match. The duplication
costs no memory or time. For details, see
<a class="reference internal" href="user/basics.broadcasting.html"><span class="doc">Broadcasting.</span></a></p>
</dd>
<dt id="term-C-order">C order<a class="headerlink" href="#term-C-order" title="Link to this term">#</a></dt><dd><p>Same as <a class="reference internal" href="#term-row-major"><span class="xref std std-term">row-major</span></a>.</p>
</dd>
<dt id="term-casting">casting<a class="headerlink" href="#term-casting" title="Link to this term">#</a></dt><dd><p>The process of converting array data from one dtype to another. There
exist several casting modes, defined by the following casting rules:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">no</span></code>: The data types should not be cast at all.
Any mismatch in data types between the arrays will raise a
<em class="xref py py-obj">TypeError</em>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">equiv</span></code>: Only byte-order changes are allowed.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">safe</span></code>: Only casts that can preserve values are allowed. Upcasting
(e.g., from int to float) is allowed, but downcasting is not.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">same_kind</span></code>: The ‘same_kind’ casting option allows safe casts and
casts within a kind, like float64 to float32.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">unsafe</span></code>: any data conversions may be done.</p></li>
</ul>
</dd>
<dt id="term-column-major">column-major<a class="headerlink" href="#term-column-major" title="Link to this term">#</a></dt><dd><p>See <a class="reference external" href="https://en.wikipedia.org/wiki/Row-_and_column-major_order">Row- and column-major order</a>.</p>
</dd>
<dt id="term-contiguous">contiguous<a class="headerlink" href="#term-contiguous" title="Link to this term">#</a></dt><dd><p>An array is contiguous if:</p>
<ul class="simple">
<li><p>it occupies an unbroken block of memory, and</p></li>
<li><p>array elements with higher indexes occupy higher addresses (that
is, no <a class="reference internal" href="#term-stride"><span class="xref std std-term">stride</span></a> is negative).</p></li>
</ul>
<p>There are two types of proper-contiguous NumPy arrays:</p>
<ul class="simple">
<li><p>Fortran-contiguous arrays refer to data that is stored column-wise,
i.e. the indexing of data as stored in memory starts from the
lowest dimension;</p></li>
<li><p>C-contiguous, or simply contiguous arrays, refer to data that is
stored row-wise, i.e. the indexing of data as stored in memory
starts from the highest dimension.</p></li>
</ul>
<p>For one-dimensional arrays these notions coincide.</p>
<p>For example, a 2x2 array <code class="docutils literal notranslate"><span class="pre">A</span></code> is Fortran-contiguous if its elements are
stored in memory in the following order:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span> <span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span> <span class="n">A</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">]</span> <span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">]</span>
</pre></div>
</div>
<p>and C-contiguous if the order is as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span> <span class="n">A</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">]</span> <span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span> <span class="n">A</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">]</span>
</pre></div>
</div>
<p>To test whether an array is C-contiguous, use the <code class="docutils literal notranslate"><span class="pre">.flags.c_contiguous</span></code>
attribute of NumPy arrays. To test for Fortran contiguity, use the
<code class="docutils literal notranslate"><span class="pre">.flags.f_contiguous</span></code> attribute.</p>
</dd>
<dt id="term-copy">copy<a class="headerlink" href="#term-copy" title="Link to this term">#</a></dt><dd><p>See <a class="reference internal" href="#term-view"><span class="xref std std-term">view</span></a>.</p>
</dd>
<dt id="term-dimension">dimension<a class="headerlink" href="#term-dimension" title="Link to this term">#</a></dt><dd><p>See <a class="reference internal" href="#term-axis"><span class="xref std std-term">axis</span></a>.</p>
</dd>
<dt id="term-dtype">dtype<a class="headerlink" href="#term-dtype" title="Link to this term">#</a></dt><dd><p>The datatype describing the (identically typed) elements in an ndarray.
It can be changed to reinterpret the array contents. For details, see
<a class="reference internal" href="reference/arrays.dtypes.html"><span class="doc">Data type objects (dtype).</span></a></p>
</dd>
<dt id="term-fancy-indexing">fancy indexing<a class="headerlink" href="#term-fancy-indexing" title="Link to this term">#</a></dt><dd><p>Another term for <a class="reference internal" href="#term-advanced-indexing"><span class="xref std std-term">advanced indexing</span></a>.</p>
</dd>
<dt id="term-field">field<a class="headerlink" href="#term-field" title="Link to this term">#</a></dt><dd><p>In a <a class="reference internal" href="#term-structured-data-type"><span class="xref std std-term">structured data type</span></a>, each subtype is called a <em class="xref py py-obj">field</em>.
The <em class="xref py py-obj">field</em> has a name (a string), a type (any valid dtype), and
an optional <em class="xref py py-obj">title</em>. See <a class="reference internal" href="reference/arrays.dtypes.html#arrays-dtypes"><span class="std std-ref">Data type objects (dtype)</span></a>.</p>
</dd>
<dt id="term-Fortran-order">Fortran order<a class="headerlink" href="#term-Fortran-order" title="Link to this term">#</a></dt><dd><p>Same as <a class="reference internal" href="#term-column-major"><span class="xref std std-term">column-major</span></a>.</p>
</dd>
<dt id="term-flattened">flattened<a class="headerlink" href="#term-flattened" title="Link to this term">#</a></dt><dd><p>See <a class="reference internal" href="#term-ravel"><span class="xref std std-term">ravel</span></a>.</p>
</dd>
<dt id="term-homogeneous">homogeneous<a class="headerlink" href="#term-homogeneous" title="Link to this term">#</a></dt><dd><p>All elements of a homogeneous array have the same type. ndarrays, in
contrast to Python lists, are homogeneous. The type can be complicated,
as in a <a class="reference internal" href="#term-structured-array"><span class="xref std std-term">structured array</span></a>, but all elements have that type.</p>
<p>NumPy <a class="reference external" href="#term-object-array">object arrays</a>, which contain references to
Python objects, fill the role of heterogeneous arrays.</p>
</dd>
<dt id="term-itemsize">itemsize<a class="headerlink" href="#term-itemsize" title="Link to this term">#</a></dt><dd><p>The size of the dtype element in bytes.</p>
</dd>
<dt id="term-little-endian">little-endian<a class="headerlink" href="#term-little-endian" title="Link to this term">#</a></dt><dd><p>See <a class="reference external" href="https://en.wikipedia.org/wiki/Endianness">Endianness</a>.</p>
</dd>
<dt id="term-mask">mask<a class="headerlink" href="#term-mask" title="Link to this term">#</a></dt><dd><p>A boolean array used to select only certain elements for an operation:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">x</span>
<span class="go">array([0, 1, 2, 3, 4])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mask</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span> <span class="o">></span> <span class="mi">2</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">mask</span>
<span class="go">array([False, False, False, True, True])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span><span class="p">[</span><span class="n">mask</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
<span class="gp">>>> </span><span class="n">x</span>
<span class="go">array([ 0, 1, 2, -1, -1])</span>
</pre></div>
</div>
</dd>
<dt id="term-masked-array">masked array<a class="headerlink" href="#term-masked-array" title="Link to this term">#</a></dt><dd><p>Bad or missing data can be cleanly ignored by putting it in a masked
array, which has an internal boolean array indicating invalid
entries. Operations with masked arrays ignore these entries.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ma</span><span class="o">.</span><span class="n">masked_array</span><span class="p">([</span><span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">],</span> <span class="p">[</span><span class="kc">True</span><span class="p">,</span> <span class="kc">False</span><span class="p">,</span> <span class="kc">True</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">a</span>
<span class="go">masked_array(data=[--, 2.0, --],</span>
<span class="go"> mask=[ True, False, True],</span>
<span class="go"> fill_value=1e+20)</span>
<span class="gp">>>> </span><span class="n">a</span> <span class="o">+</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span>
<span class="go">masked_array(data=[--, 4.0, --],</span>
<span class="go"> mask=[ True, False, True],</span>
<span class="go"> fill_value=1e+20)</span>
</pre></div>
</div>
<p>For details, see <a class="reference internal" href="reference/maskedarray.html"><span class="doc">Masked arrays.</span></a></p>
</dd>
<dt id="term-matrix">matrix<a class="headerlink" href="#term-matrix" title="Link to this term">#</a></dt><dd><p>NumPy’s two-dimensional
<a class="reference internal" href="reference/generated/numpy.matrix.html"><span class="doc">matrix class</span></a>
should no longer be used; use regular ndarrays.</p>
</dd>
<dt id="term-ndarray">ndarray<a class="headerlink" href="#term-ndarray" title="Link to this term">#</a></dt><dd><p><a class="reference internal" href="reference/arrays.html"><span class="doc">NumPy’s basic structure</span></a>.</p>
</dd>
<dt id="term-object-array">object array<a class="headerlink" href="#term-object-array" title="Link to this term">#</a></dt><dd><p>An array whose dtype is <code class="docutils literal notranslate"><span class="pre">object</span></code>; that is, it contains references to
Python objects. Indexing the array dereferences the Python objects, so
unlike other ndarrays, an object array has the ability to hold
heterogeneous objects.</p>
</dd>
<dt id="term-ravel">ravel<a class="headerlink" href="#term-ravel" title="Link to this term">#</a></dt><dd><p><a class="reference internal" href="reference/generated/numpy.ravel.html"><span class="doc">numpy.ravel </span></a>
and <a class="reference internal" href="reference/generated/numpy.ndarray.flatten.html"><span class="doc">numpy.flatten </span></a>
both flatten an ndarray. <code class="docutils literal notranslate"><span class="pre">ravel</span></code> will return a view if possible;
<code class="docutils literal notranslate"><span class="pre">flatten</span></code> always returns a copy.</p>
<p>Flattening collapses a multidimensional array to a single dimension;
details of how this is done (for instance, whether <code class="docutils literal notranslate"><span class="pre">a[n+1]</span></code> should be
the next row or next column) are parameters.</p>
</dd>
<dt id="term-record-array">record array<a class="headerlink" href="#term-record-array" title="Link to this term">#</a></dt><dd><p>A <a class="reference internal" href="#term-structured-array"><span class="xref std std-term">structured array</span></a> with allowing access in an attribute style
(<code class="docutils literal notranslate"><span class="pre">a.field</span></code>) in addition to <code class="docutils literal notranslate"><span class="pre">a['field']</span></code>. For details, see
<a class="reference internal" href="reference/generated/numpy.recarray.html"><span class="doc">numpy.recarray.</span></a></p>
</dd>
<dt id="term-row-major">row-major<a class="headerlink" href="#term-row-major" title="Link to this term">#</a></dt><dd><p>See <a class="reference external" href="https://en.wikipedia.org/wiki/Row-_and_column-major_order">Row- and column-major order</a>.
NumPy creates arrays in row-major order by default.</p>
</dd>
<dt id="term-scalar">scalar<a class="headerlink" href="#term-scalar" title="Link to this term">#</a></dt><dd><p>In NumPy, usually a synonym for <a class="reference internal" href="#term-array-scalar"><span class="xref std std-term">array scalar</span></a>.</p>
</dd>
<dt id="term-shape">shape<a class="headerlink" href="#term-shape" title="Link to this term">#</a></dt><dd><p>A tuple showing the length of each dimension of an ndarray. The
length of the tuple itself is the number of dimensions
(<a class="reference internal" href="reference/generated/numpy.ndarray.ndim.html"><span class="doc">numpy.ndim</span></a>).
The product of the tuple elements is the number of elements in the
array. For details, see
<a class="reference internal" href="reference/generated/numpy.ndarray.shape.html"><span class="doc">numpy.ndarray.shape</span></a>.</p>
</dd>
<dt id="term-stride">stride<a class="headerlink" href="#term-stride" title="Link to this term">#</a></dt><dd><p>Physical memory is one-dimensional; strides provide a mechanism to map
a given index to an address in memory. For an N-dimensional array, its
<code class="docutils literal notranslate"><span class="pre">strides</span></code> attribute is an N-element tuple; advancing from index
<code class="docutils literal notranslate"><span class="pre">i</span></code> to index <code class="docutils literal notranslate"><span class="pre">i+1</span></code> on axis <code class="docutils literal notranslate"><span class="pre">n</span></code> means adding <code class="docutils literal notranslate"><span class="pre">a.strides[n]</span></code> bytes
to the address.</p>
<p>Strides are computed automatically from an array’s dtype and
shape, but can be directly specified using
<a class="reference internal" href="reference/generated/numpy.lib.stride_tricks.as_strided.html"><span class="doc">as_strided.</span></a></p>
<p>For details, see
<a class="reference internal" href="reference/generated/numpy.ndarray.strides.html"><span class="doc">numpy.ndarray.strides</span></a>.</p>
<p>To see how striding underlies the power of NumPy views, see
<a class="reference external" href="https://arxiv.org/pdf/1102.1523.pdf">The NumPy array: a structure for efficient numerical computation. </a></p>
</dd>
<dt id="term-structured-array">structured array<a class="headerlink" href="#term-structured-array" title="Link to this term">#</a></dt><dd><p>Array whose <a class="reference internal" href="#term-dtype"><span class="xref std std-term">dtype</span></a> is a <a class="reference internal" href="#term-structured-data-type"><span class="xref std std-term">structured data type</span></a>.</p>
</dd>
<dt id="term-structured-data-type">structured data type<a class="headerlink" href="#term-structured-data-type" title="Link to this term">#</a></dt><dd><p>Users can create arbitrarily complex <a class="reference internal" href="#term-dtype"><span class="xref std std-term">dtypes</span></a>
that can include other arrays and dtypes. These composite dtypes are called
<a class="reference internal" href="user/basics.rec.html"><span class="doc">structured data types.</span></a></p>
</dd>
<dt id="term-subarray">subarray<a class="headerlink" href="#term-subarray" title="Link to this term">#</a></dt><dd><p>An array nested in a <a class="reference internal" href="#term-structured-data-type"><span class="xref std std-term">structured data type</span></a>, as <code class="docutils literal notranslate"><span class="pre">b</span></code> is here:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dt</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">([(</span><span class="s1">'a'</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int32</span><span class="p">),</span> <span class="p">(</span><span class="s1">'b'</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">float32</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,))])</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">dt</span><span class="p">)</span>
<span class="go">array([(0, [0., 0., 0.]), (0, [0., 0., 0.]), (0, [0., 0., 0.])],</span>
<span class="go"> dtype=[('a', '<i4'), ('b', '<f4', (3,))])</span>
</pre></div>
</div>
</dd>
<dt id="term-subarray-data-type">subarray data type<a class="headerlink" href="#term-subarray-data-type" title="Link to this term">#</a></dt><dd><p>An element of a structured datatype that behaves like an ndarray.</p>
</dd>
<dt id="term-title">title<a class="headerlink" href="#term-title" title="Link to this term">#</a></dt><dd><p>An alias for a field name in a structured datatype.</p>
</dd>
<dt id="term-type">type<a class="headerlink" href="#term-type" title="Link to this term">#</a></dt><dd><p>In NumPy, usually a synonym for <a class="reference internal" href="#term-dtype"><span class="xref std std-term">dtype</span></a>. For the more general
Python meaning, <a class="reference external" href="https://docs.python.org/3/glossary.html#term-type" title="(in Python v3.13)"><span class="xref std std-term">see here.</span></a></p>
</dd>
<dt id="term-ufunc">ufunc<a class="headerlink" href="#term-ufunc" title="Link to this term">#</a></dt><dd><p>NumPy’s fast element-by-element computation (<a class="reference internal" href="#term-vectorization"><span class="xref std std-term">vectorization</span></a>)
gives a choice which function gets applied. The general term for the
function is <code class="docutils literal notranslate"><span class="pre">ufunc</span></code>, short for <code class="docutils literal notranslate"><span class="pre">universal</span> <span class="pre">function</span></code>. NumPy routines
have built-in ufuncs, but users can also
<a class="reference internal" href="reference/ufuncs.html"><span class="doc">write their own.</span></a></p>
</dd>
<dt id="term-vectorization">vectorization<a class="headerlink" href="#term-vectorization" title="Link to this term">#</a></dt><dd><p>NumPy hands off array processing to C, where looping and computation are
much faster than in Python. To exploit this, programmers using NumPy
eliminate Python loops in favor of array-to-array operations.
<a class="reference internal" href="#term-vectorization"><span class="xref std std-term">vectorization</span></a> can refer both to the C offloading and to
structuring NumPy code to leverage it.</p>
</dd>
<dt id="term-view">view<a class="headerlink" href="#term-view" title="Link to this term">#</a></dt><dd><p>Without touching underlying data, NumPy can make one array appear
to change its datatype and shape.</p>
<p>An array created this way is a <em class="xref py py-obj">view</em>, and NumPy often exploits the
performance gain of using a view versus making a new array.</p>
<p>A potential drawback is that writing to a view can alter the original
as well. If this is a problem, NumPy instead needs to create a
physically distinct array – a <a class="reference external" href="https://docs.python.org/3/library/copy.html#module-copy" title="(in Python v3.13)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">copy</span></code></a>.</p>
<p>Some NumPy routines always return views, some always return copies, some
may return one or the other, and for some the choice can be specified.
Responsibility for managing views and copies falls to the programmer.
<a class="reference internal" href="reference/generated/numpy.shares_memory.html#numpy.shares_memory" title="numpy.shares_memory"><code class="xref py py-func docutils literal notranslate"><span class="pre">numpy.shares_memory</span></code></a> will check whether <code class="docutils literal notranslate"><span class="pre">b</span></code> is a view of
<code class="docutils literal notranslate"><span class="pre">a</span></code>, but an exact answer isn’t always feasible, as the documentation
page explains.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">x</span>
<span class="go">array([0, 1, 2, 3, 4])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">y</span> <span class="o">=</span> <span class="n">x</span><span class="p">[::</span><span class="mi">2</span><span class="p">]</span>
<span class="gp">>>> </span><span class="n">y</span>
<span class="go">array([0, 2, 4])</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="mi">3</span> <span class="c1"># changing x changes y as well, since y is a view on x</span>
<span class="gp">>>> </span><span class="n">y</span>
<span class="go">array([3, 2, 4])</span>
</pre></div>
</div>
</dd>
</dl>
</section>
</article>
<footer class="prev-next-footer d-print-none">
<div class="prev-next-area">
<a class="left-prev"
href="user/basics.interoperability.html"
title="previous page">
<i class="fa-solid fa-angle-left"></i>
<div class="prev-next-info">
<p class="prev-next-subtitle">previous</p>
<p class="prev-next-title">Interoperability with NumPy</p>
</div>
</a>
<a class="right-next"
href="release.html"
title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">Release notes</p>
</div>
<i class="fa-solid fa-angle-right"></i>
</a>