Re: How do you debug in Python? Coming from a Matlab and R user. I'm already aware of pdb.

2021-01-26 Thread joseph pareti
To debug python code I use spyder from the anaconda distribution

Am Mittwoch, 27. Januar 2021 schrieb C W :

> Hi Michael,
> Here's the code again, class should be called PERSONDatabase, misspelled
> earlier:
> class PERSONDatabase:
>def __init__(self, id, created_at, name, attend_date, distance):
>   self._id = id
>   self.created_at = created_at
>   self.name= name
>   self.attend_date = attend_date
>   self.distance = distance
>
>@classmethod
>def get_person(self, employee):
>   return PERSONDatabase(employee['created_at'],
> employee['id'],
> employee['name'],
> employee['attend_date'],
> employee['distance'])
>
> The PERSONDatabase class is called from main. This is the trace back I got
> from the VS code:
>
> Traceback (most recent call last):
>File "/Users/Mike/Documents/Mike/main.py", line 95, in 
>   main()
>File "/Users/Mike/Documents/Mike/main.py", line 86, in main
>   args = get_feed()
>File "/Users/Mike/DocumentsMike/main.py", line 32, in get_feed
>   result = [PERSONatabase.get_person(raw_person) for raw_neo in
> raw_objects]
>File "/Users/Mike/Documents/Mike/main.py", line 32, in 
>   result = [NEODatabase.get_person(raw_person) for raw_neo in
> raw_objects]
>File "/Users/Mike/Documents/Mike/database.py", line 24, in get_person
>   return PERSONDatabase(person['created_at'],
> KeyError: 'created_at'
>
> Thank you very much!
>
> On Wed, Jan 27, 2021 at 12:10 AM Michael Torrie  wrote:
>
> > On 1/26/21 8:37 PM, C W wrote:
> > > I have a naive question. How do I use traceback or trace the stack? In
> > > particular, I'm using VS Code with Python interactive console.
> >
> > Show us the traceback here and we can help you interpret it.  Copy and
> > paste it from the VS Code console.
> >
> > > Say, I want to print the value of employee['name']. Can I do it?
> >
> > Yes I would think so.
> >
> > > My understanding is that these classes are just "skeletons". I must
> > > create an instance, assign values, then test?
> >
> > Can't you just do something like this?
> >
> > class NEODatabase:
> > def __init__(self, id, created_at, name, attend_date, distance):
> > self._id = id
> > self.created_at = created_at
> > self.name = name
> > self.attend_date = attend_date
> > self.distance = distance
> >
> > @classmethod
> > def get_person(self, employee):
> >     print (employee['name'])
> >
> > return PERSONDatabase(employee['created_at'],
> >   employee['id'],
> >   employee['name'],
> >   employee['attend_date'],
> >   employee['distance'])
> >
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Posting code on stackoverflow

2021-06-06 Thread joseph pareti
you need to put the code between 2 lines defined as follows:
```
then it will be formatted for you

Am Sa., 5. Juni 2021 um 23:40 Uhr schrieb Rich Shepard <
rshep...@appl-ecosys.com>:

> I tried to post a question on stackoverflow.com which included a bunch of
> code (entered after clicking the box 'code'). I noticed that lines were
> wrapped but could not find how to expand the input box so they would not
> wrap.
>
> SO wouldn't let me post the question because of the wrapped code. As I've
> not asked a question ther for a long time, and it didn't involve long lines
> of code, I need to learn a) how to enter code if it's not just clicking on
> the 'code' box before pasting text and b) how to keep code lines from
> wrapping so a horizontal scroll bar is made available.
>
> TIA,
>
> Rich
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


[Errno 2] No such file or directory:

2021-07-28 Thread joseph pareti
The following code fails as shown in the title:






*import subprocesscmd = 'ls -l
/media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
| awk "{print  $9 }"'process = subprocess.Popen([cmd],
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr =
process.communicate()print('stdout ',stdout)print('stderr ',stderr)*



Traceback (most recent call last):
  File "PreProcess_1a.py", line 3, in 
process = subprocess.Popen([cmd],  stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
  File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line 854,
in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line
1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ls -l
/media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
| awk "{print  $9

-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Errno 2] No such file or directory:

2021-07-29 Thread joseph pareti
indeed. There are better options than the one I attempted. Thanks for the
advice

Am Mi., 28. Juli 2021 um 18:19 Uhr schrieb Chris Angelico :

> On Thu, Jul 29, 2021 at 2:10 AM joseph pareti 
> wrote:
> >
> > The following code fails as shown in the title:
> >
> >
> >
> >
> >
> >
> > *import subprocesscmd = 'ls -l
> >
> /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
> > | awk "{print  $9 }"'process = subprocess.Popen([cmd],
> >  stdout=subprocess.PIPE, stderr=subprocess.PIPE)stdout, stderr =
> > process.communicate()print('stdout ',stdout)print('stderr ',stderr)*
> >
> > 
> >
> > Traceback (most recent call last):
> >   File "PreProcess_1a.py", line 3, in 
> > process = subprocess.Popen([cmd],  stdout=subprocess.PIPE,
> > stderr=subprocess.PIPE)
> >   File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line
> 854,
> > in __init__
> > self._execute_child(args, executable, preexec_fn, close_fds,
> >   File "/home/joepareti54/anaconda3/lib/python3.8/subprocess.py", line
> > 1702, in _execute_child
> > raise child_exception_type(errno_num, err_msg, err_filename)
> > FileNotFoundError: [Errno 2] No such file or directory: 'ls -l
> >
> /media/joepareti54/Elements/x/finance-2020/AI/Listen_attend_spell/VCTK-Corpus/wav48
> > | awk "{print  $9
> >
>
> First off, you'll want to post code in a way that keeps the
> formatting, otherwise it becomes very hard to read.
>
> But the immediate problem here is that Popen takes an array of command
> arguments, NOT a shell command line. You cannot invoke ls and pipe it
> into awk this way.
>
> Don't think like a shell script. Python has very good
> directory-listing functionality, and you will very very seldom need to
> shell out to pipelines. Figure out what you actually need to learn
> from the directory listing and get that information directly, rather
> than trying to use two external commands and text parsing. It's far
> FAR easier, cleaner, and safer that way.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


question on trax

2021-08-17 Thread joseph pareti
In the following code, where does tl.Fn come from? i see it nowhere in the
documents, i.e I was looking for trax.layers.Fn :

import numpy as np
*from trax import layers as tl*
from trax import shapes
from trax import fastmath
#
def Addition():
layer_name = "Addition"  # don't forget to give your custom layer a
name to identify

# Custom function for the custom layer
def func(x, y):
return x + y

return *tl.Fn*(layer_name, func)


# Test it
add = Addition()
# Inspect properties
print("-- Properties --")
print("name :", add.name)
print("expected inputs :", add.n_in)
print("promised outputs :", add.n_out, "\n")

# Inputs
x = np.array([3])
y = np.array([4])
print("-- Inputs --")
print("x :", x, "\n")
print("y :", y, "\n")

# Outputs
z = add((x, y))
print("-- Outputs --")
print("z :", z)

-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: question on trax

2021-08-18 Thread joseph pareti
yes, but I do not see Fn anywhere.

Another question is on this line:
z = add((x, y))
If I code:
z = add(x, y)
Then the following exception occurs :

*Expected input to be a tuple or list; instead got .*


Am Di., 17. Aug. 2021 um 19:21 Uhr schrieb MRAB :

> On 2021-08-17 16:50, joseph pareti wrote:
> > In the following code, where does tl.Fn come from? i see it nowhere in
> the
> > documents, i.e I was looking for trax.layers.Fn :
> >
> > import numpy as np
> > *from trax import layers as tl*
> > from trax import shapes
> > from trax import fastmath
> > #
> > def Addition():
> >  layer_name = "Addition"  # don't forget to give your custom layer a
> > name to identify
> >
> >  # Custom function for the custom layer
> >  def func(x, y):
> >  return x + y
> >
> >  return *tl.Fn*(layer_name, func)
> >
> [snip]
> It comes from using the line:
>
>  from trax import layers as tl
>
> so it's equivalent to 'trax.layers.Fn'.
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


code to initialize a sequence

2021-08-29 Thread joseph pareti
In the code attached below, the A-variant is from somebody else who knows
Python better than I. But I do not like to just use any code without having
a grasp, specifically the line in* bold*, so I wrote the B-variant which
gives the same results. The C-variant is identical to A and is there for
verification: after resetting the seed I expect the same sequence. The
D-variant is closer to the way I code, and it does not work.


import random
from random import randint, seed

def generate_sequence(length, n_unique):
*return [randint(0, n_unique-1) for k in range(length)]*

def generate_sequence_JP(length, n_unique):
   LI = []
   for k in range(length):
 LI.append(randint(0, n_unique-1))
   return(LI)
def generate_sequence_EXPLICIT(length, n_unique):
   X =[None] * length
  for i in range(length):
X[i] = [randint(0, n_unique-1)]
   return X
#
# MAIN PROGRAM
#
random.seed(2)
A = generate_sequence(4, 10 )
random.seed(2)
B = generate_sequence_JP(4, 10)
random.seed(2)
C = generate_sequence(4, 10 )
random.seed(2)
D = generate_sequence_EXPLICIT(4, 10 )
print(A)
print(type(A))
print('-')
print(B)
print(type(B))
print('-')
print(C)
print(type(C))
print('-')
print(D)
print(type(D))


Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


issues when buidling python3.* on centos 7

2018-03-25 Thread joseph pareti
I have a VM in the cloud running centos that comes with python 2.7
installed on it. For my purpose, I need python 3.5 (or 6?)

However there is an issue with urlgrabber, and I  believe this is due to
inconsistencies with the 2 python versions, whcih I am not able to resolve.

DETAILS

INSTALL PYTHON 3 from scratch
https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-centos-7

change /usr/bin/yum because yum does not support python 3 so force it to
use python 2 in first line, else you get this:
except KeyboardInterrupt, e:

edits in  /usr/libexec/urlgrabber-ext-down to remove syntax errors


sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm
[joepareti54@xxx ~]$ sudo yum -y install python36u
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * epel: ftp.nluug.nl
 * ius: mirror.amsiohosting.net
Traceback (most recent call last):
  File "/usr/libexec/urlgrabber-ext-down", line 22, in 
from urlgrabber.grabber import \
ModuleNotFoundError: No module named 'urlgrabber'


Exiting on user cancel
[joepareti54@xxx ~]$

therefore

wget
http://mirror.centos.org/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm

sudo yum install python-urlgrabber-3.10-8.el7.noarch.rpm

now rerun sudo yum -y install python36u

basically same as here https://www.centos.org/forums/viewtopic.php?t=52325

the urlgrabber is not found

The following may give a clue because of inconsistent python versions:

[joepareti54@xxx ~]$ python -V
Python 3.5.2 :: Anaconda 4.3.0 (64-bit)

[joepareti54@xxx ~]$ rpm -ql python-urlgrabber | xargs -i dirname '{}' |
sort | uniq | grep site-packages

/usr/lib/python2.7/site-packages
/usr/lib/python2.7/site-packages/urlgrabber
[joepareti54@xxx ~]$

so the install of python-urlgrabber-3.10-8.el7.noarch.rpm landed in the
wrong place as suggested here
https://forums.fedoraforum.org/showthread.php?95680-yum-broken-(-quot-No-module-named-urlgrabber-quot-)
and the inconsistency explains why the grabber module is not found
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: issues when buidling python3.* on centos 7

2018-03-29 Thread joseph pareti
thank you so much. here's more detail on my troubleshooting.

-

STARTING POINT:
https://github.com/google/FluidNet


as shown in the readme files, the deployment calls for the following step:

cd FluidNet/manta/build
./manta ../scenes/_trainingData.py --dim 3 --addModelGeometry True
--addSphereGeometry True

The above command should produce the training data, so that torch will work
on it to train the deep network.

However, it fails due to incompatibilities of python 2.7 and 3.x; the
problem is described in:

https://stackoverflow.com/questions/49296737/invalid-syntax-in-python-function

The option of removing python constructs that are only supported in python
3 is not successful because there are more dependencies than just a couple
of statements, namely in the Simplified Wrapper Interface Generator (or
SWIG) which assumes python3.

Therefore, I need a python 3 environment. STEPS:

sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm
sudo yum shell
  remove python36-3.6.3-7.el7.x86_64
  remove python36-libs-3.6.3-7.el7.x86_64
  install python36u-3.6.4-1.ius.centos7.x86_64
  install python36u-libs-3.6.4-1.ius.centos7.x86_64
  run

[joepareti54@xxx ~]$ sudo yum install python36u
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * epel: epel.mirror.wearetriple.com
 * ius: mirror.amsiohosting.net
Package python36u-3.6.4-1.ius.centos7.x86_64 already installed and latest
version
Nothing to do
[joepareti54@xxx ~]$

ASSUMING python36 is now fine, so moving to the next step.

sudo yum -y install python36u-pip
sudo yum install python36u-devel

>From here on, it's manta-application specific:

cmake .. -DGUI='OFF' >> cmake-10.log 2>&1
make -j8 >> make-10.log 2>&1
./manta ../scenes/_trainingData.py --dim 3 --addModelGeometry True
--addSphereGeometry True

Version: mantaflow 64bit fp1 commit
dd3bb0c0a65cc531d3c33487bde5edcb4aa6784f from Mar 29 2018, 15:21:34
Loading script '../scenes/_trainingData.py'
Traceback (most recent call last):
  File "../scenes/_trainingData.py", line 13, in 
from voxel_utils import VoxelUtils
  File "/home/joepareti54/FluidNet/manta/scenes/voxel_utils.py", line 1, in

import numpy as np
ModuleNotFoundError: No module named 'numpy'
Script finished.

cmake options are specified in the CMakeCache.txt file, and those can be
edited to select the right python environment as explained in:

https://stackoverflow.com/questions/15291500/i-have-2-versions-of-python-installed-but-cmake-is-using-older-version-how-do

In my case i have following settings:

joepareti54@xxx build]$ cat CMakeCache.txt | grep -i python

//Compile without python support (limited functionality!)

PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3.6m

PYTHON_INCLUDE_DIR:PATH=/usr/include/python3.6m

PYTHON_LIBRARY:FILEPATH=/usr/lib64/libpython3.6m.so

FIND_PACKAGE_MESSAGE_DETAILS_PythonLibs:INTERNAL=[/usr/lib64/
libpython3.6m.so][/usr/include/python3.6m][v3.6.4()]


I don't see why manta cannot find numpy, because python does find it:

[joepareti54@xxx ~]$ python
Python 3.5.2 |Anaconda 4.3.0 (64-bit)| (default, Jul  2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
[joepareti54@xxx ~]$

Also note that system wide python 2.7 is still there, and it is required by
centos:

[joepareti54@xxx ~]$ ls -l /usr/bin/python
lrwxrwxrwx. 1 root root 18 Mar 29 08:00 /usr/bin/python ->
/usr/bin/python2.7
[joepareti54@xxx ~]$


In addition:
[joepareti54@xxx build]$ python3.6 -V
Python 3.6.3
[joepareti54@xxx build]$ which python
/anaconda/envs/py35/bin/python
[joepareti54@xxx build]$ file /anaconda/envs/py35/bin/python
/anaconda/envs/py35/bin/python: symbolic link to `python3.5'
[joepareti54@xxx build]$ ls -l /anaconda/envs/py35/bin/python
lrwxrwxrwx. 1 root root 9 Nov 10  2016 /anaconda/envs/py35/bin/python ->
python3.5
[joepareti54@xxx build]$ ls -l /usr/bin/python
lrwxrwxrwx. 1 root root 18 Mar 29 08:00 /usr/bin/python ->
/usr/bin/python2.7
[joepareti54@xxx build]$

CONCLUSION

In summary, I don't know whether this configuration is consistent or not
for building the manta application, and whether the python set-up is
consistent.
Also to be noted that the manta application was built by the authors on an
ubuntu platform, so my work is an adaption to centos



2018-03-27 4:07 GMT+02:00 Michael Torrie :

> On 03/25/2018 10:15 AM, joseph pareti wrote:
> > The following may give a clue because of inconsistent python versions:
> >
> > [joepareti54@xxx ~]$ python -V
> > Python 3.5.2 :: Anaconda 4.3.0 (64-bit)
>
> What does 'which python' return?  As Joseph said, hopefully you didn't
> overwrite /usr/bin/python with Python 3.5.  If you did, you're hosed.
> You&#x

permission denied when installing tensorflow on centos 7

2018-04-30 Thread joseph pareti
here are details on my attempt:


tensorflow for centos 7 installation guidelines are in:
https://gist.github.com/thoolihan/28679cd8156744a62f88

sudo yum -y install epel-release
sudo yum -y install gcc gcc-c++ python-pip python-devel atlas atlas-devel
gcc- gfortran openssl-devel libffi-devel
# use pip or pip3 as you prefer for python or python3
pip install --upgrade virtualenv
virtualenv --system-site-packages ~/venvs/tensorflow
source ~/venvs/tensorflow/bin/activate
pip install --upgrade numpy scipy wheel cryptography #optional
pip install --upgrade
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp35-
cp35m-linux_x86_64.whl
# or below if you want gpu, support, but cuda and cudnn are required, see
docs for more install instructions
pip install --upgrade
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0rc0-cp35-
cp35m-linux_x86_64.whl

EXECUTION /STEP 1
OK

EXECUTION /STEP 2
OK

EXECUTION /STEP 3
[joepareti54@xxx tensorflow_tmpdir]$ pip3 install --upgrade virtualenv >>
step3.txt 2>&1
[joepareti54@xxx tensorflow_tmpdir]$ cat step3.txt
Collecting virtualenv
  Downloading
https://files.pythonhosted.org/packages/ed/ea/e20b5cbebf45d3096e8138ab74eda139595d827677f38e9dd543e6015bdf/virtualenv-15.2.0-py2.py3-none-any.whl
(2.6MB)
Installing collected packages: virtualenv
Exception:
Traceback (most recent call last):
  File
"/anaconda/envs/py35/lib/python3.5/site-packages/pip/basecommand.py", line
215, in main
status = self.run(options, args)
  File
"/anaconda/envs/py35/lib/python3.5/site-packages/pip/commands/install.py",
line 342, in run
prefix=options.prefix_path,
  File
"/anaconda/envs/py35/lib/python3.5/site-packages/pip/req/req_set.py", line
784, in install
**kwargs
  File
"/anaconda/envs/py35/lib/python3.5/site-packages/pip/req/req_install.py",
line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File
"/anaconda/envs/py35/lib/python3.5/site-packages/pip/req/req_install.py",
line 1064, in move_wheel_files
isolated=self.isolated,
  File "/anaconda/envs/py35/lib/python3.5/site-packages/pip/wheel.py", line
345, in move_wheel_files
clobber(source, lib_dir, True)
  File "/anaconda/envs/py35/lib/python3.5/site-packages/pip/wheel.py", line
323, in clobber
shutil.copyfile(srcfile, destfile)
  File "/anaconda/envs/py35/lib/python3.5/shutil.py", line 115, in copyfile
with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied:
'/anaconda/envs/py35/lib/python3.5/site-packages/virtualenv.py'
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[joepareti54@xxx tensorflow_tmpdir]$
-- 
https://mail.python.org/mailman/listinfo/python-list


syntax error (?) on ubuntu

2018-05-03 Thread joseph pareti
$ python tf_simple.py

/anaconda/envs/py35/lib/python3.5/site-packages/h5py/__init__.py:36:
FutureWarning: Conversion of the second argument of issubdtype from `float`
to `np.floating` is deprecated. In future, it will be treated as
`np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "tf_simple.py", line 29, in 
import uniio
  File "../tools/uniio.py", line 132
if(PY3K): ID = ID.decode("utf-8")
 ^
TabError: inconsistent use of tabs and spaces in indentation
-- 
https://mail.python.org/mailman/listinfo/python-list


ImportError: cannot import name _remove_dead_weakref

2018-05-03 Thread joseph pareti
on an Ubuntu VM with :


   1. Linux JP-Paid-UBUNTU-DSVM 4.13.0-1014-azure
   2. Python 3.5.4 :: Anaconda custom (64-bit)

$ manta manta_genSimData.py
Loading script 'manta_genSimData.py'
Traceback (most recent call last):

skipping some details

...
File "/anaconda/lib/python2.7/weakref.py", line 14, in 
from _weakref import (
*ImportError: cannot import name _remove_dead_weakref*
Script finished.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ImportError: cannot import name _remove_dead_weakref

2018-05-03 Thread joseph pareti
please excuse my full python ignorance, however if I set PYTHONPTAH as
shown below, then the results are quite different than before:

$ echo $PYTHONPATH
/backupdata/anaconda/lib/python2.7/
$ python tf_train_pressure.py
Fatal Python error: Py_Initialize: Unable to get the locale encoding
  File "/backupdata/anaconda/lib/python2.7/encodings/__init__.py", line 124
raise CodecRegistryError,\
^
SyntaxError: invalid syntax

Current thread 0x7f2b4459f700 (most recent call first):
Aborted (core dumped)


2018-05-03 19:15 GMT+02:00 Chris Angelico :

> On Fri, May 4, 2018 at 1:53 AM, joseph pareti 
> wrote:
> > on an Ubuntu VM with :
> >
> >
> >1. Linux JP-Paid-UBUNTU-DSVM 4.13.0-1014-azure
> >2. Python 3.5.4 :: Anaconda custom (64-bit)
> >
> > $ manta manta_genSimData.py
> > Loading script 'manta_genSimData.py'
> > Traceback (most recent call last):
> >
> > skipping some details
> >
> > ...
> > File "/anaconda/lib/python2.7/weakref.py", line 14, in 
> > from _weakref import (
> > *ImportError: cannot import name _remove_dead_weakref*
> > Script finished.
>
> Somehow, the details you're skipping include jumping from a Python
> 3.5.4 into a Python 2.7's standard library. Check your Anaconda
> settings and see if you have something bizarre going on with your
> PYTHONPATH.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ImportError: cannot import name _remove_dead_weakref

2018-05-04 Thread joseph pareti
thank you for the advice: depending on the value of PYTHONPATH (version
2.7, 3.5, or unset), tensorflow stops with 3 different error traps

2018-05-04 7:55 GMT+02:00 dieter :

> Chris Angelico  writes:
> > ...
> > Somewhere, you have a mismatch of versions. Make sure you're using the
> > same Python version for everything. You have some Python 2.7 messing
> > up your 3.5.
>
> I have had similar problems. In my case, an active "PYTHONPATH" envvar
> was responsible -- "unset"ting this envar has resolved the problem for me.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ImportError: cannot import name _remove_dead_weakref

2018-05-05 Thread joseph pareti
thanks for the hint, virtualenv looks like an interesting option, however
in my case I need to rely on several components that are already installed
in the VM in Azure, including tensorflow, etc.
If I use virtualenv, do I  need to start from scratch?

In addition, I am not sure this will solve my problem: all I have seen is
that the error code changes depending on the PYTHONPATH value. Perhaps it
is a bug in the application code?

2018-05-05 9:12 GMT+02:00 dieter :

> joseph pareti  writes:
> > thank you for the advice: depending on the value of PYTHONPATH (version
> > 2.7, 3.5, or unset), tensorflow stops with 3 different error traps
>
> "PYTHONPATH" usually is used when you have private Python modules
> not installed at the standard place. Nowadays, you can use
> a so called "virtual environment" for your local installations.
> Look whether "virtualenv" (or "venv") is installed in your environment.
> It can be used to create a virtual environment.
> Then install your own modules in this virtual environment --
> ensuring not to mix things for Python 2 and Python 3.
> Finally unset "PYTHONPATH" and run your Python in the virtual environment.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


basic question on how "import" works

2019-01-19 Thread joseph pareti
[*u23885@c009 3_NeuralNetworks]$ cat foo.py*
from __future__ import print_function

# Import MNIST data
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)

[u23885@c009 3_NeuralNetworks]$
when the above code is executed, equivalent of
*$ python foo.py*

the output is as follows:
...
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Extracting /tmp/data/train-images-idx3-ubyte.gz
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Extracting /tmp/data/train-labels-idx1-ubyte.gz
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Extracting /tmp/data/t10k-images-idx3-ubyte.gz
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting /tmp/data/t10k-labels-idx1-ubyte.gz
...
My questions are:

   1. where are the write / print statements that display *Successfully
   downloaded, extracting ...*
   2. I don't see any such files in /tmp/data on my system, why?
   3. (this is part of a code for training a neuronal network which works
   as expected, it's just for my own understanding of how this works -- Thank
   you)



-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


generate matplotlib images without having access to an X server

2019-01-23 Thread joseph pareti
The following piece of code is supposed to generate images for plotting:
(in *bold*, my added / corrected statements)
...
*# JP handle non X server*
*import matplotlib*
*matplotlib.use('Agg')*
# JP
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
...
# Generate images from noise, using the generator network.
f, a = plt.subplots(4, 10, figsize=(10, 4))
for i in range(10):
# Noise input.
z = np.random.uniform(-1., 1., size=[4, noise_dim])
g = sess.run([gen_sample], feed_dict={gen_input: z})
g = np.reshape(g, newshape=(4, 28, 28, 1))
# Reverse colours for better display
g = -1 * (g - 1)
for j in range(4):
# Generate image from noise. Extend to 3 channels for matplot
figure.
img = np.reshape(np.repeat(g[j][:, :, np.newaxis], 3, axis=2),
 newshape=(28, 28, 3))
a[j][i].imshow(img)
*# JP HAck*
*# see
https://matplotlib.org/faq/howto_faq.html#matplotlib-in-a-web-application-server
<https://matplotlib.org/faq/howto_faq.html#matplotlib-in-a-web-application-server>*
*# "tuple packing" ->
https://docs.python.org/2/tutorial/datastructures.html#tuples-and-sequences
<https://docs.python.org/2/tutorial/datastructures.html#tuples-and-sequences>*
*#f.show()*
*#plt.draw()*
*#plt.waitforbuttonpress()*
*#a.savefig('a.png')*
*f.savefig('f.png')*

To make it run, I commented out all plt.* statements. Indeed it runs and it
produces the 'f.png' picture.
However, when the statement:
a.savefig('a.png')
is also activated (i.e. not commented out), the program ends with the
following exception:


* a.savefig('a.png')*
*AttributeError: 'numpy.ndarray' object has no attribute 'savefig'*

Anything I am missing? I am not familiar with the code, just trying to
understand it.
Thank you
-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


issue with regular expressions

2019-10-22 Thread joseph pareti
the following code ends in an exception:

import re
pattern = 'Sottoscrizione unica soluzione'
mylines = []# Declare an empty list.
with open ('tmp.txt', 'rt') as myfile:  # Open tmp.txt for reading text.
for myline in myfile:   # For each line in the file,
mylines.append(myline.rstrip('\n')) # strip newline and add to list.
for element in mylines: # For each element in the list,
#print(element)
   match = re.search(pattern, element)
   s = match.start()
   e = match.end()
   print(element[s:e])


F:\October20-2019-RECOVERY\Unicredit_recovery\tmp_re_search>c:\Users\joepareti\Miniconda3\pkgs\python-3.7.1-h8c8aaf0_6\python.exe
search_0.py
Traceback (most recent call last):
  File "search_0.py", line 10, in 
s = match.start()
AttributeError: 'NoneType' object has no attribute 'start'

any help? Thanks
-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: issue with regular expressions

2019-10-22 Thread joseph pareti
Ok, thanks. It works for me.
regards,

Am Di., 22. Okt. 2019 um 11:29 Uhr schrieb Matt Wheeler :

>
>
> On Tue, 22 Oct 2019, 09:44 joseph pareti,  wrote:
>
>> the following code ends in an exception:
>>
>> import re
>> pattern = 'Sottoscrizione unica soluzione'
>> mylines = []# Declare an empty list.
>
> with open ('tmp.txt', 'rt') as myfile:  # Open tmp.txt for reading
>> text.
>> for myline in myfile:   # For each line in the file,
>> mylines.append(myline.rstrip('\n')) # strip newline and add to
>> list.
>> for element in mylines: # For each element in the
>> list,
>> #print(element)
>>match = re.search(pattern, element)
>>s = match.start()
>>e = match.end()
>>print(element[s:e])
>>
>>
>>
>> F:\October20-2019-RECOVERY\Unicredit_recovery\tmp_re_search>c:\Users\joepareti\Miniconda3\pkgs\python-3.7.1-h8c8aaf0_6\python.exe
>> search_0.py
>> Traceback (most recent call last):
>>   File "search_0.py", line 10, in 
>> s = match.start()
>> AttributeError: 'NoneType' object has no attribute 'start'
>>
>> any help? Thanks
>>
>
> Check over the docs for re.match again, you'll see it returns either a
> Match object (which is always truthy), or None.
>
> So a simple solution is to wrap your attempts to use the Match object in
>
> ```
> if match:
> ...
> ```
>
>>

-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


TypeError: unhashable type: 'list'

2019-10-23 Thread joseph pareti
I am experimnenting with this (reproducer) code:
pattern_eur= ['Total amount']
mylines = []# Declare an empty list.
with open ('tmp0.txt', 'rt') as myfile: # Open tmp.txt for reading text.
for myline in myfile:   # For each line in the file,
mylines.append(myline.rstrip('\n')) # strip newline and add to list.
for element in mylines: # For each element in the list,
   match_C = re.search(pattern_eur, element)
   if match_C:
 element = element + 2
 print(element)
--
the input file being:
$ cat tmp0.txt
line 0
line 1
Total amount

5.00
linex
line z
line c
Total amount

43598
line
line m

Total amount

32000
line end -1
line end 0
line end 1
line end 2

--

My intent is to locate the line containing "Total amount", skip the next
line, then print the eur value. The program terminates as follows:
Traceback (most recent call last):
  File "search_then_advance.py", line 8, in 
match_C = re.search(pattern_eur, element)
  File
"c:\Users\joepareti\Miniconda3\pkgs\python-3.7.1-h8c8aaf0_6\lib\re.py",
line 183, in search
return _compile(pattern, flags).search(string)
  File
"c:\Users\joepareti\Miniconda3\pkgs\python-3.7.1-h8c8aaf0_6\lib\re.py",
line 276, in _compile
return _cache[type(pattern), pattern, flags]
TypeError: unhashable type: 'list'

Thanks for any insigths --
-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


web scraper

2019-10-26 Thread joseph pareti
Thank you so much for your very valuable guidance on my python experiment.
Meanwhile the problems I reported before have been solved.

This is part of a program that extracts specific information from bank
transaction records, and one functionality I still need to implement is a *web
scraper*:

The eureka / guide <https://www.edureka.co/blog/web-scraping-with-python/>
"web scraping with python" provides some insights, that are however linked
to a specific website:
by associating the "inspected" web page with the code shown in the Eureka
page, one can build the algorithm, but
can it be generalized?
Not all tags are in the form of   https://www.flipkart.com/laptops/~buyback-guarantee-on-laptops-/pr?sid=6bo%2Cb5g&uniqBStoreParam1=val1&wid=11.productCard.PMU_V2>
contains all the needed data, while my case requires a lookup of one item
at a time, namely:
(i) loop over a bunch of ISIN codes
(ii) access a specific website (=morningstar?), that does the
ISIN-to-fund-name translation
(iii) "inspect" that page containing the result and grab the fund name.

I would appreciate any advice on how to program all this. Thanks.
-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hi there! We are here to answer any questions you have about Udacit...

2019-11-11 Thread joseph pareti
i have done the first 6 lessons of python ---
https://classroom.udacity.com/courses/ud1110/lessons/bbacebc6-406a-4dc5-83f6-ef7ba3371da6/concepts/50247542-7933-4afe-9130-ff1dff429b03

what do you recommend next? My goal is ML/AI

thank you ---


Am Do., 7. Nov. 2019 um 22:01 Uhr schrieb joseph pareti <
joeparet...@gmail.com>:

>
>
> -- Forwarded message -----
> Von: joseph pareti 
> Date: Do., 7. Nov. 2019 um 09:26 Uhr
> Subject: Re: Hi there! We are here to answer any questions you have about
> Udacit...
> To: Sherry from Udacity 
>
>
> apologies if you are not the right person to ask: I am doing the python
> tutorial at
> https://classroom.udacity.com/courses/ud1110/lessons/8655bee4-19e1-4de0-8177-4f895a74b57b/concepts/44a22f87-f7ce-4a9a-a1f5-86024edb0f29
>
> When I run the program in the provided environment I get an EOF exception
> (see screen dump).
>
> However, in my environment, windows 10, miniconda3, python 3.* it runs
> just fine. Why?
> I am also sending the program source code.
> ---
>
>
> F:\x\finance-2019\AI\python\udacity\input>c:\Users\joepareti\Miniconda3\pkgs\python-3.6.8-h9f7ef89_0\python.exe
> tmp_input.py
> Enter a number:
> 8
> your input is:  8
> corresponding int is:  8
> Oops!  Your guess was too high.
>
> F:\x\finance-2019\AI\python\udacity\input>c:\Users\joepareti\Miniconda3\pkgs\python-3.6.8-h9f7ef89_0\python.exe
> tmp_input.py
> Enter a number:
> 0
> your input is:  0
> corresponding int is:  0
> Oops!  Your guess was too low.
>
> F:\x\finance-2019\AI\python\udacity\input>c:\Users\joepareti\Miniconda3\pkgs\python-3.6.8-h9f7ef89_0\python.exe
> tmp_input.py
> Enter a number:
> 5
> your input is:  5
> corresponding int is:  5
> Nice!  Your guess matched the answer!
>
> Am Di., 29. Okt. 2019 um 21:22 Uhr schrieb Sherry from Udacity <
> sherry.ch...@udacity.com>:
>
>> Hi Joseph, I'm Sherry!
>>
>> It seems like we missed you. Before I go I would like to suggest you the
>> path you should follow:
>> If you're new to programming, we suggest starting your learning path by
>> building a strong foundation in the basics with our Intro to Programming
>> Nanodegree. Once you complete this course, you will have much better view
>> of what to take next:)
>> Intro to programming
>> <https://www.udacity.com/course/intro-to-programming-nanodegree--nd000>
>> | Syllabus
>> <https://d20vrrgs8k4bvw.cloudfront.net/documents/en-US/Introduction+to+Programming+Nanodegree+Syllabus.pdf>
>> The course comes with a Certificate as well as Mentorship Program, Expert
>> projects reviewers, Career Services and more!
>>
>> *Mentorship Program:*
>> When you enroll in a Udacity Nanodegree program, you'll be matched with a
>> 1-on-1 technical mentor. Mentors are individuals with strong subject matter
>> knowledge who are there to help you succeed in your Nanodegree program.
>> Your Mentor will
>>
>> -Respond to content-specific and project-specific questions you have
>> about your Nanodegree program
>> -Conduct 1-on-1 virtual meetings with you, at your request (you'll be
>> able to schedule one 1-on-1 each week, if needed)
>> -Motivate you to stay on track with your custom learning plan.
>>
>> *Career Services:*
>> As a student enrolled in a Nanodegree program, you'll have access to the
>> following career resources for 12 months after the graduation and during
>> the class to help you reach your goals:
>>
>> -1:1 Career Coaching appointment
>> -Career + Networking Events
>> -GitHub, LinkedIn, Resume, Cover Letter Reviews
>> -The Career Portal
>> -Membership in the Udacity Talent Program with top tech employers upon
>> graduation
>> -Send students resume to over 95 companies that we are partners with.
>> Let me know if you need to know anything else [image: +1]
>>
>> --
>> [image: Sherry] *Sherry* from Udacity
>> On Tue, Oct 29, 2019 at 03:12 PM, "Joseph" 
>> wrote:
>>
>> udacity told me that I first need to have good python knowledge, right?
>> On Tue, Oct 29, 2019 at 03:10 PM, "Carla" <
>> opera...@udacity-8fbceca20105.intercom-mail.com> wrote:
>>
>> *Great, we have advisors ready to answer your questions! To get started,
>> please put in your email so we can follow up in case we get disconnected:*
>>
>> *By providing your information and clicking “Submit,” you consent and
>> agree to receive marketing emails from Udacity, and that your information
>> will be used in accordance with the Udacity** Terms of Use*
>> <https://www.uda

apologies for my latest email; it was not intended for this mailing list

2019-11-11 Thread joseph pareti
-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


using classes

2020-03-12 Thread joseph pareti
The following code that uses a class 'Fahrzeug' and an inherited class
'PKW' runs correctly. However, if I use the 'super ' statement in in the
PKW class, it ends with the following error message:






*Traceback (most recent call last):  File "erben_a.py", line 19, in
fiat = PKW("Fiat Marea",50,0)  File "erben_a.py", line 11, in
__init__super(PKW, self).__init__()TypeError: __init__() missing 2
required positional arguments: 'bez' and 'ge'*

- CODE THAT WORKS ---
class Fahrzeug:
def __init__(self, bez, ge):
  self.bezeichnung = bez
  self.geschwindigkeit = ge
def beschleunigen(self, wert):
  self.geschwindigkeit += wert
def __str__(self):
  return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h"
class PKW(Fahrzeug):
def __init__(self, bez, ge, ins):
   Fahrzeug.__init__(self, bez, ge)
   self.insassen = ins
def __str__(self):
   return Fahrzeug.__str__(self) + " " + str(self.insassen) + "
Insassen"
def einsteigen(self, anzahl):
   self.insassen += anzahl
def aussteigen(self, anzahl):
   self.insassen -= anzahl
fiat = PKW("Fiat Marea",50,0)
fiat.einsteigen(3)
fiat.aussteigen(1)
fiat.beschleunigen(10)
print(fiat)

-CODE THAT FAILS --
class Fahrzeug:
def __init__(self, bez, ge):
  self.bezeichnung = bez
  self.geschwindigkeit = ge
def beschleunigen(self, wert):
  self.geschwindigkeit += wert
def __str__(self):
  return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h"
class PKW(Fahrzeug):
def __init__(self, bez, ge, ins):
   *super(PKW, self).__init__()*
   self.insassen = ins
def __str__(self):
   return Fahrzeug.__str__(self) + " " + str(self.insassen) + "
Insassen"
def einsteigen(self, anzahl):
   self.insassen += anzahl
def aussteigen(self, anzahl):
   self.insassen -= anzahl
fiat = PKW("Fiat Marea",50,0)
fiat.einsteigen(3)
fiat.aussteigen(1)
fiat.beschleunigen(10)
print(fiat)


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: using classes

2020-03-12 Thread joseph pareti
thank you, that fixes it. I also noticed that both statements work:

 super(PKW, self).__init__(bez,ge)

or

   super().__init__(bez,ge)

Am Do., 12. März 2020 um 12:58 Uhr schrieb MRAB :

> On 2020-03-12 10:54, joseph pareti wrote:
> > The following code that uses a class 'Fahrzeug' and an inherited class
> > 'PKW' runs correctly. However, if I use the 'super ' statement in in the
> > PKW class, it ends with the following error message:
> >
> >
> >
> > *Traceback (most recent call last):  File "erben_a.py", line 19, in
> > fiat = PKW("Fiat Marea",50,0)  File "erben_a.py", line 11, in
> > __init__super(PKW, self).__init__()TypeError: __init__() missing 2
> > required positional arguments: 'bez' and 'ge'*
> >
> > - CODE THAT WORKS ---
> > class Fahrzeug:
> >  def __init__(self, bez, ge):
> >self.bezeichnung = bez
> >self.geschwindigkeit = ge
> >  def beschleunigen(self, wert):
> >self.geschwindigkeit += wert
> >  def __str__(self):
> >return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h"
> > class PKW(Fahrzeug):
> >  def __init__(self, bez, ge, ins):
> > Fahrzeug.__init__(self, bez, ge)
> > self.insassen = ins
> >  def __str__(self):
> > return Fahrzeug.__str__(self) + " " + str(self.insassen) + "
> > Insassen"
> >  def einsteigen(self, anzahl):
> > self.insassen += anzahl
> >  def aussteigen(self, anzahl):
> > self.insassen -= anzahl
> > fiat = PKW("Fiat Marea",50,0)
> > fiat.einsteigen(3)
> > fiat.aussteigen(1)
> > fiat.beschleunigen(10)
> > print(fiat)
> >
> > -CODE THAT FAILS --
> > class Fahrzeug:
> >  def __init__(self, bez, ge):
> >self.bezeichnung = bez
> >self.geschwindigkeit = ge
> >  def beschleunigen(self, wert):
> >self.geschwindigkeit += wert
> >  def __str__(self):
> >return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h"
> > class PKW(Fahrzeug):
> >  def __init__(self, bez, ge, ins):
> > *super(PKW, self).__init__()*
> > self.insassen = ins
> >  def __str__(self):
> > return Fahrzeug.__str__(self) + " " + str(self.insassen) + "
> > Insassen"
> >  def einsteigen(self, anzahl):
> > self.insassen += anzahl
> >  def aussteigen(self, anzahl):
> > self.insassen -= anzahl
> > fiat = PKW("Fiat Marea",50,0)
> > fiat.einsteigen(3)
> > fiat.aussteigen(1)
> > fiat.beschleunigen(10)
> > print(fiat)
> >
> >
> The traceback tells you what the problem is. The line should be:
>
>  super(PKW, self).__init__(bez, ge)
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: using classes

2020-03-13 Thread joseph pareti
one more question. In the code below, there are 2 init() methods, one for
the class 'Fahrzeug' and one for the class 'PKW'.
The program works when I instantiate the class as:

fiat = PKW("Fiat Marea",50,0)

but it fails if I say:

*fiat = PKW("Fiat Marea",50,0,1)*




*Traceback (most recent call last):  File "erben_a.py", line 19, in
fiat = PKW("Fiat Marea",50,0,1)TypeError: __init__() takes 4
positional arguments but 5 were given*

yet the statement in *bold* matches IMO the init() method of the PKW class.
Can anyone explain why? Thanks.
---

class Fahrzeug:
def __init__(self, bez, ge):
  self.bezeichnung = bez
  self.geschwindigkeit = ge
def beschleunigen(self, wert):
  self.geschwindigkeit += wert
def __str__(self):
  return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h"
class PKW(Fahrzeug):
def __init__(self, bez, ge, ins):
   super(PKW, self).__init__(bez,ge)
   self.insassen = ins
def __str__(self):
   return Fahrzeug.__str__(self) + " " + str(self.insassen) + "
Insassen"
def einsteigen(self, anzahl):
   self.insassen += anzahl
def aussteigen(self, anzahl):
   self.insassen -= anzahl
fiat = PKW("Fiat Marea",50,0,1)
fiat = PKW("Fiat Marea",50,0)
fiat.einsteigen(3)
fiat.aussteigen(1)
fiat.beschleunigen(10)
print(fiat)


Am Do., 12. März 2020 um 17:38 Uhr schrieb Pieter van Oostrum <
piete...@vanoostrum.org>:

> joseph pareti  writes:
>
> > thank you, that fixes it. I also noticed that both statements work:
> >
> >  super(PKW, self).__init__(bez,ge)
> >
> > or
> >
> >super().__init__(bez,ge)
>
> The first is the required Python 2 calling (at least the first argument is
> required). The second way can be used in Python 3.
> --
> Pieter van Oostrum
> www: http://pieter.vanoostrum.org/
> PGP key: [8DAE142BE17999C4]
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reduce waiting queue at supermarket from Corona with Python-Webapp

2020-03-17 Thread joseph pareti
the use case is VERY valuable.

In order to increase its penetration, how about writing the app as a plug
in for a more widely used one such as google maps?

Am Di., 17. März 2020 um 11:20 Uhr schrieb Orges Leka :

> The web-app could be a simple as one button:
>
> If users are before supermarket and there is a long queue, they click on
> the web-app button and warn other users of the queue.
>
> The same principle works for anti-traffi-jam apps, with user generated
> content.
>
> If someone would like to work on this project, please let me know.
>
>
>
> Am Di., 17. März 2020 um 07:21 Uhr schrieb Souvik Dutta <
> souvik.vik...@gmail.com>:
>
> > This app might also give real time updates.
> >
> > On Tue, Mar 17, 2020, 10:19 AM Souvik Dutta 
> > wrote:
> >
> >> I think you might get a man build the app in a manner that allows the
> >> people at the supermarket to update the foot falls of the customers in a
> >> given time period. Like one might count the number on 10 am for a
> period of
> >> fifteen minutes and say that this will be the number of persons in the
> mall
> >> for at least an hour, because generally that is the time we spent in
> >> supermarkets.
> >> Then this number could be updated to the customers so that they could
> >> plan accordingly. This will though have a waiting time for the peoples
> to
> >> get good updates.
> >> And to avoid discrepancy the supermarket workers (s.w) can update the
> >> information when large number of people start coming in to the store.
> >>
> >>
> >> On Tue, Mar 17, 2020, 12:54 AM Orges Leka  wrote:
> >>
> >>> Dear Python developers,
> >>>
> >>> I am a data scientist and use Python regularly. I have a question:
> >>> How difficult is it to write a Python web-app, with the following basic
> >>> functionality:
> >>>
> >>> The user writes anonymously without registration where (City,
> >>> supermarket),
> >>> when (Date and Time) he plans to go to the supermarket.
> >>> If this is done by a lot of users, the first user gets to see the
> number
> >>> of
> >>> other buyers at this supermarket and can better plan when to go
> shopping.
> >>> This would reduce the waiting queue at the supermarket and possibly the
> >>> contact to other people thus would help a little bit in slowing down
> the
> >>> spread of the Corona virus.
> >>> One could also add openstreetmap functionality to this.
> >>>
> >>> As I am not a professional software developer, I can not predict how
> long
> >>> it would take to write such a web-app in python.
> >>>
> >>> If you do not have currently time, but know someone who would possibly
> be
> >>> interested in working at this project, I would be happy if you let me
> >>> know.
> >>>
> >>> Kind regards,
> >>> Orges Leka
> >>>
> >>> --
> >>> Mit freundlichen Grüßen
> >>> Herr Dipl. Math. Orges Leka
> >>>
> >>> Mobil: 015751078391
> >>> Email: orges.l...@googlemail.com
> >>> Holzheimerstraße 25
> >>> 65549 Limburg
> >>> --
> >>> https://mail.python.org/mailman/listinfo/python-list
> >>>
> >>
>
> --
> Mit freundlichen Grüßen
> Herr Dipl. Math. Orges Leka
>
> Mobil: 015751078391
> Email: orges.l...@googlemail.com
> Holzheimerstraße 25
> 65549 Limburg
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reduce waiting queue at supermarket from Corona with Python-Webapp

2020-03-18 Thread joseph pareti
all right, I have informed my contact person at Facebook. I'll let you know
if anything positive comes out of it

Am Mi., 18. März 2020 um 08:09 Uhr schrieb Orges Leka :

> Thanks Christian for your suggestion.
>
> I made the start here
> https://github.com/orgesleka/supermarket-waiting-queue-alarm
> The incomplete Flask/Jquery app is hosted here:
> http://www.orges-leka.de/limburg.html
> If someone can contribute by hosting this app for his city/community and
> spreading the link to his friends, that would be a great thing to help.
> If someone with better knowledge in Flask/Jquery can contribute code to
> this, that would also be great.
>
> Kind regards,
> Orges
>
> Am Di., 17. März 2020 um 23:02 Uhr schrieb Christian Gollwitzer <
> aurio...@gmx.de>:
>
> > Am 17.03.20 um 11:16 schrieb Orges Leka:
> > > The web-app could be a simple as one button:
> > >
> > > If users are before supermarket and there is a long queue, they click
> on
> > > the web-app button and warn other users of the queue.
> >
> > It might be possible to make a Facebook "app" out of it. Facebook
> > already provides a "login" feature, where it autodetects if you are near
> > som point of interest and you only need to confirm that you want to be
> > there. Also, the Facebook user base is extensive.
> >
> > > The same principle works for anti-traffi-jam apps, with user generated
> > > content.
> > >
> > > If someone would like to work on this project, please let me know.
> > >
> >
> > There is one obvious candidate who could work on this project. It's you.
> >
> > Best regards,
> >
> > Christian
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
>
>
> --
> Mit freundlichen Grüßen
> Herr Dipl. Math. Orges Leka
>
> Mobil: 015751078391
> Email: orges.l...@googlemail.com
> Holzheimerstraße 25
> 65549 Limburg
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reduce waiting queue at supermarket from Corona with Python-Webapp

2020-03-20 Thread joseph pareti
>  the supermarkets will leave only a handful of people
better later than never :-)
meanwhile folks are staging idiotic things like (NOT EVEN 2 WEEKS AGO) a
leipzig vs. tottenhame match with FULL STADION, or bragging about their
social stupidities on facebook and co.

I always thought (and I am getting more convinced by the day) that
autoritarian rule is the way to go

Am Fr., 20. März 2020 um 12:39 Uhr schrieb Orges Leka :

> Dear Robin,
>
> I am sad to hear this. The same thing is / will happen(ing) in Germany I
> suspect. But after the panic buys has gone, the supermarkets will leave
> only a handful of people in, as it is happening in Italy. The app is meant
> to inform others of those queues. But maybe it is just a silly idea. I am
> not sure about it yet.
>
> Kind regards,
> Orges
>
> Am Fr., 20. März 2020 um 12:22 Uhr schrieb Robin Becker <
> ro...@reportlab.com
> >:
>
> > On 16/03/2020 17:38, Orges Leka wrote:
> > > This would reduce the waiting queue at the supermarket and possibly the
> > > contact to other people thus would help a little bit in slowing down
> the
> > > spread of the Corona virus.
> > Unfortunately, I suspect nothing will alter the number of people in
> queues
> > in British supermarkets. I am an older person
> > and am probably a bit old-fashioned. I have been shocked at the way
> people
> > are rushing the shops.
> >
> > Late this week main shops announced first hour would be reserved for us
> > oldies. That hasn't worked with scuffles and the
> > elderly being pushed aside etc etc.
> >
> > Women and children first is long gone the new British attitude is devil
> > take the hindmost :)
> > --
> > Robin Becker
> >
>
>
> --
> Mit freundlichen Grüßen
> Herr Dipl. Math. Orges Leka
>
> Mobil: 015751078391
> Email: orges.l...@googlemail.com
> Holzheimerstraße 25
> 65549 Limburg
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


mport pytorch fails on my windows 10 PC

2020-03-28 Thread joseph pareti
apologies for asking here a presumably off-topic question:

I have installed pytorch using (miniconda3) the following command:

*conda install pytorch torchvision cpuonly -c pytorch*

In the jupyter notebook, the 'import torch' fails:

*ModuleNotFoundError: No module named 'torch._C'*

I am not sure if having several python versions on the system could cause
the issue:

./Users/joepareti/Miniconda3/envs/myenv/python.exe
./Users/joepareti/Miniconda3/envs/myenv1/python.exe
./Users/joepareti/Miniconda3/pkgs/python-3.6.8-h9f7ef89_0/python.exe
./Users/joepareti/Miniconda3/pkgs/python-3.6.8-h9f7ef89_1/python.exe
./Users/joepareti/Miniconda3/pkgs/python-3.7.1-h8c8aaf0_6/python.exe
./Users/joepareti/Miniconda3/python.exe
-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


jupyter notebook permission denied

2020-04-02 Thread joseph pareti
I have installed anaconda on windows 10, and when launching jupyter
notebook from the anaconda navigator, it works fine.  However, I am bound
to work on files within the folder c:\Users\username\...

If I launch jupyter notebook from a windows 10 cmd prompt, I can cd to my
project directory. However, a permission denied issue prevents
loading/updating the *ipynb files. Any idea why?

Same happens if I do it as Administrator.
-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NLP Project with Python

2020-04-08 Thread joseph pareti
if you want to do work in NLP there are numerous opportunities, especially
with the virus oubreak
see e.g.
https://www.cnbc.com/2020/03/03/bluedot-used-artificial-intelligence-to-predict-coronavirus-spread.html

Am Mi., 8. Apr. 2020 um 09:18 Uhr schrieb :

> Hello everyone
> I`m new to python. I need to select a project idea so that I can work with
> it during this semester. the project should be in the area of business and
> finance
> at first I was thinking of creating a project using NLP but I don`t know
> what exactly to create
> also I would like to create something related to blockchain, such as
> tracking the currency at which its sold and bought, customers reviews and
> the value of cryptocurrencies during this outbreak of the coronavirus
> I welcome all your ideas just please inspire me. I`m lost in my own
> thoughts.
> thanks in advance
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Helping Windows first time users

2020-04-15 Thread joseph pareti
FWIW, here is my experience on Windows 10.

I had some troubles with python on Windows 10. Most of the issues were
presumably due to having multiple python versions on the same PC, and also
relying on 'miniconda3' which was kind of inherited from an older
experiment.

At some point, to recover from a system crash I had to re-install Windows
10, and after that I installed the full suite of Anaconda products. Things
improved a lot. Besides Python and Jupyter notebook, i find Spyder very
useful as an IDE, and everything seems to be running smoothly. On top of
that I also installed PyTorch 1.4: I am currently training a neural network
which takes more than 20 hours. The only annoying thing was the
occasional automatic reboot during keyboard inactivity which I then
disabled at the "Windows Update" menu.

Am Mi., 15. Apr. 2020 um 21:06 Uhr schrieb Barry Scott <
ba...@barrys-emacs.org>:

> I post some suggestion to improve the Python installer for Windows
> to better sign post users on the next steps.
>
>
> https://mail.python.org/archives/list/python-id...@python.org/message/TKHID7PMKN5TK5QDQ2BL3G45FYAJNYJX/
>
> It also seems like we could do with drafting the text of a helpful
> reply to help the Windows first time users. This would help folks that
> reply to the Windows first time users to have a quick way to reply
> without drafting the text a reply every time.
>
> What are your thoughts on the installer changes and reply text?
>
> Barry
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python and numpy

2020-04-21 Thread joseph pareti
FWIW, I installed Anaconda on Windows 10. Then besides Python you also get
SPIDER, Jupyter and more, all out of the box.

Am Mittwoch, 22. April 2020 schrieb Souvik Dutta :

> First head over to the official python download page. Then choose the
> version and type of installer you want. After you download it click on the
> installer to install it. Don't forget to click on the check boxes that says
> add python to path and download pip. Then search for idle in the search
> menu. This is applicable for windows and Mac. I don't know for Linux.
> https://www.python.org/downloads/
> This is the official python website.
> Thank you
> Souvik flutter dev
>
> On Wed, Apr 22, 2020, 12:34 AM Derek Vladescu via Python-list <
> python-list@python.org> wrote:
>
> > I’ve just begun a serious study of using Python as an aspiring
> > programmer/data scientist.
> > Can someone please walk me through how to download Python, SO THAT I will
> > be able to import numpy?
> >
> > Thanks,
> > Derek
> >
> > Sent from Mail for Windows 10
> >
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pip not working on windows

2020-05-03 Thread joseph pareti
are you doing *pip** install* from Windows cmd of from Anaconda prompt? I
used the latter and it works

Am So., 3. Mai 2020 um 16:48 Uhr schrieb Aakash Jana <
aakashjana2...@gmail.com>:

> I recently upgraded pip to version 20.1 and now whenever I try pup install
> on my PC I get the following error :- Fatal error in launcher : unable to
> create process using '"c:\python38\python.exe '
> "c:\Python38\Scripts\pip.exe" : The system cannot find the file specified.
> But when I manually inspected the folder 📂 the files were there I even
> tried upgrading it by python -m pip install --upgrade pip which worked but
> I still can not use pip.
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


basic Python question

2020-05-08 Thread joseph pareti
In general I prefer doing:


X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33,
random_state=42) clf = RandomForestClassifier(n_estimators = 100, max_depth=
None) *clf_f = clf.fit(X_train, y_train)* predicted_labels = clf_f.predict(
X_test) score = clf.score(X_test, y_test) score1 = metrics.accuracy_score(
y_test, predicted_labels)






rather than:

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33,
random_state=42) clf0=RandomForestClassifier(n_estimators=100, max_depth=
None) *clf0.fit(X_train, y_train)* y_pred =clf0.predict(X_test) score=
metrics.accuracy_score(y_test, y_pred)














Are the two codes really equivalent?
-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: basic Python question

2020-05-08 Thread joseph pareti
yes, it is random forest classifier from scikit learn. Thank you.

Am Fr., 8. Mai 2020 um 21:50 Uhr schrieb MRAB :

> On 2020-05-08 20:02, joseph pareti wrote:
> > In general I prefer doing:
> >
> >
> > X_train, X_test, y_train, y_test = train_test_split(X, y,
> test_size=0.33, random_state=42)
>  >clf = RandomForestClassifier(n_estimators = 100, max_depth=
> > None) *clf_f = clf.fit(X_train, y_train)* predicted_labels =
> clf_f.predict(
> > X_test) score = clf.score(X_test, y_test) score1 =
> metrics.accuracy_score(
> > y_test, predicted_labels)
> >
> >
> > rather than:
> >
> > X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33,
> > random_state=42) clf0=RandomForestClassifier(n_estimators=100, max_depth=
> > None) *clf0.fit(X_train, y_train)* y_pred =clf0.predict(X_test) score=
> > metrics.accuracy_score(y_test, y_pred)
> >
> >
> > Are the two codes really equivalent?
> >
> You didn't give any context and say what package you're using!
>
> After searching for "RandomForestClassifier", I'm guessing that you're
> using scikit.
>
>  From the documentation here:
>
>
> https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html#sklearn.ensemble.RandomForestClassifier.fit
>
> it says:
>
>  Returns: self : object
>
> so it looks like clf.fit(...) returns clf.
>
> That being the case, then, yes, they're equivalent.
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: basic Python question

2020-05-08 Thread joseph pareti
yet, something is still unclear; in Python you can do things like:

*clf0.fit(X_train, y_train)*

which is not the way I programmed in other languages where a left-hand side
and a right hand side is required.

Am Fr., 8. Mai 2020 um 21:52 Uhr schrieb joseph pareti <
joeparet...@gmail.com>:

> yes, it is random forest classifier from scikit learn. Thank you.
>
> Am Fr., 8. Mai 2020 um 21:50 Uhr schrieb MRAB  >:
>
>> On 2020-05-08 20:02, joseph pareti wrote:
>> > In general I prefer doing:
>> >
>> >
>> > X_train, X_test, y_train, y_test = train_test_split(X, y,
>> test_size=0.33, random_state=42)
>>  >clf = RandomForestClassifier(n_estimators = 100, max_depth=
>> > None) *clf_f = clf.fit(X_train, y_train)* predicted_labels =
>> clf_f.predict(
>> > X_test) score = clf.score(X_test, y_test) score1 =
>> metrics.accuracy_score(
>> > y_test, predicted_labels)
>> >
>> >
>> > rather than:
>> >
>> > X_train, X_test, y_train, y_test = train_test_split(X, y,
>> test_size=0.33,
>> > random_state=42) clf0=RandomForestClassifier(n_estimators=100,
>> max_depth=
>> > None) *clf0.fit(X_train, y_train)* y_pred =clf0.predict(X_test) score=
>> > metrics.accuracy_score(y_test, y_pred)
>> >
>> >
>> > Are the two codes really equivalent?
>> >
>> You didn't give any context and say what package you're using!
>>
>> After searching for "RandomForestClassifier", I'm guessing that you're
>> using scikit.
>>
>>  From the documentation here:
>>
>>
>> https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html#sklearn.ensemble.RandomForestClassifier.fit
>>
>> it says:
>>
>>  Returns: self : object
>>
>> so it looks like clf.fit(...) returns clf.
>>
>> That being the case, then, yes, they're equivalent.
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>
> --
> Regards,
> Joseph Pareti - Artificial Intelligence consultant
> Joseph Pareti's AI Consulting Services
> https://www.joepareti54-ai.com/
> cell +49 1520 1600 209
> cell +39 339 797 0644
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: From an existing Pandas DataFrame, how can I create a summary DataFrame based on the union of overlapping date ranges (given a start and an end date) and an additional column?

2020-06-09 Thread joseph pareti
i gave it a shot, see attached

Am Mi., 3. Juni 2020 um 23:38 Uhr schrieb Aaron :

> Hello,
>
> Given a dateframe with trips made by employees of different companies, I am
> trying to generate a new dataframe with only the company names.  I am
> looking to combine the overlapping travel times from employees of the SAME
> company into a single row.  If there are no overlapping travel times, then
> that row just transfers over as-is.  When there are overlapping travel
> times, then the following will happen:
>
> --The name field is removed b/c that is no longer relevant (company name
> stays), the Depart date will be the earliest date of any of the trip dates
> regardless of the employee, the Return date will be the latest date of any
> of the trip dates regardless of the employee, the charges for the trip will
> be summed
>
> For example, if trips had dates 01/01/20 - 01/31/20, 01/15/20 - 02/15/20,
> 02/01-20 - 02/28/20, then all three would be combined.  The starting date
> will be 1/1/20 and ending as of 2/28/20.  Basically, the company was on
> that trip from start to finish… kinda like a relay run handing off the
> baton.  Also, the charges will be summed for each of those trips and
> transferred over to the single row.
>
> Here is the starting dataframe code/output (note: the row order is
> typically not already sorted by company name as in this example):
>
> import pandas as pd
>
>
> emp_trips = {'Name': ['Bob','Joe','Sue','Jack', 'Henry', 'Frank',
> 'Lee', 'Jack'],
> 'Company': ['ABC', 'ABC', 'ABC', 'HIJ', 'HIJ', 'DEF', 'DEF',
> 'DEF'],
> 'Depart' : ['01/01/2020', '01/01/2020', '01/06/2020',
> '01/01/2020', '05/01/2020', '01/13/2020', '01/12/2020', '01/14/2020'],
> 'Return' : ['01/31/2020', '02/15/2020', '02/20/2020',
> '03/01/2020', '05/05/2020', '01/15/2020', '01/30/2020', '02/02/2020'],
> 'Charges': [10.10, 20.25, 30.32, 40.00, 50.01, 60.32, 70.99, 80.87]
> }
>
> df = pd.DataFrame(emp_trips, columns = ['Name', 'Company', 'Depart',
> 'Return', 'Charges'])
> # Convert to date format
> df['Return']= pd.to_datetime(df['Return'])
> df['Depart']= pd.to_datetime(df['Depart'])
>
>   Name Company Depart Return  Charges0Bob ABC
> 2020-01-01 2020-01-3110.101Joe ABC 2020-01-01 2020-02-15
>  20.252Sue ABC 2020-01-06 2020-02-2030.323   Jack HIJ
> 2020-01-01 2020-03-0140.004  Henry HIJ 2020-05-01 2020-05-05
>  50.015  Frank DEF 2020-01-13 2020-01-1560.326Lee DEF
> 2020-01-12 2020-01-3070.997   Jack DEF 2020-01-14 2020-02-02
>  80.87
>
> And, here is the desired/generated dataframe:
>
>   Company  Depart  Return  Charges0 ABC  01/01/2020
> 02/20/202060.671 HIJ  01/01/2020  03/01/202040.002 HIJ
>  05/01/2020  05/05/202050.013 DEF  01/12/2020  02/02/2020
> 212.18
>
> I have been trying to use a combination of sorting and grouping but
> the best I've achieved is reordering the dataframe.  Even though I am
> able to sort/group based on values, I still run into the issues of
> finding overlapping date ranges and pulling out all trips based on a
> single company per aggregate/overlapping date range.
>
> Thank you in advance for any help!
>
> Aaron
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


i don't understand this python class

2020-06-29 Thread joseph pareti
I have piece of code with constructs as follows:

*class* *SentimentNetwork**:*

*def* __init__*(*self*,* reviews*,* labels*,* hidden_nodes *=* 10*,*
learning_rate *=* 0.1*):*



np*.*random*.*seed*(*1*)*



   self*.*init_network*(**len**(*self*.*review_vocab*),*hidden_nodes*,*
1*,* learning_rate*)*







*def* init_network*(*self*,* input_nodes*,* hidden_nodes*,* output_nodes
*,* learning_rate*):*

# Store the number of nodes in input, hidden, and output layers.

self*.*input_nodes *=* input_nodes

self*.*hidden_nodes *=* hidden_nodes

self*.*output_nodes *=* output_nodes

which makes me think about the redundant usage of* init_network:*

   1. as a method, AND
   2. as a property

So far I have only seen codes where the 2 things are separated, e.g. :

*import* insurance *as* ins

*class* *Vehicle**:*

*def* __init__*(*self*,* speed*,* make*):*

self*.*speed *=* speed

self*.*make *=* make

*class* *car**(*Vehicle*):*

*def* __init__*(*self*,* speed*,* make*):*

Vehicle*.*__init__*(*self*,* speed*,* make*)*

self*.*insurance *=* ins*.*calc*(*make*)*

*def* show_out*(*self*):*

*print**(*'vehicle is '*,*self*.*make*,*' insurance premium '*,*self
*.*insurance*)*

*def* claim*(*self*,* discount*):*

X *=* self*.*insurance *+* discount

*return* X


And hence I am not sure about the behavior of the first code in this email.
-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: dictionaries an matrices

2020-09-16 Thread joseph pareti
you can use the following: (change the matrices as it suits your app):

import numpy as np
def set_params(w, b):

params = {"w0": w[0], "w1": w[1] , "w2": w[2], "w3": w[3], "w4":
w[4], "b": b}

return params

w = np.random.randn((5))
b = 1
params = set_params(w, b)
for i in range(5):
W = params.get("w"+str(i))
print(W)
B = params.get('b')
print(B)

Am Mi., 16. Sept. 2020 um 13:14 Uhr schrieb Ing Diegohl <
ingdieg...@gmail.com>:

> Good morning everyone
> I would like to know if i can to create a dictionary with two matrices,
> where every element of the first matrix corresponds to dictionary's keys
> and the elements of the second matrix will be the values every key.
> thanks
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list