Skip to content
Snippets Groups Projects
Commit 86e75e71 authored by Dima Kogan's avatar Dima Kogan
Browse files

Update upstream source from tag 'upstream/0.38'

Update to upstream version '0.38'
with Debian dir 80bdd28c2719514006ff17b42ceb884fde0a9428
parents a7860823 7c2695d2
No related branches found
No related tags found
No related merge requests found
gnuplotlib (0.37) unstable; urgency=medium gnuplotlib (0.38)
* Extended add_plot_option() API
This is a backwards-compatible update. There is NO API break. Two new
features:
- multiple key/value sets can be set in a single call by using keyword
arguments
- "overwrite" kwarg can be used to overwrite previously-set keys OR to
leave the previous ones without barfing
-- Dima Kogan <dkogan@debian.org> Sun, 11 Apr 2021 18:42:07 -0700
gnuplotlib (0.37)
* Updated default hardcopy settings * Updated default hardcopy settings
-- Dima Kogan <dkogan@debian.org> Wed, 03 Feb 2021 14:31:33 -0800 -- Dima Kogan <dkogan@debian.org> Wed, 03 Feb 2021 14:31:33 -0800
gnuplotlib (0.36) unstable; urgency=medium gnuplotlib (0.36)
* add_plot_option() API change: takes single options as scalars and * add_plot_option() API change: takes single options as scalars and
lists as lists, just like the plot options that accept multiple values lists as lists, just like the plot options that accept multiple values
-- Dima Kogan <dkogan@debian.org> Fri, 13 Nov 2020 21:28:55 -0800 -- Dima Kogan <dkogan@debian.org> Fri, 13 Nov 2020 21:28:55 -0800
gnuplotlib (0.35) unstable; urgency=medium gnuplotlib (0.35)
* Improved default svg terminal settings * Improved default svg terminal settings
* Added add_plot_option() function, more robust plot option parsing * Added add_plot_option() function, more robust plot option parsing
-- Dima Kogan <dkogan@debian.org> Sun, 08 Nov 2020 01:33:03 -0800 -- Dima Kogan <dkogan@debian.org> Sun, 08 Nov 2020 01:33:03 -0800
gnuplotlib (0.34) unstable; urgency=medium gnuplotlib (0.34)
* Lots of updates to the guide contents, and to the way it is built * Lots of updates to the guide contents, and to the way it is built
* I now barf if both "_key" and "key" are given in any set of options * I now barf if both "_key" and "key" are given in any set of options
......
...@@ -1092,7 +1092,7 @@ import numpy as np ...@@ -1092,7 +1092,7 @@ import numpy as np
import numpysane as nps import numpysane as nps
# setup.py assumes the version is a simple string in '' quotes # setup.py assumes the version is a simple string in '' quotes
__version__ = '0.37' __version__ = '0.38'
# In a multiplot, the "process" options apply to the larger plot containing all # In a multiplot, the "process" options apply to the larger plot containing all
# the subplots, and the "subplot" options apply to each invididual plot. # the subplots, and the "subplot" options apply to each invididual plot.
...@@ -2745,14 +2745,17 @@ def wait(): ...@@ -2745,14 +2745,17 @@ def wait():
globalplot.wait() globalplot.wait()
def add_plot_option(d, key, values): def add_plot_option(d,
key = None,
values = None,
overwrite = None,
**kwargs):
r'''Ingests new key/value pairs into an option dict r'''Ingests new key/value pairs into an option dict
SYNOPSIS SYNOPSIS
# A baseline plot_options dict was given to us. We want to make the # A baseline plot_options dict was given to us. We want to make the
# plot, but make sure to omit the legend key # plot, but make sure to omit the legend key
add_plot_option(plot_options, 'unset', 'key') add_plot_option(plot_options, 'unset', 'key')
gp.plot(..., **plot_options) gp.plot(..., **plot_options)
...@@ -2782,8 +2785,41 @@ def add_plot_option(d, key, values): ...@@ -2782,8 +2785,41 @@ def add_plot_option(d, key, values):
If the given key supports multiple values, they can be given in a single If the given key supports multiple values, they can be given in a single
call, as a list or a tuple. call, as a list or a tuple.
Multiple key/values can be given using keyword arguments.
ARGUMENTS
- d: the plot options dict we're updating
- key: string. The key being set
- values: string (if setting a single value) or iterable (if setting multiple
values)
- **kwargs: more key/value pairs to set. We set the key/value positional
arguments first, and then move on to the kwargs
- overwrite: optional boolean that controls how we handle overwriting keys that
do not accept multiple values. By default (overwrite is None), trying to set a
key that is already set results in an exception. elif overwrite: we overwrite
the previous values. elif not overwrite: we leave the previous value
''' '''
if kwargs:
add_plot_option(d, key, values,
overwrite)
for key in kwargs:
add_plot_option(d, key, kwargs[key],
overwrite)
return
if key is None:
if values is not None:
raise Exception("key is None, but values is not. Giving up")
return
key_normalized = key if key[0] != '_' else key[1:] key_normalized = key if key[0] != '_' else key[1:]
if not (key_normalized in keysAcceptingIterable and \ if not (key_normalized in keysAcceptingIterable and \
isinstance(values, (list,tuple))): isinstance(values, (list,tuple))):
...@@ -2793,10 +2829,17 @@ def add_plot_option(d, key, values): ...@@ -2793,10 +2829,17 @@ def add_plot_option(d, key, values):
if len(values) == 0: return if len(values) == 0: return
if key_normalized not in keysAcceptingIterable: if key_normalized not in keysAcceptingIterable:
if key in d or key_normalized in d or len(values) > 1: if len(values) > 1:
# Already have old key, so can't add a new key. Or have multiple new raise GnuplotlibError("plot options given multiple values for key '{}'".format(key_normalized))
# values. if key in d or key_normalized in d:
raise GnuplotlibError("Options dict given multiple values for key '{}'".format(key_normalized)) # A value already exists. What do I do?
if (overwrite is not None) and overwrite:
pass
elif (overwrite is not None) and not overwrite:
return
else:
# overwrite is None (the default). Barf.
raise GnuplotlibError("plot options already have a value for key '{}'. Pass 'overwrite=False' to use the existing one of 'overwrite=True' to use the new one".format(key_normalized))
d[key_normalized] = values[0] d[key_normalized] = values[0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment