Figuring out what dependencies are needed

2013-12-11 Thread sal
I'm a Python beginner.  I want to use it for stats work, so I downloaded 
Anaconda which has several of the popular libraries already packaged for Mac OS 
X.

Now I'd like to use the backtesting package from zipline (zipline.io), but 
while running the test script in iPython, I receive the following error:

AssertionErrorTraceback (most recent call last)
 in ()
> 1 data = load_from_yahoo()
  2 dma = DualMovingAverage()
  3 results = dma.run(data)

1)  I assume that I'm missing some packages that aren't included in Anaconda, 
but how do I know which ones to upload?

2)  Often I'll just unzip a library file and put the main folder in the iPython 
folder, but I notice there's usually a setup.py file in the main library 
folder.  I've been ignoring this.  Should I be using it?

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Newbie: unsigned shift right

2008-03-26 Thread Sal
Is there any way to do an unsigned shift right in Python? When I enter
(-1>>1) the answer is -1. What I'm looking for is the equivalent of an
unsigned shift in C or the ">>>" operator in Java.
-- 
http://mail.python.org/mailman/listinfo/python-list


Remove old version before upgrade?

2008-04-24 Thread Sal
I'm currently running Windows version 2.5.1 and would like to upgrade
to 2.5.2. My question is, can I just go ahead and install the new
version over the old or should I remove the old version with add/
remove programs first? The old version is in a directory named
Python25.
--
http://mail.python.org/mailman/listinfo/python-list


Re: The end to all language wars and the great unity API to come!

2011-07-05 Thread sal migondis
On Jul 4, 10:31 pm, alex23  wrote:
> rantingrick  wrote:
> > I believe (unlike most people) that nature is striving for perfection
>
> Your belief is wrong. "Nature" doesn't "strive" for _anything_. Things
> in the world are either fit enough to continue their existence or not.
> As circumstances change, some things that were once suitably fit for
> the environment are no longer so and are replaced. Same with ideas.
> There is no "perfection", there is only "what works best now".

How could a belief be wrong?

> > What do you think will be the eventual outcome of the human existence
> > Alex? Since you have no imagination i will tell you, a singular
> > intelligence.

All from the land of creationism.

> Firstly: cite some kind of evidence that this "will be the eventual
> outcome" or admit you're talking shit.
>
> Secondly: I can imagine humanity evolving into a great many things and
> something as limited as a 'botnet' is certainly nothing to be proud of
> as a species.
>
> > It is selflessness on a grand scale.
>
> I don't really know if you're a troll,

Beats me... I think everybody else does..

> have no self-reflective
> capability, delusionally believe what you're spouting, or are on or
> off medication, but sometimes your hypocrisy is just funny as hell.
>
> >> Because the people who ACTUALLY WROTE THE LANGUAGES wanted to explore
> >> different implementations.
> > Why can they not explore within the hive mind? Why must they hide
> > their explorations from the greater group. SELFISHNESS
>
> You mean like how Guido hid the Python code base and never let anyone
> else touch or influence it in any way?
>
> Rick, you remind me a lot of Bill Hicks yelling, "You are free to do
> as we tell you! YOU ARE FREE TO DO AS WE TELL YOU!!" Using terms like
> "hive mind" kinda shows that I'm wasting my time pushing the value of
> diversity to you.

Now you're taking a troll as an excuse for your own trolling.



> No need to answer that last one, we already know the answer: from the
> very beginning.

In the beginning was a singularity... and Albert Einstein was a chain-
smoker.

Sal.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The end to all language wars and the great unity API to come!

2011-07-08 Thread sal migondis
On Jul 6, 7:45 am, Steven D'Aprano  wrote:
> sal migondis wrote:

> > How could a belief be wrong?

> I believe...

Shifting from 'belief' to 'believe', the latter having a considerably
wider semantic scope.

After that, anything goes.. naturally.

> you are a small glass of beer. Are you *actually* a small glass of
> beer in reality? If so, my belief is right. If you are a human being, then
> my belief is wrong.

Are you a lawyer..?

Sal.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE/text-editor

2011-04-17 Thread sal migondis
On Apr 17, 7:09 am, Ben Finney  wrote:
> Alec Taylor  writes:

[..]

> > whereas nano, and all the text-editors/IDEs above are user-friendly.

No they're not 'user-friendly'. They are a user's worst enemy.
What's
the point of a computer if all you can come up with is a typewriter
in
disguise? Back to the dark ages. I have not tried all of the above,
but
a quick peek at nano & imagining I would having to use it for
anything
beyond _entering_ text and crossing fingers I ever need to change
a single comma or fix a single typo sends shivers down my spine.

> As many others in this thread have said, the learning curve pays off

[..]

Ben, I agree wholeheartedly with the rest of your post, but in the
case
of Vi/Vim... what learning curve..? It takes an hour at most to do
the
Vim tutorial. Do it, say 3 times and read Bram Moolenaar's 'Seven
habits of effective editing' twice and within one week you are
already
editing (much) more efficiently and with a lot less frustration than
with
those supposedly 'user-friendly' editors. And contrary to Notepad and
its descendants your editing experience will keep improving. Now that
is the difference between a _real_ friend a passing acquaintance.

Sal.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: English Idiom in Unix: Directory Recursively

2011-05-26 Thread sal migondis
On Thu, May 26, 2011 at 12:28 PM, sal migondis  wrote:
> From: Thorsten Kampe 
> Subject: Re: English Idiom in Unix: Directory Recursively
> Date: Thu, 26 May 2011 12:46:58 +0200
> To: python-list@python.org
>
> * Steven D'Aprano (26 May 2011 10:06:44 GMT)
>>
>> On Thu, 26 May 2011 10:48:07 +0200, Thorsten Kampe wrote:
>>
>> > But not to digress, the /real/ problem with commands or idioms like "rm
>> > -r" is /not/ their choice of option names but that they explain these
>> > options in the exact same terms. No one would have a problem with "-r,
>> > --recursive -- remove directories including all sub-directories" instead
>> > of "-r, --recursive -- remove directories and their contents
>> > recursively".
>>
>> I think you are understanding the description "remove directories and
>> their contents recursively" as a description of the *mechanism* by which
>> rm removes the directory, i.e. some recursive tree-walking function that
>> visits each node and deletes it.
>>
>> I don't believe that's how the description is meant to be understood. I
>> understand it as describing the effect, not the implementation.

> It doesn't matter how I interprete the explanation "-r = recursively
> delete". [..]

Quite the contrary.. and that's the whole issue: your superficial
knowledge of the English language..  :-)

>> You're interpreting the reference to "recursive" as a nod to the
>> implementation. I'm not, and therefore your arguments don't convince
>> me.
>
> No one understands what "recursively delete" means

... _We_ do.. :-)

> until someone explains ("translates") it to him. This is not an argument
> but a simple fact. I experienced it many times, others here in the thread
> did and probably you, too.
>
> "recursively delete" is completely unneccessary because there is already
> a simple explanation that everyone understands without translation
> ("delete including subdirectories").

.. which is very poor 'style' indeed.

Style is not a matter of aesthetics. It's all about clarity and expressiveness.
It's about effectively communicating your thoughts to your audience. When
I hear or read 'delete recursively', I immediately 'get the idea' and I can
move on..

Now, if I heard 'delete including subdirectories', my first reaction would be..
ouch, I bet that hurts.. or ugh.. how ugly.. See, I'm distracted already.

But it doesn't stop there.. After the initial jolt to my attention, I'd start
thinking along the lines of.. hm. subdirectories.. now what about
sub sub directories.. etc. not seriously, perhaps.. but by the time I got
over it and was able to focus again on what was being said (or what
I was reading) I would have lost the thread.

This is why the author of the document puts paid to all the  nonsense
and instinctively uses 'recursively delete', not going into irrelevant
details.

It's that simple.

> It's unnecessary bullshit buzzword bingo from nerds which adds or helps
> or explains nothing. It's just that simple.

This has nothing to do with buzzwords whatsoever.

Despite polite hints from several other posters, the problem is that (like
the OP) you are not a native speaker of English but you will not listen and
still think you are qualified to make recommendations regarding usage and
abusage in the English language.

Sorry pal, but right here, you are like the kellet teaching the fishes to swim.

Sal.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Figuring out what dependencies are needed

2013-12-11 Thread sal i
On Thursday, December 12, 2013 1:48:42 PM UTC+8, alex23 wrote:
> On 11/12/2013 10:44 PM, s...@nearlocal.com wrote:
> 
> > I'm a Python beginner.  I want to use it for stats work, so I downloaded 
> > Anaconda which has several of the popular libraries already packaged for 
> > Mac OS X.
> 
> >
> 
> > Now I'd like to use the backtesting package from zipline (zipline.io), but 
> > while running the test script in iPython, I receive the following error:
> 
> >
> 
> > AssertionErrorTraceback (most recent call last)
> 
> >  in ()
> 
> > > 1 data = load_from_yahoo()
> 
> >2 dma = DualMovingAverage()
> 
> >3 results = dma.run(data)
> 
> >
> 
> > 1)  I assume that I'm missing some packages that aren't included in 
> > Anaconda, but how do I know which ones to upload?
> 
> 
> 
> You're not missing a package, you're missing parameters. This is the 
> 
> signature for load_from_yahoo:
> 
> 
> 
>  def load_from_yahoo(indexes=None,
> 
>  stocks=None,
> 
>  start=None,
> 
>  end=None,
> 
>  adjusted=True):
> 
> 
> 
> The first thing it does is call a helper function 
> 
> `_load_raw_yahoo_data`, which has this assertion:
> 
> 
> 
>  assert indexes is not None or stocks is not None, """
> 
> 
> 
> As you're passing no parameters into `load_from_yahoo`, both `indexes` 
> 
> and `stocks` default to None, so the assertion fails. Take a look at the 
> 
> examples in the zipline library to see what it is expecting.
> 
> > 2)  Often I'll just unzip a library file and put the main folder in the 
> > iPython folder, but I notice there's usually a setup.py file in the main 
> > library folder.  I've been ignoring this.  Should I be using it?
> 
> >
> 
> > Thanks
> 
> >

Thanks everyone.

This is the entire testing file along with the error at the bottom.  It looks 
like a stock is specified as data['AAPL']:

%pylab inline
Populating the interactive namespace from numpy and matplotlib
In [14]:

from zipline.algorithm import TradingAlgorithm
from zipline.transforms import MovingAverage
from zipline.utils.factory import load_from_yahoo
In [15]:

class DualMovingAverage(TradingAlgorithm):
"""Dual Moving Average algorithm.
"""
def initialize(self, short_window=200, long_window=400):
# Add 2 mavg transforms, one with a long window, one
# with a short window.
self.add_transform(MovingAverage, 'short_mavg', ['price'],
   market_aware=True,
   window_length=short_window)
 
self.add_transform(MovingAverage, 'long_mavg', ['price'],
   market_aware=True,
   window_length=long_window)
 
# To keep track of whether we invested in the stock or not
self.invested = False
 
self.short_mavg = []
self.long_mavg = []
 
 
def handle_data(self, data):
if (data['AAPL'].short_mavg['price'] > data['AAPL'].long_mavg['price']) 
and not self.invested:
self.order('AAPL', 100)
self.invested = True
elif (data['AAPL'].short_mavg['price'] < 
data['AAPL'].long_mavg['price']) and self.invested:
self.order('AAPL', -100)
self.invested = False
 
# Save mavgs for later analysis.
self.short_mavg.append(data['AAPL'].short_mavg['price'])
self.long_mavg.append(data['AAPL'].long_mavg['price'])
 
In [16]:

data = load_from_yahoo()
dma = DualMovingAverage()
results = dma.run(data)
---
AssertionErrorTraceback (most recent call last)
 in ()
> 1 data = load_from_yahoo()
  2 dma = DualMovingAverage()
  3 results = dma.run(data)

/Users/my_mac/zipline/data/loader.pyc in load_from_yahoo(indexes, stocks, 
start, end, adjusted)
302 
303 """
--> 304 data = _load_raw_yahoo_data(indexes, stocks, start, end)
305 if adjusted:
306 close_key = 'Adj Close'

/Users/my_mac/zipline/data/loader.pyc in _load_raw_yahoo_data(indexes, stocks, 
start, end)
245 
246 assert indexes is not None or stocks is not None, """
--> 247 must specify stocks or indexes"""
248 
249 if start is None:

AssertionError: 
must specify stocks or indexes
-- 
https://mail.python.org/mailman/listinfo/python-list


using modules

2010-09-06 Thread Sal Lopez
The following code runs OK under 3.1:

@filename=cats_and_dogs.py

#!/usr/bin/python

def make_sound(animal):
print(animal + ' says ' + sounds[animal])

sounds = { "cat": "meow", "dog": "woof" }

for i in sounds.keys():
make_sound(i)

# output:
# dog says woof
# cat says meow

When I move the def to it's own file to create a module, it barfs:

@filename= cats_and_dogs.py
#!/usr/bin/python

import defs

sounds = { "cat": "meow", "dog": "woof" }

for i in sounds.keys():
defs.make_sound(i)

@filename=defs.py
def make_sound(animal):
print(animal + ' says ' + sounds[animal])

Traceback (most recent call last):
File "./cats_and_dogs.py", line 11, in 
defs.make_sound(i)
File "defs.py", line 4, in make_sound
print(animal + ' says ' + sounds[animal])
NameError: global name 'sounds' is not defined


I thought that importing the function(s) made them local to the main program? 
Any assistance is appreciated.  
-- 
http://mail.python.org/mailman/listinfo/python-list