src/amuse/datamodel/particles.py
def to_string(self, attributes_to_show = None, split_at = 20):
        """
        Display string of a particle set.

        >>> p0 = Particle(10)
        >>> p1 = Particle(11)
        >>> particles = Particles()
        >>> particles.add_particle(p0) # doctest:+ELLIPSIS
        <amuse.datamodel.particles.Particle object at ...>
        >>> particles.add_particle(p1) # doctest:+ELLIPSIS
        <amuse.datamodel.particles.Particle object at ...>
        >>> particles.x = [4.0 , 3.0] | units.m
        >>> particles.y = [5.0 , 2.0] | units.km
        >>> print particles.to_string()
                         key            x            y
                           -            m           km
        ====================  ===========  ===========
                          10    4.000e+00    5.000e+00
                          11    3.000e+00    2.000e+00
        ====================  ===========  ===========

        """
        attributes = sorted(self.get_attribute_names_defined_in_store())
        if attributes_to_show:
            attributes = [x for x in attributes if x in attributes_to_show]
        
        if len(self) == 0:
            return self.empty_particles_set_string(attributes)

        format_float = '{0: >11.3e}'.format
        format_str20 = '{0: >20}'.format
        format_str11 = '{0!s: >11}'.format

        columns = [[format_str11(x)] for x in attributes]
        columns.insert(0,[format_str20('key')])

        all_values = self.get_values_in_store(self.get_all_indices_in_store(), attributes)
        for index, quantity in enumerate(all_values):
            column = columns[index + 1]
            if hasattr(quantity, 'unit'):
                column.append(format_str11(str(quantity.unit)))
                quantity = quantity.number
            else:
                column.append(format_str11('none'))

            column.append('=' * 11)
            if len(quantity) > split_at * 2:
                if isinstance(quantity, LinkedArray):
                    values_to_show = list(map(format_str11,quantity[:split_at].to_print_list()))
                    values_to_show.append(format_str11('...'))
                    values_to_show.extend(map(format_str11,quantity[-split_at:].to_print_list()))
                elif hasattr(quantity, 'dtype'):
                    if numpy.issubdtype(quantity.dtype, numpy.floating):
                        values_to_show = list(map(format_float,quantity[:split_at]))
                        values_to_show.append(format_str11('...'))
                        values_to_show.extend(map(format_float,quantity[-split_at:]))
                    else:
                        values_to_show = list(map(format_str11,quantity[:split_at]))
                        values_to_show.append(format_str11('...'))
                        values_to_show.extend(map(format_str11,quantity[-split_at:]))
                else:
                    values_to_show = list(map(format_str11,quantity[:split_at]))
                    values_to_show.append(format_str11('...'))
                    values_to_show.extend(map(format_str11,quantity[-split_at:]))
            else:
                if isinstance(quantity, LinkedArray):
                    values_to_show = list(map(format_str11,quantity.to_print_list()))
                elif hasattr(quantity, 'dtype'):
                    if numpy.issubdtype(quantity.dtype, numpy.floating):
                        try:
                            values_to_show = list(map(format_float,quantity))
                        except ValueError:
                            values_to_show = list(map(format_str11,quantity))
                    else:
                        values_to_show = list(map(format_str11,quantity))
                else:
                    values_to_show = list(map(format_str11, quantity))

            column.extend(values_to_show)
            column.append('=' * 11)

        column = columns[0]
        column.append(format_str20("-"))
        column.append('=' * 20)
        particle_keys = self.get_all_keys_in_store()
        if len(particle_keys) > split_at * 2:
            values_to_show = list(map(format_str20, particle_keys[:split_at]))
            values_to_show.append(format_str20('...'))
            values_to_show.extend(map(format_str20, particle_keys[-split_at:]))
        else:
            values_to_show = list(map(format_str20,particle_keys))

        column.extend(values_to_show)

        column.append('=' * 20)

        rows = []
        for i in range(len(columns[0])):

            row = [x[i] for x in columns]
            rows.append(row)

        lines = ['  '.join(x) for x in rows]
        return '\n'.join(lines)

        Display string of a particle set.

        >>> p0 = Particle(10)
        >>> p1 = Particle(11)
        >>> particles = Particles()
        >>> particles.add_particle(p0) # doctest:+ELLIPSIS
        <amuse.datamodel.particles.Particle object at ...>
        >>> particles.add_particle(p1) # doctest:+ELLIPSIS
        <amuse.datamodel.particles.Particle object at ...>
        >>> particles.x = [4.0 , 3.0] | units.m
        >>> particles.y = [5.0 , 2.0] | units.km
        >>> print particles.to_string()
                         key            x            y
                           -            m           km
        ====================  ===========  ===========
                          10    4.000e+00    5.000e+00
                          11    3.000e+00    2.000e+00
        ====================  ===========  ===========

        
Display string of a particle set.
Display string of a particle set .
def to_string(self, attributes_to_show = None, split_at = 20):
        attributes = sorted(self.get_attribute_names_defined_in_store())
        if attributes_to_show:
            attributes = [x for x in attributes if x in attributes_to_show]
        if len(self) == 0:
            return self.empty_particles_set_string(attributes)
        format_float = '{0: >11.3e}'.format
        format_str20 = '{0: >20}'.format
        format_str11 = '{0!s: >11}'.format
        columns = [[format_str11(x)] for x in attributes]
        columns.insert(0,[format_str20('key')])
        all_values = self.get_values_in_store(self.get_all_indices_in_store(), attributes)
        for index, quantity in enumerate(all_values):
            column = columns[index + 1]
            if hasattr(quantity, 'unit'):
                column.append(format_str11(str(quantity.unit)))
                quantity = quantity.number
            else:
                column.append(format_str11('none'))
            column.append('=' * 11)
            if len(quantity) > split_at * 2:
                if isinstance(quantity, LinkedArray):
                    values_to_show = list(map(format_str11,quantity[:split_at].to_print_list()))
                    values_to_show.append(format_str11('...'))
                    values_to_show.extend(map(format_str11,quantity[-split_at:].to_print_list()))
                elif hasattr(quantity, 'dtype'):
                    if numpy.issubdtype(quantity.dtype, numpy.floating):
                        values_to_show = list(map(format_float,quantity[:split_at]))
                        values_to_show.append(format_str11('...'))
                        values_to_show.extend(map(format_float,quantity[-split_at:]))
                    else:
                        values_to_show = list(map(format_str11,quantity[:split_at]))
                        values_to_show.append(format_str11('...'))
                        values_to_show.extend(map(format_str11,quantity[-split_at:]))
                else:
                    values_to_show = list(map(format_str11,quantity[:split_at]))
                    values_to_show.append(format_str11('...'))
                    values_to_show.extend(map(format_str11,quantity[-split_at:]))
            else:
                if isinstance(quantity, LinkedArray):
                    values_to_show = list(map(format_str11,quantity.to_print_list()))
                elif hasattr(quantity, 'dtype'):
                    if numpy.issubdtype(quantity.dtype, numpy.floating):
                        try:
                            values_to_show = list(map(format_float,quantity))
                        except ValueError:
                            values_to_show = list(map(format_str11,quantity))
                    else:
                        values_to_show = list(map(format_str11,quantity))
                else:
                    values_to_show = list(map(format_str11, quantity))
            column.extend(values_to_show)
            column.append('=' * 11)
        column = columns[0]
        column.append(format_str20("-"))
        column.append('=' * 20)
        particle_keys = self.get_all_keys_in_store()
        if len(particle_keys) > split_at * 2:
            values_to_show = list(map(format_str20, particle_keys[:split_at]))
            values_to_show.append(format_str20('...'))
            values_to_show.extend(map(format_str20, particle_keys[-split_at:]))
        else:
            values_to_show = list(map(format_str20,particle_keys))
        column.extend(values_to_show)
        column.append('=' * 20)
        rows = []
        for i in range(len(columns[0])):
            row = [x[i] for x in columns]
            rows.append(row)
        lines = ['  '.join(x) for x in rows]
        return '\n'.join(lines)
def to_string ( self , attributes_to_show = None , split_at = 20 ) : attributes = sorted ( self . get_attribute_names_defined_in_store ( ) ) if attributes_to_show : attributes = [ x for x in attributes if x in attributes_to_show ] if len ( self ) == 0 : return self . empty_particles_set_string ( attributes ) format_float = '{0: >11.3e}' . format format_str20 = '{0: >20}' . format format_str11 = '{0!s: >11}' . format columns = [ [ format_str11 ( x ) ] for x in attributes ] columns . insert ( 0 , [ format_str20 ( 'key' ) ] ) all_values = self . get_values_in_store ( self . get_all_indices_in_store ( ) , attributes ) for index , quantity in enumerate ( all_values ) : column = columns [ index + 1 ] if hasattr ( quantity , 'unit' ) : column . append ( format_str11 ( str ( quantity . unit ) ) ) quantity = quantity . number else : column . append ( format_str11 ( 'none' ) ) column . append ( '=' * 11 ) if len ( quantity ) > split_at * 2 : if isinstance ( quantity , LinkedArray ) : values_to_show = list ( map ( format_str11 , quantity [ : split_at ] . to_print_list ( ) ) ) values_to_show . append ( format_str11 ( '...' ) ) values_to_show . extend ( map ( format_str11 , quantity [ - split_at : ] . to_print_list ( ) ) ) elif hasattr ( quantity , 'dtype' ) : if numpy . issubdtype ( quantity . dtype , numpy . floating ) : values_to_show = list ( map ( format_float , quantity [ : split_at ] ) ) values_to_show . append ( format_str11 ( '...' ) ) values_to_show . extend ( map ( format_float , quantity [ - split_at : ] ) ) else : values_to_show = list ( map ( format_str11 , quantity [ : split_at ] ) ) values_to_show . append ( format_str11 ( '...' ) ) values_to_show . extend ( map ( format_str11 , quantity [ - split_at : ] ) ) else : values_to_show = list ( map ( format_str11 , quantity [ : split_at ] ) ) values_to_show . append ( format_str11 ( '...' ) ) values_to_show . extend ( map ( format_str11 , quantity [ - split_at : ] ) ) else : if isinstance ( quantity , LinkedArray ) : values_to_show = list ( map ( format_str11 , quantity . to_print_list ( ) ) ) elif hasattr ( quantity , 'dtype' ) : if numpy . issubdtype ( quantity . dtype , numpy . floating ) : try : values_to_show = list ( map ( format_float , quantity ) ) except ValueError : values_to_show = list ( map ( format_str11 , quantity ) ) else : values_to_show = list ( map ( format_str11 , quantity ) ) else : values_to_show = list ( map ( format_str11 , quantity ) ) column . extend ( values_to_show ) column . append ( '=' * 11 ) column = columns [ 0 ] column . append ( format_str20 ( "-" ) ) column . append ( '=' * 20 ) particle_keys = self . get_all_keys_in_store ( ) if len ( particle_keys ) > split_at * 2 : values_to_show = list ( map ( format_str20 , particle_keys [ : split_at ] ) ) values_to_show . append ( format_str20 ( '...' ) ) values_to_show . extend ( map ( format_str20 , particle_keys [ - split_at : ] ) ) else : values_to_show = list ( map ( format_str20 , particle_keys ) ) column . extend ( values_to_show ) column . append ( '=' * 20 ) rows = [ ] for i in range ( len ( columns [ 0 ] ) ) : row = [ x [ i ] for x in columns ] rows . append ( row ) lines = [ '  ' . join ( x ) for x in rows ] return '\n' . join ( lines )
Display string of a particle set.
Display string of a particle set .
"""
        Display string of a particle set.

        >>> p0 = Particle(10)
        >>> p1 = Particle(11)
        >>> particles = Particles()
        >>> particles.add_particle(p0) # doctest:+ELLIPSIS
        <amuse.datamodel.particles.Particle object at ...>
        >>> particles.add_particle(p1) # doctest:+ELLIPSIS
        <amuse.datamodel.particles.Particle object at ...>
        >>> particles.x = [4.0 , 3.0] | units.m
        >>> particles.y = [5.0 , 2.0] | units.km
        >>> print particles.to_string()
                         key            x            y
                           -            m           km
        ====================  ===========  ===========
                          10    4.000e+00    5.000e+00
                          11    3.000e+00    2.000e+00
        ====================  ===========  ===========

        """
self
attributes_to_show
split_at