haochengxia / vscode-pydata-viewer

Display PyData files (.npz .npy .pkl .pth) in VSCode.
https://marketplace.visualstudio.com/items?itemName=Percy.vscode-pydata-viewer
MIT License
14 stars 8 forks source link

Improved pickel file output for simple datatypes. untested. #4

Closed JBrandonS closed 1 year ago

JBrandonS commented 1 year ago

I changed the output logic for pickel files only to use pprintpp or pprint if pprintpp is not installed. This allows for better output on basic datatypes. I also added a

 tag before the content to allow the tabs to stay.

For example

old:

{'cosmoFid': {'eta10': 6.123, 'N_nu': 3.0, 'tau': 879.4}, 'fisherGaussian': {0: {'unlensed': array([[ 5.06049552e+02, -2.55554979e+02, -8.78798042e-01],
[-2.55554979e+02, 1.41617640e+02, 6.27457347e-01],
[-8.78798042e-01, 6.27457347e-01, 4.21131257e-03]])}}, 'DALI3Gaussian': {0: {'unlensed': array([[[ 5.66979301e+02, -2.63640317e+02, -6.52961142e-01],

new:

{
    'DALI3Gaussian': {
        0: {
            'unlensed': array([[[ 5.66979301e+02, -2.63640317e+02, -6.52961142e-01],
                    [-3.50799589e+02,  2.18858592e+02,  1.21892504e+00],

I only tested this with simple pickel files containing a dict. It should be tested with other types at some point.

Cheers, Brandon

haochengxia commented 1 year ago

Thanks for your PR. Your advice indeed motivates me to add a feature which enables user to chose the formatting style of the output. I would review the code and consider the further improvement seriously.

haochengxia commented 1 year ago

Given that we have implemented functionality enabling users to utilize customized scripting, I will go ahead and close this pull request. Thank you.