Esempio n. 1
0
 def __getattr__(self, attr):
     if attr == 'A':
         if self._is_array:
             warn(
                 np.VisibleDeprecationWarning(
                     "Please use `.todense()` instead"))
         return self.toarray()
     elif attr == 'T':
         return self.transpose()
     elif attr == 'H':
         if self._is_array:
             warn(
                 np.VisibleDeprecationWarning(
                     "Please use `.conj().T` instead"))
         return self.getH()
     elif attr == 'real':
         return self._real()
     elif attr == 'imag':
         return self._imag()
     elif attr == 'size':
         return self.getnnz()
     else:
         raise AttributeError(attr + " not found")
Esempio n. 2
0
    def build_sweep_table(self, sweep_info=None, deprecation_warning=True):

        if deprecation_warning:
            warnings.warn(np.VisibleDeprecationWarning(
                "in ipfx version 1.0.0 build_sweep_table will not be a "
                "public method of EphysDataSet"
            ))

        if sweep_info:
            self.add_clamp_mode(
                sweep_info, deprecation_warning=deprecation_warning
            )
            self.sweep_table = pd.DataFrame.from_records(sweep_info)
        else:
            self.sweep_table = pd.DataFrame(columns=self.COLUMN_NAMES)
Esempio n. 3
0
    def get_barcode_table(self, **barcode_kwargs):
        """ A convenience method for getting barcode times and codes in a dictionary.

        Notes
        -----
        This method is deprecated! 

        """
        warnings.warn(
            np.VisibleDeprecationWarning(
                "This function is deprecated as unecessary (and slated for removal). Instead, simply use extract_barcodes."
            ))

        barcode_times, barcodes = self.extract_barcodes(**barcode_kwargs)
        return {"codes": barcodes, "times": barcode_times}
Esempio n. 4
0
    def __init__(
            self, 
            ontology, 
            validate_stim=True, 
            deprecation_warning=False
    ):
        self.sweep_table = None
        self.ontology = ontology
        self.validate_stim = validate_stim

        if deprecation_warning:
            warnings.warn(np.VisibleDeprecationWarning((
                "Instead of constructing {} instances "
                "directly, use ipfx.data_set_utils.create_data_set"
                "this will make it easier to transition to ipfx 1.0.0"
            ).format(type(self))))
Esempio n. 5
0
    def add_clamp_mode(self, sweep_info, deprecation_warning=True):
        """
        Check if clamp mode is available and otherwise detect it
        Parameters
        ----------
        sweep_info

        Returns
        -------

        """

        if deprecation_warning:
            warnings.warn(np.VisibleDeprecationWarning(
                "in ipfx version 1.0.0 add_clamp_mode will not be a "
                "public method of EphysDataSet"
            ))

        for sweep_record in sweep_info:
            sweep_number = sweep_record["sweep_number"]
            sweep_record[self.CLAMP_MODE] = self.get_clamp_mode(sweep_number)
Esempio n. 6
0
def test_sparse_bond_matrix():
    """Test :func:`sparse_bond_matrix`."""
    ref1 = np.load(PATH / 'sparse_bond_matrix.npy')
    ref2 = ref1.astype(int)
    ref3 = ref1.astype(bool)

    mat1 = sparse_bond_matrix(MOL, dtype=float)
    mat2 = sparse_bond_matrix(MOL, dtype=int)
    mat3 = sparse_bond_matrix(MOL)

    np.testing.assert_array_equal(mat1.toarray(), ref1)
    np.testing.assert_array_equal(mat2.toarray(), ref2)
    np.testing.assert_array_equal(mat3.toarray(), ref3)

    sparse_type_tup = (bsr_matrix, coo_matrix, csr_matrix, csc_matrix,
                       dia_matrix, dok_matrix, lil_matrix)

    with warnings.catch_warnings():
        warnings.simplefilter('ignore',
                              category=np.VisibleDeprecationWarning())

        for sparse_type in sparse_type_tup:
            mat_n = sparse_bond_matrix(MOL, sparse_type=sparse_type)
            np.testing.assert_array_equal(mat_n.toarray(), ref3)

    assertion.assert_(sparse_bond_matrix,
                      MOL,
                      dtype='bob',
                      exception=TypeError)
    assertion.assert_(sparse_bond_matrix,
                      MOL,
                      sparse_type='bob',
                      exception=TypeError)
    assertion.assert_(sparse_bond_matrix,
                      MOL,
                      sparse_type=int,
                      exception=TypeError)
from typing import Type

import numpy as np

reveal_type(np.ModuleDeprecationWarning())  # E: numpy.ModuleDeprecationWarning
reveal_type(np.VisibleDeprecationWarning())  # E: numpy.VisibleDeprecationWarning
reveal_type(np.ComplexWarning())  # E: numpy.ComplexWarning
reveal_type(np.RankWarning())  # E: numpy.RankWarning
reveal_type(np.TooHardError())  # E: numpy.TooHardError
reveal_type(np.AxisError(1))  # E: numpy.AxisError
Esempio n. 8
0
from typing import Type

import numpy as np

reveal_type(np.ModuleDeprecationWarning())  # E: numpy.ModuleDeprecationWarning
reveal_type(
    np.VisibleDeprecationWarning())  # E: numpy.VisibleDeprecationWarning
reveal_type(np.ComplexWarning())  # E: numpy.ComplexWarning
reveal_type(np.RankWarning())  # E: numpy.RankWarning
reveal_type(np.TooHardError())  # E: numpy.TooHardError
reveal_type(np.AxisError(1))  # E: numpy.AxisError
Esempio n. 9
0
 def nwb_data(self):
     warnings.warn(np.VisibleDeprecationWarning(
             "In ipfx 1.0.0 nwb_data will not be a public attribute of "
             "EphysDataSet"
     ))
     return self._nwb_data