Skip to content

Fix GPX file loading errors and quantile extraction bug - #4

Draft
pascal2802 wants to merge 9 commits into
vibe/streamlit-app-90c846from
pr-2
Draft

pascal2802 wants to merge 9 commits into
vibe/streamlit-app-90c846from
pr-2

Conversation

@pascal2802

Copy link
Copy Markdown
Owner

Fixes the errors reported in PR #2:

  • Error when using default GPX example files
  • Error when uploading GPX files via the upload button

Additional fix:

  • Fixed quantile extraction bug in simulate_ar1_speeds where [0] was used instead of [0][0]

Root cause: GPX files (XML format) must be opened in binary mode ('rb'), not text mode ('r'). Also fixed temporary file handling logic in the Streamlit app.

Changes:

  • Base.py: Changed open() mode from 'r' to 'rb' and fixed quantile extraction
  • main.py: Changed open() mode from 'r' to 'rb'
  • app.py: Fixed temporary file creation and handling for both example files and user uploads

- Changed file opening mode from text ('r') to binary ('rb') in Base.py and main.py
  to properly parse GPX files which are XML format
- Fixed temporary file handling in app.py for both example files and user uploads:
  - Separated file content reading from temporary file creation
  - Added explicit mode='wb' for temporary files
  - Properly closed temporary files before use
  - Fixed variable shadowing issue where uploaded_file was being overwritten

These changes resolve the errors reported in PR #2:
- Error when using default GPX example files
- Error when uploading GPX files via the upload button

The root cause was that gpxpy.parse() requires a file opened in binary mode,
not text mode, and the temporary file handling had logic errors.
- Fixed bug where computeQuantilePerComponent returns a Sample, and [0] returns a Point
- Need to use [0][0] to extract the float value from the Point
- This was causing TypeError when comparing lower <= mean_speed <= upper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants