使用InterX函数转换为python时发生模块错误 [英] module Error using InterX function translated to python

查看:133
本文介绍了使用InterX函数转换为python时发生模块错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用函数InterX来查找两条曲线的交点,但是我总是遇到相同的错误TypeError:模块"对象不可调用.无论我将哪种数据引入函数中.

I am trying to use the function InterX which finds the intersection of two curves, but I am having always the same error TypeError: 'module' object is not callable. No matter the kind of data I introduce into the function.

可以在 https://github.com/kelseynlucas/InterX.git

在功能描述中,作者说: InterX曲线的交点

In the description of the function the author says: InterX Intersection of curves

输入: -L1x-曲线1的x值的熊猫数据框 -L1y-曲线1的y值的Pandas数据框 可选输入: -L2x-曲线2的x值的熊猫数据框 -L2y-曲线2的y值的Pandas数据框 因此,我为名为"Line"的直线的x和y值创建了一个数据框,并为名为"Curve"的曲线创建了一个数据框,并使用了该函数.

Input: -L1x - Pandas dataframe of x-values for curve 1 -L1y - Pandas dataframe of y-values for curve 1 Optional input: -L2x - Pandas dataframe of x-values for curve 2 -L2y - Pandas dataframe of y-values for curve 2 So I have created a dataframe for the x and y values of the straight line called "Line" and another for the curve called "Curve" and used the function.

但是,即使我将DataFrame或数组或数据手动引入函数中,我也始终会遇到相同的错误.

However even if I introduce the DataFrame, or the arrays or the data manually to the function I always having the same error.

import numpy as np
import pandas as pd
import InterX

x_t = np.linspace(0, 10, 10, True)
z_t = np.array((0, 0, 0, 0, 0, 0, 0.055, 0.41, 1.23, 4))
X_P = np.array((2,4))
Z_P = np.array((3,-1))

Line = pd.DataFrame(np.array((X_P,Z_P)))
Curve = pd.DataFrame(np.array([x_t,z_t]))
Curve = Curve.T
P = InterX(Line[0],Line[1],Curve[0],Curve[1])

我希望输出P = [3.5,0].但是我总是遇到相同的错误:

I expect the ouput P = [3.5 , 0]. However I am having always the same error:

第22行,在 P = InterX(x_t,z_t,X_P,Z_P)

line 22, in P = InterX(x_t,z_t,X_P,Z_P)

TypeError:模块"对象不可调用

TypeError: 'module' object is not callable

推荐答案

不幸的是,模块名称和内部函数具有相同的名称,当您编写P = InterX(...时,您调用的是模块,而不是其中的函数,这导致错误.

Unfortunately, the module name and the function inside have the same name and when you write P = InterX(... you call the module, not the function in it, which leads to the error.

使用:

from InterX import InterX
...
P = InterX(Line[0],Line[1],Curve[0],Curve[1])

import InterX
...
P = InterX.InterX(Line[0],Line[1],Curve[0],Curve[1])

import InterX as interX
...
P = interX.InterX(Line[0],Line[1],Curve[0],Curve[1])

这篇关于使用InterX函数转换为python时发生模块错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆