Burrows-Wheeler (BWT) Algorithm in Python

2005-11-02 Thread DENG
Hi, all

I've used Python Bz2 module for times and want to kown something about
Burrows-Wheeler (BWT) algorithm, the Bz2 module is wrriten in C, is
there a version in Python too?

BWT
http://gatekeeper.dec.com/pub/DEC/SRC/research-reports/abstracts/src-rr-124.html
Python Bz2 module
http://labix.org/python-bz2

thanks

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


Re: Burrows-Wheeler (BWT) Algorithm in Python

2005-11-03 Thread DENG
thanks very much Michael

i'll try your implementation, i hope i can improve it after i
understand all the theory:)

cheers

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


Re: python html

2005-08-20 Thread DENG
try this

http://miex.tigris.org

i wrote this for checking bad html, correct them and optimize them

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


how to join two Dictionary together?

2005-08-30 Thread DENG

dict1={...something...}

dict2={...somethind else ..}

dict1 + dict2


that's does works ..:(, it's not like List...


anyone can tell me how to get it?

thanks in advance

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


Re: how to join two Dictionary together?

2005-08-30 Thread DENG
yes, that's really what i want!

the 2nd replace the 1st one' value!

thanks so much King

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


Re: how to join two Dictionary together?

2005-08-30 Thread DENG
thanks  all!!

update is very useful!

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


HTML tags optimization [ interesting problem]

2005-08-31 Thread DENG

hi all,

i use SGMLParser to process HTML files, in order to do some
optimizations,

something like this:

TEXT1TEXT2

optimise to

TEXT1TEXT2


at the very beginning, i was thinking of analysing each text-block, to
know their color, size, if is bold or italic, but i found it was too
complicated.

e.g

TEXT1

optimise to

TEXT1


but if there is TEXT2 exist

TEXT1TEXT2

we can not do any optimization.

my problem is I can not find a method to treat all those situation, I
had too much thinking and get fool now


anyone can give me some advices?

thanks




PS:

other examples:

1
TEXT
=>
TEXT

2
TEXT TEXT
=>
TEXT TEXT

3
TEXTTEXT
=>
TEXT

etc...

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


Re: HTML tags optimization [better learn CSS]

2005-09-01 Thread DENG
I know very well Tidy, sir

Tidy do a nice job but it is writen in Java, and have Python ported

my aim is to learn Python, learn how to program

I know many people write "hello the world" in 2005, why I can not write
this program in 2005?

you are french, right? peut etre we can talk about it in ecole
polytechnique? i'll be there waiting for you

thanks

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


Re: HTML tags optimization [ interesting problem]

2005-09-01 Thread DENG
I know very well Tidy, sir

Tidy do a nice job but it is writen in Java, and have Python ported

my aim is to learn Python, learn how to program

I know many people write "hello the world" in 2005, why I can not write
this program in 2005?

you are french, right? peut etre we can talk about it in ecole
polytechnique? i'll be there waiting for you

thanks

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


HTML tags optimization

2005-09-02 Thread DENG
hi all,

i want to do some optimizations for HTML tags,

something like this:

TEXT1TEXT2

optimise to

TEXT1TEXT2

at the very beginning, i was thinking of analysing each text-block, to
know their color, size, if is bold or italic, but i found it was too
complicated.

e.g

TEXT1

optimise to

TEXT1

but if there is TEXT2 exist

TEXT1TEXT2

we can not do any optimization.

my problem is I can not find a method to treat all those situation, I
had too much thinking and get fool now

anyone can give me some advices?

thanks

PS:

other examples:

1
TEXT
=>
TEXT

2
TEXT TEXT
=>
TEXT TEXT

3
TEXTTEXT
=>
TEXT

etc...

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


Re: HTML tags optimization [ interesting problem]

2005-09-02 Thread DENG
hi, Sybren,

thanks for your reply, if use CSS:

texttexttext

optimise to:

texttexttext

what i need is the METHOD to do optimization, in fact, i have ready
write a program to analyse the syntax of CSS, to make it works with all
situation

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


Share your SciTEGlobal.properties pls~~~~

2005-02-28 Thread DENG
hi,
im new to Python, i chose SciTE as my Python editor. but the problem is
SciTE needs to be config carefully, are there anyone use SciTE too? can
you share your SciTEGlobal.properties file? black background solution
is prefered:)

thanks in advance

best regards

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


Share your SciTEGlobal.properties pls~~~~

2005-02-28 Thread DENG
hi,
im new to Python, i chose SciTE as my Python editor. but the problem is
SciTE needs to be config carefully, are there anyone use SciTE too? can
you share your SciTEGlobal.properties file? black background solution
is prefered:)

thanks in advance

best regards

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


how to execute Python in VIM

2005-03-05 Thread DENG
hi,

im a newbie to VIM(gVIM under WINXP), i want to execute python in vim
like press F5 in SciTE.

i try to search in google and config as follows in my _vimrc:
---
map :D:\python24\python.exe %

if has("autocmd")


  autocmd FileType python setlocal et | setlocal sta | setlocal sw=4
  autocmd FileType python compiler pyunit
  autocmd FileType python setlocal makeprg=python\ ./alltests.py
  autocmd BufNewFile,BufRead test*.py setlocal makeprg=python\ %


endif

--

but neither F5 nor MAKE works.

who can help me ?

thanks in advance

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


Re: how to execute Python in VIM

2005-03-05 Thread DENG
i change the path

 autocmd FileType python setlocal makeprg=\"d:\\Python24\\python.exe\"\

  autocmd BufNewFile,BufRead test*.py setlocal
makeprg=\"d:\\Python24\\python.exe\"\ %

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


Re: how to execute Python in VIM

2005-03-05 Thread DENG
ok

i find it

map  :!d:\python24\python.exe %


but it comes with a new pop-up windowsdame~

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


Re: how to execute Python in VIM

2005-03-07 Thread DENG
thanks Aaron

i've changed that, but this time, even worse...

when i press F5, the pop-up windows appears, and then, it disppears
very quickly...(less than 1 second)

i cant see anything~  :(

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


How can I solve a equation like solve a function containint expressions like sqrt(log(x) - 1) = 2 and exp((log(x) - 1.5)**2 - 3) = 5

2011-08-27 Thread Xiong Deng
HI,

Hi, I am trying to solve an equation containing both exp, log, erfc, and
they may be embedded into each otherBut sympy cannot handle this, as
shown below:

>>> from sympy import solve, exp, log, pi
>>>from sympy.mpmath import *
>>>from sympy import Symbol
>>>x=Symbol('x')
>>>sigma = 4
>>>mu = 1.5
>>>solve(x * ((1.0 / sqrt(2 * pi) * x * sigma) * exp(-0.5 * (log(x) - mu)**2
/ sigma**2)) + 0.5 * erfc((mu - log(x)) / (sigma * sqrt(2))) - 1, x)

Traceback (most recent call last):
  File "", line 1, in 
  File
"/home/work/local/python-2.7.1/lib/python2.7/site-packages/sympy/mpmath/functions/functions.py",
line 287, in log
return ctx.ln(x)
  File
"/home/work/local/python-2.7.1/lib/python2.7/site-packages/sympy/mpmath/ctx_mp_python.py",
line 984, in f
x = ctx.convert(x)
  File
"/home/work/local/python-2.7.1/lib/python2.7/site-packages/sympy/mpmath/ctx_mp_python.py",
line 662, in convert
return ctx._convert_fallback(x, strings)
  File
"/home/work/local/python-2.7.1/lib/python2.7/site-packages/sympy/mpmath/ctx_mp.py",
line 556, in _convert_fallback
raise TypeError("cannot create mpf from " + repr(x))
TypeError: cannot create mpf from x

But sqrt, log, exp, itself is OK, as shown as below:

>>> solve((1.0 / sqrt(2 * pi) * x * sigma) - 1, x)
[0.626657068657750]

SO, How can I solve an equation containint expressions like sqrt(log(x) -
1)=0 or exp((log(x) - mu)**2 - 3) = 0??? If there are any other methods
without Sympy, it is still OK.

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


Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-22 Thread Siyi Deng
I have a dynamic library doing some numerical computations. 

I used ctypes to interact it by passing numpy arrays back and forth. 

Python 3.5 gives me the correct results. 

Python 2.7 gives me different, erroneous results, but it never crashes. 

How is this possible? There is no string operations involved whatsoever.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Siyi Deng
Thanks for all the replies.  

It turned out that the Apple OS X stock python 2.7 gives the wrong results, but 
other distributions like 2.7 from miniconda gives the correct results. Facepalm.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Siyi Deng
Hello ChrisA,
I don't quite understand, the binary shared library contains no python 
interfaces, it should be independent of python. As a matter of fact, I have 
successfully used it in Conda python 2.7, 3.5,  Julialang as well as c++ 
executables. I think the fact that only stock python 2.7 failed to run 
correctly indicates some bug in that python distribution. 


> When you use a binary shared library, it has to be compiled against
> the correct Python. You're messing around with ctypes, so basically
> you've voided your warranty; *everything* you're doing is
> platform-specific. Have fun. :)
> 
> ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Siyi Deng
The c function has a signature as follows:

int cfun(int len_data, float* data, int* a, int num_a,
int flag1, int flag2, int flag3, float* param,
float* out1, float* out2, float* out3)


and in python:

import numpy as np
import ctypes as ct

data = np.atleast_2d(np.float32(data))
a = np.atleast_2d(np.int32(a)) if a else np.zeros((2, 1), dtype=np.int32)
param = np.atleast_2d(np.float32(param))

num_a = activity.shape[1]
len_data = data.shape[1]
num_inc = len_data//256
cf = ct.POINTER(ct.c_float)

hr = np.zeros((2, num_inc), dtype=np.float32)
of = np.zeros((num_inc, 207), dtype=np.float32)
gait = np.zeros((num_inc, 14), dtype=np.float32)
pt_of = of.ctypes.data_as(cf) if do_of else None
pt_gait = gait.ctypes.data_as(cf) if do_gait else None
pt_param = param.ctypes.data_as(cf) if param else None
dl.run_plt_hrm(len_data, data.ctypes.data_as(cf),
activity.ctypes.data_as(ct.POINTER(ct.c_int)),
num_act, do_long_fft+0, do_cls_mitigate+0, do_weighted_average+0,
pt_param, hr.ctypes.data_as(cf), pt_of, pt_gait)

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


Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Siyi Deng
Here is a summary of what I did with numpy and the dll

I have verified that the values entering the last dll call (dl.cfunction) are 
identical across platforms.


 

The c function has a signature as follows: 

int cfunction(int len_data, float* data, int* ac, int num_ac, 
int flag1, int flag2, int flag3, float* param, 
float* out) 


and in python: 

import numpy as np 
import ctypes as ct 

dl = ct.cdll.LoadLibrary('xxx.dylib')

# data, ac, param are loaded from somewhere else.
data = np.atleast_2d(np.float32(data)) 
ac = np.atleast_2d(np.int32(a)) if a else np.zeros((2, 1), dtype=np.int32) 
param = np.atleast_2d(np.float32(param)) 
flag1 = True
flag2 = True
flag3 = True
num_ac = ac.shape[1] 
len_data = data.shape[1] 
num_inc = len_data//200
out = np.zeros((2, num_inc), dtype=np.float32) 
pt_param = param.ctypes.data_as(cf) if param else None

cf = ct.POINTER(ct.c_float) 
dl.cfunction(len_data, data.ctypes.data_as(cf), 
ac.ctypes.data_as(ct.POINTER(ct.c_int)), 
num_ac, flag1+0, flag2+0, flag3+0, 
pt_param, out.ctypes.data_as(cf)) 


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


Hello everyone!

2009-04-20 Thread Yilong Deng
I'm a newby here, I love python very much.
Is there any Chinese here?--
http://mail.python.org/mailman/listinfo/python-list


pickle.load() all dict

2010-05-15 Thread Yutao Deng
Hi all:
I'm trying to learn to use Python  wrote a applet to record every day doing.
and i use the pickle
pickle.dump something to file no problem i think.
but pickle.load whith a problem. can not load all dict do my way that what i
pickle.dump().

My code:

import cPickle as pickle
pickle_file = open("data2","rb")
i = pickle.load(pickle_file)
print i
i = pickle.load(pickle_file)
print i
i = pickle.load(pickle_file)
print i
i = pickle.load(pickle_file)
print i
i = pickle.load(pickle_file)
print i

console show :
{'2010-5-23': ['1242', 'first']}
{'2010-5-24': ['1232', 'third']}
{'2010-5-25': ['211', 'second']}
{'2010-3-22': ['3211', 'fou']}
{'2050-3-2': ['3990', '322']}

This is i want but that's silly. if the dict too much, then i have not
ideas.

the other way from
http://mail.python.org/pipermail/tutor/2005-July/039859.html


import cPickle as pickle
pickle_file = open("data2","rb")

number_of_pickles = pickle.load(pickle_file)
for n in range(number_of_pickles):
p = pickle.load(pickle_file)
print p

this way didnt work for me.

console show:
Traceback (most recent call last):
number_of_pickles = pickle.load(pickle_file)
cPickle.UnpicklingError: invalid load key, '
'.
how do i define the range of pickle.load a file. i mean that how can i know
how many dict in the data2.
-- 
http://mail.python.org/mailman/listinfo/python-list


socket.error: (32, 'Broken pipe'): need help

2005-10-27 Thread Junhua Deng (AL/EAB)
Hi,
I have a simple server-client application with threading. It works fine when 
both server and client on the same machine, but I get the following error 
message if the server is on another machine:

... ...
self.socket.send(outgoingMsg)
socket.error: (32, 'Broken pipe')

I do not know where to start with? 

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