Fundamentals and usage
These pages clarify the concepts, design decisions, and behavioral rules behind NumSharp - the .NET port of NumPy that targets 1-to-1 API and behavioral compatibility with NumPy 2.x. They are the NumSharp counterparts of NumPy's own NumPy fundamentals guide: one article per NumPy article, rewritten for C# and honest about where a .NET runtime forces NumSharp to diverge.
If you have written NumPy before, these pages are the fastest way to map that knowledge onto NDArray. If you have not, they are the place to build a mental model before reaching for the API reference.
The articles
| Article | What it covers | NumPy original |
|---|---|---|
| Array creation | The six ways to make an NDArray - from .NET sequences, intrinsic functions, joins, disk, raw bytes, and random |
basics.creation |
| Indexing on NDArray | Basic indexing (views), advanced indexing (copies), boolean masks, the flat iterator, and assignment | basics.indexing |
| I/O with NumSharp | The byte-exact .npy/.npz stack, text I/O (loadtxt/savetxt), and raw-binary I/O |
basics.io |
| Data types | Numeric and text descriptors, NumPy mappings, promotion, and the .NET-specific Decimal and Char types | basics.types |
| Broadcasting | How arrays of different shapes combine in arithmetic - the shape rules and the stride-0 mechanism | basics.broadcasting |
| Copies and views | Which operations share memory and which duplicate it, and how to tell | basics.copies |
| Strings, bytes and chararrays | Fixed-width S/U, variable-width StringDType, missing values, text computation, numpy.char and NDCharArray; how they differ from C# Char | basics.strings |
| Structured arrays | Why NumSharp does not implement record/structured dtypes, and the .NET-idiomatic alternatives | basics.rec |
| Universal functions (ufunc) basics | Elementwise ops, out=/where=/dtype=, broadcasting, casting, and reductions |
basics.ufuncs |
Data types and Broadcasting already have dedicated, in-depth NumSharp guides (Dtypes, Broadcasting); they are the NumSharp conversions of NumPy's data-types and broadcasting articles, so they are linked here rather than duplicated.
What "convert each NumPy article to a NumSharp one" means
NumSharp's goal is that ported NumPy code behaves identically. So each article follows its NumPy source closely - same concepts, same section order, the same worked examples - but:
- Code is C#, not Python.
np.zeros((2, 3)),arr["1:3, :2"],arr.astype(np.float64). Python slice literals (a[1:5:2]) become strings in C# (a["1:5:2"]) because C# has no slice syntax - see Indexing. - NumSharp's dtypes follow NumPy's model. Arrays can hold numbers, Unicode strings, byte strings or variable-width
StringDTypetext;DecimalandCharadd .NET-specific choices. Object, void and structured arrays, nativecomplex64storage and datetime/timedelta storage are not represented. Each article explains the relevant rules and alternatives. - Divergences are documented, never silent. Where NumSharp cannot match NumPy exactly (e.g. a C#
int[]is a strong array that wraps on downcast, where a Python list is weak and raises), the article flags it. Behavioral differences are gated in the test suite under theMisalignedcategory.
Where these fit among the other guides
The fundamentals articles are conceptual. When you want the exhaustive how-to, the neighbouring guides go deeper:
- NDArray - the anatomy of the array (storage, shape, strides, the view/copy rule).
- Getting & Setting Values - every accessor for reading and writing, with the conversion and write-through rules.
- Iterating & Enumerating -
flat,nditer, typed/unboxed iteration,.NETinterop. - NumPy Compliance & Compatibility - type promotion (NEP 50) and the broader 2.x parity story.
- Array API Standard - the array-API surface NumSharp implements.
Related reading
- NumPy fundamentals - the upstream guide these pages track.
- NumPy API Coverage & Support - which
np.*functions are implemented.