Coder Social home page Coder Social logo

has2k1 / mizani Goto Github PK

View Code? Open in Web Editor NEW
45.0 5.0 13.0 1.17 MB

A scales package for python

Home Page: https://mizani.readthedocs.io

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.34% Python 99.48% Shell 0.18%
python scales graphing

mizani's Introduction

Mizani

Release License Build Status Documentation Coverage

Mizani is a scales package for graphics. It is written in Python and is based on Hadley Wickham's Scales. See the documentation for how to use it in a graphics system.

Installation

Official Release

$ pip install mizani

Development version

$ pip install git+https://github.com/has2k1/mizani.git@main

mizani's People

Contributors

cool-rr avatar has2k1 avatar ivanistheone avatar katosh avatar sthagen avatar stillmatic avatar vals avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mizani's Issues

date_format doesn't support time formatting

date_format returns zeros for %H, %M and %S

>>> from datetime import datetime
>>> import time
>>> from mizani import date_format

>>> fmt = "%Y-%m-%d %H:%M:%S"
>>> ts = datetime(2017,12,1,16,5,7)

>>> ts.strftime(fmt)
'2017-12-01 16:05:07'
>>> date_format(fmt)([ts])
['2017-12-01 00:00:00']

I looked to see if there was a different formatter for datetimes instead of just dates, but I couldn't find one.

Spotted incompatibility problem

Latest release 0.10.0 is incompatible with some other dependencies (I spotted it while working on plantcv package). To fix it I needed to downgrade to 0.9.2. Not sure if you are interested in fixing that, just wanted to mention it.

Error when loading dev version: No module named 'mizani.external'

As of a475dc5, import plotnine fails with the error No module named 'mizani.external'. The problem seems to be in loading mizani.palettes:

>>> import plotnine
Traceback (most recent call last):
  File "<exec>", line 1, in <module>
  File "/lib/python3.10/site-packages/plotnine/__init__.py", line 4, in <module>
    from .facets import *  # noqa: F401,F403,E261
  File "/lib/python3.10/site-packages/plotnine/facets/__init__.py", line 4, in <module>
    from .facet_grid import facet_grid
  File "/lib/python3.10/site-packages/plotnine/facets/facet_grid.py", line 9, in <module>
    from .facet import (
  File "/lib/python3.10/site-packages/plotnine/facets/facet.py", line 15, in <module>
    from ..scales.scales import Scales
  File "/lib/python3.10/site-packages/plotnine/scales/__init__.py", line 5, in <module>
    from .limits import expand_limits, lims, xlim, ylim
  File "/lib/python3.10/site-packages/plotnine/scales/limits.py", line 7, in <module>
    from ..geoms import geom_blank
  File "/lib/python3.10/site-packages/plotnine/geoms/__init__.py", line 13, in <module>
    from .geom_boxplot import geom_boxplot
  File "/lib/python3.10/site-packages/plotnine/geoms/geom_boxplot.py", line 24, in <module>
    from .geom_point import geom_point
  File "/lib/python3.10/site-packages/plotnine/geoms/geom_point.py", line 9, in <module>
    from ..scales.scale_shape import FILLED_SHAPES
  File "/lib/python3.10/site-packages/plotnine/scales/scale_shape.py", line 3, in <module>
    from mizani.palettes import manual_pal
  File "/lib/python3.10/site-packages/mizani/palettes.py", line 26, in <module>
    from .external import crayon_rgb, husl, xkcd_rgb
ModuleNotFoundError: No module named 'mizani.external'

I believe the problem is caused by this:

mizani/pyproject.toml

Lines 95 to 97 in a475dc5

exclude = [
"mizani/external/*"
]

Release: mizani-0.9.1

  • Run tests and coverage locally

    git switch main
    git pull origin/main
    git switch -c release-v0.9.1
    make test
    make coverage
    • The tests pass
    • The coverage is acceptable
  • Verify online documentation

  • Create a release branch

    git switch -c release-v0.9.1
  • Tag a pre-release version. These are automatically deployed on testpypi

    git tag -as v0.9.1a1 -m "Version 0.9.1a1"  # e.g. 0.9.1a1, 0.9.1b1, 0.9.1rc1
    git push
  • The latest online documentation builds, be sure to browse

  • Update changelog

    nvim doc/changelog.rst
    git commit -am "Update changelog for release"
    git push
    • Update / confirm the version to be released
    • Add a release date
    • The GHA tests pass
  • Tag final version and release

    git tag -as v0.9.1 -m "Version 0.9.1"
    git push
  • Update main branch

    git switch main
    git merge --ff-only release-v0.9.1
    git push
  • Create conda release

    sha256sum dist/*.tar.gz
    # copy hash
    • Update mizani-feedsock

      cd ../mizani-feestock
      git switch main
      git pull upstream/main
      git switch -c 0.9.1
      nvim recipe/meta.yml
      git commit -am  "Version 0.9.1"
      git push -u origin 0.9.1
    • Create a PR

    • Complete PR (follow the steps and merge)

  • Add zenodo badge to the changelog.

Missing dependencies: dateutil and docs/test dependencies

Hi!
Another missing dependency issue (like has2k1/plydata#25). In addition to the docs/test dependencies not listed in setup.py, I see that dateutil is imported by mizani/transforms.py, but is not listed in setup.py. In the test suite, the package pytz is also used.
I'm looking forward to using plotnine :-)
Best wishes!

Unable to load mizani.transforms on some platforms due to lack of system tzdata on some platforms

On some platforms, the system does not provide tzdata, and this causes import mizani.transforms to result in an error.

For example, on recent versions of Pyodide, tzdata is not included. If you run the following in the pyodide web console, it will result in an error.

>>> import micropip
>>> await micropip.install("mizani")
>>> import mizani
>>> mizani.__version__
'0.8.1'
>>> import mizani.transforms
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 995, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1053, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1030, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tzdata'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/lib/python3.10/site-packages/mizani/transforms.py", line 54, in <module>
    UTC = ZoneInfo('UTC')
  File "/lib/python3.10/zoneinfo/_zoneinfo.py", line 43, in __new__
    instance = cls._weak_cache.setdefault(key, cls._new_instance(key))
  File "/lib/python3.10/zoneinfo/_zoneinfo.py", line 70, in _new_instance
    file_obj = _common.load_tzdata(key)
  File "/lib/python3.10/zoneinfo/_common.py", line 24, in load_tzdata
    raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key UTC'

The error comes from this line:

UTC = ZoneInfo('UTC')

I believe that Windows also does not include tzdata by default, but I don't know for sure. PEP 615 has something to say about this.

It is possible to make it work, by installing the tzdata module from PyPI. Running this in the pyodide web console will work:

>>> import micropip
>>> await micropip.install("mizani")
>>> await micropip.install("tzdata")
>>> import mizani
>>> mizani.__version__
'0.8.1'
>>> import mizani.transforms

I don't know what the best way is to specify a dependency on the tzdata module -- it doesn't seem like it should be a hard dependency, because it is only necessary if the system doesn't provide tzdata.

Missing `number` and `number_format`

scales has functions number and number_format which can come handy for example when altering the scales of axes. Would be nice to have them here.

breaks.log_breaks errors for narrow range if base=2

The following code:

x = [
    1.768712, 1.7549, 1.836442, 1.79616, 1.57543, 1.519078, 1.861349, 1.905086,
    1.86907, 1.818797, 0.588072, 0.723217, 0.636356, 0.707729, 0.681214, 0.79747, 
    0.961983, 0.985598, 1.027589, 1.102333
]
limits = min(x), max(x)
breaks = breaks.log_breaks(base = 2)(limits)

correctly falls through to _log_sub_breaks but errors due to lines 223-224:

if self.base == 2:
    return base ** np.arange(_min, _max+1)

as dtype is not specified as float.

Hence, there is also no way for base=2 to fall through to the extended_breaks function. Should this be the case?

Release: mizani-0.9.2

  • Run tests and coverage locally

    git switch main
    git pull origin/main
    make test
    make coverage
    • The tests pass
    • The coverage is acceptable
  • The latest online documentation builds, be sure to browse

  • Create a release branch

    git switch -c release-v0.9.2
  • Tag a pre-release version. These are automatically deployed on testpypi

    git tag -as v0.9.2a1 -m "Version 0.9.2a1"  # e.g. 0.9.2a1, 0.9.2b1, 0.9.2rc1
    git push -u origin release-v0.9.2
  • Update changelog

    nvim doc/changelog.rst
    git commit -am "Update changelog for release"
    git push
    • Update / confirm the version to be released
    • Add a release date
    • The GHA tests pass
  • Tag final version and release

    git tag -as v0.9.2 -m "Version 0.9.2"
    git push
  • Update main branch

    git switch main
    git merge --ff-only release-v0.9.2
    git push
  • Create conda release

    • Copy SHA256 hash. Click view hashes, for the Source Distribution (.tar.gz).

    • Update mizani-feedsock

      cd ../mizani-feestock
      git switch main
      git pull upstream main
      git switch -c v0.9.2
      nvim recipe/meta.yml
      git commit -am  "Version 0.9.2"
      git push -u origin v0.9.2
    • Create a PR

    • Complete PR (follow the steps and merge)

  • Add zenodo badge to the changelog.

Release: mizani-0.10.0

  • Run tests and coverage locally

    git switch main
    git pull origin/main
    make test
    make coverage
    • The tests pass
    • The coverage is acceptable
  • The latest online documentation builds, be sure to browse

  • Create a release branch

    git switch -c release-v0.10.0
  • Tag a pre-release version. These are automatically deployed on testpypi

    git tag -as v0.10.0a1 -m "Version 0.10.0a1"  # e.g. 0.10.0a1, 0.10.0b1, 0.10.0rc1
    git push -u origin release-v0.10.0
  • Update changelog

    nvim doc/changelog.rst
    git commit -am "Update changelog for release"
    git push
    • Update / confirm the version to be released
    • Add a release date
    • The GHA tests pass
  • Tag final version and release

    git tag -as v0.10.0 -m "Version 0.10.0"
    git push
  • Update main branch

    git switch main
    git merge --ff-only release-v0.10.0
    git push
  • Create conda release

    • Copy SHA256 hash. Click view hashes, for the Source Distribution (.tar.gz).

    • Update mizani-feedsock

      cd ../mizani-feestock
      git switch main
      git pull upstream main
      git switch -c v0.10.0
      nvim recipe/meta.yml
      git commit -am  "Version 0.10.0"
      git push -u origin v0.10.0
    • Create a PR

    • Complete PR (follow the steps and merge)

  • Add zenodo badge to the changelog.

Release: mizani-0.9.3

  • Run tests and coverage locally

    git switch main
    git pull origin/main
    make test
    make coverage
    • The tests pass
    • The coverage is acceptable
  • The latest online documentation builds, be sure to browse

  • Create a release branch

    git switch -c release-v0.9.3
  • Tag a pre-release version. These are automatically deployed on testpypi

    git tag -as v0.9.3a1 -m "Version 0.9.3a1"  # e.g. 0.9.3a1, 0.9.3b1, 0.9.3rc1
    git push -u origin release-v0.9.3
  • Update changelog

    nvim doc/changelog.rst
    git commit -am "Update changelog for release"
    git push
    • Update / confirm the version to be released
    • Add a release date
    • The GHA tests pass
  • Tag final version and release

    git tag -as v0.9.3 -m "Version 0.9.3"
    git push
  • Update main branch

    git switch main
    git merge --ff-only release-v0.9.3
    git push
  • Create conda release

    • Copy SHA256 hash. Click view hashes, for the Source Distribution (.tar.gz).

    • Update mizani-feedsock

      cd ../mizani-feestock
      git switch main
      git pull upstream main
      git switch -c v0.9.3
      nvim recipe/meta.yml
      git commit -am  "Version 0.9.3"
      git push -u origin v0.9.3
    • Create a PR

    • Complete PR (follow the steps and merge)

  • Add zenodo badge to the changelog.

Release: mizani-0.11.1

  • Run tests and coverage locally

    git switch main
    git pull origin/main
    make test
    make coverage
    • The tests pass
    • The coverage is acceptable
  • The latest online documentation builds, be sure to browse

  • Create a release branch

    git switch -c release-v0.11.1
  • Tag a pre-release version. These are automatically deployed on testpypi

    git tag -as v0.11.1a1 -m "Version 0.11.1a1"  # e.g. 0.11.1a1, 0.11.1b1, 0.11.1rc1
    git push -u origin release-v0.11.1
  • Update changelog

    nvim doc/changelog.rst
    git commit -am "Update changelog for release"
    git push
    • Update / confirm the version to be released
    • Add a release date
    • The GHA tests pass
  • Tag final version and release

    git tag -as v0.11.1 -m "Version 0.11.1"
    git push
  • Update main branch

    git switch main
    git merge --ff-only release-v0.11.1
    git push
  • Create conda release

    • Copy SHA256 hash. Click view hashes, for the Source Distribution (.tar.gz).

    • Update mizani-feedsock

      cd ../mizani-feestock
      git switch main
      git pull upstream main
      git switch -c v0.11.1
      nvim recipe/meta.yml
      git commit -am  "Version 0.11.1"
      git push -u origin v0.11.1
    • Create a PR

    • Complete PR (follow the steps and merge)

  • Add zenodo badge to the changelog.

Release: mizani-0.11.0

  • Run tests and coverage locally

    git switch main
    git pull origin/main
    make test
    make coverage
    • The tests pass
    • The coverage is acceptable
  • The latest online documentation builds, be sure to browse

  • Create a release branch

    git switch -c release-v0.11.0
  • Tag a pre-release version. These are automatically deployed on testpypi

    git tag -as v0.11.0a1 -m "Version 0.11.0a1"  # e.g. 0.11.0a1, 0.11.0b1, 0.11.0rc1
    git push -u origin release-v0.11.0
  • Update changelog

    nvim doc/changelog.rst
    git commit -am "Update changelog for release"
    git push
    • Update / confirm the version to be released
    • Add a release date
    • The GHA tests pass
  • Tag final version and release

    git tag -as v0.11.0 -m "Version 0.11.0"
    git push
  • Update main branch

    git switch main
    git merge --ff-only release-v0.11.0
    git push
  • Create conda release

    • Copy SHA256 hash. Click view hashes, for the Source Distribution (.tar.gz).

    • Update mizani-feedsock

      cd ../mizani-feestock
      git switch main
      git pull upstream main
      git switch -c v0.11.0
      nvim recipe/meta.yml
      git commit -am  "Version 0.11.0"
      git push -u origin v0.11.0
    • Create a PR

    • Complete PR (follow the steps and merge)

  • Add zenodo badge to the changelog.

"ValueError: assignment destination is read-only" in .bounds.squish_infinite() with pandas CoW

We began to see issues today in GitHub Actions runs like this one that boil down to:


  File "/tmp/ipykernel_8039/2786353714.py", line 32, in save_plot
    obj.save("westeros_report.pdf", verbose=False)
    sv = self.save_helper(
         ^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotnine/ggplot.py", line 610, in save_helper
    figure = self.draw(show=False)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotnine/ggplot.py", line 279, in draw
    self._draw_layers()
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotnine/ggplot.py", line 442, in _draw_layers
    self.layers.draw(self.layout, self.coordinates)
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotnine/layer.py", line 459, in draw
    l.draw(layout, coord)
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotnine/layer.py", line 367, in draw
    self.geom.draw_layer(self.data, layout, coord, **params)
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotnine/geoms/geom.py", line 289, in draw_layer
    self.draw_panel(pdata, panel_params, coord, ax, **params)
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotnine/geoms/geom_path.py", line 148, in draw_panel
    self.draw_group(gdata, panel_params, coord, ax, **params)
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotnine/geoms/geom_path.py", line 158, in draw_group
    data = coord.transform(data, panel_params, munch=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotnine/coords/coord_cartesian.py", line 61, in transform
    return transform_position(data, squish_infinite_x, squish_infinite_y)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotnine/positions/position.py", line 127, in transform_position
    data[xs] = data[xs].apply(trans_x)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/pandas/core/frame.py", line 10034, in apply
    return op.apply().__finalize__(self, method="apply")
           ^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/pandas/core/apply.py", line 837, in apply
    return self.apply_standard()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/pandas/core/apply.py", line 965, in apply_standard
    results, res_index = self.apply_series_generator()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/pandas/core/apply.py", line 981, in apply_series_generator
    results[i] = self.func(v, *self.args, **self.kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/plotnine/coords/coord_cartesian.py", line 56, in squish_infinite_x
    return squish_infinite(col, range=panel_params.x.range)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.8/x64/lib/python3.11/site-packages/mizani/bounds.py", line 242, in squish_infinite
    _x[np.isneginf(_x)] = range[0]
    ~~^^^^^^^^^^^^^^^^^
ValueError: assignment destination is read-only

My colleague @glatterf42 helpfully bisected and narrowed down the cause, which I summarize here:

  • Pandas is moving towards "copy-on-write" (CoW ๐Ÿ„), which will be default starting in version 3.0 (I am not sure when that will be released).
  • They have a documentation page with migration tips.
  • Although this is not yet the default, when one is using dask-expr (v1.0.1), a requirement for recent versions of dask[dataframe] (e.g. v2024.3.0), that package pre-emptively enables pandas copy-on-write. This seems to also be causing headaches for others, see dask/dask#10996.
  • The result in mizani.bounds.squish_infinite() is that:
    • x is a pd.Series backed by read-only data.
    • _x is an np.ndarray reference to/view of that read-only data.
    • The above error occurs.

So I realize this issue is about a migration that mizani may have to make in the future, but at the moment it prevents simultaneous use of plotnine and dask[dataframe].

We will try to hack up a work-around (maybe forcibly disable copy-on-write just before a call to plotnine.ggplot.save()?) but wanted to give a heads-up.

Improve date_breaks

has2k1/plotnine/issues/87

Change self.intervald[YEARLY] factors. But this would be a partial solution, MPL yearly datelocator needs to get smarter and choose ticks at the decades.

import datetime
from mizani.breaks import date_breaks

limits = [datetime.datetime(1965, 1, 1),
          datetime.datetime(2017, 1, 1)]
breaks = date_breaks()
breaks(limits)
Out[1]: [datetime.datetime(2013, 1, 1, 0, 0, tzinfo=<matplotlib.dates._UTC object at 0x7fa4eccd7cf8>)]

Warnings when used with pandas 2.1.0

From has2k1/plotnine#713

With pandas 2.1.0, using plotnine results in a number of warnings from is_categorical_dtype.

For example:

from plotnine import ggplot, geom_point, aes, stat_smooth, facet_wrap
from plotnine.data import mtcars

ggplot(mtcars, aes("wt", "mpg", color="factor(gear)")) + geom_point()
#> /opt/homebrew/lib/python3.11/site-packages/plotnine/utils.py:1183: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
#> /opt/homebrew/lib/python3.11/site-packages/plotnine/utils.py:289: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
#> /opt/homebrew/lib/python3.11/site-packages/mizani/scale.py:210: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
#> /opt/homebrew/lib/python3.11/site-packages/mizani/scale.py:223: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead

date_format doesn't respect localized time zone

date_format doesn't respect the time zone of a pandas.Timestamp:

>>> from mizani.formatters import date_format
>>> import pandas as pd
>>>
>>> ts_utc = pd.Timestamp('2017-11-30 23:16:00', tz='UTC')
>>> ts_pst = ts_utc.tz_convert('US/Pacific')
>>> ts_pst.strftime("%H")
'15'
>>> date_format("%H")([tc_pst])
['23']

Dependency issues of plotnine and mizani?

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?

[doc] Norminal scale to nominal scale

Summary:

norminal โ†’ nominal In mizami/scale.py

Proposal:

I did not read the reference, but the scale that applies to items only being i
related among each other per equality relation is called nominal and not norminal.

This is a nit only, but as documentation targets the readers understanding ir may be worth the change.

Nominal comes from the Latin nomen which means name, we can at least identify and thus name the
Items. No norm is possible, and no oredering is defined either - one has to apply a convention.

bounds.rescale_max yields NaN when maximum of data is 0

I just tried to use plotnine to plot data which has values [-5, -4, -3, -2, -1, 0], and received a lot of warnings and an improper plot, in line with this (mis?)behavior:

>>> mizani.bounds.rescale_max([-5, -4, -3, -2, -1, 0])
array([-inf, -inf, -inf, -inf, -inf,  nan])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.