Esempio n. 1
0
    def test_equality_operator(self):
        JSON_path = '../../../tests/minimax.wcon'
        w2 = WCONWorms.load_from_file(JSON_path)
        w2.units['y'] = MeasurementUnit.create('m')
        w2data = w2.data.copy()

        w2c = w2.to_canon
        # A change to_canon should change the data in one but equality
        # should remain
        self.assertFalse(WCONWorms.is_data_equal(w2, w2c, convert_units=False))
        self.assertEqual(w2, w2)
        self.assertEqual(w2c, w2c)
        self.assertEqual(w2, w2c)

        # Change the units for w2 (not really what we should do but just
        # force a difference now, with w2c)
        w2.units['y'] = MeasurementUnit.create('mm')
        self.assertNotEqual(w2, w2c)
Esempio n. 2
0
    def test_equality_operator(self):
        JSON_path = '../../../tests/minimax.wcon'
        w2 = WCONWorms.load_from_file(JSON_path)
        w2.units['y'] = MeasurementUnit.create('m')
        w2data = w2.data.copy()

        w2c = w2.to_canon
        # A change to_canon should change the data in one but equality
        # should remain
        self.assertFalse(WCONWorms.is_data_equal(w2, w2c, convert_units=False))
        self.assertEqual(w2, w2)
        self.assertEqual(w2c, w2c)
        self.assertEqual(w2, w2c)

        # Change the units for w2 (not really what we should do but just
        # force a difference now, with w2c)
        w2.units['y'] = MeasurementUnit.create('mm')
        self.assertNotEqual(w2, w2c)
Esempio n. 3
0
    def test_bad_units(self):
        # Verify that combining the full name with an abbreviation causes
        # an error to be raised
        with self.assertRaises(AssertionError):
            MeasurementUnit.create('msecond')

        with self.assertRaises(AssertionError):
            MeasurementUnit.create('millis')

        # This form, on the other hand, should be fine, since both prefix
        # and suffix are long-form.
        MeasurementUnit.create('milliseconds')
Esempio n. 4
0
    def test_bad_units(self):
        # Verify that combining the full name with an abbreviation causes
        # an error to be raised
        with self.assertRaises(AssertionError):
            MeasurementUnit.create('msecond')

        with self.assertRaises(AssertionError):
            MeasurementUnit.create('millis')

        # This form, on the other hand, should be fine, since both prefix
        # and suffix are long-form.
        MeasurementUnit.create('milliseconds')
Esempio n. 5
0
pd.set_option('display.expand_frame_repr', False)

# Suppress RuntimeWarning warnings in Spider because it's a known bug
# http://stackoverflow.com/questions/30519487/
# warnings.simplefilter(action = "ignore", category = RuntimeWarning)

if __name__ == '__main__':

    JSON_path = '../../tests/minimax.wcon'

    w2 = WCONWorms.load_from_file(JSON_path)

    w2.save_to_file('example_saved_file.WCON', pretty_print=True)
    w3 = WCONWorms.load_from_file('example_saved_file.WCON')

    u = MeasurementUnit.create('cm')

    # io=StringIO()
    # json.dump([None], io)
    # io.getvalue()

if __name__ == '__main__2':
    worm_file_text2 = (('{"units":{"t":"s","x":"m","y":"m"},'
                        '"data":[{"id":3, "t":1.3, '
                        '"x":[3,4], "y":[5.4,3]}]}'))

    w1 = WCONWorms.load(StringIO(worm_file_text2))

if __name__ == '__main__3':
    w1 = WCONWorms.load(
        StringIO('{"units":{},'
# Suppress RuntimeWarning warnings in Spider because it's a known bug
# http://stackoverflow.com/questions/30519487/
# warnings.simplefilter(action = "ignore", category = RuntimeWarning)


if __name__ == '__main__':

    JSON_path = '../../tests/minimax.wcon'

    w2 = WCONWorms.load_from_file(JSON_path)

    w2.save_to_file('example_saved_file.WCON', pretty_print=True)
    w3 = WCONWorms.load_from_file('example_saved_file.WCON')

    u = MeasurementUnit.create('cm')

    # io=StringIO()
    # json.dump([None], io)
    # io.getvalue()

if __name__ == '__main__2':
    worm_file_text2 = (('{"units":{"t":"s","x":"m","y":"m"},'
                        '"data":[{"id":3, "t":1.3, '
                        '"x":[3,4], "y":[5.4,3]}]}'))

    w1 = WCONWorms.load(StringIO(worm_file_text2))


if __name__ == '__main__3':
    w1 = WCONWorms.load(StringIO('{"units":{},'