首页 \ 问答 \ 按字母顺序排列集合(Sorting a collection in alphabetical order)

按字母顺序排列集合(Sorting a collection in alphabetical order)

有没有什么方法可以用来按字母顺序排列集合(使用C#2.0?)。

谢谢


Is there any way, out of the box, to sort a collection in alphabetical order (using C# 2.0 ?).

Thanks


原文:https://stackoverflow.com/questions/3494941
更新时间:2022-10-03 16:10

最满意答案

包含您实际运行的代码,得到的结果以及您的预期结果总是一个好主意。

在这里,主要的问题是你有一个语法错误。 其次,你应该使用numpy数组,而不是列表。 第三,正如文档所示(请参阅https://lmfit.github.io/lmfit-py/model.html#lmfit.model.ModelResult.evalresult.eval()params作为第一个参数,而不是自变量。 总之,你想用你的最后两行代替

x1 = np.array([1, 2, 3]) # input for prediction
a = result.eval(x=x1)   # prediction

应该按预期工作。

而且:当然,你不需要lmfit做线性回归。 )。


It is always a good idea to include the code you actually ran, the result you got, and the result you expected.

Here, the main problem is that you have a syntax error. Second, you should use numpy arrays, not lists. And third, as the docs show (see https://lmfit.github.io/lmfit-py/model.html#lmfit.model.ModelResult.eval) result.eval() would take params as the first argument, not the independent variable. In short, you want to replace your last two lines with

x1 = np.array([1, 2, 3]) # input for prediction
a = result.eval(x=x1)   # prediction

that should work as expected.

And: of course, you don't need lmfit to do a linear regression. ;).

相关问答

更多
  • 绘图方法是为X轴采用数组,为Y轴采用数组,并根据这些数组绘制一条线 。 你试图用线条的方法绘制一个点 ... 为了使您的代码能够工作(我已经测试过并且工作正常),请切换此行: plt.plot(X[0],obj.predict(7),color='black',linewidth=3) 用这一行: plt.scatter(7,obj.predict(7),color='black',linewidth=3) 散射方法将采用给定的点(7,7)并将其放入图中,就像您想要的那样。 我希望这有帮助:) The ...
  • 由于fit_func不使用self,因此将其fit_func静态方法: @staticmethod def fit_func(x, a, b): return a * x + b 这样你就不必担心self 。 Since fit_func is not using self, make it a static method: @staticmethod def fit_func(x, a, b): return a * x + b This way you don't have to w ...
  • 您的脚本可能要短得多,以说明问题。 但是,最终的参数保存在result_150.params ,依此类推。 传递给minimize()的参数在拟合中不会改变。 那么,对于lmfit版本0.9.0及更高版本来说也是如此。 也许你的同事在lmfit上有一个旧版本。 Your script could be a lot shorter to illustrate the question. But, the final Parameters are held in result_150.params and so ...
  • 我认为前一行中有一个括号问题。 这会导致返回包含在公式中。 我认为最后有一个缺失。 I think there is a parenthesis problem in the previous line. This causes the return to be included in the formula. I think there's a ) missing at the end.
  • 嗯,应该是 out = mod1.fit(spectra_beBG[:,1], pars, x=spectra_beBG[:,0]) 也就是说,你想要拟合“y”,并传入“pars”和“x”数组来帮助计算具有这些参数和自变量的模型。 Hm, should that be out = mod1.fit(spectra_beBG[:,1], pars, x=spectra_beBG[:,0]) That is, you want to fit "y", and pass in the "pars" and ...
  • 包含您实际运行的代码,得到的结果以及您的预期结果总是一个好主意。 在这里,主要的问题是你有一个语法错误。 其次,你应该使用numpy数组,而不是列表。 第三,正如文档所示(请参阅https://lmfit.github.io/lmfit-py/model.html#lmfit.model.ModelResult.eval ) result.eval()将params作为第一个参数,而不是自变量。 总之,你想用你的最后两行代替 x1 = np.array([1, 2, 3]) # input for pred ...
  • 将标记附加到表示感兴趣的子集/类别的救护车数据上(例如,“忙碌”与“非忙碌”)。 对于非正式或非参数分析,请使用relrisk工具,或者在使用split.ppp分离不同类型的点后使用split.ppp 。 对于正式分析(考虑样本大小等),您应该将几个候选模型拟合到相同的数据,一个模型具有繁忙/非繁忙效果,另一个模型没有这样的效果,然后使用anova.ppm正式测试是否有一个忙/不忙的效果。 参见上述书的第14章。 Attach marks to the ambulance data representing ...
  • 您可能尝试在函数外部打印该数据。 amp , shift , omega和decay变量在fc2min的局部范围内,因此只能在函数内部访问。 您的数据分析技能似乎远远超过您的Python专有技术,因此我在此代码中添加了一些有用的提示: import numpy as np import matplotlib.pyplot as plt from lmfit import minimize, Parameters, Parameter, report_fit # create data to be fitt ...
  • 您需要两个以上的数据点才能将双参数指数模型拟合为数据。 Lmfit模型旨在进行数据拟合。 像这样的东西可以工作: import numpy as np import lmfit xdat = np.linspace(0, 2.0, 11) ydat = 2.1 * np.exp(-xdat /0.88) + np.random.normal(size=len(xdat), scale=0.06) mod = lmfit.models.ExponentialModel() pars = mod.guess ...
  • 这只是一个绘图问题,您只需更改两行就可以看到结果相同: yValTest = VoigtConv(absPlot[:,0], result.best_values.get('A'), result.best_values.get('x0'), result.best_values.get('sigma'), result.best_values.get('gamma'),) 到(注意改变切片) yValTest = VoigtConv(absPlot[50:170, 0], result.best_va ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)