SynBioDex / pySBOL2

A pure Python implementation of the SBOL standard.
Apache License 2.0
20 stars 6 forks source link

Error in OwnedObject.set: object is not iterable #345

Closed bbartley closed 4 years ago

bbartley commented 4 years ago

Example:

class DataSheet(sbol2.Identified):

    RDF_TYPE = 'http://example.org/test#DataSheet'

    def __init__(self, uri='example'):
        super().__init__(uri=uri,
                         type_uri=DataSheet.RDF_TYPE)

class Analysis(sbol2.TopLevel):

    RDF_TYPE = 'http://example.org/test#Analysis'

    def __init__(self, uri=None, model=None):
        super().__init__(uri=uri,
                         type_uri=Analysis.RDF_TYPE)
        self.dataSheet = sbol2.OwnedObject(self, 'http://examples.org#dataSheet',
                                           DataSheet, 0, 1, [])

analysis = Analysis('foo')
analysis.dataSheet = DataSheet('foo')

This results in TypeError: 'DataSheet' object is not iterable

The error results because if self.getUpperBound() == '1': evaluates as False

bbartley commented 4 years ago

This one is a little puzzling... the failing case appears very similar to this test case which passes: https://github.com/SynBioDex/pySBOL2/blob/master/test/test_property.py#L158

tcmitchell commented 4 years ago

The failing case in the issue description uses integers for the upper and lower bounds, while the cited test case uses strings as the upper and lower bounds. Pull request #347 allows integers (and floats) for the bounds arguments on all Property instances. A test case derived from the cited test case has been added as well.