Roffild's library - page 10

 
Advanced Vector Extensions - Wikipedia
  • en.wikipedia.org
AVX2 expands most integer commands to 256 bits and introduces fused multiply-accumulate (FMA) operations. AVX-512 expands AVX to 512-bit support using a new EVEX prefix encoding proposed by Intel in July 2013 and first supported by Intel with the Knights Landing processor, which shipped in 2016.[3][4] AVX uses sixteen YMM registers. Each YMM...
 
Roffild:

The message"Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2" appears on newer CPUs as well. This is a known bug in TensorFlow. It has nothing to do with the Python version.

There is another message like "...not load dll..." from Python


That's true... i have i3 and GForce video, if i'm not mistaken the laptop is 3-4 years old, even the toys fly well, but with AVE just found out

 

@Roffild, good afternoon.

Installed your library and immediately caught the error of the very first check:

2019.07.09 21:56:43.540 PythonDLL_Example (USDRUB,D1)   ERROR: PythonHome == ""

The variables are all in place too.


What else did I forget to do?

Thanks.

 
 

Yes, I've got it figured out.

Sorry about the stupidity.

 

Good afternoon.

Started the first steps on using your library. As an example took PythonDLL_Example.mq5 and PythonDLL_Example.py. Just decided to test the call-result. Took, made an array of 11 numbers and passed it to the function. So far the function in PythonDLL_Example.py looked like:

    def getDouble(self, magic: int, value: float, array: tuple) -> tuple or list:
        x = array[2] + array[1]
        return [x]

(my first change ))) )Everything worked as it should. Due to the fact that I have started to write when the exchange is closed, to test the function I have moved the call to int OnInit() No problem, it works when EA is running.

Next, began simply adding imported libraries in the file PythonDLL_Example.py

The file began to look like this:

# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# https://github.com/Roffild/RoffildLibrary
# ==============================================================================

import pandas as pd

import numpy as np

import tensorflow as tf
from tensorflow import keras

import sys
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

class PythonDLL_Example():
    def getLong(self, magic: int, value: int, array: tuple) -> tuple or list:
        raise NotImplementedError

    def getULong(self, magic: int, value: int, array: tuple) -> tuple or list:
        raise NotImplementedError

    def getDouble(self, magic: int, value: float, array: tuple) -> tuple or list:
        x = array[2] + array[1]
        return [x]

    def getString(self, magic: int, value: str, array: bytes) -> str:
        if magic == 1:
            return value + str(sys.version)
        if magic == 2:
            return str(array) + " " + str(sys.version_info)
        if magic == 3:
            return "sys.path:\n" + "\n".join(sys.path) + \
                   "os.environ[\"PATH\"]:\n" + os.environ["PATH"].replace(";", "\n")
        raise Exception("This is not a bug! This is a feature :D")


__mql__ = PythonDLL_Example()

The following started to happen:

1. I hang the EA, the result is correct. The output below.


Correct! Result is 251920 - this is correct!

2. I withdraw the Expert Advisor and re-attach it. The output is shown below:



On the third or fourth time, the Expert Advisor crashes.

What is the problem and how can it be solved? What do I have to do?

Thank you

 
  • Calling pyFinalize() to free memory makes sense, but because of a bug in the popular NumPy library, you shouldn't do it. issue8097,issue34309

Crashes are inevitable when using popular libraries. Crashes happen precisely at the moment of finishing and starting a new one, not during code execution. It's easier to restart the terminal for a new code execution. The tester may hang up if you kill the terminal before completion.

Crashdumps can accumulate inc:\Users\ \AppData\Local\CrashDumps

The problem is with Python itself, or rather the lack of a mechanism to notify external libraries of completion.

Crash when importing numpy from the Python C-API after calling Py_Finilize() · Issue #8097 · numpy/numpy
Crash when importing numpy from the Python C-API after calling Py_Finilize() · Issue #8097 · numpy/numpy
  • numpy
  • github.com
New issue Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Already on GitHub? Sign in to your account
 

OK, thank you very much.

I will work with what I have.

 

I'm crying bloody tears!

One line at a time trying to write function code.

What happened:

    def getDouble(self, magic: int, value: float, array: tuple) -> tuple or list:
        x = array[2] + array[1]
        return [x]

The value of x is returned correctly! Result is 251920

What was added:

    def getDouble(self, magic: int, value: float, array: tuple) -> tuple or list:
        x = array[2] + array[1]
        df = pd.read_csv("RTSSplice.csv", usecols=['Low', 'Open', 'Close', 'High', 'Volume', 'Indicator1', 'Indicator2', 'Indicator3', 'Indicator4', 'Indicator5', 'Indicator6', 'Indicator7'], encoding='utf-16')
        return [x]

The value of x returns incorrectly! Result is 3.211426697968103e-322

Tried adding-removing a string several times! I just read the file with the added string! It does not affect the calculation of x in any way! The pandas library is imported.

Why is the system behaving like this? Where to look for the problem?

Thank you! )

 
You can debug code in PyCharm as well. You can also place print() in problematic places - it's the easiest way to control variable values. The console can be activated.