Re: Red Black Tree implementation?

2013-05-06 Thread duncan smith
On 03/05/13 03:00, Dan Stromberg wrote: On Wed, May 1, 2013 at 7:06 PM, duncan smith mailto:buzzard@invalid.invalid>> wrote: I have an implementation that you can try out. It's not based on any other implementation, so my bugs will be independent of any bugs in the

Re: Red Black Tree implementation?

2013-05-07 Thread duncan smith
On 07/05/13 02:20, Dan Stromberg wrote: [snip] I'm starting to think Red Black Trees are pretty complex. A while ago I looked at a few different types of self-balancing binary tree. Most look much easier to implement. BTW, the licence might be MIT - I just copied it from someone else's

Re: Red Black Tree implementation?

2013-05-08 Thread duncan smith
On 07/05/13 02:20, Dan Stromberg wrote: On Mon, May 6, 2013 at 5:55 PM, duncan smith mailto:buzzard@invalid.invalid>> wrote: [snip] I'd prefer Apache or MIT or BSD 3-clause, but I could probably work with this. http://joinup.ec.europa.eu/community/eupl/news/licence-proliferat

Re: Red Black Tree implementation?

2013-05-08 Thread duncan smith
On 09/05/13 02:40, Dan Stromberg wrote: OK, I've got one copy of trees.py with md5 211f80c0fe7fb9cb42feb9645b4b3ffe. You seem to be saying I should have two though, but I don't know that I do... I've just re-sent it. Duncan -- http://mail.python.org/mailman/listinfo/python-list

Re: Red Black Tree implementation?

2013-05-09 Thread duncan smith
On 09/05/13 02:40, Dan Stromberg wrote: OK, I've got one copy of trees.py with md5 211f80c0fe7fb9cb42feb9645b4b3ffe. You seem to be saying I should have two though, but I don't know that I do... [snip] Yes, 211f80c0fe7fb9cb42feb9645b4b3ffe is the correct checksum for the latest version. The

Re: Red Black Tree implementation?

2013-05-11 Thread duncan smith
On 12/05/13 00:24, Dan Stromberg wrote: I'm afraid I'm having some trouble with the module. I've checked it into my SVN at http://stromberg.dnsalias.org/svn/red-black-tree-mod/trunk/duncan I have two versions of your tests in there now - "t" is minimally changed, and test-red_black_tree_mod is

Re: Red Black Tree implementation?

2013-05-11 Thread duncan smith
On 12/05/13 02:29, Dan Stromberg wrote: On Sat, May 11, 2013 at 4:24 PM, Dan Stromberg mailto:drsali...@gmail.com>> wrote: I'm afraid I'm having some trouble with the module. I've checked it into my SVN at http://stromberg.dnsalias.org/svn/red-black-tree-mod/trunk/duncan I ha

Re: Red Black Tree implementation?

2013-05-12 Thread duncan smith
On 12/05/13 03:02, duncan smith wrote: On 12/05/13 02:29, Dan Stromberg wrote: On Sat, May 11, 2013 at 4:24 PM, Dan Stromberg mailto:drsali...@gmail.com>> wrote: [snip] What should BinaryTree.find() do if it finds a data.node that is None? A call to "find(data)" should

Re: Ordered dictionaries compared

2013-05-23 Thread duncan smith
On 23/05/13 04:31, Dan Stromberg wrote: What kind of ordered dictionaries? Sorted by key. I've redone the previous comparison, this time with a better red-black tree implementation courtesy of Duncan G. Smith. The comparison is at http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-c

Re: Ordered dictionaries compared

2013-05-23 Thread duncan smith
On 23/05/13 18:44, Dan Stromberg wrote: On Thu, May 23, 2013 at 9:41 AM, duncan smith mailto:buzzard@invalid.invalid>> wrote: RBT is quicker than Treap for insertion with randomized data, but slower with ordered data. Randomized data will tend to minimize the number o

Re: Simple algorithm question - how to reorder a sequence economically

2013-05-24 Thread duncan smith
On 24/05/13 10:11, Chris Angelico wrote: On Fri, May 24, 2013 at 6:47 PM, Fábio Santos wrote: On 24 May 2013 09:41, "Chris Angelico" wrote: On Fri, May 24, 2013 at 6:14 PM, Peter Brooks wrote: What is the easiest way to reorder a sequence pseudo-randomly? That is, for a sequence 1,2,3,4

emded revision control in Python application?

2012-06-22 Thread duncan smith
Hello, I have an application that would benefit from collaborative working. Over time users construct a "data environment" which is a number of files in JSON format contained in a few directories (in the future I'll probably place these in a zip so the environment is contained within a s

Re: emded revision control in Python application?

2012-06-22 Thread duncan smith
On 22/06/12 17:42, Emile van Sebille wrote: On 6/22/2012 8:58 AM duncan smith said... Hello, I have an application that would benefit from collaborative working. Over time users construct a "data environment" which is a number of files in JSON format contained in a few directories

Re: emded revision control in Python application?

2012-06-22 Thread duncan smith
On 22/06/12 21:34, Emile van Sebille wrote: On 6/22/2012 11:19 AM duncan smith said... On 22/06/12 17:42, Emile van Sebille wrote: On 6/22/2012 8:58 AM duncan smith said... Hello, I have an application that would benefit from collaborative working. Over time users construct a "

Re: emded revision control in Python application?

2012-06-23 Thread duncan smith
On 23/06/12 06:45, rusi wrote: On Jun 22, 8:58 pm, duncan smith wrote: Hello, I have an application that would benefit from collaborative working. Over time users construct a "data environment" which is a number of files in JSON format contained in a few directories (in the f

Re: creating an artificial "last element" in sort list

2012-09-28 Thread duncan smith
On 29/09/12 00:51, dave wrote: more clearer, this is a more realistic use case: ['awefawef', 'awefawfsf', 'awefsdf', 'zz', 'zz', 'zz'] and the quantity of ''zz'' would be dynamic. Maybe, class Greatest: def __lt__(self, other): r

Re: Strange object identity problem

2012-11-12 Thread duncan smith
On 12/11/12 13:40, F.R. wrote: On 11/12/2012 02:27 PM, Robert Franke wrote: Hi Frederic, [...] bas = {} for year in range (2010, 2013): ba = st.runs ('BA', '%d-01-01' % year, '%d-12-31' % year) ba.run () print year, id (ba) bas [year] = ba 2010 150289932 2011 150835852 2012 1

Re: Exponential arrival distribution in Python

2012-11-29 Thread duncan smith
On 28/11/12 21:34, Ricky wrote: Hi all, I am doing a project on traffic simulation. I want to introduce exponential arrival distribution to precede this task. Therefore I want write a code in python for exponential arrival distribution. I am very new for programming and if anybody can help m

Re: String manipulation in python..NEED HELP!!!!

2012-12-11 Thread duncan smith
On 10/12/12 22:38, qbai...@ihets.org wrote: I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the new letter. i hav

Re: Probabilistic unit tests?

2013-01-11 Thread duncan smith
On 11/01/13 01:59, Nick Mellor wrote: Hi, I've got a unit test that will usually succeed but sometimes fails. An occasional failure is expected and fine. It's failing all the time I want to test for. What I want to test is "on average, there are the same number of males and females in a samp

Re: Probabilistic unit tests?

2013-01-12 Thread duncan smith
On 12/01/13 08:07, alex23 wrote: On 11 Jan, 13:34, Steven D'Aprano wrote: Well, that's not really a task for unit testing. Unit tests, like most tests, are well suited to deterministic tests, but not really to probabilistic testing. As far as I know, there aren't really any good frameworks for

Re: Iterate from 2nd element of a huge list

2012-01-31 Thread duncan smith
On 01/02/12 01:39, Paulo da Silva wrote: Hi! What is the best way to iterate thru a huge list having the 1st element a different process? I.e.: process1(mylist[0]) for el in mylist[1:]: process2(el) This way mylist is almost duplicated, isn't it? Thanks. Maybe (untested), it = iter

Re: Distribution

2012-03-20 Thread duncan smith
On 20/03/12 04:31, prince.pangeni wrote: Hi all, I am doing a simulation project using Python. In my project, I want to use some short of distribution to generate requests to a server. The request should have two distributions. One for request arrival rate (should be poisson) and another for

Re: Newbie, homework help, please.

2012-04-21 Thread duncan smith
On 21/04/12 23:48, BartC wrote: "someone" wrote in message news:9533449.630.1335042672358.JavaMail.geo-discussion-forums@ynmf4... On Saturday, April 21, 2012 3:44:49 PM UTC-5, BartC wrote: Hi, Bart: Thank you, your post is working now, maybe, I did something wrong, unfortunately, you are rig

Re: usenet reading

2012-05-26 Thread duncan smith
On 25/05/12 23:38, Jon Clements wrote: Hi All, Normally use Google Groups but it's becoming absolutely frustrating - not only has the interface changed to be frankly impractical, the posts are somewhat random of what appears, is posted and whatnot. (Ironically posted from GG) Is there a serve

sqlite INSERT performance

2012-05-30 Thread duncan smith
Hello, I have been attempting to speed up some code by using an sqlite database, but I'm not getting the performance gains I expected. The use case: I have text files containing data which may or may not include a header in the first line. Each line (other than the header) is a record,

Re: sqlite INSERT performance

2012-05-31 Thread duncan smith
On 31/05/12 06:15, John Nagle wrote: On 5/30/2012 6:57 PM, duncan smith wrote: Hello, I have been attempting to speed up some code by using an sqlite database, but I'm not getting the performance gains I expected. SQLite is a "lite" database. It's good for data that&

Re: sqlite INSERT performance

2012-05-31 Thread duncan smith
On 31/05/12 17:06, Jon Clements wrote: On Thursday, 31 May 2012 16:25:10 UTC+1, duncan smith wrote: On 31/05/12 06:15, John Nagle wrote: On 5/30/2012 6:57 PM, duncan smith wrote: Hello, I have been attempting to speed up some code by using an sqlite database, but I'm not gettin

Re: Wondering in the Python Forrest

2011-07-30 Thread duncan smith
Ken Watford wrote: On Sat, Jul 30, 2011 at 7:13 AM, ray wrote: I found that structured data could be presented in Python using a module in wxPython. Where am I? I do not know the relationships between the Pythons. I feel that I am missing something. I started with Python as it has so much f

Re: General Purpose Pipeline library?

2017-11-20 Thread duncan smith
On 20/11/17 15:48, Jason wrote: > a pipeline can be described as a sequence of functions that are applied to an > input with each subsequent function getting the output of the preceding > function: > > out = f6(f5(f4(f3(f2(f1(in)) > > However this isn't very readable and does not support co

Re: Problem with assignment. Python error or mine?

2017-12-21 Thread duncan smith
On 21/12/17 19:06, John Ladasky wrote: > On Thursday, December 21, 2017 at 7:37:39 AM UTC-8, MRAB wrote: > >> Python never makes a copy unless you ask it to. >> >> What x1=X does is make the name x1 refer to the same object that X >> refers to. No copying. > > Well, except with very simple, muta

Re: Speeding up the implementation of Stochastic Gradient Ascent in Python

2018-01-18 Thread duncan smith
On 17/01/18 14:29, leutrim.kal...@gmail.com wrote: > > Hello everyone, > > I am implementing a time-dependent Recommender System which applies BPR > (Bayesian Personalized Ranking), where Stochastic Gradient Ascent is used to > learn the parameters of the model. Such that, one iteration involv

Re: plot / graph connecting re ordered lists

2018-01-23 Thread duncan smith
On 23/01/18 23:42, Vincent Davis wrote: > On Tue, Jan 23, 2018 at 4:15 PM Dennis Lee Bieber > wrote: > >> On Tue, 23 Jan 2018 13:51:55 -0700, Vincent Davis >> declaimed the following: >> >>> Looking for suggestions. I have an ordered list of names these names will >>> be reordered. I am looking

Re: How do you debug in Python? Coming from a Matlab and R user. I'm already aware of pdb.

2021-01-27 Thread duncan smith
On 27/01/2021 22:41, C W wrote: > Great tutorial Irv, very simple with if-else example, gets the point > across. > > My main takeaway from the discussion so far is that: you can't troubleshoot > Python without some kind of breakpoint or debugger. > [snip] Really? Duncan -- https://mail.python

mutating a deque whilst iterating over it

2021-02-11 Thread duncan smith
Hello, It seems that I can mutate a deque while iterating over it if I assign to an index, but not if I append to it. Is this the intended behaviour? It seems a bit inconsistent. Cheers. Duncan >>> from collections import deque >>> d = deque(range(8)) >>> it = iter(d) >>> next(it) 0 >>> d[1

Re: mutating a deque whilst iterating over it

2021-02-13 Thread duncan smith
On 12/02/2021 03:04, Terry Reedy wrote: > On 2/11/2021 3:22 PM, duncan smith wrote: > >>    It seems that I can mutate a deque while iterating over it if I >> assign to an index, but not if I append to it. Is this the intended >> behaviour? > > Does the deque d

Re: mutating a deque whilst iterating over it

2021-02-14 Thread duncan smith
On 13/02/2021 19:12, Dan Stromberg wrote: > On Sat, Feb 13, 2021 at 10:25 AM duncan smith > wrote: > >> On 12/02/2021 03:04, Terry Reedy wrote: >>> On 2/11/2021 3:22 PM, duncan smith wrote: >>> >>>>It seems that I can mutate a deque while i

Re: Comparing sequences with range objects

2022-04-08 Thread duncan smith
On 08/04/2022 08:21, Antoon Pardon wrote: Op 8/04/2022 om 08:24 schreef Peter J. Holzer: On 2022-04-07 17:16:41 +0200, Antoon Pardon wrote: Op 7/04/2022 om 16:08 schreef Joel Goldstick: On Thu, Apr 7, 2022 at 7:19 AM Antoon Pardon wrote: I am working with a list of data from which I have t

Re: Comparing sequences with range objects

2022-04-09 Thread duncan smith
On 08/04/2022 22:08, Antoon Pardon wrote: Op 8/04/2022 om 16:28 schreef duncan smith: On 08/04/2022 08:21, Antoon Pardon wrote: Yes I know all that. That is why I keep a bucket of possible duplicates per "identifying" field that is examined and use some heuristics at the end

Re: Comparing sequences with range objects

2022-04-10 Thread duncan smith
On 10/04/2022 21:20, Antoon Pardon wrote: Op 9/04/2022 om 02:01 schreef duncan smith: On 08/04/2022 22:08, Antoon Pardon wrote: Well my first thought is that a bitset makes it less obvious to calulate the size of the set or to iterate over its elements. But it is an idea worth exploring

Re: How to pick out the same titles.

2016-10-16 Thread duncan smith
On 16/10/16 16:16, Seymore4Head wrote: > How to pick out the same titles. > > I have a long text file that has movie titles in it and I would like > to find dupes. > > The thing is that sometimes I have one called "The Killing Fields" and > it also could be listed as "Killing Fields" Sometimes

retain dimensions for numpy slice

2016-10-24 Thread duncan smith
Hello, I have several arrays that I need to combine elementwise in various fashions. They are basically probability tables and there is a mapping of axes to variables. I have code for transposing and reshaping that aligns the variables / axes so the usual broadcasting rules achieve the desire

Re: retain dimensions for numpy slice

2016-10-24 Thread duncan smith
On 24/10/16 19:05, Peter Otten wrote: > duncan smith wrote: > >> Hello, >> I have several arrays that I need to combine elementwise in >> various fashions. They are basically probability tables and there is a >> mapping of axes to variables. I have code for tra

Re: need some kind of "coherence index" for a group of strings

2016-11-04 Thread duncan smith
On 03/11/16 16:18, Fillmore wrote: > > Hi there, apologies for the generic question. Here is my problem let's > say that I have a list of lists of strings. > > list1:#strings are sort of similar to one another > > my_nice_string_blabla > my_nice_string_blqbli > my_nice_string_bl0bla >

OSError: [Errno 12] Cannot allocate memory

2016-11-30 Thread duncan smith
Hello, I have had an issue with some code for a while now, and I have not been able to solve it. I use the subprocess module to invoke dot (Graphviz) to generate a file. But if I do this repeatedly I end up with an error. The following traceback is from a larger application, but it appears to

Re: OSError: [Errno 12] Cannot allocate memory

2016-11-30 Thread duncan smith
[snip] Sorry, should have said Python 2.7.12 on Ubuntu 16.04. Duncan -- https://mail.python.org/mailman/listinfo/python-list

Re: OSError: [Errno 12] Cannot allocate memory

2016-11-30 Thread duncan smith
On 30/11/16 17:57, Chris Angelico wrote: > On Thu, Dec 1, 2016 at 4:34 AM, duncan smith wrote: >> >> def _execute(command): >> # shell=True security hazard? >> p = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, >>

Re: OSError: [Errno 12] Cannot allocate memory

2016-11-30 Thread duncan smith
On 30/11/16 17:53, Chris Kaynor wrote: > On Wed, Nov 30, 2016 at 9:34 AM, duncan smith wrote: >> Hello, >> I have had an issue with some code for a while now, and I have not >> been able to solve it. I use the subprocess module to invoke dot >> (Graphviz) to g

Re: OSError: [Errno 12] Cannot allocate memory

2016-11-30 Thread duncan smith
On 01/12/16 00:46, Chris Kaynor wrote: > On Wed, Nov 30, 2016 at 4:12 PM, duncan smith wrote: >> On 30/11/16 17:57, Chris Angelico wrote: >>> On Thu, Dec 1, 2016 at 4:34 AM, duncan smith wrote: >>>> >>>> def _execute(command): >>>> # she

Re: OSError: [Errno 12] Cannot allocate memory

2016-12-01 Thread duncan smith
On 01/12/16 01:12, Chris Kaynor wrote: > On Wed, Nov 30, 2016 at 4:54 PM, duncan smith wrote: >> >> Thanks. So something like the following might do the job? >> >> def _execute(command): >> p = subprocess.Popen(command, shell=False, >>

Re: geopandas bug ?

2017-01-14 Thread duncan smith
On 14/01/17 11:18, Xristos Xristoou wrote: > i want to create a simple spatial joing using geopandas but i thing so > geopandas has bug ? > > > > geopandas code : > > from geopandas import gpd > import geopandas > points = geopandas.GeoDataFrame.from_file('points.shp') # or geojson etc > poly

Re: geopandas bug ?

2017-01-14 Thread duncan smith
On 14/01/17 14:59, Xristos Xristoou wrote: > Τη Σάββατο, 14 Ιανουαρίου 2017 - 4:38:39 μ.μ. UTC+2, ο χρήστης duncan smith > έγραψε: >> On 14/01/17 11:18, Xristos Xristoou wrote: >>> i want to create a simple spatial joing using geopandas but i thing so

Re: Treatment of NANs in the statistics module

2018-03-17 Thread duncan smith
On 16/03/18 23:16, Steven D'Aprano wrote: > The bug tracker currently has a discussion of a bug in the median(), > median_low() and median_high() functions that they wrongly compute the > medians in the face of NANs in the data: > > https://bugs.python.org/issue33084 > > I would like to ask peo

Re: Instance variables question

2018-04-16 Thread duncan smith
On 16/04/18 17:03, Irv Kalb wrote: > I have been writing OOP code for many years in other languages and for the > past few years in Python. I am writing new curriculum for a course on OOP in > Python. In order to see how others are explaining OOP concepts, I have been > reading as many books a

plotly / dash export data

2018-06-09 Thread duncan smith
Hello, I have been trying to work out how to export data from a dash application. I know little about html or javascript. I can upload data into a table as per the example at https://github.com/plotly/dash-core-components/pull/73. I can edit the data in the table. But I can't find a way of ex

Re: Help Needed : script weird result.

2018-09-01 Thread duncan smith
On 01/09/18 18:11, moha...@gmail.com wrote: > All, > > I m trying to run this small script to find the lowest of the given array of > numbers. The script works fine for various combination of inputs but fails in > a weird way for a particular set of inputs, can anyone point the mistake in > the

numpy use cases for where and out

2018-09-11 Thread duncan smith
Hello, I'm writing some code for sparse arrays that is intended to pretty much follow the numpy API. Because my arrays can have different default values there is an issue with using the 'out' keyword argument for functions. e.g. If I elementwise multiply 2 arrays with defaults a and b, then t

Re: Why do integers compare equal to booleans?

2018-11-16 Thread duncan smith
On 16/11/18 14:51, Steve Keller wrote: > Why do the integers 0 and 1 compare equal to the boolean values False > and True and all other integers to neither of them? > > $ python3 > Python 3.5.2 (default, Nov 12 2018, 13:43:14) > [GCC 5.4.0 20160609] on linux > Type "help", "copyrig

Injecting methods into instance / class

2018-12-02 Thread duncan smith
Hello, I have a lot of functions that take an instance of a particular class as the first argument. I want to create corresponding methods in the class. I have tried the following, which (when called from __init__) creates the relevant methods in an instance (Python 3.6). def init_methods(s

Re: Injecting methods into instance / class

2018-12-02 Thread duncan smith
On 02/12/2018 18:26, Stefan Ram wrote: > duncan smith writes: >> I have tried to find examples of injecting methods into classes without > > Wouldn't the normal approach be to just define a > class with your functions as instance methods? > > main.py >

Re: Injecting methods into instance / class

2018-12-02 Thread duncan smith
On 02/12/2018 18:36, Peter Otten wrote: > duncan smith wrote: > >> Hello, >> I have a lot of functions that take an instance of a particular >> class as the first argument. I want to create corresponding methods in >> the class. I have tried the following, wh

sampling from frequency distribution / histogram without replacement

2019-01-14 Thread duncan smith
Hello, Just checking to see if anyone has attacked this problem before for cases where the population size is unfeasibly large. i.e. The number of categories is manageable, but the sum of the frequencies, N, precludes simple solutions such as creating a list, shuffling it and using the first

Re: sampling from frequency distribution / histogram without replacement

2019-01-14 Thread duncan smith
On 14/01/2019 22:59, Gregory Ewing wrote: > duncan smith wrote: >> Hello, >>   Just checking to see if anyone has attacked this problem before >> for cases where the population size is unfeasibly large. > > The fastest way I know of is to create a list of cum

Re: sampling from frequency distribution / histogram without replacement

2019-01-15 Thread duncan smith
On 15/01/2019 02:41, Spencer Graves wrote: > > > On 2019-01-14 18:40, duncan smith wrote: >> On 14/01/2019 22:59, Gregory Ewing wrote: >>> duncan smith wrote: >>>> Hello, >>>>    Just checking to see if anyone has attacked this problem be

Re: sampling from frequency distribution / histogram without replacement

2019-01-15 Thread duncan smith
On 15/01/2019 17:59, Ian Hobson wrote: > Hi, > > If I understand your problem you can do it in two passes through the > population. > The thing is that I start with the population histogram and I want to generate a sample histogram. The population itself is too large to deal with each population

Re: sampling from frequency distribution / histogram without replacement

2019-01-18 Thread duncan smith
On 14/01/2019 20:11, duncan smith wrote: > Hello, > Just checking to see if anyone has attacked this problem before > for cases where the population size is unfeasibly large. i.e. The number > of categories is manageable, but the sum of the frequencies, N, > precludes simple

in a pickle

2019-03-06 Thread duncan smith
Hello, I've been trying to figure out why one of my classes can be pickled but not unpickled. (I realise the problem is probably with the pickling, but I get the error when I attempt to unpickle.) A relatively minimal example is pasted below. >>> import pickle >>> class test(dict):

Re: in a pickle

2019-03-06 Thread duncan smith
[snip] Sorry, this is Python 3.6 on Linux. Duncan -- https://mail.python.org/mailman/listinfo/python-list

Re: in a pickle

2019-03-06 Thread duncan smith
On 06/03/2019 16:14, duncan smith wrote: > Hello, > I've been trying to figure out why one of my classes can be > pickled but not unpickled. (I realise the problem is probably with the > pickling, but I get the error when I attempt to unpickle.) > > A relatively mi

Re: in a pickle

2019-03-06 Thread duncan smith
On 06/03/2019 20:24, Peter Otten wrote: > duncan smith wrote: > >> On 06/03/2019 16:14, duncan smith wrote: >>> Hello, >>> I've been trying to figure out why one of my classes can be >>> pickled but not unpickled. (I realise the problem is probabl

Re: in a pickle

2019-03-06 Thread duncan smith
On 07/03/2019 00:18, Ethan Furman wrote: > On 03/06/2019 10:30 AM, duncan smith wrote: > >>  I've been trying to figure out why one of my classes can be >> pickled but not unpickled. (I realise the problem is probably with the >> pickling, but I get the error when I

Re: doctest random output?

2019-04-17 Thread duncan smith
On 28/08/2017 20:17, Leam Hall wrote: > On 08/28/2017 11:40 AM, Dennis Lee Bieber wrote: > > ... a bunch of good stuff ... > > I'm (re-)learning python and just trying make sure my function works. > Not at the statistical or cryptographic level.   :) > > Thanks! > > Leam If it's supposed to ge

Re: Import module from a different subdirectory

2019-05-16 Thread duncan smith
On 16/05/2019 22:50, Rich Shepard wrote: > I'm developing a Python3 application using Python3-3.7.3 and > virtualenv-16.5.0 on a Slackware-14.2 host. > > The project directory contains subdirectories, including gui/ (with the > tkinter views) and classes/ with the SQLAlchemy model.py. > > Within

duck typing / library functions

2019-09-12 Thread duncan smith
Hello, The problem I have relates to writing algorithmic code that can handle types with a given API, but where some of the required functionality is implemented as library functions rather than methods. Specifically I have code that uses numpy arrays, but I want to adapt it to use sparse arr

Re: Instantiating sub-class from super

2019-10-15 Thread duncan smith
On 15/10/2019 21:36, DL Neil wrote: > On 16/10/19 12:38 AM, Rhodri James wrote: >> On 14/10/2019 21:55, DL Neil via Python-list wrote: > ... > >>> It seemed better (at the design-level) to have Man( Person ) and >>> Woman( Person ) sub-classes to contain the pertinent attributes, >>> source more d

Re: Instantiating sub-class from super

2019-10-16 Thread duncan smith
On 16/10/2019 04:41, DL Neil wrote: > On 16/10/19 1:55 PM, duncan smith wrote: >> On 15/10/2019 21:36, DL Neil wrote: >>> On 16/10/19 12:38 AM, Rhodri James wrote: >>>> On 14/10/2019 21:55, DL Neil via Python-list wrote: >>> ... >>> So, yes, the &q

Re: Instantiating sub-class from super

2019-10-16 Thread duncan smith
On 16/10/2019 19:52, MRAB wrote: > On 2019-10-16 19:43, duncan smith wrote: >> On 16/10/2019 04:41, DL Neil wrote: >>> On 16/10/19 1:55 PM, duncan smith wrote: >>>> On 15/10/2019 21:36, DL Neil wrote: >>>>> On 16/10/19 12:38 AM, Rhodri James wrote: &

Re: Instantiating sub-class from super

2019-10-19 Thread duncan smith
On 18/10/2019 23:57, DL Neil wrote: > On 17/10/19 7:52 AM, MRAB wrote: >> On 2019-10-16 19:43, duncan smith wrote: >>> On 16/10/2019 04:41, DL Neil wrote: >>>> On 16/10/19 1:55 PM, duncan smith wrote: >>>>> On 15/10/2019 21:36, DL Neil wrote: &g

Re: stuck on time

2019-12-08 Thread duncan smith
On 07/12/2019 17:48, RobH wrote: > I am trying to do this project on a pi zero: > > http://frederickvandenbosch.be/?p=1365 > > After overcoming a few errors, I now have the display working and the > start of the code showing on the display, that being the time. > > It doesn't move on to the next

distinguishable matplotlib colours / symbols / line styles

2019-12-16 Thread duncan smith
Hello, Not really specific to Python or matplotlib (but that's what I'm using). I'm looking for a good combination of colours and symbols for scatter plots, and combination of colours and line styles for line plots. Too often I find myself producing these when I don't know whether they will e

Re: distinguishable matplotlib colours / symbols / line styles

2019-12-16 Thread duncan smith
On 16/12/2019 21:08, DL Neil wrote: > On 17/12/19 5:19 am, Chris Angelico wrote: >> On Tue, Dec 17, 2019 at 3:16 AM duncan smith >> wrote: >>> >>> Hello, >>>    Not really specific to Python or matplotlib (but that's what I'm >>&

Re: What I learned today

2020-02-14 Thread duncan smith
On 14/02/2020 23:21, Dan Stromberg wrote: > On Fri, Feb 14, 2020 at 3:10 PM Stefan Ram wrote: > >> By trial and error (never read documentation!) I found >> that you can count the number of e's in a text by just >> >> Counter( text ).get( 'e' ) >> >> (after »from collections import Counter«

queue versus list

2020-03-19 Thread duncan smith
Hello, I have generator code along the following lines, Q = queue.Queue() Q.put(x) while not Q.empty(): x = Q.get() if : yield x else: Q.put() If I change it to, Q = [] Q.append(x) for x in Q: if : yield x else: Q.append() then it runs a

Re: queue versus list

2020-03-19 Thread duncan smith
On 19/03/2020 20:40, MRAB wrote: > On 2020-03-19 20:08, duncan smith wrote: >> Hello, >>    I have generator code along the following lines, >> >> >> Q = queue.Queue() >> Q.put(x) >> while not Q.empty(): >> x = Q.get() >>   

Re: queue versus list

2020-03-20 Thread duncan smith
On 20/03/2020 21:57, Barry wrote: > > >> On 20 Mar 2020, at 00:42, duncan smith wrote: >> >> Bingo. Performance is indistinguishable from that of the list. Thread >> safety is unimportant (for my purposes), but the docs at >> https://docs.python.org/2/librar

inheriting from long on Python2 or int on Python3

2020-03-21 Thread duncan smith
Hello, I have a class I wrote for Python2 that needs to be made to work on Python3. On Python2 it inherited from long, so it needs to inherit from int on Python3. The following works, but I'm not sure it's the cleanest solution. It's the first time I've wanted / needed to make a parent class

Re: inheriting from long on Python2 or int on Python3

2020-03-21 Thread duncan smith
On 21/03/2020 21:55, Skip Montanaro wrote: >> import sys >> >> class C_hash(int if sys.version_info.major >= 3 else long): > ... > > There's nothing incorrect with your solution. Chris offered another. I > was going to suggest you consider running your code through 2to3 to > see what it does. I cr

Re: Confused about np.polyfit()

2020-07-19 Thread duncan smith
On 19/07/2020 11:19, Dino wrote: > > Hi, I am looking at someone else's code trying to understand their use > of numpy.polyfit. > > My understanding was that you can use it to fit polynomials, but > apparently, the original author has used it for logarithmic and > exponential curves as well this

Re: Confused about np.polyfit()

2020-07-19 Thread duncan smith
On 19/07/2020 16:11, Dino wrote: > On 7/19/2020 4:54 PM, duncan smith wrote: >> >> It depends on what you expect the result to be. There's nothing >> inherently wrong with transforming variables before using least squares >> fitting. Whether it gives you the "

Re: Find word by given characters

2020-11-01 Thread duncan smith
On 01/11/2020 13:38, Bischoop wrote: > On 2020-11-01, Bischoop wrote: >> I'm working on a script i which user inputs letters and then a printed >> words containing those letters. The scripts works however I can't solve >> one problem , it prints also words in which these letters occur more >> tha

Re: Find word by given characters

2020-11-02 Thread duncan smith
On 02/11/2020 19:09, dn wrote: > On 02/11/2020 23:29, Bischoop wrote: >> On 2020-11-01, duncan smith wrote: >>>> >>> >>> But this generates the letters counts for each word. They only need to >>> be generated once (outside the for loop). And usi

Re: Find word by given characters

2020-11-03 Thread duncan smith
On 03/11/2020 14:06, Bischoop wrote: > On 2020-11-03, dn wrote: >> >> >> The (full) specs are not clear. There's certainly room for >> misunderstanding. I'd be happier if I could 'see' a full spec or >> recognise a practical application, because then we'd be better able to >> discuss facts. Mea

Re: Find word by given characters

2020-11-03 Thread duncan smith
On 03/11/2020 23:35, Bischoop wrote: > On 2020-11-03, duncan smith wrote: >>> >> >>>>> from collections import Counter >>>>> letters = 'att' >>>>> letter_counts = Counter(letters) >>>>> word = 'tolerate

Re: Find word by given characters

2020-11-03 Thread duncan smith
On 03/11/2020 22:14, Avi Gross wrote: > I, too, have wondered what exactly the point was of the required > functionality for SCRABBLE but note you can extend a current word so > additional letters may be available in a game but only if they are an exact > fit to put before, after, or in middle of y

Re: Find word by given characters

2020-11-04 Thread duncan smith
On 04/11/2020 04:21, Avi Gross wrote: > Duncan, my comments below yours at end. > > ---YOURS--- > The Counter approach only requires iterating over the letters once to > construct the letters bag, then each word once to create the relevant word > bag. After that it's (at worst) a couple of lookups

Re: Find word by given characters

2020-11-04 Thread duncan smith
On 04/11/2020 19:12, Avi Gross wrote: > My comments at end: > > -Original Message- > From: Python-list On > Behalf Of duncan smith > Sent: Wednesday, November 4, 2020 1:09 PM > To: python-list@python.org > Subject: Re: Find word by given characters > >

Re: When someone from Britain speaks, Americans hear a "Britishaccent"...

2005-10-07 Thread Duncan Smith
Rocco Moretti wrote: > Steve Holden wrote: > >>> On Fri, 07 Oct 2005 00:33:43 -, Grant Edwards <[EMAIL PROTECTED]> >>> wrote: > > For example: In British English one uses a plural verb when the subject consists of more than one person. Sports teams, government departments, st

Re: When someone from Britain speaks, Americans hear a "Britishaccent"...

2005-10-08 Thread Duncan Smith
Steve Holden wrote: > Duncan Smith wrote: > >> Rocco Moretti wrote: > > [...] > >> >> So English is spoken only in the South East of England, except London? >> I think you should also disbar the queen (unless she's already >> classified as a Lo

Re: compare list

2005-11-14 Thread Duncan Smith
Brian van den Broek wrote: > Ben Bush said unto the world upon 2005-11-14 05:51: > >> I have four lists: >> lisA=[1,2,3,4,5,6,9] >> lisB=[1,6,5] >> lisC=[5,6,3] >> lisD=[11,14,12,15] >> how can I write a function to compare lisB, lisC and lisD with lisA, >> if they >> share two continuous elements

Re: all possible combinations

2005-07-13 Thread Duncan Smith
rbt wrote: > On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: > >>Say I have a list that has 3 letters in it: >> >>['a', 'b', 'c'] >> >>I want to print all the possible 4 digit combinations of those 3 >>letters: >> >>4^3 = 64 >> >> >>abaa >>aaba >>aaab >>acaa >>aaca >>aaac >>... >> >>What is the

  1   2   3   >