小编Zyg*_*lis的帖子

找出矩阵是否肯定与numpy

我需要找出矩阵是否是正定的.我的矩阵是numpy矩阵.我期待在numpy库中找到任何相关的方法,但没有成功.我感谢任何帮助.

python numpy matrix scipy

49
推荐指数
5
解决办法
3万
查看次数

Flask-restful:将复杂对象编组为json

我有一个关于烧瓶宁静延伸的问题.我刚开始使用它并面临一个问题.我有flask-sqlalchemy连接多对一关系的实体,我希望restful端点返回父实体及其所有子节点json使用marshaller.在我的情况下,Set包含许多参数.我查看了烧瓶文件,但没有任何解释如何解决这个案例.

似乎我错过了一些明显的东西,但无法找出任何解决方案.这是我的代码:

# entities
class Set(db.Model):
    id = db.Column("id", db.Integer, db.Sequence("set_id_seq"), primary_key=True)
    title = db.Column("title", db.String(256))

    parameters = db.relationship("Parameters", backref="set", cascade="all")


class Parameters(db.Model):
    id = db.Column("id", db.Integer, db.Sequence("parameter_id_seq"), primary_key=True)
    flag = db.Column("flag", db.String(256))
    value = db.Column("value", db.String(256))
    set_id = db.Column("set_id", db.Integer, db.ForeignKey("set.id"))


# marshallers

from flask.ext.restful import fields

parameter_marshaller = {
    "flag": fields.String,
    "value": fields.String
}

set_marshaller = {
    'id': fields.String,
    'title': fields.String,
    'parameters': fields.List(fields.Nested(parameter_marshaller))
}

# endpoint    

class SetApi(Resource):

    @marshal_with(marshallers.set_marshaller)
    def get(self, set_id): …
Run Code Online (Sandbox Code Playgroud)

python rest json flask flask-restful

14
推荐指数
2
解决办法
1万
查看次数

如何使用ScalaTest覆盖Playframework单元测试中的guice模块

我想在PlayFramework中为我的控制器编写功能测试.为此,我想模拟一些类的实现.

我在这里找到了如何使用spec2做到这一点的很好的例子:http://www.innovaedge.com/2015/07/01/how-to-use-mocks-in-injected-objects-with-guiceplayscala/

但我正在使用带有OneAppPerSuite使用FakeApplication的特性的scala测试.以下是文档:https: //www.playframework.com/documentation/2.4.x/ScalaFunctionalTestingWithScalaTest

问题是我无法找到一种方法来拦截GuiceApplicationBuilder和覆盖一些模拟实现的绑定.

以下是FakeApplication实施play.api.test:

case class FakeApplication(
  override val path: java.io.File = new java.io.File("."),
  override val classloader: ClassLoader = classOf[FakeApplication].getClassLoader,
  additionalPlugins: Seq[String] = Nil,
  withoutPlugins: Seq[String] = Nil,
  additionalConfiguration: Map[String, _ <: Any] = Map.empty,
  withGlobal: Option[play.api.GlobalSettings] = None,
  withRoutes: PartialFunction[(String, String), Handler] = PartialFunction.empty) extends Application {

private val app: Application = new GuiceApplicationBuilder()
  .in(Environment(path, classloader, Mode.Test))
  .global(withGlobal.orNull)
  .configure(additionalConfiguration)
  .bindings(
    bind[FakePluginsConfig] to FakePluginsConfig(additionalPlugins, withoutPlugins), …
Run Code Online (Sandbox Code Playgroud)

unit-testing scala guice scalatest playframework

13
推荐指数
1
解决办法
976
查看次数

Scala使用guice上下文播放应用程序集成测试

我是新玩框架,对scala的经验有限.使用play framework 2.4我正在尝试编写完整的集成测试,我想调用控制器,并使用内存中的数据库从中检索数据.我正在和我scalatest-plus一起使用scalatest.我已经阅读了游戏文档中的游戏单元测试,现在尝试使用,play.api.test.FakeApplication但我找不到将这个假应用程序注入我的guice模块的方法.我正在使用OneAppPerSuite特征,我可以覆盖FakeApplication但不能通过任何guice注射模块.以下是FakeApplication来源:

case class FakeApplication(
  override val path: java.io.File = new java.io.File("."),
  override val classloader: ClassLoader = classOf[FakeApplication].getClassLoader,
  additionalPlugins: Seq[String] = Nil,
  withoutPlugins: Seq[String] = Nil,
  additionalConfiguration: Map[String, _ <: Any] = Map.empty,
  withGlobal: Option[play.api.GlobalSettings] = None,
  withRoutes: PartialFunction[(String, String), Handler] = PartialFunction.empty) extends Application {

private val app: Application = new GuiceApplicationBuilder()
  .in(Environment(path, classloader, Mode.Test))
  .global(withGlobal.orNull)
  .configure(additionalConfiguration)
  .bindings(
    bind[FakePluginsConfig] to FakePluginsConfig(additionalPlugins, withoutPlugins), …
Run Code Online (Sandbox Code Playgroud)

integration-testing scala guice playframework playframework-2.0

6
推荐指数
1
解决办法
2537
查看次数

用于多个源特定消息的Camel模式聚合并重定向到目标

我有一个问题,并且不知道如何使用驼峰来解决它.我在骆驼文档中搜索了相关的EIP,但没有结果.

现在我有简单的路线:

<route id="routeId">
    <from uri="Source1"/>
    <from uri="Source2"/>
    <to   uri="Destination"/>
</route>
Run Code Online (Sandbox Code Playgroud)

两个源都将JMS消息发送到Destination,并且在Source完成其作业时,它会发送特定的结束消息,并带有一些标志.我需要做的是收集或计算这些结束消息,并在收到来自两个来源的最终消息时将单端消息发送到目的地.只有当我收到两个结束消息时(想象它只是简单的消息带有一些标题标志)然后我应该将单个消息发送到目的地.

对不起,如果问题解释不够清楚.

提前致谢.

java apache-camel eip

4
推荐指数
2
解决办法
3650
查看次数

jaxb2 maven插件,在单独的标签中定义多个模式文件

我正在使用 Maven jaxb2 插件从 xsd 文件生成 Java 类。最近我遇到了问题,我的模式文件列表变得非常长,我将它们全部写在shemaFiles标签中作为逗号分隔值,并且该行本身很长,我担心将来它会影响代码的可读性并成为错误原因。那么有没有什么解决方案可以将文件写入单独的标签中,例如:

<schemaFilesList>
  <schemaFile>SharedResources/xsd/Common.xsd</schemaFile>
  <schemaFile>SharedResources/xsd/Another.xsd</schemaFile>
          .... 
 </schemaFilesList>
Run Code Online (Sandbox Code Playgroud)

这是我现在的代码:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>jaxb2-maven-plugin</artifactId>
  <executions>
    <execution>
      <goals>
        <goal>xjc</goal>
      </goals>
      <configuration>
        <extension>true</extension>
        <schemaDirectory>target/xsd</schemaDirectory>
        <!-- I have really long list of files here, in different directories-->
        <schemaFiles>
           SharedResources/xsd/Common.xsd,SharedResources/xsd/Messaging/EmailService.xsd, .....
        </schemaFiles>
      </configuration>
    </execution>
  </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

提前致谢。

java xsd jaxb2 maven-plugin maven-jaxb2-plugin

3
推荐指数
1
解决办法
8206
查看次数