{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 800100715151 Astronomide Veritabanları #\n", "\n", "## Ders - 00 Derse Giriş ##" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Doç. Dr. Özgür Baştürk
\n", "Ankara Üniversitesi, Astronomi ve Uzay Bilimleri Bölümü
\n", "obasturk at ankara.edu.tr
\n", "http://ozgur.astrotux.org" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Dersin İçeriği #\n", "\n", "* Ders 1.\tJupyter Defterleri ve Python’la Programlamaya Giriş\n", "* Ders 2.\tPandas Modülü ve Pandas'la Veri İşleme\n", "* Ders 3.\tPandas'la Veri İşleme -- İleri Konular\n", "* Ders 4.\tPython Betikleri Yardımıyla Astronomi Veritabanı ve Kataloglarının Sorgulanması\n", "* Ders 5.\tYapılandırılmış Sorgu Dili'ne (SQL) Giriş\n", "* Ders 6.\tAstronomi Veri Sorgulama Dili'ne (ADQL) Giriş\n", "* Ders 7.\tVeri Görselleştirme" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Dersin Amacı\n", "\n", "Bu ders Ankara Üniversitesi Fen Bilimleri, Astronomi ve Uzay Bilimleri Anabilim Dalı'nın bir Yüksek Lisans dersi olup, temel amacı öğrencilere astronomide kullanılan veritabanlarına modern yöntemlerle erişme, veritabanları ve kataloglarını sorgulama, veri çekme, bu veriyi analize hazır hale getirme (işleme), veriyi görselleştirme ve rapor oluşturmaya yönelik olarak bilgi vermeyi amaçlamaktadır. Öğrencilere bu amaçlarla kullanılan `numpy`, `scipy`, `pandas`, `astroquery`, `matplotlib` gibi Python modülleri, Yapılandırılmış Sorgulama Dili (Structured Query Language, SQL) ve Astronomi Veri Sorgulama Dili (Astronomical Data Language, ADQL) dilleri ile astronomide sık başvurulan veritabanları tanıtılacaktır. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Yöntem\n", "\n", "Astronomide veritabanlarına erişim, veri çekme, veri analizi, görselleştirme ve raporlaştırma işlemleri için neredeyse bir standart haline gelen `Python` programlama dilinin ve modüllerinin olanakları dersin amaçları doğrultusunda kullanılacaktır. Dersin temel yöntemi gelişmiş bir programlama dili olan Python'ın temel yapıları ve dış modüllerin fonksiyonları kullanılarak bilgisayar kodlarının geliştirilmesine ve kullanımına dayalıdır. Ayrıca Yapılandırılmış Sorgulama Dili (Structured Query Language, SQL) ve Astronomi Veri Sorgulama Dili (Astronomical Data Language, ADQL) dillerine de giriş yapılacak, ancak bu dillerin kullanımı için de büyük ölçüde ilgili Python modüllerinden faydalanılacaktır. Öğrenci, araştırma ilgisi ve alanı dahilinde kendi geliştireceği kodlarla temel konuları uygulamalı olarak öğrenecek, arasınav yerine geçecek küçük ödevlerle konuları pekiştirecek, final projesiyle de astronomide ilgi duyduğu bir alandaki bir veritabanı uygulaması geliştirecektir. \n", "\n", "Ders notları, ödevler ve final projesi için Juypter defterlerinden (notebook) yararlanılacak, ana platform olarak Jupyter Notebooks ve / veya Jupyter Lab platformu kullanılacaktır." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Dersin İşlenişi\n", "\n", "800100715151 Astronomide Veritabanları dersi 8 AKTS kredi ve haftada 3 saatlik (Salı günleri, 13:30-16:30) bir programdan oluşmaktadır. Dersin notlandırması\n", "\n", "* 1 Arasınav : 4 Kısa Ödev (%50)\n", "* 1 Final Projesi: (%50)\n", "\n", "üzerinden yapılacaktır. Final Projesi her bir öğrenciye özgü ve öncelikle ilgi duyduğu araştırma alanına odaklı olarak öğrenciyle birlikte seçilecek ve sınırları birlikte saptanacaktır." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Dersin-İçeriği)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 800100715151 Astronomide Veritabanları #\n", "\n", "## Ders - 01 Jupyter ve Python'a Giriş ##" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Jupyter ve Python'a Giriş #\n", "\n", "* [Jupyter Defteleri](#Jupyter-Defterleri)\n", "* [Jupyter'da Kod Çalıştırmak](#Jupyter'da-Kod-Çalıştırmak)\n", "* [Jupyter'da Metin Hücreleri](#Jupyter'da-Metin-Hücreleri)\n", "* [Jupyter'da Sihirli Sözcükler](#Jupyter'da-Sihirli-Sözcükler)\n", "* [Jupyter'da Hücre Silmek ve Eklemek](#Jupyter'da-Hücre-Silmek-ve-Eklemek)\n", "* [Jupyter'da Yardım Seçenekleri](#Jupyter'da-Yardım-Seçenekleri)\n", "* [Jupyter ve Çekirdekler](#Jupyter-ve-Çekirdekler)\n", "* [Kod Çıktılarıyla İşlemler](#Kod-Çıktılarıyla-İşlemler)\n", "* [Python, Numpy ve Scipy'a Giriş](#Python,-Numpy-ve-Scipy'a-Giriş)\n", " * [Numpy'a Giriş](#Numpy'a-Giriş)\n", " * [Dizi Oluşturma İşlemleri](#Dizi-Oluşturma-İşlemleri)\n", " * [İndeksleme ve Dizi Dilimleme](#İndeksleme-ve-Dizi-Dilimleme)\n", " * [Çok Boyutlu Dizilerde İndeksleme ve Dilimleme](#Çok-Boyutlu-Dizilerde-İndeksleme-ve-Dilimleme)\n", " * [Temel numpy metotları](#Temel-numpy-metotları)\n", " * [Dizi Kopyalama](#Dizi-Kopyalama)\n", " * [Diziler Üzerinde İşlemler](#Diziler-Üzerinde-İşlemler)\n", " * [Alıştırmalar](#Alıştırmalar)\n", "* [Ödev 0](#Ödev-0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Jupyter Defterleri #\n", "\n", "Jupyter temel olarak metin, görsel, kod (Python, R ve Julia başta olmak üzere çeşitli program dillerinde yazılmış), kod çıktısı ve işaretle dillerinin (html, latex) bir arada kullanılabildiği bir platformdur. Bu ders Jupyter platformu üzerinden işleneek olup, öğrencinin temel fonksiyonları biliyor olmasının yanı sıra bazı kısa yolları ve ileri düzey yapıları kullanabiliyor olması kendi yararına olacaktır. Jupyter hakkında daha geniş bilgiye [Jupyter sitesinden](https://jupyter.readthedocs.io/en/latest/content-quickstart.html) ulaşabilirsiniz. Jupyter ve Python'u kurmak için bu derste önerilen yöntem olan Anaconda üzerinden kurmak için [AST415 Astronomide Sayısal Çözümleme-I](http://ozgur.astrotux.org/tr/teaching/ast415-astronomide-sayisal-cozumleme/) [Ders 1. Unix ve Python'a Giriş](http://ozgur.astrotux.org/ast415/Ders_01/Ders01_Python_ve_UNIXe_Giris.pdf) 'in sonuna doğru görsellerle verilen anlatımdan yararlanabilirsiniz.\n", "\n", "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Jupyter'da Kod Çalıştırmak #\n", "\n", "Jupyter'la etkileşebileceğiniz iki temel yöntemden birincisi kod çalıştırmaktır. Bu nedenle Jupyter defterlerinin temel birimi olan hücrelerin (cell) varsayılan türü kod çalıştırmaya (Code cell) yöneliktir. Yapmanız gereken tek şey yeni (Insert --> Cell Below) ya da b kısayol tuşuna basarak bir hücre oluşturup, o hücrenin içerisinde kodunuzu yazmanızdır. Yeni oluşturulan bir Jupyter defteri zaten boş bir kod hücresiyle açılır. Bir kod hücresi içine istediğiniz uzunlukta kod yazabilirsiniz. Jupyter hücresinin başında yazdığınızı bir girdi (input) olduğunu gösteren In ifadesi ve yanında köşeli parantez içinde çalıştırıldığı vakit, çalıştırılan kaçıncı kod olduğnu gösteren bir tam sayı yer alır. Kodunuzu kod hücresi içinde yazdıktan sonra çalıştırmak için Run aracını () ve Cell --> Run Cells menü seçeneklerini kullanabileceğiniz gibi Ctrl+Enter seçeneği ile kodunuzu çalıştırıp o hücre içinde kalabilir, Alt+Enter tuş takımı ile kodunuzu çalıştırıp alta yeni bir hücre (kod hücresi açabilir ya da Shift+Enter seçeneği ile kodunuzu çalıştırıp varsa bir sonraki hücreyi seçebilirsiniz. Kodunuzu her çalıştırmanız sonrasında o kodun çalıştırılma sayısı (In [ ] ) bir artacaktır.\n", "\n", "Dikey atış problemini çözen bir Python kodu aşağıda örnek olarak verilmiştir." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1.2342\n" ] } ], "source": [ "v0 = 5 # Ilk hiz m/s\n", "t = 0.6 # zaman s\n", "g = 9.81 # yercekimi ivmesi m/s**2\n", "y = v0*t - 0.5*g*t**2\n", "print(y)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Kod, kod hücresine yazılırken; çalıştırıldığında çekirdete (Kernel) çalıştırılır. Çekirdeğe ilişkin işlemler Kernel menüsünden ya da araç çubuğundaki , gibi butonlarla çalıştırılabilir, dudurulabilir ya da yeniden tüm çekirdek yeniden başlatılabilir." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Jupyter'da Metin Hücreleri #\n", "\n", "Jupyter'da herhangi bir metin yazmak için hücreyi tıklayarak ya da hücrenin içine girilmişse ESC tuşuyla hücre seçilmelidir. Aktif bir hücre yeşil renkte bir çerçeveyle, seçili bir hücre ise mavi renkte bir çerçeveyle çevrilidir. Hücre seçildikten sonra türü istenirse Araç Çubuğu'ndaki drop-down menüden Markdown seçeneği seçilerek, istenirse de kısaca m tuşuna basılarak metin moduna dönüştürülür. Aynı şekilde bir hücreyi kod hücresine dönüştürmek istediğinizde araç çubuğundaki menüyü kullanabileceğiniz gibi y kısayol tuşundan da faydalanabilirsiniz. Bu durumda kod satırlarındaki In [ ] ifadesi hücre başında yer almaz. Şu ana kadar bu Jupyter defterinin tüm metin hücreleri bu şekilde oluşturulmuştur. Örnek olarak inceleyebilirsiniz.\n", "\n", "Metin hücrelerinde latex ve html işaretleme dillerini kullanablirsiniz. Dikey atış kodu örneğindeki formül\n", "\n", "$$ y = V_0 t - \\frac{1}{2} g t^2 $$\n", "\n", "ifadesi ile verilebilir. $ işareti satır içinde latex ifadesi kulllanmak, $$ ise yazılan latex ifadesini yeni bir satırın ortasına almak için kullanılabilir.\n", "\n", "Ayrıca metinlerinizde html etiketlerini (tag) kullanarak bold, italik, altı çizili metinler yazabilir, metinlerinize link verebilir ya da renklendirebilirsiniz!\n", "\n", "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Jupyter'da Sihirli Sözcükler #" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Çizdiğiniz grafikleri Jupyter defterinizde göstermek ve .py uzantılı dış programları çalıştırmak gibi bu derste sıkça ihtiyaç duyacağınız bazı aksiyonlar için Jupyter'da \"sihirli sözcükler\" (magic words) adı verilen yapılardan yararlanmanız gerekecektir. Bir örnek aşağıda verilmektedir." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "/* global mpl */\n", "window.mpl = {};\n", "\n", "mpl.get_websocket_type = function () {\n", " if (typeof WebSocket !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof MozWebSocket !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert(\n", " 'Your browser does not have WebSocket support. ' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.'\n", " );\n", " }\n", "};\n", "\n", "mpl.figure = function (figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = this.ws.binaryType !== undefined;\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById('mpl-warnings');\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent =\n", " 'This browser does not support binary websocket messages. ' +\n", " 'Performance may be slow.';\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = document.createElement('div');\n", " this.root.setAttribute('style', 'display: inline-block');\n", " this._root_extra_style(this.root);\n", "\n", " parent_element.appendChild(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message('supports_binary', { value: fig.supports_binary });\n", " fig.send_message('send_image_mode', {});\n", " if (fig.ratio !== 1) {\n", " fig.send_message('set_device_pixel_ratio', {\n", " device_pixel_ratio: fig.ratio,\n", " });\n", " }\n", " fig.send_message('refresh', {});\n", " };\n", "\n", " this.imageObj.onload = function () {\n", " if (fig.image_mode === 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function () {\n", " fig.ws.close();\n", " };\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "};\n", "\n", "mpl.figure.prototype._init_header = function () {\n", " var titlebar = document.createElement('div');\n", " titlebar.classList =\n", " 'ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix';\n", " var titletext = document.createElement('div');\n", " titletext.classList = 'ui-dialog-title';\n", " titletext.setAttribute(\n", " 'style',\n", " 'width: 100%; text-align: center; padding: 3px;'\n", " );\n", " titlebar.appendChild(titletext);\n", " this.root.appendChild(titlebar);\n", " this.header = titletext;\n", "};\n", "\n", "mpl.figure.prototype._canvas_extra_style = function (_canvas_div) {};\n", "\n", "mpl.figure.prototype._root_extra_style = function (_canvas_div) {};\n", "\n", "mpl.figure.prototype._init_canvas = function () {\n", " var fig = this;\n", "\n", " var canvas_div = (this.canvas_div = document.createElement('div'));\n", " canvas_div.setAttribute(\n", " 'style',\n", " 'border: 1px solid #ddd;' +\n", " 'box-sizing: content-box;' +\n", " 'clear: both;' +\n", " 'min-height: 1px;' +\n", " 'min-width: 1px;' +\n", " 'outline: 0;' +\n", " 'overflow: hidden;' +\n", " 'position: relative;' +\n", " 'resize: both;'\n", " );\n", "\n", " function on_keyboard_event_closure(name) {\n", " return function (event) {\n", " return fig.key_event(event, name);\n", " };\n", " }\n", "\n", " canvas_div.addEventListener(\n", " 'keydown',\n", " on_keyboard_event_closure('key_press')\n", " );\n", " canvas_div.addEventListener(\n", " 'keyup',\n", " on_keyboard_event_closure('key_release')\n", " );\n", "\n", " this._canvas_extra_style(canvas_div);\n", " this.root.appendChild(canvas_div);\n", "\n", " var canvas = (this.canvas = document.createElement('canvas'));\n", " canvas.classList.add('mpl-canvas');\n", " canvas.setAttribute('style', 'box-sizing: content-box;');\n", "\n", " this.context = canvas.getContext('2d');\n", "\n", " var backingStore =\n", " this.context.backingStorePixelRatio ||\n", " this.context.webkitBackingStorePixelRatio ||\n", " this.context.mozBackingStorePixelRatio ||\n", " this.context.msBackingStorePixelRatio ||\n", " this.context.oBackingStorePixelRatio ||\n", " this.context.backingStorePixelRatio ||\n", " 1;\n", "\n", " this.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband_canvas = (this.rubberband_canvas = document.createElement(\n", " 'canvas'\n", " ));\n", " rubberband_canvas.setAttribute(\n", " 'style',\n", " 'box-sizing: content-box; position: absolute; left: 0; top: 0; z-index: 1;'\n", " );\n", "\n", " // Apply a ponyfill if ResizeObserver is not implemented by browser.\n", " if (this.ResizeObserver === undefined) {\n", " if (window.ResizeObserver !== undefined) {\n", " this.ResizeObserver = window.ResizeObserver;\n", " } else {\n", " var obs = _JSXTOOLS_RESIZE_OBSERVER({});\n", " this.ResizeObserver = obs.ResizeObserver;\n", " }\n", " }\n", "\n", " this.resizeObserverInstance = new this.ResizeObserver(function (entries) {\n", " var nentries = entries.length;\n", " for (var i = 0; i < nentries; i++) {\n", " var entry = entries[i];\n", " var width, height;\n", " if (entry.contentBoxSize) {\n", " if (entry.contentBoxSize instanceof Array) {\n", " // Chrome 84 implements new version of spec.\n", " width = entry.contentBoxSize[0].inlineSize;\n", " height = entry.contentBoxSize[0].blockSize;\n", " } else {\n", " // Firefox implements old version of spec.\n", " width = entry.contentBoxSize.inlineSize;\n", " height = entry.contentBoxSize.blockSize;\n", " }\n", " } else {\n", " // Chrome <84 implements even older version of spec.\n", " width = entry.contentRect.width;\n", " height = entry.contentRect.height;\n", " }\n", "\n", " // Keep the size of the canvas and rubber band canvas in sync with\n", " // the canvas container.\n", " if (entry.devicePixelContentBoxSize) {\n", " // Chrome 84 implements new version of spec.\n", " canvas.setAttribute(\n", " 'width',\n", " entry.devicePixelContentBoxSize[0].inlineSize\n", " );\n", " canvas.setAttribute(\n", " 'height',\n", " entry.devicePixelContentBoxSize[0].blockSize\n", " );\n", " } else {\n", " canvas.setAttribute('width', width * fig.ratio);\n", " canvas.setAttribute('height', height * fig.ratio);\n", " }\n", " canvas.setAttribute(\n", " 'style',\n", " 'width: ' + width + 'px; height: ' + height + 'px;'\n", " );\n", "\n", " rubberband_canvas.setAttribute('width', width);\n", " rubberband_canvas.setAttribute('height', height);\n", "\n", " // And update the size in Python. We ignore the initial 0/0 size\n", " // that occurs as the element is placed into the DOM, which should\n", " // otherwise not happen due to the minimum size styling.\n", " if (fig.ws.readyState == 1 && width != 0 && height != 0) {\n", " fig.request_resize(width, height);\n", " }\n", " }\n", " });\n", " this.resizeObserverInstance.observe(canvas_div);\n", "\n", " function on_mouse_event_closure(name) {\n", " return function (event) {\n", " return fig.mouse_event(event, name);\n", " };\n", " }\n", "\n", " rubberband_canvas.addEventListener(\n", " 'mousedown',\n", " on_mouse_event_closure('button_press')\n", " );\n", " rubberband_canvas.addEventListener(\n", " 'mouseup',\n", " on_mouse_event_closure('button_release')\n", " );\n", " rubberband_canvas.addEventListener(\n", " 'dblclick',\n", " on_mouse_event_closure('dblclick')\n", " );\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband_canvas.addEventListener(\n", " 'mousemove',\n", " on_mouse_event_closure('motion_notify')\n", " );\n", "\n", " rubberband_canvas.addEventListener(\n", " 'mouseenter',\n", " on_mouse_event_closure('figure_enter')\n", " );\n", " rubberband_canvas.addEventListener(\n", " 'mouseleave',\n", " on_mouse_event_closure('figure_leave')\n", " );\n", "\n", " canvas_div.addEventListener('wheel', function (event) {\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " on_mouse_event_closure('scroll')(event);\n", " });\n", "\n", " canvas_div.appendChild(canvas);\n", " canvas_div.appendChild(rubberband_canvas);\n", "\n", " this.rubberband_context = rubberband_canvas.getContext('2d');\n", " this.rubberband_context.strokeStyle = '#000000';\n", "\n", " this._resize_canvas = function (width, height, forward) {\n", " if (forward) {\n", " canvas_div.style.width = width + 'px';\n", " canvas_div.style.height = height + 'px';\n", " }\n", " };\n", "\n", " // Disable right mouse context menu.\n", " this.rubberband_canvas.addEventListener('contextmenu', function (_e) {\n", " event.preventDefault();\n", " return false;\n", " });\n", "\n", " function set_focus() {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "};\n", "\n", "mpl.figure.prototype._init_toolbar = function () {\n", " var fig = this;\n", "\n", " var toolbar = document.createElement('div');\n", " toolbar.classList = 'mpl-toolbar';\n", " this.root.appendChild(toolbar);\n", "\n", " function on_click_closure(name) {\n", " return function (_event) {\n", " return fig.toolbar_button_onclick(name);\n", " };\n", " }\n", "\n", " function on_mouseover_closure(tooltip) {\n", " return function (event) {\n", " if (!event.currentTarget.disabled) {\n", " return fig.toolbar_button_onmouseover(tooltip);\n", " }\n", " };\n", " }\n", "\n", " fig.buttons = {};\n", " var buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'mpl-button-group';\n", " for (var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " /* Instead of a spacer, we start a new button group. */\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", " buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'mpl-button-group';\n", " continue;\n", " }\n", "\n", " var button = (fig.buttons[name] = document.createElement('button'));\n", " button.classList = 'mpl-widget';\n", " button.setAttribute('role', 'button');\n", " button.setAttribute('aria-disabled', 'false');\n", " button.addEventListener('click', on_click_closure(method_name));\n", " button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n", "\n", " var icon_img = document.createElement('img');\n", " icon_img.src = '_images/' + image + '.png';\n", " icon_img.srcset = '_images/' + image + '_large.png 2x';\n", " icon_img.alt = tooltip;\n", " button.appendChild(icon_img);\n", "\n", " buttonGroup.appendChild(button);\n", " }\n", "\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", "\n", " var fmt_picker = document.createElement('select');\n", " fmt_picker.classList = 'mpl-widget';\n", " toolbar.appendChild(fmt_picker);\n", " this.format_dropdown = fmt_picker;\n", "\n", " for (var ind in mpl.extensions) {\n", " var fmt = mpl.extensions[ind];\n", " var option = document.createElement('option');\n", " option.selected = fmt === mpl.default_extension;\n", " option.innerHTML = fmt;\n", " fmt_picker.appendChild(option);\n", " }\n", "\n", " var status_bar = document.createElement('span');\n", " status_bar.classList = 'mpl-message';\n", " toolbar.appendChild(status_bar);\n", " this.message = status_bar;\n", "};\n", "\n", "mpl.figure.prototype.request_resize = function (x_pixels, y_pixels) {\n", " // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n", " // which will in turn request a refresh of the image.\n", " this.send_message('resize', { width: x_pixels, height: y_pixels });\n", "};\n", "\n", "mpl.figure.prototype.send_message = function (type, properties) {\n", " properties['type'] = type;\n", " properties['figure_id'] = this.id;\n", " this.ws.send(JSON.stringify(properties));\n", "};\n", "\n", "mpl.figure.prototype.send_draw_message = function () {\n", " if (!this.waiting) {\n", " this.waiting = true;\n", " this.ws.send(JSON.stringify({ type: 'draw', figure_id: this.id }));\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_save = function (fig, _msg) {\n", " var format_dropdown = fig.format_dropdown;\n", " var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n", " fig.ondownload(fig, format);\n", "};\n", "\n", "mpl.figure.prototype.handle_resize = function (fig, msg) {\n", " var size = msg['size'];\n", " if (size[0] !== fig.canvas.width || size[1] !== fig.canvas.height) {\n", " fig._resize_canvas(size[0], size[1], msg['forward']);\n", " fig.send_message('refresh', {});\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_rubberband = function (fig, msg) {\n", " var x0 = msg['x0'] / fig.ratio;\n", " var y0 = (fig.canvas.height - msg['y0']) / fig.ratio;\n", " var x1 = msg['x1'] / fig.ratio;\n", " var y1 = (fig.canvas.height - msg['y1']) / fig.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", " y1 = Math.floor(y1) + 0.5;\n", " var min_x = Math.min(x0, x1);\n", " var min_y = Math.min(y0, y1);\n", " var width = Math.abs(x1 - x0);\n", " var height = Math.abs(y1 - y0);\n", "\n", " fig.rubberband_context.clearRect(\n", " 0,\n", " 0,\n", " fig.canvas.width / fig.ratio,\n", " fig.canvas.height / fig.ratio\n", " );\n", "\n", " fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n", "};\n", "\n", "mpl.figure.prototype.handle_figure_label = function (fig, msg) {\n", " // Updates the figure title.\n", " fig.header.textContent = msg['label'];\n", "};\n", "\n", "mpl.figure.prototype.handle_cursor = function (fig, msg) {\n", " fig.rubberband_canvas.style.cursor = msg['cursor'];\n", "};\n", "\n", "mpl.figure.prototype.handle_message = function (fig, msg) {\n", " fig.message.textContent = msg['message'];\n", "};\n", "\n", "mpl.figure.prototype.handle_draw = function (fig, _msg) {\n", " // Request the server to send over a new figure.\n", " fig.send_draw_message();\n", "};\n", "\n", "mpl.figure.prototype.handle_image_mode = function (fig, msg) {\n", " fig.image_mode = msg['mode'];\n", "};\n", "\n", "mpl.figure.prototype.handle_history_buttons = function (fig, msg) {\n", " for (var key in msg) {\n", " if (!(key in fig.buttons)) {\n", " continue;\n", " }\n", " fig.buttons[key].disabled = !msg[key];\n", " fig.buttons[key].setAttribute('aria-disabled', !msg[key]);\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_navigate_mode = function (fig, msg) {\n", " if (msg['mode'] === 'PAN') {\n", " fig.buttons['Pan'].classList.add('active');\n", " fig.buttons['Zoom'].classList.remove('active');\n", " } else if (msg['mode'] === 'ZOOM') {\n", " fig.buttons['Pan'].classList.remove('active');\n", " fig.buttons['Zoom'].classList.add('active');\n", " } else {\n", " fig.buttons['Pan'].classList.remove('active');\n", " fig.buttons['Zoom'].classList.remove('active');\n", " }\n", "};\n", "\n", "mpl.figure.prototype.updated_canvas_event = function () {\n", " // Called whenever the canvas gets updated.\n", " this.send_message('ack', {});\n", "};\n", "\n", "// A function to construct a web socket function for onmessage handling.\n", "// Called in the figure constructor.\n", "mpl.figure.prototype._make_on_message_function = function (fig) {\n", " return function socket_on_message(evt) {\n", " if (evt.data instanceof Blob) {\n", " var img = evt.data;\n", " if (img.type !== 'image/png') {\n", " /* FIXME: We get \"Resource interpreted as Image but\n", " * transferred with MIME type text/plain:\" errors on\n", " * Chrome. But how to set the MIME type? It doesn't seem\n", " * to be part of the websocket stream */\n", " img.type = 'image/png';\n", " }\n", "\n", " /* Free the memory for the previous frames */\n", " if (fig.imageObj.src) {\n", " (window.URL || window.webkitURL).revokeObjectURL(\n", " fig.imageObj.src\n", " );\n", " }\n", "\n", " fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n", " img\n", " );\n", " fig.updated_canvas_event();\n", " fig.waiting = false;\n", " return;\n", " } else if (\n", " typeof evt.data === 'string' &&\n", " evt.data.slice(0, 21) === 'data:image/png;base64'\n", " ) {\n", " fig.imageObj.src = evt.data;\n", " fig.updated_canvas_event();\n", " fig.waiting = false;\n", " return;\n", " }\n", "\n", " var msg = JSON.parse(evt.data);\n", " var msg_type = msg['type'];\n", "\n", " // Call the \"handle_{type}\" callback, which takes\n", " // the figure and JSON message as its only arguments.\n", " try {\n", " var callback = fig['handle_' + msg_type];\n", " } catch (e) {\n", " console.log(\n", " \"No handler for the '\" + msg_type + \"' message type: \",\n", " msg\n", " );\n", " return;\n", " }\n", "\n", " if (callback) {\n", " try {\n", " // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n", " callback(fig, msg);\n", " } catch (e) {\n", " console.log(\n", " \"Exception inside the 'handler_\" + msg_type + \"' callback:\",\n", " e,\n", " e.stack,\n", " msg\n", " );\n", " }\n", " }\n", " };\n", "};\n", "\n", "// from https://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n", "mpl.findpos = function (e) {\n", " //this section is from http://www.quirksmode.org/js/events_properties.html\n", " var targ;\n", " if (!e) {\n", " e = window.event;\n", " }\n", " if (e.target) {\n", " targ = e.target;\n", " } else if (e.srcElement) {\n", " targ = e.srcElement;\n", " }\n", " if (targ.nodeType === 3) {\n", " // defeat Safari bug\n", " targ = targ.parentNode;\n", " }\n", "\n", " // pageX,Y are the mouse positions relative to the document\n", " var boundingRect = targ.getBoundingClientRect();\n", " var x = e.pageX - (boundingRect.left + document.body.scrollLeft);\n", " var y = e.pageY - (boundingRect.top + document.body.scrollTop);\n", "\n", " return { x: x, y: y };\n", "};\n", "\n", "/*\n", " * return a copy of an object with only non-object keys\n", " * we need this to avoid circular references\n", " * https://stackoverflow.com/a/24161582/3208463\n", " */\n", "function simpleKeys(original) {\n", " return Object.keys(original).reduce(function (obj, key) {\n", " if (typeof original[key] !== 'object') {\n", " obj[key] = original[key];\n", " }\n", " return obj;\n", " }, {});\n", "}\n", "\n", "mpl.figure.prototype.mouse_event = function (event, name) {\n", " var canvas_pos = mpl.findpos(event);\n", "\n", " if (name === 'button_press') {\n", " this.canvas.focus();\n", " this.canvas_div.focus();\n", " }\n", "\n", " var x = canvas_pos.x * this.ratio;\n", " var y = canvas_pos.y * this.ratio;\n", "\n", " this.send_message(name, {\n", " x: x,\n", " y: y,\n", " button: event.button,\n", " step: event.step,\n", " guiEvent: simpleKeys(event),\n", " });\n", "\n", " /* This prevents the web browser from automatically changing to\n", " * the text insertion cursor when the button is pressed. We want\n", " * to control all of the cursor setting manually through the\n", " * 'cursor' event from matplotlib */\n", " event.preventDefault();\n", " return false;\n", "};\n", "\n", "mpl.figure.prototype._key_event_extra = function (_event, _name) {\n", " // Handle any extra behaviour associated with a key event\n", "};\n", "\n", "mpl.figure.prototype.key_event = function (event, name) {\n", " // Prevent repeat events\n", " if (name === 'key_press') {\n", " if (event.key === this._key) {\n", " return;\n", " } else {\n", " this._key = event.key;\n", " }\n", " }\n", " if (name === 'key_release') {\n", " this._key = null;\n", " }\n", "\n", " var value = '';\n", " if (event.ctrlKey && event.key !== 'Control') {\n", " value += 'ctrl+';\n", " }\n", " else if (event.altKey && event.key !== 'Alt') {\n", " value += 'alt+';\n", " }\n", " else if (event.shiftKey && event.key !== 'Shift') {\n", " value += 'shift+';\n", " }\n", "\n", " value += 'k' + event.key;\n", "\n", " this._key_event_extra(event, name);\n", "\n", " this.send_message(name, { key: value, guiEvent: simpleKeys(event) });\n", " return false;\n", "};\n", "\n", "mpl.figure.prototype.toolbar_button_onclick = function (name) {\n", " if (name === 'download') {\n", " this.handle_save(this, null);\n", " } else {\n", " this.send_message('toolbar_button', { name: name });\n", " }\n", "};\n", "\n", "mpl.figure.prototype.toolbar_button_onmouseover = function (tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", "\n", "///////////////// REMAINING CONTENT GENERATED BY embed_js.py /////////////////\n", "// prettier-ignore\n", "var _JSXTOOLS_RESIZE_OBSERVER=function(A){var t,i=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakMap,o=new Set;function s(e){if(!(this instanceof s))throw new TypeError(\"Constructor requires 'new' operator\");i.set(this,e)}function h(){throw new TypeError(\"Function is not a constructor\")}function c(e,t,i,n){e=0 in arguments?Number(arguments[0]):0,t=1 in arguments?Number(arguments[1]):0,i=2 in arguments?Number(arguments[2]):0,n=3 in arguments?Number(arguments[3]):0,this.right=(this.x=this.left=e)+(this.width=i),this.bottom=(this.y=this.top=t)+(this.height=n),Object.freeze(this)}function d(){t=requestAnimationFrame(d);var s=new WeakMap,p=new Set;o.forEach((function(t){r.get(t).forEach((function(i){var r=t instanceof window.SVGElement,o=a.get(t),d=r?0:parseFloat(o.paddingTop),f=r?0:parseFloat(o.paddingRight),l=r?0:parseFloat(o.paddingBottom),u=r?0:parseFloat(o.paddingLeft),g=r?0:parseFloat(o.borderTopWidth),m=r?0:parseFloat(o.borderRightWidth),w=r?0:parseFloat(o.borderBottomWidth),b=u+f,F=d+l,v=(r?0:parseFloat(o.borderLeftWidth))+m,W=g+w,y=r?0:t.offsetHeight-W-t.clientHeight,E=r?0:t.offsetWidth-v-t.clientWidth,R=b+v,z=F+W,M=r?t.width:parseFloat(o.width)-R-E,O=r?t.height:parseFloat(o.height)-z-y;if(n.has(t)){var k=n.get(t);if(k[0]===M&&k[1]===O)return}n.set(t,[M,O]);var S=Object.create(h.prototype);S.target=t,S.contentRect=new c(u,d,M,O),s.has(i)||(s.set(i,[]),p.add(i)),s.get(i).push(S)}))})),p.forEach((function(e){i.get(e).call(e,s.get(e),e)}))}return s.prototype.observe=function(i){if(i instanceof window.Element){r.has(i)||(r.set(i,new Set),o.add(i),a.set(i,window.getComputedStyle(i)));var n=r.get(i);n.has(this)||n.add(this),cancelAnimationFrame(t),t=requestAnimationFrame(d)}},s.prototype.unobserve=function(i){if(i instanceof window.Element&&r.has(i)){var n=r.get(i);n.has(this)&&(n.delete(this),n.size||(r.delete(i),o.delete(i))),n.size||r.delete(i),o.size||cancelAnimationFrame(t)}},A.DOMRectReadOnly=c,A.ResizeObserver=s,A.ResizeObserverEntry=h,A}; // eslint-disable-line\n", "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Left button pans, Right button zooms\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\\nx/y fixes axis\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", "mpl.extensions = [\"eps\", \"jpeg\", \"pgf\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n", "\n", "mpl.default_extension = \"png\";/* global mpl */\n", "\n", "var comm_websocket_adapter = function (comm) {\n", " // Create a \"websocket\"-like object which calls the given IPython comm\n", " // object with the appropriate methods. Currently this is a non binary\n", " // socket, so there is still some room for performance tuning.\n", " var ws = {};\n", "\n", " ws.binaryType = comm.kernel.ws.binaryType;\n", " ws.readyState = comm.kernel.ws.readyState;\n", " function updateReadyState(_event) {\n", " if (comm.kernel.ws) {\n", " ws.readyState = comm.kernel.ws.readyState;\n", " } else {\n", " ws.readyState = 3; // Closed state.\n", " }\n", " }\n", " comm.kernel.ws.addEventListener('open', updateReadyState);\n", " comm.kernel.ws.addEventListener('close', updateReadyState);\n", " comm.kernel.ws.addEventListener('error', updateReadyState);\n", "\n", " ws.close = function () {\n", " comm.close();\n", " };\n", " ws.send = function (m) {\n", " //console.log('sending', m);\n", " comm.send(m);\n", " };\n", " // Register the callback with on_msg.\n", " comm.on_msg(function (msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", " var data = msg['content']['data'];\n", " if (data['blob'] !== undefined) {\n", " data = {\n", " data: new Blob(msg['buffers'], { type: data['blob'] }),\n", " };\n", " }\n", " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(data);\n", " });\n", " return ws;\n", "};\n", "\n", "mpl.mpl_figure_comm = function (comm, msg) {\n", " // This is the function which gets called when the mpl process\n", " // starts-up an IPython Comm through the \"matplotlib\" channel.\n", "\n", " var id = msg.content.data.id;\n", " // Get hold of the div created by the display call when the Comm\n", " // socket was opened in Python.\n", " var element = document.getElementById(id);\n", " var ws_proxy = comm_websocket_adapter(comm);\n", "\n", " function ondownload(figure, _format) {\n", " window.open(figure.canvas.toDataURL());\n", " }\n", "\n", " var fig = new mpl.figure(id, ws_proxy, ondownload, element);\n", "\n", " // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n", " // web socket which is closed, not our websocket->open comm proxy.\n", " ws_proxy.onopen();\n", "\n", " fig.parent_element = element;\n", " fig.cell_info = mpl.find_output_cell(\"
\");\n", " if (!fig.cell_info) {\n", " console.error('Failed to find cell for figure', id, fig);\n", " return;\n", " }\n", " fig.cell_info[0].output_area.element.on(\n", " 'cleared',\n", " { fig: fig },\n", " fig._remove_fig_handler\n", " );\n", "};\n", "\n", "mpl.figure.prototype.handle_close = function (fig, msg) {\n", " var width = fig.canvas.width / fig.ratio;\n", " fig.cell_info[0].output_area.element.off(\n", " 'cleared',\n", " fig._remove_fig_handler\n", " );\n", " fig.resizeObserverInstance.unobserve(fig.canvas_div);\n", "\n", " // Update the output cell to use the data from the current canvas.\n", " fig.push_to_output();\n", " var dataURL = fig.canvas.toDataURL();\n", " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable();\n", " fig.parent_element.innerHTML =\n", " '';\n", " fig.close_ws(fig, msg);\n", "};\n", "\n", "mpl.figure.prototype.close_ws = function (fig, msg) {\n", " fig.send_message('closing', msg);\n", " // fig.ws.close()\n", "};\n", "\n", "mpl.figure.prototype.push_to_output = function (_remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", " var width = this.canvas.width / this.ratio;\n", " var dataURL = this.canvas.toDataURL();\n", " this.cell_info[1]['text/html'] =\n", " '';\n", "};\n", "\n", "mpl.figure.prototype.updated_canvas_event = function () {\n", " // Tell IPython that the notebook contents must change.\n", " IPython.notebook.set_dirty(true);\n", " this.send_message('ack', {});\n", " var fig = this;\n", " // Wait a second, then push the new image to the DOM so\n", " // that it is saved nicely (might be nice to debounce this).\n", " setTimeout(function () {\n", " fig.push_to_output();\n", " }, 1000);\n", "};\n", "\n", "mpl.figure.prototype._init_toolbar = function () {\n", " var fig = this;\n", "\n", " var toolbar = document.createElement('div');\n", " toolbar.classList = 'btn-toolbar';\n", " this.root.appendChild(toolbar);\n", "\n", " function on_click_closure(name) {\n", " return function (_event) {\n", " return fig.toolbar_button_onclick(name);\n", " };\n", " }\n", "\n", " function on_mouseover_closure(tooltip) {\n", " return function (event) {\n", " if (!event.currentTarget.disabled) {\n", " return fig.toolbar_button_onmouseover(tooltip);\n", " }\n", " };\n", " }\n", "\n", " fig.buttons = {};\n", " var buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'btn-group';\n", " var button;\n", " for (var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " /* Instead of a spacer, we start a new button group. */\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", " buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'btn-group';\n", " continue;\n", " }\n", "\n", " button = fig.buttons[name] = document.createElement('button');\n", " button.classList = 'btn btn-default';\n", " button.href = '#';\n", " button.title = name;\n", " button.innerHTML = '';\n", " button.addEventListener('click', on_click_closure(method_name));\n", " button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n", " buttonGroup.appendChild(button);\n", " }\n", "\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = document.createElement('span');\n", " status_bar.classList = 'mpl-message pull-right';\n", " toolbar.appendChild(status_bar);\n", " this.message = status_bar;\n", "\n", " // Add the close button to the window.\n", " var buttongrp = document.createElement('div');\n", " buttongrp.classList = 'btn-group inline pull-right';\n", " button = document.createElement('button');\n", " button.classList = 'btn btn-mini btn-primary';\n", " button.href = '#';\n", " button.title = 'Stop Interaction';\n", " button.innerHTML = '';\n", " button.addEventListener('click', function (_evt) {\n", " fig.handle_close(fig, {});\n", " });\n", " button.addEventListener(\n", " 'mouseover',\n", " on_mouseover_closure('Stop Interaction')\n", " );\n", " buttongrp.appendChild(button);\n", " var titlebar = this.root.querySelector('.ui-dialog-titlebar');\n", " titlebar.insertBefore(buttongrp, titlebar.firstChild);\n", "};\n", "\n", "mpl.figure.prototype._remove_fig_handler = function (event) {\n", " var fig = event.data.fig;\n", " if (event.target !== this) {\n", " // Ignore bubbled events from children.\n", " return;\n", " }\n", " fig.close_ws(fig, {});\n", "};\n", "\n", "mpl.figure.prototype._root_extra_style = function (el) {\n", " el.style.boxSizing = 'content-box'; // override notebook setting of border-box.\n", "};\n", "\n", "mpl.figure.prototype._canvas_extra_style = function (el) {\n", " // this is important to make the div 'focusable\n", " el.setAttribute('tabindex', 0);\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " } else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "};\n", "\n", "mpl.figure.prototype._key_event_extra = function (event, _name) {\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which === 13) {\n", " this.canvas_div.blur();\n", " // select the cell after this one\n", " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", " IPython.notebook.select(index + 1);\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_save = function (fig, _msg) {\n", " fig.ondownload(fig, null);\n", "};\n", "\n", "mpl.find_output_cell = function (html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i = 0; i < ncells; i++) {\n", " var cell = cells[i];\n", " if (cell.cell_type === 'code') {\n", " for (var j = 0; j < cell.output_area.outputs.length; j++) {\n", " var data = cell.output_area.outputs[j];\n", " if (data.data) {\n", " // IPython >= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] === html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "};\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel !== null) {\n", " IPython.notebook.kernel.comm_manager.register_target(\n", " 'matplotlib',\n", " mpl.mpl_figure_comm\n", " );\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%matplotlib notebook\n", "from matplotlib import pyplot as plt\n", "import numpy as np\n", "x = np.linspace(0,9,10)\n", "y = x**2\n", "plt.plot(x,y,'r--')\n", "plt.xlabel('x')\n", "plt.ylabel('$y = x^2$')\n", "plt.title(\"x'in karesi\")\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Jupyter'da kullanılabilecek bazı kullanışlı sihirli sözcükler aşağıda listelenmiştir.\n", "\n", "* %paste & %cpaste: Başka bir kaynaktan ya da terminalden kod kopyalarken \">>>\" prompt sembollerini atarak sizin sadece kodu kopyalamanızı sağlar.\n", "\n", "* %run: Bu derste sıkça kullanacağınız bir sihirli sözcük olup, py uzantılı kodlarınızı Jupyter içinden çalıştırmanıza olanak sağlar (Örnek: %run deneme.py)\n", "\n", "* %timeit: Kodunuzu zamanlamanıza olanak sağlar (Örnek: %timeit L = [x ** 2 for x in range(1000)])\n", "\n", "* %xmode: Hata mesajlarının gösterilme şeklini belirler. Plain, Verbose ve Context olmak üzere üç çeşit hata mesajı alma modu bulunmaktadır.\n", "\n", "\n", "* %debug: Herhangi bir hata mesajı aldığınızda, kodun hata veren noktasına gidip bir hata ayıklama (debug) kutucuğu (prompt) açar ve sizden kodu düzeltmenizi bekler.\n", "\n", "* %pdb on: Jupyter'ın varsayılan davranışının bir hatayla karşılaşıldığında debug prompt'u açması şeklinde olmasını istiyorsanız bu sihirli sözcükle sağlayabilirsiniz. \n", "\n", "* %history: : İlgiil Jupyter defterinin tarihçesini listeler.\n", "\n", "* %lsmagic: Tüm sihirli sözcüklerin bir listesine erişiminizi saplar" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/json": { "cell": { "!": "OSMagics", "HTML": "Other", "SVG": "Other", "bash": "Other", "capture": "ExecutionMagics", "cmd": "Other", "debug": "ExecutionMagics", "file": "Other", "html": "DisplayMagics", "javascript": "DisplayMagics", "js": "DisplayMagics", "latex": "DisplayMagics", "markdown": "DisplayMagics", "perl": "Other", "prun": "ExecutionMagics", "pypy": "Other", "python": "Other", "python2": "Other", "python3": "Other", "ruby": "Other", "script": "ScriptMagics", "sh": "Other", "svg": "DisplayMagics", "sx": "OSMagics", "system": "OSMagics", "time": "ExecutionMagics", "timeit": "ExecutionMagics", "writefile": "OSMagics" }, "line": { "alias": "OSMagics", "alias_magic": "BasicMagics", "autoawait": "AsyncMagics", "autocall": "AutoMagics", "automagic": "AutoMagics", "autosave": "KernelMagics", "bookmark": "OSMagics", "cd": "OSMagics", "clear": "KernelMagics", "cls": "KernelMagics", "colors": "BasicMagics", "conda": "PackagingMagics", "config": "ConfigMagics", "connect_info": "KernelMagics", "copy": "Other", "ddir": "Other", "debug": "ExecutionMagics", "dhist": "OSMagics", "dirs": "OSMagics", "doctest_mode": "BasicMagics", "echo": "Other", "ed": "Other", "edit": "KernelMagics", "env": "OSMagics", "gui": "BasicMagics", "hist": "Other", "history": "HistoryMagics", "killbgscripts": "ScriptMagics", "ldir": "Other", "less": "KernelMagics", "load": "CodeMagics", "load_ext": "ExtensionMagics", "loadpy": "CodeMagics", "logoff": "LoggingMagics", "logon": "LoggingMagics", "logstart": "LoggingMagics", "logstate": "LoggingMagics", "logstop": "LoggingMagics", "ls": "Other", "lsmagic": "BasicMagics", "macro": "ExecutionMagics", "magic": "BasicMagics", "matplotlib": "PylabMagics", "mkdir": "Other", "more": "KernelMagics", "notebook": "BasicMagics", "page": "BasicMagics", "pastebin": "CodeMagics", "pdb": "ExecutionMagics", "pdef": "NamespaceMagics", "pdoc": "NamespaceMagics", "pfile": "NamespaceMagics", "pinfo": "NamespaceMagics", "pinfo2": "NamespaceMagics", "pip": "PackagingMagics", "popd": "OSMagics", "pprint": "BasicMagics", "precision": "BasicMagics", "prun": "ExecutionMagics", "psearch": "NamespaceMagics", "psource": "NamespaceMagics", "pushd": "OSMagics", "pwd": "OSMagics", "pycat": "OSMagics", "pylab": "PylabMagics", "qtconsole": "KernelMagics", "quickref": "BasicMagics", "recall": "HistoryMagics", "rehashx": "OSMagics", "reload_ext": "ExtensionMagics", "ren": "Other", "rep": "Other", "rerun": "HistoryMagics", "reset": "NamespaceMagics", "reset_selective": "NamespaceMagics", "rmdir": "Other", "run": "ExecutionMagics", "save": "CodeMagics", "sc": "OSMagics", "set_env": "OSMagics", "store": "StoreMagics", "sx": "OSMagics", "system": "OSMagics", "tb": "ExecutionMagics", "time": "ExecutionMagics", "timeit": "ExecutionMagics", "unalias": "OSMagics", "unload_ext": "ExtensionMagics", "who": "NamespaceMagics", "who_ls": "NamespaceMagics", "whos": "NamespaceMagics", "xdel": "NamespaceMagics", "xmode": "BasicMagics" } }, "text/plain": [ "Available line magics:\n", "%alias %alias_magic %autoawait %autocall %automagic %autosave %bookmark %cd %clear %cls %colors %conda %config %connect_info %copy %ddir %debug %dhist %dirs %doctest_mode %echo %ed %edit %env %gui %hist %history %killbgscripts %ldir %less %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %ls %lsmagic %macro %magic %matplotlib %mkdir %more %notebook %page %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %pip %popd %pprint %precision %prun %psearch %psource %pushd %pwd %pycat %pylab %qtconsole %quickref %recall %rehashx %reload_ext %ren %rep %rerun %reset %reset_selective %rmdir %run %save %sc %set_env %store %sx %system %tb %time %timeit %unalias %unload_ext %who %who_ls %whos %xdel %xmode\n", "\n", "Available cell magics:\n", "%%! %%HTML %%SVG %%bash %%capture %%cmd %%debug %%file %%html %%javascript %%js %%latex %%markdown %%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%svg %%sx %%system %%time %%timeit %%writefile\n", "\n", "Automagic is ON, % prefix IS NOT needed for line magics." ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%lsmagic" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Formüllerle-Hesaplar)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Jupyter'da Hücre Silmek ve Eklemek #\n", "\n", "Hücre silmek ve eklemek için Insert ve Cell menü seçeneklerinden uygun olanlarını, araç çubuğundaki simgeleri kullanabileceğiniz gibi, işletim sistemlerinin sağladığı Crtl+c, Crtl+x ve Crtl+v seçenekleri de kullanabilirsiniz. Ayrıca araç çubuğunda bu işlerin yanı sıra satır taşımak için kullanabileceğiniz araçlara erişiminizi sağlayan butonlar da bulunmaktadır. Ancak en pratiği kısa yol tuşlarını kullanmaktır. Bu noktada tavisye kısa yol tuşlarını öğrenmek ve verimlilik açısından klavyeden elinizi ayırmadan (ve böylece yazdığınız şeye konsantrasyonunuzu kaybetmeden) bu tuşları kullanmanız olacaktır. a tuşunu bulunulan hücrenin üstüne, b tuşuna altına hücre eklemek, tuşunu iki kez arkaya basmak suretiyle hücre silmek için kullanabilirsiniz. Bu işlemler için bulunduğunuz hücrenin aktif olmayıp (yeşil çerçeve) (edit mode), sadece seçilii (mavi çerçeve) emin olunuz. Aktif ise ESC tuşuna basarak hücreyi seçili duruma getirebilirsiniz. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Jupyter'da Yardım Seçenekleri #\n", "\n", "Jupyter'da herhangi bir konuda yardım almak ve tanımlı kısayol tuşlarını öğrenmek için Help menüsündeki seçeneklerden yararlanabilirsiniz. Bu bölümde Python'la kod yazarken ve bazı önemli paketleri (modülleri) kullanırken sorunlarla karşılaştığınız zaman nasıl yardım alabileceğinize ilişkin bazı ipuçları verilecektir.\n", "\n", "1. iPython'ın (Jupyter iPython defer yapısı üzerine kurulmuştur) tanımlı (built-in) yardım fonksiyonu (help)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on built-in function len in module builtins:\n", "\n", "len(obj, /)\n", " Return the number of items in a container.\n", "\n" ] } ], "source": [ "help(len)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Aynı seçeneğe erişmek için daha kısa bir yol ise yardım almak istediğiniz fonksiyonu yazıp sonuna ? koymaktır. İşletim sistemi ve kullanılan tarayıcıya bağlı olarak standard bir çıktı alınabileceği gibi yardım içeriğini taşıyan bir pencere (pop-up window) de açılabilir." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "len?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sadece ön tanımlı fonksiyonlar değil, çeşitlli nesneler üzerine tanımlı metotlara (ing. attribute) ulaşmak için aynı yöntemler kullanılabilir." ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on built-in function insert:\n", "\n", "insert(index, object, /) method of builtins.list instance\n", " Insert object before index.\n", "\n" ] } ], "source": [ "L = ['1', 3.14, 2]\n", "help(L.insert)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['1', 2.72, 3.14, 2]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L.insert(1,2.72)\n", "L" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "L?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Herhangi bir fonksiyonun (kulllanıcı tanımlı ya da değil) dokümantasyon bloğu (docstring) varsa, ona ulaşarak da fonksiyonun (sınıfın ya da kod parçasının) nasıl kullanılabileceği konusunda da bilgi alınabilir." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Yaricapi 5 birim olan bir dairenin alani 78.5398 birimkare, cevresi 31.4159 birimdir\n", "-----------------------------------------\n", "Daire fonksiyonu dokumantasyon blogu:\n", "-----------------------------------------\n", "Help on function daire in module __main__:\n", "\n", "daire(r=1)\n", " r yaricapina sahip bir dairenin \n", " cevresini ve alanini hesaplayip \n", " programa dondurur.\n", " Kullanilisi:\n", " alan, cevre = daire(R)\n", " Input:\n", " r : Dairenin yaricapi\n", " Output:\n", " alan = pi*r**2\n", " cevre = 2*pi*r\n", " Ornek:\n", " R = 5\n", " print(daire(R))\n", " Cikti:\n", " 78.53981633974483 31.41592653589793\n", "\n" ] } ], "source": [ "def daire(r = 1):\n", " \"\"\"\n", "    r yaricapina sahip bir dairenin \n", " cevresini ve alanini hesaplayip \n", " programa dondurur.\n", " Kullanilisi:\n", " alan, cevre = daire(R)\n", " Input:\n", " r : Dairenin yaricapi\n", " Output:\n", " alan = pi*r**2\n", " cevre = 2*pi*r\n", " Ornek:\n", " R = 5\n", " print(daire(R))\n", " Cikti:\n", " 78.53981633974483 31.41592653589793\n", " \"\"\"\n", " from math import pi\n", " return pi*r**2, 2*pi*r\n", "\n", "R = 5\n", "alan, cevre = daire(R)\n", "print(\"Yaricapi {:g} birim olan bir dairenin alani {:g} birimkare, cevresi {:g} birimdir\".\\\n", " format(R,alan,cevre))\n", "print(\"-----------------------------------------\")\n", "print(\"Daire fonksiyonu dokumantasyon blogu:\")\n", "print(\"-----------------------------------------\")\n", "help(daire)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Fonksiyonun kaynak koduna ulaşmak için fonksiyon adını takiben ?? kullanılır." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "daire??" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Eğer bu opsiyon (??) sadece iç dokümantasyon bloğunu veren ? ile aynı çıktıyı veriyorsa bu durumda bu fonksiyon Python dışında bir programcılık diliyle kodlanıp, Python'a entegre edilmiş olabilir." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "len??" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ayrıca tam adını hatırlayamadığınız fonksiyonları hatırlamak ya da bütün fonksiyonun adını yazmamak için fonksiyonun hatırlayabildiğiniz ya da yazmak istediğiniz kadarını yazdıktan sonra TAB tuşuna basarak geri kalanını iPython'ın yazmasını isteyebilirsiniz." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "# Daha once tanimladiginiz L listesi uzerinde hangi metotlarin\n", "# tanimli oldugunu gormek icin L yazip nokta koyduktan sonra\n", "# tusuna basiniz\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ayrıca nesnenin üzerinde tanımlı gizli metotları da görmek isterseniz; nesne_adi._ yazdıktan sonra TAB tuşuna basabilirsiniz." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Daha once tanimladiginiz L listesi uzerinde hangi gizli metotlarin\n", "# tanimli oldugunu gormek icin L._ yazdiktan sonra\n", "# tusuna basiniz\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "TAB ile birlikte wildcard (*, ?) kullanmak, adını ve ilk birkaç harfini hatırlayamadığınız ancak bir kısmını hatırlayabildiğiniz fonksiyon, metot ya da modülleri bulmanıza yardımcı olacaktır. " ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "*Warning?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Sihirli Sözcükler Konusunda Yardım Alma: ###\n", "\n", "Tıpkı Python fonksiyonları gibi, IPython sihirli sözcükleriyle tanımlanan fonksiyonlarının da aynı şekilde ulaşılabilen iç dokümantasyon blokları bulunmaktadır. " ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "%timeit?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Herhangi bir sihirli sözcükle ilgili dokümantasyona sözcüğü yazıp Enter'a basarak erişebilirsiniz." ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "%run" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Jupyter ve Çekirdekler #" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Çekirdek (Kernel) Jupyter'ın interaktif olarak kod çalıştıran bileşenidir. IPython kulllanırken, bu bir Python kodudur. Python'dan başka dillerde çekirdekler olabileceği gibi birden fazla Python versiyonu (2.7, 3.8, 3.10 gibi) sistemde kurulu iseler bulunabilir. Çekirdek Jupyter defterindeki kod parçalarını alır, çalıştırır ve deftere çıktı (output) ya da hata mesajı (error message) yollar.\n", "\n", "Çıktı koda bağlı olarak print ifadesi kullanılmamışsa tıpkı input hücreleri gibi Out[ ] ifadesi ile köşeli parantez içinde numarandırılır. print ifadesinin kulllanıldığı durumda çıktı stdout nesnesine yönlendirilr. Kod hatta veriyorsa bu da stderr nesnesi üzerinden gelir." ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "merhaba, stdout\n" ] } ], "source": [ "print(\"merhaba, stdout\")" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "8" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "3 + 5" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([1, 2, 3])" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.array([1,2,3])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Kod Çıktılarıyla İşlemler #\n", "\n", "Jupyter'da çıktılar senkronize değildir. Kod bir taraftan çıktı üretir ve ekrana getirirken, siz diğer tarafta başka bir hücre üzerinde çalışıyor olabilirsiniz. Bir hücre çıktı ürettikçe üretilen çıktı bir önceki çıktıdan sonra ekrana gelir. Tüm kod bloğunun çalışıp, tüm çıktıların ekrana tek bir anda basılması beklenmez." ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "1\n", "2\n", "3\n", "4\n" ] } ], "source": [ "import time, sys\n", "for i in range(5):\n", " print(i)\n", " time.sleep(0.8)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Kod bloklarının uzun çıktılar vermesi durumunda çıktının olduğu blok isteğe göre büyütülüp küçültülebilir. Aşağıdaki kod parçasının çalıştırıldıktan sonra verdiği çıktıyı küçültmek için çıktı hücresinin sol tarafında beliren alana tek (sağ tarafta bir kaydırma çubuğu için) ya da çift (çıktı bloğunu tamamen kapatmak için) tıklayınız." ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "10\n", "11\n", "12\n", "13\n", "14\n", "15\n", "16\n", "17\n", "18\n", "19\n", "20\n", "21\n", "22\n", "23\n", "24\n", "25\n", "26\n", "27\n", "28\n", "29\n", "30\n", "31\n", "32\n", "33\n", "34\n", "35\n", "36\n", "37\n", "38\n", "39\n", "40\n", "41\n", "42\n", "43\n", "44\n", "45\n", "46\n", "47\n", "48\n", "49\n", "50\n", "51\n", "52\n", "53\n", "54\n", "55\n", "56\n", "57\n", "58\n", "59\n" ] } ], "source": [ "for i in range(60):\n", " print(i)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Eğer kodun çıktsı çok uzunsa tarayıcı bunun için bir kaydırma çubuğunu otomatik olarak sağlar. " ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.0\n", "6.283185307179586\n", "12.566370614359172\n", "18.84955592153876\n", "25.132741228718345\n", "31.41592653589793\n", "37.69911184307752\n", "43.982297150257104\n", "50.26548245743669\n", "56.548667764616276\n", "62.83185307179586\n", "69.11503837897544\n", "75.39822368615503\n", "81.68140899333463\n", "87.96459430051421\n", "94.24777960769379\n", "100.53096491487338\n", "106.81415022205297\n", "113.09733552923255\n", "119.38052083641213\n", "125.66370614359172\n", "131.94689145077132\n", "138.23007675795088\n", "144.51326206513048\n", "150.79644737231007\n", "157.07963267948966\n", "163.36281798666926\n", "169.64600329384882\n", "175.92918860102841\n", "182.212373908208\n", "188.49555921538757\n", "194.77874452256717\n", "201.06192982974676\n", "207.34511513692635\n", "213.62830044410595\n", "219.9114857512855\n", "226.1946710584651\n", "232.4778563656447\n", "238.76104167282426\n", "245.04422698000386\n", "251.32741228718345\n", "257.610597594363\n", "263.89378290154264\n", "270.1769682087222\n", "276.46015351590177\n", "282.7433388230814\n", "289.02652413026095\n", "295.3097094374406\n", "301.59289474462014\n", "307.8760800517997\n", "314.1592653589793\n", "320.4424506661589\n", "326.7256359733385\n", "333.0088212805181\n", "339.29200658769764\n", "345.57519189487726\n", "351.85837720205683\n", "358.1415625092364\n", "364.424747816416\n", "370.7079331235956\n", "376.99111843077515\n", "383.27430373795477\n", "389.55748904513433\n", "395.84067435231395\n", "402.1238596594935\n", "408.4070449666731\n", "414.6902302738527\n", "420.97341558103227\n", "427.2566008882119\n", "433.53978619539146\n", "439.822971502571\n", "446.10615680975064\n", "452.3893421169302\n", "458.6725274241098\n", "464.9557127312894\n", "471.23889803846896\n", "477.5220833456485\n", "483.80526865282815\n", "490.0884539600077\n", "496.37163926718733\n", "502.6548245743669\n", "508.93800988154646\n", "515.221195188726\n", "521.5043804959057\n", "527.7875658030853\n", "534.0707511102648\n", "540.3539364174444\n", "546.637121724624\n", "552.9203070318035\n", "559.2034923389832\n", "565.4866776461628\n", "571.7698629533423\n", "578.0530482605219\n", "584.3362335677015\n", "590.6194188748811\n", "596.9026041820607\n", "603.1857894892403\n", "609.4689747964198\n", "615.7521601035994\n", "622.0353454107791\n", "628.3185307179587\n", "634.6017160251382\n", "640.8849013323178\n", "647.1680866394973\n", "653.451271946677\n", "659.7344572538566\n", "666.0176425610362\n", "672.3008278682157\n", "678.5840131753953\n", "684.8671984825748\n", "691.1503837897545\n", "697.4335690969341\n", "703.7167544041137\n", "709.9999397112932\n", "716.2831250184728\n", "722.5663103256525\n", "728.849495632832\n", "735.1326809400116\n", "741.4158662471912\n", "747.6990515543707\n", "753.9822368615503\n", "760.26542216873\n", "766.5486074759095\n", "772.8317927830891\n", "779.1149780902687\n", "785.3981633974482\n", "791.6813487046279\n", "797.9645340118075\n", "804.247719318987\n", "810.5309046261666\n", "816.8140899333462\n", "823.0972752405258\n", "829.3804605477054\n", "835.663645854885\n", "841.9468311620645\n", "848.2300164692441\n", "854.5132017764238\n", "860.7963870836033\n", "867.0795723907829\n", "873.3627576979625\n", "879.645943005142\n", "885.9291283123216\n", "892.2123136195013\n", "898.4954989266809\n", "904.7786842338604\n", "911.06186954104\n", "917.3450548482195\n", "923.6282401553992\n", "929.9114254625788\n", "936.1946107697584\n", "942.4777960769379\n", "948.7609813841175\n", "955.044166691297\n", "961.3273519984767\n", "967.6105373056563\n", "973.8937226128359\n", "980.1769079200154\n", "986.460093227195\n", "992.7432785343747\n", "999.0264638415542\n", "1005.3096491487338\n", "1011.5928344559134\n", "1017.8760197630929\n", "1024.1592050702725\n", "1030.442390377452\n", "1036.7255756846316\n", "1043.0087609918114\n", "1049.291946298991\n", "1055.5751316061705\n", "1061.85831691335\n", "1068.1415022205297\n", "1074.4246875277092\n", "1080.7078728348888\n", "1086.9910581420684\n", "1093.274243449248\n", "1099.5574287564275\n", "1105.840614063607\n", "1112.1237993707869\n", "1118.4069846779664\n", "1124.690169985146\n", "1130.9733552923256\n", "1137.2565405995051\n", "1143.5397259066847\n", "1149.8229112138642\n", "1156.1060965210438\n", "1162.3892818282234\n", "1168.672467135403\n", "1174.9556524425827\n", "1181.2388377497623\n", "1187.5220230569419\n", "1193.8052083641214\n", "1200.088393671301\n", "1206.3715789784806\n", "1212.6547642856601\n", "1218.9379495928397\n", "1225.2211349000193\n", "1231.5043202071988\n", "1237.7875055143784\n", "1244.0706908215582\n", "1250.3538761287377\n", "1256.6370614359173\n", "1262.9202467430969\n", "1269.2034320502764\n", "1275.486617357456\n", "1281.7698026646356\n", "1288.0529879718151\n", "1294.3361732789947\n", "1300.6193585861743\n", "1306.902543893354\n", "1313.1857292005336\n", "1319.4689145077132\n", "1325.7520998148927\n", "1332.0352851220723\n", "1338.3184704292519\n", "1344.6016557364314\n", "1350.884841043611\n", "1357.1680263507906\n", "1363.4512116579701\n", "1369.7343969651497\n", "1376.0175822723295\n", "1382.300767579509\n", "1388.5839528866886\n", "1394.8671381938682\n", "1401.1503235010478\n", "1407.4335088082273\n", "1413.7166941154069\n", "1419.9998794225864\n", "1426.283064729766\n", "1432.5662500369456\n", "1438.8494353441251\n", "1445.132620651305\n", "1451.4158059584845\n", "1457.698991265664\n", "1463.9821765728436\n", "1470.2653618800232\n", "1476.5485471872028\n", "1482.8317324943823\n", "1489.114917801562\n", "1495.3981031087415\n", "1501.681288415921\n", "1507.9644737231006\n", "1514.2476590302804\n", "1520.53084433746\n", "1526.8140296446395\n", "1533.097214951819\n", "1539.3804002589986\n", "1545.6635855661782\n", "1551.9467708733578\n", "1558.2299561805373\n", "1564.513141487717\n", "1570.7963267948965\n", "1577.0795121020763\n", "1583.3626974092558\n", "1589.6458827164354\n", "1595.929068023615\n", "1602.2122533307945\n", "1608.495438637974\n", "1614.7786239451536\n", "1621.0618092523332\n", "1627.3449945595128\n", "1633.6281798666923\n", "1639.911365173872\n", "1646.1945504810517\n", "1652.4777357882313\n", "1658.7609210954108\n", "1665.0441064025904\n", "1671.32729170977\n", "1677.6104770169495\n", "1683.893662324129\n", "1690.1768476313086\n", "1696.4600329384882\n", "1702.7432182456678\n", "1709.0264035528476\n", "1715.3095888600271\n", "1721.5927741672067\n", "1727.8759594743863\n", "1734.1591447815658\n", "1740.4423300887454\n", "1746.725515395925\n", "1753.0087007031045\n", "1759.291886010284\n", "1765.5750713174637\n", "1771.8582566246432\n", "1778.141441931823\n", "1784.4246272390026\n", "1790.7078125461821\n", "1796.9909978533617\n", "1803.2741831605413\n", "1809.5573684677208\n", "1815.8405537749004\n", "1822.12373908208\n", "1828.4069243892595\n", "1834.690109696439\n", "1840.9732950036187\n", "1847.2564803107985\n", "1853.539665617978\n", "1859.8228509251576\n", "1866.1060362323371\n", "1872.3892215395167\n", "1878.6724068466963\n", "1884.9555921538758\n", "1891.2387774610554\n", "1897.521962768235\n", "1903.8051480754145\n", "1910.088333382594\n", "1916.371518689774\n", "1922.6547039969535\n", "1928.937889304133\n", "1935.2210746113126\n", "1941.5042599184922\n", "1947.7874452256717\n", "1954.0706305328513\n", "1960.3538158400308\n", "1966.6370011472104\n", "1972.92018645439\n", "1979.2033717615698\n", "1985.4865570687493\n", "1991.769742375929\n", "1998.0529276831085\n", "2004.336112990288\n", "2010.6192982974676\n", "2016.9024836046472\n", "2023.1856689118267\n", "2029.4688542190063\n", "2035.7520395261859\n", "2042.0352248333654\n", "2048.318410140545\n", "2054.601595447725\n", "2060.884780754904\n", "2067.167966062084\n", "2073.4511513692632\n", "2079.734336676443\n", "2086.017521983623\n", "2092.300707290802\n", "2098.583892597982\n", "2104.8670779051613\n", "2111.150263212341\n", "2117.4334485195204\n", "2123.7166338267\n", "2129.9998191338796\n", "2136.2830044410593\n", "2142.5661897482387\n", "2148.8493750554185\n", "2155.1325603625983\n", "2161.4157456697776\n", "2167.6989309769574\n", "2173.9821162841367\n", "2180.2653015913165\n", "2186.548486898496\n", "2192.8316722056757\n", "2199.114857512855\n", "2205.398042820035\n", "2211.681228127214\n", "2217.964413434394\n", "2224.2475987415737\n", "2230.530784048753\n", "2236.813969355933\n", "2243.097154663112\n", "2249.380339970292\n", "2255.6635252774713\n", "2261.946710584651\n", "2268.2298958918304\n", "2274.5130811990102\n", "2280.79626650619\n", "2287.0794518133694\n", "2293.362637120549\n", "2299.6458224277285\n", "2305.9290077349083\n", "2312.2121930420876\n", "2318.4953783492674\n", "2324.7785636564467\n", "2331.0617489636265\n", "2337.344934270806\n", "2343.6281195779857\n", "2349.9113048851655\n", "2356.194490192345\n", "2362.4776754995246\n", "2368.760860806704\n", "2375.0440461138837\n", "2381.327231421063\n", "2387.610416728243\n", "2393.893602035422\n", "2400.176787342602\n", "2406.4599726497813\n", "2412.743157956961\n", "2419.026343264141\n", "2425.3095285713202\n", "2431.5927138785\n", "2437.8758991856794\n", "2444.159084492859\n", "2450.4422698000385\n", "2456.7254551072183\n", "2463.0086404143976\n", "2469.2918257215774\n", "2475.5750110287568\n", "2481.8581963359366\n", "2488.1413816431163\n", "2494.4245669502957\n", "2500.7077522574755\n", "2506.990937564655\n", "2513.2741228718346\n", "2519.557308179014\n", "2525.8404934861937\n", "2532.123678793373\n", "2538.406864100553\n", "2544.690049407732\n", "2550.973234714912\n", "2557.256420022092\n", "2563.539605329271\n", "2569.822790636451\n", "2576.1059759436303\n", "2582.38916125081\n", "2588.6723465579894\n", "2594.955531865169\n", "2601.2387171723485\n", "2607.5219024795283\n", "2613.805087786708\n", "2620.0882730938874\n", "2626.3714584010672\n", "2632.6546437082466\n", "2638.9378290154264\n", "2645.2210143226057\n", "2651.5041996297855\n", "2657.787384936965\n", "2664.0705702441446\n", "2670.353755551324\n", "2676.6369408585037\n", "2682.9201261656835\n", "2689.203311472863\n", "2695.4864967800427\n", "2701.769682087222\n", "2708.052867394402\n", "2714.336052701581\n", "2720.619238008761\n", "2726.9024233159403\n", "2733.18560862312\n", "2739.4687939302994\n", "2745.751979237479\n", "2752.035164544659\n", "2758.3183498518383\n", "2764.601535159018\n", "2770.8847204661975\n", "2777.1679057733772\n", "2783.4510910805566\n", "2789.7342763877364\n", "2796.0174616949157\n", "2802.3006470020955\n", "2808.583832309275\n", "2814.8670176164546\n", "2821.1502029236344\n", "2827.4333882308138\n", "2833.7165735379936\n", "2839.999758845173\n", "2846.2829441523527\n", "2852.566129459532\n", "2858.849314766712\n", "2865.132500073891\n", "2871.415685381071\n", "2877.6988706882503\n", "2883.98205599543\n", "2890.26524130261\n", "2896.548426609789\n", "2902.831611916969\n", "2909.1147972241483\n", "2915.397982531328\n", "2921.6811678385075\n", "2927.9643531456873\n", "2934.2475384528666\n", "2940.5307237600464\n", "2946.8139090672257\n", "2953.0970943744055\n", "2959.3802796815853\n", "2965.6634649887646\n", "2971.9466502959444\n", "2978.229835603124\n", "2984.5130209103036\n", "2990.796206217483\n", "2997.0793915246627\n", "3003.362576831842\n", "3009.645762139022\n", "3015.928947446201\n", "3022.212132753381\n", "3028.4953180605607\n", "3034.77850336774\n", "3041.06168867492\n", "3047.344873982099\n", "3053.628059289279\n", "3059.9112445964583\n", "3066.194429903638\n", "3072.4776152108175\n", "3078.7608005179973\n", "3085.043985825177\n", "3091.3271711323564\n", "3097.610356439536\n", "3103.8935417467155\n", "3110.1767270538953\n", "3116.4599123610747\n", "3122.7430976682544\n", "3129.026282975434\n", "3135.3094682826136\n" ] } ], "source": [ "from math import pi\n", "for r in range(500):\n", " print(2*pi*r)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " **Önemli Not**: Bir Jupyter defteri üzerinde çalışırken daha önce çalıştırdığınız tüm hücrelerdeki tüm değişkenler, tanımladığınız fonksiyonlar, yaptığınız tüm değişiklikler vs. hafızada tutulur ve IPython tarafından bilinir. Tüm defterin başına çıkıp, defterin daha alt kısmında tanımlı bir fonksiyona bir değişken gönderseniz dahi çalışacaktır. Zira o fonksiyon IPython tarafından bilinmektedir. Her şeyi sıfırlamak istemeniz durumunda Kernel menüsünün altındaki seçenenkleri (Restart, Restart & Clear Output, Restart & Run All) kullanabilirsiniz.\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Jupyter defterlerinde In tüm girdilerin (inputs), Out ise çıktıların tutulduğu birer Python listesidir. İstenen girdi ya da çıktı istendiği vakit ekrana getirilebilir ya da üzerinde işlem yapılabilir." ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "v0 = 5 # Ilk hiz m/s\n", "t = 0.6 # zaman s\n", "g = 9.81 # yercekimi ivmesi m/s**2\n", "y = v0*t - 0.5*g*t**2\n", "print(y)\n" ] } ], "source": [ "print(In[1])" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "8.0" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = 2.0\n", "y = 2*x**2 - 2*x + 4\n", "y" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "8.0\n" ] } ], "source": [ "print(Out[28]) # Sizde 25. output olmayabilir, dogru sayiyla calistiriniz" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "96.0" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Out[28]*3*x**2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "print(_) son çıktıyı, print(__) bir öncekini, and print(___) ondan öncekini ... verir" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "96.0\n", "8.0\n" ] } ], "source": [ "print(_)\n", "print(__)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Out[25] için bir kısa yol _25 yazmaktır." ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "7.0" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import math\n", "_28-math.sin(math.pi/2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sonuna \";\" işareti koyduğunuz kod bloğu çalışır ama ekrana çıktı vermez. Bu yapıyı sıklıkla kullanmanız gerekebileceğinden öğrenmenizde fayda vardır." ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "math.sin(2) + math.cos(2);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Bu durumda bu satırın vereceği çıktıya da Out[x] ile (ya da _x ile) erişmek mümkün değildir. " ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "ename": "KeyError", "evalue": "33", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)", "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_2064\\2370835290.py\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mOut\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m33\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;31m# Bir önceki kod satiri hangi sayiya sahipse onu kullaniniz\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;31mKeyError\u001b[0m: 33" ] } ], "source": [ "Out[33] # Bir önceki kod satiri hangi sayiya sahipse onu kullaniniz" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "%history ilgili Jupyter defterinde çalıştırılmış kod bloklarının numaralarını almak için kullanılabilir." ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 20: %run?\n", " 21: print(\"merhaba, stdout\")\n", " 22: 3 + 5\n", " 23: np.array([1,2,3])\n" ] } ], "source": [ "%history -n 20-23" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Python, Numpy ve Scipy'a Giriş #\n", "\n", "Bu derste ihtiyaç duyulacak temel Python programlama bilgisi Ankara Üniversitesi Fen Fakültesi Astronomi ve Uzay Bilimleri Bölümü 4. sınıf seçmeli dersi [AST415 Astronomide Sayısal Çözümleme-I](http://ozgur.astrotux.org/tr/teaching/ast415-astronomide-sayisal-cozumleme/) dersinde verilmektedir. Bu derse başlamadan önce AST415'in internet sayfasına eriştikten sonra ders notlarını indirmeniz, anlayarak okumanız, kod yazarak çalışmanız, alıştırmalarını ve ödev sorularını yapıp cevaplarıyla karşılaştırmanız önerilir. Bu nedenle 800100715151 Astronomide Veritabanları dersini alacak tüm yüksek lisans / doktora öğrencilerine bu çalışmayı ders başlamadan yapmalarını öneriyoruz. İdealinde bu dersi AST415 almış ya da bir başka şekilde Python diliyle programlamaya aşina öğrencilerin almasıdır. Ancak yüksek lisans derslerine önkoşul koyamadığımız için programlama bilgisi yeterli olmayan öğrencilerimize AST415 notlarına iyi çalışmalarını önermekle yetiniyoruz. Aşağıda seçilmiş 8 soru 1. ödev olarak verilmiştir. Bu ödevi anlayarak yapabiliyor olmanız durumunda bu dersin gerektirdiği Python programlama bilgisinin asgari düzeyine sahip olduğunuz varsayılabilir. \n", "\n", "Bu derste sıkça kullanacağımız numpy ve scipy paketleri için ise özel bir girişe ihtiyaç duyduk. Bu paketleri özet olarak anlatırken Python'la ilgili bazı temel yapıları da tekrar görmenizi, hatırlamanızı ve daha iyi öğrenmenizi de amaçladık. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Numpy'a Giriş ##\n", "\n", "Numpy, Python için temel bilimsel fonksiyonların bulunduğu bir pakettir. Sağladığı N-boyutlu dizi nesnesi yardımıyla matematiksel işlemler ve fonksiyonların uygulanmasını kolaylaştırır ve lineer cebirden Fourier dönüşümlerine kadar pek çok konuda gelişmiş fonksiyonlar sunar. \n", "\n", "Bu işlemleri optimize gerçekleştirebilmesi için numpy'ın temel nesnesi olan dizi nesnesi, listelerden farklı olarak aynı tür (float) veri içerir ve sabit uzunlukta tanımlanır. Aritmetik işlemlerin ve vektörel (diziler üzerinde işlem yapmak üzere) tanımlanmış fonksiyonların döngü tanımlanmaksızın tek bir kerede uygulanmasını sağlaması itibarı ile ayrıca pratiktir." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Dizi Oluşturma İşlemleri ###\n", "\n", "Bir numpy dizisi oluşturmak için sıklıkla kullanılan iki fonksiyon bulunmaktadır; npp.arange ve np.linspace. Öncelikle bu iki fonksiyona bakalım." ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a: [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14]\n", "a: [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14]\n" ] } ], "source": [ "# Oncelikle numpy modulunu cagiralim (import edelim)\n", "# numpy modulunun standart lakabi np 'dir.\n", "import numpy as np \n", "a = np.arange(0,15,1) # O'dan 15'e (15 haric) 1er aralikli sayilardan olusan dizi\n", "print(\"a: \", a)\n", "# baslangic noktasinin varsayilan degeri 0, adim buyuklugununki 1 oldugundan\n", "# ayni dizi asagidaki sekilde de tanimlanabilir.\n", "a = np.arange(15)\n", "print(\"a: \", a)" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b: [0. 1. 2. 3. 4. 5. 6. 7. 8. 9.]\n" ] } ], "source": [ "# Linspace'de ise baslangic, son (son dahil) ve adim buyuklugu yerine \n", "# dizide kac eleman istendigi bilgisi saglanir\n", "b = np.linspace(0,9,10)\n", "print(\"b: \", b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Bir listeyi ya da diziye dönüştürülebilecek herhangi başka bir seriyi (ing. iterable) bir numpy disizine dönüştürmek üzere ise np.array fonksiyonu kullanılır." ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "c: [1 2 3 4 5]\n", "d: [ 0 1 2 3 4 5 6 7 8 9 10 11]\n" ] } ], "source": [ "liste = [1, 2, 3, 4, 5]\n", "c = np.array(liste)\n", "print(\"c: \", c)\n", "seri = range(12)\n", "d = np.array(seri)\n", "print(\"d: \", d)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ayrıca ihtiyaca göre (örneğin toplayarak ilerlemek üzere) sıfırlardan (ya da çarparak ilerlemek üzere) birlerden oluşan diziler oluşturmak üzere de sırasıyla np.zeros ve np.ones fonksiyonları kullanılır." ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "5 tane 0'dan olusan dizi: [0. 0. 0. 0. 0.]\n", "8 tane 1'den olusan dizi: [1. 1. 1. 1. 1. 1. 1. 1.]\n" ] } ], "source": [ "sifirlar = np.zeros(5)\n", "print(\"5 tane 0'dan olusan dizi:\", sifirlar)\n", "birler = np.ones(8)\n", "print(\"8 tane 1'den olusan dizi: \", birler)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "np.linspace'e çok benzeyen ancak eşit aralıkları logaritmik olarak düzenleyen bir de np.logspace fonksiyonu bulunmaktadır." ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "loga : [1.e+01 1.e+02 1.e+03 1.e+04 1.e+05]\n" ] } ], "source": [ "loga = np.logspace(1,5,5)\n", "print(\"loga : \", loga)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Bir fonksiyona dayalı olarak bir numpy dizisi oluşturmak için np.fromfunction fonksiyonunu kullanabilirsiniz." ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[0 0 0 0]\n", " [0 1 2 3]\n", " [0 2 4 6]\n", " [0 3 6 9]]\n" ] } ], "source": [ "dizi = np.fromfunction(lambda i, j: i * j, (4, 4), dtype=int)\n", "print(dizi)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### İndeksleme ve Dizi Dilimleme ###\n", "\n", "numpy'da nümerik dizilerde indeksleme ve dilimleme çok önemli bir fark dışında listelerdekiyle aynı şekilde yapılır. Bu çok önemli fark dilimlerin orjinal dizinin bir kopyası olmayıp gerçekten bir bölümü olmasıdır. Dolayısı ile dilim üzerinde bir değişiklik yapıldığı vakit orjinal dizide de bu dilimin karşılık geldiği elemanlar değişir!. Bazı " ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a: [10. 15. 20. 25. 30. 35. 40. 45. 50.]\n", "a[0]: 10.00, a[-1]: 50.00, a[5]: 35.00\n", "a[:5]: [10. 15. 20. 25. 30.]\n", "a[7:]: [45. 50.]\n", "a[3:7]: [25. 30. 35. 40.]\n", "a[0:-1:2]: [10. 20. 30. 40.]\n", "a[::4]: [10. 30. 50.]\n", "a[1:-1]: [15. 20. 25. 30. 35. 40. 45.]\n" ] } ], "source": [ "a = np.linspace(10,50,9)\n", "print(\"a: \", a)\n", "# linspace reel sayilardan (float) mutesekkil bir dizi yaratir\n", "print(\"a[0]: {:.2f}, a[-1]: {:.2f}, a[5]: {:.2f}\".format(a[0],a[-1],a[5]))\n", "print(\"a[:5]: \", a[:5])\n", "print(\"a[7:]: \", a[7:])\n", "print(\"a[3:7]: \", a[3:7])\n", "print(\"a[0:-1:2]: \", a[0:-1:2])\n", "print(\"a[::4]: \", a[::4])\n", "print(\"a[1:-1]: \", a[1:-1])" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b: [15. 20. 25. 30. 35. 40. 45.]\n", "Yeni b: [15. 20. 0.1 30. 35. 40. 45. ]\n", "a: [10. 15. 20. 0.1 30. 35. 40. 45. 50. ]\n" ] } ], "source": [ "b = a[1:-1]\n", "print(\"b: \", b)\n", "b[2] = 0.1\n", "print(\"Yeni b: \", b)\n", "print(\"a: \", a)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Nümerik dizilerde indeksleme ve dilimleme işlemlerinde getirdiği pratik kullanım faydaları açısından $a[range(f:t:i)]$ yapsını incelemek gerekir. Bu yapı $a[f:t:i]$ yapısyla aynıdır ve $a$ dizisinin $f$ indeksinden başlayıp $t$ indeksine kadar ($t$ hariç), $i$ büyüklüğündeki adımlarla elemanlarının alınması ve istenirse değiştirilmesine yarar." ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a = [72. 73. 74. 75. 76. 77. 78. 79.]\n", "a[[1,6,7]] = 10 --> [ 72. 100. 74. 75. 76. 77. 100. 100.]\n", "a[range(2,8,3)] = -2 --> [ 72. 100. -2. 75. 76. -2. 100. 100.]\n" ] } ], "source": [ "import numpy as np\n", "a = np.linspace(72,79,8)\n", "print(\"a = \", a)\n", "a[[1,6,7]] = 100 # 1., 6. ve 7. indekslerin değerini 100 yap\n", "print(\"a[[1,6,7]] = 10 -->\", a)\n", "# range 2 ile 8 indeksler arasinda (8 haric) 3er atlayarak indeks degerlerini uretir\n", "a[range(2,8,3)] = -2 \n", "print(\"a[range(2,8,3)] = -2 -->\", a)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Daha da pratik ve oldukça kullanışlı bir indeksleme ve dilimleme yöntemi de boolean ifadelere dayanandır. Aşağıda verilen örneklerde göreceğiniz gibi boolean ifadeler de indeksleme ve dilimleme için kullanılabilir." ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a[a < 0] --> [-4. -3. -2. -1.]\n", "a[a < 0] = a.max() --> [5. 5. 5. 5. 0. 1. 2. 3. 4. 5.]\n" ] } ], "source": [ "import numpy as np\n", "a = np.linspace(-4,5,10)\n", "print(\"a[a < 0] -->\", a[a < 0])\n", "# negatif elemanlari a dizisinin maksimumu degeri yap\n", "a[a < 0] = a.max()\n", "print(\"a[a < 0] = a.max() -->\", a)" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a[[1,6,7]] = 10 --> [ 5. 10. 5. 5. 0. 1. 10. 10. 4. 5.]\n", "a[a == 10] = [10, 20, 30] --> [ 5. 10. 5. 5. 0. 1. 20. 30. 4. 5.]\n", "[ True True True True False False True True True True]\n" ] } ], "source": [ "# 1., 6. ve 7. indekslerin değerini 10 yap\n", "a[[1,6,7]] = 10 \n", "print(\"a[[1,6,7]] = 10 -->\", a)\n", "# a'daki 10lari verilen baska bir diziden sirayla secilen elemanlarla degistir\n", "a[a == 10] = [10, 20, 30] \n", "print(\"a[a == 10] = [10, 20, 30] -->\", a)\n", "# a > 2 returns True for elements of a larger than 2 and False otherwise\n", "print(a > 2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Çok Boyutlu Dizilerde İndeksleme ve Dilimleme ###\n", "\n", "numpy'da çok boyutlu diziler satırları öne alan (row major storage) yapıda saklanır. Aşağıdaki örnekte oluşturan a dizisinin her bir satırının $[ ]$ arasında tutulduğuna, sütunların ise ayrılmadığına dikkat ediniz." ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a: \n", " [[ 0 1 2 3 4]\n", " [ 5 6 7 8 9]\n", " [10 11 12 13 14]]\n" ] } ], "source": [ "a = np.arange(15).reshape(3,5)\n", "print(\"a: \\n\", a)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Dizi içinde belli bir elemanın yerini belirlemek (indekslemek) için aşağıdaki yazım kurallarından herhangi biri kullanılabilir." ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a[1,2]: 7\n", "a[1][2]: 7\n" ] } ], "source": [ "print(\"a[1,2]: \", a[1,2])\n", "print(\"a[1][2]: \", a[1][2])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Benzer bir mantığı takip ederek dilimleme de yapabilirsiniz." ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a[0:2,1:4]: \n", " [[1 2 3]\n", " [6 7 8]]\n" ] } ], "source": [ "# a dizinin 0 ile 2. satir arasi (2 haric)\n", "# 1 ve 4 sütunlar arasi (4 haric)\n", "print(\"a[0:2,1:4]: \\n\",a[0:2,1:4])" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a[::2,:-1] \n", " [[ 0 1 2 3]\n", " [10 11 12 13]]\n" ] } ], "source": [ "# a dizisinin bastan sona birer atlayarak tum satirlari\n", "# ve son satir haric tum sutunlari\n", "print(\"a[::2,:-1] \\n\", a[::2,:-1]) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Herhangi bir sütuna ulaşmaya çalışırken numpy'ın satırı öncelediği akılda tutulmalıdır." ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a[:,2]: [ 2 7 12]\n" ] } ], "source": [ "print(\"a[:,2]: \", a[:,2])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Satırları tek tek yazdırmak için bir for döngüsü kullanmak isteyebilirsiniz ancak önerilen Python dizilerini eleman eleman ya da satır satır taramak için döngüleri kullanmanız yerine dilimleri kullanmanızdır, çünkü bu yol çok daha hızlıdır." ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1.satir: [0 1 2 3 4]\n", "2.satir: [5 6 7 8 9]\n", "3.satir: [10 11 12 13 14]\n", "0.sutun: [ 0 5 10]\n", "1.sutun: [ 1 6 11]\n", "2.sutun: [ 2 7 12]\n", "3.sutun: [ 3 8 13]\n", "4.sutun: [ 4 9 14]\n" ] } ], "source": [ "# Satir uzerinden ilerleme\n", "i = 1\n", "for satir in a:\n", " print(\"{:d}.satir: {:s}\".format(i, str(satir)))\n", " i += 1\n", "# Sutun uzerinden ilerleme\n", "for j in range(a.shape[1]):\n", " print(\"{:d}.sutun: {:s}\".format(j, str(a[:,j])))\n", " j += 1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Temel numpy metotları ###\n", "\n", "Bir numpy dizisi üzerine tanılanmış pek çok metot bulunmakla birlikte sıklıkla kullanılanları aşağıda örneklenmiştir." ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a dizisinin boyutu: 1\n", "a dizisinin sekli: (15,)\n", "a dizisinin eleman sayisi: 15\n", "a dizisinin elemanlarinin turu: int32\n", "a dizisinin eleman buyuklugu:b 4\n", "a dizisinin turu: \n" ] } ], "source": [ "a = np.arange(15)\n", "print(\"a dizisinin boyutu: \", a.ndim)\n", "print(\"a dizisinin sekli: \",a.shape)\n", "print(\"a dizisinin eleman sayisi: \",a.size)\n", "print(\"a dizisinin elemanlarinin turu: \",a.dtype)\n", "print(\"a dizisinin eleman buyuklugu:b \",a.itemsize)\n", "print(\"a dizisinin turu: \", type(a))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ayrıca diziler ve üzerinde yapabileceğiniz işlemler ve tanımlı metotlar hakkında daha fazla bilgi almak için help fonksiyonundan faydalanabilirsiniz." ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on ndarray object:\n", "\n", "class ndarray(builtins.object)\n", " | ndarray(shape, dtype=float, buffer=None, offset=0,\n", " | strides=None, order=None)\n", " | \n", " | An array object represents a multidimensional, homogeneous array\n", " | of fixed-size items. An associated data-type object describes the\n", " | format of each element in the array (its byte-order, how many bytes it\n", " | occupies in memory, whether it is an integer, a floating point number,\n", " | or something else, etc.)\n", " | \n", " | Arrays should be constructed using `array`, `zeros` or `empty` (refer\n", " | to the See Also section below). The parameters given here refer to\n", " | a low-level method (`ndarray(...)`) for instantiating an array.\n", " | \n", " | For more information, refer to the `numpy` module and examine the\n", " | methods and attributes of an array.\n", " | \n", " | Parameters\n", " | ----------\n", " | (for the __new__ method; see Notes below)\n", " | \n", " | shape : tuple of ints\n", " | Shape of created array.\n", " | dtype : data-type, optional\n", " | Any object that can be interpreted as a numpy data type.\n", " | buffer : object exposing buffer interface, optional\n", " | Used to fill the array with data.\n", " | offset : int, optional\n", " | Offset of array data in buffer.\n", " | strides : tuple of ints, optional\n", " | Strides of data in memory.\n", " | order : {'C', 'F'}, optional\n", " | Row-major (C-style) or column-major (Fortran-style) order.\n", " | \n", " | Attributes\n", " | ----------\n", " | T : ndarray\n", " | Transpose of the array.\n", " | data : buffer\n", " | The array's elements, in memory.\n", " | dtype : dtype object\n", " | Describes the format of the elements in the array.\n", " | flags : dict\n", " | Dictionary containing information related to memory use, e.g.,\n", " | 'C_CONTIGUOUS', 'OWNDATA', 'WRITEABLE', etc.\n", " | flat : numpy.flatiter object\n", " | Flattened version of the array as an iterator. The iterator\n", " | allows assignments, e.g., ``x.flat = 3`` (See `ndarray.flat` for\n", " | assignment examples; TODO).\n", " | imag : ndarray\n", " | Imaginary part of the array.\n", " | real : ndarray\n", " | Real part of the array.\n", " | size : int\n", " | Number of elements in the array.\n", " | itemsize : int\n", " | The memory use of each array element in bytes.\n", " | nbytes : int\n", " | The total number of bytes required to store the array data,\n", " | i.e., ``itemsize * size``.\n", " | ndim : int\n", " | The array's number of dimensions.\n", " | shape : tuple of ints\n", " | Shape of the array.\n", " | strides : tuple of ints\n", " | The step-size required to move from one element to the next in\n", " | memory. For example, a contiguous ``(3, 4)`` array of type\n", " | ``int16`` in C-order has strides ``(8, 2)``. This implies that\n", " | to move from element to element in memory requires jumps of 2 bytes.\n", " | To move from row-to-row, one needs to jump 8 bytes at a time\n", " | (``2 * 4``).\n", " | ctypes : ctypes object\n", " | Class containing properties of the array needed for interaction\n", " | with ctypes.\n", " | base : ndarray\n", " | If the array is a view into another array, that array is its `base`\n", " | (unless that array is also a view). The `base` array is where the\n", " | array data is actually stored.\n", " | \n", " | See Also\n", " | --------\n", " | array : Construct an array.\n", " | zeros : Create an array, each element of which is zero.\n", " | empty : Create an array, but leave its allocated memory unchanged (i.e.,\n", " | it contains \"garbage\").\n", " | dtype : Create a data-type.\n", " | numpy.typing.NDArray : A :term:`generic ` version\n", " | of ndarray.\n", " | \n", " | Notes\n", " | -----\n", " | There are two modes of creating an array using ``__new__``:\n", " | \n", " | 1. If `buffer` is None, then only `shape`, `dtype`, and `order`\n", " | are used.\n", " | 2. If `buffer` is an object exposing the buffer interface, then\n", " | all keywords are interpreted.\n", " | \n", " | No ``__init__`` method is needed because the array is fully initialized\n", " | after the ``__new__`` method.\n", " | \n", " | Examples\n", " | --------\n", " | These examples illustrate the low-level `ndarray` constructor. Refer\n", " | to the `See Also` section above for easier ways of constructing an\n", " | ndarray.\n", " | \n", " | First mode, `buffer` is None:\n", " | \n", " | >>> np.ndarray(shape=(2,2), dtype=float, order='F')\n", " | array([[0.0e+000, 0.0e+000], # random\n", " | [ nan, 2.5e-323]])\n", " | \n", " | Second mode:\n", " | \n", " | >>> np.ndarray((2,), buffer=np.array([1,2,3]),\n", " | ... offset=np.int_().itemsize,\n", " | ... dtype=int) # offset = 1*itemsize, i.e. skip first element\n", " | array([2, 3])\n", " | \n", " | Methods defined here:\n", " | \n", " | __abs__(self, /)\n", " | abs(self)\n", " | \n", " | __add__(self, value, /)\n", " | Return self+value.\n", " | \n", " | __and__(self, value, /)\n", " | Return self&value.\n", " | \n", " | __array__(...)\n", " | a.__array__([dtype], /) -> reference if type unchanged, copy otherwise.\n", " | \n", " | Returns either a new reference to self if dtype is not given or a new array\n", " | of provided data type if dtype is different from the current dtype of the\n", " | array.\n", " | \n", " | __array_function__(...)\n", " | \n", " | __array_prepare__(...)\n", " | a.__array_prepare__(obj) -> Object of same type as ndarray object obj.\n", " | \n", " | __array_ufunc__(...)\n", " | \n", " | __array_wrap__(...)\n", " | a.__array_wrap__(obj) -> Object of same type as ndarray object a.\n", " | \n", " | __bool__(self, /)\n", " | True if self else False\n", " | \n", " | __complex__(...)\n", " | \n", " | __contains__(self, key, /)\n", " | Return key in self.\n", " | \n", " | __copy__(...)\n", " | a.__copy__()\n", " | \n", " | Used if :func:`copy.copy` is called on an array. Returns a copy of the array.\n", " | \n", " | Equivalent to ``a.copy(order='K')``.\n", " | \n", " | __deepcopy__(...)\n", " | a.__deepcopy__(memo, /) -> Deep copy of array.\n", " | \n", " | Used if :func:`copy.deepcopy` is called on an array.\n", " | \n", " | __delitem__(self, key, /)\n", " | Delete self[key].\n", " | \n", " | __divmod__(self, value, /)\n", " | Return divmod(self, value).\n", " | \n", " | __eq__(self, value, /)\n", " | Return self==value.\n", " | \n", " | __float__(self, /)\n", " | float(self)\n", " | \n", " | __floordiv__(self, value, /)\n", " | Return self//value.\n", " | \n", " | __format__(...)\n", " | Default object formatter.\n", " | \n", " | __ge__(self, value, /)\n", " | Return self>=value.\n", " | \n", " | __getitem__(self, key, /)\n", " | Return self[key].\n", " | \n", " | __gt__(self, value, /)\n", " | Return self>value.\n", " | \n", " | __iadd__(self, value, /)\n", " | Return self+=value.\n", " | \n", " | __iand__(self, value, /)\n", " | Return self&=value.\n", " | \n", " | __ifloordiv__(self, value, /)\n", " | Return self//=value.\n", " | \n", " | __ilshift__(self, value, /)\n", " | Return self<<=value.\n", " | \n", " | __imatmul__(self, value, /)\n", " | Return self@=value.\n", " | \n", " | __imod__(self, value, /)\n", " | Return self%=value.\n", " | \n", " | __imul__(self, value, /)\n", " | Return self*=value.\n", " | \n", " | __index__(self, /)\n", " | Return self converted to an integer, if self is suitable for use as an index into a list.\n", " | \n", " | __int__(self, /)\n", " | int(self)\n", " | \n", " | __invert__(self, /)\n", " | ~self\n", " | \n", " | __ior__(self, value, /)\n", " | Return self|=value.\n", " | \n", " | __ipow__(self, value, /)\n", " | Return self**=value.\n", " | \n", " | __irshift__(self, value, /)\n", " | Return self>>=value.\n", " | \n", " | __isub__(self, value, /)\n", " | Return self-=value.\n", " | \n", " | __iter__(self, /)\n", " | Implement iter(self).\n", " | \n", " | __itruediv__(self, value, /)\n", " | Return self/=value.\n", " | \n", " | __ixor__(self, value, /)\n", " | Return self^=value.\n", " | \n", " | __le__(self, value, /)\n", " | Return self<=value.\n", " | \n", " | __len__(self, /)\n", " | Return len(self).\n", " | \n", " | __lshift__(self, value, /)\n", " | Return self<>self.\n", " | \n", " | __rshift__(self, value, /)\n", " | Return self>>value.\n", " | \n", " | __rsub__(self, value, /)\n", " | Return value-self.\n", " | \n", " | __rtruediv__(self, value, /)\n", " | Return value/self.\n", " | \n", " | __rxor__(self, value, /)\n", " | Return value^self.\n", " | \n", " | __setitem__(self, key, value, /)\n", " | Set self[key] to value.\n", " | \n", " | __setstate__(...)\n", " | a.__setstate__(state, /)\n", " | \n", " | For unpickling.\n", " | \n", " | The `state` argument must be a sequence that contains the following\n", " | elements:\n", " | \n", " | Parameters\n", " | ----------\n", " | version : int\n", " | optional pickle version. If omitted defaults to 0.\n", " | shape : tuple\n", " | dtype : data-type\n", " | isFortran : bool\n", " | rawdata : string or list\n", " | a binary string with the data (or a list if 'a' is an object array)\n", " | \n", " | __sizeof__(...)\n", " | Size of object in memory, in bytes.\n", " | \n", " | __str__(self, /)\n", " | Return str(self).\n", " | \n", " | __sub__(self, value, /)\n", " | Return self-value.\n", " | \n", " | __truediv__(self, value, /)\n", " | Return self/value.\n", " | \n", " | __xor__(self, value, /)\n", " | Return self^value.\n", " | \n", " | all(...)\n", " | a.all(axis=None, out=None, keepdims=False, *, where=True)\n", " | \n", " | Returns True if all elements evaluate to True.\n", " | \n", " | Refer to `numpy.all` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.all : equivalent function\n", " | \n", " | any(...)\n", " | a.any(axis=None, out=None, keepdims=False, *, where=True)\n", " | \n", " | Returns True if any of the elements of `a` evaluate to True.\n", " | \n", " | Refer to `numpy.any` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.any : equivalent function\n", " | \n", " | argmax(...)\n", " | a.argmax(axis=None, out=None)\n", " | \n", " | Return indices of the maximum values along the given axis.\n", " | \n", " | Refer to `numpy.argmax` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.argmax : equivalent function\n", " | \n", " | argmin(...)\n", " | a.argmin(axis=None, out=None)\n", " | \n", " | Return indices of the minimum values along the given axis.\n", " | \n", " | Refer to `numpy.argmin` for detailed documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.argmin : equivalent function\n", " | \n", " | argpartition(...)\n", " | a.argpartition(kth, axis=-1, kind='introselect', order=None)\n", " | \n", " | Returns the indices that would partition this array.\n", " | \n", " | Refer to `numpy.argpartition` for full documentation.\n", " | \n", " | .. versionadded:: 1.8.0\n", " | \n", " | See Also\n", " | --------\n", " | numpy.argpartition : equivalent function\n", " | \n", " | argsort(...)\n", " | a.argsort(axis=-1, kind=None, order=None)\n", " | \n", " | Returns the indices that would sort this array.\n", " | \n", " | Refer to `numpy.argsort` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.argsort : equivalent function\n", " | \n", " | astype(...)\n", " | a.astype(dtype, order='K', casting='unsafe', subok=True, copy=True)\n", " | \n", " | Copy of the array, cast to a specified type.\n", " | \n", " | Parameters\n", " | ----------\n", " | dtype : str or dtype\n", " | Typecode or data-type to which the array is cast.\n", " | order : {'C', 'F', 'A', 'K'}, optional\n", " | Controls the memory layout order of the result.\n", " | 'C' means C order, 'F' means Fortran order, 'A'\n", " | means 'F' order if all the arrays are Fortran contiguous,\n", " | 'C' order otherwise, and 'K' means as close to the\n", " | order the array elements appear in memory as possible.\n", " | Default is 'K'.\n", " | casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional\n", " | Controls what kind of data casting may occur. Defaults to 'unsafe'\n", " | for backwards compatibility.\n", " | \n", " | * 'no' means the data types should not be cast at all.\n", " | * 'equiv' means only byte-order changes are allowed.\n", " | * 'safe' means only casts which can preserve values are allowed.\n", " | * 'same_kind' means only safe casts or casts within a kind,\n", " | like float64 to float32, are allowed.\n", " | * 'unsafe' means any data conversions may be done.\n", " | subok : bool, optional\n", " | If True, then sub-classes will be passed-through (default), otherwise\n", " | the returned array will be forced to be a base-class array.\n", " | copy : bool, optional\n", " | By default, astype always returns a newly allocated array. If this\n", " | is set to false, and the `dtype`, `order`, and `subok`\n", " | requirements are satisfied, the input array is returned instead\n", " | of a copy.\n", " | \n", " | Returns\n", " | -------\n", " | arr_t : ndarray\n", " | Unless `copy` is False and the other conditions for returning the input\n", " | array are satisfied (see description for `copy` input parameter), `arr_t`\n", " | is a new array of the same shape as the input array, with dtype, order\n", " | given by `dtype`, `order`.\n", " | \n", " | Notes\n", " | -----\n", " | .. versionchanged:: 1.17.0\n", " | Casting between a simple data type and a structured one is possible only\n", " | for \"unsafe\" casting. Casting to multiple fields is allowed, but\n", " | casting from multiple fields is not.\n", " | \n", " | .. versionchanged:: 1.9.0\n", " | Casting from numeric to string types in 'safe' casting mode requires\n", " | that the string dtype length is long enough to store the max\n", " | integer/float value converted.\n", " | \n", " | Raises\n", " | ------\n", " | ComplexWarning\n", " | When casting from complex to float or int. To avoid this,\n", " | one should use ``a.real.astype(t)``.\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.array([1, 2, 2.5])\n", " | >>> x\n", " | array([1. , 2. , 2.5])\n", " | \n", " | >>> x.astype(int)\n", " | array([1, 2, 2])\n", " | \n", " | byteswap(...)\n", " | a.byteswap(inplace=False)\n", " | \n", " | Swap the bytes of the array elements\n", " | \n", " | Toggle between low-endian and big-endian data representation by\n", " | returning a byteswapped array, optionally swapped in-place.\n", " | Arrays of byte-strings are not swapped. The real and imaginary\n", " | parts of a complex number are swapped individually.\n", " | \n", " | Parameters\n", " | ----------\n", " | inplace : bool, optional\n", " | If ``True``, swap bytes in-place, default is ``False``.\n", " | \n", " | Returns\n", " | -------\n", " | out : ndarray\n", " | The byteswapped array. If `inplace` is ``True``, this is\n", " | a view to self.\n", " | \n", " | Examples\n", " | --------\n", " | >>> A = np.array([1, 256, 8755], dtype=np.int16)\n", " | >>> list(map(hex, A))\n", " | ['0x1', '0x100', '0x2233']\n", " | >>> A.byteswap(inplace=True)\n", " | array([ 256, 1, 13090], dtype=int16)\n", " | >>> list(map(hex, A))\n", " | ['0x100', '0x1', '0x3322']\n", " | \n", " | Arrays of byte-strings are not swapped\n", " | \n", " | >>> A = np.array([b'ceg', b'fac'])\n", " | >>> A.byteswap()\n", " | array([b'ceg', b'fac'], dtype='|S3')\n", " | \n", " | ``A.newbyteorder().byteswap()`` produces an array with the same values\n", " | but different representation in memory\n", " | \n", " | >>> A = np.array([1, 2, 3])\n", " | >>> A.view(np.uint8)\n", " | array([1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,\n", " | 0, 0], dtype=uint8)\n", " | >>> A.newbyteorder().byteswap(inplace=True)\n", " | array([1, 2, 3])\n", " | >>> A.view(np.uint8)\n", " | array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,\n", " | 0, 3], dtype=uint8)\n", " | \n", " | choose(...)\n", " | a.choose(choices, out=None, mode='raise')\n", " | \n", " | Use an index array to construct a new array from a set of choices.\n", " | \n", " | Refer to `numpy.choose` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.choose : equivalent function\n", " | \n", " | clip(...)\n", " | a.clip(min=None, max=None, out=None, **kwargs)\n", " | \n", " | Return an array whose values are limited to ``[min, max]``.\n", " | One of max or min must be given.\n", " | \n", " | Refer to `numpy.clip` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.clip : equivalent function\n", " | \n", " | compress(...)\n", " | a.compress(condition, axis=None, out=None)\n", " | \n", " | Return selected slices of this array along given axis.\n", " | \n", " | Refer to `numpy.compress` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.compress : equivalent function\n", " | \n", " | conj(...)\n", " | a.conj()\n", " | \n", " | Complex-conjugate all elements.\n", " | \n", " | Refer to `numpy.conjugate` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.conjugate : equivalent function\n", " | \n", " | conjugate(...)\n", " | a.conjugate()\n", " | \n", " | Return the complex conjugate, element-wise.\n", " | \n", " | Refer to `numpy.conjugate` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.conjugate : equivalent function\n", " | \n", " | copy(...)\n", " | a.copy(order='C')\n", " | \n", " | Return a copy of the array.\n", " | \n", " | Parameters\n", " | ----------\n", " | order : {'C', 'F', 'A', 'K'}, optional\n", " | Controls the memory layout of the copy. 'C' means C-order,\n", " | 'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,\n", " | 'C' otherwise. 'K' means match the layout of `a` as closely\n", " | as possible. (Note that this function and :func:`numpy.copy` are very\n", " | similar but have different default values for their order=\n", " | arguments, and this function always passes sub-classes through.)\n", " | \n", " | See also\n", " | --------\n", " | numpy.copy : Similar function with different default behavior\n", " | numpy.copyto\n", " | \n", " | Notes\n", " | -----\n", " | This function is the preferred method for creating an array copy. The\n", " | function :func:`numpy.copy` is similar, but it defaults to using order 'K',\n", " | and will not pass sub-classes through by default.\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.array([[1,2,3],[4,5,6]], order='F')\n", " | \n", " | >>> y = x.copy()\n", " | \n", " | >>> x.fill(0)\n", " | \n", " | >>> x\n", " | array([[0, 0, 0],\n", " | [0, 0, 0]])\n", " | \n", " | >>> y\n", " | array([[1, 2, 3],\n", " | [4, 5, 6]])\n", " | \n", " | >>> y.flags['C_CONTIGUOUS']\n", " | True\n", " | \n", " | cumprod(...)\n", " | a.cumprod(axis=None, dtype=None, out=None)\n", " | \n", " | Return the cumulative product of the elements along the given axis.\n", " | \n", " | Refer to `numpy.cumprod` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.cumprod : equivalent function\n", " | \n", " | cumsum(...)\n", " | a.cumsum(axis=None, dtype=None, out=None)\n", " | \n", " | Return the cumulative sum of the elements along the given axis.\n", " | \n", " | Refer to `numpy.cumsum` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.cumsum : equivalent function\n", " | \n", " | diagonal(...)\n", " | a.diagonal(offset=0, axis1=0, axis2=1)\n", " | \n", " | Return specified diagonals. In NumPy 1.9 the returned array is a\n", " | read-only view instead of a copy as in previous NumPy versions. In\n", " | a future version the read-only restriction will be removed.\n", " | \n", " | Refer to :func:`numpy.diagonal` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.diagonal : equivalent function\n", " | \n", " | dot(...)\n", " | a.dot(b, out=None)\n", " | \n", " | Dot product of two arrays.\n", " | \n", " | Refer to `numpy.dot` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.dot : equivalent function\n", " | \n", " | Examples\n", " | --------\n", " | >>> a = np.eye(2)\n", " | >>> b = np.ones((2, 2)) * 2\n", " | >>> a.dot(b)\n", " | array([[2., 2.],\n", " | [2., 2.]])\n", " | \n", " | This array method can be conveniently chained:\n", " | \n", " | >>> a.dot(b).dot(b)\n", " | array([[8., 8.],\n", " | [8., 8.]])\n", " | \n", " | dump(...)\n", " | a.dump(file)\n", " | \n", " | Dump a pickle of the array to the specified file.\n", " | The array can be read back with pickle.load or numpy.load.\n", " | \n", " | Parameters\n", " | ----------\n", " | file : str or Path\n", " | A string naming the dump file.\n", " | \n", " | .. versionchanged:: 1.17.0\n", " | `pathlib.Path` objects are now accepted.\n", " | \n", " | dumps(...)\n", " | a.dumps()\n", " | \n", " | Returns the pickle of the array as a string.\n", " | pickle.loads or numpy.loads will convert the string back to an array.\n", " | \n", " | Parameters\n", " | ----------\n", " | None\n", " | \n", " | fill(...)\n", " | a.fill(value)\n", " | \n", " | Fill the array with a scalar value.\n", " | \n", " | Parameters\n", " | ----------\n", " | value : scalar\n", " | All elements of `a` will be assigned this value.\n", " | \n", " | Examples\n", " | --------\n", " | >>> a = np.array([1, 2])\n", " | >>> a.fill(0)\n", " | >>> a\n", " | array([0, 0])\n", " | >>> a = np.empty(2)\n", " | >>> a.fill(1)\n", " | >>> a\n", " | array([1., 1.])\n", " | \n", " | flatten(...)\n", " | a.flatten(order='C')\n", " | \n", " | Return a copy of the array collapsed into one dimension.\n", " | \n", " | Parameters\n", " | ----------\n", " | order : {'C', 'F', 'A', 'K'}, optional\n", " | 'C' means to flatten in row-major (C-style) order.\n", " | 'F' means to flatten in column-major (Fortran-\n", " | style) order. 'A' means to flatten in column-major\n", " | order if `a` is Fortran *contiguous* in memory,\n", " | row-major order otherwise. 'K' means to flatten\n", " | `a` in the order the elements occur in memory.\n", " | The default is 'C'.\n", " | \n", " | Returns\n", " | -------\n", " | y : ndarray\n", " | A copy of the input array, flattened to one dimension.\n", " | \n", " | See Also\n", " | --------\n", " | ravel : Return a flattened array.\n", " | flat : A 1-D flat iterator over the array.\n", " | \n", " | Examples\n", " | --------\n", " | >>> a = np.array([[1,2], [3,4]])\n", " | >>> a.flatten()\n", " | array([1, 2, 3, 4])\n", " | >>> a.flatten('F')\n", " | array([1, 3, 2, 4])\n", " | \n", " | getfield(...)\n", " | a.getfield(dtype, offset=0)\n", " | \n", " | Returns a field of the given array as a certain type.\n", " | \n", " | A field is a view of the array data with a given data-type. The values in\n", " | the view are determined by the given type and the offset into the current\n", " | array in bytes. The offset needs to be such that the view dtype fits in the\n", " | array dtype; for example an array of dtype complex128 has 16-byte elements.\n", " | If taking a view with a 32-bit integer (4 bytes), the offset needs to be\n", " | between 0 and 12 bytes.\n", " | \n", " | Parameters\n", " | ----------\n", " | dtype : str or dtype\n", " | The data type of the view. The dtype size of the view can not be larger\n", " | than that of the array itself.\n", " | offset : int\n", " | Number of bytes to skip before beginning the element view.\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.diag([1.+1.j]*2)\n", " | >>> x[1, 1] = 2 + 4.j\n", " | >>> x\n", " | array([[1.+1.j, 0.+0.j],\n", " | [0.+0.j, 2.+4.j]])\n", " | >>> x.getfield(np.float64)\n", " | array([[1., 0.],\n", " | [0., 2.]])\n", " | \n", " | By choosing an offset of 8 bytes we can select the complex part of the\n", " | array for our view:\n", " | \n", " | >>> x.getfield(np.float64, offset=8)\n", " | array([[1., 0.],\n", " | [0., 4.]])\n", " | \n", " | item(...)\n", " | a.item(*args)\n", " | \n", " | Copy an element of an array to a standard Python scalar and return it.\n", " | \n", " | Parameters\n", " | ----------\n", " | \\*args : Arguments (variable number and type)\n", " | \n", " | * none: in this case, the method only works for arrays\n", " | with one element (`a.size == 1`), which element is\n", " | copied into a standard Python scalar object and returned.\n", " | \n", " | * int_type: this argument is interpreted as a flat index into\n", " | the array, specifying which element to copy and return.\n", " | \n", " | * tuple of int_types: functions as does a single int_type argument,\n", " | except that the argument is interpreted as an nd-index into the\n", " | array.\n", " | \n", " | Returns\n", " | -------\n", " | z : Standard Python scalar object\n", " | A copy of the specified element of the array as a suitable\n", " | Python scalar\n", " | \n", " | Notes\n", " | -----\n", " | When the data type of `a` is longdouble or clongdouble, item() returns\n", " | a scalar array object because there is no available Python scalar that\n", " | would not lose information. Void arrays return a buffer object for item(),\n", " | unless fields are defined, in which case a tuple is returned.\n", " | \n", " | `item` is very similar to a[args], except, instead of an array scalar,\n", " | a standard Python scalar is returned. This can be useful for speeding up\n", " | access to elements of the array and doing arithmetic on elements of the\n", " | array using Python's optimized math.\n", " | \n", " | Examples\n", " | --------\n", " | >>> np.random.seed(123)\n", " | >>> x = np.random.randint(9, size=(3, 3))\n", " | >>> x\n", " | array([[2, 2, 6],\n", " | [1, 3, 6],\n", " | [1, 0, 1]])\n", " | >>> x.item(3)\n", " | 1\n", " | >>> x.item(7)\n", " | 0\n", " | >>> x.item((0, 1))\n", " | 2\n", " | >>> x.item((2, 2))\n", " | 1\n", " | \n", " | itemset(...)\n", " | a.itemset(*args)\n", " | \n", " | Insert scalar into an array (scalar is cast to array's dtype, if possible)\n", " | \n", " | There must be at least 1 argument, and define the last argument\n", " | as *item*. Then, ``a.itemset(*args)`` is equivalent to but faster\n", " | than ``a[args] = item``. The item should be a scalar value and `args`\n", " | must select a single item in the array `a`.\n", " | \n", " | Parameters\n", " | ----------\n", " | \\*args : Arguments\n", " | If one argument: a scalar, only used in case `a` is of size 1.\n", " | If two arguments: the last argument is the value to be set\n", " | and must be a scalar, the first argument specifies a single array\n", " | element location. It is either an int or a tuple.\n", " | \n", " | Notes\n", " | -----\n", " | Compared to indexing syntax, `itemset` provides some speed increase\n", " | for placing a scalar into a particular location in an `ndarray`,\n", " | if you must do this. However, generally this is discouraged:\n", " | among other problems, it complicates the appearance of the code.\n", " | Also, when using `itemset` (and `item`) inside a loop, be sure\n", " | to assign the methods to a local variable to avoid the attribute\n", " | look-up at each loop iteration.\n", " | \n", " | Examples\n", " | --------\n", " | >>> np.random.seed(123)\n", " | >>> x = np.random.randint(9, size=(3, 3))\n", " | >>> x\n", " | array([[2, 2, 6],\n", " | [1, 3, 6],\n", " | [1, 0, 1]])\n", " | >>> x.itemset(4, 0)\n", " | >>> x.itemset((2, 2), 9)\n", " | >>> x\n", " | array([[2, 2, 6],\n", " | [1, 0, 6],\n", " | [1, 0, 9]])\n", " | \n", " | max(...)\n", " | a.max(axis=None, out=None, keepdims=False, initial=, where=True)\n", " | \n", " | Return the maximum along a given axis.\n", " | \n", " | Refer to `numpy.amax` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.amax : equivalent function\n", " | \n", " | mean(...)\n", " | a.mean(axis=None, dtype=None, out=None, keepdims=False, *, where=True)\n", " | \n", " | Returns the average of the array elements along given axis.\n", " | \n", " | Refer to `numpy.mean` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.mean : equivalent function\n", " | \n", " | min(...)\n", " | a.min(axis=None, out=None, keepdims=False, initial=, where=True)\n", " | \n", " | Return the minimum along a given axis.\n", " | \n", " | Refer to `numpy.amin` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.amin : equivalent function\n", " | \n", " | newbyteorder(...)\n", " | arr.newbyteorder(new_order='S', /)\n", " | \n", " | Return the array with the same data viewed with a different byte order.\n", " | \n", " | Equivalent to::\n", " | \n", " | arr.view(arr.dtype.newbytorder(new_order))\n", " | \n", " | Changes are also made in all fields and sub-arrays of the array data\n", " | type.\n", " | \n", " | \n", " | \n", " | Parameters\n", " | ----------\n", " | new_order : string, optional\n", " | Byte order to force; a value from the byte order specifications\n", " | below. `new_order` codes can be any of:\n", " | \n", " | * 'S' - swap dtype from current to opposite endian\n", " | * {'<', 'little'} - little endian\n", " | * {'>', 'big'} - big endian\n", " | * '=' - native order, equivalent to `sys.byteorder`\n", " | * {'|', 'I'} - ignore (no change to byte order)\n", " | \n", " | The default value ('S') results in swapping the current\n", " | byte order.\n", " | \n", " | \n", " | Returns\n", " | -------\n", " | new_arr : array\n", " | New array object with the dtype reflecting given change to the\n", " | byte order.\n", " | \n", " | nonzero(...)\n", " | a.nonzero()\n", " | \n", " | Return the indices of the elements that are non-zero.\n", " | \n", " | Refer to `numpy.nonzero` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.nonzero : equivalent function\n", " | \n", " | partition(...)\n", " | a.partition(kth, axis=-1, kind='introselect', order=None)\n", " | \n", " | Rearranges the elements in the array in such a way that the value of the\n", " | element in kth position is in the position it would be in a sorted array.\n", " | All elements smaller than the kth element are moved before this element and\n", " | all equal or greater are moved behind it. The ordering of the elements in\n", " | the two partitions is undefined.\n", " | \n", " | .. versionadded:: 1.8.0\n", " | \n", " | Parameters\n", " | ----------\n", " | kth : int or sequence of ints\n", " | Element index to partition by. The kth element value will be in its\n", " | final sorted position and all smaller elements will be moved before it\n", " | and all equal or greater elements behind it.\n", " | The order of all elements in the partitions is undefined.\n", " | If provided with a sequence of kth it will partition all elements\n", " | indexed by kth of them into their sorted position at once.\n", " | axis : int, optional\n", " | Axis along which to sort. Default is -1, which means sort along the\n", " | last axis.\n", " | kind : {'introselect'}, optional\n", " | Selection algorithm. Default is 'introselect'.\n", " | order : str or list of str, optional\n", " | When `a` is an array with fields defined, this argument specifies\n", " | which fields to compare first, second, etc. A single field can\n", " | be specified as a string, and not all fields need to be specified,\n", " | but unspecified fields will still be used, in the order in which\n", " | they come up in the dtype, to break ties.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.partition : Return a parititioned copy of an array.\n", " | argpartition : Indirect partition.\n", " | sort : Full sort.\n", " | \n", " | Notes\n", " | -----\n", " | See ``np.partition`` for notes on the different algorithms.\n", " | \n", " | Examples\n", " | --------\n", " | >>> a = np.array([3, 4, 2, 1])\n", " | >>> a.partition(3)\n", " | >>> a\n", " | array([2, 1, 3, 4])\n", " | \n", " | >>> a.partition((1, 3))\n", " | >>> a\n", " | array([1, 2, 3, 4])\n", " | \n", " | prod(...)\n", " | a.prod(axis=None, dtype=None, out=None, keepdims=False, initial=1, where=True)\n", " | \n", " | Return the product of the array elements over the given axis\n", " | \n", " | Refer to `numpy.prod` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.prod : equivalent function\n", " | \n", " | ptp(...)\n", " | a.ptp(axis=None, out=None, keepdims=False)\n", " | \n", " | Peak to peak (maximum - minimum) value along a given axis.\n", " | \n", " | Refer to `numpy.ptp` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.ptp : equivalent function\n", " | \n", " | put(...)\n", " | a.put(indices, values, mode='raise')\n", " | \n", " | Set ``a.flat[n] = values[n]`` for all `n` in indices.\n", " | \n", " | Refer to `numpy.put` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.put : equivalent function\n", " | \n", " | ravel(...)\n", " | a.ravel([order])\n", " | \n", " | Return a flattened array.\n", " | \n", " | Refer to `numpy.ravel` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.ravel : equivalent function\n", " | \n", " | ndarray.flat : a flat iterator on the array.\n", " | \n", " | repeat(...)\n", " | a.repeat(repeats, axis=None)\n", " | \n", " | Repeat elements of an array.\n", " | \n", " | Refer to `numpy.repeat` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.repeat : equivalent function\n", " | \n", " | reshape(...)\n", " | a.reshape(shape, order='C')\n", " | \n", " | Returns an array containing the same data with a new shape.\n", " | \n", " | Refer to `numpy.reshape` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.reshape : equivalent function\n", " | \n", " | Notes\n", " | -----\n", " | Unlike the free function `numpy.reshape`, this method on `ndarray` allows\n", " | the elements of the shape parameter to be passed in as separate arguments.\n", " | For example, ``a.reshape(10, 11)`` is equivalent to\n", " | ``a.reshape((10, 11))``.\n", " | \n", " | resize(...)\n", " | a.resize(new_shape, refcheck=True)\n", " | \n", " | Change shape and size of array in-place.\n", " | \n", " | Parameters\n", " | ----------\n", " | new_shape : tuple of ints, or `n` ints\n", " | Shape of resized array.\n", " | refcheck : bool, optional\n", " | If False, reference count will not be checked. Default is True.\n", " | \n", " | Returns\n", " | -------\n", " | None\n", " | \n", " | Raises\n", " | ------\n", " | ValueError\n", " | If `a` does not own its own data or references or views to it exist,\n", " | and the data memory must be changed.\n", " | PyPy only: will always raise if the data memory must be changed, since\n", " | there is no reliable way to determine if references or views to it\n", " | exist.\n", " | \n", " | SystemError\n", " | If the `order` keyword argument is specified. This behaviour is a\n", " | bug in NumPy.\n", " | \n", " | See Also\n", " | --------\n", " | resize : Return a new array with the specified shape.\n", " | \n", " | Notes\n", " | -----\n", " | This reallocates space for the data area if necessary.\n", " | \n", " | Only contiguous arrays (data elements consecutive in memory) can be\n", " | resized.\n", " | \n", " | The purpose of the reference count check is to make sure you\n", " | do not use this array as a buffer for another Python object and then\n", " | reallocate the memory. However, reference counts can increase in\n", " | other ways so if you are sure that you have not shared the memory\n", " | for this array with another Python object, then you may safely set\n", " | `refcheck` to False.\n", " | \n", " | Examples\n", " | --------\n", " | Shrinking an array: array is flattened (in the order that the data are\n", " | stored in memory), resized, and reshaped:\n", " | \n", " | >>> a = np.array([[0, 1], [2, 3]], order='C')\n", " | >>> a.resize((2, 1))\n", " | >>> a\n", " | array([[0],\n", " | [1]])\n", " | \n", " | >>> a = np.array([[0, 1], [2, 3]], order='F')\n", " | >>> a.resize((2, 1))\n", " | >>> a\n", " | array([[0],\n", " | [2]])\n", " | \n", " | Enlarging an array: as above, but missing entries are filled with zeros:\n", " | \n", " | >>> b = np.array([[0, 1], [2, 3]])\n", " | >>> b.resize(2, 3) # new_shape parameter doesn't have to be a tuple\n", " | >>> b\n", " | array([[0, 1, 2],\n", " | [3, 0, 0]])\n", " | \n", " | Referencing an array prevents resizing...\n", " | \n", " | >>> c = a\n", " | >>> a.resize((1, 1))\n", " | Traceback (most recent call last):\n", " | ...\n", " | ValueError: cannot resize an array that references or is referenced ...\n", " | \n", " | Unless `refcheck` is False:\n", " | \n", " | >>> a.resize((1, 1), refcheck=False)\n", " | >>> a\n", " | array([[0]])\n", " | >>> c\n", " | array([[0]])\n", " | \n", " | round(...)\n", " | a.round(decimals=0, out=None)\n", " | \n", " | Return `a` with each element rounded to the given number of decimals.\n", " | \n", " | Refer to `numpy.around` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.around : equivalent function\n", " | \n", " | searchsorted(...)\n", " | a.searchsorted(v, side='left', sorter=None)\n", " | \n", " | Find indices where elements of v should be inserted in a to maintain order.\n", " | \n", " | For full documentation, see `numpy.searchsorted`\n", " | \n", " | See Also\n", " | --------\n", " | numpy.searchsorted : equivalent function\n", " | \n", " | setfield(...)\n", " | a.setfield(val, dtype, offset=0)\n", " | \n", " | Put a value into a specified place in a field defined by a data-type.\n", " | \n", " | Place `val` into `a`'s field defined by `dtype` and beginning `offset`\n", " | bytes into the field.\n", " | \n", " | Parameters\n", " | ----------\n", " | val : object\n", " | Value to be placed in field.\n", " | dtype : dtype object\n", " | Data-type of the field in which to place `val`.\n", " | offset : int, optional\n", " | The number of bytes into the field at which to place `val`.\n", " | \n", " | Returns\n", " | -------\n", " | None\n", " | \n", " | See Also\n", " | --------\n", " | getfield\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.eye(3)\n", " | >>> x.getfield(np.float64)\n", " | array([[1., 0., 0.],\n", " | [0., 1., 0.],\n", " | [0., 0., 1.]])\n", " | >>> x.setfield(3, np.int32)\n", " | >>> x.getfield(np.int32)\n", " | array([[3, 3, 3],\n", " | [3, 3, 3],\n", " | [3, 3, 3]], dtype=int32)\n", " | >>> x\n", " | array([[1.0e+000, 1.5e-323, 1.5e-323],\n", " | [1.5e-323, 1.0e+000, 1.5e-323],\n", " | [1.5e-323, 1.5e-323, 1.0e+000]])\n", " | >>> x.setfield(np.eye(3), np.int32)\n", " | >>> x\n", " | array([[1., 0., 0.],\n", " | [0., 1., 0.],\n", " | [0., 0., 1.]])\n", " | \n", " | setflags(...)\n", " | a.setflags(write=None, align=None, uic=None)\n", " | \n", " | Set array flags WRITEABLE, ALIGNED, (WRITEBACKIFCOPY and UPDATEIFCOPY),\n", " | respectively.\n", " | \n", " | These Boolean-valued flags affect how numpy interprets the memory\n", " | area used by `a` (see Notes below). The ALIGNED flag can only\n", " | be set to True if the data is actually aligned according to the type.\n", " | The WRITEBACKIFCOPY and (deprecated) UPDATEIFCOPY flags can never be set\n", " | to True. The flag WRITEABLE can only be set to True if the array owns its\n", " | own memory, or the ultimate owner of the memory exposes a writeable buffer\n", " | interface, or is a string. (The exception for string is made so that\n", " | unpickling can be done without copying memory.)\n", " | \n", " | Parameters\n", " | ----------\n", " | write : bool, optional\n", " | Describes whether or not `a` can be written to.\n", " | align : bool, optional\n", " | Describes whether or not `a` is aligned properly for its type.\n", " | uic : bool, optional\n", " | Describes whether or not `a` is a copy of another \"base\" array.\n", " | \n", " | Notes\n", " | -----\n", " | Array flags provide information about how the memory area used\n", " | for the array is to be interpreted. There are 7 Boolean flags\n", " | in use, only four of which can be changed by the user:\n", " | WRITEBACKIFCOPY, UPDATEIFCOPY, WRITEABLE, and ALIGNED.\n", " | \n", " | WRITEABLE (W) the data area can be written to;\n", " | \n", " | ALIGNED (A) the data and strides are aligned appropriately for the hardware\n", " | (as determined by the compiler);\n", " | \n", " | UPDATEIFCOPY (U) (deprecated), replaced by WRITEBACKIFCOPY;\n", " | \n", " | WRITEBACKIFCOPY (X) this array is a copy of some other array (referenced\n", " | by .base). When the C-API function PyArray_ResolveWritebackIfCopy is\n", " | called, the base array will be updated with the contents of this array.\n", " | \n", " | All flags can be accessed using the single (upper case) letter as well\n", " | as the full name.\n", " | \n", " | Examples\n", " | --------\n", " | >>> y = np.array([[3, 1, 7],\n", " | ... [2, 0, 0],\n", " | ... [8, 5, 9]])\n", " | >>> y\n", " | array([[3, 1, 7],\n", " | [2, 0, 0],\n", " | [8, 5, 9]])\n", " | >>> y.flags\n", " | C_CONTIGUOUS : True\n", " | F_CONTIGUOUS : False\n", " | OWNDATA : True\n", " | WRITEABLE : True\n", " | ALIGNED : True\n", " | WRITEBACKIFCOPY : False\n", " | UPDATEIFCOPY : False\n", " | >>> y.setflags(write=0, align=0)\n", " | >>> y.flags\n", " | C_CONTIGUOUS : True\n", " | F_CONTIGUOUS : False\n", " | OWNDATA : True\n", " | WRITEABLE : False\n", " | ALIGNED : False\n", " | WRITEBACKIFCOPY : False\n", " | UPDATEIFCOPY : False\n", " | >>> y.setflags(uic=1)\n", " | Traceback (most recent call last):\n", " | File \"\", line 1, in \n", " | ValueError: cannot set WRITEBACKIFCOPY flag to True\n", " | \n", " | sort(...)\n", " | a.sort(axis=-1, kind=None, order=None)\n", " | \n", " | Sort an array in-place. Refer to `numpy.sort` for full documentation.\n", " | \n", " | Parameters\n", " | ----------\n", " | axis : int, optional\n", " | Axis along which to sort. Default is -1, which means sort along the\n", " | last axis.\n", " | kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional\n", " | Sorting algorithm. The default is 'quicksort'. Note that both 'stable'\n", " | and 'mergesort' use timsort under the covers and, in general, the\n", " | actual implementation will vary with datatype. The 'mergesort' option\n", " | is retained for backwards compatibility.\n", " | \n", " | .. versionchanged:: 1.15.0\n", " | The 'stable' option was added.\n", " | \n", " | order : str or list of str, optional\n", " | When `a` is an array with fields defined, this argument specifies\n", " | which fields to compare first, second, etc. A single field can\n", " | be specified as a string, and not all fields need be specified,\n", " | but unspecified fields will still be used, in the order in which\n", " | they come up in the dtype, to break ties.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.sort : Return a sorted copy of an array.\n", " | numpy.argsort : Indirect sort.\n", " | numpy.lexsort : Indirect stable sort on multiple keys.\n", " | numpy.searchsorted : Find elements in sorted array.\n", " | numpy.partition: Partial sort.\n", " | \n", " | Notes\n", " | -----\n", " | See `numpy.sort` for notes on the different sorting algorithms.\n", " | \n", " | Examples\n", " | --------\n", " | >>> a = np.array([[1,4], [3,1]])\n", " | >>> a.sort(axis=1)\n", " | >>> a\n", " | array([[1, 4],\n", " | [1, 3]])\n", " | >>> a.sort(axis=0)\n", " | >>> a\n", " | array([[1, 3],\n", " | [1, 4]])\n", " | \n", " | Use the `order` keyword to specify a field to use when sorting a\n", " | structured array:\n", " | \n", " | >>> a = np.array([('a', 2), ('c', 1)], dtype=[('x', 'S1'), ('y', int)])\n", " | >>> a.sort(order='y')\n", " | >>> a\n", " | array([(b'c', 1), (b'a', 2)],\n", " | dtype=[('x', 'S1'), ('y', '>> x = np.array([[0, 1], [2, 3]], dtype='>> x.tobytes()\n", " | b'\\x00\\x00\\x01\\x00\\x02\\x00\\x03\\x00'\n", " | >>> x.tobytes('C') == x.tobytes()\n", " | True\n", " | >>> x.tobytes('F')\n", " | b'\\x00\\x00\\x02\\x00\\x01\\x00\\x03\\x00'\n", " | \n", " | tofile(...)\n", " | a.tofile(fid, sep=\"\", format=\"%s\")\n", " | \n", " | Write array to a file as text or binary (default).\n", " | \n", " | Data is always written in 'C' order, independent of the order of `a`.\n", " | The data produced by this method can be recovered using the function\n", " | fromfile().\n", " | \n", " | Parameters\n", " | ----------\n", " | fid : file or str or Path\n", " | An open file object, or a string containing a filename.\n", " | \n", " | .. versionchanged:: 1.17.0\n", " | `pathlib.Path` objects are now accepted.\n", " | \n", " | sep : str\n", " | Separator between array items for text output.\n", " | If \"\" (empty), a binary file is written, equivalent to\n", " | ``file.write(a.tobytes())``.\n", " | format : str\n", " | Format string for text file output.\n", " | Each entry in the array is formatted to text by first converting\n", " | it to the closest Python type, and then using \"format\" % item.\n", " | \n", " | Notes\n", " | -----\n", " | This is a convenience function for quick storage of array data.\n", " | Information on endianness and precision is lost, so this method is not a\n", " | good choice for files intended to archive data or transport data between\n", " | machines with different endianness. Some of these problems can be overcome\n", " | by outputting the data as text files, at the expense of speed and file\n", " | size.\n", " | \n", " | When fid is a file object, array contents are directly written to the\n", " | file, bypassing the file object's ``write`` method. As a result, tofile\n", " | cannot be used with files objects supporting compression (e.g., GzipFile)\n", " | or file-like objects that do not support ``fileno()`` (e.g., BytesIO).\n", " | \n", " | tolist(...)\n", " | a.tolist()\n", " | \n", " | Return the array as an ``a.ndim``-levels deep nested list of Python scalars.\n", " | \n", " | Return a copy of the array data as a (nested) Python list.\n", " | Data items are converted to the nearest compatible builtin Python type, via\n", " | the `~numpy.ndarray.item` function.\n", " | \n", " | If ``a.ndim`` is 0, then since the depth of the nested list is 0, it will\n", " | not be a list at all, but a simple Python scalar.\n", " | \n", " | Parameters\n", " | ----------\n", " | none\n", " | \n", " | Returns\n", " | -------\n", " | y : object, or list of object, or list of list of object, or ...\n", " | The possibly nested list of array elements.\n", " | \n", " | Notes\n", " | -----\n", " | The array may be recreated via ``a = np.array(a.tolist())``, although this\n", " | may sometimes lose precision.\n", " | \n", " | Examples\n", " | --------\n", " | For a 1D array, ``a.tolist()`` is almost the same as ``list(a)``,\n", " | except that ``tolist`` changes numpy scalars to Python scalars:\n", " | \n", " | >>> a = np.uint32([1, 2])\n", " | >>> a_list = list(a)\n", " | >>> a_list\n", " | [1, 2]\n", " | >>> type(a_list[0])\n", " | \n", " | >>> a_tolist = a.tolist()\n", " | >>> a_tolist\n", " | [1, 2]\n", " | >>> type(a_tolist[0])\n", " | \n", " | \n", " | Additionally, for a 2D array, ``tolist`` applies recursively:\n", " | \n", " | >>> a = np.array([[1, 2], [3, 4]])\n", " | >>> list(a)\n", " | [array([1, 2]), array([3, 4])]\n", " | >>> a.tolist()\n", " | [[1, 2], [3, 4]]\n", " | \n", " | The base case for this recursion is a 0D array:\n", " | \n", " | >>> a = np.array(1)\n", " | >>> list(a)\n", " | Traceback (most recent call last):\n", " | ...\n", " | TypeError: iteration over a 0-d array\n", " | >>> a.tolist()\n", " | 1\n", " | \n", " | tostring(...)\n", " | a.tostring(order='C')\n", " | \n", " | A compatibility alias for `tobytes`, with exactly the same behavior.\n", " | \n", " | Despite its name, it returns `bytes` not `str`\\ s.\n", " | \n", " | .. deprecated:: 1.19.0\n", " | \n", " | trace(...)\n", " | a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)\n", " | \n", " | Return the sum along diagonals of the array.\n", " | \n", " | Refer to `numpy.trace` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.trace : equivalent function\n", " | \n", " | transpose(...)\n", " | a.transpose(*axes)\n", " | \n", " | Returns a view of the array with axes transposed.\n", " | \n", " | For a 1-D array this has no effect, as a transposed vector is simply the\n", " | same vector. To convert a 1-D array into a 2D column vector, an additional\n", " | dimension must be added. `np.atleast2d(a).T` achieves this, as does\n", " | `a[:, np.newaxis]`.\n", " | For a 2-D array, this is a standard matrix transpose.\n", " | For an n-D array, if axes are given, their order indicates how the\n", " | axes are permuted (see Examples). If axes are not provided and\n", " | ``a.shape = (i[0], i[1], ... i[n-2], i[n-1])``, then\n", " | ``a.transpose().shape = (i[n-1], i[n-2], ... i[1], i[0])``.\n", " | \n", " | Parameters\n", " | ----------\n", " | axes : None, tuple of ints, or `n` ints\n", " | \n", " | * None or no argument: reverses the order of the axes.\n", " | \n", " | * tuple of ints: `i` in the `j`-th place in the tuple means `a`'s\n", " | `i`-th axis becomes `a.transpose()`'s `j`-th axis.\n", " | \n", " | * `n` ints: same as an n-tuple of the same ints (this form is\n", " | intended simply as a \"convenience\" alternative to the tuple form)\n", " | \n", " | Returns\n", " | -------\n", " | out : ndarray\n", " | View of `a`, with axes suitably permuted.\n", " | \n", " | See Also\n", " | --------\n", " | transpose : Equivalent function\n", " | ndarray.T : Array property returning the array transposed.\n", " | ndarray.reshape : Give a new shape to an array without changing its data.\n", " | \n", " | Examples\n", " | --------\n", " | >>> a = np.array([[1, 2], [3, 4]])\n", " | >>> a\n", " | array([[1, 2],\n", " | [3, 4]])\n", " | >>> a.transpose()\n", " | array([[1, 3],\n", " | [2, 4]])\n", " | >>> a.transpose((1, 0))\n", " | array([[1, 3],\n", " | [2, 4]])\n", " | >>> a.transpose(1, 0)\n", " | array([[1, 3],\n", " | [2, 4]])\n", " | \n", " | var(...)\n", " | a.var(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True)\n", " | \n", " | Returns the variance of the array elements, along given axis.\n", " | \n", " | Refer to `numpy.var` for full documentation.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.var : equivalent function\n", " | \n", " | view(...)\n", " | a.view([dtype][, type])\n", " | \n", " | New view of array with the same data.\n", " | \n", " | .. note::\n", " | Passing None for ``dtype`` is different from omitting the parameter,\n", " | since the former invokes ``dtype(None)`` which is an alias for\n", " | ``dtype('float_')``.\n", " | \n", " | Parameters\n", " | ----------\n", " | dtype : data-type or ndarray sub-class, optional\n", " | Data-type descriptor of the returned view, e.g., float32 or int16.\n", " | Omitting it results in the view having the same data-type as `a`.\n", " | This argument can also be specified as an ndarray sub-class, which\n", " | then specifies the type of the returned object (this is equivalent to\n", " | setting the ``type`` parameter).\n", " | type : Python type, optional\n", " | Type of the returned view, e.g., ndarray or matrix. Again, omission\n", " | of the parameter results in type preservation.\n", " | \n", " | Notes\n", " | -----\n", " | ``a.view()`` is used two different ways:\n", " | \n", " | ``a.view(some_dtype)`` or ``a.view(dtype=some_dtype)`` constructs a view\n", " | of the array's memory with a different data-type. This can cause a\n", " | reinterpretation of the bytes of memory.\n", " | \n", " | ``a.view(ndarray_subclass)`` or ``a.view(type=ndarray_subclass)`` just\n", " | returns an instance of `ndarray_subclass` that looks at the same array\n", " | (same shape, dtype, etc.) This does not cause a reinterpretation of the\n", " | memory.\n", " | \n", " | For ``a.view(some_dtype)``, if ``some_dtype`` has a different number of\n", " | bytes per entry than the previous dtype (for example, converting a\n", " | regular array to a structured array), then the behavior of the view\n", " | cannot be predicted just from the superficial appearance of ``a`` (shown\n", " | by ``print(a)``). It also depends on exactly how ``a`` is stored in\n", " | memory. Therefore if ``a`` is C-ordered versus fortran-ordered, versus\n", " | defined as a slice or transpose, etc., the view may give different\n", " | results.\n", " | \n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])\n", " | \n", " | Viewing array data using a different type and dtype:\n", " | \n", " | >>> y = x.view(dtype=np.int16, type=np.matrix)\n", " | >>> y\n", " | matrix([[513]], dtype=int16)\n", " | >>> print(type(y))\n", " | \n", " | \n", " | Creating a view on a structured array so it can be used in calculations\n", " | \n", " | >>> x = np.array([(1, 2),(3,4)], dtype=[('a', np.int8), ('b', np.int8)])\n", " | >>> xv = x.view(dtype=np.int8).reshape(-1,2)\n", " | >>> xv\n", " | array([[1, 2],\n", " | [3, 4]], dtype=int8)\n", " | >>> xv.mean(0)\n", " | array([2., 3.])\n", " | \n", " | Making changes to the view changes the underlying array\n", " | \n", " | >>> xv[0,1] = 20\n", " | >>> x\n", " | array([(1, 20), (3, 4)], dtype=[('a', 'i1'), ('b', 'i1')])\n", " | \n", " | Using a view to convert an array to a recarray:\n", " | \n", " | >>> z = x.view(np.recarray)\n", " | >>> z.a\n", " | array([1, 3], dtype=int8)\n", " | \n", " | Views share data:\n", " | \n", " | >>> x[0] = (9, 10)\n", " | >>> z[0]\n", " | (9, 10)\n", " | \n", " | Views that change the dtype size (bytes per entry) should normally be\n", " | avoided on arrays defined by slices, transposes, fortran-ordering, etc.:\n", " | \n", " | >>> x = np.array([[1,2,3],[4,5,6]], dtype=np.int16)\n", " | >>> y = x[:, 0:2]\n", " | >>> y\n", " | array([[1, 2],\n", " | [4, 5]], dtype=int16)\n", " | >>> y.view(dtype=[('width', np.int16), ('length', np.int16)])\n", " | Traceback (most recent call last):\n", " | ...\n", " | ValueError: To change to a dtype of a different size, the array must be C-contiguous\n", " | >>> z = y.copy()\n", " | >>> z.view(dtype=[('width', np.int16), ('length', np.int16)])\n", " | array([[(1, 2)],\n", " | [(4, 5)]], dtype=[('width', '>> x = np.array([[1.,2.],[3.,4.]])\n", " | >>> x\n", " | array([[ 1., 2.],\n", " | [ 3., 4.]])\n", " | >>> x.T\n", " | array([[ 1., 3.],\n", " | [ 2., 4.]])\n", " | >>> x = np.array([1.,2.,3.,4.])\n", " | >>> x\n", " | array([ 1., 2., 3., 4.])\n", " | >>> x.T\n", " | array([ 1., 2., 3., 4.])\n", " | \n", " | See Also\n", " | --------\n", " | transpose\n", " | \n", " | __array_finalize__\n", " | None.\n", " | \n", " | __array_interface__\n", " | Array protocol: Python side.\n", " | \n", " | __array_priority__\n", " | Array priority.\n", " | \n", " | __array_struct__\n", " | Array protocol: C-struct side.\n", " | \n", " | base\n", " | Base object if memory is from some other object.\n", " | \n", " | Examples\n", " | --------\n", " | The base of an array that owns its memory is None:\n", " | \n", " | >>> x = np.array([1,2,3,4])\n", " | >>> x.base is None\n", " | True\n", " | \n", " | Slicing creates a view, whose memory is shared with x:\n", " | \n", " | >>> y = x[2:]\n", " | >>> y.base is x\n", " | True\n", " | \n", " | ctypes\n", " | An object to simplify the interaction of the array with the ctypes\n", " | module.\n", " | \n", " | This attribute creates an object that makes it easier to use arrays\n", " | when calling shared libraries with the ctypes module. The returned\n", " | object has, among others, data, shape, and strides attributes (see\n", " | Notes below) which themselves return ctypes objects that can be used\n", " | as arguments to a shared library.\n", " | \n", " | Parameters\n", " | ----------\n", " | None\n", " | \n", " | Returns\n", " | -------\n", " | c : Python object\n", " | Possessing attributes data, shape, strides, etc.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.ctypeslib\n", " | \n", " | Notes\n", " | -----\n", " | Below are the public attributes of this object which were documented\n", " | in \"Guide to NumPy\" (we have omitted undocumented public attributes,\n", " | as well as documented private attributes):\n", " | \n", " | .. autoattribute:: numpy.core._internal._ctypes.data\n", " | :noindex:\n", " | \n", " | .. autoattribute:: numpy.core._internal._ctypes.shape\n", " | :noindex:\n", " | \n", " | .. autoattribute:: numpy.core._internal._ctypes.strides\n", " | :noindex:\n", " | \n", " | .. automethod:: numpy.core._internal._ctypes.data_as\n", " | :noindex:\n", " | \n", " | .. automethod:: numpy.core._internal._ctypes.shape_as\n", " | :noindex:\n", " | \n", " | .. automethod:: numpy.core._internal._ctypes.strides_as\n", " | :noindex:\n", " | \n", " | If the ctypes module is not available, then the ctypes attribute\n", " | of array objects still returns something useful, but ctypes objects\n", " | are not returned and errors may be raised instead. In particular,\n", " | the object will still have the ``as_parameter`` attribute which will\n", " | return an integer equal to the data attribute.\n", " | \n", " | Examples\n", " | --------\n", " | >>> import ctypes\n", " | >>> x = np.array([[0, 1], [2, 3]], dtype=np.int32)\n", " | >>> x\n", " | array([[0, 1],\n", " | [2, 3]], dtype=int32)\n", " | >>> x.ctypes.data\n", " | 31962608 # may vary\n", " | >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_uint32))\n", " | <__main__.LP_c_uint object at 0x7ff2fc1fc200> # may vary\n", " | >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_uint32)).contents\n", " | c_uint(0)\n", " | >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_uint64)).contents\n", " | c_ulong(4294967296)\n", " | >>> x.ctypes.shape\n", " | # may vary\n", " | >>> x.ctypes.strides\n", " | # may vary\n", " | \n", " | data\n", " | Python buffer object pointing to the start of the array's data.\n", " | \n", " | dtype\n", " | Data-type of the array's elements.\n", " | \n", " | Parameters\n", " | ----------\n", " | None\n", " | \n", " | Returns\n", " | -------\n", " | d : numpy dtype object\n", " | \n", " | See Also\n", " | --------\n", " | numpy.dtype\n", " | \n", " | Examples\n", " | --------\n", " | >>> x\n", " | array([[0, 1],\n", " | [2, 3]])\n", " | >>> x.dtype\n", " | dtype('int32')\n", " | >>> type(x.dtype)\n", " | \n", " | \n", " | flags\n", " | Information about the memory layout of the array.\n", " | \n", " | Attributes\n", " | ----------\n", " | C_CONTIGUOUS (C)\n", " | The data is in a single, C-style contiguous segment.\n", " | F_CONTIGUOUS (F)\n", " | The data is in a single, Fortran-style contiguous segment.\n", " | OWNDATA (O)\n", " | The array owns the memory it uses or borrows it from another object.\n", " | WRITEABLE (W)\n", " | The data area can be written to. Setting this to False locks\n", " | the data, making it read-only. A view (slice, etc.) inherits WRITEABLE\n", " | from its base array at creation time, but a view of a writeable\n", " | array may be subsequently locked while the base array remains writeable.\n", " | (The opposite is not true, in that a view of a locked array may not\n", " | be made writeable. However, currently, locking a base object does not\n", " | lock any views that already reference it, so under that circumstance it\n", " | is possible to alter the contents of a locked array via a previously\n", " | created writeable view onto it.) Attempting to change a non-writeable\n", " | array raises a RuntimeError exception.\n", " | ALIGNED (A)\n", " | The data and all elements are aligned appropriately for the hardware.\n", " | WRITEBACKIFCOPY (X)\n", " | This array is a copy of some other array. The C-API function\n", " | PyArray_ResolveWritebackIfCopy must be called before deallocating\n", " | to the base array will be updated with the contents of this array.\n", " | UPDATEIFCOPY (U)\n", " | (Deprecated, use WRITEBACKIFCOPY) This array is a copy of some other array.\n", " | When this array is\n", " | deallocated, the base array will be updated with the contents of\n", " | this array.\n", " | FNC\n", " | F_CONTIGUOUS and not C_CONTIGUOUS.\n", " | FORC\n", " | F_CONTIGUOUS or C_CONTIGUOUS (one-segment test).\n", " | BEHAVED (B)\n", " | ALIGNED and WRITEABLE.\n", " | CARRAY (CA)\n", " | BEHAVED and C_CONTIGUOUS.\n", " | FARRAY (FA)\n", " | BEHAVED and F_CONTIGUOUS and not C_CONTIGUOUS.\n", " | \n", " | Notes\n", " | -----\n", " | The `flags` object can be accessed dictionary-like (as in ``a.flags['WRITEABLE']``),\n", " | or by using lowercased attribute names (as in ``a.flags.writeable``). Short flag\n", " | names are only supported in dictionary access.\n", " | \n", " | Only the WRITEBACKIFCOPY, UPDATEIFCOPY, WRITEABLE, and ALIGNED flags can be\n", " | changed by the user, via direct assignment to the attribute or dictionary\n", " | entry, or by calling `ndarray.setflags`.\n", " | \n", " | The array flags cannot be set arbitrarily:\n", " | \n", " | - UPDATEIFCOPY can only be set ``False``.\n", " | - WRITEBACKIFCOPY can only be set ``False``.\n", " | - ALIGNED can only be set ``True`` if the data is truly aligned.\n", " | - WRITEABLE can only be set ``True`` if the array owns its own memory\n", " | or the ultimate owner of the memory exposes a writeable buffer\n", " | interface or is a string.\n", " | \n", " | Arrays can be both C-style and Fortran-style contiguous simultaneously.\n", " | This is clear for 1-dimensional arrays, but can also be true for higher\n", " | dimensional arrays.\n", " | \n", " | Even for contiguous arrays a stride for a given dimension\n", " | ``arr.strides[dim]`` may be *arbitrary* if ``arr.shape[dim] == 1``\n", " | or the array has no elements.\n", " | It does *not* generally hold that ``self.strides[-1] == self.itemsize``\n", " | for C-style contiguous arrays or ``self.strides[0] == self.itemsize`` for\n", " | Fortran-style contiguous arrays is true.\n", " | \n", " | flat\n", " | A 1-D iterator over the array.\n", " | \n", " | This is a `numpy.flatiter` instance, which acts similarly to, but is not\n", " | a subclass of, Python's built-in iterator object.\n", " | \n", " | See Also\n", " | --------\n", " | flatten : Return a copy of the array collapsed into one dimension.\n", " | \n", " | flatiter\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.arange(1, 7).reshape(2, 3)\n", " | >>> x\n", " | array([[1, 2, 3],\n", " | [4, 5, 6]])\n", " | >>> x.flat[3]\n", " | 4\n", " | >>> x.T\n", " | array([[1, 4],\n", " | [2, 5],\n", " | [3, 6]])\n", " | >>> x.T.flat[3]\n", " | 5\n", " | >>> type(x.flat)\n", " | \n", " | \n", " | An assignment example:\n", " | \n", " | >>> x.flat = 3; x\n", " | array([[3, 3, 3],\n", " | [3, 3, 3]])\n", " | >>> x.flat[[1,4]] = 1; x\n", " | array([[3, 1, 3],\n", " | [3, 1, 3]])\n", " | \n", " | imag\n", " | The imaginary part of the array.\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.sqrt([1+0j, 0+1j])\n", " | >>> x.imag\n", " | array([ 0. , 0.70710678])\n", " | >>> x.imag.dtype\n", " | dtype('float64')\n", " | \n", " | itemsize\n", " | Length of one array element in bytes.\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.array([1,2,3], dtype=np.float64)\n", " | >>> x.itemsize\n", " | 8\n", " | >>> x = np.array([1,2,3], dtype=np.complex128)\n", " | >>> x.itemsize\n", " | 16\n", " | \n", " | nbytes\n", " | Total bytes consumed by the elements of the array.\n", " | \n", " | Notes\n", " | -----\n", " | Does not include memory consumed by non-element attributes of the\n", " | array object.\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.zeros((3,5,2), dtype=np.complex128)\n", " | >>> x.nbytes\n", " | 480\n", " | >>> np.prod(x.shape) * x.itemsize\n", " | 480\n", " | \n", " | ndim\n", " | Number of array dimensions.\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.array([1, 2, 3])\n", " | >>> x.ndim\n", " | 1\n", " | >>> y = np.zeros((2, 3, 4))\n", " | >>> y.ndim\n", " | 3\n", " | \n", " | real\n", " | The real part of the array.\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.sqrt([1+0j, 0+1j])\n", " | >>> x.real\n", " | array([ 1. , 0.70710678])\n", " | >>> x.real.dtype\n", " | dtype('float64')\n", " | \n", " | See Also\n", " | --------\n", " | numpy.real : equivalent function\n", " | \n", " | shape\n", " | Tuple of array dimensions.\n", " | \n", " | The shape property is usually used to get the current shape of an array,\n", " | but may also be used to reshape the array in-place by assigning a tuple of\n", " | array dimensions to it. As with `numpy.reshape`, one of the new shape\n", " | dimensions can be -1, in which case its value is inferred from the size of\n", " | the array and the remaining dimensions. Reshaping an array in-place will\n", " | fail if a copy is required.\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.array([1, 2, 3, 4])\n", " | >>> x.shape\n", " | (4,)\n", " | >>> y = np.zeros((2, 3, 4))\n", " | >>> y.shape\n", " | (2, 3, 4)\n", " | >>> y.shape = (3, 8)\n", " | >>> y\n", " | array([[ 0., 0., 0., 0., 0., 0., 0., 0.],\n", " | [ 0., 0., 0., 0., 0., 0., 0., 0.],\n", " | [ 0., 0., 0., 0., 0., 0., 0., 0.]])\n", " | >>> y.shape = (3, 6)\n", " | Traceback (most recent call last):\n", " | File \"\", line 1, in \n", " | ValueError: total size of new array must be unchanged\n", " | >>> np.zeros((4,2))[::2].shape = (-1,)\n", " | Traceback (most recent call last):\n", " | File \"\", line 1, in \n", " | AttributeError: Incompatible shape for in-place modification. Use\n", " | `.reshape()` to make a copy with the desired shape.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.reshape : similar function\n", " | ndarray.reshape : similar method\n", " | \n", " | size\n", " | Number of elements in the array.\n", " | \n", " | Equal to ``np.prod(a.shape)``, i.e., the product of the array's\n", " | dimensions.\n", " | \n", " | Notes\n", " | -----\n", " | `a.size` returns a standard arbitrary precision Python integer. This\n", " | may not be the case with other methods of obtaining the same value\n", " | (like the suggested ``np.prod(a.shape)``, which returns an instance\n", " | of ``np.int_``), and may be relevant if the value is used further in\n", " | calculations that may overflow a fixed size integer type.\n", " | \n", " | Examples\n", " | --------\n", " | >>> x = np.zeros((3, 5, 2), dtype=np.complex128)\n", " | >>> x.size\n", " | 30\n", " | >>> np.prod(x.shape)\n", " | 30\n", " | \n", " | strides\n", " | Tuple of bytes to step in each dimension when traversing an array.\n", " | \n", " | The byte offset of element ``(i[0], i[1], ..., i[n])`` in an array `a`\n", " | is::\n", " | \n", " | offset = sum(np.array(i) * a.strides)\n", " | \n", " | A more detailed explanation of strides can be found in the\n", " | \"ndarray.rst\" file in the NumPy reference guide.\n", " | \n", " | Notes\n", " | -----\n", " | Imagine an array of 32-bit integers (each 4 bytes)::\n", " | \n", " | x = np.array([[0, 1, 2, 3, 4],\n", " | [5, 6, 7, 8, 9]], dtype=np.int32)\n", " | \n", " | This array is stored in memory as 40 bytes, one after the other\n", " | (known as a contiguous block of memory). The strides of an array tell\n", " | us how many bytes we have to skip in memory to move to the next position\n", " | along a certain axis. For example, we have to skip 4 bytes (1 value) to\n", " | move to the next column, but 20 bytes (5 values) to get to the same\n", " | position in the next row. As such, the strides for the array `x` will be\n", " | ``(20, 4)``.\n", " | \n", " | See Also\n", " | --------\n", " | numpy.lib.stride_tricks.as_strided\n", " | \n", " | Examples\n", " | --------\n", " | >>> y = np.reshape(np.arange(2*3*4), (2,3,4))\n", " | >>> y\n", " | array([[[ 0, 1, 2, 3],\n", " | [ 4, 5, 6, 7],\n", " | [ 8, 9, 10, 11]],\n", " | [[12, 13, 14, 15],\n", " | [16, 17, 18, 19],\n", " | [20, 21, 22, 23]]])\n", " | >>> y.strides\n", " | (48, 16, 4)\n", " | >>> y[1,1,1]\n", " | 17\n", " | >>> offset=sum(y.strides * np.array((1,1,1)))\n", " | >>> offset/y.itemsize\n", " | 17\n", " | \n", " | >>> x = np.reshape(np.arange(5*6*7*8), (5,6,7,8)).transpose(2,3,1,0)\n", " | >>> x.strides\n", " | (32, 4, 224, 1344)\n", " | >>> i = np.array([3,5,2,2])\n", " | >>> offset = sum(i * x.strides)\n", " | >>> x[3,5,2,2]\n", " | 813\n", " | >>> offset / x.itemsize\n", " | 813\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data and other attributes defined here:\n", " | \n", " | __hash__ = None\n", "\n" ] } ], "source": [ "help(a)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Dizilerin eleman sayısına uygun şekilde şeklini (satır x sütun 'dan oluşan bir matris şeklinde düşünebilirsiniz) değiştirebilmek için np.reshape fonksiyonundan aşağıdaki örnekte olduğu gibi yararlanabilirsiniz. " ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Degisiklik oncesi a dizisi: \n", " [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14]\n", "Degisiklik oncesi a dizisinin boyutu: 1\n", "a dizisinin eleman sayisi: 15\n", "Degisiklik sonrasi a dizisi: \n", " [[ 0 1 2 3 4]\n", " [ 5 6 7 8 9]\n", " [10 11 12 13 14]]\n", "Degisiklik sonrasi a dizisinin boyutu: 2\n", "a dizisinin eleman sayisi: 15\n" ] } ], "source": [ "a = np.arange(15)\n", "print(\"Degisiklik oncesi a dizisi: \\n\", a)\n", "print(\"Degisiklik oncesi a dizisinin boyutu: \", a.ndim)\n", "print(\"a dizisinin eleman sayisi: \", a.size)\n", "a = a.reshape(3,5)\n", "print(\"Degisiklik sonrasi a dizisi: \\n\", a)\n", "print(\"Degisiklik sonrasi a dizisinin boyutu: \", a.ndim)\n", "print(\"a dizisinin eleman sayisi: \", a.size)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "nxn bir birim matris formunda bir numpy dizisi oluşturmak için np.eye fonksiyonunu kullanabilirsiniz. Uyarı: numpy 'da matrix nesnesi dizi (array) nesnesinden farklıdıır." ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4x4 birim matris formunda dizi: \n", " [[1. 0. 0. 0.]\n", " [0. 1. 0. 0.]\n", " [0. 0. 1. 0.]\n", " [0. 0. 0. 1.]]\n" ] } ], "source": [ "i4 = np.eye(4)\n", "print(\"4x4 birim matris formunda dizi: \\n\", i4)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Dizi Kopyalama ###\n", "\n", "numpy dizileri ile çalışırken atama operatörü (\"=\") bir kopyalama işlemi yapmak yerine aynı diziye yeni bir isim verilmesini sağlar. Bu nedenle dizilerden herhangi birinde bir değişiklik yapıldığında diğeri de değişir." ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a: [0. 0.25 0.5 0.75 1. 1.25 1.5 1.75 2. 2.25 2.5 2.75 3. 3.25\n", " 3.5 3.75 4. ]\n", "b: [0. 0.25 0.5 0.75 1. 1.25 1.5 1.75 2. 2.25 2.5 2.75 3. 3.25\n", " 3.5 3.75 4. ]\n", "Degisiklik sonrasi a: [ 0. 0.25 100. 0.75 1. 1.25 1.5 1.75 2. 2.25\n", " 2.5 2.75 3. 3.25 3.5 3.75 4. ]\n", "Degisiklik sonrasi b: [ 0. 0.25 100. 0.75 1. 1.25 1.5 1.75 2. 2.25\n", " 2.5 2.75 3. 3.25 3.5 3.75 4. ]\n" ] } ], "source": [ "a = np.arange(0,4.25,0.25)\n", "print(\"a: \", a)\n", "b = a\n", "print(\"b: \", b)\n", "a[2] = 100.0\n", "print(\"Degisiklik sonrasi a: \", a)\n", "print(\"Degisiklik sonrasi b: \", b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sonuç olarak :\n", "* `b = a`\n", " \n", " ifadesiyle herhangi bir kopyalama işlemi yapılmaz. `a` ve `b` hafızanın aynı adresinde bulunan bir dizi için iki farklı isimldir.\n", " \n", "\n", "* `b = a[:]`\n", "\n", " ifadesi a'nın bir görüntüsünü (view) b'ye alır (_shallow copy_). a ve b aynı hafıza adresindeki dizinin iki farklı adıyken, şekilleri bağımsız olarak tutulur.\n", " \n", " \n", "* `b = a.copy()`\n", "\n", " ifadesiyle a'nın içeriği b'ye kopyalanır ( _deep_ copy). Hafızanın başka bir adresinde a'yla aynı içeriğe sahip ancak ondan farklı isimde bir b dizisi yaratılır. Dolayısyla a'da yapılacak bir değişiklik b'yi; b'de yapılacak bir değişiklik ise a'yı etkilemez." ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1. dizi: \n", " [[ 0 1 2 3 4 5]\n", " [ 6 7 8 9 10 11]\n", " [12 13 14 15 16 17]]\n", "2. dizi: \n", " [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17]\n", "2. dizideki degisiklik sonrasi 1. dizi: \n", " [[ 0 -1 2 3 4 5]\n", " [ 6 7 8 9 10 11]\n", " [12 13 14 15 16 17]]\n", "2. dizideki degisiklik sonrasi 2. dizi: \n", " [ 0 -1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17]\n" ] } ], "source": [ "dizi1 = np.arange(18)\n", "dizi2 = dizi1[:]\n", "dizi1.shape = (3,6)\n", "\n", "print(\"1. dizi: \\n\", dizi1)\n", "print(\"2. dizi: \\n\", dizi2)\n", "\n", "dizi2[1] = -1\n", "print(\"2. dizideki degisiklik sonrasi 1. dizi: \\n\", dizi1)\n", "print(\"2. dizideki degisiklik sonrasi 2. dizi: \\n\", dizi2)" ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a: [0. 0.5 1. 1.5 2. ]\n", "b: [0. 0.5 1. 1.5 2. ]\n", "a: [0. 0.5 1. 1.5 2. ]\n", "b: [ 0. -100. -1000. 1.5 2. ]\n" ] } ], "source": [ "a = np.arange(0,2.1,0.5)\n", "b = a.copy()\n", "print(\"a: \", a)\n", "print(\"b: \", b)\n", "b[1:3] = np.array([-100,-1000])\n", "print(\"a: \", a)\n", "print(\"b: \", b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "İki diziyi karşılaştırmak ve aynı olup olmadıklarını ve ne düzeyde benzer olduklarını anlamak için çeşitli fonksiyonlar ya da yapılar kullanılabilir." ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a: [1. 1.6 2.2 2.8 3.4 4. ]\n", "c: [1. 1.6 2.2 2.8 3.4 4. ]\n", "c = a?: False\n" ] } ], "source": [ "a = np.arange(1,4.1,0.6)\n", "c = a[:]\n", "print(\"a: \", a)\n", "print(\"c: \", c)\n", "print(\"c = a?:\", c is a)" ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "outputs": [], "source": [ "a.flags?" ] }, { "cell_type": "code", "execution_count": 62, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "c: [[1. 1.6 2.2]\n", " [2.8 3.4 4. ]]\n", "True\n", "False\n", "True\n" ] } ], "source": [ "c = c.reshape(2,3)\n", "print(\"c: \", c)\n", "print(c.base is a)\n", "print(c.flags.owndata)\n", "print(a.flags.owndata)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Diziler Üzerinde İşlemler ###\n", "\n", "Python'da, toplama, bir sabitle çarpma gibi bazı işlemler numpy dizileri üzerinde doğrudan uygulanabilir." ] }, { "cell_type": "code", "execution_count": 64, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a: \n", " [[ 0 1 2 3]\n", " [ 4 5 6 7]\n", " [ 8 9 10 11]\n", " [12 13 14 15]\n", " [16 17 18 19]]\n", "3a: \n", " [[ 0 3 6 9]\n", " [12 15 18 21]\n", " [24 27 30 33]\n", " [36 39 42 45]\n", " [48 51 54 57]]\n", "a + a: \n", " [[ 0 2 4 6]\n", " [ 8 10 12 14]\n", " [16 18 20 22]\n", " [24 26 28 30]\n", " [32 34 36 38]]\n" ] } ], "source": [ "a = np.arange(20).reshape(5,4)\n", "print(\"a: \\n\", a)\n", "print(\"3a: \\n\", a*3)\n", "print(\"a + a: \\n\", a + a)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ancak çarpma ve bölmenin sadece karşılıklı elemanların çarpılması ya da bölünmesinden ibaret olduğu (matris çarpması olmadığı) bilinmelidir. Dolayısı ile çarpma ve bölme sadece aynı şekildeki diziler arasında uygulanabilen işlemlerdir." ] }, { "cell_type": "code", "execution_count": 65, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a^2: \n", " [[ 0 1 4 9]\n", " [ 16 25 36 49]\n", " [ 64 81 100 121]\n", " [144 169 196 225]\n", " [256 289 324 361]]\n" ] } ], "source": [ "print(\"a^2: \\n\", a**2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ancak matris çarpması da numpy üzerinde yapılabilir ve bunun için @ operatörü kullanılır." ] }, { "cell_type": "code", "execution_count": 66, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[1 2 3]\n", "[5 6 7]\n", "[ 5 12 21]\n" ] } ], "source": [ "x = np.arange(1,4,1)\n", "y = np.arange(5,8,1)\n", "print(x)\n", "print(y)\n", "print(x*y)" ] }, { "cell_type": "code", "execution_count": 67, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a: \n", " [[ 0 1 2 3]\n", " [ 4 5 6 7]\n", " [ 8 9 10 11]\n", " [12 13 14 15]\n", " [16 17 18 19]]\n", "b: \n", " [[10. 11. 12. 13. 14.]\n", " [15. 16. 17. 18. 19.]\n", " [20. 21. 22. 23. 24.]\n", " [25. 26. 27. 28. 29.]]\n", "a . b: \n", " [[ 130. 136. 142. 148. 154.]\n", " [ 410. 432. 454. 476. 498.]\n", " [ 690. 728. 766. 804. 842.]\n", " [ 970. 1024. 1078. 1132. 1186.]\n", " [1250. 1320. 1390. 1460. 1530.]]\n" ] } ], "source": [ "b = np.linspace(10,29,20)\n", "print(\"a: \\n\", a)\n", "b = b.reshape(4,5)\n", "print(\"b: \\n\", b)\n", "print(\"a . b: \\n\", a @ b)" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "Görüldüğü üzere a: 5x4 bir dizi, b: 4x5 dizi olduğundan a.b: 5x5 bir dizidir." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Pek çok fonksiyon diziler üzerinde de kullanılabildiği gibi bazı fonksiyonların diziler için özel olarak tanımlanmış halleri de numpy paketinde bulunabilir. " ] }, { "cell_type": "code", "execution_count": 68, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a dizisi elemanlarinin toplami: [40 45 50 55]\n", "cos(theta): \n", " [ 1.00000000e+00 9.80785280e-01 9.23879533e-01 8.31469612e-01\n", " 7.07106781e-01 5.55570233e-01 3.82683432e-01 1.95090322e-01\n", " 6.12323400e-17 -1.95090322e-01 -3.82683432e-01 -5.55570233e-01\n", " -7.07106781e-01 -8.31469612e-01 -9.23879533e-01 -9.80785280e-01\n", " -1.00000000e+00 -9.80785280e-01 -9.23879533e-01 -8.31469612e-01\n", " -7.07106781e-01 -5.55570233e-01 -3.82683432e-01 -1.95090322e-01\n", " -1.83697020e-16 1.95090322e-01 3.82683432e-01 5.55570233e-01\n", " 7.07106781e-01 8.31469612e-01 9.23879533e-01 9.80785280e-01\n", " 1.00000000e+00]\n" ] }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAksAAAGwCAYAAAC5ACFFAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAABbTklEQVR4nO3de3zO9f/H8cdlR6fNYcz8LIevnA8xYpNSaQ5R1Dd0GArlGzkl0hGp5VuKDoSITqikVE5TTjkV0UGSymGykeKa48Zcvz/e322tMTPb3tfheb/drtv18dnn+ux5Lblee3/en9fb4XK5XIiIiIjIORWzHUBERETEnalYEhEREcmFiiURERGRXKhYEhEREcmFiiURERGRXKhYEhEREcmFiiURERGRXPjbDuANzp49y/79+yldujQOh8N2HBEREckDl8vF0aNHqVy5MsWKnX/8SMVSAdi/fz+RkZG2Y4iIiEg+JCYmUqVKlfN+XcVSAShdujRgftghISGW04iIiEhepKSkEBkZmfk5fj4qlgpAxqW3kJAQFUsiIiIe5kJTaDTBW0RERCQXKpZEREREcqFiSURERCQXKpZEREREcqFiSURERCQXKpZEREREcqFiSURERCQXKpZEREREcqFiSURERCQXKpZEREREcuFRxdLq1avp3LkzlStXxuFw8NFHH13wNatWrSIqKorg4GBq1KjBa6+9luOY+fPnU69ePYKCgqhXrx4LFiwohPQiIiLiiTyqWDp+/DiNGzfmlVdeydPxu3btomPHjrRu3ZotW7bwyCOPMGjQIObPn595zPr16+nevTtxcXF8++23xMXF0a1bNzZu3FhYb0NEREQ8iMPlcrlsh8gPh8PBggUL6NKly3mPGTlyJAsXLmT79u2Z+/r378+3337L+vXrAejevTspKSksXrw485j27dtTtmxZ5syZk6csKSkphIaG4nQ6C3Yh3X37IDUVatSACyzyJyIi4pXS02HbNqhaFUJDC/TUef389qiRpYu1fv16YmNjs+1r164dmzZt4vTp07kes27duvOeNzU1lZSUlGyPQvHqq1CzJkREwK23woQJsGEDpKUVzvcTERGx7ehRWL4cxo6Fdu2gXDlo3BgSEqxF8rf2nYtAcnIy4eHh2faFh4dz5swZDh06RERExHmPSU5OPu954+PjGTNmTKFkziYlBQID4cAB+PBD8wAICoLmzaFVK4iJMY+wsMLPIyIiUpBcLkhMhLVrzWPdOvj2Wzh7NvtxpUvDH3/YyYiXF0tgLtf9XcZVx7/vP9cx/9z3d6NGjWLYsGGZf05JSSEyMrIg4mb36qtmNGnz5qy/RGvXwqFD8OWX5pGhdm1TNLVqZR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ymUteGu+d9vzbt27eKyyy7zyTvfRHKoVw/atoXly2HyZBg/3nYiEbmQjHYB/fqpUJILytcE76pVq/Lll19y1113ERMTw++//w7AW2+9xZda/kF8Ucbk0OnTzRwIEXFf27bB55+b0eD777edRjxAvoql+fPn065dO4oXL84333xDamoqAEePHuWZZ54p0IAiHqFjR7NK+eHD8PbbttOISG4yRpW6doXLLrObRTxCvoqlcePG8dprrzF9+nQCAgIy98fExPDNN98UWDgRj6E2AiKe4a+/4K23zLbaBUge5atY2rFjB1dffXWO/SEhIRw5cuRSM4l4prvvNkslbNsGK1bYTiMi5zJjBpw8CY0bQ+vWttOIh8hXsRQREcEvv/ySY/+XX36phXTFd5UpA716me2MYX4RcR9nzqhdgORLvoql++67j8GDB7Nx40YcDgf79+/nnXfeYfjw4dyvyXLiyzIuxS1cCLt22c0iItl98gns3Qvly8Ptt9tOIx7koloHZBgxYgROp5Nrr72WU6dOcfXVVxMUFMTw4cMZmPFhIeKL6taF2FhYtgxefRWef952IhHJkDHie++9WvhaLspFNaX8pxMnTvDjjz9y9uxZ6tWrR6lSpQoym8dQU0rJ5rPPoFMnCA2FffvAR/+/EHEr331n5in5+ZlR38hI24nEDeT18ztfl+EylChRgmbNmnHllVf6bKEkkkOHDlCzJjidaiMg4i5eftk833qrCiW5aPkqlo4fP87jjz9OTEwMNWvWpEaNGtkehWny5MlUr16d4OBgoqKiWLNmTa7Hr1q1iqioKIKDg6lRowavvfZajmPmz59PvXr1CAoKol69eixYsKCw4osvKFYMHnjAbKuNgIh9f/6Z9YuL2gVIPuRrzlLfvn1ZtWoVcXFxREREFNmyJ/PmzWPIkCFMnjyZVq1aMXXqVDp06MCPP/7IZedoLLZr1y46duxIv379ePvtt1m7di33338/FSpU4NZbbwVg/fr1dO/enaeeeoquXbuyYMECunXrxpdffkmLFi2K5H2JF+rdGx59FLZvN52C27a1nUjEd73+Opw6BU2bQkyM7TTigfI1Z6lMmTJ89tlntGrVqjAynVeLFi1o2rQpU6ZMydxXt25d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JBcqlkRERERyoWJJREREJBcqlkRERERyoWJJREREJBcqlkRERERyoWJJREREJBcqlkRERERyoWJJREREJBcqlkRERERy8f/8GC/H79GzaAAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "print(\"a dizisi elemanlarinin toplami: \", sum(a))\n", "theta = np.arange(0, 2*np.pi+np.pi/32, np.pi/16)\n", "print(\"cos(theta): \\n\", np.cos(theta))\n", "from matplotlib import pyplot as plt\n", "%matplotlib inline\n", "plt.plot(theta, np.cos(theta), \"r-\")\n", "plt.xlabel(\"theta\")\n", "plt.ylabel(\"cos(theta)\")\n", "plt.hlines(y = 0, xmin=min(theta), xmax=max(theta), lw=1)\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Alıştırmalar #\n", "\n", "1. `np.random.random_sample()` fonksiyonu `[0.0, 1.0)` aralığıda rastgele değerlerden oluşan diziler yaratmak için kullanılır. Bu fonksiyonu ve sabitle çarpmayı kullanarak 10x10 bir numpy dizisi oluşturunuz. Dizinin ortalamasını ve standart sapmasını uygun `numpy` fonksiyonlarını kullanarak yazdırınız.\n", "\n", "2. Aşağdaki diziyi manuel olarak (elinizle) yazmadan pratik bir yöntemle oluşturunuz. Bu dizinin sadece 1, 3 ve 5. satırları ile 2. sütunundan oluşan bir dizi (vektör) oluşturup, ekrana yazdırınız.\n", "```\n", "[[1, 6, 11],\n", " [2, 7, 12],\n", " [3, 8, 13],\n", " [4, 9, 14],\n", " [5, 10, 15]]\n", "```\n", "\n", "3. Kenarlarındaki tüm rakamları 1, ortasındaki tüm rakamları 0 olan nxn bir dizi oluşturmak üzere bir fonksiyon yazınız. Fonksiyonunuz kare dizinin bir kenarını (n) argüman olarak alsın ve bu kurala uygun olarak oluşturduğu nxn diziyi programa döndürsün. Aşağıda 4x4 bir dizi örnek olarak verilmiştir.\n", "```\n", "1 1 1 1 \n", "1 0 0 1 \n", "1 0 0 1 \n", "1 1 1 1 \n", "```\n", "\n", "4. 0 ile 90 derece (0 dahil 90 hariç) arasında beşer derecelik eşit uzaklıklarla birbirinden ayrılan zenit açılarından oluşan, `zenit` isminde bir numpy dizisi oluşturunuz. `z` zenit açısını, `X` hava kütlesini göstermek üzere bu dizinin 60 dereceden küçük tüm elemanlarına $ X = sec(z) $; 60 derece ve ondan büyük bütün elemanlarına; $ X = sec(z) - 0.0018167 (sec(z) - 1) - 0.002875 (sec(z) - 1)^2 - 0.0008083 (sec(z) - 1)^3 $ (Hardie, 1962) formülünü uygulayarak hava kütlesini hesaplayınız ve `X` isimli bir dizide toplayarak, bu diziyi ekrana yazdırınız.\n", "\n", "5. [yildizlar.dat](yildizlar.dat) salt metin dosyasını `np.loadtxt()` fonksiyonu ile okuyarak sütunlarını uygun olarak isimlendirdiğiniz dizilerde toplayınız. Yörünge döneminin histogramını bulunduğu diziyi `np.histogram()` fonksiyonunu kullanarak oluşturunuz. Fonksiyon çıktı olarak her bir gruptaki (bin) gezegen sayısını ve grubun limitlerini döndürür. Her bir grubun ortalamasını hesaplayarak ekrana yazdırınız.\n", "\n", "6. Standart sapma aşağıdaki ifade ile hesaplanır.\n", "\n", "$$\n", "\\sigma = \\left [ \\frac{1}{N} \\sum_{i=1}^N (a_i - \\bar{a})^2 \\right ]^{1/2}\n", "$$\n", "\n", "Verilen bir a dizisi için \n", "\n", " * `a` dizisinin ortalmasını ($\\bar{a}$),\n", " * Her bir elemanının ortalamadan farkını $a - \\bar{a}$,\n", " * Bu farkların kareleri toplamını ($\\Sigma (a - \\bar{a})^2$),\n", " * Bu toplamın `a` dizisinin eleman sayısını bölümünü,\n", " * ve son olarak bu bölümün karekökünü \n", "\n", "hesaplayan `standart_sapma` isimli bir fonksiyon yazınız. Fonksiyonunuz sadece `a` dizisini alsın ve dizinin standart sapmasını döndürsün.\n", " \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Ödev 0\n", "## 7 Mart 2023, Salı 13:30 ##\n", "\n", "Soru 1. Betelgeuse'un ışınım gücü, Güneş'inkinin 140 000 katı, sıcaklığı ise yaklaşık olarak 3500 K'dir. Güneş'in yüzey sıcaklığını 5780 K, yarıçapını 700 000 km almak üzere gerekli değişken tanımlarını yapıp, iyi bilinen ışınım gücü formülünü de kullanarak Betelgeuse'un yarıçapını Astronomi Birimi cinsinden hesaplayan ve ekrana güzel bir formatla yazdıran bir Python kod parçası yazınız. (1 AB = 149.6 milyon km)\n", "\n", "Soru 2. Bir karadeliğin olay ufkunun merkezine uzaklığını tanımlayan Schwarzschild Yarıçapı'nın ifadesi aşağıdaki gibidir.\n", "\n", "$$R_{Sch} = \\frac{2 G M}{c^2}$$\n", "\n", "Geçen sene Dünya üzerindeki büyük radyo teleskop ve dizgelerinin katılımıyla (Olay Ufku Teleskobu, ing. Event Horizon Telescope, EHT) \"fotoğrafı çekilen\" ilk karadelik olan M87 gökadasının merkezindeki süper kütleli karadeliğin kütlesi $M = 6.4 x 10^9 M_{Güneş}$ 'tir. Bu süper kütleli karadeliğin Schwarzschild yarıçapını Astronomi Birimi'nden hesaplayan bir Python kodu yazınız. ($G = 6.67 x 10^{-11} m^3 kg^{-1} s^{-2}, c = 299792458 m s^{-1}$)\n", "\n", "Soru 3. Herhangi bir dalgaboyu bölgesinde görünen parlaklığı verilen iki yıldızdan alınan akılar oranını hesaplayan ve programda çağrıldığı noktaya döndüren pogson isimli bir fonksiyon yazınız. Fonksiyonunuzu görünen parlaklıkları $m_1 = -1^m$, $m_2 = 4^m$ iki yıldızın akıları oranını ($F_1 / F_2$) hesaplayarak test ediniz.\n", "\n", "Soru 4. Bir yıldızın görünen parlaklığını kadir biriminde ve Gaia paralaksını miliyaysaniyesi biriminde alarak, yıldızın uzaklığını parsek biriminde ve mutlak parlaklığını kadir biriminde döndüren bir fonksiyon yazınız.\n", "\n", "Soru 5. Yazdığınız fonksiyonu test etmek üzere görünen parlaklğı ve Gaia paralaksı istenen birimlerde (sırasıyla kadir ve miliyaysaniyesi) kullanıcı tarafından klavyeden girilen bir cismin uzaklığını ve mutlak parlaklığını 4. soruda yazdığınız fonksiyonu kullanarak ekrana getiren bir Python programı yazınız. Örnek cisimler olarak HD 114762, 51 Pegasi, Kepler-47, HAT-P-19 ve WASP-69'u kullanarak bu cisimler için uzaklık ve mutlak parlaklık hesabı yapınız. Örnek cisimlerin Gaia fotometrik parlaklık (phot_g_mean_mag) ve paralaks değerlerini [Gaia veritabanından](https://gea.esac.esa.int/archive/) alabilirsiniz.\n", "\n", "Soru 6. Aşağıda Güneş Sistemi gezegenlerinin isimlerinin anahtar,yörünge dönemlerinin Dünya günü, Güneş'e olan uzaklıklarının milyon kilometre cinsinden tanımlandığı birer demette değer olarak tutulduğu bir sözlük degişkeni verilmiştir.\n", "\n", "gezegenler = {'Merkur':(88.0, 57.9),'Venus':(224.7, 108.2),'Dunya':(365.25, 149.6),'Mars':(687.0, 227.9),\n", " 'Jupiter':(4331.0, 778.6),'Saturn':(10747.0, 1433.5),\n", " 'Uranus':(30589.0, 2872.5),'Neptun':(59800.0, 4495.1)}\n", " \n", "Bu sözlük değişkenindenki verileri ve matplotlib.pyplot fonksiyonlarını kullanarak Dünya yılı cinsinden yörünge döneminin karesine karşılık Astronomi Birimi cinsinden yörünge yarı-büyük eksen uzunluğunun küpünü, veri noktalarını kırmızı içi dolu daireler ile göstermek ve eksenlere uygun isimler vermek suretiyle çizdiriniz.\n", "\n", "Soru 7. Bir önceki soruda çizdirdiğiniz grafikteki ilişkiye, yörünge dönemi ve yörünge yarı-büyük eksen uzunluklarını birer numpy dizisine (array) aldıktan sonra numpy.polyfit fonksiyonlarını kullanarak bir doğru uyumlayınız. Uyumladığınız doğrunun denklemini ekrana yazdırınız. Uyumladığınız bu doğru denkleminde 0 ile 165 yıl arasında 0.1 yıl eşit uzaklığa sahip noktalardan oluşturacağınız bir numpy dizisinin karesini (P2) koyarak yörünge yarı-büyük eksen uzunluklarını küpünü elde ediniz (a3) ve birer numpy dizisinde saklayınız. Bu iki numpy dizisini (P2, a3) 6. sorudaki grafiğinizin üzerine mavi kesiksiz eğri ile çizdiriniz ve grafiğinizi ekrana getiriniz.\n", "\n", "Soru 8.\n", "\n", "a) Sırasıyla $parlaklik$ ve $uzaklik$ numpy dizilerinde bir grup yıldız için kadir cinsinden verilen görünen görsel parlaklık ve parsek cinsinden uzaklıklarını kullanarak çağrıldığı programa cisimlerin mutlak görsel parlaklığını döndüren uzaklik_modulu isimli bir fonksiyon yazınız.\n", "\n", "b) [yildizlar.dat](yildizlar.dat) salt metin dosyasının birinci sütununda bazı yıldızların adları, ikinci sütununda kadir cinsinden görunen görsel parlaklıkları, üçüncü sütunda parsek cinsinden uzaklıkları, dördüncü sütunda ise Kelvin cinsinden yüzey sıcaklıkları bulunmaktadır. Bu dosyayı açıp satır satır okuyarak her bir satırda yer alan yıldız isimlerini $yildizlar$, görünen görsel parlakliklarını $mV$, uzakliklarını $d$, yüzey sıcaklıklarını $T$ isimli listelere toplayiniz. Not: Sayısal değerleri kayan noktalı sayıya dönüştürmeyi unutmayınız! Dosyayı kapattıktan sonra ilgili numpy fonksiyonunu kullanarak $mV$, $d$ ve $T$ listelerini aynı isimli $numpy$ nümerik dizilerine (array) çeviriniz. \n", "\n", "c) $mV$ ve $d$ numpy dizilerini (a) şıkkında yazdığınız uzaklik_modulu isimli fonksiyona göndererek bu fonksiyonun döndüreceği mutlak görsel parlaklıkları $MV$ isimli bir numpy dizisine alınız.\n", "\n", "d) Kelvin cinsinden $T$ dizisinde verilen sıcaklıkların 10 tabanında logaritmasını (numpy.log10 fonksiyonu ile) aldıktan sonra x ekseninde, $MV$ dizisindeki mutlak görsel parlaklıkları ise y ekseninde olacak şekilde çizdirerek bir HR diyagramı oluşturunuz. HR diyagramlarında geleneksel olarak sıcaklığın ($log T_{eff}$) büyükten küçüğe (ters sırada) verildiğine özen gösteriniz. Veri noktalarınızı kırmızı içi dolu dairlerle gösteriniz. Eksenlere ve grağinize uygun birer isim veriniz ve grafiğiniz üzerinde gösteriniz." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Başa Dön](#Jupyter-ve-Python'a-Giriş)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 1 }