# Path: cclib/io/wfxwriter.py
# def _section(section_name, section_data):
#     """Add opening/closing section_name tags to data."""
#     opening_tag = ['<' + section_name + '>']
#     closing_tag = ['</' + section_name + '>']
# 
#     section = None
#     if isinstance(section_data, list):
#         section = opening_tag + section_data + closing_tag
#     elif isinstance(section_data, str):
#         section = opening_tag + (' ' + section_data).split('\n') + closing_tag
#     elif isinstance(section_data, int) or isinstance(section_data, float):
#         section = opening_tag + [' ' + str(section_data)] + closing_tag
#     return section
# 
# Path: cclib/io/wfxwriter.py
# def _list_format(data, per_line, style=WFX_FIELD_FMT):
#     """Format lists for pretty print."""
#     template = style * per_line
#     leftover = len(data) % per_line
#     # Template for last line.
#     last_template = style * leftover
# 
#     pretty_list = [template%tuple(data[i:i+per_line])
#                     for i in range(0, len(data) - leftover, per_line)]
#     if leftover:
#         return pretty_list + [last_template%tuple(data[-1*leftover:])]
#     return  pretty_list


import os
import unittest
import numpy as np
import cclib
from cclib.io.filewriter import MissingAttributeError
from cclib.io.wfxwriter import _section
from cclib.io.wfxwriter import _list_format
        fpath_ref = os.path.join(__datadir__, ref_file)
        data_ref = cclib.io.ccread(fpath_ref)
        wfx_ref = cclib.io.wfxwriter.WFXWriter(data_ref)
        norm_mat_ref = wfx_ref._norm_mat()[0]
        mos_ref = wfx_ref._no_of_mos()

        for name in programs:
            fpath_prog = os.path.join(__datadir__, programs[name])
            data_prog = cclib.io.ccread(fpath_prog)
            wfx_prog = cclib.io.wfxwriter.WFXWriter(data_prog)

            norm_mat_prog = wfx_prog._norm_mat()[0]
            mos_prog = wfx_prog._no_of_mos()

            # Check if normalization matrix are matching.
            self.assertAlmostEqual(max(np.array(norm_mat_prog) -
                                       np.array(norm_mat_ref)), 0, places=5)
            # Check if number of orbitals to be printed are as expected.
            self.assertEqual(mos_prog, mos_ref)

    def test_section_printing(self):
        """Check if wfx section printing works as expected."""
        float_section = _section('Test Section', 123.456)
        expected = ['<Test Section>', ' 123.456', '</Test Section>']
        self.assertEqual(float_section, expected)

        list_section = _section('Test Section', ['1', '2'])
        expected = ['<Test Section>', '1', '2', '</Test Section>']
        self.assertEqual(list_section, expected)


# Path: cclib/io/wfxwriter.py
# def _section(section_name, section_data):
#     """Add opening/closing section_name tags to data."""
#     opening_tag = ['<' + section_name + '>']
#     closing_tag = ['</' + section_name + '>']
# 
#     section = None
#     if isinstance(section_data, list):
#         section = opening_tag + section_data + closing_tag
#     elif isinstance(section_data, str):
#         section = opening_tag + (' ' + section_data).split('\n') + closing_tag
#     elif isinstance(section_data, int) or isinstance(section_data, float):
#         section = opening_tag + [' ' + str(section_data)] + closing_tag
#     return section
# 
# Path: cclib/io/wfxwriter.py
# def _list_format(data, per_line, style=WFX_FIELD_FMT):
#     """Format lists for pretty print."""
#     template = style * per_line
#     leftover = len(data) % per_line
#     # Template for last line.
#     last_template = style * leftover
# 
#     pretty_list = [template%tuple(data[i:i+per_line])
#                     for i in range(0, len(data) - leftover, per_line)]
#     if leftover:
#         return pretty_list + [last_template%tuple(data[-1*leftover:])]
#     return  pretty_list


# Path: test/io/testwfxwriter.py
import os
import unittest
import numpy as np
import cclib
from cclib.io.filewriter import MissingAttributeError
from cclib.io.wfxwriter import _section
from cclib.io.wfxwriter import _list_format

        fpath_ref = os.path.join(__datadir__, ref_file)
        data_ref = cclib.io.ccread(fpath_ref)
        wfx_ref = cclib.io.wfxwriter.WFXWriter(data_ref)
        norm_mat_ref = wfx_ref._norm_mat()[0]
        mos_ref = wfx_ref._no_of_mos()

        for name in programs:
            fpath_prog = os.path.join(__datadir__, programs[name])
            data_prog = cclib.io.ccread(fpath_prog)
            wfx_prog = cclib.io.wfxwriter.WFXWriter(data_prog)

            norm_mat_prog = wfx_prog._norm_mat()[0]
            mos_prog = wfx_prog._no_of_mos()

            # Check if normalization matrix are matching.
            self.assertAlmostEqual(max(np.array(norm_mat_prog) -
                                       np.array(norm_mat_ref)), 0, places=5)
            # Check if number of orbitals to be printed are as expected.
            self.assertEqual(mos_prog, mos_ref)

    def test_section_printing(self):
        """Check if wfx section printing works as expected."""
        float_section = _section('Test Section', 123.456)
        expected = ['<Test Section>', ' 123.456', '</Test Section>']
        self.assertEqual(float_section, expected)

        list_section = _section('Test Section', ['1', '2'])
        expected = ['<Test Section>', '1', '2', '</Test Section>']
        self.assertEqual(list_section, expected)


        str_section = _section('Test Section', 'Test Data')