First time here? Check out the FAQ!

Revision history  [back]

How to Handle ANSI Escape Sequences in Stack Data display?

Hi everyone,

I'm currently using Wing Pro IDE for my Python development, and I've encountered an issue while debugging. When I inspect variables or print output in the Stack Data panel, I see a lot of ANSI escape sequences (e.g., ?[4m, ?[1m, ?[0;0m). These sequences are used for text formatting, like colors and styles, but they clutter the output and make it hard to read.

Is there a way to configure Wing Pro IDE to either interpret these sequences correctly or strip them out so that the output is clean and readable?

Here is an example of the output I'm seeing:

image description

The testing code is as follows:

# Now import pymatgen and other modules
from mp_api.client import MPRester
from pymatgen.io.vasp.sets import MPRelaxSet


# Use MPRester to fetch data
with MPRester() as mpr:
    # Search for materials with chemical system "Au" and space group number 225 (Fm-3m)
    #results = mpr.materials.search(formula="Au", spacegroup_number=225)
    results = mpr.materials.search(chemsys="Au", num_elements=(1, 1), spacegroup_number=225)
    #https://next-gen.materialsproject.org/materials/mp-568430?formula=BaRh2
    # results = mpr.materials.search(formula="BaRh2", spacegroup_number=227)

    # Print results
    for result in results:
        material_id = result.material_id
        print(f"Material ID: {material_id}, Formula: {result.formula_pretty}")

        # Get material structure
        structure = mpr.materials.get_structure_by_material_id(material_id)

        # Generate VASP input files using MPRelaxSet
        vasp_input_set = MPRelaxSet(structure)
        incar = vasp_input_set.incar

        # Print INCAR file content
        print(incar)

Any suggestions or guidance on how to handle this within Wing Pro would be greatly appreciated!

Thanks in advance for your help!

Best regards, Zhao

How to Handle ANSI Escape Sequences in Stack Data display?

Hi everyone,

I'm currently using Wing Pro IDE for my Python development, and I've encountered an issue while debugging. When I inspect variables or print output in the Stack Data panel, I see a lot of ANSI escape sequences (e.g., ?[4m, ?[1m, ?[0;0m). These sequences are used for text formatting, like colors and styles, but they clutter the output and make it hard to read.

Is there a way to configure Wing Pro IDE to either interpret these sequences correctly or strip them out so that the output is clean and readable?

Here is an example of the output I'm seeing:

image description

0 = ?[4m?[1mMPDataDoc<MaterialsDoc>?[0;0m?[0;0m(
builder_meta=EmmetMeta(emmet_version='0.71.0', pymatgen_version='2023.10.4', pull_request=990, database_version='2023.11.1', build_date=datetime.datetime(2023, 10, 18, 21, 17, 9, 357000), license='BY-C'),
...
)

The testing code is as follows:

# Now import pymatgen and other modules
from mp_api.client import MPRester
from pymatgen.io.vasp.sets import MPRelaxSet


# Use MPRester to fetch data
with MPRester() as mpr:
    # Search for materials with chemical system "Au" and space group number 225 (Fm-3m)
    #results = mpr.materials.search(formula="Au", spacegroup_number=225)
    results = mpr.materials.search(chemsys="Au", num_elements=(1, 1), spacegroup_number=225)
    #https://next-gen.materialsproject.org/materials/mp-568430?formula=BaRh2
    # results = mpr.materials.search(formula="BaRh2", spacegroup_number=227)

    # Print results
    for result in results:
        material_id = result.material_id
        print(f"Material ID: {material_id}, Formula: {result.formula_pretty}")

        # Get material structure
        structure = mpr.materials.get_structure_by_material_id(material_id)

        # Generate VASP input files using MPRelaxSet
        vasp_input_set = MPRelaxSet(structure)
        incar = vasp_input_set.incar

        # Print INCAR file content
        print(incar)

Any suggestions or guidance on how to handle this within Wing Pro would be greatly appreciated!

Thanks in advance for your help!

Best regards, Zhao