From 6887e773e17beb5a6c2df0c7397d5223eebde37e Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 9 Sep 2017 21:23:36 +0200 Subject: misc wip. --- demo/notebooks/BOM Demo.ipynb | 1400 ----------------------------------------- demo/notebooks/bad-bom.ipynb | 437 +++++++++++++ 2 files changed, 437 insertions(+), 1400 deletions(-) delete mode 100644 demo/notebooks/BOM Demo.ipynb create mode 100644 demo/notebooks/bad-bom.ipynb (limited to 'demo/notebooks') diff --git a/demo/notebooks/BOM Demo.ipynb b/demo/notebooks/BOM Demo.ipynb deleted file mode 100644 index f9d6faa..0000000 --- a/demo/notebooks/BOM Demo.ipynb +++ /dev/null @@ -1,1400 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Notebook configuration" - ] - }, - { - "cell_type": "code", - "execution_count": 115, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The autoreload extension is already loaded. To reload it, use:\n", - " %reload_ext autoreload\n" - ] - } - ], - "source": [ - "%load_ext autoreload\n", - "%autoreload 2\n", - "\n", - "%aimport ee.kicad.bom\n", - "%aimport ee.kicad.bom.io\n", - "\n", - "from ee.kicad.bom import *\n", - "from ee.kicad.bom.io import read_bom" - ] - }, - { - "cell_type": "code", - "execution_count": 170, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "bom_file = \"../kicad/bom/A64-OlinuXino_Rev_C.xml\"\n", - "bom_file = \"../kicad/bom/gw.xml\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Load the BOM, sort by reference" - ] - }, - { - "cell_type": "code", - "execution_count": 199, - "metadata": { - "scrolled": true - }, - "outputs": [], - "source": [ - "import os\n", - "import os.path\n", - "import pandas\n", - "\n", - "bom = read_bom(bom_file).to_pandas()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Sort a BOM" - ] - }, - { - "cell_type": "code", - "execution_count": 200, - "metadata": { - "scrolled": true - }, - "outputs": [], - "source": [ - "f=lambda x: pandas.Series(data=x, index=['ref_name', 'ref_num', 'ref_rest'])\n", - "sort_fields=bom[\"ref\"].map(ee.kicad.bom.split_ref).apply(f)\n", - "\n", - "bom=pandas.concat([bom, sort_fields], axis=1, join_axes=[bom.index])\n", - "bom=bom.sort_values(by=list(sort_fields.columns))\n" - ] - }, - { - "cell_type": "code", - "execution_count": 201, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
CapacitanceColorDescriptionFrequencyImpedanceInductanceManufacturerPart NumberResistancerefvalueref_nameref_numref_rest
C11.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC1C0402_1u_10Vdc_X5RC1
C21.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC2C0402_1u_10Vdc_X5RC2
C31.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC3C0402_1u_10Vdc_X5RC3
C41.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC4C0402_1u_10Vdc_X5RC4
C51.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC5C0402_1u_10Vdc_X5RC5
C61.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC6C0402_1u_10Vdc_X5RC6
C71.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC7C0402_1u_10Vdc_X5RC7
C81.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC8C0402_1u_10Vdc_X5RC8
C91.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC9C0402_1u_10Vdc_X5RC9
C104.7uFNone4.7uF, 6.3Vdc, ±20%, X5RNoneNoneNoneMurataGRM185R60J475ME15NoneC10C0603_4u7_6.3Vdc_X5RC10
C114.7uFNone4.7uF, 6.3Vdc, ±20%, X5RNoneNoneNoneMurataGRM185R60J475ME15NoneC11C0603_4u7_6.3Vdc_X5RC11
C124.7uFNone4.7uF, 6.3Vdc, ±20%, X5RNoneNoneNoneMurataGRM185R60J475ME15NoneC12C0603_4u7_6.3Vdc_X5RC12
C131.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC13C0402_1u_10Vdc_X5RC13
C141.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC14C0402_1u_10Vdc_X5RC14
C1510000pFNone10000pF, 10Vdc, ±10%, X5RNoneNoneNoneMurataGRM155R61A103KA01NoneC15C0402_10n_10Vdc_X5RC15
C1610000pFNone10000pF, 10Vdc, ±10%, X5RNoneNoneNoneMurataGRM155R61A103KA01NoneC16C0402_10n_10Vdc_X5RC16
C1710000pFNone10000pF, 10Vdc, ±10%, X5RNoneNoneNoneMurataGRM155R61A103KA01NoneC17C0402_10n_10Vdc_X5RC17
C181.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC18C0402_1u_10Vdc_X5RC18
C191.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC19C0402_1u_10Vdc_X5RC19
C201.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC20C0402_1u_10Vdc_X5RC20
C211.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC21C0402_1u_10Vdc_X5RC21
C2210pFNone10pF, 100Vdc, ±2%, C0GNoneNoneNoneMurataGRM1555C2A100GA01NoneC22C0402_10p_100Vdc_C0GC22
C2310pFNone10pF, 100Vdc, ±2%, C0GNoneNoneNoneMurataGRM1555C2A100GA01NoneC23C0402_10p_100Vdc_C0GC23
C2410pFNone10pF, 100Vdc, ±2%, C0GNoneNoneNoneMurataGRM1555C2A100GA01NoneC24C0402_10p_100Vdc_C0GC24
C2510pFNone10pF, 100Vdc, ±2%, C0GNoneNoneNoneMurataGRM1555C2A100GA01NoneC25C0402_10p_100Vdc_C0GC25
C2610pFNone10pF, 100Vdc, ±2%, C0GNoneNoneNoneMurataGRM1555C2A100GA01NoneC26C0402_10p_100Vdc_C0GC26
C271.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC27C0402_1u_10Vdc_X5RC27
C2815pFNone15pF, 100Vdc, ±2%, C0GNoneNoneNoneMurataGRM1555C2A150GA01NoneC28C0402_15p_100Vdc_C0GC28
C291.0uFNone1.0uF, 10Vdc, ±20%, X5RNoneNoneNoneMurataGRM153R61A105ME95NoneC29C0402_1u_10Vdc_X5RC29
C3015pFNone15pF, 100Vdc, ±2%, C0GNoneNoneNoneMurataGRM1555C2A150GA01NoneC30C0402_15p_100Vdc_C0GC30
.............................................
R32NoneNone1.5k, ±1%, 0.063WNoneNoneNoneVishayCRCW04021K50FKED1.5kR32R0402_1k50R32
R33NoneNone10k, ±1%, 0.063WNoneNoneNoneVishayCRCW040210K0FKED10kR33R0402_10kR33
R34NoneNone330, ±1%, 0.063WNoneNoneNoneVishayCRCW0402330RFKED330R34R0402_330RR34
R35NoneNone330, ±1%, 0.063WNoneNoneNoneVishayCRCW0402330RFKED330R35R0402_330RR35
R36NoneNone10k, ±1%, 0.063WNoneNoneNoneVishayCRCW040210K0FKED10kR36R0402_10kR36
R37NoneNone100k, ±1%, 0.063WNoneNoneNoneVishayCRCW0402100KFKED100kR37R0402_100kR37
R38NoneNone100k, ±1%, 0.063WNoneNoneNoneVishayCRCW0402100KFKED100kR38R0402_100kR38
R39NoneNone100k, ±1%, 0.063WNoneNoneNoneVishayCRCW0402100KFKED100kR39R0402_100kR39
R40NoneNone100, ±1%, 0.063WNoneNoneNoneVishayCRCW0402100RFKED100R40R0402_100RR40
R41NoneNone100, ±1%, 0.063WNoneNoneNoneVishayCRCW0402100RFKED100R41R0402_100RR41
R42NoneNone39, ±1%, 0.063WNoneNoneNoneVishayCRCW040239R0FKED39R42R0402_39RR42
R43NoneNone39, ±1%, 0.063WNoneNoneNoneVishayCRCW040239R0FKED39R43R0402_39RR43
R44NoneNone10k, ±1%, 0.063WNoneNoneNoneVishayCRCW040210K0FKED10kR44R0402_10kR44
T1NoneNoneNoneNoneNoneNoneNoneNoneNoneT1S558-5999-T7-FT1
U1NoneNoneNoneNoneNoneNoneNoneNoneNoneU1AT91SAM9G25U1
U2NoneNoneNoneNoneNoneNoneNoneNoneNoneU2USBLC6-4U2
U3NoneNoneNoneNoneNoneNoneNoneNoneNoneU3CC2520U3
U4NoneNoneNoneNoneNoneNoneNoneNoneNoneU4NCP360SNAET1GU4
U5NoneNoneNoneNoneNoneNoneNoneNoneNoneU5TPS62742U5
U6NoneNoneNoneNoneNoneNoneNoneNoneNoneU6MIC23254U6
U7NoneNoneNoneNoneNoneNoneNoneNoneNoneU7IS46DR16640BU7
U8NoneNoneNoneNoneNoneNoneNoneNoneNoneU8MX30LF1G08AAU8
U9NoneNoneNoneNoneNoneNoneNoneNoneNoneU9LAN8710U9
U10NoneNoneNoneNoneNoneNoneNoneNoneNoneU10USBLC6-4U10
U11NoneNoneNoneNoneNoneNoneNoneNoneNoneU11LP3470M5-3.08U11
X1NoneNonef=12MHz, Stability:±150ppm, Tol:±50ppm,Load ca...12MHzNoneNoneNDKNX3225GA-12.000M-STD-CRA-1NoneX1NX3225GA-12.000M-STD-CRA-1X1
X2NoneNonef=32.768kHz, Stability:-, Tol:±20ppm,Load capa...32.768kHzNoneNoneNDKNX2012SA-32.768K-STD-MUB-1NoneX2NX2012SA-32.768K-STD-MUB-1X2
X3NoneNonef=32MHz, Stability:±10ppm, Tol:±10ppm,Load cap...32MHzNoneNoneNDKNX2520SA-32.000000MHZNoneX3NX2520SA-32.000000MHZX3
X4NoneNonef=25MHz, Stability:±25ppm, Tol:±15ppm,Load cap...25MHzNoneNoneNDKNX2520SA-25.000M-STD-CSW-5NoneX4NX2520SA-25.000M-STD-CSW-5X4
Z1NoneNoneNoneNoneNoneNoneNoneNoneNoneZ1WLA.01Z1
\n", - "

165 rows × 14 columns

\n", - "
" - ], - "text/plain": [ - " Capacitance Color Description \\\n", - "C1 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C2 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C3 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C4 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C5 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C6 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C7 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C8 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C9 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C10 4.7uF None 4.7uF, 6.3Vdc, ±20%, X5R \n", - "C11 4.7uF None 4.7uF, 6.3Vdc, ±20%, X5R \n", - "C12 4.7uF None 4.7uF, 6.3Vdc, ±20%, X5R \n", - "C13 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C14 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C15 10000pF None 10000pF, 10Vdc, ±10%, X5R \n", - "C16 10000pF None 10000pF, 10Vdc, ±10%, X5R \n", - "C17 10000pF None 10000pF, 10Vdc, ±10%, X5R \n", - "C18 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C19 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C20 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C21 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C22 10pF None 10pF, 100Vdc, ±2%, C0G \n", - "C23 10pF None 10pF, 100Vdc, ±2%, C0G \n", - "C24 10pF None 10pF, 100Vdc, ±2%, C0G \n", - "C25 10pF None 10pF, 100Vdc, ±2%, C0G \n", - "C26 10pF None 10pF, 100Vdc, ±2%, C0G \n", - "C27 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C28 15pF None 15pF, 100Vdc, ±2%, C0G \n", - "C29 1.0uF None 1.0uF, 10Vdc, ±20%, X5R \n", - "C30 15pF None 15pF, 100Vdc, ±2%, C0G \n", - ".. ... ... ... \n", - "R32 None None 1.5k, ±1%, 0.063W \n", - "R33 None None 10k, ±1%, 0.063W \n", - "R34 None None 330, ±1%, 0.063W \n", - "R35 None None 330, ±1%, 0.063W \n", - "R36 None None 10k, ±1%, 0.063W \n", - "R37 None None 100k, ±1%, 0.063W \n", - "R38 None None 100k, ±1%, 0.063W \n", - "R39 None None 100k, ±1%, 0.063W \n", - "R40 None None 100, ±1%, 0.063W \n", - "R41 None None 100, ±1%, 0.063W \n", - "R42 None None 39, ±1%, 0.063W \n", - "R43 None None 39, ±1%, 0.063W \n", - "R44 None None 10k, ±1%, 0.063W \n", - "T1 None None None \n", - "U1 None None None \n", - "U2 None None None \n", - "U3 None None None \n", - "U4 None None None \n", - "U5 None None None \n", - "U6 None None None \n", - "U7 None None None \n", - "U8 None None None \n", - "U9 None None None \n", - "U10 None None None \n", - "U11 None None None \n", - "X1 None None f=12MHz, Stability:±150ppm, Tol:±50ppm,Load ca... \n", - "X2 None None f=32.768kHz, Stability:-, Tol:±20ppm,Load capa... \n", - "X3 None None f=32MHz, Stability:±10ppm, Tol:±10ppm,Load cap... \n", - "X4 None None f=25MHz, Stability:±25ppm, Tol:±15ppm,Load cap... \n", - "Z1 None None None \n", - "\n", - " Frequency Impedance Inductance Manufacturer Part Number \\\n", - "C1 None None None Murata GRM153R61A105ME95 \n", - "C2 None None None Murata GRM153R61A105ME95 \n", - "C3 None None None Murata GRM153R61A105ME95 \n", - "C4 None None None Murata GRM153R61A105ME95 \n", - "C5 None None None Murata GRM153R61A105ME95 \n", - "C6 None None None Murata GRM153R61A105ME95 \n", - "C7 None None None Murata GRM153R61A105ME95 \n", - "C8 None None None Murata GRM153R61A105ME95 \n", - "C9 None None None Murata GRM153R61A105ME95 \n", - "C10 None None None Murata GRM185R60J475ME15 \n", - "C11 None None None Murata GRM185R60J475ME15 \n", - "C12 None None None Murata GRM185R60J475ME15 \n", - "C13 None None None Murata GRM153R61A105ME95 \n", - "C14 None None None Murata GRM153R61A105ME95 \n", - "C15 None None None Murata GRM155R61A103KA01 \n", - "C16 None None None Murata GRM155R61A103KA01 \n", - "C17 None None None Murata GRM155R61A103KA01 \n", - "C18 None None None Murata GRM153R61A105ME95 \n", - "C19 None None None Murata GRM153R61A105ME95 \n", - "C20 None None None Murata GRM153R61A105ME95 \n", - "C21 None None None Murata GRM153R61A105ME95 \n", - "C22 None None None Murata GRM1555C2A100GA01 \n", - "C23 None None None Murata GRM1555C2A100GA01 \n", - "C24 None None None Murata GRM1555C2A100GA01 \n", - "C25 None None None Murata GRM1555C2A100GA01 \n", - "C26 None None None Murata GRM1555C2A100GA01 \n", - "C27 None None None Murata GRM153R61A105ME95 \n", - "C28 None None None Murata GRM1555C2A150GA01 \n", - "C29 None None None Murata GRM153R61A105ME95 \n", - "C30 None None None Murata GRM1555C2A150GA01 \n", - ".. ... ... ... ... ... \n", - "R32 None None None Vishay CRCW04021K50FKED \n", - "R33 None None None Vishay CRCW040210K0FKED \n", - "R34 None None None Vishay CRCW0402330RFKED \n", - "R35 None None None Vishay CRCW0402330RFKED \n", - "R36 None None None Vishay CRCW040210K0FKED \n", - "R37 None None None Vishay CRCW0402100KFKED \n", - "R38 None None None Vishay CRCW0402100KFKED \n", - "R39 None None None Vishay CRCW0402100KFKED \n", - "R40 None None None Vishay CRCW0402100RFKED \n", - "R41 None None None Vishay CRCW0402100RFKED \n", - "R42 None None None Vishay CRCW040239R0FKED \n", - "R43 None None None Vishay CRCW040239R0FKED \n", - "R44 None None None Vishay CRCW040210K0FKED \n", - "T1 None None None None None \n", - "U1 None None None None None \n", - "U2 None None None None None \n", - "U3 None None None None None \n", - "U4 None None None None None \n", - "U5 None None None None None \n", - "U6 None None None None None \n", - "U7 None None None None None \n", - "U8 None None None None None \n", - "U9 None None None None None \n", - "U10 None None None None None \n", - "U11 None None None None None \n", - "X1 12MHz None None NDK NX3225GA-12.000M-STD-CRA-1 \n", - "X2 32.768kHz None None NDK NX2012SA-32.768K-STD-MUB-1 \n", - "X3 32MHz None None NDK NX2520SA-32.000000MHZ \n", - "X4 25MHz None None NDK NX2520SA-25.000M-STD-CSW-5 \n", - "Z1 None None None None None \n", - "\n", - " Resistance ref value ref_name ref_num ref_rest \n", - "C1 None C1 C0402_1u_10Vdc_X5R C 1 \n", - "C2 None C2 C0402_1u_10Vdc_X5R C 2 \n", - "C3 None C3 C0402_1u_10Vdc_X5R C 3 \n", - "C4 None C4 C0402_1u_10Vdc_X5R C 4 \n", - "C5 None C5 C0402_1u_10Vdc_X5R C 5 \n", - "C6 None C6 C0402_1u_10Vdc_X5R C 6 \n", - "C7 None C7 C0402_1u_10Vdc_X5R C 7 \n", - "C8 None C8 C0402_1u_10Vdc_X5R C 8 \n", - "C9 None C9 C0402_1u_10Vdc_X5R C 9 \n", - "C10 None C10 C0603_4u7_6.3Vdc_X5R C 10 \n", - "C11 None C11 C0603_4u7_6.3Vdc_X5R C 11 \n", - "C12 None C12 C0603_4u7_6.3Vdc_X5R C 12 \n", - "C13 None C13 C0402_1u_10Vdc_X5R C 13 \n", - "C14 None C14 C0402_1u_10Vdc_X5R C 14 \n", - "C15 None C15 C0402_10n_10Vdc_X5R C 15 \n", - "C16 None C16 C0402_10n_10Vdc_X5R C 16 \n", - "C17 None C17 C0402_10n_10Vdc_X5R C 17 \n", - "C18 None C18 C0402_1u_10Vdc_X5R C 18 \n", - "C19 None C19 C0402_1u_10Vdc_X5R C 19 \n", - "C20 None C20 C0402_1u_10Vdc_X5R C 20 \n", - "C21 None C21 C0402_1u_10Vdc_X5R C 21 \n", - "C22 None C22 C0402_10p_100Vdc_C0G C 22 \n", - "C23 None C23 C0402_10p_100Vdc_C0G C 23 \n", - "C24 None C24 C0402_10p_100Vdc_C0G C 24 \n", - "C25 None C25 C0402_10p_100Vdc_C0G C 25 \n", - "C26 None C26 C0402_10p_100Vdc_C0G C 26 \n", - "C27 None C27 C0402_1u_10Vdc_X5R C 27 \n", - "C28 None C28 C0402_15p_100Vdc_C0G C 28 \n", - "C29 None C29 C0402_1u_10Vdc_X5R C 29 \n", - "C30 None C30 C0402_15p_100Vdc_C0G C 30 \n", - ".. ... ... ... ... ... ... \n", - "R32 1.5k R32 R0402_1k50 R 32 \n", - "R33 10k R33 R0402_10k R 33 \n", - "R34 330 R34 R0402_330R R 34 \n", - "R35 330 R35 R0402_330R R 35 \n", - "R36 10k R36 R0402_10k R 36 \n", - "R37 100k R37 R0402_100k R 37 \n", - "R38 100k R38 R0402_100k R 38 \n", - "R39 100k R39 R0402_100k R 39 \n", - "R40 100 R40 R0402_100R R 40 \n", - "R41 100 R41 R0402_100R R 41 \n", - "R42 39 R42 R0402_39R R 42 \n", - "R43 39 R43 R0402_39R R 43 \n", - "R44 10k R44 R0402_10k R 44 \n", - "T1 None T1 S558-5999-T7-F T 1 \n", - "U1 None U1 AT91SAM9G25 U 1 \n", - "U2 None U2 USBLC6-4 U 2 \n", - "U3 None U3 CC2520 U 3 \n", - "U4 None U4 NCP360SNAET1G U 4 \n", - "U5 None U5 TPS62742 U 5 \n", - "U6 None U6 MIC23254 U 6 \n", - "U7 None U7 IS46DR16640B U 7 \n", - "U8 None U8 MX30LF1G08AA U 8 \n", - "U9 None U9 LAN8710 U 9 \n", - "U10 None U10 USBLC6-4 U 10 \n", - "U11 None U11 LP3470M5-3.08 U 11 \n", - "X1 None X1 NX3225GA-12.000M-STD-CRA-1 X 1 \n", - "X2 None X2 NX2012SA-32.768K-STD-MUB-1 X 2 \n", - "X3 None X3 NX2520SA-32.000000MHZ X 3 \n", - "X4 None X4 NX2520SA-25.000M-STD-CSW-5 X 4 \n", - "Z1 None Z1 WLA.01 Z 1 \n", - "\n", - "[165 rows x 14 columns]" - ] - }, - "execution_count": 201, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "bom" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.5.4rc1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/demo/notebooks/bad-bom.ipynb b/demo/notebooks/bad-bom.ipynb new file mode 100644 index 0000000..e84de79 --- /dev/null +++ b/demo/notebooks/bad-bom.ipynb @@ -0,0 +1,437 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Notebook configuration" + ] + }, + { + "cell_type": "code", + "execution_count": 248, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The autoreload extension is already loaded. To reload it, use:\n", + " %reload_ext autoreload\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "[autoreload of ee failed: Traceback (most recent call last):\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/IPython/extensions/autoreload.py\", line 246, in check\n", + " superreload(m, reload, self.old_objects)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/IPython/extensions/autoreload.py\", line 369, in superreload\n", + " module = reload(module)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/imp.py\", line 315, in reload\n", + " return importlib.reload(module)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/importlib/__init__.py\", line 166, in reload\n", + " _bootstrap._exec(spec, module)\n", + " File \"\", line 626, in _exec\n", + " File \"\", line 697, in exec_module\n", + " File \"\", line 222, in _call_with_frames_removed\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/src/ee/__init__.py\", line 43, in \n", + " EeVal.r = re.compile(\"([0-9]+)( *)([\" + join(EeVal.exponents.keys()) + \"])\")\n", + "NameError: name 'join' is not defined\n", + "]\n", + "[autoreload of ee failed: Traceback (most recent call last):\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/IPython/extensions/autoreload.py\", line 246, in check\n", + " superreload(m, reload, self.old_objects)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/IPython/extensions/autoreload.py\", line 369, in superreload\n", + " module = reload(module)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/imp.py\", line 315, in reload\n", + " return importlib.reload(module)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/importlib/__init__.py\", line 166, in reload\n", + " _bootstrap._exec(spec, module)\n", + " File \"\", line 626, in _exec\n", + " File \"\", line 697, in exec_module\n", + " File \"\", line 222, in _call_with_frames_removed\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/src/ee/__init__.py\", line 43, in \n", + " EeVal.r = re.compile(\"([0-9]+)( *)([\" + join(EeVal.exponents.keys()) + \"])\")\n", + "NameError: name 'join' is not defined\n", + "]\n" + ] + }, + { + "ename": "NameError", + "evalue": "name 'EeVal' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mee\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkicad\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbom\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mee\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkicad\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mio\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mread_bom\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 11\u001b[0;31m \u001b[0mEeVal\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mNameError\u001b[0m: name 'EeVal' is not defined" + ] + } + ], + "source": [ + "%load_ext autoreload\n", + "%autoreload 2\n", + "\n", + "%aimport ee.kicad.bom\n", + "%aimport ee.kicad.bom.io\n", + "\n", + "import ee\n", + "from ee.formatting import *\n", + "from ee.kicad.bom import *\n", + "from ee.kicad.bom.io import read_bom\n", + "EeVal.r" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load the BOM" + ] + }, + { + "cell_type": "code", + "execution_count": 239, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
digikeympnrefvalue
R1311-1.00KFRTR-NDRC1206FR-071KLR110k
C4NoneNoneC41uF
R2NoneNoneR210k
C3NoneNoneC3100n
\n", + "
" + ], + "text/plain": [ + " digikey mpn ref value\n", + "R1 311-1.00KFRTR-ND RC1206FR-071KL R1 10k\n", + "C4 None None C4 1uF\n", + "R2 None None R2 10k\n", + "C3 None None C3 100n" + ] + }, + "execution_count": 239, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import os\n", + "import os.path\n", + "import pandas\n", + "\n", + "bom = read_bom(\"../kicad/bad-bom.xml\").to_pandas()\n", + "bom" + ] + }, + { + "cell_type": "code", + "execution_count": 244, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "[autoreload of ee failed: Traceback (most recent call last):\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/IPython/extensions/autoreload.py\", line 246, in check\n", + " superreload(m, reload, self.old_objects)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/IPython/extensions/autoreload.py\", line 369, in superreload\n", + " module = reload(module)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/imp.py\", line 315, in reload\n", + " return importlib.reload(module)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/importlib/__init__.py\", line 166, in reload\n", + " _bootstrap._exec(spec, module)\n", + " File \"\", line 626, in _exec\n", + " File \"\", line 697, in exec_module\n", + " File \"\", line 222, in _call_with_frames_removed\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/src/ee/__init__.py\", line 42, in \n", + " EeVal.r = re.compile(\"([0-9]+)( *)([\" + join(EeVal.exponents.keys()) + \"])\")\n", + "NameError: name 're' is not defined\n", + "]\n", + "[autoreload of ee failed: Traceback (most recent call last):\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/IPython/extensions/autoreload.py\", line 246, in check\n", + " superreload(m, reload, self.old_objects)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/IPython/extensions/autoreload.py\", line 369, in superreload\n", + " module = reload(module)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/imp.py\", line 315, in reload\n", + " return importlib.reload(module)\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/importlib/__init__.py\", line 166, in reload\n", + " _bootstrap._exec(spec, module)\n", + " File \"\", line 626, in _exec\n", + " File \"\", line 697, in exec_module\n", + " File \"\", line 222, in _call_with_frames_removed\n", + " File \"/home/trygvis/dev/io.trygvis/2017/07/ee-python/src/ee/__init__.py\", line 42, in \n", + " EeVal.r = re.compile(\"([0-9]+)( *)([\" + join(EeVal.exponents.keys()) + \"])\")\n", + "NameError: name 're' is not defined\n", + "]\n" + ] + }, + { + "ename": "TypeError", + "evalue": "exceptions must derive from BaseException", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mbom\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"value\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mee_parse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/pandas/core/series.py\u001b[0m in \u001b[0;36mapply\u001b[0;34m(self, func, convert_dtype, args, **kwds)\u001b[0m\n\u001b[1;32m 2353\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2354\u001b[0m \u001b[0mvalues\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masobject\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2355\u001b[0;31m \u001b[0mmapped\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmap_infer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconvert\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mconvert_dtype\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2356\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2357\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmapped\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmapped\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mSeries\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32mpandas/_libs/src/inference.pyx\u001b[0m in \u001b[0;36mpandas._libs.lib.map_infer (pandas/_libs/lib.c:66645)\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32m~/dev/io.trygvis/2017/07/ee-python/src/ee/formatting/__init__.py\u001b[0m in \u001b[0;36mee_parse\u001b[0;34m(s)\u001b[0m\n\u001b[1;32m 99\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 100\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mee_parse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ms\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 101\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0;34m\"deprecated\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 102\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mdecimal\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mDecimal\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 103\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: exceptions must derive from BaseException" + ] + } + ], + "source": [ + "bom[\"value\"].apply(ee_parse)" + ] + }, + { + "cell_type": "code", + "execution_count": 229, + "metadata": {}, + "outputs": [ + { + "ename": "KeyError", + "evalue": "'Part Number'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mpn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mitem\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mbom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgroupby\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Part Number'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mg\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_group\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"# {}:\\n{}\\n\\n\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpn\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mg\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36mgroupby\u001b[0;34m(self, by, axis, level, as_index, sort, group_keys, squeeze, **kwargs)\u001b[0m\n\u001b[1;32m 4414\u001b[0m return groupby(self, by=by, axis=axis, level=level, as_index=as_index,\n\u001b[1;32m 4415\u001b[0m \u001b[0msort\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msort\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgroup_keys\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mgroup_keys\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msqueeze\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msqueeze\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 4416\u001b[0;31m **kwargs)\n\u001b[0m\u001b[1;32m 4417\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4418\u001b[0m def asfreq(self, freq, method=None, how=None, normalize=False,\n", + "\u001b[0;32m~/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/pandas/core/groupby.py\u001b[0m in \u001b[0;36mgroupby\u001b[0;34m(obj, by, **kwds)\u001b[0m\n\u001b[1;32m 1697\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'invalid type: %s'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1698\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1699\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mklass\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mby\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1700\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1701\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/pandas/core/groupby.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, obj, keys, axis, level, grouper, exclusions, selection, as_index, sort, group_keys, squeeze, **kwargs)\u001b[0m\n\u001b[1;32m 390\u001b[0m \u001b[0mlevel\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlevel\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 391\u001b[0m \u001b[0msort\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msort\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 392\u001b[0;31m mutated=self.mutated)\n\u001b[0m\u001b[1;32m 393\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 394\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mobj\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mobj\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/dev/io.trygvis/2017/07/ee-python/env-python3/lib/python3.5/site-packages/pandas/core/groupby.py\u001b[0m in \u001b[0;36m_get_grouper\u001b[0;34m(obj, key, axis, level, sort, mutated)\u001b[0m\n\u001b[1;32m 2688\u001b[0m \u001b[0min_axis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlevel\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgpr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgpr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2689\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2690\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgpr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2691\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgpr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mGrouper\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mgpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkey\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2692\u001b[0m \u001b[0;31m# Add key to exclusions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: 'Part Number'" + ] + } + ], + "source": [ + "for pn, item in bom.groupby(['Part Number']):\n", + " g = x.get_group(pn)\n", + " print(\"# {}:\\n{}\\n\\n\".format(pn, len(g)))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 325, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
invalueexpunitrestlen(rest)
010100
110k10k0
210kOhm10kOhm0
310k G10kG1
410M Hwat10MHwat3
\n", + "
" + ], + "text/plain": [ + " in value exp unit rest len(rest)\n", + "0 10 10 0\n", + "1 10k 10 k 0\n", + "2 10kOhm 10 k Ohm 0\n", + "3 10k G 10 k G 1\n", + "4 10M Hwat 10 M H wat 3" + ] + }, + "execution_count": 325, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import re\n", + "r=re.compile(\"([0-9]+)( *)([EMpPnuTµkmGf]?) *(F|Ohm|Ω|H?) *(.*)\")\n", + "\n", + "tests = [\"10\", \"10k\", \"10kOhm\", \"10k G\", \"10M Hwat\"]\n", + "data=[]\n", + "\n", + "for t in tests:\n", + " m=r.match(t)\n", + " gs=m.groups()\n", + " data.append((t, gs[0], gs[2], gs[3], gs[4], len(gs[4])))\n", + "\n", + "pandas.DataFrame(data=data, columns=['in', 'value', 'exp', 'unit', 'rest', 'len(rest)'])" + ] + }, + { + "cell_type": "code", + "execution_count": 300, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 1.27270446, 0.04395931, 1.54053766, -0.29093601, 1.30028845],\n", + " [-0.12251453, -1.16148211, 0.53045512, 0.44172195, 0.94238916],\n", + " [-0.12981926, -0.98367131, 0.37159006, 0.6195868 , -0.90403497],\n", + " [ 0.26614445, 0.47932884, 0.23314929, -0.15904921, 1.3544832 ],\n", + " [-1.19267536, 2.33740053, -1.18444525, 0.44111548, 0.60629138],\n", + " [-1.45884344, 0.61256059, -0.97138815, -0.82263728, 0.68976108],\n", + " [ 1.08294243, 0.88823694, -0.19957563, 0.52466939, -0.38971842],\n", + " [-0.94265388, 1.86801751, 0.21990138, -1.34364849, 0.32846411],\n", + " [ 0.83686376, -1.03843546, 0.84131267, -1.10071726, -0.25169346],\n", + " [-0.50006954, 1.21361699, 0.14561531, -0.39272299, 0.30361834]])" + ] + }, + "execution_count": 300, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import numpy as np\n", + "np.random.randn(10, 5)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.5.4rc1" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} -- cgit v1.2.3