Skip to content

Commit

Permalink
Merge pull request #296 from euroargodev/release-v0.1.14
Browse files Browse the repository at this point in the history
Prepare for "v0.1.14 Frog release 🐸"
  • Loading branch information
gmaze authored Sep 29, 2023
2 parents 7b3287d + da7f90a commit fd7ae1c
Show file tree
Hide file tree
Showing 22 changed files with 325 additions and 343 deletions.
5 changes: 2 additions & 3 deletions HOW_TO_RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Setup

- [ ] Create a new branch for this release: ``git checkout -b releasev0.X.Y``
- [ ] Increase release version in ``./setup.py``
- [ ] Update release version in ``./docs/whats-new.rst``
- [ ] Increase release version in ``./setup.py``
- [ ] Create a PR to prepare it, name it with one of the [Nature emoji](https://www.webfx.com/tools/emoji-cheat-sheet/#tabs-3) and make sure it was [never used before](https://github.com/euroargodev/argopy/pulls?q=is%3Apr+label%3Arelease+)

# Prepare code for release
Expand All @@ -14,8 +14,7 @@
## Software distribution readiness
- [ ] Manually trigger [upstream CI tests](https://github.com/euroargodev/argopy/actions/workflows/pytests-upstream.yml) for the release branch and ensure they are passed
- [ ] Update pinned dependencies versions in ``./ci/requirements/py*-*-pinned.yml`` environment files using [upstream CI tests](https://github.com/euroargodev/argopy/actions/workflows/pytests-upstream.yml) information
- [ ] If CI tests with the oldest dependencies versions are not passed, upgrade these versions in ``./ci/requirements/py*-*-min.yml`` files up to the point where CI tests are passed
- [ ] Possibly update ``./requirements.txt`` and ``./docs/requirements.txt`` if the oldest dependencies versions were upgraded in the previous step
- [ ] Possibly update ``./requirements.txt`` and ``./docs/requirements.txt`` if the oldest dependencies versions were upgraded
- [ ] Make sure that all CI tests are passed
- [ ] [Activate](https://readthedocs.org/projects/argopy/versions/) and make sure the documentation for the release branch is [built on RTD](https://readthedocs.org/projects/argopy/builds/)

Expand Down
40 changes: 20 additions & 20 deletions argopy/data_fetchers/erddap_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,26 +445,26 @@ def _bgc_vlist_avail(self):

return results

def _bgc_handle_wildcard(self, param_list):
"""In a list, replace item with wildcard by available BGC parameter(s)"""
is_valid_param = lambda x: x in list( # noqa: E731
argopy.ArgoNVSReferenceTables().tbl(3)["altLabel"]
)

results = param_list.copy()
for p in param_list:
if not is_valid_param(p):
if "*" not in p:
raise ValueError(
"Invalid BGC parameter '%s' (not listed in Argo reference table 3)"
% p
)
else:
match = fnmatch.filter(self._bgc_vlist_avail, p)
if len(match) > 0:
[results.append(m) for m in match]
results.remove(p)
return results
# def _bgc_handle_wildcard(self, param_list):
# """In a list, replace item with wildcard by available BGC parameter(s)"""
# is_valid_param = lambda x: x in list( # noqa: E731
# argopy.ArgoNVSReferenceTables().tbl(3)["altLabel"]
# )

# results = param_list.copy()
# for p in param_list:
# if not is_valid_param(p):
# if "*" not in p:
# raise ValueError(
# "Invalid BGC parameter '%s' (not listed in Argo reference table 3)"
# % p
# )
# else:
# match = fnmatch.filter(self._bgc_vlist_avail, p)
# if len(match) > 0:
# [results.append(m) for m in match]
# results.remove(p)
# return results

@property
def _minimal_vlist(self):
Expand Down
3 changes: 1 addition & 2 deletions argopy/plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .plot import plot_trajectory, bar_plot, open_sat_altim_report, scatter_map, scatter_plot
from .argo_colors import ArgoColors
from .dashboards import open_dashboard as dashboard
from .utils import discrete_coloring, latlongrid
from .utils import latlongrid


__all__ = (
Expand All @@ -21,5 +21,4 @@

# Utils:
"latlongrid",
"discrete_coloring",
)
155 changes: 0 additions & 155 deletions argopy/plot/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
from contextlib import contextmanager
import importlib
from ..utils.decorators import deprecated


def _importorskip(modname):
Expand Down Expand Up @@ -64,160 +63,6 @@ def axes_style(style: str = STYLE["axes"]):
yield


@deprecated("The 'discrete_coloring' plotting utility is deprecated since 0.1.13. It's been replaced by 'ArgoColors'. Calling it will raise an error after argopy 0.1.14")
class discrete_coloring:
""" Handy class to manage discrete coloring and the associated colorbar
Warnings
--------
This plotting utility is deprecated since 0.1.13. It's been replaced by :class:`argopy.plot.ArgoColors`. Calling
it will raise an error after argopy 0.1.14.
Examples
--------
This class can be used like this:
::
year_range = np.arange(2002,2010)
dc = discrete_coloring(name='Spectral', N=len(year_range) )
plt.scatter(this['LONGITUDE'], this['LATITUDE'], c=this['TIME.year'],
cmap=dc.cmap, vmin=year_range[0], vmax=year_range[-1])
dc.cbar(ticklabels=yr_range, fraction=0.03, label='Years')
"""

def __init__(self, name="Set1", N=12):
"""
Parameters
----------
name: str
Name if the colormap to use. Default: 'Set1'
N: int
Number of colors to reduce the colormap to. Default: 12
"""
self.name = name
self.Ncolors = N

@property
def cmap(self):
"""Return a discrete colormap from a quantitative or continuous colormap name
Returns
-------
:class:`matplotlib.colors.LinearSegmentedColormap`
"""
name = self.name
K = self.Ncolors
if name in [
"Set1",
"Set2",
"Set3",
"Pastel1",
"Pastel2",
"Paired",
"Dark2",
"Accent",
]:
# Segmented (or quantitative) colormap:
N_ref = {
"Set1": 9,
"Set2": 8,
"Set3": 12,
"Pastel1": 9,
"Pastel2": 8,
"Paired": 12,
"Dark2": 8,
"Accent": 8,
}
N = N_ref[name]
cmap = plt.get_cmap(name=name)
colors_i = np.concatenate(
(np.linspace(0, 1.0, N), (0.0, 0.0, 0.0, 0.0)), axis=0
)
cmap = cmap(colors_i) # N x 4
n = np.arange(0, N)
new_n = n.copy()
if K > N:
for k in range(N, K):
r = np.roll(n, -k)[0][np.newaxis]
new_n = np.concatenate((new_n, r), axis=0)
new_cmap = cmap.copy()
new_cmap = cmap[new_n, :]
new_cmap = mcolors.LinearSegmentedColormap.from_list(
name + "_%d" % K, colors=new_cmap, N=K
)
elif name == "Month":
clist = [
"darkslateblue",
"skyblue",
"powderblue",
"honeydew",
"lemonchiffon",
"pink",
"salmon",
"deeppink",
"gold",
"chocolate",
"darkolivegreen",
"cadetblue",
]
cmap = mcolors.LinearSegmentedColormap.from_list("my_colormap", clist)
N = 12
colors_i = np.concatenate((np.linspace(0, 1.0, N), (0.0, 0.0, 0.0, 0.0)))
colors_rgba = cmap(colors_i)
indices = np.linspace(0, 1.0, N + 1)
cdict = {}
for ki, key in enumerate(("red", "green", "blue")):
cdict[key] = [
(indices[i], colors_rgba[i - 1, ki], colors_rgba[i, ki])
for i in np.arange(N + 1)
]
new_cmap = mcolors.LinearSegmentedColormap("month_%d" % N, cdict, N)
else:
# Continuous colormap:
N = K
cmap = plt.get_cmap(name=name)
colors_i = np.concatenate((np.linspace(0, 1.0, N), (0.0, 0.0, 0.0, 0.0)))
colors_rgba = cmap(colors_i) # N x 4
indices = np.linspace(0, 1.0, N + 1)
cdict = {}
for ki, key in enumerate(("red", "green", "blue")):
cdict[key] = [
(indices[i], colors_rgba[i - 1, ki], colors_rgba[i, ki])
for i in np.arange(N + 1)
]
# Return colormap object.
new_cmap = mcolors.LinearSegmentedColormap(cmap.name + "_%d" % N, cdict, N)
self._colormap = new_cmap
return new_cmap

def cbar(self, ticklabels=None, **kwargs):
"""Return a colorbar with adjusted tick labels
Returns
-------
:class:`matplotlib.pyplot.colorbar`
"""
cmap = self.cmap
ncolors = self.Ncolors
mappable = cm.ScalarMappable(cmap=cmap)
mappable.set_array([])
mappable.set_clim(-0.5, ncolors + 0.5)
colorbar = plt.colorbar(mappable, **kwargs)
colorbar.set_ticks(np.linspace(0, ncolors, ncolors))
colorbar.set_ticklabels(ticklabels)
self._colorbar = colorbar
return colorbar

def to_rgba(self, range, value):
""" Return the RGBA color for a given value of the colormap and a range """
norm = mpl.colors.Normalize(vmin=range[0], vmax=range[-1])
scalarMap = cm.ScalarMappable(norm=norm, cmap=self.cmap)
return scalarMap.to_rgba(value)


def latlongrid(ax, dx="auto", dy="auto", fontsize="auto", label_style_arg={}, **kwargs):
""" Add latitude/longitude grid line and labels to a cartopy geoaxes
Expand Down
1 change: 0 additions & 1 deletion argopy/related/euroargo_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@ def get_ea_profile_page(WMO, CYC=None, **kwargs):
df = get_coriolis_profile_id(WMO, CYC, **kwargs)
url = "https://dataselection.euro-argo.eu/cycle/{}"
return [url.format(this_id) for this_id in sorted(df["ID"])]

1 change: 0 additions & 1 deletion argopy/related/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ def mapp_dict(Adictionnary, Avalue):
return "Unknown"
else:
return Adictionnary[Avalue]

6 changes: 3 additions & 3 deletions argopy/stores/filesystems.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def cached_files(self):
else:
# See https://github.com/euroargodev/argopy/issues/294
return self.fs._metadata.cached_files

def cachepath(self, uri: str, errors: str = "raise"):
"""Return path to cached file for a given URI"""
if not self.cache:
Expand Down Expand Up @@ -261,7 +261,7 @@ def _clear_cache_item(self, uri):
cached_files = json.load(f)
else:
cached_files = cache

# Build new metadata without uri to delete, and delete corresponding cached file:
cache = {}
for k, v in cached_files.items():
Expand All @@ -271,7 +271,7 @@ def _clear_cache_item(self, uri):
# Delete file:
os.remove(os.path.join(self.fs.storage[-1], v["fn"]))
# log.debug("Removed %s -> %s" % (uri, v['fn']))

# Update cache metadata file:
if version.parse(fsspec.__version__) <= version.parse("2023.6.0"):
with tempfile.NamedTemporaryFile(mode="wb", delete=False) as f:
Expand Down
8 changes: 4 additions & 4 deletions argopy/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
check_index_cols,
check_gdac_path,
isconnected,
urlhaskeyword,
urlhaskeyword, # noqa: F401
isalive,
isAPIconnected,
erddap_ds_exists,
Expand All @@ -33,10 +33,10 @@
show_versions,
show_options,
modified_environ,
get_sys_info,
netcdf_and_hdf5_versions,
get_sys_info, # noqa: F401
netcdf_and_hdf5_versions, # noqa: F401
)
from .monitors import monitor_status, badge, fetch_status
from .monitors import monitor_status, badge, fetch_status # noqa: F401
from .geo import wmo2box, wrap_longitude, toYearFraction, YearFraction_to_datetime
from .compute import linear_interpolation_remap, groupby_remap
from .transform import (
Expand Down
2 changes: 1 addition & 1 deletion argopy/utils/casting.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
DATA_TYPES = json.load(f)


@deprecated
@deprecated("The 'cast_types' utility is deprecated since 0.1.13. It's been replaced by 'cast_Argo_variable_type'. Calling it will raise an error after argopy 0.1.15")
def cast_types(ds): # noqa: C901
"""Make sure variables are of the appropriate types according to Argo
Expand Down
6 changes: 2 additions & 4 deletions ci/requirements/py3.8-all-free.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies:
- fsspec
- netCDF4
- packaging
- requests
- scipy
- toolz
- xarray
Expand All @@ -33,6 +34,7 @@ dependencies:
- seaborn

# DEV:
- aiofiles
- black
- bottleneck
- cfgrib
Expand All @@ -47,11 +49,7 @@ dependencies:
- pytest-cov
- pytest-env
- pytest-localftpserver
# - pytest-reportlog
- aiofiles
- setuptools
# - sphinx
- requests

- pip:
- pytest-reportlog
Loading

0 comments on commit fd7ae1c

Please sign in to comment.