Skip to content

gt.load.seaglider_show_variables doesn't work from command line #133

@callumrollo

Description

@callumrollo

gt.load.seaglider_show_variables uses pandas dataframe .style to make a pretty return. This will not work if run from plain python/command line application

To Reproduce

  1. Start a Python session from the command line and load glidertools import glidertools as gt
  2. Get some Seaglider .nc files and point at them filenames = 'data_marina/p*.nc'
  3. gt.load.seaglider_show_variables(filenames)
  4. Get the return:
    <pandas.io.formats.style.Styler at 0x7fe6bbf98af0>

Expected behavior
Print out a pretty table with all the variables in those .nc files

Cause

The styling commands at lines 53-59 of gt.load.seaglider:

    vars = (
        vars.sort_values(["dims", "name"])
        .reset_index(drop=True)
        .loc[:, ["dims", "name", "units", "comment"]]
        .set_index("name")
        .style
    )

System

  • Linux Ubuntu 20.04
  • Python from terminal session

Proposed fix

  • Detect if user is running jupyter-like environment. If not, simply print the table, don't style it.

Credit to Marina Azaneu at UEA for discovering this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions