Skip to content

Updated local bat - #223

Closed
q24609962-svg wants to merge 16 commits into
juami:mainfrom
q24609962-svg:pullrequest3
Closed

Updated local bat #223
q24609962-svg wants to merge 16 commits into
juami:mainfrom
q24609962-svg:pullrequest3

Conversation

@q24609962-svg

Copy link
Copy Markdown
Contributor

closes #209
Changed:

  • Python 3.8 → 3.12 (matches pyproject.toml requirement of >=3.11, <3.13)
  • Removed all 28 hardcoded .whl files: replaced with direct pip install from PyPI, which automatically resolves correct versions and sub-dependencies
  • Added PySide6: was missing from the old script
  • setup.py install → pip install . The project no longer has a setup.py, it uses pyproject.toml
  • Added pip self-upgrade step
  • Added simulation mode instructions in the completion message
  • Uses %~dp0 for reliable relative paths instead of assuming the working directory

q24609962-svg and others added 12 commits February 19, 2026 15:24
Global GUI stylesheet: I updated src/GUI/code/main.py to enforce clear, 
readable colors across all GUI windows (including CV/CA/LSV creators, 
experiment list, and port dropdown).
Key addition (already in your file now):
app = QApplication(sys.argv)
Created a new app_setup.py file to centralize the creation of the QApplication and enforce a consistent stylesheet for readable text and background colors. Updated main.py to utilize this new function, streamlining the application setup process. Added a test for the stylesheet to ensure it sets readable colors across GUI components.
Updated the test file to skip tests if PySide6 is not available, ensuring compatibility and preventing import errors. This change enhances the robustness of the test suite when running in environments without PySide6.
                                                                                                                                                 Problem
                                                                                                                                                                   Testing and learning the code requires a physical JUAMI potentiostat connected via USB. This makes it hard to run experiments, develop new features, or onboard   new users without hardware.
                                                                                                                                                                   Solution

  Added a software simulator that mocks the Arduino pin I/O, allowing all three experiment types (CV, LSV, CA) to run without hardware.
  Changes
  New files:
  - src/pytentiostat/simulator.py: SimulatedPotentiostat class that mimics pyFirmata pin behavior (d9 PWM output, a0/a2 analog reads). Generates realistic
  signals: tanh-based I-V curves for LSV/CV, exponential current decay for CA, with configurable noise and auto-scaled current limits.                             - tests/test_simulator.py: 11 tests covering simulator unit behavior and full integration tests for all three experiment types.
                                                                                                                                                                   Modified files:
  - src/pytentiostat/routines.py: startup_routine() accepts simulate flag; when True, returns simulated pin objects instead of connecting to hardware.
  - src/pytentiostat/main.py : Reads PYTENTIOSTAT_SIMULATE env var to enable simulation mode. Added experiment-type switching menu after each run (LSV/CV/CA) so
  users can try all experiments in one session.
  - src/pytentiostat/operator.py: Fixed UnboundLocalError in CA experiments where normalized_start was undefined (bug present in hardware mode too).
  - src/pytentiostat/config_reader.py: Falls back to the bundled config.yml when no config file exists in the current directory (only when no explicit path was
  provided).
                                                                                                                                                                   Usage

  # Windows PowerShell
  $env:PYTENTIOSTAT_SIMULATE="1"; python -m pytentiostat.main
                                                                                                                                                                   # Linux/macOS
  PYTENTIOSTAT_SIMULATE=1 python -m pytentiostat.main

  Test plan
  - python -m pytest tests/test_simulator.py -v , all 11 tests pass
  - python -m pytest tests/ --ignore=tests/test_routines.py -v ,full suite passes
  - Run simulation interactively and verify distinct plots for CV, LSV, and CA
  - Verify existing hardware workflow is unaffected (no env var set)
@sbillinge

Copy link
Copy Markdown
Member

Thanks for this @q24609962-svg it is appreciated.

I have a few comments:

  • please split this into more branches where each does one of the tasks in your nice todo list. At least two, one for the installation updates and the other for the simulation work. Please build off an updated main as I did some cleaning. Please also check that everything is still working after my changes! I didn't check whether I broke anything, but I needed to do that to get the CI working again.
  • please provide a news (or a no-news) with each PR (https://scikit-package.github.io/scikit-package/snippets/news-file-format.html)
  • is there a reason we are skipping docformatter and merge-to-branch checks in t he CI? In general we don't want to change these things.
  • Is there a reason you are editing the local_installation file? This is not the general installation instructions but was for situations where the code is to be installed when there is no internet and code is being installed from a flash-drive. In the presence of internet (i.e., when pip will install from pypi) we use the installation instructions in the README.md. Undoubtedly these local_install instructions need to be updated, but they would need to be updated in a way so that don't use the internet for the install.
  • Please check that tests are passing in CI. I fixed the CI so that the tests should run correctly when you make the new PRs

Thanks so much for hte contributions we really appreciate them!

@q24609962-svg q24609962-svg mentioned this pull request Mar 22, 2026
@sbillinge

Copy link
Copy Markdown
Member

closing as replaced by #226

@sbillinge sbillinge closed this Mar 22, 2026
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