Re: PyInstaller value error: Invalid Windows resource specifier

2023-10-30 Thread MRAB via Python-list

On 2023-10-30 19:19, McDermott Family via Python-list wrote:

Hello, I am trying to create a one file executable with pyinstaller 6.1.0
and auto-py-to-exe 2.41.0 using Python version 3.10.9 in a virtual
environment.

Some points before the output of pinstaller is shown. My resource .py file
is there where it should be. Also I can fun my program from the command-line


and it does work with the compiled resource file without a problem. Any help
would be greatly appreciated. Thank you.


Running auto-py-to-exe v2.41.0

Building directory: C:\Users\icnte\AppData\Local\Temp\tmpp870eytg

Provided command: pyinstaller --noconfirm --onefile --windowed --icon
"D:/Work/Python/cfepy310/xl/cfegui/Resources/Conform-e_48_1.ico" --name
"Conform-e" --clean --log-level "DEBUG" --debug "all" --version-file
"D:/Work/Python/cfepy310/xl/cfegui/cfe_versionfile.txt" --resource
"D:/Work/Python/cfepy310/xl/cfegui/cfe_Resource_rc.py"
"D:/Work/Python/cfepy310/xl/cfegui/cfe_MainForm.py"

Recursion Limit is set to 5000

Executing: pyinstaller --noconfirm --onefile --windowed --icon
D:/Work/Python/cfepy310/xl/cfegui/Resources/Conform-e_48_1.ico --name
Conform-e --clean --log-level DEBUG --debug all --version-file
D:/Work/Python/cfepy310/xl/cfegui/cfe_versionfile.txt --resource
D:/Work/Python/cfepy310/xl/cfegui/cfe_Resource_rc.py
D:/Work/Python/cfepy310/xl/cfegui/cfe_MainForm.py --distpath
C:\Users\icnte\AppData\Local\Temp\tmpp870eytg\application --workpath
C:\Users\icnte\AppData\Local\Temp\tmpp870eytg\build --specpath
C:\Users\icnte\AppData\Local\Temp\tmpp870eytg


[snip]


ValueError: Invalid Windows resource specifier
'D:WorkPythoncfepy310xlcfeguicfe_Resource_rc.py'!
For arbitrary data file, the format is 'filename,type,name,[language]'!

  


Project output will not be moved to output folder

Complete.


In the docs for "--resource" it says:

"""FILE can be a data file or an exe/dll. For data files, at least TYPE 
and NAME must be specified."""


That might be the problem, but I haven't been able to find out what 
"TYPE" means!


I also wonder whether "--add-data" would work.

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


[issue32291] Value error for string shared memory in multiprocessing

2021-11-05 Thread Irit Katriel


Change by Irit Katriel :


--
stage:  -> resolved
status: pending -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32291] Value error for string shared memory in multiprocessing

2021-10-18 Thread Irit Katriel


Change by Irit Katriel :


--
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32291] Value error for string shared memory in multiprocessing

2021-10-18 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner
status: pending -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32291] Value error for string shared memory in multiprocessing

2021-10-17 Thread Irit Katriel


Irit Katriel  added the comment:

Is there anything left to do here?

It seems hongweipeng's explanation and the link to the documentation pretty 
much cover it.

--
nosy: +iritkatriel
resolution:  -> not a bug
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41838] Value error is showing in docset python (class)

2020-09-28 Thread Eric V. Smith

Eric V. Smith  added the comment:

If you can provide the information requested, please reopen this issue. In the 
meantime, I’m closing it.

--
resolution:  -> rejected
stage:  -> resolved
status: pending -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41838] Value error is showing in docset python (class)

2020-09-24 Thread Eric V. Smith


Change by Eric V. Smith :


--
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41838] Value error is showing in docset python (class)

2020-09-23 Thread Eric V. Smith


Eric V. Smith  added the comment:

It would be helpful if you can:
- simplify the example
- attach the simplified code to this issue
- show how the code runs with no errors, and how you invoke it
- show how you invoke the code when it does have errors

Please do no attach images: they are not friendly to users using accessibility 
software, and they're impossible to copy/paste/search.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41838] Value error is showing in docset python (class)

2020-09-23 Thread Mohit Kumar


New submission from Mohit Kumar :

https://github.com/python/bugs.python.org/issues/55

--
assignee: docs@python
components: Documentation
messages: 377362
nosy: docs@python, mkay6122
priority: normal
severity: normal
status: open
title: Value error is showing in docset python (class)
type: behavior
versions: Python 3.8

___
Python tracker 
<https://bugs.python.org/issue41838>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37377] unicode error should raise a value error

2019-06-23 Thread hai shi


hai shi  added the comment:

Got it, thank for your detailed explanation, steven.

--
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37377] unicode error should raise a value error

2019-06-23 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

It is a *syntax* error. You have written bad syntax, just as the error message 
says. Your \xXX code is too short, only 1 hex digit instead of 2. I disagree 
that this should be a value error: it isn't a bad value, it is bad syntax.

I don't know what the context of the BDFL pronouncement in PEP 223 was, but I 
think it was decided later that Guido wrong because the error in Python 2.4 and 
2.5 was UnicodeDecodeError and then changed to SyntaxError in 2.6 (probably to 
match Python 3, I guess).

In Python 3, both unicode and bytes strings give a syntax error for this error.

--
nosy: +steven.daprano
versions: +Python 3.9

___
Python tracker 
<https://bugs.python.org/issue37377>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37377] unicode error should raise a value error

2019-06-23 Thread hai shi


New submission from hai shi :

>>> "\x1"
  File "", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in 
position 0-2: truncated \xXX escape

I think rasing the valueError would be exact.(pep223 agree this behavior: 
https://www.python.org/dev/peps/pep-0223/#bdfl-pronouncements).

And I think the error type could be changed in:
https://github.com/python/cpython/blob/master/Python/ast.c#L682

--
components: Interpreter Core
messages: 346321
nosy: shihai1991
priority: normal
severity: normal
status: open
title: unicode error should raise a value error
type: behavior

___
Python tracker 
<https://bugs.python.org/issue37377>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32291] Value error for string shared memory in multiprocessing

2018-09-29 Thread hongweipeng


hongweipeng  added the comment:

I think I know the reason. `c_wchar_p` corresponds to the string pointer 
`wchar_t *`.It's not a good idea to pass pointers between processes. As quoted 
from `multiprocessing` docs:

Note Although it is possible to store a pointer in shared memory remember that 
this will refer to a location in the address space of a specific process. 
However, the pointer is quite likely to be invalid in the context of a second 
process and trying to dereference the pointer from the second process may cause 
a crash.

https://docs.python.org/3.6/library/multiprocessing.html?#module-multiprocessing.sharedctypes

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32291] Value error for string shared memory in multiprocessing

2018-09-29 Thread hongweipeng


hongweipeng  added the comment:

This problem seems to be support for str.

import multiprocessing
import ctypes

def child_process_fun(share):
share.value = 'bb'

if __name__ == '__main__':
share = multiprocessing.Value(ctypes.c_wchar_p, 'aa')
process = multiprocessing.Process(target=child_process_fun, args=(share, ))
process.start()
process.join()
print(share.value)

It also raises ValueError.When use c_double or c_int, it works well.

Test in python3.7 and 3.8

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32291] Value error for string shared memory in multiprocessing

2018-09-29 Thread hongweipeng


Change by hongweipeng :


--
nosy: +hongweipeng

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32291] Value error for string shared memory in multiprocessing

2018-09-20 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32291] Value error for string shared memory in multiprocessing

2017-12-12 Thread Marc Guetg

New submission from Marc Guetg <guetg.m...@gmail.com>:

It seems like sharing a string over processes is not possible.

#!/usr/bin/env python3

import multiprocessing
import threading
import ctypes


def fun(share_c, share_s, set_c, set_s, name):
print(f'{name}: {share_c.value}; {share_s.value}')
share_c.value = set_c
share_s.value = set_s
print(f'{name}: {share_c.value}; {share_s.value}')


if __name__ == '__main__':
share_c = multiprocessing.Value(ctypes.c_wchar, 'a')
share_s = multiprocessing.Value(ctypes.c_wchar_p, 'aa')

print(f'pre_thread: {share_c.value}; {share_s.value}')
thread = threading.Thread(target=fun, args=(share_c, share_s, 
'b', 'bb', 'thread'))
thread.start()
thread.join()

print(f'post_thread: {share_c.value}; {share_s.value}')
process = multiprocessing.Process(target=fun, args=(share_c, 
share_s, 'c', 'cc', 'process'))
process.start()
process.join()

print(f'post_process: {share_c.value}', end='; ')
print(share_s.value)  # <--- Blows here

produces: 

pre_thread: a; aa
thread: a; aa
thread: b; bb
post_thread: b; bb
process: b; bb
process: c; cc
post_process: c; Traceback (most recent call last):
  File "test2.py", line 30, in 
print(share_s.value)  # <--- Blows here
  File "", line 5, in getvalue
ValueError: character U+ff92f210 is not in range [U+; U+10]

Where the character value in the error message is different every time. To me 
this seems like a bug as it is working properly with threads as well as single 
characters. (Maybe relevant question also here: 
https://stackoverflow.com/questions/47763878/how-to-share-string-between-processes?noredirect=1#comment82492062_47763878)

For the case it matters:
Python 3.6.1 (Anaconda 4.4.0) on RHEL 6

--
components: Library (Lib), Unicode
messages: 308144
nosy: ezio.melotti, magu, vstinner
priority: normal
severity: normal
status: open
title: Value error for string shared memory in multiprocessing
type: crash
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32291>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Matplotlib error: Value Error: x and y must have same first dimension

2015-11-16 Thread Abhishek Mallela
Thank you Laura and Oscar.

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


Re: Matplotlib error: Value Error: x and y must have same first dimension

2015-11-13 Thread Laura Creighton
In a message of Thu, 12 Nov 2015 17:54:28 -0800, Abhishek writes:
>I am trying to run some Python code for the last few hours. How can I achieve 
>the effect of "dot divide" from Matlab, in the following code? I am having 
>trouble working with list comprehension and numpy arrays and getting the 
>following error:
>
>Traceback (most recent call last):
>  File "Thurs.py", line 128, in 
>plt.plot(np.array(range(1,N/2+2)), 
> Splot[alpha][iii,val]/utot[iii,val],color=cmap(iii/50))
>
>ValueError: x and y must have same first dimension

Splot is a list.  matplotlib wants 2 numpy arrays.  You have to cast
it with np.array() too.

no guarantees that the rest of the code works -- it is not plotting for
me -- but that gets rid of that error at any rate.

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


Re: Matplotlib error: Value Error: x and y must have same first dimension

2015-11-13 Thread Laura Creighton
In a message of Fri, 13 Nov 2015 14:04:01 +, Oscar Benjamin writes:
>On 13 November 2015 at 08:34, Laura Creighton  wrote:
>> In a message of Thu, 12 Nov 2015 17:54:28 -0800, Abhishek writes:
>>>I am trying to run some Python code for the last few hours. How can I 
>>>achieve the effect of "dot divide" from Matlab, in the following code? I am 
>>>having trouble working with list comprehension and numpy arrays and getting 
>>>the following error:
>>>
>>>Traceback (most recent call last):
>>>  File "Thurs.py", line 128, in 
>>>plt.plot(np.array(range(1,N/2+2)), 
>>> Splot[alpha][iii,val]/utot[iii,val],color=cmap(iii/50))
>>>
>>>ValueError: x and y must have same first dimension
>>
>> Splot is a list.  matplotlib wants 2 numpy arrays.  You have to cast
>> it with np.array() too.
>
>Actually the plot command is perfectly happy converting lists or lists
>of lists etc. to arrays (by calling np.array internally) so you don't
>need to convert any of your inputs. By the way: np.arange(1, N/2+2)
>would be the usual way to create a numpy array that is a range.
>
>The error here comes because (after both arguments are converted to
>arrays) they have incompatible sizes. In other words:
>
>len(range(1,N/2+2)) != len(Splot[alpha][iii,val]/utot[iii,val])
>
>I'm not sure what the solution is as the code is too complex for me to
>spend time trying to guess what it's trying to do.
>
>--
>Oscar

I am sorry for the bad information.  Thank you Oscar.

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


Re: Matplotlib error: Value Error: x and y must have same first dimension

2015-11-13 Thread Oscar Benjamin
On 13 November 2015 at 08:34, Laura Creighton  wrote:
> In a message of Thu, 12 Nov 2015 17:54:28 -0800, Abhishek writes:
>>I am trying to run some Python code for the last few hours. How can I achieve 
>>the effect of "dot divide" from Matlab, in the following code? I am having 
>>trouble working with list comprehension and numpy arrays and getting the 
>>following error:
>>
>>Traceback (most recent call last):
>>  File "Thurs.py", line 128, in 
>>plt.plot(np.array(range(1,N/2+2)), 
>> Splot[alpha][iii,val]/utot[iii,val],color=cmap(iii/50))
>>
>>ValueError: x and y must have same first dimension
>
> Splot is a list.  matplotlib wants 2 numpy arrays.  You have to cast
> it with np.array() too.

Actually the plot command is perfectly happy converting lists or lists
of lists etc. to arrays (by calling np.array internally) so you don't
need to convert any of your inputs. By the way: np.arange(1, N/2+2)
would be the usual way to create a numpy array that is a range.

The error here comes because (after both arguments are converted to
arrays) they have incompatible sizes. In other words:

len(range(1,N/2+2)) != len(Splot[alpha][iii,val]/utot[iii,val])

I'm not sure what the solution is as the code is too complex for me to
spend time trying to guess what it's trying to do.

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


Matplotlib error: Value Error: x and y must have same first dimension

2015-11-12 Thread Abhishek
I am trying to run some Python code for the last few hours. How can I achieve 
the effect of "dot divide" from Matlab, in the following code? I am having 
trouble working with list comprehension and numpy arrays and getting the 
following error:

Traceback (most recent call last):
  File "Thurs.py", line 128, in 
plt.plot(np.array(range(1,N/2+2)), 
Splot[alpha][iii,val]/utot[iii,val],color=cmap(iii/50))

ValueError: x and y must have same first dimension

Code:

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.integrate import odeint

N = 2
K00 = np.logspace(3,5,101,10)
len1 = len(K00)
Qvec = np.logspace(-2,2,2,10)
S10vec = np.logspace(2,6,2,10)
len2 = len(Qvec)
y0 = [0]*(3*N/2+3)
Kplot = np.zeros((len1,len2))
Pplot = np.zeros((len1,len2))
S = [np.zeros((len1,len2)) for  in range(N/2+1)]
KS = [np.zeros((len1,len2)) for  in range(N/2)]
PS = [np.zeros((len1,len2)) for  in range(N/2)]
Splot = [np.zeros((len1,len2)) for  in range(N/2+1)]
KSplot = [np.zeros((len1,len2)) for  in range(N/2)]
PSplot = [np.zeros((len1,len2)) for  in range(N/2)]

for val in range(0,len2):
for series in range(0,len1):
K0 = K00[series]
Q = Qvec[val]
S10 = S10vec[val]
r1 = 0.0001
r2 = 0.001
a = 0.001
d = 0.001
k = 0.999
P0 = 1
tfvec = [1e7, 1e10]
tf = tfvec[val]
time = np.linspace(0,tf,1001)

def f(y,t):
for alpha in range(0,(N/2+1)):
S[alpha] = y[alpha]
for beta in range((N/2)+1,N+1):
KS[beta-N/2-1] = y[beta]
for gamma in range(N+1,3*N/2+1):
PS[gamma-N-1] = y[gamma]
K = y[3*N/2+1]
P = y[3*N/2+2]

ydot = np.zeros((3*N/2+3,1))
B = range((N/2)+1,N+1)
G = range(N+1,3*N/2+1)
runsumPS = 0
runsum1 = 0
runsumKS = 0
runsum2 = 0

for m in range(0,N/2):
runsumPS = runsumPS + PS[m]
runsum1 = runsum1 + S[m+1]
runsumKS = runsumKS + KS[m]
runsum2 = runsum2 + S[m]
ydot[B[m]] = a*K*S[m]-(d+k+r1)*KS[m]

for i in range(0,N/2-1):
ydot[G[i]] = a*P*S[i+1]-(d+k+r1)*PS[i]

for p in range(1,N/2):
ydot[p] = -S[p]*(r1+a*K+a*P)+k*KS[p-1]+d*(PS[p-1]+KS[p])

ydot[0] = Q-(r1+a*K)*S[0]+d*KS[0]+k*runsumPS
ydot[N/2] = k*KS[N/2-1]-(r2+a*P)*S[N/2]+d*PS[N/2-1]
ydot[G[N/2-1]] = a*P*S[N/2]-(d+k+r2)*PS[N/2-1]
ydot[3*N/2+1] = (d+k+r1)*runsumKS-a*K*runsum2
ydot[3*N/2+2] = (d+k+r1)*(runsumPS-PS[N/2-1])- \
a*P*runsum1+(d+k+r2)*PS[N/2-1]

ydot_new = []
for j in range(0,3*N/2+3):
ydot_new.extend(ydot[j])
return ydot_new

y0[0] = S10
for i in range(1,3*N/2+1):
y0[i] = 0
y0[3*N/2+1] = K0
y0[3*N/2+2] = P0

soln = odeint(f,y0,time, mxstep = 5000)
for alpha in range(0,(N/2+1)):
S[alpha] = soln[:,alpha]
for beta in range((N/2)+1,N+1):
KS[beta-N/2-1] = soln[:,beta]
for gamma in range(N+1,3*N/2+1):
PS[gamma-N-1] = soln[:,gamma]

for alpha in range(0,(N/2+1)):
Splot[alpha][series,val] = soln[len(time)-1,alpha]
for beta in range((N/2)+1,N+1):
KSplot[beta-N/2-1][series,val] = soln[len(time)-1,beta]
for gamma in range(N+1,3*N/2+1):
PSplot[gamma-N-1][series,val] = soln[len(time)-1,gamma]

u1 = 0
u2 = 0
u3 = 0

for alpha in range(0,(N/2+1)):
u1 = u1 + Splot[alpha]
for beta in range((N/2)+1,N+1):
u2 = u2 + KSplot[beta-N/2-1]
for gamma in range(N+1,3*N/2+1):
u3 = u3 + PSplot[gamma-N-1]

K = soln[:,3*N/2+1]
P = soln[:,3*N/2+2]
Kplot[series] = soln[len1-1,3*N/2+1]
Pplot[series] = soln[len1-1,3*N/2+2]
utot = u1+u2+u3

plt.figure(val)
cmap = mpl.cm.autumn
for iii in range(0,100,50):
for alpha in range(0,(N/2+1)):
plt.plot(np.array(range(1,N/2+2)), 
Splot[alpha][iii,val]/utot[iii,val],color=cmap(iii/50))
plt.xlabel('i')
plt.ylabel(r'$\frac{S_i}{S_{tot}}$ (nM)')

About a value error called 'ValueError: A value in x_new is below the interpolation range'

2013-02-05 Thread Isaac Won
Dear all,

I am trying to calculate correlation coefficients between one time series data 
and other time series. However,there are some missing values. So, I 
interploated each time series with 1d interpolation in scipy and got 
correlation coefficients between them. This code works well for some data sets, 
but doesn't for some others. Following is actual error I got:
0.0708904109589
0.0801369863014
0.0751141552511
0.0938356164384
0.0769406392694
Traceback (most recent call last):
  File error_removed.py, line 56, in module
i2 = interp(indices)
  File 
/lustre/work/apps/python-2.7.1/lib/python2.7/site-packages/scipy/interpolate/interpolate.py,
 line 394, in __call__
out_of_bounds = self._check_bounds(x_new)
  File 
/lustre/work/apps/python-2.7.1/lib/python2.7/site-packages/scipy/interpolate/interpolate.py,
 line 449, in _check_bounds
raise ValueError(A value in x_new is below the interpolation 
ValueError: A value in x_new is below the interpolation range.

This time is 'x_new is below the interpolation range, but some times, it shows 
above interpolation range.'

I would like to make some self-contained code, but, I am not sure how to make 
it to represent my case well.
I just put all of my code here. I apologize for this inconvenience.
---
-
a = []
c = 4
with open(filin1, 'r') as f1:
arrays = [map(float, line.split()) for line in f1]
newa = [[x[1],x[2]] for x in arrays]

o = newa[58]
f = open(filin, r)
percent1 = []
for columns in ( raw.strip().split() for raw in f ):
a.append(columns[63])
x = np.array(a, float)

not_nan = np.logical_not(np.isnan(x))
indices = np.arange(len(x))
interp = interp1d(indices[not_nan], x[not_nan])
#interp = np.interp(indices, indices[not_nan], x[not_nan])
i1 = interp(indices)

f.close
h1 = []
p1 = []
while c 278:
c = c + 1
d = c - 5
b = []


f.seek(0,0)
for columns in ( raw.strip().split() for raw in f ):

b.append(columns[c])
 y = np.array(b, float)
h = haversine.distance(o, newa[d])
n = len(y)
l = b.count('nan')
percent = l/8760.
percent1 = percent1 + [percent]
   #print l, percent

if percent  0.1:
not_nan = np.logical_not(np.isnan(y))
indices = np.arange(len(y))

interp = interp1d(indices[not_nan], y[not_nan])
#interp = np.interp(indices, indices[not_nan], x[not_nan])
i2 = interp(indices)

pearcoef = sp.pearsonr(i1,i2)
p = pearcoef[0]
p1 = p1 + [p]
h1 = h1 + [h]
print percent

print h1
print p1
print len(p1)
plt.plot(h1, p1, 'o')
plt.xlabel('Distance(km)')
plt.ylabel('Correlation coefficient')
plt.grid(True)
plt.show()
---
For any help or advice, I will really appreciate.

Best regards,

Isaac
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue7195] Value error 'path is on drive c: start on drive d:' in os.path.relpath

2009-10-31 Thread Jason R. Coombs

Jason R. Coombs jar...@jaraco.com added the comment:

Based on the response, then the documentation is inadequate. I don't
want to make a stink about this, but I think the issue is still
unresolved. If it would be better to discuss this elsewhere, please advise.

The documentation says Return a relative filepath to path either from
the current directory or from an optional start point.

The documentation should say Return a relative filepath to a path,
where path is considered relative to the current directory, either from
the current directory or from an optional start point. On Windows, a
ValueError is raised if the current directory and the start path are not
on the same drive.

The clarification is that the path specified is _not_ relative to the
start point (which would have been my guess), but is relative to another
unspecified environmental condition (the current directory). To leave
out this clarification means that this implicit behavior is left to the
user to discover rather than to state that it's by design.

For my purposes, I wanted a function that would calculate a target based
on a start path and a relative or absolute path from it. Based on the
documentation, I thought relpath was it.

I understand better now what the purpose of relpath is, and it's not
what I was expecting. I think the documentation could be improved to
help manage this expectation for other users.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7195
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7195] Value error 'path is on drive c: start on drive d:' in os.path.relpath

2009-10-31 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

The path *returned* is relative to the start point. The target path is
figured out normally (i.e. relative to the current directory if an
absolute path is not given).

In your example, you aren't passing in an absolute Windows path - you
give a path relative to the current drive (since no drive is specified).

Windows file pathing is hopeless, but it isn't the job of Python's
documentation to explain its quirks.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7195
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7195] Value error 'path is on drive c: start on drive d:' in os.path.relpath

2009-10-31 Thread Jason R. Coombs

Jason R. Coombs jar...@jaraco.com added the comment:

The documentation changes I suggested make no mention to Windows pathing
quirks. They instead clarify two aspects:

1) cross-platform behavior (how the path is interpreted) and
2) platform-specific implementation of relpath (what Python exceptions
to expect in exceptional conditions).

These two changes would have made it clear to me from the beginning that
relpath is not what I was searching for when I wanted to find a path
from one path to another. I'm just trying to help those who come after
me to not run into the same situation.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7195
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7195] Value error 'path is on drive c: start on drive d:' in os.path.relpath

2009-10-31 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

os.relpath *does* give you a relative path between two directories.

The problem you are encountering is that, on Windows, a relative path
doesn't even *exist* if the two directories are on different drives
(which is exactly what the error message says).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7195
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7195] Value error 'path is on drive c: start on drive d:' in os.path.relpath

2009-10-30 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

It's not the current directory that's the problem, it's the current
drive. Windows has no absolute root directory - instead, it has a root
directory for each drive. That means that \\dir is a path relative to
the current drive rather than an absolute path. You need to put the
drive letter in there to make it an absolute path.

That's just a fact of life when working with the windows file system,
rather than anything specific to Python or os.path.relpath.

--
nosy: +ncoghlan
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7195
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7195] Value error 'path is on drive c: start on drive d:' in os.path.relpath

2009-10-23 Thread Jason R. Coombs

New submission from Jason R. Coombs jar...@jaraco.com:

A simple test fails:

Python 2.6.3 (r263rc1:75186, Oct 2, 2009, 20:40:30) [MSC v.1500 32 bit
(Intel)] on win32
 import os
 os.path.relpath('\\bar', 'd:\\')
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\python\lib\ntpath.py, line 487, in relpath
% (path_list[0], start_list[0]))
ValueError: path is on drive C:, start on drive d:

If I change the current directory to 'E:\', the error changes to path
is on drive E:, start on drive d:.

Clearly, relpath is doing some calculations based on the current
directory, although the documentation states that it should be
performing a relative path calculation based on the supplied start
(D:\ in this case).

In Python 3.1.1, the error is path is on mount 'C:', start on mount 'd:'

os.path.relpath should be able to perform relative path calculations
regardless of the current directory, or the documentation should explain
why the current directory is relevant when start is supplied.

--
components: Windows
messages: 94394
nosy: jaraco
severity: normal
status: open
title: Value error 'path is on drive c: start on drive d:' in os.path.relpath
type: behavior
versions: Python 2.6, Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7195
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



value error

2009-04-23 Thread Francesco Pietra
hi:
with script

data = open('134-176_rectified_edited.pdb', 'r')
outp = open('134-176_renumbered.pdb', 'w')

for L in data:
   if L[3] == 'M':
 L = L[:24] + %4d % (int(L[24-28])+133) + L[28:]
   outp.write(L)


i wanted to modify lines of the type:
ATOM  1 HH31 ACE 1   1.573   1.961   0.769  1.00  0.00   H

to add 133 to column 25, getting 134 there, and so on for next lines 2
- 135, 3 - 136, etc.


i must have heavily messed things because the file was not even read:

$ python renumber.py 134-176_rectified.pdb
Traceback (most recent call last):
  File renumber.py, line 6, in module
L = L[:24] + %4d % (int(L[24-28])+133) + L[28:]
ValueError: invalid literal for int() with base 10: ''



thanks for having an expert look

chiendarret
--
http://mail.python.org/mailman/listinfo/python-list


Re: value error

2009-04-23 Thread Gerhard Häring
Francesco Pietra wrote:
 hi:
 with script
 
 data = open('134-176_rectified_edited.pdb', 'r')
 outp = open('134-176_renumbered.pdb', 'w')
 
 for L in data:
if L[3] == 'M':
  L = L[:24] + %4d % (int(L[24-28])+133) + L[28:]
outp.write(L)
 
 
 i wanted to modify lines of the type:
 ATOM  1 HH31 ACE 1   1.573   1.961   0.769  1.00  0.00   H
 
 to add 133 to column 25, getting 134 there, and so on for next lines 2
 - 135, 3 - 136, etc.
 
 
 i must have heavily messed things because the file was not even read:
 
 $ python renumber.py 134-176_rectified.pdb
 Traceback (most recent call last):
   File renumber.py, line 6, in module
 L = L[:24] + %4d % (int(L[24-28])+133) + L[28:]
 ValueError: invalid literal for int() with base 10: ''

Instead of L[24-28] you want L[24:28]. Otherwise it's L[-4] ;-)

-- Gerhard

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


Re: value error

2009-04-23 Thread Ben Finney
Francesco Pietra chiendar...@gmail.com writes:

 $ python renumber.py 134-176_rectified.pdb
 Traceback (most recent call last):
   File renumber.py, line 6, in module
 L = L[:24] + %4d % (int(L[24-28])+133) + L[28:]
 ValueError: invalid literal for int() with base 10: ''

For this reason, it's best to break up big complex expressions like this
into a sequence of simpler statements, so when one of them fails it's
easier to see what went wrong.

In this case, it's because you have L[24-28] where that's almost
certainly not what you mean. It calculates 24-28, getting -4; then uses
that value as an index into L.

You probably wanted to say L[24:28], a slice instead of a single index.

But, really, why are all these magic numbers littering the source,
instead of using named values? You're writing code that will be a
nightmare to maintain.

-- 
 \   “A lot of people are afraid of heights. Not me, I'm afraid of |
  `\   widths.” —Steven Wright |
_o__)  |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list


Re: value error

2009-04-23 Thread Jeremiah Dodds
On Thu, Apr 23, 2009 at 3:59 PM, Francesco Pietra chiendar...@gmail.comwrote:

 hi:
 with script

 data = open('134-176_rectified_edited.pdb', 'r')
 outp = open('134-176_renumbered.pdb', 'w')

 for L in data:
   if L[3] == 'M':
 L = L[:24] + %4d % (int(L[24-28])+133) + L[28:]
   outp.write(L)


 i wanted to modify lines of the type:
 ATOM  1 HH31 ACE 1   1.573   1.961   0.769  1.00  0.00
   H

 to add 133 to column 25, getting 134 there, and so on for next lines 2
 - 135, 3 - 136, etc.


 i must have heavily messed things because the file was not even read:

 $ python renumber.py 134-176_rectified.pdb
 Traceback (most recent call last):
  File renumber.py, line 6, in module
L = L[:24] + %4d % (int(L[24-28])+133) + L[28:]
 ValueError: invalid literal for int() with base 10: ''



 thanks for having an expert look

 chiendarret
 --
 http://mail.python.org/mailman/listinfo/python-list



I wrote this function the other day for something similar I needed to do,
you may find it useful:

def chunk_line(line, steps):
Return a list of chunks from a string, with sizes as specified by the
list steps.

 line = '1121231234'
 steps = [1,2,3,4]
 chunk_line(line, steps)
['1', '12', '123', '1234']

result = []
for step in steps:
result.append(line[:step])
line = line[step:]
return result
--
http://mail.python.org/mailman/listinfo/python-list


Re: value error

2009-04-23 Thread Terry Reedy

Francesco Pietra wrote:

hi:
with script

data = open('134-176_rectified_edited.pdb', 'r')
outp = open('134-176_renumbered.pdb', 'w')

for L in data:
   if L[3] == 'M':
 L = L[:24] + %4d % (int(L[24-28])+133) + L[28:]
   outp.write(L)


i wanted to modify lines of the type:
ATOM  1 HH31 ACE 1   1.573   1.961   0.769  1.00  0.00   H

to add 133 to column 25, getting 134 there, and so on for next lines 2
- 135, 3 - 136, etc.


A side note in addition to solution given: when writing code like this, 
to operate on column-oriented date, which I have done much of, I find it 
helpful to include in the code something like


# Sample line
#   1 2 3 4 5 6
# 012345678901234567890123456789012345678901234567890123456789012345 ...
# ATOM  1 HH31 ACE 1   1.573   1.961   0.769  1.00  0.00

Having done so...
Since slice indexes cut to the left of the corrresponding item index, I 
suspect you actually want

   L = L[:25] + %4d % (int(L[25:29])+133) + L[29:]
if the number is currently left-justified in its field (but note that 
%4d will *right*-justify the new number), or

   L = L[:22] + %4d % (int(L[22:26])+133) + L[26:]
if the number is currently right-justified.

If the data file is too big to verify correct formatting by eye, I also 
typically did preliminary checks first.  For instance, is every line 
exact the right length.  In this case, you better by sure that there are 
at most 9866 records, so you do not over-flow your four-char field.


Terry Jan Reedy

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


Re: os.walk Value Error?

2008-06-16 Thread Gabriel Genellina
En Sat, 14 Jun 2008 19:06:16 -0300, [EMAIL PROTECTED] escribió:

 I'm using os.walk as follows:

 (basedir, pathnames, files) = os.walk(results, topdown=True)

 and I'm getting the error:

 ValueError: too many values to unpack

 From my googling, that means:

 This is the standard message when Python tries to unpack a tuple
 into fewer variables than are in the tuple.

 From what I can see of the examples on the python site, I'm using it
 correctly.  I have commas in my original code, and the results
 directory exists and is directly under the directory from which my
 script is run.

Look the examples more carefully again - they don't use an assignment, but 
another Python statement...

-- 
Gabriel Genellina

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


os.walk Value Error?

2008-06-14 Thread tdahsu
Hi,

I'm using os.walk as follows:

(basedir, pathnames, files) = os.walk(results, topdown=True)

and I'm getting the error:

ValueError: too many values to unpack

From my googling, that means:

This is the standard message when Python tries to unpack a tuple
into fewer variables than are in the tuple.

From what I can see of the examples on the python site, I'm using it
correctly.  I have commas in my original code, and the results
directory exists and is directly under the directory from which my
script is run.

I'm assuming that 12 files (the number of files in the results
directory) is not too many for Python to handle!  ;-)

Is there any other reason I might get that error?
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.walk Value Error?

2008-06-14 Thread Larry Bates

[EMAIL PROTECTED] wrote:

Hi,

I'm using os.walk as follows:

(basedir, pathnames, files) = os.walk(results, topdown=True)

and I'm getting the error:

ValueError: too many values to unpack

From my googling, that means:

This is the standard message when Python tries to unpack a tuple
into fewer variables than are in the tuple.

From what I can see of the examples on the python site, I'm using it
correctly.  I have commas in my original code, and the results
directory exists and is directly under the directory from which my
script is run.

I'm assuming that 12 files (the number of files in the results
directory) is not too many for Python to handle!  ;-)

Is there any other reason I might get that error?


os.walk is a generator so you need to make it a loop target:

for basedir, pathnames, files in os.walk(results):
#
# Do you work inside the loop
#

-Larry
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.walk Value Error?

2008-06-14 Thread Christian Heimes
[EMAIL PROTECTED] wrote:
 Is there any other reason I might get that error?

Yes, you are using it the wrong way. The correct way is

for root, dirs, files in os.walk(path):
do something

os.walk returns an iterator which yields root, dirs and files for each
iteration.

Christian

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


Re: os.walk Value Error?

2008-06-14 Thread tdahsu
On Jun 14, 7:11 pm, Larry Bates [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
  Hi,

  I'm using os.walk as follows:

  (basedir, pathnames, files) = os.walk(results, topdown=True)

  and I'm getting the error:

  ValueError: too many values to unpack

  From my googling, that means:

  This is the standard message when Python tries to unpack a tuple
  into fewer variables than are in the tuple.

  From what I can see of the examples on the python site, I'm using it
  correctly.  I have commas in my original code, and the results
  directory exists and is directly under the directory from which my
  script is run.

  I'm assuming that 12 files (the number of files in the results
  directory) is not too many for Python to handle!  ;-)

  Is there any other reason I might get that error?

 os.walk is a generator so you need to make it a loop target:

 for basedir, pathnames, files in os.walk(results):
      #
      # Do you work inside the loop
      #

 -Larry

Thanks!
--
http://mail.python.org/mailman/listinfo/python-list


[ python-Bugs-1276587 ] dict('') doesn't raise a value error

2005-08-30 Thread SourceForge.net
Bugs item #1276587, was opened at 2005-08-30 12:52
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1276587group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Mike Foord (mjfoord)
Assigned to: Nobody/Anonymous (nobody)
Summary: dict('') doesn't raise a value error

Initial Comment:
The dict function will theoretically accept any sequence 
or bounded iterable that yields (key, value) tuples.

A side effect is that dict('') is valid - producing an emtpy 
dictionary.

dict(x) where x is *any* string other than '' fails with a 
ValueError. I suggest that dict('') ought to produce a 
ValueError to as a string is *never* a valid input to the 
dict function.

The current situation allows obscure errors to pass 
unnoticed.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1276587group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1276587 ] dict('') doesn't raise a value error

2005-08-30 Thread SourceForge.net
Bugs item #1276587, was opened at 2005-08-30 08:52
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1276587group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Mike Foord (mjfoord)
Assigned to: Nobody/Anonymous (nobody)
Summary: dict('') doesn't raise a value error

Initial Comment:
The dict function will theoretically accept any sequence 
or bounded iterable that yields (key, value) tuples.

A side effect is that dict('') is valid - producing an emtpy 
dictionary.

dict(x) where x is *any* string other than '' fails with a 
ValueError. I suggest that dict('') ought to produce a 
ValueError to as a string is *never* a valid input to the 
dict function.

The current situation allows obscure errors to pass 
unnoticed.

--

Comment By: Tim Peters (tim_one)
Date: 2005-08-30 10:39

Message:
Logged In: YES 
user_id=31435

It's not theoretical:  it's a fact that dict() accepts any iterable 
producing iterables each producing 2 objects (the latter don't 
have to be tuples; a (key, value) tuple is just one kind of 
iterable producing 2 objects; e.g., dict([ab]) == {'a': 'b'}).

An empty str meets the input requirements, so there's no 
way to stop this without special-case type-sniffing.  That's 
very unattractive, in part because it's impossible to guess 
which kinds of empty iterables would necessarily lead to an 
exception when passed to dict() had they not been empty.  
For example, passing an empty array.array (of any flavor) to 
dict() also constructs an empty dict.  The universe of iterable 
objects is vast.

Keeping it uniform and easy to explain (an empty iterable 
produces an empty dict) seems better to me than adding a 
maze of special cases that's bound to change over time 
(except for an empty str ... oh, or an empty 
unicode ... oh, or an empty array.array ... oh, or an empty 
file ... oh, oops, guess not, cuz a file with two lines works 
fine ... etc).

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1276587group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com