has2k1 / mizani

A scales package for python
https://mizani.readthedocs.io
BSD 3-Clause "New" or "Revised" License
49 stars 14 forks source link

Dependency issues of plotnine and mizani? #36

Closed thistlillo closed 6 months ago

thistlillo commented 11 months ago

I cannot get plotnine to work with mizani, there are some issues with the management of dependencies.

conda is up-to-date with the latest version.

plotnine=0.12.1=py39h06a4308_0
mizani=0.10.0=pyhd8ed1ab_0

With the messy system used by conda for the updates, I was not able to have both plotnine and mizani at their latest minor version, that should be 0.12.3 for plotnine. When I update plotnine to 0.12.3, I find mizani at a 0.9 version.

When I try to use the trans=symlog_trans() in + p9.scale_y_continuous(trans=symlog_trans(), labels=lambda l: [str(int(x)) for x in l]):

g = (
p9.ggplot(df, p9.aes(x="n_events", y="stat(count)")) 
    + p9.geom_histogram(binwidth=0.5)
    + p9.scale_y_continuous(trans=symlog_trans(), labels=lambda l: [str(int(x)) for x in l])
    + p9.geom_text(p9.aes(label='stat(count)', y='stat(count)'), stat='count', va='bottom', nudge_y=0.1, size=8, format_string='{:.0f}')
    + p9.scale_x_continuous(breaks=df.n_events.unique())
    + p9.xlab("Number of events a sample belongs to")
    + p9.ylab("Count")
    + p9.ggtitle("Histogram of the number of events a sample belongs to")
)   
display(g.draw())

I get:

AttributeError: 'symlog_trans' object has no attribute 'dataspace_is_numerical'

However, when I prepared a MWE:

import pandas as pd
import plotnine as p9
from mizani.transforms import symlog_trans

df = pd.DataFrame({
    'x': list(range(-100, 101)),
    'y': list(range(-100, 101))
})

g = (
    p9.ggplot(df, p9.aes(x='x', y='y'))
    + p9.geom_point()
    + p9.scale_y_continuous(trans=symlog_trans())
)
g.draw()

I got the output with no errors.

This happens using the same environment. Clearly, the two dataframes are different, but I cannot share the one leading to the error.

Then...

I uninstalled both plotnine and mizani, then resinstalled plotnine, but got these versions:

conda install -c conda-forge plotnine
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/user/miniconda3/envs/ai

  added / updated specs:
    - plotnine

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    backports.zoneinfo-0.2.1   |   py39hf3d152e_8           7 KB  conda-forge
    mizani-0.9.3               |     pyhd8ed1ab_0         204 KB  conda-forge
    ------------------------------------------------------------
                                           Total:         211 KB

The following NEW packages will be INSTALLED:

  backports.zoneinfo conda-forge/linux-64::backports.zoneinfo-0.2.1-py39hf3d152e_8 
  mizani             conda-forge/noarch::mizani-0.9.3-pyhd8ed1ab_0 
  patsy              conda-forge/noarch::patsy-0.5.3-pyhd8ed1ab_0 
  plotnine           conda-forge/noarch::plotnine-0.12.3-pyhd8ed1ab_0 
  statsmodels        conda-forge/linux-64::statsmodels-0.14.0-py39h44dd56e_2 

The following packages will be UPDATED:

  openssl              pkgs/main::openssl-3.0.11-h7f8727e_2 --> conda-forge::openssl-3.1.4-hd590300_0 

The following packages will be SUPERSEDED by a higher-priority channel:

  ca-certificates    pkgs/main::ca-certificates-2023.08.22~ --> conda-forge::ca-certificates-2023.7.22-hbcca054_0 
  certifi            pkgs/main/linux-64::certifi-2023.7.22~ --> conda-forge/noarch::certifi-2023.7.22-pyhd8ed1ab_0 

i.e., the current version of plotnine and the old mizani:

mizani-0.9.3

What am I supposed to do in order to use mizani 0.10?

has2k1 commented 10 months ago

I think there should be nothing wrong if you leave the dependency management to the package manager.

If you check the dependency specification for plotnine-0.12.3, you will notice that it requires mizani<0.10.0!

Only the development version of plotnine needs (and can use) mizani 0.10.0.

thistlillo commented 10 months ago

But then I get that error about the missing attribute.

Il sab 28 ott 2023, 12:48 Hassan Kibirige @.***> ha scritto:

I think there should be nothing wrong if you leave the dependency management to the package manager.

If you check the dependency specification for plotnine-0.12.3, you will notice that it requires mizani<0.10.0!

Only the development version of plotnine needs (and can use) mizani 0.10.0.

— Reply to this email directly, view it on GitHub https://github.com/has2k1/mizani/issues/36#issuecomment-1783776247, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTIBV3XTDV4PBH3SEXGEIDYBTPJVAVCNFSM6AAAAAA6T2RIMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBTG43TMMRUG4 . You are receiving this because you authored the thread.Message ID: @.***>

has2k1 commented 10 months ago

You should not have mizani-0.10.0 and plotnine-0.12.* in the same environment. That is why you get the attribute error. mizani.

You can only use symlog_trans with the development version of plotnine.