蠎加载 174

原文: Import Python Weekly Newsletter - Issue No 174 欢迎, 来 PyChina/weekly 共同翻译/增订/推荐 周刊 蠎消息 ;-) 该读 ~ 文章, Blog, 教程… 中级 Python eBook - Free ebook If you are a beginner, intermediate or even an advanced programmer there is something for you in this book. Please note that this book is not a tutorial and does not teach you Python. The topics are not explained in depth, instead only the minimum required information is given. (是也乎: 叕一本免费入门书… 所以, 图书免费, 找作者干点儿什么再收费? ) 用特征标记驯服不可逆性 software engineering Feature Flags are a very simple technique to make features of your application quickly toggleable. The way it works is, everytime we change some behavior in our software, a logical branch is created and this new behavior is only accessible if some specific configuration variable is set or, in certain cases, if the application context respects some rules. (是也乎: 简单的说, 防御型软件架构, 远远没有到放弃的地步… ) Python 咯表驱动单元测试 unit testing Now days, table driven tests are pretty much industry standard. In my workplace, we use table driven tests when we write unit tests (in golang though). Here I shall share a simple code example using pytest that shows how to write table driven tests in Python. In table driven test, what you need to do is, to gather all the tests cases together in a single table. We can use dictionary for each test case and a list to store all the test cases. Instead of discussing it further, let me show you an example. (是也乎: 其实吧, 单元测试的难点不在技术, 而在成本的认同… ) Qt for Python: under the hood pyside When the PySide project was launched back in 2009, the team decided to use external tools to generate Python bindings from Qt C++ headers. One of the main concerns, besides using a tool that properly handles all the Qt C++ constructs, was the size of the final packages. The previous choice was using templates excessively, hence another alternative was required. After analyzing a few other options the team decided to write their own generator, Shiboken. (是也乎: Qt 当年的开源是自救,现在面对移动互联网, 却一直没找到嗯哼点… 当然从 PySide –> Shiboken , 可能也只是因为 Why not 毕竟客户不多… ) 用 Python 和 scrapy, xarray, 以及 cartopy 可视化全球土地温度 scrapy, xarry, cartopy A few years ago, I worked on a project that involved collecting data on a variety of global environmental conditions over time. Some of the data sets included cloud cover, rainfall, types of land cover, sea temperature, and land temperature. I enjoyed developing a greater understanding of our Earth by visualizing how these conditions vary over time around the planet. To get a sense of how fun and informative it can be to analyze environmental data over time, let’s work on visualizing global land surface temperatures from 2001 to 2016. (是也乎: 当然, 一切的开始, 还是得要先有公开数据 ) A Gilectomy 更新 gil In a rather short session at the 2018 Python Language Summit, Larry Hastings updated attendees on the status of his Gilectomy project. The aim of that effort is to remove the global interpreter lock (GIL) from CPython. Since his status report at last year’s summit, little has happened, which is part of why the session was so short. He hasn’t given up on the overall idea, but it needs a new approach. Gilectomy has been “untouched for a year”, Hastings said. He worked on it at the PyCon sprints after last year’s summit, but got tired of it at that point. He is “out of bullets” at least with that approach. With his complicated buffered-reference-count approach he was able to get his “gilectomized” interpreter to reach performance parity with CPython—except that his interpreter was running on around seven cores to keep up with CPython on one. (是也乎: 真的有人真正动手来清除所有 GIL , 虽然 Guido 不动手, 但是, 开源世界里, 不代表不可能… ) forge project forge is an elegant Python package for crafting function signatures. Its aim is to help you write better, more literate code with less boilerplate. (是也乎: 好闹… ) 用 Python 实现缝线雕刻 image processing Seam carving is a novel way to crop images without losing important content in the image. This is often called “content-aware” cropping or image retargeting. (是也乎: 内容感知向的图片智能裁剪 ) Bpython - 可选交互式 Python 解释器 - YouTube video Bpython - alternative interactive python interpreter (是也乎: 和 IPyNB 同时期诞生的交互增强, 可惜, 人家都独立为 Jupyter 了, Bpython 还在嗯哼… ) Python 中的抽象语法树(ast library) AST An Abstract Syntax Tree is a simplified syntactic tree representation of a programming language’s source code. Each node of the tree stands for an statement occurring in the code. This trees don’t show the entire syntactic clutter, just the important information for analyzing the code. If it showed the entire structure it would be a Concrete Syntax Tree, but it’s usually better to simplify it because the information we use when building compilers can be found on an abstract syntax tree. (是也乎: 内置的只是可用, 远远达不到大家的期待.. ) 好物 ~ 包/模块/库/片段… ...

2018-05-31 · 5 min · 2025 words · ZoomQuiet

蠎加载 173

原文: Import Python Weekly Newsletter - Issue No 173 欢迎, 来 PyChina/weekly 共同翻译/增订/推荐 周刊 蠎消息 ;-) 该读 ~ 文章, Blog, 教程… 集合理论与实践: Grok Pythonic收集类型 core-python, set Sets and logic are strongly related. That’s why proper use of set operations can eliminate lots of nested loops and ifs, producing code that is more readable and faster. Let’s talk about using sets in practice, and learn great API design ideas from Python’s set types. Luciano covered: - Python collection types - Theory and algebraic logic behind set-less and set types - Python protocols and operations for collections - Code examples for implementations of kinds of sets (是也乎: 善用 set 可以有效减少不必要的 循环和 if 判定 ) Pyre: Python 的快速类型检查 ...

2018-05-14 · 5 min · 2050 words · ZoomQuiet

蠎加载 172

原文: Import Python Weekly Newsletter - Issue No 172 欢迎, 来 PyChina/weekly 共同翻译/增订/推荐 周刊 蠎消息 ;-) 该读 ~ 文章, Blog, 教程… TensorFlow Dev Summit 2018 TensorFlow, google Join the TensorFlow team as they kick off the 2018 TensorFlow Dev Summit! The TensorFlow Dev Summit brings together a diverse mix of machine learning users from around the world for a full day of highly technical talks, demos, and conversations with the TensorFlow team and community. 如何使用 Python 中 textblob 分类器自动分配 Jira Issue? text classification I’ve used Python’s textblob classifier to simply classify issues according to assignees from their description and headers. Classified issues used to classify newly created issues and results are recorded to a database. 2019 issues used as training set and %82 assignment accuracy have been achieved. As the training set grows bigger accuracy could be better. (是也乎: 嗯哼,目测只有在客服 Issue 方向有用… ) 基本 Python 面试题和答案 interview questions (是也乎: 叕一辑 FAQ.py, 应聘专用 ) Python 开发者画像: 用什么 作什么 survey A survey of 9,500 developers shows what Python programmers use and what they work on. See how typical you are as a Python developer (是也乎: 等等吧, 所以, Py2 即便官方不维护, 也不影响其广泛的使用… ) 最佳免费 Python 可视化包 visualization Nice curated list. (是也乎: 可视化的方向一定是专业化, 通用的, 考虑到输出, 推荐 Bokeh; 考虑日常推荐: pandas 呃, 其实用的就是: matplotlib ) 在 Python 中回归一个比例 statistics I frequently predict proportions (e.g., proportion of year during which a customer is active). This is a regression task because the dependent variables is a float, but the dependent variable is bound between the 0 and 1. Googling around, I had a hard time finding the a good way to model this situation, so I’ve written here what I think is the most straight forward solution. (是也乎: 数据归一化的常见招术式: from sklearn.datasets import make_regression ) 用 Python 对非数字数据进行聚类 numeric_data Clustering data is the process of grouping items so that items in a group (cluster) are similar and items in different groups are dissimilar. After data has been clustered, the results can be analyzed to see if any useful patterns emerge. For example, clustered sales data could reveal which items are often purchased together (famously, beer and diapers). 主题建模评估: 主题一致性 topic modeling In this article, we will go through the evaluation of Topic Modelling by introducing the concept of Topic coherence, as topic models give no guaranty on the interpretability of their output. Topic modeling provides us with methods to organize, understand and summarize large collections of textual information. There are many techniques that are used to obtain topic models. Latent Dirichlet Allocation (LDA) is a widely used topic modeling technique to extract topic from the textual data. Announcing PyTorch 1.0 for both research and production pytorch PyTorch 1.0 takes the modular, production-oriented capabilities from Caffe2 and ONNX and combines them with PyTorch’s existing flexible, research-focused design to provide a fast, seamless path from research prototyping to production deployment for a broad range of AI projects. (是也乎: 江湖传说:to be politically correct at Google import torch as tf ) 用 Python 基于 Google 位置记录分析通勤情况 | nvbn blog visualization, location, commute Since I moved to Amsterdam I’m biking to work almost every morning. And as Google is always tracking the location of my phone, I thought that it might be interesting to do something with that data. (是也乎: 反正都被追踪了, 那么除了 google 自动分析 我们自己也应该可以… ) PostgreSQL: 跨函数调用共享数据 postgres Recently I did some PostgreSQL consulting in the Berlin area (Germany) when I stumbled over an interesting request: How can data be shared across function calls in PostgreSQL? I recalled some one of the other features of PostgreSQL (15+ years old or so) to solve the issue. Here is how it works. (是也乎: OpenResty 从一开始就内置了一个对象数据库来解决跨请求的数据共享/操作… ) 正态性测试 testing, data science So you have a dataset and you’re about to run some test on it but first, you need to check for normality. Think about this question, “Given my data … if there is a deviation from normality, will there be a material impact my results?” (是也乎: 被测试数据对象集本身的正常状态检测 ) 从 subscene.com 批量下载字幕 – Scribbleghost project Ever just wanted to download a bunch of subtitles to check which one fits the video? Subscene got everything, but it can be tedious to download subtitles one by one. 前沿效益: 用 scipy 优化投资组合分配 scipy Given 4 assets’ risk and return as following, what could be the risk-return for any portfolio built with the assets. One may think that all possible values should fall inside the area. But it is possible to go beyond the bond, because combining inversely correlated assets can construct a portfolio with lower risk. Python/networkx 图形魔术 networkx Basic graph representation function on top of networkx graph library. (是也乎: networkx 是对 Graphviz 的 Pythonic 封装, 基于 dot 等工具的稳定, 可以尽情折腾… ) 使用 Python 和 Apache Spark 的阅读计划建议 spark, recommendation My goal in this post is simply to share how we at YouVersion are leveraging machine learning tools to generate product recommendations. 好物 ~ 包/模块/库/片段… ...

2018-05-07 · 5 min · 2227 words · ZoomQuiet

蠎加载 171

原文: Import Python Weekly Newsletter - Issue No 171 欢迎, 来 PyChina/weekly 共同翻译/增订/推荐 周刊 蠎消息 ;-) 该读 ~ 文章, Blog, 教程… 最好的 Python:从2017年到2018年收藏的一系列文章(到目前为止) 2017, python articles In this article, I’d like to share with you the articles I found most interesting and insightful (inspiring) last year and this year (so far). My other goal was to create a comprehensive list of the most valuable pieces for my Python students. (是也乎: 老司机的私人体验, 应该就是 Py 自身真正的好物了… ) Python 3.7: 介绍数据类 pycharm, data classes Python 3.7 is set to be released this summer, let’s have a sneak peek at some of the new features! If you’d like to play along at home with PyCharm, make sure you get PyCharm 2018.1 (or later if you’re reading this from the future). There are many new things in Python 3.7: various character set improvements, postponed evaluation of annotations, and more. One of the most exciting new features is support for the dataclass decorator. (是也乎: 怀疑哪, Py3 这么多激荡的变化, 是否有 IDE 厂商的嗯哼? ) Qt 让 Python 令计算贴近你 - Qt Blog pyside PySide2 – the bindings from Python to Qt – changes skin this spring. We have re-branded it as Qt for Python on a solution level, as we wanted the name to reflect the use of Qt in Python applications. Under the hood it is still PySide2 – just better. (是也乎: Qt 开源后走的一直不错, 只是太慢, 就连 IDE 都一直非常不嗯哼…这种广告都没有 subl 来的多…可想… ) 转换 Python ASTs 来优化 AST tl;dr Python comprehensions can have duplicate function calls (e.g. [foo(x) for x in … if foo(x)]). If these function calls are expensive, we need to rewrite our comprehensions to avoid the cost of calling them multiple times. In this post, we solve this by writing a decorator that converts a function in to AST, optimizes away duplicate function calls and compiles it at runtime in ~200 lines of code. (是也乎: 不过,这种机械优化, 永远没有人工介入后, 经验加成的效果好… ) Cgo 和 Python go, cpython If you look at the new Datadog Agent, you might notice most of the codebase is written in Go, although the checks we use to gather metrics are still written in Python. This is possible because the Datadog Agent, a regular Go binary, embeds a CPython interpreter that can be called whenever it needs to execute Python code. This process can be made transparent using an abstraction layer so that you can still write idiomatic Go code even when there’s Python running under the hood. (是也乎: 通过 C , go 和 python 一直灵魂相通的… ) 用 Python 进行机器学习的一些基本技巧和窍门 machine learning We describe some essential hacks and tricks for practicing machine learning with Python. 在 Kubernetes 中部署深度学习 GPU 运算模型 deep learning, GPU In this tutorial, we provide step-by-step instructions to go from loading a pre-trained Convolutional Neural Network model to creating a containerized web application that is hosted on Kubernetes cluster with GPUs on Azure Container Service (AKS). AKS makes it quick and easy to deploy and manage containerized applications without much expertise in managing Kubernetes environment. It eliminates complexity and operational overhead of maintaining the cluster by provisioning, upgrading, and scaling resources on demand, without taking the applications offline. AKS reduces the cost and complexity of using a Kubernetes cluster by managing the master nodes for which the user does no incur a cost. (是也乎: 这类工具一定会越来越方便的, 问题在 GPU 本身是硬件, 有固定成本, 这就是门槛了… ) Python 3 cheatsheet cheatsheet (是也乎: 叕一则作弊条…但是, 最靠谱的还是多用… ) Python 3 到 ES6 Javascript 转译器 js (是也乎: 没毛病, 问题只是, 这种转换的使用场景在哪儿? ) 用 PySpark 进行单元测试 – CambridgeSpark testing I don’t particularly enjoy writing tests, but having a proper testing suite is one of the fundamental building blocks that differentiate hacking from software engineering. Sort of like sending your application to the gym, if you do it right, it might not be a pleasant experience, but you’ll reap the benefits continuously. At work we are especially big fans of the testing pyramid, and having dozens of unit tests give us the support that we need to deliver high quality software with rapid delivery to production. (是也乎: 叕一个单元测试框架, ) 好物 ~ 包/模块/库/片段… ...

2018-04-22 · 4 min · 1979 words · ZoomQuiet