def get_client_kwargs(self, path):
            assert path
            dummy_client_kwargs['path'] = path
            return dummy_client_kwargs
get_client_kwargs(self=<tests.test_io_system.test_system_base.<locals>.DummySystem object at 0x7ffa2009ff70>, path='directory/file', dummy_client_kwargs={'arg1': 1, 'arg2': 2}, self._client='client', self._roots=(re.compile('root2://'), 'root://', '://'), self._storage_parameters={'arg3': 3, 'arg4': 4}, self._unsecure=False)

{'arg1': 1, 'arg2': 2, 'path': 'directory/file'}


def put_object(key=None, data=None, **_):
            assert key.startswith(key_value)
            if key[-1] == '/':
                assert data == b''
            else:
                assert len(data) == len(ossobject._write_buffer)
            put_object_called.append(1)
put_object(key='key/', data=b'', _={}, key_value='key', ossobject=None, put_object_called=[])


def _get_roots(self):
        region = self._get_session().region_name or '[\w-]+'
        return (
                's3://',
                _re.compile('http://[\w.-]+\.s3\.amazonaws\.com'),
                _re.compile('http://[\w.-]+\.s3-%s\.amazonaws\.com' % region),
                _re.compile('http://s3\.amazonaws\.com'),
                _re.compile('http://s3-%s\.amazonaws\.com' % region))
_get_roots(self=<pycosio.storage.s3._S3System object at 0x7ffa0a47e550>, self._client=None, self._session=None, self._storage_parameters={}, self._unsecure=False)

<tests.test_s3.test_s3_raw_io.<locals>.Session object at 0x7ffa0a440220>


def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
    assert isinstance(commands, list)
    p = None
    for c in commands:
        try:
            dispcmd = str([c] + args)
            p = subprocess.Popen([c] + args, cwd=cwd, stdout=subprocess.PIPE,
                                 stderr=(subprocess.PIPE if hide_stderr
                                         else None))
            break
        except EnvironmentError:
            e = sys.exc_info()[1]
            if e.errno == errno.ENOENT:
                continue
            if verbose:
                print("unable to run %s" % dispcmd)
                print(e)
            return None
    else:
        if verbose:
            print("unable to find command, tried %s" % (commands,))
        return None
    stdout = p.communicate()[0].strip()
    if sys.version_info[0] >= 3:
        stdout = stdout.decode()
    if p.returncode != 0:
        if verbose:
            print("unable to run %s (error)" % dispcmd)
        return None
    return stdout
run_command(commands=['git'], args=['describe', '--tags', '--dirty', '--always', '--long'], cwd='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/danielfrg+datasciencebox/danielfrg+datasciencebox', verbose=False, hide_stderr=False)

<Popen: returncode: None args: ['git', 'describe', '--tags', '--dirty', '--a...>

<Popen: returncode: 0 args: ['git', 'describe', '--tags', '--dirty', '--alwa...>

"['git', 'describe', '--tags', '--dirty', '--always', '--long']"


"['git', 'describe', '--tags', '--dirty', '--always', '--long']"


p = subprocess.Popen([c] + args, cwd=cwd, stdout=subprocess.PIPE,

<Popen: returncode: None args: ['git', 'describe', '--tags', '--dirty', '--a...>


def get_logger_name(context=None):
        log_names = [root_logger_name, logger_name]
        if context is not None:
            log_names.insert(1,
                             context if isinstance(context,
                                                   string_types) else context.__class__.__name__)
        return '.'.join(log_names)
get_logger_name(context=None, logger_name='State')


def start_server(self):
        if self._socket is None:
            context = zmq.Context()
            self._socket = context.socket(zmq.REP)
            self._socket.bind('tcp://{0}:{1}'.format(self.host, self.port))
            self.log.info('Listening on %s:%s', self.host, self.port)
start_server(self=<lewis.core.control_server.ControlServer object at 0x7fba9d810790>, self._exposed_object=<lewis.core.control_server.ExposedObjectCollection object at 0x7fba9d6c15e0>, self._socket=None, self.host='127.0.0.1', self.port='10001')

Context: <MagicMock name='Context()' id='140439481752112'>


def _get_final_state_handlers(self, overrides):
        states = self._get_state_handlers()
        if overrides is not None:
            dict_strict_update(states, overrides)
        return states
_get_final_state_handlers(self=<lewis.devices.chopper.devices.device.SimulatedChopper object at 0x7fbaa1e458e0>, overrides={'invalid': <lewis.devices.chopper.devices.states.DefaultIdleState object at 0x7fbaa17d86a0>}, self._bearings=<lewis.devices.chopper.devices.device.SimulatedBearings object at 0x7fbaa1e454c0>, self._idle_commanded=False, self._initialized=False, self._park_commanded=False, self._phase_commanded=False, self._processors=[], self._shutdown_commanded=False, self._start_commanded=False, self._stop_commanded=False, self.auto_park=False, self.parking_position=0.0, self.phase=0.0, self.speed=0.0, self.target_parking_position=0.0, self.target_phase=0.0, self.target_speed=0.0)

{'init': <lewis.devices.chopper.devices.states.DefaultInitState object at 0x7fbaa1782f40>, 'bearings': {'in_state': <lewis.devices.chopper.devices.device.SimulatedBearings object at 0x7fbaa1e454c0>}, 'stopped': <lewis.devices.chopper.devices.states.DefaultStoppedState object at 0x7fbaa1782fd0>, 'stopping': <lewis.devices.chopper.devices.states.DefaultStoppingState object at 0x7fbaa1782190>, 'accelerating': <lewis.devices.chopper.devices.states.DefaultAcceleratingState object at 0x7fbaa1782ee0>, 'phase_locking': <lewis.devices.chopper.devices.states.DefaultPhaseLockingState object at 0x7fbaa1782d60>, 'phase_locked': <lewis.devices.chopper.devices.states.DefaultPhaseLockedState object at 0x7fbaa17821c0>, 'idle': <lewis.devices.chopper.devices.states.DefaultIdleState object at 0x7fbaa1782d00>, 'parking': <lewis.devices.chopper.devices.states.DefaultParkingState object at 0x7fbaa1782e20>, 'parked': <lewis.devices.chopper.devices.states.DefaultParkedState object at 0x7fbaa1782dc0>}


def _get_final_transition_handlers(self, overrides):
        transitions = self._get_transition_handlers()
        if overrides is not None:
            dict_strict_update(transitions, overrides)
        return transitions
_get_final_transition_handlers(self=<lewis.devices.chopper.devices.device.SimulatedChopper object at 0x7fbaa1782250>, overrides={('idle', 'phase_locking'): <function TestSimulatedChopper.test_invalid_transition_override_fails.<locals>.<lambda> at 0x7fbaa1a5c820>}, self._bearings=<lewis.devices.chopper.devices.device.SimulatedBearings object at 0x7fbaa17821f0>, self._idle_commanded=False, self._initialized=False, self._park_commanded=False, self._phase_commanded=False, self._processors=[], self._shutdown_commanded=False, self._start_commanded=False, self._stop_commanded=False, self.auto_park=False, self.parking_position=0.0, self.phase=0.0, self.speed=0.0, self.target_parking_position=0.0, self.target_phase=0.0, self.target_speed=0.0)

OrderedDict([(('init', 'bearings'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa13c3dc0>), (('bearings', 'stopped'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa13c3e50>), (('bearings', 'init'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa13c3d30>), (('parking', 'parked'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17848b0>), (('parking', 'stopping'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa13c3ee0>), (('parked', 'stopping'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa13c3f70>), (('parked', 'accelerating'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa13c3b80>), (('stopped', 'accelerating'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa13c3ca0>), (('stopped', 'parking'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa13c3c10>), (('stopped', 'bearings'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17844c0>), (('accelerating', 'stopping'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e7280>), (('accelerating', 'idle'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e7310>), (('accelerating', 'phase_locking'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e73a0>), (('idle', 'accelerating'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e7430>), (('idle', 'stopping'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e74c0>), (('phase_locking', 'stopping'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e7550>), (('phase_locking', 'phase_locked'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e75e0>), (('phase_locking', 'idle'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e7670>), (('phase_locked', 'accelerating'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e7700>), (('phase_locked', 'phase_locking'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e7790>), (('phase_locked', 'stopping'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e7820>), (('phase_locked', 'idle'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e78b0>), (('stopping', 'accelerating'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e7940>), (('stopping', 'stopped'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e79d0>), (('stopping', 'idle'), <function SimulatedChopper._get_transition_handlers.<locals>.<lambda> at 0x7fbaa17e7a60>)])


def limit_checked(obj, new_value):
            lower = getattr(obj, self._lower) if isinstance(self._lower,
                                                            string_types) else self._lower
            upper = getattr(obj, self._upper) if isinstance(self._upper,
                                                            string_types) else self._upper
            if (lower is None or lower <= new_value) and (upper is None or new_value <= upper):
                return f(obj, new_value)
            if not self._silent:
                raise LimitViolationException(
                    '%f is outside limits (%r, %r)' % (new_value, lower, upper))
limit_checked(obj={_processors=[<lewis.core.statemachine.StateMachine object at 0x7fbaa17d8760>], _csm=<lewis.core.statemachine.StateMachine object at 0x7fbaa17d8760>}, new_value=10, f=<function SimulatedJulabo.set_external_d at 0x7fbaa1ce4a60>, self=<lewis.core.utils.check_limits object at 0x7fbaa1d41430>, self._lower=0, self._silent=False, self._upper=999)

{_processors=[<lewis.core.statemachine.StateMachine object at 0x7fbaa17d8760>], _csm=<lewis.core.statemachine.StateMachine object at 0x7fbaa17d8760>, external_d=10}


upper = getattr(obj, self._upper) if isinstance(self._upper,


def _bind_commands(self, cmds):
        patterns = set()
        bound_commands = []
        for cmd in cmds:
            bound = cmd.bind(self) or cmd.bind(self.device) or None
            if bound is None:
                raise RuntimeError(
                    'Unable to produce callable object for non-existing member \'{}\' '
                    'of device or interface.'.format(cmd.func))
            for bound_cmd in bound:
                if bound_cmd.pattern in patterns:
                    raise RuntimeError(
                        'The regular expression {} is '
                        'associated with multiple commands.'.format(bound_cmd.pattern.pattern))
                patterns.add(bound_cmd.pattern)
                bound_commands.append(bound_cmd)
        return bound_commands
_bind_commands(self=<lewis.devices.linkam_t95.interfaces.stream_interface.LinkamT95StreamInterface object at 0x7fbaa1d3edf0>, cmds={<lewis.adapters.stream.Cmd object at 0x7fbaa1cb6c10>, <lewis.adapters.stream.Cmd object at 0x7fbaa1cb6a90>, <lewis.adapters.stream.Cmd object at 0x7fbaa1cb6ca0>, <lewis.adapters.stream.Cmd object at 0x7fbaa1cb6eb0>, <lewis.adapters.stream.Cmd object at 0x7fbaa1cb6af0>, <lewis.adapters.stream.Cmd object at 0x7fbaa1cb6f10>, <lewis.adapters.stream.Cmd object at 0x7fbaa1cb6f70>, <lewis.adapters.stream.Cmd object at 0x7fbaa1cb6b80>, <lewis.adapters.stream.Cmd object at 0x7fbaa1cb61c0>}, self._bound_commands=[], self._device=<lewis.devices.linkam_t95.devices.device.SimulatedLinkamT95 object at 0x7fbaa1d3e0d0>, self._options=Namespace(bind_address='0.0.0.0', port=9999, telnet_mode=False), self._server=None)

[<lewis.adapters.stream.Func object at 0x7fbaa1d3efd0>]

[<lewis.adapters.stream.Func object at 0x7fbaa1d3efd0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3efa0>]

[<lewis.adapters.stream.Func object at 0x7fbaa1d3efd0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3efa0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3e190>]

[<lewis.adapters.stream.Func object at 0x7fbaa1d3efd0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3efa0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3e190>, <lewis.adapters.stream.Func object at 0x7fbaa1d3edc0>]

[<lewis.adapters.stream.Func object at 0x7fbaa1d3efd0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3efa0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3e190>, <lewis.adapters.stream.Func object at 0x7fbaa1d3edc0>, <lewis.adapters.stream.Func object at 0x7fbaa17e2730>]

[<lewis.adapters.stream.Func object at 0x7fbaa1d3efd0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3efa0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3e190>, <lewis.adapters.stream.Func object at 0x7fbaa1d3edc0>, <lewis.adapters.stream.Func object at 0x7fbaa17e2730>, <lewis.adapters.stream.Func object at 0x7fbaa17e2a90>]

[<lewis.adapters.stream.Func object at 0x7fbaa1d3efd0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3efa0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3e190>, <lewis.adapters.stream.Func object at 0x7fbaa1d3edc0>, <lewis.adapters.stream.Func object at 0x7fbaa17e2730>, <lewis.adapters.stream.Func object at 0x7fbaa17e2a90>, <lewis.adapters.stream.Func object at 0x7fbaa17e2d60>]

[<lewis.adapters.stream.Func object at 0x7fbaa1d3efd0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3efa0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3e190>, <lewis.adapters.stream.Func object at 0x7fbaa1d3edc0>, <lewis.adapters.stream.Func object at 0x7fbaa17e2730>, <lewis.adapters.stream.Func object at 0x7fbaa17e2a90>, <lewis.adapters.stream.Func object at 0x7fbaa17e2d60>, <lewis.adapters.stream.Func object at 0x7fbaa17e2250>]

[<lewis.adapters.stream.Func object at 0x7fbaa1d3efd0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3efa0>, <lewis.adapters.stream.Func object at 0x7fbaa1d3e190>, <lewis.adapters.stream.Func object at 0x7fbaa1d3edc0>, <lewis.adapters.stream.Func object at 0x7fbaa17e2730>, <lewis.adapters.stream.Func object at 0x7fbaa17e2a90>, <lewis.adapters.stream.Func object at 0x7fbaa17e2d60>, <lewis.adapters.stream.Func object at 0x7fbaa17e2250>, <lewis.adapters.stream.Func object at 0x7fbaa17e2c40>]

{func='set_limit', pattern='^L1([0-9]+)$', argument_mappings=None, doc=None}

{func='set_rate', pattern='^R1([0-9]+)$', argument_mappings=None, doc=None}

{func='stop', pattern='^E$', argument_mappings=None, doc=None}

{func='cool', pattern='^C$', argument_mappings=None, doc=None}

{func='hold', pattern='^O$', argument_mappings=None, doc=None}

{func='heat', pattern='^H$', argument_mappings=None, doc=None}

{func='pump_command', pattern='^P(a0|m0|[0123456789:;<=>?@ABCDEFGHIJKLMN]{1})$', argument_mappings=None, doc=None}

{func='start', pattern='^S$', argument_mappings=None, doc=None}

{func='get_status', pattern='^T$', argument_mappings=None, doc=None}

[<lewis.adapters.stream.Func object at 0x7fbaa1d3efa0>]

[<lewis.adapters.stream.Func object at 0x7fbaa1d3e190>]

[<lewis.adapters.stream.Func object at 0x7fbaa1d3edc0>]

[<lewis.adapters.stream.Func object at 0x7fbaa17e2730>]

[<lewis.adapters.stream.Func object at 0x7fbaa17e2a90>]

[<lewis.adapters.stream.Func object at 0x7fbaa17e2d60>]

[<lewis.adapters.stream.Func object at 0x7fbaa17e2250>]

[<lewis.adapters.stream.Func object at 0x7fbaa17e2c40>]

{raw_pattern='^L1([0-9]+)$', pattern=re.compile(b'^L1([0-9]+)$'), argument_mappings=None, doc='Models "Limit Command" functionality of device.\n\nSets the target temperate to be reached.\n\n:param param: Target temperature in C, multiplied by 10, as a string. Can be negative.\n:return: Empty string.'}

{raw_pattern='^R1([0-9]+)$', pattern=re.compile(b'^R1([0-9]+)$'), argument_mappings=None, doc='Models "Rate Command" functionality of device.\n\nSets the target rate of temperature change.\n\n:param param: Rate of temperature change in C/min, multiplied by 100, as a string.\nMust be positive.\n:return: Empty string.'}

{raw_pattern='^E$', pattern=re.compile(b'^E$'), argument_mappings=None, doc='Models "Stop Command" functionality of device.\n\nTells the T95 unit to stop heating or cooling.\n\n:return: Empty string.'}

{raw_pattern='^C$', pattern=re.compile(b'^C$'), argument_mappings=None, doc='Models "Cool Command" functionality of device.\n\n:return: Empty string.'}

{raw_pattern='^O$', pattern=re.compile(b'^O$'), argument_mappings=None, doc='Models "Hold Command" functionality of device.\n\nDevice will hold current temperature until a heat or cool command is issued.\n\n:return: Empty string.'}

{raw_pattern='^H$', pattern=re.compile(b'^H$'), argument_mappings=None, doc='Models "Heat Command" functionality of device.\n\n:return: Empty string.'}

{raw_pattern='^P(a0|m0|[0123456789:;<=>?@ABCDEFGHIJKLMN]{1})$', pattern=re.compile(b'^P(a0|m0|[0123456789:;<=>?@ABCDEFGHIJKLMN]{1})$'), argument_mappings=None, doc='Models "LNP Pump Commands" functionality of device.\n\nSwitches between automatic or manual pump mode, and adjusts speed when in manual mode.\n\n:param param: \'a0\' for auto, \'m0\' for manual, [0-N] for speed.\n:return:'}

{raw_pattern='^S$', pattern=re.compile(b'^S$'), argument_mappings=None, doc='Models "Start Command" functionality of device.\n\nTells the T95 unit to start heating or cooling at the rate specified by setRate and to a\nlimit set by setLimit.\n\n:return: Empty string.'}

{raw_pattern='^T$', pattern=re.compile(b'^T$'), argument_mappings=None, doc='Models "T Command" functionality of device.\n\nReturns all available status information about the device as single byte array.\n\n:return: Byte array consisting of 10 status bytes.'}


def stop_server(self):
        self._running = False
stop_server(self=<test.test_core_adapters.DummyAdapter object at 0x7fba9d325ee0>, self._device=None, self._running=True, self.protocol='foo')


def _discover_setups(self, setups_package):
        setups = getattr(self._module, 'setups', {})
        all_setups = setups if isinstance(setups, dict) else {}
        if setups_package is not None:
            for name, setup_module in get_submodules(setups_package).items():
                existing_setup = all_setups.get(name)
                if existing_setup is not None:
                    raise RuntimeError(
                        'The setup \'{}\' is defined twice in device \'{}\'.'.format(
                            existing_setup, self.name))
                all_setups[name] = {
                    'device_type': getattr(setup_module, 'device_type', self.default_device_type),
                    'parameters': getattr(setup_module, 'parameters', {})
                }
        if 'default' not in all_setups:
            all_setups['default'] = {'device_type': self.default_device_type}
        return all_setups
_discover_setups(self=<lewis.core.devices.DeviceBuilder object at 0x7fbaa2f019d0>, setups_package=None, self._device_types=[<class 'test.test_core_devices.TestDeviceBuilderSimpleModule.setUpClass.<locals>.DummyDevice'>], self._module=<module 'simple_dummy_module'>)


def _discover_interfaces(self, interface_package):
        all_interfaces = []
        if interface_package is not None:
            for interface_module in get_submodules(interface_package).values():
                all_interfaces += list(get_members(interface_module, is_adapter).values())
        all_interfaces += list(get_members(self._module, is_adapter).values())
        interfaces = {}
        for interface in all_interfaces:
            existing_interface = interfaces.get(interface.protocol)
            if existing_interface is not None:
                raise RuntimeError(
                    'The protocol \'{}\' is defined in two interfaces for device \'{}\':\n'
                    '    {} (in {})\n'
                    '    {} (in {})\n'
                    'One of the protocol names needs to be changed.'.format(
                        interface.protocol, self.name, existing_interface.__name__,
                        existing_interface.__module__, interface.__name__, interface.__module__))
            interfaces[interface.protocol] = interface
        return interfaces
_discover_interfaces(self=<lewis.core.devices.DeviceBuilder object at 0x7fbaa2f019d0>, interface_package=None, self._device_types=[<class 'test.test_core_devices.TestDeviceBuilderSimpleModule.setUpClass.<locals>.DummyDevice'>], self._module=<module 'simple_dummy_module'>, self._setups={'default': {'device_type': <class 'test.test_core_devices.TestDeviceBuilderSimpleModule.setUpClass.<locals>.DummyDevice'>}})


def pause(self):
        if not self._running:
            raise RuntimeError('Can only pause a running simulation.')
        self.log.info('Pausing simulation')
        self._running = False
pause(self=<lewis.core.simulation.Simulation object at 0x7fbaa1b6c6d0>, self._adapters=<lewis.core.adapters.AdapterCollection object at 0x7fbaa1b6ca60>, self._control_server=None, self._cycle_delay=0.1, self._cycles=0, self._device=<Mock id='140439553755216'>, self._running=False, self._runtime=0.0, self._speed=1.0, self._start_time=None, self._started=False, self._stop_commanded=False)


def start(self):
        self.log.info('Starting simulation')
        self._running = True
        self._started = True
        self._stop_commanded = False
        if self._control_server is not None:
            self._control_server.start_server()
        self._adapters.connect()
        self._start_time = datetime.now()
        delta = 0.0
        while not self._stop_commanded:
            delta = self._process_cycle(delta)
        self._running = False
        self._started = False
        self._adapters.disconnect()
start(self=<lewis.core.simulation.Simulation object at 0x7fba9d7d1ac0>, self._adapters=<lewis.core.adapters.AdapterCollection object at 0x7fba9d7d1e80>, self._control_server=<Mock id='140439482866800'>, self._cycle_delay=0.1, self._cycles=0, self._device=<Mock id='140439482866224'>, self._process_cycle=<Mock id='140439482865792'>, self._running=False, self._runtime=0.0, self._speed=1.0, self._start_time=None, self._started=False, self._stop_commanded=False)


def set_baz(self, new_baz):
                self.baz = new_baz
set_baz(self=<test.test_utils.TestCheckLimits.test_upper_lower_only.<locals>.Foo object at 0x7fba9c870fa0>, new_baz=0, self.bar=-5)


def test_addremove_header_array_obj(self):
        shutil.copy2(TestHarFileObj._dd + "test.har", "test_remove_header_array.har")
        hfo = HarFileObj._loadFromDisk("test_remove_header_array.har")
        hao = hfo._removeHeaderArrayObjs("INTA")
        hn = hfo.getHeaderArrayNames()
        test_hn = ['XXCD', 'XXCR', 'XXCP', 'XXHS', 'CHST', 'SIMP', 'SIM2', 'NH01', 'ARR7']
        self.assertTrue(all([x == y for (x, y) in zip(hn, test_hn)]))
        hfo._addHeaderArrayObjs("INTA", hao)
        with self.assertRaises(HarFileObj.InvalidHeaderArrayName):
            hfo._addHeaderArrayObjs("TOO LONG NAME", hao)
        hn = hfo.getHeaderArrayNames()
        test_hn = ['XXCD', 'XXCR', 'XXCP', 'XXHS', 'CHST', 'SIMP', 'SIM2', 'NH01', 'ARR7', 'INTA']
        self.assertTrue(all([x == y for (x, y) in zip(hn, test_hn)]))
        os.remove("test_remove_header_array.har")
test_addremove_header_array_obj(self=<harpy.tests.test_har_file.TestHarFileObj testMethod=test_addremove_header_array_obj>, self._cleanups=[], self._outcome=<unittest.case._Outcome object at 0x7fd0b7249f10>, self._subtest=None, self._testMethodDoc=None, self._testMethodName='test_addremove_header_array_obj', self._type_equality_funcs={<class 'dict'>: 'assertDictEqual', <class 'list'>: 'assertListEqual', <class 'tuple'>: 'assertTupleEqual', <class 'set'>: 'assertSetEqual', <class 'frozenset'>: 'assertSetEqual', <class 'str'>: 'assertMultiLineEqual'}, self.test_addremove_header_array_obj=<bound method TestHarFileObj.test_addremove_header_array_obj of <harpy.tests.test_har_file.TestHarFileObj testMethod=test_addremove_header_array_obj>>)

{_head_arrs=OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd016334340>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd016391ca0>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd016391430>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd016391df0>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd0163914f0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd016391f10>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f1f0>)]), filename='test_remove_header_array.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>}

{_head_arrs=OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd016334340>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd016391ca0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd016391df0>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd0163914f0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd016391f10>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f1f0>)]), filename='test_remove_header_array.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>}

{_head_arrs=OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd016334340>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd016391ca0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd016391df0>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd0163914f0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd016391f10>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f1f0>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd016391430>)]), filename='test_remove_header_array.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>}

[<harpy.header_array.HeaderArrayObj object at 0x7fd016391430>]


def readHarFileInfo(filename: str) -> HarFileInfoObj:
        hfiObj = HarFileInfoObj(file=filename)
        with open(filename, "rb") as f:
            f.seek(0)
            while True:
                pos, name, end_pos = HarFileIO._readHeaderPosName(f)
                if not name:
                    break
                hfiObj.addHAInfo(name, pos, end_pos)
                hfi=hfiObj.ha_infos[name]
                (hfi.version, hfi.data_type, hfi.storage_type,  hfi.long_name, hfi.file_dims) = HarFileIO._getHeaderInfo(f, name)
        return hfiObj
readHarFileInfo(filename='test_remove_header_array.har')

{filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har', _mtime=1708906163.399167, _ha_infos=OrderedDict([('XXCD', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334730>), ('XXCR', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163345e0>)])}

{filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har', _mtime=1708906163.399167, _ha_infos=OrderedDict([('XXCD', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334730>), ('XXCR', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163345e0>), ('XXCP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163347c0>)])}

{filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har', _mtime=1708906163.399167, _ha_infos=OrderedDict([('XXCD', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334730>), ('XXCR', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163345e0>), ('XXCP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163347c0>), ('XXHS', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334910>)])}

{filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har', _mtime=1708906163.399167, _ha_infos=OrderedDict([('XXCD', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334730>), ('XXCR', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163345e0>), ('XXCP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163347c0>), ('XXHS', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334910>), ('CHST', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163340a0>)])}

{filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har', _mtime=1708906163.399167, _ha_infos=OrderedDict([('XXCD', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334730>), ('XXCR', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163345e0>), ('XXCP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163347c0>), ('XXHS', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334910>), ('CHST', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163340a0>), ('INTA', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334280>)])}

{filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har', _mtime=1708906163.399167, _ha_infos=OrderedDict([('XXCD', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334730>), ('XXCR', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163345e0>), ('XXCP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163347c0>), ('XXHS', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334910>), ('CHST', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163340a0>), ('INTA', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334280>), ('SIMP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163341c0>)])}

{filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har', _mtime=1708906163.399167, _ha_infos=OrderedDict([('XXCD', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334730>), ('XXCR', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163345e0>), ('XXCP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163347c0>), ('XXHS', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334910>), ('CHST', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163340a0>), ('INTA', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334280>), ('SIMP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163341c0>), ('SIM2', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163503a0>)])}

{filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har', _mtime=1708906163.399167, _ha_infos=OrderedDict([('XXCD', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334730>), ('XXCR', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163345e0>), ('XXCP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163347c0>), ('XXHS', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334910>), ('CHST', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163340a0>), ('INTA', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334280>), ('SIMP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163341c0>), ('SIM2', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163503a0>), ('NH01', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016350430>)])}

{filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har', _mtime=1708906163.399167, _ha_infos=OrderedDict([('XXCD', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334730>), ('XXCR', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163345e0>), ('XXCP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163347c0>), ('XXHS', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334910>), ('CHST', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163340a0>), ('INTA', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334280>), ('SIMP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163341c0>), ('SIM2', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163503a0>), ('NH01', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016350430>), ('ARR7', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163342b0>)])}

{name='XXCD', pos_name=0, pos_data=12, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=0, data_type=None, storage_type=None, long_name=None, file_dims=None, sets=None, coeff_name=None}

{name='XXCD', pos_name=0, pos_data=12, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=1, data_type='1C', storage_type='FULL', long_name='Creation Date and Time                                                ', file_dims=(1, 70), sets=None, coeff_name=None}

{name='XXCR', pos_name=206, pos_data=218, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=0, data_type=None, storage_type=None, long_name=None, file_dims=None, sets=None, coeff_name=None}

{name='XXCR', pos_name=206, pos_data=218, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=1, data_type='1C', storage_type='FULL', long_name='Creating Program                                                      ', file_dims=(2, 70), sets=None, coeff_name=None}

{name='XXCP', pos_name=482, pos_data=494, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=0, data_type=None, storage_type=None, long_name=None, file_dims=None, sets=None, coeff_name=None}

{name='XXCP', pos_name=482, pos_data=494, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=1, data_type='1C', storage_type='FULL', long_name='compiler used to make EXE which created this file                     ', file_dims=(1, 6), sets=None, coeff_name=None}

{name='XXHS', pos_name=624, pos_data=636, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=0, data_type=None, storage_type=None, long_name=None, file_dims=None, sets=None, coeff_name=None}

{name='XXHS', pos_name=624, pos_data=636, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=1, data_type='1C', storage_type='FULL', long_name='File History                                                          ', file_dims=(53, 60), sets=None, coeff_name=None}

{name='CHST', pos_name=3940, pos_data=3952, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=0, data_type=None, storage_type=None, long_name=None, file_dims=None, sets=None, coeff_name=None}

{name='CHST', pos_name=3940, pos_data=3952, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=1, data_type='1C', storage_type='FULL', long_name='Simple set of strings                                                 ', file_dims=(5, 12), sets=None, coeff_name=None}

{name='INTA', pos_name=4136, pos_data=4148, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=0, data_type=None, storage_type=None, long_name=None, file_dims=None, sets=None, coeff_name=None}

{name='INTA', pos_name=4136, pos_data=4148, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=1, data_type='2I', storage_type='FULL', long_name='2D integer array                                                      ', file_dims=(4, 4), sets=None, coeff_name=None}

{name='SIMP', pos_name=4352, pos_data=4364, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=0, data_type=None, storage_type=None, long_name=None, file_dims=None, sets=None, coeff_name=None}

{name='SIMP', pos_name=4352, pos_data=4364, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=1, data_type='1C', storage_type='FULL', long_name='Set SimpleSet Simple 2 item set                                       ', file_dims=(2, 1), sets=None, coeff_name=None}

{name='SIM2', pos_name=4490, pos_data=4502, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=0, data_type=None, storage_type=None, long_name=None, file_dims=None, sets=None, coeff_name=None}

{name='SIM2', pos_name=4490, pos_data=4502, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=1, data_type='1C', storage_type='FULL', long_name='Set SimpleSet2 Simple set 2                                           ', file_dims=(2, 2), sets=None, coeff_name=None}

{name='NH01', pos_name=4630, pos_data=4642, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=0, data_type=None, storage_type=None, long_name=None, file_dims=None, sets=None, coeff_name=None}

{name='NH01', pos_name=4630, pos_data=4642, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=1, data_type='RE', storage_type='FULL', long_name='Simple 2 dimensional array                                            ', file_dims=(2, 2, 1, 1, 1, 1, 1), sets=None, coeff_name=None}

{name='ARR7', pos_name=5088, pos_data=5100, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=0, data_type=None, storage_type=None, long_name=None, file_dims=None, sets=None, coeff_name=None}

{name='ARR7', pos_name=5088, pos_data=5100, parent_har_file=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, version=1, data_type='RE', storage_type='FULL', long_name='7-Dimensional Array                                                   ', file_dims=(2, 2, 2, 2, 2, 2, 2), sets=None, coeff_name=None}


def _readHeaderPosName(fp: BinaryIO):
        pos = fp.tell()
        data = ''
        while True:
            Hpos = pos
            nbyte = HarFileIO._getEntrySize(fp)
            if not nbyte: break
            data = fp.read(4).strip()
            if data:
                data += fp.read(nbyte - 4)
                HarFileIO._checkRead(fp, nbyte)
                break
            data = None
            pos = pos + 8 + nbyte
            fp.seek(pos - 4)
            HarFileIO._checkRead(fp, nbyte)
        return Hpos, fb(data), fp.tell()
_readHeaderPosName(fp=<_io.BufferedReader name='test_remove_header_array.har'>)


def readHeaderArraysFromFile(hfi: HarFileInfoObj, ha_names: 'Union[None, str, List[str]]' = None, readData=False):
        if ha_names is None:
            ha_names = hfi.getHeaderArrayNames()
        elif isinstance(ha_names, str):
            ha_names = [ha_names]
        haos = []
        for ha_name in ha_names or readData:
            haos.append(HarFileIO.readHeader(hfi=hfi, header_name=ha_name))
        return ha_names, haos
readHeaderArraysFromFile(hfi={filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har', _mtime=1708906163.399167, _ha_infos=OrderedDict([('XXCD', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334730>), ('XXCR', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163345e0>), ('XXCP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163347c0>), ('XXHS', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334910>), ('CHST', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163340a0>), ('INTA', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016334280>), ('SIMP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163341c0>), ('SIM2', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163503a0>), ('NH01', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016350430>), ('ARR7', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd0163342b0>)])}, ha_names=None, readData=False)

['XXCD', 'XXCR', 'XXCP', 'XXHS', 'CHST', 'INTA', 'SIMP', 'SIM2', 'NH01', 'ARR7']

[<harpy.header_array.HeaderArrayObj object at 0x7fd016334340>]

[<harpy.header_array.HeaderArrayObj object at 0x7fd016334340>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>]

[<harpy.header_array.HeaderArrayObj object at 0x7fd016334340>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>]

[<harpy.header_array.HeaderArrayObj object at 0x7fd016334340>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>]

[<harpy.header_array.HeaderArrayObj object at 0x7fd016334340>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391ca0>]

[<harpy.header_array.HeaderArrayObj object at 0x7fd016334340>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391ca0>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391430>]

[<harpy.header_array.HeaderArrayObj object at 0x7fd016334340>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391ca0>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391430>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391df0>]

[<harpy.header_array.HeaderArrayObj object at 0x7fd016334340>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391ca0>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391430>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391df0>, <harpy.header_array.HeaderArrayObj object at 0x7fd0163914f0>]

[<harpy.header_array.HeaderArrayObj object at 0x7fd016334340>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391ca0>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391430>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391df0>, <harpy.header_array.HeaderArrayObj object at 0x7fd0163914f0>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391f10>]

[<harpy.header_array.HeaderArrayObj object at 0x7fd016334340>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391ca0>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391430>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391df0>, <harpy.header_array.HeaderArrayObj object at 0x7fd0163914f0>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391f10>, <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f1f0>]


def _setHeaderBaseData(array, coeff_name, hao, long_name) -> None:
        if not isinstance(array, (np.ndarray, np.float32, np.int32,np.float64)):
            print(type(array))
            raise HeaderArrayObj.UnsupportedArrayType("'array' must be of numpy.ndarray type.")
        if coeff_name is None:
            coeff_name = " " * 12
        if long_name is None:
            long_name = coeff_name
        if len(coeff_name) < 12:
            coeff_name = coeff_name.ljust(12)
        if len(long_name) < 70:
            long_name = long_name.ljust(70)
        hao.array = array
        hao.coeff_name = coeff_name
        hao.long_name = long_name
_setHeaderBaseData(array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), coeff_name=None, hao={_coeff_name='', _array=None, _sets=None, _long_name=''}, long_name='Creation Date and Time                                                ')

'Creation Date and Time                                                '

{_coeff_name='            ', _array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), _sets=None, _long_name='Creation Date and Time                                                '}


def _readSets(fp: BinaryIO, file_dims=None) -> (str,_HeaderDims):
        Coefficient, SetList, SetStatus, ElementList = HarFileIO._readSetElementInfoRecord(fp)
        set_names = [name.strip() for name in SetList]
        idim = 0
        header_sets = []
        processedSet = OrderedDict()
        for name, status in zip(set_names, SetStatus):
            if status == 'k':
                if name not in processedSet:
                    processedSet[name] = HarFileIO._readCharVec(fp, itemsize=12, use_unicode=is_unicode, size=tuple([file_dims[idim]]), dtype="<U12")
                header_sets.append(_HeaderSet(name=name, status=status, dim_desc=[item.strip() for item in processedSet[name]], dim_size= file_dims[idim]))
            elif status == 'u':
                header_sets.append(_HeaderSet(name=name, status=status, dim_desc=None, dim_size= file_dims[idim]))
            elif status == 'e':
                header_sets.append(_HeaderSet(name=name, status=status, dim_desc=ElementList.pop(0), dim_size= file_dims[idim]))
            idim += 1
        return Coefficient, _HeaderDims(header_sets)
_readSets(fp=<_io.BufferedReader name='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har'>, file_dims=(2, 2, 1, 1, 1, 1, 1))

[<harpy._header_sets._HeaderSet object at 0x7fd016391130>]

[<harpy._header_sets._HeaderSet object at 0x7fd016391130>, <harpy._header_sets._HeaderSet object at 0x7fd0163912e0>]

OrderedDict([('SimpleSet', array(['A           ', 'B           '], dtype='<U12'))])

OrderedDict([('SimpleSet', array(['A           ', 'B           '], dtype='<U12')), ('SimpleSet2', array(['I           ', 'II          '], dtype='<U12'))])


def _readSetElementInfoRecord(fp):
        SetNames = []
        ElementList = []
        SetStatus = []
        nbyte = HarFileIO._getEntrySize(fp)
        dataForm = '=' + '4siii12si'
        V = HarFileIO._unpack_data(fp, dataForm)
        if fb(V[0]) != '    ':
            raise RuntimeError("Encountered characters at first four positions at SetEl")
        NSets = V[3]
        Coefficient = fb(V[4])
        setKnown=V[5]!=0
        if not setKnown:
            dataForm = '=i'
        else:
            dataForm = "=" + str(NSets * 12) + 's' + str(NSets) + 's' + str(NSets) + 'i' + 'i'
        V = HarFileIO._unpack_data(fp, dataForm)
        if setKnown:
            SetNames = [fb(V[0][i:i + 12]) for i in range(0, NSets * 12, 12)]
            SetStatus = [fb(V[1][i:i + 1]) for i in range(0, NSets)]
        Nexplicit = V[-1]
        dataForm = '=' + str(Nexplicit * 12) + 's'
        V = HarFileIO._unpack_data(fp, dataForm)
        if Nexplicit > 0:
            dataForm = '=' + str(Nexplicit * 12) + 's'
            V = HarFileIO._unpack_data(fp, dataForm)
            ElementList = [fb(V[-1][i:i + 12]) for i in range(0, NSets * 12, 12)]
        HarFileIO._checkRead(fp, nbyte)
        return Coefficient, SetNames, SetStatus, ElementList
_readSetElementInfoRecord(fp=<_io.BufferedReader name='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har'>)

(b'SimpleSet   SimpleSet2  ', b'kk', 0, 0, 0)


def _readREFullObj(fp, array, dtype):
        nbyte = HarFileIO._getEntrySize(fp)
        dataForm = '=4sii'
        V = HarFileIO._unpack_data(fp, dataForm)
        if fb(V[0]) != '    ':
            raise Exception("Encountered characters at read7D[1]")
        nrec = V[1]
        NDim = V[2]
        dataForm = "=" + ('i' * NDim)
        V = HarFileIO._unpack_data(fp, dataForm)
        if nbyte != HarFileIO._getEntrySize(fp):
            raise RuntimeError("Header corrupted read7D[0] @ %d" % fp.tell())
        oldshape = array.shape
        array = array.flatten('F')
        idata = 0
        while nrec > 1:
            nbyte = HarFileIO._getEntrySize(fp)
            dataForm = '4s15i'
            V = HarFileIO._unpack_data(fp, dataForm)
            if fb(V[0]) != '    ':
                raise RuntimeError("Encountered characters at first four positions at)SetEl")
            if nbyte != HarFileIO._getEntrySize(fp):
                raise RuntimeError('read7D data[2] corrupted')
            nbyte = HarFileIO._getEntrySize(fp)
            ndata = (nbyte - 8) // struct.calcsize(dtype)
            dataForm = '4si' + str(ndata) + dtype
            V = HarFileIO._unpack_data(fp, dataForm)
            if nbyte != HarFileIO._getEntrySize(fp):
                raise RuntimeError('read7D data[2])corrupted')
            if fb(V[0]) != '    ':
                raise RuntimeError("Encountered characters at read7D[2]")
            nrec = V[1]
            array[idata:idata + ndata] = V[2:]
            idata += ndata
        array = array.reshape(oldshape, order='F')
        return array
_readREFullObj(fp=<_io.BufferedReader name='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_remove_header_array.har'>, array=array([[0., 0.],       [0., 0.]], dtype=float32), dtype='f')


V = HarFileIO._unpack_data(fp, dataForm)


def _addHeaderArrayObjs(self, hnames, ha_objs) -> None:
        if isinstance(ha_objs, HeaderArrayObj):
            ha_objs = [ha_objs]
        if isinstance(hnames, str):
            hnames = [hnames]
        for hname, ha_obj in zip(hnames,ha_objs):
            if ha_obj.is_valid():
                self._addHeaderArrayObj(hname, ha_obj)
        return None
_addHeaderArrayObjs(self=<harpy.har_file.HarFileObj object at 0x7fd016334e80>, hnames='INTA', ha_objs=[<harpy.header_array.HeaderArrayObj object at 0x7fd016391430>], self._head_arrs=OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd016334340>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd016391ca0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd016391df0>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd0163914f0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd016391f10>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f1f0>)]), self._hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334ee0>, self.filename='test_remove_header_array.har')

OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd016334340>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd016334580>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd016334d60>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd016334160>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd016391ca0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd016391df0>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd0163914f0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd016391f10>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f1f0>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd016391430>)])


def test_del_and_contains(self):
        hfo = HarFileObj._loadFromDisk(TestHarFileObj._dd + "test.har")
        test_hn = ['XXCD', 'XXCR', 'XXCP', 'XXHS', 'CHST', 'INTA', 'SIMP', 'SIM2', 'NH01', 'ARR7']
        self.assertFalse("HNOT" in hfo)
        self.assertTrue( "XXCD" in hfo)
        self.assertTrue("xxcd" in hfo)
        del hfo["XXCD"]
        self.assertFalse("XXCD" in hfo)
        del hfo["xxcr"]
        self.assertFalse("XXCR" in hfo)
        del_hn = ['XXCP', 'XXHS', 'CHST', 'INTA', 'SIMP', 'SIM2', 'NH01', 'ARR7']
        del hfo[del_hn]
        self.assertFalse(any([ name in hfo for name in del_hn ]))
test_del_and_contains(self=<harpy.tests.test_har_file.TestHarFileObj testMethod=test_del_and_contains>, self._cleanups=[], self._outcome=<unittest.case._Outcome object at 0x7fd016334d60>, self._subtest=None, self._testMethodDoc=None, self._testMethodName='test_del_and_contains', self._type_equality_funcs={<class 'dict'>: 'assertDictEqual', <class 'list'>: 'assertListEqual', <class 'tuple'>: 'assertTupleEqual', <class 'set'>: 'assertSetEqual', <class 'frozenset'>: 'assertSetEqual', <class 'str'>: 'assertMultiLineEqual'}, self.test_del_and_contains=<bound method TestHarFileObj.test_del_and_contains of <harpy.tests.test_har_file.TestHarFileObj testMethod=test_del_and_contains>>)

{_head_arrs=OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd016391ac0>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd0163910a0>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd0163918b0>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd016391460>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd016391dc0>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d7f0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d520>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d5e0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d4c0>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d280>)]), filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/harpy/tests/testdata/test.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334280>}

{_head_arrs=OrderedDict([('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd0163910a0>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd0163918b0>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd016391460>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd016391dc0>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d7f0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d520>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d5e0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d4c0>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d280>)]), filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/harpy/tests/testdata/test.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334280>}

{_head_arrs=OrderedDict([('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd0163918b0>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd016391460>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd016391dc0>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d7f0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d520>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d5e0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d4c0>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d280>)]), filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/harpy/tests/testdata/test.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016334280>}


def test_get_item(self):
        hfo = HarFileObj._loadFromDisk(TestHarFileObj._dd + "test.har")
        test_hn = ['XXCD', 'XXCR', 'XXCP', 'XXHS', 'CHST', 'INTA', 'SIMP', 'SIM2', 'NH01', 'ARR7']
        XXCDHead=hfo["XXCD"]
        self.assertTrue(isinstance(XXCDHead,HeaderArrayObj))
        xxcdHead=hfo["xxcd"]
        self.assertTrue(xxcdHead==XXCDHead)
        HeadList=hfo[test_hn]
        for i,headid in enumerate(test_hn):
            self.assertTrue(hfo[headid] == HeadList[i])
        with self.assertRaises(KeyError):
            HeadList = hfo["NOTH"]
        with self.assertRaises(TypeError):
            HeadList = hfo[1]
test_get_item(self=<harpy.tests.test_har_file.TestHarFileObj testMethod=test_get_item>, self._cleanups=[], self._outcome=<unittest.case._Outcome object at 0x7fd016334160>, self._subtest=None, self._testMethodDoc=None, self._testMethodName='test_get_item', self._type_equality_funcs={<class 'dict'>: 'assertDictEqual', <class 'list'>: 'assertListEqual', <class 'tuple'>: 'assertTupleEqual', <class 'set'>: 'assertSetEqual', <class 'frozenset'>: 'assertSetEqual', <class 'str'>: 'assertMultiLineEqual'}, self.test_get_item=<bound method TestHarFileObj.test_get_item of <harpy.tests.test_har_file.TestHarFileObj testMethod=test_get_item>>)

{_head_arrs=OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd016321b20>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd0b71f5bb0>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd0b71f5c40>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd016321910>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd016321e80>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd016313dc0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd016313400>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd016313cd0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd0163137c0>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd016313580>)]), filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/harpy/tests/testdata/test.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016391ac0>}

{_coeff_name='            ', _array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016321a60>, _long_name='Creation Date and Time                                                '}

[<harpy.header_array.HeaderArrayObj object at 0x7fd016321b20>, <harpy.header_array.HeaderArrayObj object at 0x7fd0b71f5bb0>, <harpy.header_array.HeaderArrayObj object at 0x7fd0b71f5c40>, <harpy.header_array.HeaderArrayObj object at 0x7fd016321910>, <harpy.header_array.HeaderArrayObj object at 0x7fd016321e80>, <harpy.header_array.HeaderArrayObj object at 0x7fd016313dc0>, <harpy.header_array.HeaderArrayObj object at 0x7fd016313400>, <harpy.header_array.HeaderArrayObj object at 0x7fd016313cd0>, <harpy.header_array.HeaderArrayObj object at 0x7fd0163137c0>, <harpy.header_array.HeaderArrayObj object at 0x7fd016313580>]


def writeToDisk(self, filename: str=None, ha_names=None):
        if filename is None and self.filename is None:
            raise ValueError("No filename specified in write or upon creation, use writeToDisk(filename=YOURFILENAME)")
        if filename is None:
            filename=self.filename
        if ha_names is None:
            ha_names = self.getHeaderArrayNames()
        elif isinstance(ha_names, str):
            ha_names = [ha_names]
        ha_to_write = self._getHeaderArrayObjs(ha_names)
        HarFileIO.writeHeaders(filename, ha_names, ha_to_write)
        self._hfi.updateMtime()
writeToDisk(self=<harpy.har_file.HarFileObj object at 0x7fd01634d400>, filename='test_overwrite_header.har', ha_names=None, self._head_arrs=OrderedDict([('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd016391250>)]), self._hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd01634d4c0>, self.filename='test_overwrite_header.har')

OrderedDict([('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd016391250>), ('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd016391490>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd016391e80>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd016391280>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd016391310>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd016334880>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd016334100>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f100>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f700>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f1f0>)])

[<harpy.header_array.HeaderArrayObj object at 0x7fd016391490>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391e80>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391280>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391310>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334880>, <harpy.header_array.HeaderArrayObj object at 0x7fd016334100>, <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f100>, <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f700>, <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f1f0>, <harpy.header_array.HeaderArrayObj object at 0x7fd016391250>]


def _writeSecondRecord(fp: BinaryIO, inList):
        nint = len(inList) - 4
        if len(inList[3]) != 70:
            raise ValueError("'long_name' must be precisely 70 characters long. 'long_name' is: %s (%d characters long)." % (inList[3], len(inList[3])))
        inList = [tb(x) if isinstance(x, str) else x for x in inList]
        dataForm = '=i4s2s4s70s' + 'i' * nint + 'i'
        byteLen = struct.calcsize(dataForm) - 8
        inList.append(byteLen)
        inList.insert(0, byteLen)
        packed = struct.pack(dataForm, *inList)
        fp.write(packed)
_writeSecondRecord(fp=<_io.BufferedWriter name='test_overwrite_header.har'>, inList=['    ', '1C', 'FULL', 'Creation Date and Time                                                ', 2, 1, 70])

[b'    ', b'1C', b'FULL', b'Creation Date and Time                                                ', 2, 1, 70]

[b'    ', b'1C', b'FULL', b'Creation Date and Time                                                ', 2, 1, 70, 92]

[92, b'    ', b'1C', b'FULL', b'Creation Date and Time                                                ', 2, 1, 70, 92]


inList = [tb(x) if isinstance(x, str) else x for x in inList]

[b'    ', b'1C', b'FULL', b'Creation Date and Time                                                ', 2, 1, 70]


dataForm = '=i4s2s4s70s' + 'i' * nint + 'i' # For reading it is "=4s2s4s70si"


[b'    ', b'1C', b'FULL', b'Creation Date and Time                                                ', 2, 1, 70, 92]


[92, b'    ', b'1C', b'FULL', b'Creation Date and Time                                                ', 2, 1, 70, 92]


def _write1CArray(fp : BinaryIO, array : np.array, vecDim : int, strLen : int):
        maxwrt = 29996
        maxPerLine = maxwrt // strLen
        nrec = (vecDim - 1) // maxPerLine + 1
        nLeft = vecDim
        nDone = 0
        if nrec==0:
            dataForm = '=i4siiii'
            fp.write(struct.pack(dataForm, 16, tb('    '), 1, 0, 0,16))
        while nrec > 0:
            dataForm = '=i4siii'
            nOnRec = min(nLeft, maxPerLine)
            ndata = 16 + nOnRec * strLen
            fp.write(struct.pack(dataForm, ndata, tb('    '), nrec, vecDim, nOnRec))
            dataForm = '=' + str(ndata - 16) + 'si'
            packStr = tb(''.join([array[i].ljust(strLen) for i in range(nDone,nDone + nOnRec)]))
            fp.write(struct.pack(dataForm, packStr, ndata))
            nrec -= 1
            nLeft -= nOnRec
            nDone += nOnRec
_write1CArray(fp=<_io.BufferedWriter name='test_overwrite_header.har'>, array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), vecDim=1, strLen=70)


def _writeHeader2D(fp: BinaryIO, hname : str, head_arr_obj: HeaderArrayObj):
        HarFileIO._writeHeaderName(fp, hname)
        typeString = str(head_arr_obj.array.dtype)
        shape2D = [head_arr_obj.array.shape[i] if i < head_arr_obj.array.ndim else 1 for i in range(0, 2)]
        if typeString == 'int32':
            dtype = 'i'
            secRecList = ['    ', '2I', 'FULL', head_arr_obj.long_name, 2]
        elif typeString == 'float32':
            secRecList = ['    ', '2R', 'FULL', head_arr_obj.long_name, 2]
            dtype = 'f'
        else:
            raise TypeError("Can only write 32bit float or int to 2D arrays")
        secRecList.extend(shape2D)
        HarFileIO._writeSecondRecord(fp, secRecList)
        HarFileIO._write2DArray(fp, np.asfortranarray(head_arr_obj.array), dtype)
_writeHeader2D(fp=<_io.BufferedWriter name='test_overwrite_header.har'>, hname='INTA', head_arr_obj={_coeff_name='            ', _array=array([[ 0,  1,  2,  3],       [ 4,  5,  6,  7],       [ 8,  9, 10, 11],       [12, 13, 14, 15]], dtype=int32), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016334820>, _long_name='2D integer array                                                      '})

['    ', '2I', 'FULL', '2D integer array                                                      ', 2]


secRecList = ['    ', '2I', 'FULL', head_arr_obj.long_name, 2]

['    ', '2I', 'FULL', '2D integer array                                                      ', 2]


def _write2DArray(fp, array, dtype):
        dataForm = "=i4siiiiiii"
        maxData = 7991
        nrec = (array.size - 1) // maxData + 1
        ndata = 0
        indexTuple=(None,)
        nbyte=0
        for st, end in HarFileIO._slice_inds(array, maxData):
            if array.ndim == 1:
                indexTuple = (slice(st[0], end[0]))
                ndata = (end[0] - st[0])
                nbyte = ndata * 4 + 32
                fp.write(struct.pack(dataForm, nbyte, tb('    '), nrec, array.size, 1, st[0] + 1, end[0], 1, 1))
            elif array.ndim == 2:
                indexTuple = (slice(st[0], end[0]), slice(st[1], end[1]))
                ndata = (end[0] - st[0]) * (end[1] - st[1])
                nbyte = ndata * 4 + 32
                fp.write(struct.pack(dataForm, nbyte, tb('    '), nrec, array.shape[0],
                                         array.shape[1], st[0] + 1, end[0], st[1] + 1, end[1]))
            dataForm1 = '=' + str(ndata) + dtype
            fp.write(struct.pack(dataForm1, *array[indexTuple].flatten('F')))
            fp.write(struct.pack('=i', nbyte))
            nrec = nrec - 1
_write2DArray(fp=<_io.BufferedWriter name='test_overwrite_header.har'>, array=array([[ 0,  1,  2,  3],       [ 4,  5,  6,  7],       [ 8,  9, 10, 11],       [12, 13, 14, 15]], dtype=int32), dtype='i')


def _writeHeader7D(fp: BinaryIO, hname : str, head_arr_obj: HeaderArrayObj):
        hasElements = head_arr_obj.sets.defined()
        dataFill = float(np.count_nonzero(head_arr_obj.array)) / head_arr_obj.array.size
        if dataFill > 0.4:
            head_arr_obj.storage_type = 'FULL'
        else:
            head_arr_obj.storage_type = 'SPSE'
        shape7D = [head_arr_obj.array.shape[i] if i < head_arr_obj.array.ndim else 1 for i in range(0, 7)]
        HarFileIO._writeHeaderName(fp, hname)
        HeaderType = 'RE'
        secRecList = ['    ', HeaderType, head_arr_obj.storage_type, head_arr_obj.long_name, 7]
        secRecList.extend(shape7D)
        HarFileIO._writeSecondRecord(fp, secRecList)
        HarFileIO._writeSetElInfo(fp, head_arr_obj)
        if head_arr_obj.storage_type == 'FULL':
            HarFileIO._write7DFullArray(fp, np.asfortranarray(head_arr_obj.array), 'f')
        else:
            HarFileIO._write7DSparseArray(fp, np.asfortranarray(head_arr_obj.array), 'f')
_writeHeader7D(fp=<_io.BufferedWriter name='test_overwrite_header.har'>, hname='NH01', head_arr_obj={_coeff_name='Array2D     ', _array=array([[1.  , 3.14],       [3.14, 5.  ]], dtype=float32), _sets=<harpy._header_sets._HeaderDims object at 0x7fd0b7249e80>, _long_name='Simple 2 dimensional array                                            '})

{_coeff_name='Array2D     ', _array=array([[1.  , 3.14],       [3.14, 5.  ]], dtype=float32), _sets=<harpy._header_sets._HeaderDims object at 0x7fd0b7249e80>, _long_name='Simple 2 dimensional array                                            ', storage_type='FULL'}

['    ', 'RE', 'FULL', 'Simple 2 dimensional array                                            ', 7]


dataFill = float(np.count_nonzero(head_arr_obj.array)) / head_arr_obj.array.size


shape7D = [head_arr_obj.array.shape[i] if i < head_arr_obj.array.ndim else 1 for i in range(0, 7)]


def _writeSetElInfo(fp, header_arr_obj: HeaderArrayObj):
        sets = [setDim.name for setDim in header_arr_obj.sets.dims]
        indexTypes = [setDim.status for setDim in header_arr_obj.sets.dims]
        Elements = [setDim.dim_desc for setDim in header_arr_obj.sets.dims]
        CName = header_arr_obj.coeff_name
        tmp = {}
        elList = []
        if all(item is None for item in sets):
            nToWrite = 0
            nSets = len(sets)
            nElement = 0
            setsKnown= 0
        else:
            setsKnown=1
            statusStr = ''
            outputElements = []
            for i, j, setEls in zip(sets, indexTypes, Elements):
                if j == 'k':
                    if not i in tmp:
                        outputElements.append(setEls)
                    tmp[i] = setEls
                    statusStr += 'k'
                elif j == 'e':
                    elList.append(setEls[0])
                    statusStr += 'e'
                else:
                    statusStr += 'u'
            nToWrite = len(tmp)
            nElement = len(elList)
            ElementStr = tb(''.join(elList))
            statusStr = tb(statusStr)
            SetStr = tb(''.join([item.ljust(12) if not item is None else " "*12 for item in sets]))
            nSets = len(sets)
        dataForm = '=i4siii12si'
        if setsKnown == 1: dataForm += str(nSets * 13) + 's' + str(nSets) + 'i'
        dataForm += 'i'
        if nElement > 0: dataForm += str(nElement * 12)
        dataForm += 'i'
        nbyte = struct.calcsize(dataForm) - 8
        writeList = [nbyte, tb('    '), nToWrite, 1, nSets, tb(CName.ljust(12)), setsKnown]
        if setsKnown == 1:
            writeList.append(SetStr + statusStr)
            writeList.extend([0]*len(Elements) )
        writeList.append(nElement)
        if nElement > 0: writeList.append(ElementStr)
        writeList.append(nbyte)
        fp.write(struct.pack(dataForm, *writeList))
        if nToWrite > 0:
            for Els in outputElements:
                array = np.array(Els)
                HarFileIO._write1CArray(fp, array, len(Els), 12)
_writeSetElInfo(fp=<_io.BufferedWriter name='test_overwrite_header.har'>, header_arr_obj={_coeff_name='Array2D     ', _array=array([[1.  , 3.14],       [3.14, 5.  ]], dtype=float32), _sets=<harpy._header_sets._HeaderDims object at 0x7fd0b7249e80>, _long_name='Simple 2 dimensional array                                            ', storage_type='FULL'})

[70, b'    ', 2, 1, 2, b'Array2D     ', 1, b'SimpleSet   SimpleSet2  kk']

[70, b'    ', 2, 1, 2, b'Array2D     ', 1, b'SimpleSet   SimpleSet2  kk', 0, 0]

[70, b'    ', 2, 1, 2, b'Array2D     ', 1, b'SimpleSet   SimpleSet2  kk', 0, 0, 0]


def _write7DFullArray(fp, array, dtype):
        StEndList = []
        for i, j in HarFileIO._slice_inds(array, 7996):
            StEndList.append([i[:], j[:]])
        nrec = len(StEndList) * 2 + 1
        dataForm = '=i4sii7ii'
        nbyte = struct.calcsize(dataForm) - 8
        writeList = [nbyte, tb('    '), nrec, 7]
        writeList.extend([array.shape[i] if i < array.ndim else 1 for i in range(0, 7)])
        writeList.append(nbyte)
        fp.write(struct.pack(dataForm, *writeList))
        array1=array.flatten('F')
        nWritten=0
        for StEnd in StEndList:
            nrec = nrec - 1
            st = StEnd[0]
            end = StEnd[1]
            PosList = [[st[i] + 1, end[i]][ind] if i < array.ndim else [1, 1][ind] for i in range(0, 7) for ind in
                       range(0, 2)]
            dataForm = '=i4s16i'
            nbyte = struct.calcsize(dataForm) - 8
            writeList = [nbyte, tb('    '), nrec]
            writeList.extend(PosList)
            writeList.append(nbyte)
            fp.write(struct.pack(dataForm, *writeList))
            nrec = nrec - 1
            ndata = 1
            for i, j in zip(st, end): ndata *= (j - i)
            if dtype == 'f' or dtype == 'i': nbyte = ndata * 4 + 8
            dataForm = '=i4si'
            fp.write(struct.pack(dataForm, nbyte, tb('    '), nrec))
            dataForm = '=' + str(ndata) + dtype
            fp.write(struct.pack(dataForm, *array1[nWritten:nWritten+ndata].flatten('F')))
            nWritten+=ndata
            dataForm = '=i'
            fp.write(struct.pack(dataForm, nbyte))
_write7DFullArray(fp=<_io.BufferedWriter name='test_overwrite_header.har'>, array=array([[1.  , 3.14],       [3.14, 5.  ]], dtype=float32), dtype='f')


writeList = [nbyte, tb('    '), nrec, 7]


def updateMtime(self):
        self._mtime = os.path.getmtime(self.filename)
updateMtime(self=<harpy.har_file_io.HarFileInfoObj object at 0x7fd01634d4c0>, self._ha_infos=OrderedDict([('XXCD', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd01634dc70>), ('XXCR', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd01634d8b0>), ('XXCP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd01634dc10>), ('XXHS', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd01634d4f0>), ('CHST', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd01634d220>), ('INTA', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016307f40>), ('SIMP', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016307d30>), ('SIM2', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016307b80>), ('NH01', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016307a00>), ('ARR7', <harpy.har_file_io.HarFileInfoObj._HAInfo object at 0x7fd016307070>)]), self._mtime=1708906163.399167, self.filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/test_overwrite_header.har')


def test_set_item(self):
        hfo = HarFileObj._loadFromDisk(TestHarFileObj._dd + "test.har")
        test_hn = ['XXCD', 'XXCR', 'XXCP', 'XXHS', 'CHST', 'INTA', 'SIMP', 'SIM2', 'NH01', 'ARR7']
        xxcdHead = hfo["xxcd"]
        hfo["xxc1"]=xxcdHead
        self.assertTrue("XXC1" in hfo)
        hfo[["xxc2","xxc3"]]=[xxcdHead]*2
        self.assertTrue(all(name in hfo for name in ["XXC2","XXC3"]))
        with self.assertRaises(HarFileObj.InvalidHeaderArrayName):
            hfo["TOO LONG NAME"] = xxcdHead
        with self.assertRaises(TypeError):
            hfo[1] = xxcdHead
test_set_item(self=<harpy.tests.test_har_file.TestHarFileObj testMethod=test_set_item>, self._cleanups=[], self._outcome=<unittest.case._Outcome object at 0x7fd016378610>, self._subtest=None, self._testMethodDoc=None, self._testMethodName='test_set_item', self._type_equality_funcs={<class 'dict'>: 'assertDictEqual', <class 'list'>: 'assertListEqual', <class 'tuple'>: 'assertTupleEqual', <class 'set'>: 'assertSetEqual', <class 'frozenset'>: 'assertSetEqual', <class 'str'>: 'assertMultiLineEqual'}, self.test_set_item=<bound method TestHarFileObj.test_set_item of <harpy.tests.test_har_file.TestHarFileObj testMethod=test_set_item>>)

{_head_arrs=OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d5e0>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f1f0>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd016391490>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd0163215e0>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd0163216d0>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd0163344f0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd0163781c0>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd0163780d0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd0b7206040>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd0b7206280>)]), filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/harpy/tests/testdata/test.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016378580>}

{_head_arrs=OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d5e0>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f1f0>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd016391490>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd0163215e0>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd0163216d0>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd0163344f0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd0163781c0>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd0163780d0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd0b7206040>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd0b7206280>), ('XXC1', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d5e0>)]), filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/harpy/tests/testdata/test.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016378580>}

{_head_arrs=OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d5e0>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd0b725f1f0>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd016391490>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd0163215e0>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd0163216d0>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd0163344f0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd0163781c0>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd0163780d0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd0b7206040>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd0b7206280>), ('XXC1', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d5e0>), ('XXC2', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d5e0>), ('XXC3', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d5e0>)]), filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/harpy/tests/testdata/test.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016378580>}

{_coeff_name='            ', _array=array(['at 2/03/2018 4:22:38 PM                                               '],      dtype='<U70'), _sets=<harpy._header_sets._HeaderDims object at 0x7fd01634d400>, _long_name='Creation Date and Time                                                '}


def test_write_all(self):
        hfo = HarFileObj._loadFromDisk(TestHarFileObj._dd + "test.har")
        hfo.writeToDisk("temp.har")
        self.assertTrue(os.path.isfile("temp.har"))
        hfo = HarFileObj._loadFromDisk("temp.har")
        header_names = hfo.getHeaderArrayNames()
        test_hn = ['XXCD', 'XXCR', 'XXCP', 'XXHS', 'CHST', 'INTA', 'SIMP', 'SIM2', 'NH01', 'ARR7']
        self.assertTrue(all([x == y for (x, y) in zip(header_names, test_hn)]))
        os.remove("temp.har")
test_write_all(self=<harpy.tests.test_har_file.TestHarFileObj testMethod=test_write_all>, self._cleanups=[], self._outcome=<unittest.case._Outcome object at 0x7fd016378100>, self._subtest=None, self._testMethodDoc=None, self._testMethodName='test_write_all', self._type_equality_funcs={<class 'dict'>: 'assertDictEqual', <class 'list'>: 'assertListEqual', <class 'tuple'>: 'assertTupleEqual', <class 'set'>: 'assertSetEqual', <class 'frozenset'>: 'assertSetEqual', <class 'str'>: 'assertMultiLineEqual'}, self.test_write_all=<bound method TestHarFileObj.test_write_all of <harpy.tests.test_har_file.TestHarFileObj testMethod=test_write_all>>)

{_head_arrs=OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd016334b50>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd0163345e0>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd016334a30>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd016334280>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd0163342e0>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd0163910a0>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd0163919d0>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd016391430>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd016391df0>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd016391a90>)]), filename='/local/rcs/XXX/code/pytrace-collector/logs/pypibugs/tried/GEMPACKsoftware+HARPY/GEMPACKsoftware+HARPY/harpy/tests/testdata/test.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd016378730>}

{_head_arrs=OrderedDict([('XXCD', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d910>), ('XXCR', <harpy.header_array.HeaderArrayObj object at 0x7fd01634da30>), ('XXCP', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d760>), ('XXHS', <harpy.header_array.HeaderArrayObj object at 0x7fd01634da60>), ('CHST', <harpy.header_array.HeaderArrayObj object at 0x7fd01634d9d0>), ('INTA', <harpy.header_array.HeaderArrayObj object at 0x7fd016307a00>), ('SIMP', <harpy.header_array.HeaderArrayObj object at 0x7fd016307490>), ('SIM2', <harpy.header_array.HeaderArrayObj object at 0x7fd0b85d07f0>), ('NH01', <harpy.header_array.HeaderArrayObj object at 0x7fd0b85d0af0>), ('ARR7', <harpy.header_array.HeaderArrayObj object at 0x7fd0b71f5a60>)]), filename='temp.har', _hfi=<harpy.har_file_io.HarFileInfoObj object at 0x7fd0b725f100>}


def test_array_operation(self):
        array_2d = np.array([[1.0, 2.0], [3.0, 4.0]])
        hao1 = HeaderArrayObj.HeaderArrayFromData( array=array_2d)
        hao2 = HeaderArrayObj.HeaderArrayFromData( array=array_2d)
        hao3 = hao1 + hao2
        self.assertTrue(np.allclose(hao3.array, array_2d*2))
        hao3 = hao1 - hao2
        self.assertTrue(np.allclose(hao3.array, np.array([[0, 0], [0, 0]])))
        hao3 = hao1 * hao2
        self.assertTrue(np.allclose(hao3.array, np.array([[1, 4], [9, 16]])))
        hao3 = hao1 / hao2
        self.assertTrue(np.allclose(hao3.array, np.array([[1, 1], [1, 1]])))
test_array_operation(self=<harpy.tests.test_header_array.TestHeaderArray testMethod=test_array_operation>, self._cleanups=[], self._outcome=<unittest.case._Outcome object at 0x7fd016350b80>, self._subtest=None, self._testMethodDoc=None, self._testMethodName='test_array_operation', self._type_equality_funcs={<class 'dict'>: 'assertDictEqual', <class 'list'>: 'assertListEqual', <class 'tuple'>: 'assertTupleEqual', <class 'set'>: 'assertSetEqual', <class 'frozenset'>: 'assertSetEqual', <class 'str'>: 'assertMultiLineEqual'}, self.test_array_operation=<bound method TestHeaderArray.test_array_operation of <harpy.tests.test_header_array.TestHeaderArray testMethod=test_array_operation>>)

{_coeff_name='            ', _array=array([[1., 2.],       [3., 4.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016350250>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[1., 2.],       [3., 4.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391100>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[2., 4.],       [6., 8.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd0163914c0>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[0., 0.],       [0., 0.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd0163305e0>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[ 1.,  4.],       [ 9., 16.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd0163914c0>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[1., 1.],       [1., 1.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd0163305e0>, _long_name='                                                                      '}


def matchSets(self,sets=None, shape:tuple=None):
        if sets is None and shape is None : raise KeyError("Only one argument allowed")
        newSets = []
        if not sets is None:
            iset=len(self.dims)-1; jset=len(sets.dims)-1
            while iset >=0 and jset >=0:
                if jset < 0 :
                    newSets.append(self.dims[iset])
                    iset -=1
                elif iset < 0 :
                    newSets.append(sets.dims[jset])
                    jset -=1
                if self.dims[iset].dim_size == sets.dims[jset].dim_size or self.dims[iset].dim_size == 1 or sets.dims[jset].dim_size == 1:
                    if self.dims[iset].status != 'n':
                        newSets.append(self.dims[iset])
                    else:
                        newSets.append(sets.dims[jset])
                    iset-= 1 ; jset -=1
            newSets.reverse()
        elif not shape is None:
            iset = len(self.dims) - 1; jset=len(shape)-1
            while iset >=0 and jset >=0:
                if jset < 0 :
                    newSets.append(self.dims[iset])
                    iset -=1
                elif iset < 0 :
                    newSets.append(_HeaderSet(None , 'n' , None, shape[jset]))
                    jset -=1
                if self.dims[iset].dim_size == shape[jset] or self.dims[iset].dim_size == 1 or shape[jset] == 1:
                    newSets.append(self.dims[iset])
                    iset-= 1 ; jset -=1
        else:
            return KeyError("Either sets o shape have to be defined")
        return _HeaderDims(newSets)
matchSets(self=<harpy._header_sets._HeaderDims object at 0x7fd016350250>, sets={_dims=[<harpy._header_sets._HeaderSet object at 0x7fd016391ca0>, <harpy._header_sets._HeaderSet object at 0x7fd016391bb0>]}, shape=None, self._dims=[<harpy._header_sets._HeaderSet object at 0x7fd0163913d0>, <harpy._header_sets._HeaderSet object at 0x7fd016391e80>])

[<harpy._header_sets._HeaderSet object at 0x7fd016391bb0>]

[<harpy._header_sets._HeaderSet object at 0x7fd016391bb0>, <harpy._header_sets._HeaderSet object at 0x7fd016391ca0>]


def test_array_operation_float(self):
        array_2d = np.array([[1.0, 2.0], [3.0, 4.0]])
        hao1 = HeaderArrayObj.HeaderArrayFromData(array=array_2d)
        hao3 = hao1 + 1.5
        self.assertTrue(np.allclose(hao3.array, array_2d + 1.5))
        hao3 = hao1 - 0.5
        self.assertTrue(np.allclose(hao3.array, array_2d - 0.5))
        hao3 = hao1 * 3.14
        self.assertTrue(np.allclose(hao3.array, array_2d * 3.14))
        hao3 = hao1 / -2.5
        self.assertTrue(np.allclose(hao3.array, array_2d / -2.5))
        hao3 = 1.5 + hao1
        self.assertTrue(np.allclose(hao3.array, array_2d + 1.5))
        hao3 = 0.5 - hao1
        self.assertTrue(np.allclose(hao3.array, 0.5 - array_2d))
        hao3 = 3.14 * hao1
        self.assertTrue(np.allclose(hao3.array, array_2d * 3.14))
        hao3 = -2.5 / hao1
        self.assertTrue(np.allclose(hao3.array, -2.5 / array_2d))
test_array_operation_float(self=<harpy.tests.test_header_array.TestHeaderArray testMethod=test_array_operation_float>, self._cleanups=[], self._outcome=<unittest.case._Outcome object at 0x7fd016350df0>, self._subtest=None, self._testMethodDoc=None, self._testMethodName='test_array_operation_float', self._type_equality_funcs={<class 'dict'>: 'assertDictEqual', <class 'list'>: 'assertListEqual', <class 'tuple'>: 'assertTupleEqual', <class 'set'>: 'assertSetEqual', <class 'frozenset'>: 'assertSetEqual', <class 'str'>: 'assertMultiLineEqual'}, self.test_array_operation_float=<bound method TestHeaderArray.test_array_operation_float of <harpy.tests.test_header_array.TestHeaderArray testMethod=test_array_operation_float>>)

{_coeff_name='            ', _array=array([[1., 2.],       [3., 4.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391bb0>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[2.5, 3.5],       [4.5, 5.5]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391bb0>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[0.5, 1.5],       [2.5, 3.5]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391bb0>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[ 3.14,  6.28],       [ 9.42, 12.56]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391bb0>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[-0.4, -0.8],       [-1.2, -1.6]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391bb0>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[-0.5, -1.5],       [-2.5, -3.5]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391bb0>, _long_name='                                                                      '}


def test_array_operation_int(self):
        array_2d = np.array([[1.0, 2.0], [3.0, 4.0]])
        hao1 = HeaderArrayObj.HeaderArrayFromData(array=array_2d)
        hao3 = hao1 + 2
        self.assertTrue(np.allclose(hao3.array, array_2d + 2))
        hao3 = hao1 - 1
        self.assertTrue(np.allclose(hao3.array, array_2d - 1))
        hao3 = hao1 * 3
        self.assertTrue(np.allclose(hao3.array, array_2d * 3))
        hao3 = hao1 / 2
        self.assertTrue(np.allclose(hao3.array, array_2d / 2))
        hao3 = 2 + hao1
        self.assertTrue(np.allclose(hao3.array, array_2d + 2))
        hao3 = 1 - hao1
        self.assertTrue(np.allclose(hao3.array, 1 - array_2d ))
        hao3 = 3 * hao1
        self.assertTrue(np.allclose(hao3.array, array_2d * 3))
        hao3 = 2 / hao1
        self.assertTrue(np.allclose(hao3.array, 2 / array_2d ))
test_array_operation_int(self=<harpy.tests.test_header_array.TestHeaderArray testMethod=test_array_operation_int>, self._cleanups=[], self._outcome=<unittest.case._Outcome object at 0x7fd016391ca0>, self._subtest=None, self._testMethodDoc=None, self._testMethodName='test_array_operation_int', self._type_equality_funcs={<class 'dict'>: 'assertDictEqual', <class 'list'>: 'assertListEqual', <class 'tuple'>: 'assertTupleEqual', <class 'set'>: 'assertSetEqual', <class 'frozenset'>: 'assertSetEqual', <class 'str'>: 'assertMultiLineEqual'}, self.test_array_operation_int=<bound method TestHeaderArray.test_array_operation_int of <harpy.tests.test_header_array.TestHeaderArray testMethod=test_array_operation_int>>)

{_coeff_name='            ', _array=array([[1., 2.],       [3., 4.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391e80>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[3., 4.],       [5., 6.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391e80>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[0., 1.],       [2., 3.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391e80>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[ 3.,  6.],       [ 9., 12.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391e80>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[0.5, 1. ],       [1.5, 2. ]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391e80>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[ 0., -1.],       [-2., -3.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391e80>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[2.        , 1.        ],       [0.66666667, 0.5       ]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016391e80>, _long_name='                                                                      '}


def test_array_operation_ndarray(self):
        array_2d = np.array([[1.0, 2.0], [3.0, 4.0]])
        hao1 = HeaderArrayObj.HeaderArrayFromData(array=array_2d)
        hao3 = hao1 + array_2d
        self.assertTrue(np.allclose(hao3.array, array_2d*2))
        hao3 = hao1 - array_2d
        self.assertTrue(np.allclose(hao3.array, np.array([[0, 0], [0, 0]])))
        hao3 = hao1 * array_2d
        self.assertTrue(np.allclose(hao3.array, np.array([[1, 4], [9, 16]])))
        hao3 = hao1 / array_2d
        self.assertTrue(np.allclose(hao3.array, np.array([[1, 1], [1, 1]])))
        hao3 = array_2d + hao1
        self.assertTrue(np.allclose(hao3.array, array_2d*2))
        hao3 = array_2d - hao1
        self.assertTrue(np.allclose(hao3.array, np.array([[0, 0], [0, 0]])))
        hao3 = array_2d * hao1
        self.assertTrue(np.allclose(hao3.array, np.array([[1, 4], [9, 16]])))
        hao3 = array_2d / hao1
        self.assertTrue(np.allclose(hao3.array, np.array([[1, 1], [1, 1]])))
test_array_operation_ndarray(self=<harpy.tests.test_header_array.TestHeaderArray testMethod=test_array_operation_ndarray>, self._cleanups=[], self._outcome=<unittest.case._Outcome object at 0x7fd0163913d0>, self._subtest=None, self._testMethodDoc=None, self._testMethodName='test_array_operation_ndarray', self._type_equality_funcs={<class 'dict'>: 'assertDictEqual', <class 'list'>: 'assertListEqual', <class 'tuple'>: 'assertTupleEqual', <class 'set'>: 'assertSetEqual', <class 'frozenset'>: 'assertSetEqual', <class 'str'>: 'assertMultiLineEqual'}, self.test_array_operation_ndarray=<bound method TestHeaderArray.test_array_operation_ndarray of <harpy.tests.test_header_array.TestHeaderArray testMethod=test_array_operation_ndarray>>)

{_coeff_name='            ', _array=array([[1., 2.],       [3., 4.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016330b50>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[2., 4.],       [6., 8.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016330a30>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[0., 0.],       [0., 0.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016330be0>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[ 1.,  4.],       [ 9., 16.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016330610>, _long_name='                                                                      '}

{_coeff_name='            ', _array=array([[1., 1.],       [1., 1.]]), _sets=<harpy._header_sets._HeaderDims object at 0x7fd016330ca0>, _long_name='                                                                      '}


def test_attributes_style(self):
        hao = HeaderArrayObj()
        hao.name = "ABC"
        hao.coeff_name = "ABCDEF"
        hao.long_name = "A test header array object."
        hao.array = np.array([[1.0, 2.0], [3.0, 4.0]])
        self.assertEqual(hao.name, "ABC")
        self.assertEqual(hao.coeff_name, "ABCDEF")
        self.assertEqual(hao.long_name, "A test header array object.")
        self.assertTrue(np.allclose(hao.array, np.array([[1.0, 2.0], [3.0, 4.0]])))
test_attributes_style(self=<harpy.tests.test_header_array.TestHeaderArray testMethod=test_attributes_style>, self._cleanups=[], self._outcome=<unittest.case._Outcome object at 0x7fd016330be0>, self._subtest=None, self._testMethodDoc='Note that the values set by the setter methods are NOT guaranteed to be consistent or legitimate. Implementation of further checks with the attribute-style referencing may cause this test to fail.', self._testMethodName='test_attributes_style', self._type_equality_funcs={<class 'dict'>: 'assertDictEqual', <class 'list'>: 'assertListEqual', <class 'tuple'>: 'assertTupleEqual', <class 'set'>: 'assertSetEqual', <class 'frozenset'>: 'assertSetEqual', <class 'str'>: 'assertMultiLineEqual'}, self.test_attributes_style=<bound method TestHeaderArray.test_attributes_style of <harpy.tests.test_header_array.TestHeaderArray testMethod=test_attributes_style>>)

{_coeff_name='', _array=None, _sets=None, _long_name=''}

{_coeff_name='', _array=None, _sets=None, _long_name='', name='ABC'}

{_coeff_name='ABCDEF', _array=None, _sets=None, _long_name='', name='ABC'}

{_coeff_name='ABCDEF', _array=None, _sets=None, _long_name='A test header array object.', name='ABC'}

{_coeff_name='ABCDEF', _array=array([[1., 2.],       [3., 4.]]), _sets=None, _long_name='A test header array object.', name='ABC'}


{_coeff_name='', _array=None, _sets=None, _long_name='', name='ABC'}


{_coeff_name='ABCDEF', _array=None, _sets=None, _long_name='', name='ABC'}


hao.long_name = "A test header array object."

{_coeff_name='ABCDEF', _array=None, _sets=None, _long_name='A test header array object.', name='ABC'}


{_coeff_name='ABCDEF', _array=array([[1., 2.],       [3., 4.]]), _sets=None, _long_name='A test header array object.', name='ABC'}