小编dan*_*rba的帖子

如何在固定位置,matplotlib上设置刻度

任何人都可以帮我用matplotlib设置固定位置的刻度线吗?我尝试过使用FixedPosition,因为本教程描述了:

ax = pl.gca()
ax.xaxis.set_major_locator(eval(locator))
Run Code Online (Sandbox Code Playgroud)

http://scipy-lectures.github.io/intro/matplotlib/matplotlib.html#figures-subplots-axes-and-ticks

但是当我尝试运行时,它告诉我set_major_locator方法不存在.

一个简单的例子非常有用.

谢谢.

python matplotlib

27
推荐指数
2
解决办法
6万
查看次数

私有方法上的@Transactional 传播

我有以下代码:

@Service
public class MyService implements IMyService {
    @Inject
    IAnotherService anotherService;
    // injects go here
    // some code
    @Transactional(isolation=Isolation.SERIALIZABLE)
    public Result myMethod() {
        // stuff done here
        return this.myPrivateMethod()
    } 

    private Result myPrivateMethod() {
         // stuff done here
         // multiple DAO SAVE of anObject
         anotherService.processSomething(anObject);
         return result; 
    }
}

@Service
public class AnotherService implements IAnotherService {
      // injections here
      // other stuff

      @Transactional(isolation=SERIALIZABLE)
      public Result processSomething(Object anObject) {
         // some code here
         // multiple dao save
         // manipulation of anObject …
Run Code Online (Sandbox Code Playgroud)

java spring transactions isolation

7
推荐指数
1
解决办法
4754
查看次数

从传递依赖导入类

我有以下依赖项:A、B 和 X。“->”表示依赖。

A -> B
X -> A
Run Code Online (Sandbox Code Playgroud)

B 有以下公共类:

public class PublicClassB {
     public static void do() {
     }
}
Run Code Online (Sandbox Code Playgroud)

PublicClassB由 X 和 AE 使用

A 类的 pom 如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>my.company.name</groupId>
    <artifactId>A</artifactId>
    <version>1.0.0</version>
    <dependencies>
          <dependency>
              <groupId>my.company.name</groupId>
              <artifactId>B</artifactId>
              <version>1.0.0</version>
          </dependency>
    </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)

X 的 pom 如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>my.company.name</groupId>
    <artifactId>X</artifactId>
    <version>1.0.0</version>
    <dependencies>
          <dependency>
              <groupId>my.company.name</groupId>
              <artifactId>A</artifactId>
              <version>1.0.0</version>
          </dependency>
    </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)

有没有办法从 X访问PublicClassB#do() ?我无法进行导入,Eclipse 没有检测到 B 上的包。

java dependencies pom.xml maven

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

Hibernate/Spring - 在事务中回滚事务

鉴于此示例代码:

public class MyServiceImpl implements MyService {
    @Transactional
    public void myTransactionalMethod() {
        List<Item> itemList = itemService.findItems();
        for (Item anItem : itemList) {
            try {
                processItem(anItem);
            catch (Exception e) {
                // dont rollback here 
                // rollback just one item
            }     
        }

    }

    @Transactional
    public void processItem(Item anItem) { 
        anItem.setSomething(new Something);
        anItem.applyBehaviour();
        itemService.save(anItem);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我想要实现的目标:

  1. 只有processItem(anItem);在其中发生异常时才应回滚.
  2. 如果发生异常,myTransactionalMethod应该继续,这意味着for-each应该结束.
  3. 如果异常发生在内部myTransactionalMethod但不在内processItem(anItem),myTransactionalMethod则应完全回滚.

是否存在不涉及手动管理事务(没有注释)的解决方案?

编辑:我正在考虑使用@Transactional(PROPAGATION=REQUIRES_NEW),不知道它是否会在同一个bean中工作.

java spring hibernate transactional

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

如何将字符串过滤到Python上的列表

我想过滤一个这样的字符串:'Hello%World'----> List = ['Hello','World']有没有内置函数?

python string list

0
推荐指数
1
解决办法
330
查看次数

PyGame,Surface没有显示

我试图在pygame屏幕上创建一个透明的表面,遗憾的是无法正常工作.主表面显示确定,但我试图生成的表面根本没有显示.

import pygame as pg
from pygame.locals import *

pg.display.init()
h = 640
w = 480
_display = pg.display.set_mode((h,w))
_display.fill(pg.Color(0,0,0))

_active_surface = pg.Surface((h,w))
#_active_surface.set_colorkey((255,0,255))
_active_surface.fill(pg.Color(255,0,255))
_display.blit(_active_surface, (h,w))

while True:
    for i in pg.event.get():
        if i.type == QUIT:
            pg.quit()
    pg.display.flip()  
Run Code Online (Sandbox Code Playgroud)

python pygame

0
推荐指数
1
解决办法
294
查看次数

基于与值的差异在python中排序列表

任何人都知道如何使用值作为参考对列表进行排序?例如,我有以下列表:

1,3,5,10,12
Run Code Online (Sandbox Code Playgroud)

和单个值7,输出将是:

5,10,3,12,1
Run Code Online (Sandbox Code Playgroud)

谢谢!

python sorting list

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