当前位置: 首页>>代码示例>>Python>>正文


Python numpy.string方法代码示例

本文整理汇总了Python中numpy.string方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.string方法的具体用法?Python numpy.string怎么用?Python numpy.string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy的用法示例。


在下文中一共展示了numpy.string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_bases

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def get_bases(self):
        "get bases from SpaceGroup element"
        # lattice parameters
        bases = []
        for elem in self.tree.iter():
            if elem.tag == 'SpaceGroup':
                for attr in ['AVector', 'BVector', 'CVector']:
                    basis = elem.attrib[attr]  # string
                    basis = [float(i.strip()) for i in basis.split(',')]
                    bases.append(basis)
                break
        bases = np.array(bases)
        #set base constant as 1.0
        self.bases_const = 1.0

        return bases 
开发者ID:PytLab,项目名称:VASPy,代码行数:18,代码来源:matstudio.py

示例2: __init__

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def __init__(self, filename):
        """
        Create a Material Studio *.arc file class.

        Example:

        >>> a = ArcFile("00-05.arc")

        Class attributes descriptions
        ================================================================
         Attribute         Description
         ===============  ==============================================
         filename          string, name of arc file.
         coords_iterator   generator, yield Cartisan coordinates in
                           numpy array.
         lengths           list of float, lengths of lattice axes.
         angles            list of float, angles of lattice axes.
        ================  ==============================================
        """
        super(ArcFile, self).__init__(filename)

        # Set logger.
        self.__logger = logging.getLogger("vaspy.ArcFile") 
开发者ID:PytLab,项目名称:VASPy,代码行数:25,代码来源:matstudio.py

示例3: __init__

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def __init__(self, filename='XDATCAR'):
        """
        Class to generate XDATCAR objects.

        Example:

        >>> a = XdatCar()

        Class attributes descriptions
        =======================================================================
          Attribute      Description
          ============  =======================================================
          filename       string, name of the file the direct coordiante data
                         stored in
          bases_const    float, lattice bases constant
          bases          np.array, bases of POSCAR
          natom          int, the number of total atom number
          atom_types     list of strings, atom types
          tf             list of list, T&F info of atoms
          info_nline     int, line numbers of lattice info
          ============  =======================================================
        """
        AtomCo.__init__(self, filename)
        self.info_nline = 7  # line numbers of lattice info
        self.load() 
开发者ID:PytLab,项目名称:VASPy,代码行数:27,代码来源:atomco.py

示例4: validate_col

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def validate_col(self, itemsize=None):
        """ validate this column: return the compared against itemsize """

        # validate this column for string truncation (or reset to the max size)
        if _ensure_decoded(self.kind) == u'string':
            c = self.col
            if c is not None:
                if itemsize is None:
                    itemsize = self.itemsize
                if c.itemsize < itemsize:
                    raise ValueError(
                        "Trying to store a string with len [{itemsize}] in "
                        "[{cname}] column but\nthis column has a limit of "
                        "[{c_itemsize}]!\nConsider using min_itemsize to "
                        "preset the sizes on these columns".format(
                            itemsize=itemsize, cname=self.cname,
                            c_itemsize=c.itemsize))
                return c.itemsize

        return None 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:22,代码来源:pytables.py

示例5: generate

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def generate(self, where):
        """ where can be a : dict,list,tuple,string """
        if where is None:
            return None

        q = self.table.queryables()
        try:
            return Expr(where, queryables=q, encoding=self.table.encoding)
        except NameError:
            # raise a nice message, suggesting that the user should use
            # data_columns
            raise ValueError(
                "The passed where expression: {0}\n"
                "            contains an invalid variable reference\n"
                "            all of the variable references must be a "
                "reference to\n"
                "            an axis (e.g. 'index' or 'columns'), or a "
                "data_column\n"
                "            The currently defined references are: {1}\n"
                .format(where, ','.join(q.keys()))
            ) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:23,代码来源:pytables.py

示例6: min

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def min(self):
    """Returns the minimum representable value in this data type.

    Raises:
      TypeError: if this is a non-numeric, unordered, or quantized type.

    """
    if (self.is_quantized or self.base_dtype in
        (bool, string, complex64, complex128)):
      raise TypeError("Cannot find minimum value of %s." % self)

    # there is no simple way to get the min value of a dtype, we have to check
    # float and int types separately
    try:
      return np.finfo(self.as_numpy_dtype()).min
    except:  # bare except as possible raises by finfo not documented
      try:
        return np.iinfo(self.as_numpy_dtype()).min
      except:
        raise TypeError("Cannot find minimum value of %s." % self) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:22,代码来源:dtypes.py

示例7: max

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def max(self):
    """Returns the maximum representable value in this data type.

    Raises:
      TypeError: if this is a non-numeric, unordered, or quantized type.

    """
    if (self.is_quantized or self.base_dtype in
        (bool, string, complex64, complex128)):
      raise TypeError("Cannot find maximum value of %s." % self)

    # there is no simple way to get the max value of a dtype, we have to check
    # float and int types separately
    try:
      return np.finfo(self.as_numpy_dtype()).max
    except:  # bare except as possible raises by finfo not documented
      try:
        return np.iinfo(self.as_numpy_dtype()).max
      except:
        raise TypeError("Cannot find maximum value of %s." % self) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:22,代码来源:dtypes.py

示例8: validate_col

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def validate_col(self, itemsize=None):
        """ validate this column: return the compared against itemsize """

        # validate this column for string truncation (or reset to the max size)
        if _ensure_decoded(self.kind) == u('string'):
            c = self.col
            if c is not None:
                if itemsize is None:
                    itemsize = self.itemsize
                if c.itemsize < itemsize:
                    raise ValueError(
                        "Trying to store a string with len [%s] in [%s] "
                        "column but\nthis column has a limit of [%s]!\n"
                        "Consider using min_itemsize to preset the sizes on "
                        "these columns" % (itemsize, self.cname, c.itemsize))
                return c.itemsize

        return None 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:20,代码来源:pytables.py

示例9: min

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def min(self):
        """Returns the minimum representable value in this data type.

        Raises:
          TypeError: if this is a non-numeric, unordered, or quantized type.
        """
        if self.is_quantized or self.base_dtype in (
            bool,
            string,
            complex64,
            complex128,
        ):
            raise TypeError("Cannot find minimum value of %s." % self)

        # there is no simple way to get the min value of a dtype, we have to check
        # float and int types separately
        try:
            return np.finfo(self.as_numpy_dtype).min
        except:  # bare except as possible raises by finfo not documented
            try:
                return np.iinfo(self.as_numpy_dtype).min
            except:
                if self.base_dtype == bfloat16:
                    return _np_bfloat16(float.fromhex("-0x1.FEp127"))
                raise TypeError("Cannot find minimum value of %s." % self) 
开发者ID:tensorflow,项目名称:tensorboard,代码行数:27,代码来源:dtypes.py

示例10: max

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def max(self):
        """Returns the maximum representable value in this data type.

        Raises:
          TypeError: if this is a non-numeric, unordered, or quantized type.
        """
        if self.is_quantized or self.base_dtype in (
            bool,
            string,
            complex64,
            complex128,
        ):
            raise TypeError("Cannot find maximum value of %s." % self)

        # there is no simple way to get the max value of a dtype, we have to check
        # float and int types separately
        try:
            return np.finfo(self.as_numpy_dtype).max
        except:  # bare except as possible raises by finfo not documented
            try:
                return np.iinfo(self.as_numpy_dtype).max
            except:
                if self.base_dtype == bfloat16:
                    return _np_bfloat16(float.fromhex("0x1.FEp127"))
                raise TypeError("Cannot find maximum value of %s." % self) 
开发者ID:tensorflow,项目名称:tensorboard,代码行数:27,代码来源:dtypes.py

示例11: get_name_info

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def get_name_info(self):
        """
        获取文件中能量,力等数据.
        """
        # Get info string.
        info = None
        for elem in self.tree.iter("SymmetrySystem"):
            info = elem.attrib.get('Name')
            break
        if info is None:
            return

        # Get thermo data.
        fieldnames = ["energy", "force", "magnetism", "path"]
        try:
            for key, value in zip(fieldnames, info.split()):
                if key != "path":
                    data = float(value.split(':')[-1].strip())
                else:
                    data = value.split(":")[-1].strip()
                setattr(self, key, data)
        except:
            # Set default values.
            self.force, self.energy, self.magnetism = 0.0, 0.0, 0.0

            msg = "No data info in Name property '{}'".format(info)
            self.__logger.warning(msg)
        finally:
            self.path = getcwd() 
开发者ID:PytLab,项目名称:VASPy,代码行数:31,代码来源:matstudio.py

示例12: update_bases

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def update_bases(self):
        "update bases value in ElementTree"
        bases = self.bases.tolist()
        bases_str = []
        # float -> string
        for basis in bases:
            xyz = ','.join([str(v) for v in basis])  # vector string
            bases_str.append(xyz)
        for elem in self.tree.iter('SpaceGroup'):
            elem.set('AVector', bases_str[0])
            elem.set('BVector', bases_str[1])
            elem.set('CVector', bases_str[2])
            break 
开发者ID:PytLab,项目名称:VASPy,代码行数:15,代码来源:matstudio.py

示例13: load

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def load(self, content_list):
        """ Load all data in xyz file.
        """
        # Total number of all atoms.
        natom = int(content_list[0].strip())

        # The iteration step for this xyz file.
        step = int(str2list(content_list[1])[-1])

        # Get atom coordinate and number info
        data_list = [str2list(line) for line in content_list[2:]]
        data_array = np.array(data_list)      # dtype=np.string
        atoms_list = list(data_array[:, 0])   # 1st column
        data = np.float64(data_array[:, 1:])  # rest columns

        # Atom number for each atom
        atom_types = []
        for atom in atoms_list:
            if atom not in atom_types:
                atom_types.append(atom)
        atom_numbers = [atoms_list.count(atom) for atom in atom_types]

        # Set attributes.
        self.natom = natom
        self.step = step
        self.atom_types = atom_types
        self.atom_numbers = atom_numbers
        self.data = data 
开发者ID:PytLab,项目名称:VASPy,代码行数:30,代码来源:atomco.py

示例14: _ensure_str

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def _ensure_str(name):
    """Ensure that an index / column name is a str (python 3) or
    unicode (python 2); otherwise they may be np.string dtype.
    Non-string dtypes are passed through unchanged.

    https://github.com/pandas-dev/pandas/issues/13492
    """
    if isinstance(name, compat.string_types):
        name = compat.text_type(name)
    return name 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:pytables.py

示例15: maybe_set_size

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import string [as 别名]
def maybe_set_size(self, min_itemsize=None):
        """ maybe set a string col itemsize:
               min_itemsize can be an integer or a dict with this columns name
               with an integer size """
        if _ensure_decoded(self.kind) == u'string':

            if isinstance(min_itemsize, dict):
                min_itemsize = min_itemsize.get(self.name)

            if min_itemsize is not None and self.typ.itemsize < min_itemsize:
                self.typ = _tables(
                ).StringCol(itemsize=min_itemsize, pos=self.pos) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:14,代码来源:pytables.py


注:本文中的numpy.string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。