Пример #1
0
    def testPassStringAsUnicode(self):
        """Pass a string when unicode is expected.  Should fail."""
        if not unicode_support:
            return

        a = vtk.vtkUnicodeStringArray()
        self.assertRaises(exceptions.TypeError,
                          a.InsertNextValue, ('Francois',))
Пример #2
0
    def testPassStringAsUnicode(self):
        """Pass a string when unicode is expected.  Should fail."""
        if not unicode_support:
            return

        a = vtk.vtkUnicodeStringArray()
        self.assertRaises(exceptions.TypeError, a.InsertNextValue,
                          ('Francois', ))
Пример #3
0
    def testPassAndReturnUnicodeByReference(self):
        """Pass a unicode string by const reference"""
        if not unicode_support:
            return

        a = vtk.vtkUnicodeStringArray()
        a.InsertNextValue(u'Fran\xe7ois')
        u = a.GetValue(0)
        self.assertEqual(u, u'Fran\xe7ois')
Пример #4
0
    def testPassAndReturnUnicodeByReference(self):
        """Pass a unicode string by const reference"""
        if not unicode_support:
            return

        a = vtk.vtkUnicodeStringArray()
        a.InsertNextValue(u'Fran\xe7ois')
        u = a.GetValue(0)
        self.assertEqual(u, u'Fran\xe7ois')
Пример #5
0
def _numpy_to_string(a, array_type=None):
    if np.issubdtype(a.dtype, np.string_) or array_type == VTK_STRING:
        av = vtk.vtkStringArray()
    else:
        av = vtk.vtkUnicodeStringArray()
    av.SetNumberOfComponents(1 if a.ndim == 1 else a.shape[1])
    av.SetNumberOfValues(a.size)
    for i, s in enumerate(a.ravel()):
        av.SetValue(i, s)
    return av
Пример #6
0
	def GetDocTitles(self, IDlist):
		"""Given a list of IDs selected from a parallel coordinates plot, returns
		a vtkImageData with all of the projected (reduced dimensionality by SVD) images
		for those IDs. (e.g. typically 120 dim rather than original 768 dim for MNIST digits)"""

		if self.data_loaded:

			titles = vtk.vtkUnicodeStringArray()
			titles.SetName('doc_titles')

			if self.hasDocTitles:
				print self.DocTitles
				for id in IDlist:
					print id
					titles.InsertNextValue(self.DocTitles[id])

			return titles
Пример #7
0
def dict_to_vtkarrays(row, fields, attributes):
    import vtk
    for key in fields:
        value = row[key]
        comp = 1
        if isinstance(value, list):
            comp = len(value)
            value = value[0]
        if isinstance(value, (int, long, float)):
            arr = vtk.vtkDoubleArray()
        elif isinstance(value, str):
            arr = vtk.vtkStringArray()
        elif isinstance(value, unicode):
            arr = vtk.vtkUnicodeStringArray()
        else:
            arr = vtk.vtkStringArray()
        arr.SetName(key)
        arr.SetNumberOfComponents(comp)
        attributes.AddArray(arr)
Пример #8
0
def dict_to_vtkarrays(row, fields, attributes):
    import vtk
    for key in fields:
        value = row[key]
        comp = 1
        if isinstance(value, list):
            comp = len(value)
            value = value[0]
        if isinstance(value, (int, long, float)):
            arr = vtk.vtkDoubleArray()
        elif isinstance(value, str):
            arr = vtk.vtkStringArray()
        elif isinstance(value, unicode):
            arr = vtk.vtkUnicodeStringArray()
        else:
            arr = vtk.vtkStringArray()
        arr.SetName(key)
        arr.SetNumberOfComponents(comp)
        attributes.AddArray(arr)
Пример #9
0
 def testPassBytesAsUnicode(self):
     """Pass 8-bit string when unicode is expected.  Should fail."""
     a = vtk.vtkUnicodeStringArray()
     self.assertRaises(TypeError, a.InsertNextValue, eightbit)
Пример #10
0
 def testPassAndReturnUnicodeByReference(self):
     """Pass a unicode string by const reference"""
     a = vtk.vtkUnicodeStringArray()
     a.InsertNextValue(cedilla)
     u = a.GetValue(0)
     self.assertEqual(u, cedilla)
Пример #11
0
rsv_reader = vtk.vtkArrayReader()
rsv_reader.SetFileName(os.path.join(lsa_data_path,"CH_RightSingularVectors.txt"))

sv_reader = vtk.vtkArrayReader()
sv_reader.SetFileName(os.path.join(lsa_data_path,"CH_SingluarValues.txt"))


power_weighting = vtk.vtkPowerWeighting()
power_weighting.SetInputConnection(0, sv_reader.GetOutputPort())
power_weighting.SetPower(-0.5)

# Setup the query pipeline ...
query_document_array = vtk.vtkIdTypeArray()
query_document_array.SetName("document")

query_text_array = vtk.vtkUnicodeStringArray()
query_text_array.SetName("text")

query_document_array.InsertNextValue(query_document_array.GetNumberOfTuples())
query_text_array.InsertNextValue(unicode(query_string))

query_document_table = vtk.vtkTable()
query_document_table.AddColumn(query_document_array)
query_document_table.AddColumn(query_text_array)

query_document_reader = vtk.vtkPassThrough()
query_document_reader.SetInputConnection(0, query_document_table.GetProducerPort())

query_tokens = vtkTokenization()
query_tokens.SetInputConnection(0, query_document_reader.GetOutputPort())
Пример #12
0
 def testPassBytesAsUnicode(self):
     """Pass 8-bit string when unicode is expected.  Should fail."""
     a = vtk.vtkUnicodeStringArray()
     self.assertRaises(TypeError,
                       a.InsertNextValue, eightbit)
Пример #13
0
 def testPassAndReturnUnicodeByReference(self):
     """Pass a unicode string by const reference"""
     a = vtk.vtkUnicodeStringArray()
     a.InsertNextValue(cedilla)
     u = a.GetValue(0)
     self.assertEqual(u, cedilla)
Пример #14
0
 def testPassStringAsUnicode(self):
     """Pass a string when unicode is expected.  Should fail."""
     a = vtk.vtkUnicodeStringArray()
     self.assertRaises(TypeError, a.InsertNextValue, ('Francois', ))
Пример #15
0
 def testPassStringAsUnicode(self):
     """Pass a string when unicode is expected.  Should fail."""
     a = vtk.vtkUnicodeStringArray()
     self.assertRaises(TypeError,
                       a.InsertNextValue, ('Francois',))