Guida all'uso di NumPy
Una panoramica completa e guida tecnica introduttiva a NumPy, che copre l'installazione, la manipolazione degli array, l'indicizzazione, la trasmissione e l'integrazione con C/C++.
Panoramica del corso
📚 Riepilogo del contenuto
Un'introduzione completa e un manuale tecnico su NumPy, che copre l'installazione, la manipolazione degli array, l'indicizzazione, la trasmissione (broadcasting) e l'integrazione con C/C++.
Padroneggia le basi del calcolo scientifico in Python con la guida ufficiale di NumPy.
Autore: La comunità NumPy
Ringraziamenti: Redatto dalla comunità NumPy
🎯 Obiettivi di apprendimento
- Definire NumPy e identificare il suo ruolo nell'ecosistema scientifico di Python.
- Spiegare perché NumPy è significativamente più veloce dei cicli standard di Python utilizzando il concetto di vettorizzazione.
- Eseguire comandi di installazione per diversi ambienti, inclusi Pip, Conda e Raspberry Pi.
- Identificare e interpretare gli attributi fondamentali
ndarraycomendim,shapeedtype. - Eseguire creazione e manipolazione di array usando funzioni come
linspace,reshape,vstackehstack. - Applicare operazioni elemento per elemento, funzioni universali (ufuncs) e risolutori di algebra lineare a insiemi di dati numerici.
- Gestire la precisione dei dati e mitigare gli errori di overflow utilizzando i tipi scalari di NumPy e gli strumenti di informazione (
iinfo,finfo). - Implementare l'ingresso flessibile dei dati dal disco usando
genfromtxtcon delimitatori personalizzati, intestazioni e selezioni di colonne. - Applicare le Regole Generali di Broadcasting per prevedere e controllare le interazioni tra array di forme diverse.
- Gestire i riferimenti alla memoria e evitare "insidie" nelle sottoclassi personalizzate di
ndarrayutilizzando l'attributo.base.
Lezioni 共 5 课时 · 预计 15.0h
Lezioni
Lesson
This lesson introduces NumPy as the foundational bridge between high-level Python applications and low-level hardware, focusing on the ndarray as a universal interface for scientific computing. Students will learn how the ndarray’s contiguous memory layout and homogeneous data structure enable high-performance, vectorized operations across the data science ecosystem.
This lesson introduces the NumPy ndarray as a memory-efficient, homogeneous alternative to Python lists, focusing on proper initialization and the performance benefits of contiguous memory. Students will learn to interpret core array attributes—such as shape, size, and data type—to understand how metadata defines the spatial geometry and memory footprint of numerical data.
This lesson covers precision management in NumPy, focusing on how fixed-size data types handle integer overflow and floating-point saturation. It also introduces robust data ingestion techniques using np.genfromtxt to handle irregular file formats and sanitize messy datasets.
This lesson explores the complexities of subclassing `numpy.ndarray`, focusing on the "Initialization Triad" and the critical role of the `__array_finalize__` hook in maintaining metadata. Students will learn to navigate the risks of behavioral fragility and identify when to choose subclassing for interoperability versus using composition for safer architectural design.
AI018: Extending NumPy with the C-API (Lesson 5) explores how to overcome performance bottlenecks like the interpreter tax and memory bloat by implementing high-performance C extensions. Students will learn to manage memory safely, utilize kernel fusion, and perform cache-aligned pointer arithmetic to optimize complex computational tasks.