Re: log file

2019-03-24 Thread Sharan Basappa
On Sunday, 24 March 2019 10:57:13 UTC+5:30, Cameron Simpson  wrote:
> On 23Mar2019 21:47, Sharan Basappa  wrote:
> >On Friday, 22 March 2019 09:13:18 UTC+5:30, MRAB  wrote:
> >> On 2019-03-22 03:25, Sharan Basappa wrote:
> >> > I am running a program and even though the program runs all fine, the 
> >> > log file is missing. I have pasted first few lines of the code.
> >> > Any suggestions where I maybe going wrong?
> [...]
> >> > #Create and configure logger
> >> > logging.basicConfig(filename="test_1.log", filemode='w', 
> >> > format='%(asctime)s %(message)s')
> >> >
> >> Are you sure that you know where it's putting the log file? You have a
> >> relative path there, but relative to where? Try it with an absolute path.
> >>
> >> Are you sure that it's logging anything? Log a simple message just after
> >> configuring to double-check.
> >
> >Would the file not get logged using the current directory?
> 
> It should be.
> 
> >BTW, I changed the file location as follows and still I don't see it:
> >
> >logging.basicConfig(filename="D:\Users\sharanb\OneDrive - HCL 
> >Technologies Ltd\Projects\MyBackup\Projects\Initiatives\machine 
> >learning\programs\assertion\CNN\test_1.log", filemode='w', 
> >format='%(asctime)s %(message)s')
> 
> Did you read my other recent post? You should define strings with 
> backslashes in them such are your file path as 'raw strings', which 
> start with r' or r" instead of a plain quote character. Raw strings do 
> not interpret \x escapes. In particular your path above has a '\a' in 
> it, which is not a backslash followed by an "a", it is a BEL character.
> 
> That said, I can't see what's wrong with your original example which has 
> no backslashes.
> 
> Cheers,
> Cameron Simpson 

Ah. I finally solved the issue though I don't know what the problem itself it.
This is how the new code looks like:

for handler in logging.root.handlers[:]:
logging.root.removeHandler(handler)

#Create and configure logger
filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), 
'test_1.log')
logging.basicConfig(filename=filename, filemode='w', format='%(asctime)s 
%(message)s')

I found the above tip from the following discussion:
https://stackoverflow.com/questions/30861524/logging-basicconfig-not-creating-log-file-when-i-run-in-pycharm
-- 
https://mail.python.org/mailman/listinfo/python-list


scatter plot error - possibly data type

2019-03-24 Thread ciaran . hudson
Hi,

Can anyone help me with this error?
I suspect it is something to do with the data type, but don't know how to 
resolve.
I'm trying to plot a 2 user system dates against each other and am getting the 
error below.

print(type(DialogUsers.TRDAT))


plt.scatter(DialogUsers.TRDAT, DialogUsers.ERDAT)
plt.show()
---
TypeError Traceback (most recent call last)
 in ()
> 1 plt.scatter(DialogUsers.TRDAT, DialogUsers.ERDAT)
  2 plt.show()

~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\pyplot.py in 
scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, 
edgecolors, hold, data, **kwargs)
   3473  vmin=vmin, vmax=vmax, alpha=alpha,
   3474  linewidths=linewidths, verts=verts,
-> 3475  edgecolors=edgecolors, data=data, **kwargs)
   3476 finally:
   3477 ax._hold = washold

~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\__init__.py in 
inner(ax, *args, **kwargs)
   1865 "the Matplotlib list!)" % (label_namer, 
func.__name__),
   1866 RuntimeWarning, stacklevel=2)
-> 1867 return func(ax, *args, **kwargs)
   1868 
   1869 inner.__doc__ = _add_data_doc(inner.__doc__,

~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\axes\_axes.py 
in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, 
verts, edgecolors, **kwargs)
   4245 edgecolors = 'face'
   4246 
-> 4247 self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
   4248 x = self.convert_xunits(x)
   4249 y = self.convert_yunits(y)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\axes\_base.py 
in _process_unit_info(self, xdata, ydata, kwargs)
   2170 # we only need to update if there is nothing set yet.
   2171 if not self.yaxis.have_units():
-> 2172 self.yaxis.update_units(ydata)
   2173 
   2174 # process kwargs 2nd since these will override default units

~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\axis.py in 
update_units(self, data)
   1467 neednew = self.converter != converter
   1468 self.converter = converter
-> 1469 default = self.converter.default_units(data, self)
   1470 if default is not None and self.units is None:
   1471 self.set_units(default)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\category.py in 
default_units(data, axis)
113 # default_units->axis_info->convert
114 if axis.units is None:
--> 115 axis.set_units(UnitData(data))
116 else:
117 axis.units.update(data)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\category.py in 
__init__(self, data)
180 self._counter = itertools.count(start=0)
181 if data is not None:
--> 182 self.update(data)
183 
184 def update(self, data):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\category.py in 
update(self, data)
199 for val in OrderedDict.fromkeys(data):
200 if not isinstance(val, VALID_TYPES):
--> 201 raise TypeError("{val!r} is not a 
string".format(val=val))
202 if val not in self._mapping:
203 self._mapping[val] = next(self._counter)

TypeError: nan is not a string


Thanks,
Ciarán
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: log file

2019-03-24 Thread Luuk


On 24-3-2019 09:50, Sharan Basappa wrote:


Ah. I finally solved the issue though I don't know what the problem itself it.



The problem, shown with a simple example

Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 
32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> print ("hallo")
hallo
>>> print ("h\allo")
hllo
>>> print (r"h\allo")
h\allo
>>>

The first line is a simple print statement to print the text "hallo"   
(which is Dutch for "hello")


In the second line i added a '\' (backslash), the letter 'a' seems to be 
missing, unless audio on your computer works. If audio works you will 
hear a bell.

(see: https://docs.python.org/2.0/ref/strings.html )

In the third line a 'r' is put in front of the string, and now the 'a' 
is shown again (and also the '\').



In your path there is something like '...programs\assertion\CNN..'.

Python does see a '\a', after 'programs', and before 'ssertion', and 
tries to sound a 'bell'





--
https://mail.python.org/mailman/listinfo/python-list


Re: log file

2019-03-24 Thread Sharan Basappa
On Sunday, 24 March 2019 14:20:36 UTC+5:30, Sharan Basappa  wrote:
> On Sunday, 24 March 2019 10:57:13 UTC+5:30, Cameron Simpson  wrote:
> > On 23Mar2019 21:47, Sharan Basappa  wrote:
> > >On Friday, 22 March 2019 09:13:18 UTC+5:30, MRAB  wrote:
> > >> On 2019-03-22 03:25, Sharan Basappa wrote:
> > >> > I am running a program and even though the program runs all fine, the 
> > >> > log file is missing. I have pasted first few lines of the code.
> > >> > Any suggestions where I maybe going wrong?
> > [...]
> > >> > #Create and configure logger
> > >> > logging.basicConfig(filename="test_1.log", filemode='w', 
> > >> > format='%(asctime)s %(message)s')
> > >> >
> > >> Are you sure that you know where it's putting the log file? You have a
> > >> relative path there, but relative to where? Try it with an absolute path.
> > >>
> > >> Are you sure that it's logging anything? Log a simple message just after
> > >> configuring to double-check.
> > >
> > >Would the file not get logged using the current directory?
> > 
> > It should be.
> > 
> > >BTW, I changed the file location as follows and still I don't see it:
> > >
> > >logging.basicConfig(filename="D:\Users\sharanb\OneDrive - HCL 
> > >Technologies Ltd\Projects\MyBackup\Projects\Initiatives\machine 
> > >learning\programs\assertion\CNN\test_1.log", filemode='w', 
> > >format='%(asctime)s %(message)s')
> > 
> > Did you read my other recent post? You should define strings with 
> > backslashes in them such are your file path as 'raw strings', which 
> > start with r' or r" instead of a plain quote character. Raw strings do 
> > not interpret \x escapes. In particular your path above has a '\a' in 
> > it, which is not a backslash followed by an "a", it is a BEL character.
> > 
> > That said, I can't see what's wrong with your original example which has 
> > no backslashes.
> > 
> > Cheers,
> > Cameron Simpson 
> 
> Ah. I finally solved the issue though I don't know what the problem itself it.
> This is how the new code looks like:
> 
> for handler in logging.root.handlers[:]:
> logging.root.removeHandler(handler)
> 
> #Create and configure logger
> filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), 
> 'test_1.log')
> logging.basicConfig(filename=filename, filemode='w', format='%(asctime)s 
> %(message)s')
> 
> I found the above tip from the following discussion:
> https://stackoverflow.com/questions/30861524/logging-basicconfig-not-creating-log-file-when-i-run-in-pycharm

I think I got some more idea about the issue though I still don't know the root 
cause.
So, my test program is importing design file.
Both test and design file are have the following lines:
#Create and configure logger
filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), 
'test_5.log')
logging.basicConfig(filename=filename, filemode='w', format='%(asctime)s 
%(message)s')
#Creating an object
logger = logging.getLogger()

I think this is causing the issue. Anyway, I am able to log from the test 
program. However, I am not able to log anything from design program.

I will open a separate thread on this topic.
-- 
https://mail.python.org/mailman/listinfo/python-list


Multiple log files using logging module

2019-03-24 Thread Sharan Basappa
I have a test program that imports a design program.
Both the programs need to log messages.

I have tried the following:

1) Both the programs have the following lines:
for handler in logging.root.handlers[:]:
logging.root.removeHandler(handler)

#Create and configure logger
filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), '<>')
logging.basicConfig(filename=filename, filemode='w', format='%(asctime)s 
%(message)s')
#Creating an object
logger = logging.getLogger()
#Setting the threshold of logger to DEBUG
logger.setLevel(logging.DEBUG)

replace <> above with respective log file names for test and design programs.
However, the test program logs the messages but not the design program.

2) I removed the above lines from design program altogether hoping that the 
messages will appear in the same log file. There is no error, however, no 
message is logged from the design program.

I would like to get comment from members here as well as some simple programs 
to illustrate this ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiple log files using logging module

2019-03-24 Thread Luuk

On 24-3-2019 18:13, Sharan Basappa wrote:

I have a test program that imports a design program.
Both the programs need to log messages.

I have tried the following:

1) Both the programs have the following lines:
for handler in logging.root.handlers[:]:
 logging.root.removeHandler(handler)
 
#Create and configure logger

filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), '<>')
logging.basicConfig(filename=filename, filemode='w', format='%(asctime)s 
%(message)s')
#Creating an object
logger = logging.getLogger()
#Setting the threshold of logger to DEBUG
logger.setLevel(logging.DEBUG)

replace <> above with respective log file names for test and design programs.
However, the test program logs the messages but not the design program.

2) I removed the above lines from design program altogether hoping that the 
messages will appear in the same log file. There is no error, however, no 
message is logged from the design program.

I would like to get comment from members here as well as some simple programs 
to illustrate this ...



As mentioned in your other thread, you should take note on HOW you put 
the filenames in there.


How do you see the end of the line starting with 'filename =...'?


Is it like:
for TEST:, 'TEST')
for DESIGN: , 'DESIGN')

or did you put a full pathname in there?

and, if you did put a full pathname in there (i.e. 'D:\TEMP\TEST' ),
did you also put the 'r' in front of it, like this:
   , r'D:\TEMP\TEST')


--
Luuk
--
https://mail.python.org/mailman/listinfo/python-list


Re: Multiple log files using logging module

2019-03-24 Thread DL Neil

On 25/03/19 6:13 AM, Sharan Basappa wrote:

I have a test program that imports a design program.
Both the programs need to log messages.
...> I would like to get comment from members here as well as some 
simple programs to illustrate this ...



Have you copied this code from somewhere?

Which tutorial, book, web article, or ??? are you using as your learning 
material?


--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Multiple log files using logging module

2019-03-24 Thread Peter Otten
Luuk wrote:

> On 24-3-2019 18:13, Sharan Basappa wrote:
>> I have a test program that imports a design program.
>> Both the programs need to log messages.
>> 
>> I have tried the following:
>> 
>> 1) Both the programs have the following lines:
>> for handler in logging.root.handlers[:]:
>>  logging.root.removeHandler(handler)
>>  
>> #Create and configure logger
>> filename = os.path.join(os.path.dirname(os.path.realpath(__file__)),
>> '<>') logging.basicConfig(filename=filename, filemode='w',
>> format='%(asctime)s %(message)s')
>> #Creating an object
>> logger = logging.getLogger()
>> #Setting the threshold of logger to DEBUG
>> logger.setLevel(logging.DEBUG)
>> 
>> replace <> above with respective log file names for test and design
>> programs. However, the test program logs the messages but not the design
>> program.
>> 
>> 2) I removed the above lines from design program altogether hoping that
>> the messages will appear in the same log file. There is no error,
>> however, no message is logged from the design program.
>> 
>> I would like to get comment from members here as well as some simple
>> programs to illustrate this ...
>> 
> 
> As mentioned in your other thread, you should take note on HOW you put
> the filenames in there.

I don't think that's the problem. Rather, if you call logging.basicConfig() 
multiple times in the same program only the first invocation has an effect, 
and only if there weren't any handlers added to the root logger by other 
means.

> 
> How do you see the end of the line starting with 'filename =...'?
> 
> 
> Is it like:
> for TEST:, 'TEST')
> for DESIGN: , 'DESIGN')
> 
> or did you put a full pathname in there?
> 
> and, if you did put a full pathname in there (i.e. 'D:\TEMP\TEST' ),
> did you also put the 'r' in front of it, like this:
> , r'D:\TEMP\TEST')
> 
> 


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiple log files using logging module

2019-03-24 Thread Luuk

On 24-3-2019 19:33, Peter Otten wrote:

Luuk wrote:


On 24-3-2019 18:13, Sharan Basappa wrote:

I have a test program that imports a design program.
Both the programs need to log messages.

I have tried the following:

1) Both the programs have the following lines:
for handler in logging.root.handlers[:]:
  logging.root.removeHandler(handler)
  
#Create and configure logger

filename = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'<>') logging.basicConfig(filename=filename, filemode='w',
format='%(asctime)s %(message)s')
#Creating an object
logger = logging.getLogger()
#Setting the threshold of logger to DEBUG
logger.setLevel(logging.DEBUG)

replace <> above with respective log file names for test and design
programs. However, the test program logs the messages but not the design
program.

2) I removed the above lines from design program altogether hoping that
the messages will appear in the same log file. There is no error,
however, no message is logged from the design program.

I would like to get comment from members here as well as some simple
programs to illustrate this ...



As mentioned in your other thread, you should take note on HOW you put
the filenames in there.


I don't think that's the problem. Rather, if you call logging.basicConfig()
multiple times in the same program only the first invocation has an effect,
and only if there weren't any handlers added to the root logger by other
means.



It's not clear, at least not to me, if the programs are called from each 
other.


'test' and 'design' is not giving much info about what a program should do.



How do you see the end of the line starting with 'filename =...'?


Is it like:
for TEST:, 'TEST')
for DESIGN: , 'DESIGN')

or did you put a full pathname in there?

and, if you did put a full pathname in there (i.e. 'D:\TEMP\TEST' ),
did you also put the 'r' in front of it, like this:
 , r'D:\TEMP\TEST')








--
Luuk
--
https://mail.python.org/mailman/listinfo/python-list