我正在使用git分支并准备提交我的更改,因此我使用有用的提交消息进行了提交.然后我心不在焉地对不值得保留的代码做了一些小改动.我现在想改变分支,但是git给了我,
错误:您对"X"进行了本地更改; 不能切换分支.
我以为我可以在不提交的情况下改变分支.如果是这样,我该怎么设置呢?如果没有,我该如何摆脱这个问题?我想忽略这些微小的变化而不提交,只是改变分支.
我猜他们必须参考struts和spring模型,但我找不到它们.当你NSLog
约束他们有时表现为无证类的描述字符串NSAutoresizingMaskLayoutConstraint
.我已经注意到了至少3种不同类型:h=---
,h=--&
,h=-&-
具有水平和垂直版本.
调试受约束的布局时,它们会出现很多变化.
我制作了以下示例应用来说明我的问题.
左视图是占位符视图(在Interface Builder中添加).当App加载时,我添加了一个由NSViewController管理的子视图.NSViewController绘制不同颜色的矩形,每个矩形都是NSView,这些彩色视图的布局由编程创建的约束管理并添加到-loadView
控制器的方法中.
右视图是NSTableView(在Interface Builder中添加).当App加载时,我使用相同的NSViewController类为表视图提供视图(仅添加一行).
当我添加子视图的占位符视图时,我还添加了两个附加约束,
[_placeholderView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[CTRL_VIEW]|" options:0 metrics:nil views:views]];
[_placeholderView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[CTRL_VIEW]|" options:0 metrics:nil views:views]];
Run Code Online (Sandbox Code Playgroud)
这些约束将子视图的框架设置为等于超视图的边界.一切都很好.
但是,当我使用委托方法提供NSTableView -tableView:viewForTableColumn:row:
的视图时,视图尚未添加到表中.因此它没有superview,因此不能(还)将约束添加到视图中.这就是表视图中的视图与表视图单元格的边界不同的原因.
所以我的问题是如何在我提供给表视图的视图中添加约束?在表视图添加后,我可以再次访问该视图吗?这似乎有点黑客攻击.
AppDelegate.h的源代码,
#import <Cocoa/Cocoa.h>
@class BlahViewController;
@interface AppDelegate : NSObject <NSApplicationDelegate, NSTableViewDataSource, NSTableViewDelegate>
@property (assign) IBOutlet NSWindow *window;
/* Left view controller and place holding view */
@property (strong) BlahViewController *viewController;
@property (weak) IBOutlet NSView *placeholderView;
/* Right view (which is an NSTableView) */
@property (weak) IBOutlet NSTableView *tableView;
@end
Run Code Online (Sandbox Code Playgroud)
和AppDelegate.m,
#import "AppDelegate.h"
#import "BlahViewController.h"
@interface …
Run Code Online (Sandbox Code Playgroud) 所有matplotlib 例子与hist()
生成数据集,将数据提供设置为hist
与一些二进制位函数(可能非均匀间隔的)和函数自动计算,然后绘制柱状图.
我已经有直方图数据,我只是想绘制它,我该怎么做?!例如,我有箱子(半开放范围用方括号和弯曲括号表示),
[0, 1) 0
[1, 2) 3
[2, 3) 8
[3, 4) 6
[4, 5) 2
[5, 6) 3
[6, 7) 1
[7, 8) 0
Run Code Online (Sandbox Code Playgroud) 问候,我正在学习Cocoa和Objective-C.我已经完成了"全部"教程,我对ObjC语言非常熟悉.我现在正在寻找的是学习Cocoa习语,并看到在漂亮的Cocoa应用程序中使用的真实代码.
似乎严肃的应用程序(iTunes等)不仅仅是放入IB元素.他们通过代码做了很多事情来调整它们看起来不错.(示例:iTunes播放列表抽屉.如何获得该样式?)
以下是我发现的开源友好UI的一些示例:
有关具有优秀Cocoa用户界面的开源应用程序的任何其他建议?
在OS X 10.10源列表中似乎使用了光亮的外观.在Finder(以及其他一些第三方应用程序,例如Things.app)中,源列表中的所选项目由暗色振动外观指示.例如,请参见下图中的"桌面"行.
我该如何复制这种行为?我是否需要使用委托方法来指定表行视图,
-outlineView:rowViewForItem:
Run Code Online (Sandbox Code Playgroud)
并尝试自己定制绘图或是否有更直接的方法?如果您在Xcode标准源列表界面默认的高亮是保持我们在以前版本的OS X已经看到了标准的蓝色矩形
是否可以通过双击列标题来更改NSTableView列的名称?有关最佳方法的任何建议.
我在尝试:
editWithFrame:inView:editor:delegate:event:
.我不完全确定为什么这会扭曲文本,但是当你双击标题时它会使文本看起来像这样,没有字段编辑器出现,
在AppDelegate中
-(void)awakeFromNib
{
...
[_tableView setDoubleAction:@selector(doubleClickInTableView:)];
...
}
-(void) doubleClickInTableView:(id)sender
{
NSInteger row = [_tableView clickedRow];
NSInteger column = [_tableView clickedColumn];
if(row == -1){
/* Want to edit the column header on double-click */
NSTableColumn *tableColumn = [[_tableView tableColumns] objectAtIndex:column];
NSTableHeaderView *headerView = [_tableView headerView];
NSTableHeaderCell *headerCell = [tableColumn headerCell];
NSRect cellFrame = [headerView headerRectOfColumn:column];
NSText * fieldEditor = [[headerView window] fieldEditor:YES forObject:nil];
[headerCell editWithFrame:cellFrame inView:headerView editor:fieldEditor delegate:headerCell event:nil];
}
}
Run Code Online (Sandbox Code Playgroud) 在圣人中,对未知函数f(x)进行泰勒展开是相当容易的,
x = var('x')
h = var('h')
f = function('f',x)
g1 = taylor(f,x,h,2)
Run Code Online (Sandbox Code Playgroud)
如何在同情中做到这一点?
更新
asmeurer指出,这是一个很快就可以通过拉动请求http://github.com/sympy/sympy/pull/1888获得的功能.我用pip安装了分支,
pip install -e git+git@github.com:renatocoutinho/sympy.git@897b#egg=sympy --upgrade
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试计算f(x)的系列时,
x, h = symbols("x,h")
f = Function("f")
series(f,x,x+h)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误,
TypeError:必须使用f实例作为第一个参数调用未绑定方法series()(改为使用Symbol实例)
我认为下面的例子是一个非常常见的用例:
改变@pytest.fixture(scope="module")
原因的范围ScopeMismatch: You tried to access the 'function' scoped fixture 'event_loop' with a 'module' scoped request object, involved factories
。
此外,test_insert
和test_find
协程不需要 event_loop 参数,因为可以通过传递连接来访问循环。
任何想法如何解决这两个问题?
import pytest
@pytest.fixture(scope="function") # <-- want this to be scope="module"; run once!
@pytest.mark.asyncio
async def connection(event_loop):
""" Expensive function; want to do in the module scope. Only this function needs `event_loop`!
"""
conn await = make_connection(event_loop)
return conn
@pytest.mark.dependency()
@pytest.mark.asyncio
async def test_insert(connection, event_loop): …
Run Code Online (Sandbox Code Playgroud) cocoa ×5
python ×3
autolayout ×2
nstableview ×2
branch ×1
cython ×1
git ×1
git-checkout ×1
histogram ×1
macos ×1
matplotlib ×1
objective-c ×1
osx-yosemite ×1
pdb ×1
pytest ×1
sympy ×1