Skip to content

CLEAN: keep the tilde, the last printable ASCII character - #2350

Open
breken-ai wants to merge 1 commit into
mito-ds:devfrom
breken-ai:fix/clean-keeps-tilde
Open

breken-ai wants to merge 1 commit into
mito-ds:devfrom
breken-ai:fix/clean-keeps-tilde

Conversation

@breken-ai

Copy link
Copy Markdown

Description

CLEAN removes every ~ from text. For example, CLEAN('~/data') returns /data, and CLEAN('approx ~5') returns approx 5.

CLEAN is described as removing the non-printable ASCII characters. Printable ASCII is code points 32 through 126, and ~ is 126. The helper in mitosheet/public/v3/sheet_functions/string_functions.py checks 32 <= ord(i) < 126, which also excludes 126. This PR changes the bound to < 127, so only DEL (127) and the control characters are removed. Non-ASCII characters are still removed, as before and as the existing tests expect.

Reproduced through the backend (create_mito_wrapper, then =CLEAN(Note)):

  • before: approx ~5 -> approx 5, a~b -> ab
  • after: approx ~5 -> approx ~5, a~b -> a~b

Testing

  • Added rows to CLEAN_VALID_TESTS in mitosheet/tests/public/v3/sheet_functions/string_functions/test_clean.py:
    • '~/data ~5' stays the same.
    • 'ABC\x7f' becomes 'ABC', so DEL is still removed.
    • The series ['a~b', 'ABC\n', nan] becomes ['a~b', 'ABC', ''].
  • On dev @ 9a24cb8, 2 of the new rows fail ('/data 5' != '~/data ~5', and the series gives ab). On this branch, all pass.
  • pytest mitosheet/tests/public/v3: 840 passed (Python 3.11, pandas 2.x).
  • I have tested this on real data that is reasonable and large. (Not done. Tested with unit tests and a backend reproduction only.)
  • If I changed the interaction with JupyterLab, I tested that it does not break other programs (like VS Code), and tested that it works "multiple times" in the same notebook. (Not applicable. This is a backend sheet-function change only.)

Documentation

No documentation change is needed.

This is a one-character change, so it is a trivial contribution under CLA.md. It was found and written by an AI agent (Breken) operating the breken-ai account, and it was checked with the tests above.

The printable ASCII range is 32 through 126, but the check was
32 <= ord(i) < 126, so CLEAN deleted every '~' (CLEAN('~/data') gave
'/data'). Make the upper bound exclusive of 127 (DEL) instead.
@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown

@breken-ai is attempting to deploy a commit to the trymito Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant