Skip to content

modified query index for compatibility with pandas#9

Merged
MarvinT merged 6 commits into
MarvinT:masterfrom
zztin:master
Mar 24, 2021
Merged

modified query index for compatibility with pandas#9
MarvinT merged 6 commits into
MarvinT:masterfrom
zztin:master

Conversation

@zztin
Copy link
Copy Markdown

@zztin zztin commented Aug 10, 2020

In this fix 2 issues are addressed:

  1. Tests failing on current version (216fc6b, tag: v0.0.8): ../calmap/__init__.py:238 KeyError
    Details please see pytest log: https://pastebin.ubuntu.com/p/TQt7WRFzpc/

  2. Future warning
    current_projects/calmap/calmap/init.py:181: FutureWarning: weekofyear and week have been deprecated, please use DatetimeIndex.isocalendar().week instead, which returns a Series. To exactly reproduce the behavior of week and weekofyear and return an Index, you may call pd.Int64Index(idx.isocalendar().week)
    "week": by_day.index.week,

My running environment:

  • Python 3.8.3
  • Pandas 1.1.0

Discussions and comments are very welcome!

@zztin
Copy link
Copy Markdown
Author

zztin commented Jan 7, 2021

Imcompatible with python 2.7 and 3.5, passed with python 3.6+ due to pandas version bump to v1.0. Would you consider merging the pull request?

@ErikBjare
Copy link
Copy Markdown

ErikBjare commented Jan 31, 2021

These changes look great, having similar issues with recent pandas. I hope dropping Python 2.7 support isn't an issue (shouldn't be anyway).

@MarvinT Any chance this'll be merged?

Comment thread calmap/__init__.py Outdated
norm=norm,
orientation='horizontal',
ticks=range(vmin, vmax + 1))
cb1.set_label('CTimer clocks')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This label looks a bit weird, is it correct?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's removed in the current PR.

Copy link
Copy Markdown
Owner

@MarvinT MarvinT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @zztin , sorry I didn't get to this earlier.

Thanks for updating the package. I am comfortable removing support for 2.7 and 3.5
Any idea why 3.7 tests are failing?
We'll have to change .travis.yml to only push to the compatible py versions because right now I have it push as a universal build.
Can you also format using black?

I've added a few comments inline as well

Comment thread calmap/__init__.py Outdated

__author__ = "Marvin Thielk; Martijn Vermaat; Liting Chen"
__contact__ = "marvin.thielk@gmail.com, martijn@vermaat.name, litingchen16@gmail.com"
__homepage__ = "https://github.com/zztin/calmap"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind adding you as a contact but can you leave the homepage pointing to my version since that's what pypi uses.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reverted the changes. This was a mistake of mine to include in this PR :)

Comment thread calmap/__init__.py
how="sum",
vmin=None,
vmax=None,
cmap="Reds",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to change the default behavior here? its a kwarg so if anyone wants reds they can use it but this will change everyone's plots without documenting the changes anywhere...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will revert the change back to its default behavior.

Comment thread calmap/__init__.py
Comment thread calmap/__init__.py Outdated
Comment on lines +279 to +280
vmin=0,
vmax=16,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the defaults should be None

Copy link
Copy Markdown
Author

@zztin zztin Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. It has been changed to None.

Comment thread calmap/__init__.py Outdated
ylabel_kws = dict(
fontsize=32,
color=kwargs.get("fillcolor", "whitesmoke"),
color=kwargs.get("fillcolor", "silver"),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this change for?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been removed from the current PR.

Comment thread calmap/__init__.py
Comment thread calmap/__init__.py Outdated
Comment on lines +385 to +393
cmap = plt.get_cmap(cmap)
bounds = range(vmin, vmax +1)
norm = BoundaryNorm(bounds, cmap.N, extend='both')

cb1 = ColorbarBase(axes[-1],
cmap=cmap,
norm=norm,
orientation='horizontal',
ticks=range(vmin, vmax + 1))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding a colorbar should be an optional thing. I personally prefer the clean look of not having a color bar.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been removed from this pull request. I am planning to send another pull request regarding the option to include a heatmap at a later stage.

@lawuka
Copy link
Copy Markdown

lawuka commented Mar 4, 2021

I am also looking for a fix to these two exact issues and I would prefer if the colorbar and other custom changes were left out as @MarvinT is also questioning. Are you still up for making the changes @zztin ?

@zztin
Copy link
Copy Markdown
Author

zztin commented Mar 8, 2021 via email

@fakhavan
Copy link
Copy Markdown

fakhavan commented Mar 10, 2021

Hi everyone!
I just wanted to add that I get this error when I was using your library inside one of our notebooks on Google Colab:

Screen Shot 2021-03-10 at 2 16 45 PM

This issue goes away when you install pandas 1.0.5 on colab and restart the kernel (runtime).
However wanting to find a better solution, I tried it with zztin:master with the pre-installed pandas on colab (it's version 1.1.5) and I still got an error at the exact same part with a different error message:

Screen Shot 2021-03-10 at 2 08 25 PM

I'm not sure if this issue is related to colab only or happens on a local environment with the same package versions but I thought it could be useful if you know and consider it in your next update.
Thank you

zztin added 2 commits March 11, 2021 20:21
Tests failed with KeyError: datetime.date(2014, 1, 15) in python 3.6+ for pandas compatibility.

Also fixed:

calmap/init.py:181: FutureWarning: weekofyear and week have been deprecated, please use DatetimeIndex.isocalendar().week instead
Add flexibility for plotting style: option to add border per month and plot title.
@tai271828
Copy link
Copy Markdown

tai271828 commented Mar 11, 2021

Python 3.7 failure of Travis CI is caused by numpy version,

...... (skipped messages)......
Requirement already satisfied: numpy>=1.15 in /home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages (from matplotlib>=2.0.0->-r doc/requirements.txt (line 1)) (1.16.4)
...... (skipped messages)......
ERROR: pandas 1.2.3 has requirement numpy>=1.16.5, but you'll have numpy 1.16.4 which is incompatible.
...... (skipped messages)......
ImportError: this version of pandas is incompatible with numpy < 1.16.5
346your numpy version is 1.16.4.
347Please upgrade numpy to >= 1.16.5 to use this pandas version

The travis environment shows some specific versions are used. Let me have a look if they raise version dependency issue:

# .travis.yml
install:
- pip install -r tests/requirements.txt -r doc/requirements.txt
- pip install -e .

and the corresponding requirement file content:

# test/requirements.txt
pytest>=4.6
coverage
pytest-cov
python-coveralls

# doc/requirements.txt
pytest>=4.6
coverage
pytest-cov
python-coveralls
matplotlib>=2.0.0
numpydoc
Sphinx<=1.8.2

I built from scratch for the original master (https://github.com/MarvinT/calmap) with the above requirement files and follow the pip install part of travis.yml, and I did not get the same error. The dependency issue should be raised by the other steps of travis.

Besides, I also run the original master travis CI[*], and the original master (https://github.com/MarvinT/calmap) travis config seems outdated a bit and not all python version will pass. My gut feeling shows this is for the same version dependency issue.

[*] https://travis-ci.com/github/tai271828/calmap/builds/219751194

tai271828 added a commit to tai271828/calmap that referenced this pull request Mar 11, 2021
When people were working on this pull request
MarvinT#9 , we were aware of the numpy
version compatibility issue during CI. This commit would fix the issue
by using numpy with explicit version.
tai271828 added a commit to tai271828/calmap that referenced this pull request Mar 11, 2021
When people were working on this pull request
MarvinT#9 , we were aware of the numpy
version compatibility issue during CI. This commit would fix the issue
by using numpy with explicit version.
@tai271828 tai271828 mentioned this pull request Mar 11, 2021
@tai271828
Copy link
Copy Markdown

I fixed the Travis CI error based on this pull request with the pull request #10 . Please feel free to land my pull request, or cherry-pick it in this pull request if you want.

When people were working on this pull request
MarvinT#9 , we were aware of the numpy
version compatibility issue during CI. This commit would fix the issue
by using numpy with explicit version.
@zztin
Copy link
Copy Markdown
Author

zztin commented Mar 11, 2021

Hi all,
The pull request has been updated to include the basic changes essential for pandas support and made style changes optional. I also excluded all customized modification that was accidentally committed into the previous PR request.

Thank you @tai271828 for the Travis CI fix. I've included the changes listed in #10 in this PR.

I have not taken into account the remark related to Colab notebook. Maybe the author could allow the issue page for submitting other issues?

@fakhavan
Copy link
Copy Markdown

I just tested the latest zztin:master with Colab and the issues have been fixed. I think the issue was not anything different than an incompatibility between the latest versions of pandas and calmap which seems to be fixed with these changes

@ErikBjare
Copy link
Copy Markdown

@MarvinT This looks ready to merge! 🎉

Copy link
Copy Markdown
Owner

@MarvinT MarvinT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, thanks for all the work. I think the only thing left is updating the version number and I'll deploy it.

Comment thread calmap/__init__.py
Comment thread calmap/__init__.py
Comment thread calmap/__init__.py Outdated
Co-authored-by: Erik Bjäreholt <erik.bjareholt@gmail.com>
@MarvinT MarvinT merged commit 336a6e2 into MarvinT:master Mar 24, 2021
@MarvinT
Copy link
Copy Markdown
Owner

MarvinT commented Mar 24, 2021

and released! thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants