top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Question about python package numpy

+2 votes
522 views

It is difficult to install numpy package for my PC Windows 7, 64-bit OS. In the end, I install Enthought Canopy, which is recommended on line because it does install numpy automatically. Now, I can test it with

import numpy

it succeeds. On http://wiki.scipy.org/Cookbook, it shows some interesting code example snippet, such as Cookbook / ParticleFilter, Markov chain etc.

I don't know how I can access these code examples, because I don't know where Enthought Canopy installs these package.

Could you help me on using numpy examples?

posted Mar 1, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Did you check Canopy's documentation?

Are you sure the examples in cookbook are installed with the package? You can print numpy.__file__ to know where the package is installed.

At http://wiki.scipy.org/Cookbook/Solving_Large_Markov_Chains I see "You can get the source code for this tutorial here: tandemqueue.py" with link to the file, why don't you get the source files for the example from their pages?

answer Mar 1, 2015 by Ramakrishnan
Thanks for your reply. I learned Python for about one week ago. The link  in your reply does look like executable. But the second snippet about particle filter, see below please, looks award. i.e. I do not see the
connection between the first and the second code snippet. I should save them to one .py file? Or save to two files? What name should be for the second file?
Similar Questions
+4 votes

When I try to use numpy to deal with my dataset in the style of csv, I face a problem.

In my dataset of the csv file, some columns are string that can not convert to float easily. Some of them can ignore, but other columns I need to change the data to a enum style.

for example, one column just contain three kinds : S,Q,C. Each of them can declare one meaning, so I must convert them to a dict just like {1,2,3}

Now the question is, when I use numpy.loadtxt, I must do all things above in just one line and one function.

+2 votes

I have a numpy array consisting of 1s and zeros for representing binary numbers:

e.g.

 >>> binary
 array([ 1., 0., 1., 0.])

I wish the array to be in the form 1010, so it can be manipulated. I do not want to use built in binary converters as I am trying to build my own.

0 votes

I am extending a parser and need to create many classes that are all subclassed from the same object (defined in an external library). When my module is loaded I need all the classes to be created with a particular name but the behavior is all the same. Currently I have a bunch of lines like this:

 class Vspace(Base.Command): pass
 class Boldpath(Base.Command): pass

There are a bunch of lines like that. Is there a better way? Something like

 newclasses = ['Vspace', 'Boldpath', ... ]
 for name in newclasses:
 tmp = type(name, (Base.Command,) {})
 tmp.__name__ = name

Is there a more pythonic way?

0 votes

I'm trying to figure out (or find an example) of polymorphism whereby I pass a commandline argument (a string) which comports to a class (in java, you would say that it comports to a given interface but I don't know if there is such a thing in Python) then that class of that name, somehow gets instantiated from that string. This way, I can have similar classes, but have my program use various ones by simply changing the commandline argument.

Can anyone show me how this might be done in Python?

+1 vote

I want to install path.py in my Python 3.4 environment on a Centos 5 box. My /usr/local/bin/ contains:

easy_install-3.4 
python3.4  
etc. 

We are behind a proxy server and I tried this:

# /usr/local/bin/easy_install-3.4 path.py 

Searching for path.py 
Reading https://pypi.python.org/simple/path.py/ 
Download error on https://pypi.python.org/simple/path.py/: hostname '172.29.68.1  
' doesn't match either of 'www.python.org', 'python.org', 'pypi.python.org',  
'docs.python.org', 'testpypi.python.org', 'bugs.python.org', 'wiki.python.org',  
'hg.python.org', 'mail.python.org', 'packaging.python.org', 'pythonhosted.org',  
'www.pythonhosted.org', 'test.pythonhosted.org', 'us.pycon.org', 'id.python.org' --  
Some packages may not be found! 

Couldn't find index page for 'path.py' (maybe misspelled?), Am I best to use pip or easy_install? also if easy_install, how can I fix the above error?

...