Can someone please help me get past the following issue?
I have added a new method to sympy/matrices/matrices.py to compute the
matrix dual of a given matrix. The name of the method is
dual_matrix(). I have added this method to my local copy of sympy
(test1) and have done a git add and git commit. I have also put a
test_dual_matrix function at the bottom of
sympy/matrices/tests/test_matrices.py. When I run test on the
matrices I get:
[ComerMacPro:~/sympy] comerduncan% ./bin/test
sympy/matrices/tests/test_matrices.py
============================= test process starts ==============================
executable: /usr/bin/python (2.7.1-final-0)
architecture: 64-bit
cache: yes
ground types: python
random seed: 54812667
sympy/matrices/tests/test_matrices.py[106] ...fffff.............................
....................................................................E [FAIL]
________________________________________________________________________________
____________ sympy/matrices/tests/test_matrices.py:test_dual_matrix ____________
File "/users/comerduncan/sympy/sympy/matrices/tests/test_matrices.py",
line 2221, in test_dual_matrix
assert F.dual_matrix() == Matrix(
((0,B_x,B_y,B_z),(-B_x,0,E_z,-E_y),(-B_y,-E_z,0,E_x),(-B_z,E_y,-E_x,0))
)
File "/Users/comerduncan/sympy/sympy/matrices/matrices.py", line
2953, in __getattr__
raise AttributeError("Matrix has no attribute %s." % attr)
AttributeError: Matrix has no attribute dual_matrix.
tests finished: 100 passed, 5 expected to fail, 1 exceptions, in 4.34 seconds =
DO *NOT* COMMIT!
So, how come the new function dual_matrix is not seen? Is it the case
that when ./bin/test runs sympy/matrices/tests/test_matrices.py it
loads the system sympy rather than the local, in-directory sympy tree
and thus does not see any additional function(s) added at the end of
matrices.py? I am unsure about this, so I would appreciate some ideas
on what I can//should do.
Thanks very much.
Comer
the problem is that your addition of "dual_matrix" is too far down in
the file. It is now defined as a global function to which one may pass a
matrix. However, you want it as a method of the Matrix class. You could
probably put it around line 3318, after the is_Identity method (and
similarly aligned!).
Best,
Tom
Did you understand what Tom said? A little example might help. The
following shows a class foo (like Matrix) with a method and then below
there is a function with the same name:
class foo:
def meth(self):
return str(self)+'meth'
def meth(x):
return str(x)+'func'
The method would be called like this:
f = foo()
f.meth()
whereas the function would be called like this:
meth(f)
Matrix uses both functions and methods, so you just have to decide
which makes more sense. We can help you decide if you want. (That's
one of the nice things I've found about the python community in
general: they're pretty helpful in a lot of ways.)
Best regards,
Chris
> --
> You received this message because you are subscribed to the Google
> Groups "sympy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sympy/-/eEM2f8rmMwEJ.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to
> sympy+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
On Tue, Apr 17, 2012 at 5:30 PM, Comer <comer....@gmail.com> wrote:
>
> I am having a problem with indentation in my current version of the
> dual_matrix method. I have been working on the new methods in ipython
> notebooks (ver .13 dev), which I have found to be a very productive
> environment. The newest version of the method works in the notebook.
> However, when I key it in using my default editor TextWranger in matrices.py
> and run test_matrices.py it complains about indendation. But not in the
> notebook. I said keyed in above since I am a bit leary to paste code from
> one app to another. However, apparently I still have made some indentation
> error(s). Very annoying. I am attaching the code. Can you take a look and
> give me some idea about which part of the georgraphy is inducing a stumble?
For me, Python chews rather happily the piece of code you have shown.
I have even tried dual_matrix(None) to get an error (obviously).
However, I have noticed that, at times, you use spaces for indenting,
and at times there are tabs. For example, line 21 is indented using a
tab, while line 22 is indented with spaces only; lines 25 and 26 are
indented with spaces at first and then with tabs, etc. While I don't
have any trouble getting this code to run, I distinctly remember that
mixing spaces and tabs caused me some problems in a different
language.
This guy [0] says that mixing spaces and tabs can be bad, too :-)
Sergiu
[0] http://www.cogsci.nl/blog/tutorials/136-fix-mixed-tabspace-indentation-in-python-code
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/1lGDNyilzGUJ.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
Actually, all but the most simplicistic editors have a setting for that.
It's more a question of finding and activating that setting, less a
question of the proper editor to use.
(I agree that Geany is a fine editor though.)
To unsubscribe from this group, send email to sympy+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
I have no idea, but googling gave me this:
http://wiki.geany.org/howtos/osx/running
http://packages.debian.org/search?keywords=geany claims the opposite.
(I can't verify, I'm running Ubuntu, which offers more packages than
Debian.)
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/A7RQZK_ezIwJ.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
It doesn't appear to have been pushed. The last commit is from 6 days
ago (and the cheatsheet is still missing).
/c
Ahh, you pushed to your current working branch, not the one that is in
the pull request (47b923f). So if you delete branch 47b923f (git
branch -D 47b923f) and then from your test1 branch do (git checkout -b
47b923f) it will create a clone of your test1 branch. If you then push
that (git push -f github 47b923f) it will update the pull request.
You can't delete the branch you are on :-) move to master first.
I have been keeping about half an eye on this conversation lately, so
I'm absolutely out of topic, but I'll still try.
"47b923f" looks like a commit hash rather than a branch name.
Moreover, git branch shows that you don't have a branch with this
name, so my guess is that you don't need to delete it :-)
I'm now looking at the pull request
https://github.com/sympy/sympy/pull/1229 , is this the one the
discussion is about?
Judging from what I see there, it looks like you've sent a pull
request not from a *branch*, but from a *commit*. [0] says that it's
possible:
Pull requests can be sent from any branch or commit but it’s
recommended that a topic branch be used so that follow-up commits
can be pushed to update the pull request if necessary.
As far as I understand the situation, you will *not* now be able to
update the pull request #1229.
The cleanest way out I envision is to close the pull request #1229 and
to submit a new pull request, this time from the branch test1. To
submit this new pull request, you will have to ensure that test1 on
GitHub contains all your latest changes, then select "test1" in the
little drop-down to the left of the tab "Files" and under the clone
URLs, and finally click the "Pull Request" button immediately under
you GitHub ID (top-right corner of the page).
There *may* be other solutions, my experience with GitHub is not that
extensive yet, so feel free to wait for other to react as well :-)
Sergiu
[0] http://help.github.com/send-pull-requests/
P.S. I added emphatic asterisks not to shout, but to stress key points
:-)
--
You received this message because you are subscribed to the Google Groups "sympy" group.
From what I can see https://github.com/comer/sympy/commits/master ,
Comer's master is behind SymPy's master, but it doesn't diverge. In
this case one of the proper ways to go would be to update the master
branch and then rebase test1 on top of the new master:
# Update master
git checkout master
git pull <SymPy remote name> master
# Rebase test1
git rebase -i master test1
# Update both branches on GitHub
git push <your own remote name> master test1
It should be possible to find out the exact names of <SymPy remote
name> and <your own remote name> by running git remote show.
Sergiu
P.S. I'm providing skeleton overviews; don't hesitate to ask
questions. I hope I'll have the knowledge to answer them :-)
git's pretty forgiving. You apparently made changes in the master. If
you do "git log" you can see what those changes are and then decide if
you should keep them (in which case you can just create a new branch
with "git branch my_new_branch"). If you just want to get back your
clean master then move to a different branch (like your test1 branch)
and then do "git checkout -b master --track origin/master".
If you don't want to see the whole commit message when you look at
commits, try "git log --oneline" which will give you a one line view.
Others may have better suggestions...but that's how I do it.
/c
That last message shouldn't have come twice. I'm not sure what's going
on, from a really messed-up commit history to a copy&paste mistake,
everything is possible.
> I got an editor window which I saved and then exited from the editor
> (TextWrangler).
Sounds like you tried a git commit somewhere.
git should also have listed those files that have a conflict. You can
get that list anytime by issuing git status.
(BTW git branch will tell you you're not on any branch while a rebase is
in progress, that's normal.)
> I do not know the value of<paths> so can not do the git
> add<paths> step.
That's the filename, with enough directory name components to identify
it from the current directory.
As a side remark, this means that the branch master in your repository
does not diverge from the master in SymPy, as opposed to what we
suspected.
> [homelap-3:~/sympy] comerduncan% git branch
> * master
> test1
> [homelap-3:~/sympy] comerduncan% git rebase -i master test1
> error: could not apply d5da8bd... fixed indention problems with matrices.py
> and content problems with test_matrices.py both having to do with addition
> of dual_matrix method
> hint: after resolving the conflicts, mark the corrected paths
> hint: with 'git add <paths>' and run 'git rebase --continue'
> Could not apply d5da8bd... fixed indention problems with matrices.py and
> content problems with test_matrices.py both having to do with addition of
> dual_matrix method
>
> I got an editor window which I saved and then exited from the editor
> (TextWrangler). I do not know the value of <paths> so can not do the git
> add <paths> step.
All of this is normal. Rebasing is an operation which basically takes
all your new commits in test1 and tries to put them on top of the new
master. The result is stored in test1 only, the master stays the
same.
When git tried to put the commit "d5da8bd... fixed indention problems
with matrices.py" on top of master, it encountered a merge conflict.
[0] may provide you some additional information. Presently, the
rebase process is in a hiatus. You cannot use the repository for
anything else but for continuing your rebase now. *Should* you want
to abort rebasing and return to the state of affairs as it were at the
beginning, do
git rebase --abort
Now, to see where in which files exactly the merge conflict occurred,
run
git status
You should then edit the corresponding files to resolve the merge
conflicts. When you have resolved them, do
git add <file1> <file2> ... <file n>
where <file i> are the names of files you have edited to resolve the
conflict.
After that, to continue rebasing, do
git rebase --continue
Git will show you an editor in which you will be able to edit the old
commit message, if you want. It will then try to go on rebasing the
other commits in your branch. Shall you encounter merge conflicts
again, the procedure will be exactly the same.
Sergiu
[0] http://schacon.github.com/git/user-manual.html#resolving-a-merge
Indeed, that message shouldn't have appeared twice.
I'm not a Git expert, but I did mess things up seriously a couple
times. My humble experience tells me that in such situations Git
would react much more nervously that just repeating a message. So, I
have three possible interpretations:
* copy-and-paste mistake, disregardable,
* Git works slightly differently on Comer's laptop, disregardable,
* Git itself is severely broken, which seems unlikely, judging by the
output we have been shown.
Neither of these provides an explanation, but they help me rest
relatively calm :-)
>> I got an editor window which I saved and then exited from the editor
>> (TextWrangler).
>
>
> Sounds like you tried a git commit somewhere.
No, the editor window appeared because I specified the -i option to
git-rebase, which triggered the interactive mode and made Git ask for
an explicit list of commits, which Comer has accepted.
> git should also have listed those files that have a conflict. You can get
> that list anytime by issuing git status.
From what I remember, Git doesn't show that list for me when reporting
a conflict; I can only see the list of files with conflict in git
status.
Sergiu
This works as long as nobody has changed the files since you worked on
them, otherwise you end up having to sort out the changes. It's better
if you can just copy the functions that were changed. BUT...
I really don't think this is necessary. Regardless of how the branch
got named, github thinks the name of the branch that got pushed is
47b923f . Let it think so. Just go to your test1 branch and make a
copy named 47b923f and push it to github:
git checkout test1
git checkout -b 47b923f
git push -f comer 47b923f
I squashed all your commits into one and can confirm that they rebase
on master without problem and contain only changes to 4 files. I'll
push that squashed branch and make a few comments there so you can see
them (https://github.com/sympy/sympy/pull/1253 ).
> 2. get a clean clone of sympy from github and put it in a new directory away
> from the diseased tree.
I don't think you have a problem (based on my clone of your repo).
Make sure, however, that your prompt is set to show you exactly where
you are, e.g. here's what mine looks like:
chriss@CHRIS-LT ~/sympy (test1)
$ git checkout head~1
Note: checking out 'head~1'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 3215b20... Add Angadh Nanjangud to AUTHORS/aboutus. Welcome to Sy
mPy!
chriss@CHRIS-LT ~/sympy ((3215b20...))
Notice how the SHA1 is shown rather than the branch name...this is
what tells me that I am not at the branch head.
> 6. close the #1229 pull request.
If what I suggested above works, this won't be necessary.
>
> 8. apologise for wasting people's time
>
You learn and we all learn how to help people. It's a win-win. No problem :-)