# ----------------------------------------------------------------------
# Numenta Platform for Intelligent Computing (NuPIC)
# Copyright (C) 2013, Numenta, Inc.  Unless you have purchased from
# Numenta, Inc. a separate commercial license for this software code, the
# following terms and conditions apply:
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see http://www.gnu.org/licenses.
#
# http://numenta.org/licenses/
# ----------------------------------------------------------------------




############################################################################
def bitsToString(array):
  """Returns a string representing a numpy array of 0's and 1's"""
  s = ""
  for i in xrange(len(array)):
    if array[i] == 0:
      s += "."
    else:
      s += "*"
  return s
@@ -1080,13 +1080,11 @@
 (arr
-ay
 ):%0A
+
   %22%22
@@ -1152,18 +1152,45 @@
 %22%0A  s = 
-%22%22
+array.array('c','.'*len(arr))
 %0A  for i
@@ -1207,18 +1207,16 @@
 (len(arr
-ay
 )):%0A    
@@ -1225,43 +1225,16 @@
  arr
-ay
 %5Bi%5D == 
-0:%0A      s += %22.%22%0A    else
+1
 :%0A  
@@ -1242,15 +1242,15 @@
    s
- += %22*%22
+%5Bi%5D='*'
 %0A  r
@@ -1256,8 +1256,10 @@
 return s
+%0A%0A

optimize bitsToString