benlubas/molten-nvim

[Bug] Virtual text wrap for pandas

Lun4m opened this issue · 2 comments

Lun4m commented
  • OS: Ubuntu 23.10
  • NeoVim Version: 0.9.1
  • Python Version: 3.11.6
  • Python is installed with: apt
  • Health checks
`:checkhealth molten`

==============================================================================
molten: require("molten.health").check()

molten-nvim ~

  • OK NeoVim >=0.9
  • OK Python >=3.10
  • OK Python module pynvim found
  • OK Python module jupyter-client found
  • OK Python module cairosvg found
  • WARNING Optional python module pnglatex not found
    • ADVICE:
      • pip install pnglatex
  • WARNING Optional python module plotly not found
    • ADVICE:
      • pip install plotly
  • WARNING Optional python module kaleido not found
    • ADVICE:
      • pip install kaleido
  • OK Python module pyperclip found
  • OK Python module nbformat found

Description

Not that big of a deal, but pandas Dataframe virtual text outputs wrap even if vim.g.molten_wrap_output = false.
I'm using molten as the REPL provider for NotebookNavigator.

Reproduction Steps

This wraps

import numpy as np
import pandas as pd
columns = ["sourceId", "referenceTime", "elementId", "value", "unit", "timeOffset", "someother", "another", "anotheroneone", "verylongname"]
df = pd.DataFrame(
    data={col: np.linspace(0, 10, 20) for col in columns},
)
print(df.head())

This does not wrap

print(100 * "-!-")

My molten config

{
  "benlubas/molten-nvim",
  version = "^1.0.0", -- use version <2.0.0 to avoid breaking changes
  dependencies = { "3rd/image.nvim" },
  build = ":UpdateRemotePlugins",
  init = function()
    vim.g.molten_image_provider = "image.nvim"
    vim.g.molten_virt_text_output = true
    vim.g.molten_virt_text_max_lines = 40
    vim.g.molten_wrap_output = false
  end,
}

Expected Behavior

In both cases output text should not be wrapped.

this is the way pandas formats it's output, not an issue with molten

Lun4m commented

Do you know if it's specifically for the jupyter protocol? Because if I put that snippet in a script and run it in the terminal the output doesn't wrap 🤔

Edit:
It seeems so, I just found out you need to add this for it to work in Jupyter

pd.set_option("display.expand_frame_repr", False)