예제 #1
0
파일: testBV.py 프로젝트: lmmentel/rdkit
  def test8BinText(self):
    bv = DataStructs.ExplicitBitVect(32)
    bv.SetBit(0)
    bv.SetBit(1)
    bv.SetBit(17)
    bv.SetBit(23)
    bv.SetBit(31)

    bv2 = DataStructs.CreateFromBinaryText(DataStructs.BitVectToBinaryText(bv))
    self.assertEqual(bv, bv2)

    bv2 = DataStructs.CreateFromBinaryText("")
    self.assertEqual(bv2.GetNumBits(), 0)
예제 #2
0
 def to_python(self, value):
     if value is None or isinstance(value, ExplicitBitVect):
         return value
     elif isinstance(value, six.buffer_types):
         return DataStructs.CreateFromBinaryText(bytes(value))
     else:
         raise ValidationError("Invalid input for a Bfp instance")
예제 #3
0
 def to_python(self, value):
     if value is None or isinstance(value, ExplicitBitVect):
         return value
     elif isinstance(value, (bytes, bytearray, memoryview)):
         return DataStructs.CreateFromBinaryText(bytes(value))
     else:
         raise ValidationError("Invalid input for a Bfp instance")
예제 #4
0
파일: types.py 프로젝트: iwatobipen/razi
 def process(value):
     if value is None:
         return value
     elif isinstance(value, memoryview):
         return DataStructs.CreateFromBinaryText(bytes(value))
     else:
         raise RuntimeError(
             "Unexpected row value type for a Bfp instance")
예제 #5
0
 def from_db_value(self, value, expression, connection, context):
     if value is None:
         return value
     return DataStructs.CreateFromBinaryText(bytes(value))