Ejemplo n.º 1
0
def test_logscale_invert_transform():
    fig, ax = plt.subplots()
    ax.set_yscale('log')
    # get transformation from data to axes
    tform = (ax.transAxes + ax.transData.inverted()).inverted()

    # direct test of log transform inversion
    inverted_transform = LogTransform(base=2).inverted()
    assert isinstance(inverted_transform, InvertedLogTransform)
    assert inverted_transform.base == 2
Ejemplo n.º 2
0
    def get_scatter_view_lims(counts_df: pd.DataFrame) -> Tuple[float, float]:
        """Calculates scatter view limits for the counts dataframe"""

        x0 = counts_df.min(axis='columns').where(lambda x: x != 0).dropna().min()
        x1 = np.max(counts_df).max()
        minpos = 1e-300

        if not np.isfinite([x0, x1]).all() or not isinstance(x0, np.float) or x1 <= 0:
            print("The provided dataset contains invalid values.")
            return (minpos, minpos)

        x0, x1 = (minpos if x0 <= 0 else x0,
                  minpos if x1 <= 0 else x1)

        transform = LogTransform(base=2)
        inverse_trans = transform.inverted()

        x0t, x1t = transform.transform([x0, x1])
        delta = (x1t - x0t) * mpl.rcParams.get('axes.xmargin', 0)
        if not np.isfinite(delta): delta = 0

        return inverse_trans.transform([x0t - delta, x1t + delta])
Ejemplo n.º 3
0
def test_logscale_transform_repr():
    fig, ax = plt.subplots()
    ax.set_yscale('log')
    repr(ax.transData)
    repr(LogTransform(10, nonpositive='clip'))