Re: venv and executing other python programs

2022-02-17 Thread Martin Di Paola


That's correct. I tried to be systematic in the analysis so I tested all
the possibilities.


Your test results were unexpected for `python3 -m venv xxx`. By
default, virtual environments exclude the system and user site
packages. Including them should require the command-line argument
`--system-site-packages`. I'd check sys.path in the environment. Maybe
you have PYTHONPATH set.


Nope, I checked with "echo $PYTHONPATH" and nothing. I also checked 
"sys.path" within and without the environment:


Inside the environment:

['', '/usr/lib/python37.zip', '/usr/lib/python3.7', 
 '/usr/lib/python3.7/lib-dynload', 
 '/home/user/tmp/xxx/lib/python3.7/site-packages']


Outside the environment:

['', '/usr/lib/python37.zip', '/usr/lib/python3.7', 
 '/usr/lib/python3.7/lib-dynload', 
 '/home/user/.local/lib/python3.7/site-packages', 
 '/usr/local/lib/python3.7/dist-packages', 
 '/usr/lib/python3/dist-packages']


Indeed the "sys.path" inside the environment does not include system's 
site-packages.


I'll keep looking


A virtual environment is configured by a "pyvenv.cfg" file that's
either beside the executable or one directory up. Activating an
environment is a convenience, not a requirement.


Thanks, that makes a little more sense!


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

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


Re: How to solve the given problem?

2022-02-17 Thread Dennis Lee Bieber
On Thu, 17 Feb 2022 02:20:53 -0800 (PST), NArshad 
declaimed the following:

>I have completed the homework or what so ever it used to be its only I am 
>telling the solution which looks to me as better as compared to what others 
>have given like the one that Christian has given.

This statement should probably have been how you introduced the prior
post instead of presenting something that read like a request for someone
to implement something based on your new description.

Your immediately prior post:

>The feed remaining of the second hour will be distributed and adjusted in the 
>next third and fourth hour not the next day because the fish must be hungry. 
>This can be done by both taking the average or the percentage left. What I 
>think is taking the average and then distributing in the third and fourth feed 
>is better. If the feed is given in the next day there is a chance that the 
>fish will not survive because the fish is special.  

"If the feed is given in the next day..." is a non-issue, as the
original problem description (shown here)...

>Assume that there is a pattern of feeding for a special fish in a day (10 
>hours a day) as below:
>                              150    100    30    30    30    20    20    10   
> 5    5
>Today, the fish is fed in the second hour 60 unit instead of 100 unit 
>Accidently. Implement some methods to distribute the remaining 40 unit in the 
>rest of the day and propose the new patterns. Try to keep the distribution 
>similar to the current feeding pattern. 
>Note: pay attention that the total feeding amounts should be fix in a day.

... explicitly states that the total amount must be provided within a
single day.

Since you didn't provide your implementation (or even just the
resultant feeding pattern), I can not determine exactly what you are doing
with regards to your "average" -- however, it seems to me that your
"average" distribution "in the third and fourth feed" fails both the "rest
of the day" and "try to keep the distribution similar..." requirements. It
is a given that you have to account for the 40 units that were not provided
in the second hour. It sounds very much like you are dumping them at 20&20
on the 3rd&4th hours, so your pattern (with the "error" feed now looks like

150 60  50  50  30  20  20  10  
5   5

A proportional solution would result in the full pattern looking (ignoring
round-off errors)

150 60  38  38  38  25  25  13  
6   6
(round-off means you have to account for 1 more unit -- I'd probably put it
on the first 38 hour, but that's only because I hand worked the proportions
on a calculator. A "proper" algorithm should probably be tracking the error
amounts [difference between integer units and real proportion] to apply the
round-off at the nearest correct location).

Taking error term into account

units   calcerror
150
60
38  8.0 0.0
38  8.0 0.0
38  8.0 0.0
25  5.333   .333v
25  5.333   .666v
13  2.666   1.333^
.333
6   1.333   .666v
7   1.333   .999^   (I'm only showing 3 decimal places)


Of course, one could compute the data in the other direction and get

6   1.333   .333v
6   1.333   .666v
13  2.666   1.333^
.333
25  5.333   .666v
26  5.333   .999^   (again, 3 decimal places)
0.0
38  8.0 0.0
38  8.0 0.0
38  8.0 0.0
60
150



(v = round down, ^ round up


-- 
Wulfraed Dennis Lee Bieber AF6VN
[email protected]://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list