has2k1 / mizani Goto Github PK
View Code? Open in Web Editor NEWA scales package for python
Home Page: https://mizani.readthedocs.io
License: BSD 3-Clause "New" or "Revised" License
A scales package for python
Home Page: https://mizani.readthedocs.io
License: BSD 3-Clause "New" or "Revised" License
Long term goal.
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
Ref: has2k1/plotnine#594
Run tests and coverage locally
git switch main
git pull origin/main
make test
make coverage
The latest online documentation builds, be sure to browse
Create a release branch
git switch -c release-v0.11.2
Tag a pre-release version. These are automatically deployed on testpypi
git tag -as v0.11.2a1 -m "Version 0.11.2a1" # e.g. 0.11.2a1, 0.11.2b1, 0.11.2rc1
git push -u origin release-v0.11.2
Update changelog
nvim doc/changelog.rst
git commit -am "Update changelog for release"
git push
Tag final version and release
git tag -as v0.11.2 -m "Version 0.11.2"
git push
Update main
branch
git switch main
git merge --ff-only release-v0.11.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.11.2
nvim recipe/meta.yml
git commit -am "Version 0.11.2"
git push -u origin v0.11.2
Create a PR
Complete PR (follow the steps and merge)
Add zenodo badge to the changelog.
A tunnel to all of the palettable color palettes. Then may be some palettes like brewer would use this. Upstream, plotnine should make use of this palette.
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.
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:
Lines 95 to 97 in a475dc5
date_breaks
does not support seconds:
https://mizani.readthedocs.io/en/stable/breaks.html#mizani.breaks.date_breaks
says
width ... Must be one of [minute, hour, day, week, month, year]
I guess this could be solved by including SecondLocator
from matplotlib.dates
Maybe it would also make sense to add the MicrosecondLocator
Run tests and coverage locally
git switch main
git pull origin/main
make test
make coverage
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
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.
It is a good default.
In version 0.13.x, scale_color_continuous does not recognize colormaps such as "rainbow" and "cool", which work fine in version 0.12.4.
Thanks.
Run tests and coverage locally
git switch main
git pull origin/main
make test
make coverage
The latest online documentation builds, be sure to browse
Create a release branch
git switch -c release-v0.12.0
Tag a pre-release version. These are automatically deployed on testpypi
git tag -as v0.12.0a1 -m "Version 0.12.0a1" # e.g. 0.12.0a1, 0.12.0b1, 0.12.0rc1
git push -u origin release-v0.12.0
Update changelog
nvim doc/changelog.rst
git commit -am "Update changelog for release"
git push
Tag final version and release
git tag -as v0.12.0 -m "Version 0.12.0"
git push
Update main
branch
git switch main
git merge --ff-only release-v0.12.0
git push
Create conda release
Copy SHA256 hash. Click view hashes, for the Source Distribution (.tar.gz
).
Update mizani-feedsock
cd ../mizani-feedstock
git switch main
git pull upstream main
git switch -c v0.12.0
nvim recipe/meta.yaml
git commit -am "Version 0.12.0"
git push -u origin v0.12.0
Create a PR
Complete PR (follow the steps and merge)
Add zenodo badge to the changelog.
Run tests and coverage locally
git switch main
git pull origin/main
make test
make coverage
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
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.
Run tests and coverage locally
git switch main
git pull origin/main
make test
make coverage
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
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.
Run tests and coverage locally
git switch main
git pull origin/main
git switch -c release-v0.9.1
make test
make coverage
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
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.
Run tests and coverage locally
git switch main
git pull origin/main
make test
make coverage
The latest online documentation builds, be sure to browse
Create a release branch
git switch -c release-v0.11.3
Tag a pre-release version. These are automatically deployed on testpypi
git tag -as v0.11.3a1 -m "Version 0.11.3a1" # e.g. 0.11.3a1, 0.11.3b1, 0.11.3rc1
git push -u origin release-v0.11.3
Update changelog
nvim doc/changelog.rst
git commit -am "Update changelog for release"
git push
Tag final version and release
git tag -as v0.11.3 -m "Version 0.11.3"
git push
Update main
branch
git switch main
git merge --ff-only release-v0.11.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.11.3
nvim recipe/meta.yml
git commit -am "Version 0.11.3"
git push -u origin v0.11.3
Create a PR
Complete PR (follow the steps and merge)
Add zenodo badge to the changelog.
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:
x
is a pd.Series backed by read-only data._x
is an np.ndarray reference to/view of that read-only data.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.
I haven't had time to find the exact conditions that trigger the condition described in the title, but from a little digging in my debugger, I found the following behavior in date_utils.py
:
>>> floor_hour(datetime.datetime(2022, 12, 22, 8, 10, tzinfo=datetime.timezone.utc))
datetime.datetime(2022, 12, 22, 8, 0)
This effectively erases the timezone information. In my case, the return value is then compared to a timezone-aware datetime value from my dataset, which produces an error.
The changes at bee8977 cause a ValueError
(at mizani/utils.py:360
) when with datetimes using timezone.utc
. Repro:
from datetime import datetime, timezone
from mizani.utils import get_timezone
dt = datetime.now(tz=timezone.utc)
get_timezone([dt])
Run tests and coverage locally
git switch main
git pull origin/main
make test
make coverage
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
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.
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!
I get the following warning when running the test suite:
FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
import pandas.util.testing as pdt
Best wishes
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>)]
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])
Run tests and coverage locally
git switch main
git pull origin/main
make test
make coverage
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
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.
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?
Eliminate returning of closures.
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?
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.
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:
Line 54 in eb78065
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.
norminal
โnominal
Inmizami/scale.py
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.
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']
After updating plotnine from 0.12.4 to 0.13.5 (this also triggers mizani update from 0.9.3 to 0.11.2) date labels stopped working.
Seems like it breaks when there are more than 3 observations (but maybe there are also other conditions).
All good:
import pandas as pd
from plotnine import *
plot_df = pd.DataFrame(
{
"x": ["2023-01-01", "2023-02-01", "2023-03-01"],
"y": [1, 2, 3],
}
)
plot_df["x"] = pd.to_datetime(plot_df["x"])
ggplot(plot_df, aes(x="x", y="y")) + geom_point()
But if I add one more row, date axis breaks:
plot_df = pd.DataFrame(
{
"x": ["2023-01-01", "2023-02-01", "2023-03-01", "2023-04-01"],
"y": [1, 2, 3, 4],
}
)
plot_df["x"] = pd.to_datetime(plot_df["x"])
ggplot(plot_df, aes(x="x", y="y")) + geom_point()
Adding scale_x_datetime()
or scale_x_date()
explicitly does not affect anything.
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.
Run tests and coverage locally
git switch main
git pull origin/main
make test
make coverage
The latest online documentation builds, be sure to browse
Create a release branch
git switch -c release-v0.11.4
Tag a pre-release version. These are automatically deployed on testpypi
git tag -as v0.11.4a1 -m "Version 0.11.4a1" # e.g. 0.11.4a1, 0.11.4b1, 0.11.4rc1
git push -u origin release-v0.11.4
Update changelog
nvim doc/changelog.rst
git commit -am "Update changelog for release"
git push
Tag final version and release
git tag -as v0.11.4 -m "Version 0.11.4"
git push
Update main
branch
git switch main
git merge --ff-only release-v0.11.4
git push
Create conda release
Copy SHA256 hash. Click view hashes, for the Source Distribution (.tar.gz
).
Update mizani-feedsock
cd ../mizani-feedstock
git switch main
git pull upstream main
git switch -c v0.11.4
nvim recipe/meta.yaml
git commit -am "Version 0.11.4"
git push -u origin v0.11.4
Create a PR
Complete PR (follow the steps and merge)
Add zenodo badge to the changelog.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.