numpy.number - python examples

Here are the examples of the python api numpy.number taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

145 Examples 7

3 View Complete Implementation : mfa.py
Copyright MIT License
Author : MaxHalford
    def row_contributions(self, X):
        """Returns the row contributions towards each principal component."""
        utils.validation.check_is_fitted(self)

        # Check input
        if self.check_input:
            utils.check_array(X, dtype=[str, np.number])

        # Prepare input
        X = self._prepare_input(X)

        return super().row_contributions(self._build_X_global(X))

3 View Complete Implementation : mfa.py
Copyright MIT License
Author : MaxHalford
    def _prepare_input(self, X):

        # Make sure X is a DataFrame for convenience
        if not isinstance(X, pd.DataFrame):
            X = pd.DataFrame(X)

        # Copy data
        if self.copy:
            X = X.copy()

        if self.normalize:
            # Scale continuous variables to unit variance
            num = X.select_dtypes(np.number).columns
            # If a column's cardinality is 1 then it's variance is 0 which can
            # can cause a division by 0
            normalize = lambda x: x / (np.sqrt((x ** 2).sum()) or 1)
            X.loc[:, num] = (X.loc[:, num] - X.loc[:, num].mean()).apply(normalize, axis='rows')

        return X

3 View Complete Implementation : mfa.py
Copyright MIT License
Author : MaxHalford
    def row_coordinates(self, X):
        """Returns the row principal coordinates."""
        utils.validation.check_is_fitted(self)

        # Check input
        if self.check_input:
            utils.check_array(X, dtype=[str, np.number])

        # Prepare input
        X = self._prepare_input(X)

        return self._row_coordinates_from_global(self._build_X_global(X))

3 View Complete Implementation : test_abc.py
Copyright Apache License 2.0
Author : Frank-qlu
    def test_abstract(self):
        astert_(issubclast(np.number, numbers.Number))

        astert_(issubclast(np.inexact, numbers.Complex))
        astert_(issubclast(np.complexfloating, numbers.Complex))
        astert_(issubclast(np.floating, numbers.Real))

        astert_(issubclast(np.integer, numbers.Integral))
        astert_(issubclast(np.signedinteger, numbers.Integral))
        astert_(issubclast(np.unsignedinteger, numbers.Integral))

3 View Complete Implementation : test_abc.py
Copyright Apache License 2.0
Author : Frank-qlu
    def test_abstract(self):
        astert_(issubclast(np.number, numbers.Number))

        astert_(issubclast(np.inexact, numbers.Complex))
        astert_(issubclast(np.complexfloating, numbers.Complex))
        astert_(issubclast(np.floating, numbers.Real))

        astert_(issubclast(np.integer, numbers.Integral))
        astert_(issubclast(np.signedinteger, numbers.Integral))
        astert_(issubclast(np.unsignedinteger, numbers.Integral))

3 View Complete Implementation : mca.py
Copyright MIT License
Author : MaxHalford
    def transform(self, X):
        """Computes the row principal coordinates of a dataset."""
        utils.validation.check_is_fitted(self)
        if self.check_input:
            utils.check_array(X, dtype=[str, np.number])
        return self.row_coordinates(X)

3 View Complete Implementation : test_abc.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : holzschu
    def test_abstract(self):
        astert_(issubclast(np.number, numbers.Number))

        astert_(issubclast(np.inexact, numbers.Complex))
        astert_(issubclast(np.complexfloating, numbers.Complex))
        astert_(issubclast(np.floating, numbers.Real))

        astert_(issubclast(np.integer, numbers.Integral))
        astert_(issubclast(np.signedinteger, numbers.Integral))
        astert_(issubclast(np.unsignedinteger, numbers.Integral))

3 View Complete Implementation : test_abc.py
Copyright MIT License
Author : birforce
    def test_abstract(self):
        astert_(issubclast(np.number, numbers.Number))

        astert_(issubclast(np.inexact, numbers.Complex))
        astert_(issubclast(np.complexfloating, numbers.Complex))
        astert_(issubclast(np.floating, numbers.Real))

        astert_(issubclast(np.integer, numbers.Integral))
        astert_(issubclast(np.signedinteger, numbers.Integral))
        astert_(issubclast(np.unsignedinteger, numbers.Integral))

3 View Complete Implementation : transform.py
Copyright MIT License
Author : amphibian-dev
    def _format_splits(self, splits, index = False):
        l = list()
        if np.issubdtype(splits.dtype, np.number):
            sp_l = [-np.inf] + splits.tolist() + [np.inf]
            for i in range(len(sp_l) - 1):
                l.append('['+str(sp_l[i])+' ~ '+str(sp_l[i+1])+')')
        else:
            for keys in splits:
                if isinstance(keys, str) and keys == ELSE_GROUP:
                    l.append(keys)
                else:
                    l.append(','.join(keys))

        if index:
            indexes = [i for i in range(len(l))]
            l = ["{}.{}".format(ix, lab) for ix, lab in zip(indexes, l)]

        return np.array(l)

3 View Complete Implementation : test_abc.py
Copyright MIT License
Author : PacktPublishing
    def test_abstract(self):
        astert_(issubclast(np.number, numbers.Number))

        astert_(issubclast(np.inexact, numbers.Complex))
        astert_(issubclast(np.complexfloating, numbers.Complex))
        astert_(issubclast(np.floating, numbers.Real))

        astert_(issubclast(np.integer, numbers.Integral))
        astert_(issubclast(np.signedinteger, numbers.Integral))
        astert_(issubclast(np.unsignedinteger, numbers.Integral))