numpy.isreal - python examples

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

41 Examples 7

3 View Complete Implementation : test_types.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : AllenInstitute
def test_edge_types(net):
    edge_types = net.edges.edge_types_table
    astert(edge_types is not None)
    astert(len(edge_types.edge_type_ids) == 11)
    astert(len(edge_types.columns) == 5)
    astert('template' in edge_types.columns)
    astert('delay' in edge_types.columns)
    astert(edge_types.to_dataframe().shape == (11, 5))
    astert(np.isreal(edge_types.column('delay').dtype))

    astert(1 in edge_types)
    edge_type1 = edge_types[1]
    astert(edge_type1['dynamics_params'] == 'instanteneousInh.json')
    astert(edge_type1['delay'] == 2.0)

    # check that row is being cached.
    mem_id = id(edge_type1)
    del edge_type1
    astert (mem_id == id(edge_types[1]))

3 View Complete Implementation : _sourcetracker.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : biota
def validate_gibbs_parameters(alpha1, alpha2, beta, restarts,
                              draws_per_restart, burnin, delay):
    '''Return `True` if params numerically acceptable. See `gibbs` for docs.'''
    real_vals = [alpha1, alpha2, beta]
    int_vals = [restarts, draws_per_restart, burnin, delay]
    # Check everything is real.
    if all(np.isreal(val) for val in real_vals + int_vals):
        # Check that integer values are some type of int.
        int_check = all(isinstance(val, (int, np.int32, np.int64)) for val in
                        int_vals)
        # All integer values must be > 0.
        pos_int = all(val > 0 for val in int_vals)
        # All real values must be non-negative.
        non_neg = all(val >= 0 for val in real_vals)
        return int_check and pos_int and non_neg and real_vals
    else:  # Failed to be all numeric values.
        False

3 View Complete Implementation : filtering.py
Copyright GNU General Public License v3.0
Author : gerberlab
def discard_where_data_missing(data, field):
    """ Discard subjects where data for a particular field is missing. 

    astumes the missing data value is NaN. Non-numeric values
    are never considered missing, even the empty string.

    """
    keep_indices = []
    for i, value in enumerate(data.subject_data[field].values):
        if not (np.isreal(value) and np.isnan(value)):
            keep_indices.append(i)
    return select_subjects(data, keep_indices)

3 View Complete Implementation : curve.py
Copyright MIT License
Author : jan-mue
    @property
    def foci(self):
        """tuple of Point: The foci of the conic."""
        # Algorithm from Perspectives on Projective Geometry, Section 19.4
        i = self.tangent(at=I)
        j = self.tangent(at=J)

        if isinstance(i, Line) and isinstance(j, Line):
            return i.meet(j),

        i1, i2 = i
        j1, j2 = j
        f1, f2 = i1.meet(j1), i2.meet(j2)
        g1, g2 = i1.meet(j2), i2.meet(j1)

        if np.all(np.isreal(f1.normalized_array)):
            return f1, f2
        return g1, g2

3 View Complete Implementation : table_formatters.py
Copyright GNU Lesser General Public License v2.1
Author : man-group
    def _modify_dataframe(self, df):
        """Add row to dataframe, containing numbers aggregated with self.operator."""
        if self.total_columns == []:
            columns = df.columns
        else:
            columns = self.total_columns
        if self.operator is not OP_NONE:
            df_calculated = df[columns]
            last_row = self.operator(df_calculated[df_calculated.applymap(np.isreal)])
            last_row = last_row.fillna(0.)
            last_row = last_row.append(pd.Series('', index=df.columns.difference(last_row.index)))
        else:
            last_row = pd.Series('', index=df.columns)
        last_row.name = self.row_name
        # Appending kills index name, save now and restore after appending
        index_name = df.index.name
        df = df.append(last_row)
        df.index.name = index_name
        return df

3 View Complete Implementation : table_formatters.py
Copyright GNU Lesser General Public License v2.1
Author : man-group
    def _modify_dataframe(self, df):
        """Add row to dataframe, containing numbers aggregated with self.operator."""
        if self.total_rows == []:
            rows = df.index.tolist()
        else:
            rows = self.total_rows
        if self.operator is not OP_NONE:
            new_column = self.operator(df[df.applymap(np.isreal)], axis=1)
            new_column = new_column.fillna(0.)
            new_column[~new_column.index.isin(rows)] = ''
        else:
            new_column = pd.Series('', index=df.index)
        df_mod = df.copy()
        df_mod[self.column_name] = new_column
        return df_mod

3 View Complete Implementation : test_all.py
Copyright MIT License
Author : nils-werner
@pytest.mark.parametrize("function", all_functions)
def test_inverse(sig, function, odd, window, framelength):
    #
    # Test if combinations slow-slow, slow-fast, fast-fast, fast-slow are all
    # perfect reconstructing. Tests all with lapping.
    #
    spec = function[0](sig, odd=odd, window=window, framelength=framelength)
    outsig = function[1](spec, odd=odd, window=window, framelength=framelength)

    astert numpy.all(numpy.isreal(outsig))
    astert len(outsig) == len(sig)
    astert numpy.allclose(outsig, sig)

3 View Complete Implementation : operator_spaces_test.py
Copyright Apache License 2.0
Author : quantumlib
@pytest.mark.parametrize('m1,m2,expect_real', (
    (X, X, True),
    (X, Y, True),
    (X, H, True),
    (X, SQRT_X, False),
    (I, SQRT_Z, False),
))
def test_hilbert_schmidt_inner_product_is_conjugate_symmetric(
        m1, m2, expect_real):
    v1 = cirq.hilbert_schmidt_inner_product(m1, m2)
    v2 = cirq.hilbert_schmidt_inner_product(m2, m1)
    astert v1 == v2.conjugate()

    astert np.isreal(v1) == expect_real
    if not expect_real:
        astert v1 != v2

3 View Complete Implementation : util.py
Copyright GNU Lesser General Public License v3.0
Author : v4lli
def issequence(x):
    """Test whether x is a sequence of numbers

    Parameters
    ----------
    x : sequence to test

    """
    out = True
    try:
        # can we get a length on the object
        len(x)
    except TypeError:
        return False
    # is the object not a string?
    out = np.all(np.isreal(x))
    return out

2 View Complete Implementation : test_all.py
Copyright MIT License
Author : nils-werner
def test_outtypes(sig, backsig, module, odd):
    astert numpy.all(numpy.isreal(module.transforms.mdct(sig, odd=odd)))
    astert numpy.all(numpy.isreal(module.transforms.mdst(sig, odd=odd)))
    astert numpy.any(numpy.iscomplex(module.transforms.cmdct(sig, odd=odd)))
    astert numpy.all(numpy.isreal(module.transforms.icmdct(backsig, odd=odd)))