type object 'Animation' has no attribute 'mobject' - manim

I exercise examples here
From SuccessionExample1 on, as long as there exists:
Succession(Animation, Mobject(),...
There will be error like below:
AttributeError: type object 'Animation' has no attribute 'mobject'
I checked the animation.py and found self.mobject = mobject, that is, the Animation class has mobject attribute, are those samples obselete? or other causes?

This is because that is the code for old versions (I use the February 3 version in my tutorials), I forgot to tell you in your previous question to render only the Update functions, not those of Successions. To use the Successions, the code format must be changed, this is the code for the recent version.
In case of SuccessionExample1:
class SuccessionExample1(Scene):
def construct(self):
number_line=NumberLine(x_min=-2,x_max=2)
text=TextMobject("Text")\
.next_to(number_line,DOWN)
dashed_line=DashedLine(
number_line.get_left(),
number_line.get_right(),
color=YELLOW,
).set_stroke(width=11)
self.add(number_line)
self.wait(0.3)
self.play(
LaggedStart(
*[ShowCreationThenDestruction(dashed_segment)
for dashed_segment in dashed_line],
run_time=5
),
AnimationGroup(
Animation(Mobject(),run_time=2.1),
Write(text),lag_ratio=1
)
)
self.wait()

Related

Inconsistent results using dot notation in Firestore (setData vs updateData)

UPDATE
I was experiencing inconsistencies with Firestore's dot notation and have learned that we must use literal notation when using the setData operation and can use dot notation when using the updateData operation.
The following operation was ignoring dot notation:
...setData(
["someMap.\(someId)": FieldValue.increment(Int64(-1))]
, forDocument: Firestore.firestore().collection("someDocument").document(userId), merge: true)
someMap: ["x34JF2ko0sPLnbfoijw": 1] // not decremented
someMap.x34JF2ko0sPLnbfoijw: -1 // instead, new number field created
To remedy the problem, we must simply use literal notation:
...setData(
["someMap": [someId: FieldValue.increment(Int64(-1))]
, forDocument: Firestore.firestore().collection("someDocument").document(userId), merge: true)
Nothing has changed with dot notation, but it apparently doesn't work with setValue(). As far as I can see, it's only documented to work with updateData() - you can see examples in that link to the documentation.
So, what you will have to do if you want to update that nested field is something like this:
transaction.setData(
[ "interactionCounts.\(eventId)": FieldValue.increment(Int64(-1)) ],
forDocument: Firestore.firestore().collection("trackers").document(userId)
)
I don't do swift programming, but I confirmed that similar code operates correctly for nodejs update() vs. set() with merge.
If you are absolutely certain that this worked with setData() in the past, I recommend you file an issue with the iOS SDK.

Lua - table won't insert from function

I have a Lua function where I build a table of value and attempt to add it to a global table with a named key.
The key name is pulled from the function arguments. Basically, it's a filename, and I'm pairing it up with data about the file.
Unfortunately, the global table always comes back nil. Here's my code: (let me know if you need to see more)
(Commented parts are other attempts, although many attempts have been deleted already)
Animator = Class{}
function Animator:init(atlasfile, stringatlasfriendlyname, totalanimationstates, numberofframesperstate, booleanstatictilesize)
-- Define the Animator's operation mode. Either static tile size or variable.
if booleanstatictilesize ~= false then
self.isTileSizeStatic = true
else
self.isTileSizeStatic = false
end
-- Define the total animation states (walking left, walking right, up down, etc.)
-- And then the total frames per state.
self.numAnimationStates = totalanimationstates or 1
self.numAnimationFrames = numberofframesperstate or 2
-- Assign the actual atlas file and give it a programmer-friendly name.
self.atlasname = stringatlasfriendlyname or removeFileExtension(atlasfile, 'animation')
generateAnimationQuads(atlasfile, self.atlasname, self.numAnimationStates, self.numAnimationFrames)
end
function generateAnimationQuads(atlasfile, atlasfriendlyname, states, frames)
spriteWidthDivider = atlasfile:getWidth() / frames
spriteHeightDivider = atlasfile:getHeight() / states
animationQuadArray = generateQuads(atlasfile, spriteWidthDivider, spriteHeightDivider)
animationSetValues = {atlasarray = animationQuadArray, width = spriteWidthDivider, height = spriteHeightDivider}
--gAnimationSets[#gAnimationSets+1] = atlasfriendlyname
gAnimationSets[atlasfriendlyname] = animationSetValues
--table.insert(gAnimationSets, atlasfriendlyname)
end
Note: when using print(atlasfriendlyname) and print(animationSetValues), neither are empty or nil. They both contain values.
For some reason, the line(s) that assign the key pair to gAnimationSets does not work.
gAnimationSets is defined a single time at the top of the program in main.lua, using
gAnimationSets = {}
Animator class is called during the init() function of a character class called Bug. And the Bug class is initialized in the init() function of StartState, which extends from BaseState, which simply defines dummy init(), enter(), update() etc. functions.
StartState is invoked in main.lua using the StateMachine class, where it is passed into StateMachine as a value of a global table declared in main.lua.
gAnimationSets is declared after the table of states and before invoking the state.
This is using the Love2D engine.
Sorry that I came here for help, I've been picking away at this for hours.
Edit: more testing.
Trying to print the animationQuadArray at the index gTextures['buganimation'] always returns nil. Huh?
Here's gTextures in Main.lua
gTextures = {
['background'] = love.graphics.newImage('graphics/background.png'),
['main'] = love.graphics.newImage('graphics/breakout.png'),
['arrows'] = love.graphics.newImage('graphics/arrows.png'),
['hearts'] = love.graphics.newImage('graphics/hearts.png'),
['particle'] = love.graphics.newImage('graphics/particle.png'),
['buganimation'] = love.graphics.newImage('graphics/buganimation.png')
}
Attempting to return gTextures['buganimation'] returns a file value as normal. It's not empty.
My brain is so fried right now I can't even remember why I came to edit this. I can't remember.
Global table in Main.lua, all other functions can't access it.
print(gTextures['buganimation']) works inside the function in question. So gTextures is absolutely accessible.
Table isn't empty. AnimationSetValues is not empty.
I'm adding second answer because both are correct in context.
I ended up switching IDE's to VS Code and now the original one works.
I was originally using Eclipse LDT with a Love2D interpreter and in that environment, my original answer is correct, but in VS Code, the original is also correct.
So Dimitry was right, they are equivalent, but something about my actual Eclipse setup was not allowing that syntax to work.
I switched to VS Code after I had another strange syntax problem with the interpreter where goto syntax was not recognized and gave a persistent error. The interpreter thought goto was the name of a variable.
So I switched, and now both things are fixed. I guess I just won't use LDT for now.
Solution: Lua syntax. Brain Fry Syndrome
I wrote:
animationSetValues = {atlasarray = animationQuadArray, width = spriteWidthDivider, height = spriteHeightDivider}
Should be:
animationSetValues = {['atlasfile']=atlasfile, ['atlasarray']=animationQuadArray, ['width']=spriteWidthDivider, ['height']=spriteHeightDivider}
Edit: I'm fully aware of how to use answers. This was posted here to reserve my spot for an answer so I could edit it later when I returned back home, which is exactly what I'm doing right now. I'll keep the old post for archival purposes.
Original:
I solved it. I apologize for not posting the solution right now. My brain is melted into gravy.
I will post it tomorrow. Just wanted to "answer" saying no need to help. Solved it.
Solution is basically, "oh it's just one of those Lua things". Wonderful. I'm having so much fun with this language - you can tell by my blank expression.
From the language without line endings or brackets, but forced print parentheses... ugh. I'm going back to C# when this class is done.

Specific attributes are being excluded from darts Element.setInnerHtml()

I've encountered the following problem:
Before mods may click 'duplicate', it isn't. I've searched the problem, found 'solutions', applied 'solutions' and they didn't work. So the question could be 'Why is my 'solution' not working?' or the question could be 'What is the actual solution?'
The responsible code for this is
querySelector("#element").setInnerHtml(some_element.outerHtml, treeSanitizer: NodeTreeSanitizer.trusted);
What am I doing wrong?
I found out to apply the sanitizer to the Element.
Element element = new Element.html('<a data-tag="value">thing</a>'), treeSanitizer: NodeTreeSanitizer.trusted)
I haven't gone back recently to double check that is the best way, but we've ended up building a common NodeValidator that we keep up to date with our various custom attributes.
NodeValidator get commonValidator => _commonValidator;
/// Create a NodeValidator which passes common values.
final NodeValidator _commonValidator = new NodeValidatorBuilder.common()
..allowHtml5()
..allowInlineStyles()
..allowNavigation(_policy)
..allowImages()
..allowTextElements()
..allowElement("a", attributes: [
"data-version",
"data-attribute-add"])
..allowElement("div", attributes: [
"data-sec"]);
foo.setInnerHtml(someOddHtml, validator: commonValidator);

Create keybinding to focus master client in awesome-wm

I would like to create a keybinding to switch focus to the master client. Profjim on this forum thread notes:
To get the master client on the current tag:
c = awful.client.getmaster()
I have tried the following, but it causes my ~/.config/rc.lua file to be ignored, which is the behavior if there is an error in the file. Does anyone know the correct syntax?
awful.key({ modkey, , "e", awful.client.getMaster()),
Note: "e" shouldn't cause any conflicts if you have the default key bindings.
Edit: Someone on /r/awesomewm knew the syntax to solve my problem:
awful.key({ modkey, }, "e", function() client.focus = awful.client.getmaster(); client.focus:raise() end),
Lets start with the syntax errors; from the documentation it seems that awful.key is a table, not a function. and it would presumably contain keys...which are hash tables, not sequences.
Finally your table syntax is wrong; a field may not be syntactically empty, it must have a listed value, even if that value is nil.
So basically you are trying to pass the wrong kind of value to something that can't be called.
As for how to do it correctly...the documentation is confusing, and apparently I'm not the only one that thinks so.
*deep breath*
okay, awful.new(...) creates key binders(?), and awful.key contains key bindings, so clearly we have to put the results of the first into the second.
the code on your link is but a pointer, and only covers focusing the window, not creating a keybinding.
It seems like you want something like this:
function do_focus()
current = client.focus
master = awful.client.getmaster()
if current then
client.focus = master
master:raise()
end
end
table.insert(awful.key, awful.new (modkey, 'e', nil, do_focus) )
Bare in mind that I have no way of testing the above code.

Nokogiri/Ruby array question

I have a quick question. I am currently writing a Nokogiri/Ruby script and have the following code:
fullId = doc.xpath("/success/data/annotatorResultBean/annotations/annotationBean/concept/fullId")
fullId.each do |e|
e = e.to_s()
g.write(e + "\n")
end
This spits out the following text:
<fullId>D001792</fullId>
<fullId>D001792</fullId>
<fullId>D001792</fullId>
<fullId>D008715</fullId>
I wanted the just the numbers text in between the "< fullid>" saved, without the < fullId>,< /fullId> markup. What am I missing?
Bobby
I think you want to use the text() accessor (which returns the child text values), rather than to_s() (which serializes the entire node, as you see here).
I'm not sure what the g object you're calling write on is, but the following code should give you an array containing all of the text in the fullId nodes:
doc.xpath(your_xpath).map {|e| e.text}

Resources