On 06/18/2013 04:27 PM, rusi wrote:
On Jun 18, 7:23 pm, zoom<z...@yahoo.com>  wrote:
Hi, I have a strange problem here. Perhaps someone would care to help me.

In the file test.py I have the following code:

from scipy import matrix, tile, mean, shape
import unittest

class TestSequenceFunctions(unittest.TestCase):

      def setUp(self):
          self.m = [[1,2],[3,4],[3,4],[3,4]]

      def test_simplify(self):
          m = matrix(self.m)
          print shape(m)
          print [shape(m)[1],1]
          print shape(tile(mean(m,1),[shape(m)[1],1]).T)

if __name__ == '__main__':
      unittest.main()

(Note that test.py, is just a simplification of my testing file,
sufficient to reproduce the weird behavior that I'm  about to describe.)

If i run it in terminal via "python test.py" command I get the following
output:

(4, 2)
[2, 1]
(1, 8)
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

Now comes the funny part.
Let's try to run the following code in python interpreter:

  >>>  m = [[1,2],[3,4],[3,4],[3,4]]
  >>>
  >>>  from scipy import matrix, tile, mean, shape
  >>>  print shape(m)
(4, 2)
  >>>  print [shape(m)[1],1]
[2, 1]
  >>>  print shape(tile(mean(m,1),[shape(m)[1],1]).T)
(4, 2)

Note the difference between outputs of:
print shape(tile(mean(m,1),[shape(m)[1],1]).T)

I mean, WTF?
This is definitely not the expected behavior.
Anybody knows what just happened here?

[Never used scipy so pls excuse if I am off...]

Given list m, in the class you are doing m ->  matrix(m)
which you dont seem to be doing in the interpreter.

yes, that's the thing.

thanks a lot

FYI this happens because

>>> shape(mean(m,1))
(4, 1)
>>> shape(mean(array(m),1))
(4,)

thanks again
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to