asuiu / pyxtension Goto Github PK
View Code? Open in Web Editor NEWPure Python extensions library that includes Scala-like streams, Json with attribute access syntax, and other common use stuff
License: MIT License
Pure Python extensions library that includes Scala-like streams, Json with attribute access syntax, and other common use stuff
License: MIT License
Hi there, got strange error,
i installed 2 version, local and prods server, but on prod server it gives me error like this :
Traceback (most recent call last):
File "versi1_telebot.py", line 1, in
from pyxtension.Json import Json
File "/usr/local/lib/python3.5/dist-packages/pyxtension/Json.py", line 14, in
from pyxtension.streams import *
File "/usr/local/lib/python3.5/dist-packages/pyxtension/streams.py", line 45
_IDENTITY_FUNC: Callable[[T], T] = lambda _: _
^
SyntaxError: invalid syntax
I installed pyxtension with pip, but it's weird the version shown doesn't match the real version.
I want to install version 1.11:
$ pip install pyxtension==1.11
Collecting pyxtension==1.11
Installing collected packages: pyxtension
Successfully installed pyxtension-1.0
then I use pip freeze to see the version:
$ pip freeze | grep pyxtension
pyxtension==1.0
It shows version 1.0.
Example:
def split_in_batches(self, itr: Iterable[T], batch_max_size: int = BATCH_SIZE) -> Generator[slist[T], None, None]:
batch = slist()
for el in itr:
batch.append(el)
if batch.size() == batch_max_size:
yield batch
batch = slist()
if batch.size():
yield batch
It should try the map function, and if it throws exception return an instance of custom "Fail" object that evaluates to False
for filter() functions, and contain the exception data (stack trace, etc..)
Standard lib multiprocess is not able to handle lambda functions due to use of limited serializer (Pickle). Pathos multiprocess fork is able to serialize lambdas using Dill serializer.
Proposal is to make pyxtension use this improved multiprocessing library to handle cases like lambda functions and other advantages it brings
Hello
Is there any plans to standardize installation process with pip?
P.S. Thank you for such a convenient library!
Why:
slist()+slist() retuns a list() object
Hi Andrei ,
For the sample given:
corpus = [
"MapReduce is a programming model and an associated implementation for processing and generating large data sets with a parallel, distributed algorithm on a cluster.",
"At Google, MapReduce was used to completely regenerate Google's index of the World Wide Web",
"Conceptually similar approaches have been very well known since 1995 with the Message Passing Interface standard having reduce and scatter operations."]
def reduceMaps(m1, m2):
for k, v in m2.iteritems():
m1[k] = m1.get(k, 0) + v
return m1
word_counts = stream(corpus). \
mpmap(lambda line: stream(line.lower().split(' ')).countByValue()). \
reduce(reduceMaps)
The processing results in following error:
Traceback (most recent call last):
File "C:\Users\ses\AppData\Local\Programs\Python\Python39\lib\multiprocessing\pool.py", line 537, in _handle_tasks
put(task)
File "C:\Users\ses\AppData\Local\Programs\Python\Python39\lib\multiprocessing\connection.py", line 211, in send
self._send_bytes(_ForkingPickler.dumps(obj))
File "C:\Users\ses\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 51, in dumps
cls(buf, protocol).dump(obj)
_pickle.PicklingError: Can't pickle <function at 0x00000183A90173A0>: attribute lookup on main failed
Similar error occurs with other case like:
result = stream([v for v in entry_list.values()]). \
mpmap(lambda entry: TwigBasic.split_multiple_yang_structures_in_one_line(entry) if TwigBasic._check_for_twig(entry) else [entry]). \
flatMap(). \
enumerate(). \
map(lambda item: (str(item[0]), item[1])). \
toMap()
Could you pls have a look on it!
Best regards,
Serge
csv module in Py2x standard library dails reading unicode csv files. Adding UnicodeReader and UTF8Recorder according to stdlib documentation solves the problem, but inconvenient to replicate in every project/module.
Use gzip.open function
for changing from GPL to MIT type of licenses, the explicit agree from all contributors, including @asuiu @marian-rusu , must be collected
When performing a sset() | sset()
it returns a set
. We need it return sset
so it can be chained further.
Use already implemented fastmap()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.