Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cmsstyle/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from ._version import version as __version__ # noqa: F401

from .cmsstyle import *
9 changes: 9 additions & 0 deletions src/cmsstyle/_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def env_type():
try:
ipy_str = str(type(get_ipython()))
if 'zmqshell' in ipy_str:
return 'jupyter'
if 'terminal' in ipy_str:
return 'ipython'
except:
return 'terminal'
2 changes: 2 additions & 0 deletions src/cmsstyle/_version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version: str
version_tuple: tuple[int, int, int] | tuple[int, int, int, str, str]
15 changes: 8 additions & 7 deletions src/cmsstyle/cmsstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from dataclasses import dataclass
from typing import Any, Iterable
import os
from ._utils import env_type

# This global variables for the module should not be accessed directy! Use the utilities below.
cms_lumi = "Run 2, 138 fb^{#minus1}"
Expand Down Expand Up @@ -725,13 +726,13 @@ def setCMSStyle(force=rt.kTRUE):
cmsStyle.SetHatchesSpacing(1.3)

# Some additional parameters we need to set as "style"

if (
float(".".join(re.split("\\.|/", rt.__version__)[0:2])) >= 6.32
): # Not available before!
# This change by O. Gonzalez allows to save inside the canvas the
# informnation about the defined colours.
rt.TColor.DefinedColors(1)
if env_type() != "jupyter": # Snippet below crashes in jupyter as late as 6.36. Issue reproted to ROOT
if (
float(".".join(re.split("\\.|/", rt.__version__)[0:2])) >= 6.32
): # Not available before!
# This change by O. Gonzalez allows to save inside the canvas the
# informnation about the defined colours.
rt.TColor.DefinedColors(1)

# Using the Style.
cmsStyle.cd()
Expand Down