From eric at intellovations.com Sat Dec 3 18:11:06 2016 From: eric at intellovations.com (Eric Floehr) Date: Sat, 3 Dec 2016 18:11:06 -0500 Subject: [CentralOH] COhPy social meetup Monday Message-ID: Don't forget our yearly Central Ohio Python User Group social meetup is this Monday, December 5, at Barley's Brew House across from the convention center. It officially starts at 6, but feel free to come earlier or later. Please RSVP Here: https://www.meetup.com/Central-Ohio-Python-Users-Group/events/228901555/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Sun Dec 4 12:14:23 2016 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Sun, 4 Dec 2016 12:14:23 -0500 Subject: [CentralOH] =?utf-8?q?2016-12-02_=E9=81=93=E5=A0=B4_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz8gYWR2ZW50IG9mIGNvZGU6IFByZXR0eSBhbmQgVWds?= =?utf-8?b?eTsgZHVjayB0eXBpbmc7IENvdW50ZXI7IF9fbWlzc2luZ19fOyAuY2FzZWZv?= =?utf-8?q?ld=28=29=3B_kivy=3B_loose_table_legs?= Message-ID: <20161204121423.27a3e91a.jep200404@columbus.rr.com> six folks tonight Which cell is more readable for you? Cell #1, #2, or #5? What makes the other cells less readable? http://nbviewer.jupyter.org/github/james-prior/cohpy/blob/master/20161202-dojo-advent-of-code-day-01-part-1-route-distance.ipynb First focuses on readability, then descends into obfuscation. There is some deliciously nasty stuff in there. inspired by: https://github.com/hakim89/adventofcode/blob/a21c50118f7ed1630c5a5280bb7baaa6aa48aee9/day-01.py desert challenge adventofcode.com wp:manhattan distance wp:cardinal direction airplane names wp: prefix means Wikipedia To get good answers, consider following the advice in the links below. http://catb.org/~esr/faqs/smart-questions.html http://web.archive.org/web/20090627155454/www.greenend.org.uk/rjk/2000/06/14/quoting.html new version of Learning Python updated 2016-10-14. Duck typing according to Raymond Never use the tests isinstance() and issubclass(). Don't do type checks. Everywhere you did type checks, it precluded you from the ability to do duck typing. Anybody who puts in type checks is defeating duck typing. In my first six months of doing Python, I put type checks everywhere. My next six months were taking them all back out. The maturing of a Python programmer is to not use isinstance() anywhere. wp:Red_pill_and_blue_pill Counter() is just a dictionary, can put anything in it floats, Decimals, 'kitchen sinks' Raymond loves __missing__ method. Python Lex & Yacc https://pypi.python.org/pypi/ply wp:yacc wp:Lex (software) .casefold() is the new .lower() https://www.djangoproject.com/ django szNJ6DqrqoA found long lost brand new 32 GB USB flash drive Cruzer Fit in book bag was lost about 3.5 years someone gave up on kivy someone else showed "hello" touch screen app made with kivy forgot to bring wrenches and nail polish to tighten loose table legs 1/2?, 9/16?, 5/8? 3/8 drive ratchet and sockets just wrenches From jep200404 at columbus.rr.com Tue Dec 6 10:33:17 2016 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Tue, 6 Dec 2016 10:33:17 -0500 Subject: [CentralOH] =?utf-8?q?2016-12-05_=E6=9C=83=E8=AD=B0_Coaster_Scrib?= =?utf-8?b?YmxlcyDvpJjmm7gv5oOh5paHPzogcHJlc2VudGF0aW9ucw==?= Message-ID: <20161206103317.5c472f64.jep200404@columbus.rr.com> There were 8 folks downstairs in the rearmost area by the rear door. Some of us have been in exactly the same seat for several years. There was another group of Pythonistas that was directed upstairs. Neither group knew of the other's existence. Bummer. presentations that work good: several small presentations instead of one big presentation group refactoring of a small program small challenges that both beginners and experts can do small challenges get more entries a new kind of challenge could be to start with a given program and modify it however you want. That's how the last challenge https://github.com/cohpy/challenge-201608-refactor worked out. Ideally, presentations have something for both beginners and experts. What would you like to see? What would you like to present? From jshaffstall at gmail.com Wed Dec 7 09:43:48 2016 From: jshaffstall at gmail.com (Jay Shaffstall) Date: Wed, 7 Dec 2016 09:43:48 -0500 Subject: [CentralOH] Python packaging for PyPI Message-ID: Hi all, I've been writing a physics sandbox (basically a simplified wrapper around Pymunk) for my Intro to Computer Science classes to use for one of their labs. I'd initially been writing it just for my own use, but have realized it's something that other educators might also be interested in using. My plan is to put it on Github and package it so it can be installed using pip. I have a couple of dependencies, though, that don't easily install using standard pip. I wanted to get feedback from those of you who've done this before on the best way of handling those dependencies. I'll list the dependencies below. Thanks, Jay Py2d This can be installed via pip, but the PyPI version doesn't support Python 3, which my sandbox uses. The github version does support Python 3. If I put the github repo in requirements.txt, can that be installed on machines without git? Pygame Which version of pygame needs installed depends on the version of Python they have (both version and 32/64-bit). I've always had to hunt up a specific version to match what I have installed at the time. Is there a best practice for having pygame automatically installed as a dependency if it's not already there? -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrewkubera at gmail.com Wed Dec 7 11:15:53 2016 From: andrewkubera at gmail.com (Andrew Kubera) Date: Wed, 7 Dec 2016 11:15:53 -0500 Subject: [CentralOH] Python packaging for PyPI In-Reply-To: References: Message-ID: <9D8FAAC4-A700-40E3-BB8C-6B7A9C1B6F90@gmail.com> Hi Jay, A little test just showed me python requires git to pull directly from a git repository (that might be a fun setuptools extension - pure-python implementation of the minimum functionality to do a git clone). I think the easiest thing to do is just place the Py2D source into your project; I wouldn't usually suggest that, but it hasn't been updated in years, and it'd be easier to fix any bugs. Add it to the packages list in the setup() function. It looks like pygame is uploaded to pypi as wheels, so architecture should be handled for you (eg: manylinux1_x86_64, win32, win_amd64). I don't know if you need the wheel package installed beforehand, but you can ensure it is beforehand by adding it to setup_requires=['wheel'], in the setup.py script. So the setup.py should have something like: setup( name='sandbox', packages=['sandbox', 'Py2D'], setup_requires=['wheel'], requires=['pygame', ...], ... ) I've heard that 'executable' packages should have REQUIREMENTS.txt, and 'library' packages should use setup.py to declare dependencies. I'm a fan of the setup.py method for everything (keep it DRY). Let me know if this works and be sure to share the github repo so we can check out your project when its ready! - Andrew Kubera > On Dec 7, 2016, at 9:43 AM, Jay Shaffstall wrote: > > Hi all, > > I've been writing a physics sandbox (basically a simplified wrapper around Pymunk) for my Intro to Computer Science classes to use for one of their labs. I'd initially been writing it just for my own use, but have realized it's something that other educators might also be interested in using. > > My plan is to put it on Github and package it so it can be installed using pip. I have a couple of dependencies, though, that don't easily install using standard pip. > > I wanted to get feedback from those of you who've done this before on the best way of handling those dependencies. > > I'll list the dependencies below. > > Thanks, > Jay > > Py2d > > This can be installed via pip, but the PyPI version doesn't support Python 3, which my sandbox uses. The github version does support Python 3. > > If I put the github repo in requirements.txt, can that be installed on machines without git? > > Pygame > > Which version of pygame needs installed depends on the version of Python they have (both version and 32/64-bit). I've always had to hunt up a specific version to match what I have installed at the time. > > Is there a best practice for having pygame automatically installed as a dependency if it's not already there? > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrewkubera at gmail.com Wed Dec 7 11:33:12 2016 From: andrewkubera at gmail.com (Andrew Kubera) Date: Wed, 7 Dec 2016 11:33:12 -0500 Subject: [CentralOH] Python packaging for PyPI In-Reply-To: <9D8FAAC4-A700-40E3-BB8C-6B7A9C1B6F90@gmail.com> References: <9D8FAAC4-A700-40E3-BB8C-6B7A9C1B6F90@gmail.com> Message-ID: Of course, I meant `install_requires=` instead of just `requires=`. > On Dec 7, 2016, at 11:15 AM, Andrew Kubera wrote: > > Hi Jay, > > A little test just showed me python requires git to pull directly from a git repository > (that might be a fun setuptools extension - pure-python implementation of the > minimum functionality to do a git clone). I think the easiest thing to do is just place > the Py2D source into your project; I wouldn't usually suggest that, but it hasn't been > updated in years, and it'd be easier to fix any bugs. Add it to the packages list in the > setup() function. > > It looks like pygame is uploaded to pypi as wheels, so architecture should be handled > for you (eg: manylinux1_x86_64, win32, win_amd64). I don't know if you need the > wheel package installed beforehand, but you can ensure it is beforehand by adding it > to setup_requires=['wheel'], in the setup.py script. > > So the setup.py should have something like: > > setup( > name='sandbox', > packages=['sandbox', 'Py2D'], > setup_requires=['wheel'], > requires=['pygame', ...], > ... > ) > > I've heard that 'executable' packages should have REQUIREMENTS.txt, and 'library' packages > should use setup.py to declare dependencies. > I'm a fan of the setup.py method for everything (keep it DRY). > > Let me know if this works and be sure to share the github repo so we can check out your project > when its ready! > > - Andrew Kubera > > >> On Dec 7, 2016, at 9:43 AM, Jay Shaffstall > wrote: >> >> Hi all, >> >> I've been writing a physics sandbox (basically a simplified wrapper around Pymunk) for my Intro to Computer Science classes to use for one of their labs. I'd initially been writing it just for my own use, but have realized it's something that other educators might also be interested in using. >> >> My plan is to put it on Github and package it so it can be installed using pip. I have a couple of dependencies, though, that don't easily install using standard pip. >> >> I wanted to get feedback from those of you who've done this before on the best way of handling those dependencies. >> >> I'll list the dependencies below. >> >> Thanks, >> Jay >> >> Py2d >> >> This can be installed via pip, but the PyPI version doesn't support Python 3, which my sandbox uses. The github version does support Python 3. >> >> If I put the github repo in requirements.txt, can that be installed on machines without git? >> >> Pygame >> >> Which version of pygame needs installed depends on the version of Python they have (both version and 32/64-bit). I've always had to hunt up a specific version to match what I have installed at the time. >> >> Is there a best practice for having pygame automatically installed as a dependency if it's not already there? >> _______________________________________________ >> CentralOH mailing list >> CentralOH at python.org >> https://mail.python.org/mailman/listinfo/centraloh > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jshaffstall at gmail.com Wed Dec 7 16:20:21 2016 From: jshaffstall at gmail.com (Jay Shaffstall) Date: Wed, 7 Dec 2016 16:20:21 -0500 Subject: [CentralOH] Python packaging for PyPI In-Reply-To: References: <9D8FAAC4-A700-40E3-BB8C-6B7A9C1B6F90@gmail.com> Message-ID: Thanks, Andrew! That helps a lot. I'll be working on packaging the library up for distribution over the Christmas break, and hopefully have something to show by the first of the year. Jay On Wed, Dec 7, 2016 at 11:33 AM, Andrew Kubera wrote: > Of course, I meant `*install_requires=`* instead of just `*requires=`*. > > > > On Dec 7, 2016, at 11:15 AM, Andrew Kubera wrote: > > Hi Jay, > > A little test just showed me python requires git to pull directly from a > git repository > (that might be a fun setuptools extension - pure-python implementation of > the > minimum functionality to do a git clone). I think the easiest thing to do > is just place > the Py2D source into your project; I wouldn't usually suggest that, but it > hasn't been > updated in years, and it'd be easier to fix any bugs. Add it to the > packages list in the > setup() function. > > It looks like pygame is uploaded to pypi > as wheels, so architecture should > be handled > for you (eg: manylinux1_x86_64, win32, win_amd64). I don't know if you > need the > *wheel* package installed beforehand, but you can ensure it is beforehand > by adding it > to *setup_requires=['wheel'],* in the setup.py script. > > So the setup.py should have something like: > > setup( > name='sandbox', > packages=['sandbox', 'Py2D'], > setup_requires=['wheel'], > requires=['pygame', ...], > ... > ) > > I've heard that 'executable' packages should have REQUIREMENTS.txt, and > 'library' packages > should use setup.py to declare dependencies. > I'm a fan of the setup.py method for everything (keep it DRY). > > Let me know if this works and be sure to share the github repo so we can > check out your project > when its ready! > > - Andrew Kubera > > > On Dec 7, 2016, at 9:43 AM, Jay Shaffstall wrote: > > Hi all, > > I've been writing a physics sandbox (basically a simplified wrapper around > Pymunk) for my Intro to Computer Science classes to use for one of their > labs. I'd initially been writing it just for my own use, but have realized > it's something that other educators might also be interested in using. > > My plan is to put it on Github and package it so it can be installed using > pip. I have a couple of dependencies, though, that don't easily install > using standard pip. > > I wanted to get feedback from those of you who've done this before on the > best way of handling those dependencies. > > I'll list the dependencies below. > > Thanks, > Jay > > Py2d > > This can be installed via pip, but the PyPI version doesn't support Python > 3, which my sandbox uses. The github version does support Python 3. > > If I put the github repo in requirements.txt, can that be installed on > machines without git? > > Pygame > > Which version of pygame needs installed depends on the version of Python > they have (both version and 32/64-bit). I've always had to hunt up a > specific version to match what I have installed at the time. > > Is there a best practice for having pygame automatically installed as a > dependency if it's not already there? > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Thu Dec 8 21:19:23 2016 From: eric at intellovations.com (Eric Floehr) Date: Thu, 8 Dec 2016 21:19:23 -0500 Subject: [CentralOH] N-dimensional array slicing/crosscutting Message-ID: I was wondering if anyone knows of any way in Python (functional or not), or a module, that would allow the following: Let's say I have an n-dimensional array, with keys (numeric or otherwise) for each dimension. I'd like to be able to set up and grab the elements in any row in any dimension equally easily. Here's a simple example, a 2x2 contingency table, with rows labelled "forecast" and "not forecast" and columns labelled "occurred" and "not occurred". Within each of the 4 cells, there is some value. If I set it up traditionally, as a dict within the dict: table = {} table['forecast'] = {'occurred': 0, 'not occurred': 0} table['not forecast'] = {'occurred': 0, 'not occurred': 0} and access it traditionally: table['forecast']['occurred'] = 123 The problems are: 1. Set up is hard... I have to duplicate keys, and in an n-dimensional array, this is a real pain. 2. I always have to access a cell in the right order, and have to remember that order. It would be great if I could access a cell in the example above as table['forecast']['occurred'] or table['occurred']['forecast'] (syntax doesn't matter, table('forecast', 'occurred') is fine too). 3. It's hard to slice... in a 2-dimensional array, it's easy to get the cells in the outermost dict via table['forecast'].values() but how would I just as easily (equivalently) get table['not occurred'].values()? Thoughts? Am I missing something obvious? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Thu Dec 8 22:59:22 2016 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Thu, 8 Dec 2016 22:59:22 -0500 Subject: [CentralOH] N-dimensional array slicing/crosscutting In-Reply-To: References: Message-ID: <20161208225922.35c8d444.jep200404@columbus.rr.com> On Thu, 8 Dec 2016 21:19:23 -0500, Eric Floehr wrote: > I was wondering if anyone knows of any way in Python (functional or not), > or a module, that would allow the following: > > Let's say I have an n-dimensional array, with keys (numeric or otherwise) > for each dimension. I'd like to be able to set up and grab the elements in > any row in any dimension equally easily. Here are some fast and sloppy crazy thoughts. Your example idea showed nested dictionaries. I fear that quickly descending into madness. Since you want an n-dimensional array, I think about having an n-dimensional array, and worrying about the keys separately. Avoid dictionaries nested n deep. numpy arrays would constrain the data to all the same type. I wonder about pandas' tables (or whatever they are called), since they handle missing data well. If you want numpy kind of access, but need different kinds of values, one could store just object numbers which would be keys to an object store dictionary. That would be ugly to maintain, but likely fast. A sentinel object number would tolerate missing values. You have not said if the ability to cope with missing values is important. > 2. I always have to access a cell in the right order, and have to remember > that order. It would be great if I could access a cell in the example above > as table['forecast']['occurred'] or table['occurred']['forecast'] (syntax > doesn't matter, table('forecast', 'occurred') is fine too). Wow. That's completely crazy. To support the keys in any order, I would likely use table('forecast', 'occurred') argument style syntax, but who knows, maybe with enough __method__ magic, the table['forecast']['occurred'] syntax could be made to work. Neverminding the syntax, I can think of a couple of crazy ugly solutions. 1. Use an n-dimensional array with dictionaries that go from keys to array indexes. If each key happens only in one dimension, then you could just look up which dimension it belongs to in a dictionary Perhaps a dictionary where the keys are the keys you want and the values are: a. a tuple of the dimension that key is for and the index for that key If there is more than one key for the same dimension, raise an exception. Dimensions for which there is no index are slices. b. an n tuple of indexes, with None or 0 for the irrelevant dimensions one would look up all the n-tuples for all the keys and just add them if 0 is used for irrelevant dimension If None is used for irrelevant dimension, populate the non None indexes. The dimensions for which there is no index, would be a slice. 0 for irrelevant dimension can't do that, so I'm leaning for None for irrelevant dimensions. If two keys want to populate the same dimension, then raise exception. 0 for irrelevant dimensions can't do that, so again, I'm leaning toward None for irrelevant dimensions. numpy has some pretty powerful slicing stuff. that might make numpy arrays attractive. just put a keys to numerical indexes wrapper around an numpy array 2. Use a dictionary where the keys are tuples of sorted keys. (this also makes me think of a big non-sql database like MongoDB) When looking something up, sort the keys, then combine them, then look up the data in the big dictionary. Lookups could be rather fast. The slowest part would be the sorting. Slices would be painful, requiring one to iterate through the whole dictionary. Hmmm, how about applying regular expressions to the keys? One would build the pattern from the available key values. Of course, whatever crazy solution we come up with would likely be implemented as some class with many overloaded __method__s. > 3. It's hard to slice... in a 2-dimensional array, it's easy to get the > cells in the outermost dict via table['forecast'].values() but how would I > just as easily (equivalently) get table['not occurred'].values()? > > Thoughts? Am I missing something obvious? This sounds like a fun problem. From andrewkubera at gmail.com Thu Dec 8 23:00:06 2016 From: andrewkubera at gmail.com (Andrew Kubera) Date: Thu, 8 Dec 2016 23:00:06 -0500 Subject: [CentralOH] N-dimensional array slicing/crosscutting In-Reply-To: References: Message-ID: <4E8CA398-156A-4520-BB38-0FA87B09918F@gmail.com> This is exactly the problem that pandas DataFrames solve. Initialization may be done in multiple ways: >>> import pandas as pd >>> table = pd.DataFrame( {'forecast': {'occurred': 0, 'not_occurred': 0}, 'not_forecast': {'occurred': 0, 'not_occurred': 0}}) >>> table = pd.DataFrame([[0, 0], [0, 0]], columns=('forecast', 'not_forecast'), index=('occurred', 'not_occurred?)) >>> table forecast not_forecast not_occurred 0 0 occurred 0 0 It supports attribute or item syntax >>> table.forecast is table['forecast'] True >>> table.forecast not occurred 0 occurred 0 Name: forecast, dtype: int64 At this point ?occurred?/?not_occurred? are the index, not an addressable column. Query them by taking transpose (.T) of table: >>> table.T not_occurred occurred forecast 0 0 not_forecast 0 0 >>> table.T.not_occurred forecast 0 not_forecast 0 Name: not_occurred, dtype: int64 There is also the stack and unstack methods which linearizes the matrix, either bringing ?occurred? up to columns or ?forecast? down to index. You can create higher-dimentional frames with a MultiIndex for double columns of forecast+occurred, and an index like time or location. Good Luck - Andrew Kubera > On Dec 8, 2016, at 9:19 PM, Eric Floehr wrote: > > I was wondering if anyone knows of any way in Python (functional or not), or a module, that would allow the following: > > Let's say I have an n-dimensional array, with keys (numeric or otherwise) for each dimension. I'd like to be able to set up and grab the elements in any row in any dimension equally easily. > > Here's a simple example, a 2x2 contingency table, with rows labelled "forecast" and "not forecast" and columns labelled "occurred" and "not occurred". Within each of the 4 cells, there is some value. > > If I set it up traditionally, as a dict within the dict: > > table = {} > table['forecast'] = {'occurred': 0, 'not occurred': 0} > table['not forecast'] = {'occurred': 0, 'not occurred': 0} > > and access it traditionally: > > table['forecast']['occurred'] = 123 > > The problems are: > > 1. Set up is hard... I have to duplicate keys, and in an n-dimensional array, this is a real pain. > > 2. I always have to access a cell in the right order, and have to remember that order. It would be great if I could access a cell in the example above as table['forecast']['occurred'] or table['occurred']['forecast'] (syntax doesn't matter, table('forecast', 'occurred') is fine too). > > 3. It's hard to slice... in a 2-dimensional array, it's easy to get the cells in the outermost dict via table['forecast'].values() but how would I just as easily (equivalently) get table['not occurred'].values()? > > Thoughts? Am I missing something obvious? > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh -------------- next part -------------- An HTML attachment was scrubbed... URL: From erik.n.welch at gmail.com Thu Dec 8 23:30:30 2016 From: erik.n.welch at gmail.com (Erik Welch) Date: Thu, 8 Dec 2016 22:30:30 -0600 Subject: [CentralOH] N-dimensional array slicing/crosscutting In-Reply-To: <4E8CA398-156A-4520-BB38-0FA87B09918F@gmail.com> References: <4E8CA398-156A-4520-BB38-0FA87B09918F@gmail.com> Message-ID: Might I suggest xarray (http://xarray.pydata.org/en/stable/)? It leverages indexing from pandas for n-dimensional data. Using pandas.DataFrame with a MultiIndex as Andrew suggested is very powerful as well. Cheers, Erik On Thu, Dec 8, 2016 at 10:00 PM, Andrew Kubera wrote: > This is exactly the problem that pandas DataFrames solve. > > > Initialization may be done in multiple ways: > > >>> import pandas as pd > > > >>> table = pd.DataFrame( > {'forecast': {'occurred': 0, 'not_occurred': 0}, > 'not_forecast': {'occurred': 0, 'not_occurred': 0}}) > > >>> table = pd.DataFrame([[0, 0], [0, 0]], > columns=('forecast', 'not_forecast'), > index=('occurred', 'not_occurred?)) > >>> table > forecast not_forecast > not_occurred 0 0 > occurred 0 0 > > > It supports attribute or item syntax > > >>> table.forecast is table['forecast'] > True > >>> table.forecast > > not occurred 0 > occurred 0 > Name: forecast, dtype: int64 > > > At this point ?occurred?/?not_occurred? are the *index*, not an > addressable *column.* > Query them by taking transpose (.T) of table: > > >>> table.T > not_occurred occurred > forecast 0 0 > not_forecast 0 0 > > >>> table.T.not_occurred > > forecast 0 > not_forecast 0 > Name: not_occurred, dtype: int64 > > There is also the stack and unstack methods which linearizes the matrix, > either > bringing ?occurred? up to columns or ?forecast? down to index. > > You can create higher-dimentional frames with a MultiIndex for double > columns > of forecast+occurred, and an index like time or location. > > Good Luck > > - Andrew Kubera > > > On Dec 8, 2016, at 9:19 PM, Eric Floehr wrote: > > I was wondering if anyone knows of any way in Python (functional or not), > or a module, that would allow the following: > > Let's say I have an n-dimensional array, with keys (numeric or otherwise) > for each dimension. I'd like to be able to set up and grab the elements in > any row in any dimension equally easily. > > Here's a simple example, a 2x2 contingency table, with rows labelled > "forecast" and "not forecast" and columns labelled "occurred" and "not > occurred". Within each of the 4 cells, there is some value. > > If I set it up traditionally, as a dict within the dict: > > table = {} > table['forecast'] = {'occurred': 0, 'not occurred': 0} > table['not forecast'] = {'occurred': 0, 'not occurred': 0} > > and access it traditionally: > > table['forecast']['occurred'] = 123 > > The problems are: > > 1. Set up is hard... I have to duplicate keys, and in an n-dimensional > array, this is a real pain. > > 2. I always have to access a cell in the right order, and have to remember > that order. It would be great if I could access a cell in the example above > as table['forecast']['occurred'] or table['occurred']['forecast'] (syntax > doesn't matter, table('forecast', 'occurred') is fine too). > > 3. It's hard to slice... in a 2-dimensional array, it's easy to get the > cells in the outermost dict via table['forecast'].values() but how would I > just as easily (equivalently) get table['not occurred'].values()? > > Thoughts? Am I missing something obvious? > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nludban at columbus.rr.com Thu Dec 8 23:48:31 2016 From: nludban at columbus.rr.com (Neil Ludban) Date: Thu, 8 Dec 2016 23:48:31 -0500 Subject: [CentralOH] N-dimensional array slicing/crosscutting In-Reply-To: References: Message-ID: <20161208234831.167c98ed133afb4c9e053608@columbus.rr.com> On Thu, 8 Dec 2016 21:19:23 -0500 Eric Floehr wrote: > I was wondering if anyone knows of any way in Python (functional or not), > or a module, that would allow the following: > > Let's say I have an n-dimensional array, with keys (numeric or otherwise) > for each dimension. I'd like to be able to set up and grab the elements in > any row in any dimension equally easily. > > Here's a simple example, a 2x2 contingency table, with rows labelled > "forecast" and "not forecast" and columns labelled "occurred" and "not > occurred". Within each of the 4 cells, there is some value. > > If I set it up traditionally, as a dict within the dict: > > table = {} > table['forecast'] = {'occurred': 0, 'not occurred': 0} > table['not forecast'] = {'occurred': 0, 'not occurred': 0} > > and access it traditionally: > > table['forecast']['occurred'] = 123 I've had similar issues eg when pulling data from persisted JSON documents. Transforming it into relational data has always worked out well. Row = namedtuple('Row', 'forecast occurred count') table = [ Row(True, True, 0), Row(True, False, 0), Row(False, True, 0), Row(False, False, 0), ] def select(**key_value): s = table[:] for key, value in key_value.items(): s = [ row for row in s if getattr(row, key) == value ] return s - Wrap the table list in a class. - Add insert, update, delete. Note that count is not a key column. - Use the standard library bisect.bisect_right to keep the rows sorted and speed up lookups and modifications. - The internal table array doesn't need to contain tuples, especially if the count column is updated frequently. Still nice to return or yield tuples for named, immutable key columns. - Add convenience methods for non-trivial queries. A little functional programming with the internal rows can accomplish a lot. Also consider SQL or your favorite ORM, possibly running with an in- memory DB. > The problems are: > > 1. Set up is hard... I have to duplicate keys, and in an n-dimensional > array, this is a real pain. > > 2. I always have to access a cell in the right order, and have to remember > that order. It would be great if I could access a cell in the example above > as table['forecast']['occurred'] or table['occurred']['forecast'] (syntax > doesn't matter, table('forecast', 'occurred') is fine too). > > 3. It's hard to slice... in a 2-dimensional array, it's easy to get the > cells in the outermost dict via table['forecast'].values() but how would I > just as easily (equivalently) get table['not occurred'].values()? > > Thoughts? Am I missing something obvious? Tuples as keys is valid syntax, but only addresses (1.): table['forecast', 'not occurred'] Maybe if you're really adventurous: table[frozenset(['not occurred', 'forecast'])] From erik.n.welch at gmail.com Fri Dec 9 02:53:35 2016 From: erik.n.welch at gmail.com (Erik Welch) Date: Fri, 9 Dec 2016 01:53:35 -0600 Subject: [CentralOH] N-dimensional array slicing/crosscutting In-Reply-To: <20161208234831.167c98ed133afb4c9e053608@columbus.rr.com> References: <20161208234831.167c98ed133afb4c9e053608@columbus.rr.com> Message-ID: Eric, I whipped up an example with four dimensions using xarray . Check it out: https://anaconda.org/eriknw/xarray-starting/notebook Nothing beats getting your hands dirty when learning, and I hope the above is enough to get you started. I think you may like xarray given the data sets that (I think) you work with. I like its spelling for simple operations, and advanced things are possible. It even supports out-of-core and parallel processing, which is great when data doesn't fit in memory--don't you have a few image files sitting around? ;-) btw, I think SQL, pandas, and pure Python data structures and functions are all great too. Good question and good responses! Cheers, Erik On Thu, Dec 8, 2016 at 10:48 PM, Neil Ludban wrote: > On Thu, 8 Dec 2016 21:19:23 -0500 > Eric Floehr wrote: > > I was wondering if anyone knows of any way in Python (functional or not), > > or a module, that would allow the following: > > > > Let's say I have an n-dimensional array, with keys (numeric or otherwise) > > for each dimension. I'd like to be able to set up and grab the elements > in > > any row in any dimension equally easily. > > > > Here's a simple example, a 2x2 contingency table, with rows labelled > > "forecast" and "not forecast" and columns labelled "occurred" and "not > > occurred". Within each of the 4 cells, there is some value. > > > > If I set it up traditionally, as a dict within the dict: > > > > table = {} > > table['forecast'] = {'occurred': 0, 'not occurred': 0} > > table['not forecast'] = {'occurred': 0, 'not occurred': 0} > > > > and access it traditionally: > > > > table['forecast']['occurred'] = 123 > > I've had similar issues eg when pulling data from persisted JSON > documents. Transforming it into relational data has always worked > out well. > > Row = namedtuple('Row', 'forecast occurred count') > table = [ > Row(True, True, 0), > Row(True, False, 0), > Row(False, True, 0), > Row(False, False, 0), > ] > > def select(**key_value): > s = table[:] > for key, value in key_value.items(): > s = [ row for row in s > if getattr(row, key) == value ] > return s > > - Wrap the table list in a class. > - Add insert, update, delete. Note that count is not a key column. > - Use the standard library bisect.bisect_right to keep the rows > sorted and speed up lookups and modifications. > - The internal table array doesn't need to contain tuples, especially > if the count column is updated frequently. Still nice to return or > yield tuples for named, immutable key columns. > - Add convenience methods for non-trivial queries. A little functional > programming with the internal rows can accomplish a lot. > > Also consider SQL or your favorite ORM, possibly running with an in- > memory DB. > > > > The problems are: > > > > 1. Set up is hard... I have to duplicate keys, and in an n-dimensional > > array, this is a real pain. > > > > 2. I always have to access a cell in the right order, and have to > remember > > that order. It would be great if I could access a cell in the example > above > > as table['forecast']['occurred'] or table['occurred']['forecast'] (syntax > > doesn't matter, table('forecast', 'occurred') is fine too). > > > > 3. It's hard to slice... in a 2-dimensional array, it's easy to get the > > cells in the outermost dict via table['forecast'].values() but how would > I > > just as easily (equivalently) get table['not occurred'].values()? > > > > Thoughts? Am I missing something obvious? > > Tuples as keys is valid syntax, but only addresses (1.): > > table['forecast', 'not occurred'] > > Maybe if you're really adventurous: > > table[frozenset(['not occurred', 'forecast'])] > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Fri Dec 9 20:38:07 2016 From: eric at intellovations.com (Eric Floehr) Date: Fri, 9 Dec 2016 20:38:07 -0500 Subject: [CentralOH] N-dimensional array slicing/crosscutting In-Reply-To: References: <20161208234831.167c98ed133afb4c9e053608@columbus.rr.com> Message-ID: Thanks Jim, Andrew, Erik, and Neil! I think that xarray looks to be the solution that matches most closely my needs. It looks to be really powerful and fairly easy to use. I'll definitely have to look at how it does out-of-core and parallel processing... that could definitely prove to be useful. Cheers, Eric On Fri, Dec 9, 2016 at 2:53 AM, Erik Welch wrote: > Eric, I whipped up an example with four dimensions using xarray > . Check it out: > > https://anaconda.org/eriknw/xarray-starting/notebook > > Nothing beats getting your hands dirty when learning, and I hope the above > is enough to get you started. I think you may like xarray given the data > sets that (I think) you work with. I like its spelling for simple > operations, and advanced things are possible. It even supports out-of-core > and parallel processing, which is great when data doesn't fit in > memory--don't you have a few image files sitting around? ;-) > > btw, I think SQL, pandas, and pure Python data structures and functions > are all great too. Good question and good responses! > > Cheers, > Erik > > On Thu, Dec 8, 2016 at 10:48 PM, Neil Ludban > wrote: > >> On Thu, 8 Dec 2016 21:19:23 -0500 >> Eric Floehr wrote: >> > I was wondering if anyone knows of any way in Python (functional or >> not), >> > or a module, that would allow the following: >> > >> > Let's say I have an n-dimensional array, with keys (numeric or >> otherwise) >> > for each dimension. I'd like to be able to set up and grab the elements >> in >> > any row in any dimension equally easily. >> > >> > Here's a simple example, a 2x2 contingency table, with rows labelled >> > "forecast" and "not forecast" and columns labelled "occurred" and "not >> > occurred". Within each of the 4 cells, there is some value. >> > >> > If I set it up traditionally, as a dict within the dict: >> > >> > table = {} >> > table['forecast'] = {'occurred': 0, 'not occurred': 0} >> > table['not forecast'] = {'occurred': 0, 'not occurred': 0} >> > >> > and access it traditionally: >> > >> > table['forecast']['occurred'] = 123 >> >> I've had similar issues eg when pulling data from persisted JSON >> documents. Transforming it into relational data has always worked >> out well. >> >> Row = namedtuple('Row', 'forecast occurred count') >> table = [ >> Row(True, True, 0), >> Row(True, False, 0), >> Row(False, True, 0), >> Row(False, False, 0), >> ] >> >> def select(**key_value): >> s = table[:] >> for key, value in key_value.items(): >> s = [ row for row in s >> if getattr(row, key) == value ] >> return s >> >> - Wrap the table list in a class. >> - Add insert, update, delete. Note that count is not a key column. >> - Use the standard library bisect.bisect_right to keep the rows >> sorted and speed up lookups and modifications. >> - The internal table array doesn't need to contain tuples, especially >> if the count column is updated frequently. Still nice to return or >> yield tuples for named, immutable key columns. >> - Add convenience methods for non-trivial queries. A little functional >> programming with the internal rows can accomplish a lot. >> >> Also consider SQL or your favorite ORM, possibly running with an in- >> memory DB. >> >> >> > The problems are: >> > >> > 1. Set up is hard... I have to duplicate keys, and in an n-dimensional >> > array, this is a real pain. >> > >> > 2. I always have to access a cell in the right order, and have to >> remember >> > that order. It would be great if I could access a cell in the example >> above >> > as table['forecast']['occurred'] or table['occurred']['forecast'] >> (syntax >> > doesn't matter, table('forecast', 'occurred') is fine too). >> > >> > 3. It's hard to slice... in a 2-dimensional array, it's easy to get the >> > cells in the outermost dict via table['forecast'].values() but how >> would I >> > just as easily (equivalently) get table['not occurred'].values()? >> > >> > Thoughts? Am I missing something obvious? >> >> Tuples as keys is valid syntax, but only addresses (1.): >> >> table['forecast', 'not occurred'] >> >> Maybe if you're really adventurous: >> >> table[frozenset(['not occurred', 'forecast'])] >> _______________________________________________ >> CentralOH mailing list >> CentralOH at python.org >> https://mail.python.org/mailman/listinfo/centraloh >> > > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Sun Dec 11 06:25:49 2016 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Sun, 11 Dec 2016 06:25:49 -0500 Subject: [CentralOH] =?utf-8?q?2016-12-09_=E9=81=93=E5=A0=B4_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz8gUGFydCBPbmU6IFB5dGhvbiAzLjY7IFByb2plY3Qg?= =?utf-8?q?Euler_Problem_=2312?= Message-ID: <20161211062549.51314b90.jep200404@columbus.rr.com> Python 3.6 has been released (almost) https://docs.python.org/3.6/whatsnew/3.6.html What other interesting techniques do you have for problem #12 from Project Euler? http://nbviewer.jupyter.org/github/james-prior/euler/blob/master/euler-012-highly-divisible-triangular-number-20161209.ipynb six folks tonight From pybokeh at gmail.com Sun Dec 11 13:54:08 2016 From: pybokeh at gmail.com (pybokeh) Date: Sun, 11 Dec 2016 13:54:08 -0500 Subject: [CentralOH] Integrating Spyre web app with Altair Viz framework help Message-ID: Hello everyone, please look at my github issue that I posted at the spyre repo: https://github.com/adamhajari/spyre/issues/64 I know the author of spyre has been busy of late, so I was hoping to get help here from those who are experienced in web development. spyre is a web application framework which allows Python developers to easily create dashboard apps without coding in html, css, and javascript. However, I am trying to output a plot which is generated using Altair visualization framework (see its github repo: https://github.com/altair-viz/altair) which is a javascript-based visualization library (it is awesome by the way!). If anyone can help me out with this, it would be much appreciated! I haven't been to the weekly DOJOs in a long time, so perhaps this would be my excuse to attend soon :-) Thanks, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From lenjaffe at jaffesystems.com Mon Dec 12 11:47:29 2016 From: lenjaffe at jaffesystems.com (Len Jaffe) Date: Mon, 12 Dec 2016 11:47:29 -0500 Subject: [CentralOH] Reminder: Columbus Tech Community Charity Drive Message-ID: A reminder, that in this season of giving, we're collecting goods to donate to Huckleberry House, to help at-risk youth in Central Ohio. Huckleberry House Charity Drive Because it?s the Season of Giving, we are holding a Goods Drive for Huckleberry House , a local organization that provides services to at-risk youth through their Crisis Shelter , Youth Outreach , Family Support , and Transitional Living Programs as part of our celebration in lieu of admission fees. We'll collect your donations at the party, and present them to Huckleberry House's Executive Director Becky Westerfelt, who will be on hand to tell us about the important work being done by the staff and volunteers of Huckleberry House. When asked for their highest priority items on their wish list, Becky told us "socks, hygiene products - including "boy" hygiene products, shampoo & conditioner including African American hair products, board/tabletop games, and the kinds of things you'd give as a housewarming gift - like toasters or tea towels" If you cannot attend the party, but wish to make give, contact me, and I'll arrange to pick up you donations. -- Len Jaffe - Information Technology Smoke Jumper - lenjaffe at jaffesystems.com 614-404-4214 @LenJaffe www.lenjaffe.com Host of Code Jam Columbus - @CodeJamCMH Curator of Advent Planet - An Aggregation of Online Advent Calendars. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jshaffstall at gmail.com Mon Dec 12 18:51:15 2016 From: jshaffstall at gmail.com (Jay Shaffstall) Date: Mon, 12 Dec 2016 18:51:15 -0500 Subject: [CentralOH] Python Physics Sandbox Message-ID: Hi all, I'd asked for some advice earlier packaging up a physics sandbox library intended to be used for intro programming students. I finished a first version of it and have it available to play with. The sandbox ended up having more features than I'd first planned, but I think they're all still pretty easy to use for intro students. And it'll be a lot more fun than the more limited physics simulation we've been using up until now. The source is here: https://github.com/jshaffstall/PyPhysicsSandbox And thanks to Andrew's advice a simple "pip install pyphysicssandbox" installs it and its dependencies so you can play with it. Jay -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Mon Dec 12 20:20:18 2016 From: eric at intellovations.com (Eric Floehr) Date: Mon, 12 Dec 2016 20:20:18 -0500 Subject: [CentralOH] Slack group for Techlife Columbus (including a Python channel) Message-ID: All, Techlife Columbus is the broader umbrella of the technical community in Columbus, and they now have a Slack group. There is a Python channel as well, and is great for quick discussions, etc. if you'd like. You can get your invite to the group here: http://techlife-columbus-slack.herokuapp.com/ Best Regards, Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: From jep200404 at columbus.rr.com Tue Dec 13 00:12:18 2016 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Tue, 13 Dec 2016 00:12:18 -0500 Subject: [CentralOH] =?utf-8?q?2016-12-09_=E9=81=93=E5=A0=B4_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz8gUHl0aG9uIDMuNjsgcHl0aG9uIGluIEM7IC0+IHB5?= =?utf-8?q?thon3=3B_data_min=7Ber=2Cing=7D=3B_euler_hackerrank_check=2Eio_?= =?utf-8?q?advent_of_code_challenges=2C_csv_excel_dialects=2C_virtual_envi?= =?utf-8?q?ronments=2C_=7Bana=2Cmini=7Dconda=3B_bashing_Bourne=2C_try=2Eju?= =?utf-8?q?pyter=2Eorg?= Message-ID: <20161213001218.3f97cbe2.jep200404@columbus.rr.com> From: jep200404 at columbus.rr.com To: centraloh at python.org Subject: 2016-12-09 ?? Scribbles ??/??? Part Three python in C; -> python3; data min{er,ing}; euler hackerrank check.io advent of code challenges, csv excel dialects, virtual environments, {ana,mini}conda; bashing Bourne, try.jupyter.org Date: Sat, 10 Dec 2016 17:27:48 -0500 X-Mailer: Netcat 0.99.1b (i686-pc-frabish-gnu) peanut butter and chocolate: How to embed Python code in C program http://xmodulo.com/embed-python-code-in-c.html Patent Trolls of Microsoft and Ericsson Are Trying to Tax Everything, Especially Linux Devices http://techrights.org/2016/12/04/taxing-everything-linux/ Microsoft?s Push for Software Patents Another Reminder That There is No ?New? Microsoft http://techrights.org/2016/12/05/no-new-microsoft-post-alice/ Transitioning to Python 3 http://www.linuxjournal.com/content/transitioning-python-3 FBI Gains New Hacking Powers While GOP Congress Sits on Sidelines https://www.districtsentinel.com/fbi-gains-new-hacking-powers-gop-congress-sits-sidelines/ More Examples of Microsoft and Its Patent Trolls Taxing Linux, Even After Microsoft ?Joined? (Paid) the Linux Foundation http://techrights.org/2016/12/06/microsoft-bundling-or-patent-lawsuit/ 7 cool little open source projects that stood out in 2016 https://opensource.com/16/12/yearbook-7-cool-little-projects Pa11y: Automated accessibility testing http://pa11y.org/ http://demo.pa11y.org/ https://en.wikipedia.org/wiki/Alliance_Data Python 3 Readiness http://py3readiness.org/ http://www.joyoftech.com/joyoftech/joyarchives/2359.html The Open Organization Leaders Manual??? https://github.com/opensourceway/open-org-leaders-manual/raw/master/open_org_leaders_manual_1_0.pdf https://github.com/opensourceway/open-org-leaders-manual 6 organizational growing pains you can avoid https://opensource.com/open-organization/16/12/6-pathologies-organizational-maturity if you do not have an itch to scratch, practice on: project euler hackerrank check.io advent of code challenges at https://github.com/cohpy how to automate the boring stuff with python csv module natively understands excel files with dialect='excel' and dialect='excel-tab' options. for almost any professional Python work, the use of virtual environments is pretty much mandatory virtualenv (py)venv conda linuxacademy videos live CDs/DVDs external DVD drive how to corrupt a DVD? how to corrupt a USB flash drive? start new projects in Python3 if you can anaconda miniconda allow one to install different versions of Python for each virtual environment with conda Portability is a good thing Bourne shell scripts are more portable than bash scripts Not every unix-like OS has bash C99 features in GCC on Fedora https://fedoramagazine.org/c99-features-gcc-fedora/ read one man page per day https://linux.die.net/man/ The wifi at Panera is very unreliable, so try.jupyter.org does not work well there. had someone from Yeller Springs https://en.wikipedia.org/wiki/Owenism Mills Park Hotel The "Community Room" was cold, so we met out in the open where it was warm. There was a notice taped over the thermostat saying that the heat did not work, that maintainance folks knew about it and would fix it. tightened legs of table in Community Room. 1/2" nuts used regular socket deep socket would have been better put finger nail polish on threads before tightening From jep200404 at columbus.rr.com Sat Dec 17 10:52:30 2016 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Sat, 17 Dec 2016 10:52:30 -0500 Subject: [CentralOH] =?utf-8?q?2016-12-16_=E9=81=93=E5=A0=B4_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz8gbGlzdCgpIHZlcnN1cyBbXTsgZ2l0aHViIGZhc3Qt?= =?utf-8?q?forward_merge=3B_scribus_pie_charts=3B_python_on_ios=3B_mapzen?= =?utf-8?q?=3B_pascal_favorite_language=3B_data_analysis=3B_batavia=3B_awe?= =?utf-8?q?some?= Message-ID: <20161217105230.67cc295c.jep200404@columbus.rr.com> 6 folks tonight Met out in the open again, because Community Room still did not have heat again. list() versus [] http://nbviewer.jupyter.org/github/james-prior/cohpy/blob/master/20161216-dojo-list-versus-square-brackets.ipynb some easier ways with python http://nbviewer.jupyter.org/github/james-prior/cohpy/blob/master/20161216-dojo-easier-way.ipynb (try again 2016-12-18 or 2016-12-19) Github does not do fast-forward for merges. https://help.github.com/articles/about-merge-methods-on-github/ One can do fast-forward merges by doing them on one's own machine, then pushing the merged commit up to github. learn how to use git on command line Python scripting in Scribus: Making pie charts https://opensource.com/article/16/12/python-scripting-scribus Some folks on this list might get it from a Yahoo account. http://fossforce.com/2016/12/another-yahoo-security-breach/ pythonista http://omz-software.com/pythonista/ https://mapzen.com/ https://github.com/mapzen write python api for mapzen There is a good section where he converts a Javaesque API to be Pythonic. Beyond PEP 8 -- Best practices for beautiful intelligible code http://pyvideo.org/pycon-us-2015/beyond-pep-8-best-practices-for-beautiful-inte.html Sweet! 20:00-40:20 context manager (__enter__, __exit__) to handle start up and tear down sequence class (__len__, __getitem__) to allow normal iteration @property syntactic sugah to convert attributes to function calls wp:Unix philosophy wp:The Unix Programming Environment wp:The Elements of Programming Style wp:The Elements of Style wp:The Practice of Programming wp:The C Programming Language Why Pascal is Not My Favorite Programming Language http://www.eah-jena.de/~kleine/history/languages/Kernighan-WhyPascalIsNotMyFavoriteProgrammingLanguage.pdf wp:UF https://en.wikipedia.org/wiki/Jupyter#Project_Jupyter Science And Python: retrospective of a (mostly) successful decade http://pyvideo.org/pycon-ca-2012/science-and-python-retrospective-of-a-mostly-s.html https://try.jupyter.org/ %%script numpy scipy matplotlib pandas for Python on MS Windows, miniconda or anaconda are almost mandatory using virtual environments are very stronly recommended for big python projects conda (use this for ms windows) virtualenv venv pyvenv map gdp flow through countries run Python on webpages instead of coding javascript Snakes in a Browser http://pyvideo.org/pyohio-2016/snakes-in-a-browser.html Batavia http://pybee.org/project/projects/bridges/batavia/ Hanukkah includes same day as Christmas this year. https://github.com/sindresorhus/awesome https://github.com/vinta/awesome-python From deeppunster at gmail.com Sun Dec 18 22:32:17 2016 From: deeppunster at gmail.com (Travis Risner) Date: Sun, 18 Dec 2016 22:32:17 -0500 Subject: [CentralOH] Awesome Lists Message-ID: <585754C1.4040908@gmail.com> Hi, I just ran across a list of "Awesome" Lists: https://github.com/sindresorhus/awesome. It has all the lists like "Awesome Python", "Awesome SQLAlchemy", "Awesome Django" and many more. Travis From jdsantiagojr at gmail.com Mon Dec 19 09:39:56 2016 From: jdsantiagojr at gmail.com (John Santiago) Date: Mon, 19 Dec 2016 09:39:56 -0500 Subject: [CentralOH] Awesome Lists In-Reply-To: <585754C1.4040908@gmail.com> References: <585754C1.4040908@gmail.com> Message-ID: Awesome! Thank you for the link! On Sun, Dec 18, 2016 at 10:32 PM, Travis Risner wrote: > Hi, > > I just ran across a list of "Awesome" Lists: > https://github.com/sindresorhus/awesome. It has all the lists like > "Awesome Python", "Awesome SQLAlchemy", "Awesome Django" and many more. > > Travis > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh > -- This electronic message is intended to be for the use only of the named recipient, and may contain information that is confidential or privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited. If you have received this message in error or are not the named recipient, please notify us immediately by contacting the sender at the electronic mail address noted above, and delete and destroy all copies of this message. Thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at intellovations.com Wed Dec 21 14:57:13 2016 From: eric at intellovations.com (Eric Floehr) Date: Wed, 21 Dec 2016 14:57:13 -0500 Subject: [CentralOH] Great Top 10 List of Python Libraries Message-ID: This is a great list of the Top 10 Python libraries: https://tryolabs.com/blog/2016/12/20/top-10-python-libraries-of-2016/ A few, like asyncpg, I hadn't heard about. I'm looking forward to trying it out as a replacement to psycopg2. Cheers, Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: From jocassid at gmail.com Fri Dec 23 15:04:56 2016 From: jocassid at gmail.com (John Cassidy) Date: Fri, 23 Dec 2016 15:04:56 -0500 Subject: [CentralOH] pytest and selenium Message-ID: I'm testing a website using selenium and pytest. I have some tests functions involving the various search features on the site. I also had a test where selenium accesses the sites login page and logs in. When running all tests in the module the login test would run first and the user would be logged in for the other tests. The problem is that if I try to run an individual test then the login doesn't take place. How would I handle something like logging in within the pytest framework? I'd like to avoid doing a login as part of every test and would still like to be able to run tests individually. I've thought of writing the login as a fixture. To log in I need the selenium webdriver which I've written a fixture for and the base url which I also have a fixture for. I'm not sure how to handle the fixture depending on other fixtures. Any thoughts? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jocassid at gmail.com Fri Dec 23 17:06:31 2016 From: jocassid at gmail.com (John Cassidy) Date: Fri, 23 Dec 2016 17:06:31 -0500 Subject: [CentralOH] pytest and selenium Message-ID: After I sent my email, I stumbled upon the answer to my question http://pythontesting.net/framework/pytest/pytest-fixtures-nuts-bolts/#modular has an example of fixtures depending on fixtures. I wound up with a loggedIn fixture that looks like this: @fixture(scope='module') def loggedIn(request, driver, baseUrl): driver.get(baseUrl + '/login.aspx') driver.find_element_by_id('username').send_keys('username') driver.find_element_by_id('password').send_keys('password') driver.find_element_by_id('loginButton').click() return "home" == driver.title driver and baseUrl are my existing fixtures. A typical test looks something like: def testSomething(driver, baseUrl, loggedIn): assert loggedIn # makes sure that login happened # other selenium commands and assert statements -------------- next part -------------- An HTML attachment was scrubbed... URL: From kedlav at gmail.com Fri Dec 23 15:51:52 2016 From: kedlav at gmail.com (Gmail) Date: Fri, 23 Dec 2016 15:51:52 -0500 Subject: [CentralOH] pytest and selenium In-Reply-To: References: Message-ID: I typically write a class extending whatever test class you have to create a client and login as part of init. The painful part of that is that each test you init will login, which is slow. A potential solution for that is to have a factory class that logs in once, then shares the session. This can be risky for testing of too much state is associated server side, as you may poison your test cases. Alternatively, use a good parallel test runner and make sure you don't crash production... :) Thanks, Max Morlocke Mobile: 216-407-1395 Google Voice: 512-461-8210 > On Dec 23, 2016, at 3:04 PM, John Cassidy wrote: > > I'm testing a website using selenium and pytest. I have some tests functions involving the various search features on the site. I also had a test where selenium accesses the sites login page and logs in. When running all tests in the module the login test would run first and the user would be logged in for the other tests. The problem is that if I try to run an individual test then the login doesn't take place. > > How would I handle something like logging in within the pytest framework? I'd like to avoid doing a login as part of every test and would still like to be able to run tests individually. > > I've thought of writing the login as a fixture. To log in I need the selenium webdriver which I've written a fixture for and the base url which I also have a fixture for. I'm not sure how to handle the fixture depending on other fixtures. > > Any thoughts? > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > https://mail.python.org/mailman/listinfo/centraloh From jep200404 at columbus.rr.com Sat Dec 24 13:59:53 2016 From: jep200404 at columbus.rr.com (jep200404 at columbus.rr.com) Date: Sat, 24 Dec 2016 13:59:53 -0500 Subject: [CentralOH] =?utf-8?q?2016-12-23_=E9=81=93=E5=A0=B4_Scribbles_?= =?utf-8?b?76SY5pu4L+aDoeaWhz8gY3Vyc2luZyByZWN1cnNpdmUgZmlib25hY2NpIGxy?= =?utf-8?q?u=5Fcache=3B_euler_18=3B_cjkv_ken_lunde=3B_live_DVDs=3B_virtual?= =?utf-8?q?ization=3B_instruction_sets=3B_writing_compilers=3B_coding_styl?= =?utf-8?q?e=3B_banishing_curly_braces_from_C_and_Java=3B_CPU_emulator=3B_?= =?utf-8?q?bit_twiddling=3B_print_dress=3B_v_R=3B_eclipse=3B_guis=3B_troll?= =?utf-8?q?s=3B_mr=2E_creosote?= Message-ID: <20161224135953.1490acbf.jep200404@columbus.rr.com> someone who did recursive fibonacci in school will get a laugh from: http://nbviewer.jupyter.org/url/colug.net/python/cohpy/20150223/cohpy-20150223-memoization.ipynb for real projects use lru_cache instead of memoize https://docs.python.org/3/library/functools.html#functools.lru_cache maxsize=None is nice option euler #18 redo with map(max, (zip([0]+m, m+[0]))) n = map(max, (zip([0]+m, m+[0]))) m = map(sum, zip(n, new_row)) wp:martin scorsese wp:George Harrison: Living in the Material World wp: prefix means Wikipedia To get good answers, consider following the advice in the links below. http://catb.org/~esr/faqs/smart-questions.html http://web.archive.org/web/20090627155454/www.greenend.org.uk/rjk/2000/06/14/quoting.html the definitive book for CJK: CJKV Information Processing By Ken Lunde wp:Hacking: The Art of Exploitation wp:Code: The Hidden Language of Computer Hardware and Software wp:Charles Petzold wp:Live CD wp:Knoppix wp:CentOS wp:Puppy Linux wp:Ubuntu (operating system) wp:Trinity Rescue Kit wp:Comparison_of_Linux_distributions#Live_media tomsrtbt wp:Hardware virtualization wp:Hardware-assisted virtualization wp:x86 virtualization wp:Parallels Desktop for Mac wp:Kernel-based Virtual Machine wp:QEMU good wp:PDP-11 architecture decent instruction set good addressing modes good orthogonality wp:NS320xx motorola 68000 (68k) decent arm ich intel see comment in Bloom County worst: microchip wp:restrictor plate racing compare to modern CPU's access to RAM compiler much easier to write in python than C wp:yacc https://pypi.python.org/pypi?%3Aaction=search&term=yacc&submit=search wp:lex https://pypi.python.org/pypi?%3Aaction=search&term=lex&submit=search significant linux distros to compare (that use Python) ubuntu (easy) centos (used to be serious?, fading glory?) debian mint (toy) https://www.kernel.org/doc/Documentation/CodingStyle Heretic people all over the world have claimed that this inconsistency is ... well ... inconsistent, but all right-thinking people know that (a) K&R are **right** and (b) K&R are right. Besides, functions are special anyway (you can't nest them in C). wp:Indent_Style#K.26R_style Of course, it would be better to avoid the stinking curly braces altogether. Take out all the curly braces from a C program. Write a program (in Python of course) that reads a C program that does not have curly braces, and outputs the same C program, with added curly braces depending on changes in indentation. put that in your Makefile to automate it wp:Make (software) wp:Off-side rule wp:Curly_bracket_programming_language#Curly-bracket_languages write a software emulator for something with a simple instruction set PDP-8? write it first in Python. then write it in C and Java. which is easiest to understand? which is easiest to write? what are C and Java versions good at? Is emulating I/O devices harder than emulating the instruction set? C: int x; int y; ... x ^= y; y ^= x; x ^= y; python: x, y = y, x C is a low level language Java is a medium level language Python is a high level language watch Beyond PEP 8 -- Best practices for beautiful intelligible code http://pyvideo.org/pycon-us-2015/beyond-pep-8-best-practices-for-beautiful-inte.html Using Blender and Python to 3D print a dress https://opensource.com/article/16/12/blender-python-3D-dress Python versus R for machine learning and data analysis https://opensource.com/article/16/11/python-vs-r-machine-learning-data-analysis How to use Python to hack your Eclipse IDE https://opensource.com/life/16/2/how-use-python-hack-your-ide Python vs. C/C++ in embedded systems https://opensource.com/life/16/8/python-vs-cc-embedded-systems 3 open source Python GUI frameworks https://opensource.com/life/16/5/open-source-python-gui-frameworks Supreme Court Will Hear A Case That Could Finally Shut Down East Texas As The Patent Troll Mecca https://www.techdirt.com/articles/20161215/00283936281/supreme-court-will-hear-case-that-could-finally-shut-down-east-texas-as-patent-troll-mecca.shtml?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed https://blog.pandorafms.org/network-tools/ How Linux got to be Linux: Test driving 1993-2003 distros https://opensource.com/article/16/12/yearbook-linux-test-driving-distros I wonder what Python was like then. Open education is about improving lives, not taking tests https://opensource.com/open-organization/16/12/make-sharing-rule-not-exception bit twiddling C #define LED_ON_MASK (1<<2) port |= LED_ON_MASK; port &= ~LED_ON_MASK; port ^= LED_ON_MASK; python LED_ON_MASK = (1<<2) port |= LED_ON_MASK port &= ~LED_ON_MASK port ^= LED_ON_MASK Remote Logging With Syslog, Part 4: Log Rotation https://www.linux.com/learn/remote-logging-syslog-part-1-basics https://www.linux.com/learn/sysadmin/remote-logging-syslog-part-2-main-config-file https://www.linux.com/learn/sysadmin/remote-logging-syslog-part-3-logfile-rules https://www.linux.com/learn/sysadmin/remote-logging-syslog-part-4-log-rotation Submiton./ucp.php?mode=login&return_to=%2Fservices%2Fx%2Fa.php%3Fpath%3D%2Finformation-technology%2F2016%2F12%2Fsignal-does-not-replace-pgp%2F%26s%3D1/services/x/a.php?path=%2Finformation-technology%2F2016%2F12%2Fsignal-does-not-replace-pgp%2F&s=1 Op-ed: Why I?m not giving up on PGP http://arstechnica.com/information-technology/2016/12/signal-does-not-replace-pgp/ wp:Mr Creosote Better keep a bucket nearby while reading the following code. doj at 4519_n_high:~/20161223$ cat hello.c #include #include int main(int argc, char *argv) { printf("hello world\n"); } doj at 4519_n_high:~/20161223$ cat hello.unbraced #include #include int main(int argc, char *argv) printf("hello world\n"); doj at 4519_n_high:~/20161223$ cat enbrace.py #!/usr/bin/env python3 import sys import re WHITESPACE_WIDTH = {' ': 1, '\t': 8} WHITESPACE = {' ', '\t'} def main(): old_indentation = 0 for i, line in enumerate(sys.stdin): new_indentation = 0 # Simplify following with len() of re stuff. # Better yet, expand to multiple of WHITESPACE_WIDTH column. for c in line: if c not in WHITESPACE: break new_indentation += 1 if new_indentation > old_indentation: print('{' * (new_indentation - old_indentation), end='') elif new_indentation < old_indentation: print('}' * (old_indentation - new_indentation), end='') # nasty: print( # nasty: '{' if new_indentation > old_indentation else '}' * # nasty: abs(new_indentation - old_indentation), end='') print(line, end='') old_indentation = new_indentation # print(i, new_indentation, line, end='') if old_indentation: print('}' * (old_indentation)) if __name__ == '__main__': main() doj at 4519_n_high:~/20161223$ ./enbrace.py #include int main(int argc, char *argv) {{{{ printf("hello world\n"); }}}} doj at 4519_n_high:~/20161223$ rm hello.braced doj at 4519_n_high:~/20161223$ make hello.braced cc hello.braced.c -o hello.braced doj at 4519_n_high:~/20161223$ ./hello.braced hello world doj at 4519_n_high:~/20161223$ The extra curly braces are rediculous, but cause no problem. Since the code with curly braces is just a temporary intermediate file that one would normally not read, the ugly placement of the curly braces does not matter. Write a better version of enbrace that sticks in fewest curly braces. Could it work for Java code also? just two folks tonight