jarondl / pygtfs

A python (2/3) library for GTFS
MIT License
63 stars 44 forks source link

AssertionError: value outside limits - when loading in schedule #40

Closed WetzlerkAI closed 5 years ago

WetzlerkAI commented 6 years ago

I am getting an error reading in the schedule.

I have successfully used this gtfs file for routing and service area creating via ArcMap, and I'd like to use your tool to add new routes to my analysis.

I'm unsure how to address the error.

ipython                   5.3.0                    py36_0
ipython_genutils          0.2.0                    py36_0

import pygtfs sched = pygtfs.Schedule(":memory:") pygtfs.append_feed(sched, 'full_greater_sydney_gtfs_static.zip')

The output is:

Loading GTFS data for <class 'pygtfs.gtfs_entities.Agency'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.Stop'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.Route'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.Trip'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.StopTime'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.Service'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.ServiceException'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.Fare'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.FareRule'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.ShapePoint'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.Frequency'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.Transfer'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.FeedInfo'>:
Loading GTFS data for <class 'pygtfs.gtfs_entities.Translation'>:
125 records read for <class 'pygtfs.gtfs_entities.Agency'>.
.......38991 records read for <class 'pygtfs.gtfs_entities.Stop'>.
Failure while writing Routes(route_id='1-11T-6-sj2-2', agency_id='700', route_short_name='11T6', route_long_name='Carlingford, then all stations to Clyde', route_desc='Temporary buses', route_type='714', route_color='00B5EF', route_text_color='FFFFFF')
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-9-5ce656f03730> in <module>()
----> 1 pygtfs.append_feed(sched, 'full_greater_sydney_gtfs_static.zip')

C:\ProgramData\Anaconda3\lib\site-packages\pygtfs\loader.py in append_feed(schedule, feed_filename, strip_fields, chunk_size, agency_id_override)
     87 
     88             try:
---> 89                 instance = gtfs_class(feed_id=feed_id, **records_as_dict)
     90             except:
     91                 print("Failure while writing {0}".format(record))

<string> in __init__(self, **kwargs)

C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\orm\state.py in _initialize_instance(*mixed, **kwargs)
    412         except:
    413             with util.safe_reraise():
--> 414                 manager.dispatch.init_failure(self, args, kwargs)
    415 
    416     def get_history(self, key, passive):

C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\util\langhelpers.py in __exit__(self, type_, value, traceback)
     64             self._exc_info = None   # remove potential circular references
     65             if not self.warn_only:
---> 66                 compat.reraise(exc_type, exc_value, exc_tb)
     67         else:
     68             if not compat.py3k and self._exc_info and self._exc_info[1]:

C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\util\compat.py in reraise(tp, value, tb, cause)
    185         if value.__traceback__ is not tb:
    186             raise value.with_traceback(tb)
--> 187         raise value
    188 
    189 else:

C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\orm\state.py in _initialize_instance(*mixed, **kwargs)
    409 
    410         try:
--> 411             return manager.original_init(*mixed[1:], **kwargs)
    412         except:
    413             with util.safe_reraise():

C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\ext\declarative\base.py in _declarative_constructor(self, **kwargs)
    652                 "%r is an invalid keyword argument for %s" %
    653                 (k, cls_.__name__))
--> 654         setattr(self, k, kwargs[k])
    655 _declarative_constructor.__name__ = '__init__'
    656 

C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\orm\attributes.py in __set__(self, instance, value)
    222     def __set__(self, instance, value):
    223         self.impl.set(instance_state(instance),
--> 224                       instance_dict(instance), value, None)
    225 
    226     def __delete__(self, instance):

C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\orm\attributes.py in set(self, state, dict_, value, initiator, passive, check_old, pop)
    700         if self.dispatch.set:
    701             value = self.fire_replace_event(state, dict_,
--> 702                                             value, old, initiator)
    703         state._modified_event(dict_, self, old)
    704         dict_[self.key] = value

C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\orm\attributes.py in fire_replace_event(self, state, dict_, value, previous, initiator)
    709                 state, value, previous,
    710                 initiator or self._replace_token or
--> 711                 self._init_append_or_replace_token())
    712         return value
    713 

C:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\orm\util.py in set_(state, value, oldvalue, initiator)
    116         def set_(state, value, oldvalue, initiator):
    117             if include_backrefs or not detect_is_backref(state, initiator):
--> 118                 return validator(state.obj(), key, value)
    119             else:
    120                 return value

C:\ProgramData\Anaconda3\lib\site-packages\pygtfs\gtfs_entities.py in in_range(self, key, value)
     59         else:
     60             int_value = int(value)
---> 61         assert int_value in int_choice, "value outside limits"
     62         return int_value
     63     return in_range

AssertionError: value outside limits
jarondl commented 6 years ago

It seems like an issue that should have been fixed in #34 Can you try the latest code from github, while I upload a new version to PyPI (#39)

jarondl commented 5 years ago

I think this was fixed.