[Tutor] Python dependencies in Anaconda

2016-10-11 Thread David Wolfe
Good Morning;

I'm working with a Python program that requires several dependencies
(Numpy, Matplotlib, and so on).  Normally I do all my programing through
Anaconda (using Spyder or a Juypter notebook), so the dependencies are
included, so it's not an issue.  So, what I'm wondering is, are the
dependencies that are included in Anaconda just contained in Anaconda, and
not actually accessible in Python, unless you go through the Anaconda
prompt to get to Python?

Thanks,
David
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Python Code Not Working

2016-10-11 Thread jeremygainey14
Everytime I run this it says test is not defined . I don’t understand. Can 
someone please help correct? 

#Question 10

def reverse(mystr):
reversed = ''
for char in mystr:
reversed = char + reversed
return reversed

def is_palindrome(myStr):
if myStr in reverse(myStr):
return True
else:
return False

test(is_palindrome("abba"))
test(not is_palindrome("abab"))
test(is_palindrome("tenet"))
test(not is_palindrome("banana"))
test(is_palindrome("straw warts"))
test(is_palindrome("a"))
test(is_palindrome(""))

-Jeremy Gainey 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Advise with coding

2016-10-11 Thread tracey jones-Francis
Hi


I have just started Com Sci in Uni and I am new to coding. I feel pretty 
inadequate as I am really struggling with the latest tasks. Most of the work is 
self-directed learning so we need to figure it out ourselves but I am running 
out of time. Is it possible someone on here can advise me where I am going 
wrong.


Many thanks in anticipation


T
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python dependencies in Anaconda

2016-10-11 Thread Alan Gauld via Tutor
On 10/10/16 16:54, David Wolfe wrote:

> Anaconda (using Spyder or a Juypter notebook), so the dependencies are
> included, so it's not an issue.  So, what I'm wondering is, are the
> dependencies that are included in Anaconda just contained in Anaconda, and
> not actually accessible in Python,

Anaconda is one of several specialist distributions of Python that
includes many modules not in the standard library, notably the
math/science related ones.

It is perfectly possible (although not entirely trivial) to
install all of the required dependencies manually into a
standard Python installation, but its tiresome and therefore
most folks working in that area will use a distribution like
Anaconda or Entropy.

The individual packages are mostly available on PyPI or on
the SciPy web site. They are also usually available on Linux
via the standard package management tools (apt-get, yum etc)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Advise with coding

2016-10-11 Thread Alan Gauld via Tutor
On 11/10/16 10:16, tracey jones-Francis wrote:
> Is it possible someone on here can advise me where I am going wrong.

Yesm, thats what this list is for but...

We need to see code - we can't guess what you did.
We need to know what input you used, what output
you got and why its not what you expected.

Also provide the full text of any error messages
you get.

Finally it ioften helpsa to know which OS and Python
version you are using and, if applicable, what IDE
you are using to write/run the code.

If that seems a lot, it all helps to provide specific
answers. The more specific your information is, the
more specific our response can be,.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python Code Not Working

2016-10-11 Thread Alan Gauld via Tutor
On 09/10/16 21:39, jeremygaine...@gmail.com wrote:
> Everytime I run this it says test is not defined . I don’t understand. 

It means test is not defined - that is, Python doesn't know
about it. You call a function test() but there is no such
function built into Python, so it complains.

Presumably the test function is defined in a module somewhere,
in which case you need to import that function to make it
visible to python.


Can someone please help correct?

> def is_palindrome(myStr):
> if myStr in reverse(myStr):
> return True
> else:
> return False
> 
> test(is_palindrome("abba"))
> test(not is_palindrome("abab"))
> test(is_palindrome("tenet"))

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Cluster analysis script error

2016-10-11 Thread Mike Armson
Hi there,

I am trying to run a script (attached) which determines the number of
clusters of fixations within a set of eye movement data. The script says to
enter the following command on python:

"python fixationClusters.py outputPrefix input clusterDistance"

I am getting a syntax error with the output command after entering the
following:

"python /fixationClusters.py ETv2_cluster_output ETv2_cluster_input 50"

The syntax error is indicated with an arrow under the last "t" in "output".

I realize that "/fixationClusters.py" looks different from the
"fixationClusters.py" in the instructions of the script but this part
actually works. At least, it was giving me a syntax error for
"fixationClusters.py" but not for "/fixationClusters.py".

Also, the "ETv2_cluster" portion of the output command seems to be working,
as there were originally errors here, but I fixed them.

Thanks very much for your help!

Mike

-- 
*Mike Armson, PhD Candidate*
University of Toronto, Department of Psychology
Levine Lab, Rotman Research Institute, Baycrest
*p:*  (416) 785-2500 x.2826
*e:  marm...@research.baycrest.org *


#!/usr/bin/env python
#
#   Script to find and report clusters of fixations
#
#   Clusters are defined automatically using a simple Euclidean distance metric
#   All fixations that are within D pixel units of each other are considered to
#   be in the same cluster.
#
#   Script Usage:   ./fixationClusters.py outputPrefix input clusterDistance
#   or  python fixationClusters.py outputPrefix input 
clusterDistance
#
#   input must be a csv file with 4 columns: Trial#, x-loc, y-loc and duration.
# a csv file with 5 columns: Subject#, Trial#, x-loc, y-loc and 
duration.
#   
#   The script returns a text file named outputPrefix.txt
#
#   The output is similar to the input, but with an additional column labeling
#   clusters instead of fixation duratoins. Each cluster is given a unique label
#
#   clusterDistance is the value (in pixel units) for which fixations are deemed
#   to be in the same cluster
#
#   Mark Chiew
#   Aug 2012
#

#   Imports (don't touch this stuff)

import numpy as np
import sys


#   Module Variables


#   List of subject numbers
subjects=   []

#   Screen boundaries
xBound  =   1024
yBound  =   768

#   Sort fixations (1), or keep original temporal ordering (0)
sortFix =   1

#   Use alphabetic (1), instead of numeric (0) cluster labels
alphaLabels =   1
alpha   =   'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

#   Verbose controls whether extra output is printed to screen or not
verbose =   1


#   Functions

def __detectColumns(inputFile):
"""Detects and returns the number of columns in the input file"""

data=   np.loadtxt(inputFile, skiprows=0, delimiter=',')
return len(data[0])

def __readData(inputFile, cols):
"""Assumes the input file is 4 or 5-column numeric. If 5, first column is 
subject 
number, second column is trial number, third column is x-coord, fourth 
column is y-coord, and fifth column is fixation duration. If 4, omit 
subject number.""" 

data=   np.loadtxt(inputFile, skiprows=0, delimiter=',')

if cols ==  5:

subjects=   tuple(set(map(int,data[:,0])))

data=   [np.array(filter(lambda z:z[0]==i, data)) for i in subjects]
data=   [map(lambda z:z[1:], x) for x in data]   

elif cols == 4:

subjects=   (1,)
data=   [data]


data=   [[np.array(filter(lambda z:z[0]==i, x)) for i in 
np.arange(1,x[-1][0]+1)] for x in data]

for i in range(len(data)):
if len(data[i]) == 0:
data[i] =   np.array(['No Subject'])
for j in range(len(data[i])):
if len(data[i][j]) == 0:
data[i][j] = np.array([[j+1,'NoTrial']])

for i in range(len(data)):
data[i]   =   map(lambda z: z[:,1:], data[i])

return data


def __checkOutofBoundsFixations(data):
"""Ignore fixations that occur outside of screen boundaries"""

data=   filter(lambda z: z[0] > 0, data)
data=   filter(lambda z: z[0] < xBound, data)
data=   filter(lambda z: z[1] > 0, data)
data=   filter(lambda z: z[1] < yBound, data)

return np.array(data)


def prepData(inputFile):
"""Reads data from file"""

cols=   __detectColumns(inputFile)

printVerbose('Reading data from '+inputFile)
return __readData(inputFile, cols)
  
def calcDist(a, b):
  

[Tutor] Python 3.x and Sqlite3

2016-10-11 Thread Greg Schmit
On FreeBSD I built lang/python34 from source and when I run python 3.4 I cannot 
import sqlite3. I thought it was being packaged with python 3.4. Am I incorrect 
in this assumption?

-gns
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python 3.x and Sqlite3

2016-10-11 Thread Kentaro Hori
You have to add to .configure

iPhoneから送信

2016/10/12 5:54、Greg Schmit  のメッセージ:

> On FreeBSD I built lang/python34 from source and when I run python 3.4 I 
> cannot import sqlite3. I thought it was being packaged with python 3.4. Am I 
> incorrect in this assumption?
> 
> -gns
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Cluster analysis script error

2016-10-11 Thread Alan Gauld via Tutor
On 11/10/16 22:13, Mike Armson wrote:

> I am trying to run a script (attached) which determines the number of
> clusters of fixations within a set of eye movement data. The script says to
> enter the following command on python:
> 
> "python fixationClusters.py outputPrefix input clusterDistance"
> 
> I am getting a syntax error with the output command 

I'm guessing that you are trying to run  this from the
Python interactive prompt (>>>)?

In fact, you should run it from an OS shell prompt (you
don't say which OS but in Windoze thats a CMD prompt,
in MacOS the Terminal App and in Linux whichever of
the many Terminal apps you use...)

The clue is that you are getting a syntax error - which is
usually from Python, but the command begins with 'python'
which is how you call the interpreter from the OS.

I suspect the phrase "...enter the following command on python:"
is a little misleading, it should say something like
"enter the following command at an OS shell prompt"

hth
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python 3.x and Sqlite3

2016-10-11 Thread Zachary Ware
Hi Greg,

On Tue, Oct 11, 2016 at 3:54 PM, Greg Schmit  wrote:
> On FreeBSD I built lang/python34 from source and when I run python 3.4 I 
> cannot import sqlite3. I thought it was being packaged with python 3.4. Am I 
> incorrect in this assumption?

This is more the kind of fare that python-list is good for; this list
is more for learning how to use Python.

In any case, you'll need to make sure you have sqlite3 and its headers
installed before building Python.  At the end of the 'make' step, you
probably got a message saying "The necessary bits to build these
optional modules were not found:" with _sqlite3 listed underneath it.
There may also be other useful modules listed there that you may want
to install the dependencies for, such as readline or _ssl.

Hope this helps,
-- 
Zach
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python Code Not Working

2016-10-11 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
An easier solution is simply to type 'print' in place of 'test' in the
program. It will work.
regards,
Sarma.


On Mon, Oct 10, 2016 at 2:09 AM,   wrote:
> Everytime I run this it says test is not defined . I don’t understand. Can 
> someone please help correct?
>
> #Question 10
>
> def reverse(mystr):
> reversed = ''
> for char in mystr:
> reversed = char + reversed
> return reversed
>
> def is_palindrome(myStr):
> if myStr in reverse(myStr):
> return True
> else:
> return False
>
> test(is_palindrome("abba"))
> test(not is_palindrome("abab"))
> test(is_palindrome("tenet"))
> test(not is_palindrome("banana"))
> test(is_palindrome("straw warts"))
> test(is_palindrome("a"))
> test(is_palindrome(""))
>
> -Jeremy Gainey
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor