python_practise | python 基础学习 -- 《图解算法》 《python从入门到实践》 《Python编程快速上手 | Document Editor library
kandi X-RAY | python_practise Summary
kandi X-RAY | python_practise Summary
python_practise
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- put key - value pair
- Find the maxmum of the array .
- Find the maximum crossing of a subarray .
- Check if symbol string is balanced .
- Crop an image
- Hotpotato function
- Check if text is a phononumber
- Find the first item in list2 .
- Change image to character
- Fill the given image .
python_practise Key Features
python_practise Examples and Code Snippets
Community Discussions
Trending Discussions on python_practise
QUESTION
I have got 2 modules which tend to import each other because they will be using each other in classes. I found in this link which tells to use try/except
statement along with imports to deal with circular imports, but still I am getting KeyError
instead.
The name of module is brand.py
which contains the following code:
ANSWER
Answered 2020-Apr-07 at 08:51I have got 2 modules which tend to import each other because they will be using each other in classes
Then you have a design issue, and the proper solution is not hack around it but to solve this design issue. Having circular dependencies between modules is a big no no whatever the language, even when it's technically possible.
You have three possible solutions here, depending on the concrete case: extracting common deps to a third module, regrouping both modules in one, and using dependency injection. But by all means avoid the temptation to resort to ugly hacks that will cause various issues later on (been here, done that :-/
, now I know better).
QUESTION
ANSWER
Answered 2020-Mar-13 at 13:29I think the way you create your blueprints is not the right way (See this link for a detailed explanation).
If we refer to the way you have structured your code,
QUESTION
Good day
EDIT: What I want: From any current/voltage waveform on a Power System(PS) I want the filtered 50Hz (fundamental) RMS values magnitudes (and effectively their angles). The current as measured contains all harmonics from 100Hz to 1250Hz depending on the equipment. One cannot analyse and calculate using a wave with these harmonics your error gets so big (depending on equipment) that PS protection equipment calculates incorrect quantities. The signal attached also has MANY many other frequency components involved.
My aim: PS protection Relays are special and calculate a 20ms window in a very short time. I.m not trying to get this. I'm using external recording tech and testing what the relays see are true and they operate correctly. Thus I need to do what they do and only keep 50Hz values without any harmonic and DC.
Important expected result: Given any frequency component that MAY be in the signal I want to see the magnitude of any given harmonic (150,250 - 3rd harmonic magnitudes and 5th harmonic of the fundamental) as well as the magnitude of the DC. This will tell me what type of PS equipment possibly injects these frequencies. It is important that I provide a frequency and the answer is a vector of that frequency only with all other values filtered OUT. RMS-of-the-fundamental vs RMS differs with a factor of 4000A (50Hz only) and 4500A (with other freqs included)
This code calculates a One Cycle Fourier value (RMS) for given frequency. Sometimes called a Fourier filter I think? I use it for Power System 50Hz/0Hz/150Hz analogues analysis. (The answers have been tested and are correct fundamental RMS values. (https://users.wpi.edu/~goulet/Matlab/overlap/trigfs.html)
For a large sample the code is very slow. For 55000 data points it takes 12seconds. For 3 voltages and 3 currents this gets to be VERY slow. I look at 100s of records a day.
How do I enhance it? What Python tips and tricks/ libraries are there to append my lists/array. (Also feel free to rewrite or use the code). I use the code to pick out certain values out of a signal at given times. (which is like reading the values from a specialized program for power system analysis) Edited: with how I load the files and use them, code works with pasting it:
...ANSWER
Answered 2019-Nov-21 at 10:55As I said in my previous comment:
Your code mainly relies on a
for
loop with a lot of indexation and scalar operations. You already have importednumpy
so you should take advantage of vectorization.
This answer is a start towards your solution.
Light weight MCVEFirst we create a trial signal for the MCVE:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install python_practise
You can use python_practise like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page