Skip to content

Commit

Permalink
feat: add cmasher colormaps (#75)
Browse files Browse the repository at this point in the history
* feat: add cmasher colormaps

* sort record files
  • Loading branch information
tlambert03 authored Nov 1, 2024
1 parent 048b7fc commit 9850936
Show file tree
Hide file tree
Showing 4 changed files with 20,426 additions and 3 deletions.
29 changes: 29 additions & 0 deletions LICENSE/LICENSE_CMASHER
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2019-2021, Ellert van der Velden
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 changes: 11 additions & 3 deletions src/cmap/_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,17 @@ def __init__(
# _rev_aliases maps fully qualified names to a list of aliases
self._rev_aliases: dict[str, list[str]] = {}

for name, data in _build_catalog(
sorted(data_root.rglob(record_pattern))
).items():
# sort record files. Put matplotlib-related names first so that un-namespaced
# names resolve to the matplotlib colormaps by default.
MPL_PRIORTY_NAMESPACES = ("matplotlib", "bids", "matlab", "gnuplot")

def _sorter(x: Path) -> tuple[int, Path]:
if any(s in str(x) for s in MPL_PRIORTY_NAMESPACES):
return (0, x)
return (1, x)

record_files = sorted(data_root.rglob(record_pattern), key=_sorter)
for name, data in _build_catalog(record_files).items():
normed_name = self._norm_name(name)
self._original_names[name] = normed_name
self._data[normed_name] = data
Expand Down
Loading

0 comments on commit 9850936

Please sign in to comment.