Re: configargparse - reading option from config only
Richard Damon writes: > On 8/26/21 6:01 AM, Loris Bennett wrote: >> Hi, >> >> When using configargparse, it seems that if a value is to be read from a >> config file, it also has to be defined as a command-line argument in >> order to turn up as an attribute in the parser namespace. >> >> I can sort of see why this is the case, but there are also some options >> I would like to read just from the config file and not have them >> available as command-line options. This would be, say, to prevent the >> number of options on the command-line from becoming bloated by >> little-used settings. >> >> Is there an elegant way to do this? >> >> Cheers, >> >> Loris >> > Look at the read() member function to supply the file name to read. Then > in the config object there will be sections for each section in the > config file. No need for any of these to be 'options' Do you have a link for this? As far as I can see, the config files are given in the following manner: p = configargparse.ArgParser(default_config_files=['/etc/app/conf.d/*.conf', '~/.my_settings']) I can obviously just read the config file with configparser, but the idea of configargparse is that an option can be specified as an option, in a config file, or as an environment variable, As far as I can tell, configargparse only loads entries from the config file into the appropriate namespace if they have also been defined as long options (i.e. with '--'). I was hoping to access *all* the config file entries, regardless of whether they are also options, since the config is obviously being read. Cheers, Loris -- This signature is currently under construction. -- https://mail.python.org/mailman/listinfo/python-list
Re: configargparse - reading option from config only
tuxifreund writes: > Hello, > > you could use the argparse module[1] to parse command line arguments and > configparser[2] to parse configuration files following the ini file > structure. Is that what you are expecting? I have used the combination of argparse and configparser before. However, I was hoping to just use configargparse instead. Cheers, Loris > > Cheers > > > [1]: https://docs.python.org/3/library/argparse.html > [2]: https://docs.python.org/3/library/configparser.html -- Dr. Loris Bennett (Hr./Mr.) ZEDAT, Freie Universität Berlin Email [email protected] -- https://mail.python.org/mailman/listinfo/python-list
RE: matplotlib questions
Complete documentation link (this link works) : https://matplotlib.org/stable/contents.html --- Joseph S. Teledyne Confidential; Commercially Sensitive Business Data -Original Message- From: Steve Sent: Thursday, August 26, 2021 11:48 AM To: [email protected] Subject: matplotlib questions I am trying to modify the "Bar Graph Demo" at https://matplotlib.org/stable/gallery/index.html, Lines, bars, and markers but the more I experiment and change the code, the more messed up it becomes. I have the demo code working. This is my second attempt. I guess I accidentally got my first chart working but this second one, not so good. Is there any source to help me understand how the code works and how to change it? Among many others options, how do I change the font size? How are the labels placed on the X-axis and Y-axis? -- https://mail.python.org/mailman/listinfo/python-list
sha3 internal state export & import
The hashlib module's SHA3 functions (specifically, sha3_256 & sha3_512) are not able to be pickled as far as I'm able to see. I know that the internal state of a SHA3 object can be easily represented by two unique values, the 1600-bit `S`-state value, and the last, smaller than `r`-rate number of bits (1088 for sha3_256, and 576 for sha3_512) of data which have not yet been incorporated into the `S`-state. Is there a simple way to export these two internal values from a sha3_256 or sha3_512 object, and conversely, a simple way to import these two exported values back into a new object? The goal is to be able to pause a hash object, then to store the state for some later time at which a new object can be created that's functionally equivalent to the first. Is there a simple way to do this? Best, rmlibre -- https://mail.python.org/mailman/listinfo/python-list
Re: matplotlib questions
> I am trying to modify the "Bar Graph Demo" at > https://matplotlib.org/stable/gallery/index.html, Lines, bars, and > markers > but the more I experiment and change the code, the more messed up it > becomes. It is much easier to give constructive suggestions if you give a minimum runnable code sample that indicates what you're trying and what you're trying to do. See also http://catb.org/~esr/faqs/smart-questions.html I'll also note that I see nothing called "bar graph demo" on the gallery page. - DLD -- https://mail.python.org/mailman/listinfo/python-list
Re: configargparse - reading option from config only
On 8/27/21 3:37 AM, Loris Bennett wrote: > Richard Damon writes: > >> On 8/26/21 6:01 AM, Loris Bennett wrote: >>> Hi, >>> >>> When using configargparse, it seems that if a value is to be read from a >>> config file, it also has to be defined as a command-line argument in >>> order to turn up as an attribute in the parser namespace. >>> >>> I can sort of see why this is the case, but there are also some options >>> I would like to read just from the config file and not have them >>> available as command-line options. This would be, say, to prevent the >>> number of options on the command-line from becoming bloated by >>> little-used settings. >>> >>> Is there an elegant way to do this? >>> >>> Cheers, >>> >>> Loris >>> >> Look at the read() member function to supply the file name to read. Then >> in the config object there will be sections for each section in the >> config file. No need for any of these to be 'options' > Do you have a link for this? As far as I can see, the config files are > given in the following manner: > > p = > configargparse.ArgParser(default_config_files=['/etc/app/conf.d/*.conf', > '~/.my_settings']) > > I can obviously just read the config file with configparser, but the > idea of configargparse is that an option can be specified as an option, > in a config file, or as an environment variable, > > As far as I can tell, configargparse only loads entries from the config > file into the appropriate namespace if they have also been defined as > long options (i.e. with '--'). I was hoping to access *all* the config > file entries, regardless of whether they are also options, since the > config is obviously being read. > > Cheers, > > Loris > I misread your question, I thought you were talking about configparse. Question is, if configargparse doesn't do what you want, then it isn't the right tool. It looks like configargparse is SPECIFICALLY designed to allow the use to use a file as a shorthand to present command line arguements. The whole parsing structure is based on an enumerated set of options, if that isn't what you have, it is the wrong tool. -- Richard Damon -- https://mail.python.org/mailman/listinfo/python-list
RE: matplotlib questions
I would like to know how the data is placed on the Y-axis and at the tops of
the bars.
The data is not being shown properly. With some exceptions, it looks as if
the data is getting sorted independently from the dates.
OK, here is the code:
==
# https://matplotlib.org/stable/gallery/index.html
import matplotlib.pyplot as plt
import numpy as np
width = 12 #Width of the graph
height = 6 #Height of the graph
plt.rcParams["figure.figsize"] = (width,height)
plt.rcParams["font.size"] = (9.0)
Count = 0
datesList = [] # Each date showing end of bottle use
hoursList = [] # Number of hours
# daysList = [] # Number of days calculated from hours/24
countList = [] # simple tally
with open("__Insulin_Tracker.txt", 'r') as infile:
for lineEQN in infile:
insulinHours = lineEQN[47:52].strip()
print("Hours = " + insulinHours)
hoursList.append(insulinHours)
insulinDates = lineEQN[20:30].strip()
datesList.append(insulinDates)
#insulinDays= lineEQN[57:62].strip()
#daysList.append(insulinDays)
Count += 1
countList.append(str(Count))
# print("" + str(Count) + " " + insulinDates + " Hours: " +
insulinHours)
x = Count
count = str(Count)
# Each date indicated the date on which a bottle of insulin has been
depleted
# The bar is to show the number of hours that the bottle has been in use.
Labels = datesList
Xdata= hoursList
Title = ("Bottle List Number of entries: " + count)
x = np.arange(len(Labels)) # the label locations
width = 0.35 # the width of the bars
margin = 0
fig, ax = plt.subplots()
fig.tight_layout(pad=10) # Sets the size of the graph
rects1 = ax.bar(x - width/2, Xdata, width, label='Hours') #Populates the x
axis
# Add some text for labels, title and custom x-axis tick labels, etc.
# fontsize = 20
ax.set_ylabel('Hours of use for each bottle')
ax.set_title(Title)
ax.set_xticks(x)
ax.set_xticklabels((datesList), rotation = 90) #Dates at bottom of the graph
ax.legend()
ax.bar_label(rects1, padding=0,rotation = 90)
plt.show()
===
Here is my data in __Insulin_Tracker.txt (with indents)
===
Sat Jan 02, 2021 15 29 1.21
Thu Jan 07, 2021 01116 4.83
Tue Jan 12, 2021 01120 5.00
Fri Jan 15, 2021 23 74 3.08
Tue Jan 19, 2021 22 95 3.96
Fri Jan 22, 2021 21 71 2.96
Tue Jan 26, 2021 08103 4.29
Sun Jan 31, 2021 23115 4.79
Fri Feb 05, 2021 01118 4.92
Mon Feb 08, 2021 20 71 2.96
Thu Feb 11, 2021 18 80 3.33
Tue Feb 16, 2021 08120 5.00
Fri Feb 19, 2021 18 72 3.00
Wed Feb 24, 2021 01113 4.71
Sun Feb 28, 2021 22 97 4.04
Thu Mar 04, 2021 11 95 3.96
Mon Mar 08, 2021 18103 4.29
Sat Mar 13, 2021 15117 4.88
Wed Mar 17, 2021 10 91 3.79
Sun Mar 21, 2021 00 96 4.00
Fri Mar 26, 2021 00120 5.00
Tue Mar 30, 2021 17103 4.29
Sat Apr 03, 2021 00 89 3.71
Wed Apr 07, 2021 23 99 4.12
Sun Apr 11, 2021 05 98 4.08
Thu Apr 15, 2021 14 95 3.96
Sun Apr 18, 2021 23 71 2.96
Fri Apr 23, 2021 23120 5.00
Tue Apr 27, 2021 17100 4.17
Tue Jul 27, 2021 21 2178 90.75
Sun Aug 01, 2021 18127 5.29
Thu Aug 05, 2021 23 91 3.79
Tue Aug 10, 2021 17124 5.17
Sat Aug 14, 2021 21 90 3.75
Thu Aug 19, 2021 09128 5.33
Wed Aug 25, 2021 02137 5.71
-Original Message-
From: Python-list On
Behalf Of David Lowry-Duda
Sent: Friday, August 27, 2021 3:25 PM
To: [email protected]
Subject: Re: matplotlib questions
> I am trying to modify the "Bar Graph Demo" at
> https://matplotlib.org/stable/gallery/index.html, Lines, bars, and
> markers but the more I experiment and change the code, the more messed
> up it becomes.
It is much easier to give constructive suggestions if you give a minimum
runna
