Setting spacing per breakpoint in Bootstrap 5 - bootstrap-5

I thought it was possible to set spacing (margin/padding) per breakpoint in Bootstrap 5?
Something like mb-sm-2 doesn't seem to work... Should it...?
I have checked the docs but don't really understand what it's saying - it sounds like breakpoints are supported... 🤷‍♂️

Yes. Break points are supported in Bootstrap 5.
From the docs if you want to set margin or padding for extra small dimensions(<576px) .You use
<div class="mb-2"></div>
That though will affect all dimensions as it is not under any specified media query.
If you want to specify margin on small dimensions(≥576px) . You use
<div class="mb-sm-2"></div>
That will affect dimensions that are equal and greater than 576px. In case you want that to take place only on small dimensions. You use
<div class="mb-sm-2 mb-md-0"></div>
Dimensions that are equal to and greater than 768px and those less 576px will not have the specified margin.

Bootstrap 5 uses for breakpoints a different syntax comparing with previous versions.
The available breakpoints are as follows
| Breakpoint | Class infix | Dimensions |
|-------------------|-------------|------------|
| X-Small | None | <576px |
| Small | sm | ≥576px |
| Medium | md | ≥768px |
| Large | lg | ≥992px |
| Extra large | xl | ≥1200px |
| Extra extra large | xxl | ≥1400px |
Here is a particular example: in order to get 0 margin and 0 padding ONLY for screens with lower resolution as X-Small(<576px) use something like this:
class="m-0 p-0 m-sm-4 p-sm-4"
where m-0 and p-0 will be applied only for resolution <576px and m-sm-4 and p-sm-4 for ≥576px resolution.

Related

Can logistic regression be used for variables containing lists?

I'm pretty new into Machine Learning and I was wondering if certain algorithms/models (ie. logistic regression) can handle lists as a value for their variables. Until now I've always used pretty standard datasets, where you have a couple of variables, associated values and then a classification for those set of values (view example 1). However, I now have a similar dataset but with lists for some of the variables (view example 2). Is this something logistic regression models can handle, or would I have to do some kind of feature extraction to transform this dataset into just a normal dataset like example 1?
Example 1 (normal):
+---+------+------+------+-----------------+
| | var1 | var2 | var3 | classification |
+---+------+------+------+-----------------+
| 1 | 5 | 2 | 526 | 0 |
| 2 | 6 | 1 | 686 | 0 |
| 3 | 1 | 9 | 121 | 1 |
| 4 | 3 | 11 | 99 | 0 |
+---+------+------+------+-----------------+
Example 2 (lists):
+-----+-------+--------+---------------------+-----------------+--------+
| | width | height | hlines | vlines | class |
+-----+-------+--------+---------------------+-----------------+--------+
| 1 | 115 | 280 | [125, 263, 699] | [125, 263, 699] | 1 |
| 2 | 563 | 390 | [11, 211] | [156, 253, 399] | 0 |
| 3 | 523 | 489 | [125, 255, 698] | [356] | 1 |
| 4 | 289 | 365 | [127, 698, 11, 136] | [458, 698] | 0 |
| ... | ... | ... | ... | ... | ... |
+-----+-------+--------+---------------------+-----------------+--------+
To provide some additional context on my specific problem. I'm attempting to represent drawings. Drawings have a width and height (regular variables) but drawings also have a set of horizontal and vertical lines for example (represented as a list of their coordinates on their respective axis). This is what you see in example 2. The actual dataset I'm using is even bigger, also containing variables which hold lists containing the thicknesses for each line, lists containing the extension for each line, lists containing the colors of the spaces between the lines, etc. In the end I would like to my logistic regression to pick up on what result in nice drawings. For example, if there are too many lines too close the drawing is not nice. The model should pick up itself on these 'characteristics' of what makes a nice and a bad drawing.
I didn't include these as the way this data is setup is a bit confusing to explain and if I can solve my question for the above dataset I feel like I can use the principe of this solution for the remaining dataset as well. However, if you need additional (full) details, feel free to ask!
Thanks in advance!
No, it cannot directly handle that kind of input structure. The input must be a homogeneous 2D array. What you can do, is come up with new features that capture some of the relevant information contained in the lists. For instance, for the lists that contain the coordinates of the lines along an axis (other than the actual values themselves), one could be the spacing between lines, or the total amount of lines or also some statistics such as the mean location etc.
So the way to deal with this is through feature engineering. This is in fact, something that has to be dealt with in most cases. In many ML problems, you may not only have variables which describe a unique aspect or feature of each of the data samples, but also many of them might be aggregates from other features or sample groups, which might be the only way to go if you want to consider certain data sources.
Wow, great question. I have never consider this, but when I saw other people's responses, I would have to concur, 100%. Convert the lists into a data frame and run your code on that object.
import pandas as pd
data = [["col1", "col2", "col3"], [0, 1, 2],[3, 4, 5]]
column_names = data.pop(0)
df = pd.DataFrame(data, columns=column_names)
print(df)
Result:
col1 col2 col3
0 0 1 2
1 3 4 5
You can easily do any multi regression on the fields/features of the data frame and you'll get what you need. See the link below for some ideas of how to get started.
https://pythonfordatascience.org/logistic-regression-python/
Post back if you have additional questions related to this. Or, start a new post if you have similar, but unrelated, questions.

Visualising the motion of multiple robots

I am trying to add multiple robot instances and visualising their motions. I tried a couple of ways to do this and I ran into errors/issues. They are as follows:
I tried adding another model instance after the system is created.
parsers::urdf::AddModelInstanceFromUrdfFileToWorld(
FindResourceOrThrow("path/CompassGait.urdf"),
multibody::joints::kRollPitchYaw, tree.get());
parsers::urdf::AddModelInstanceFromUrdfFileToWorld(
FindResourceOrThrow("path/quadrotor.urdf"),
multibody::joints::kRollPitchYaw, tree.get());
As expected, there are two robots which are visible in the visualiser and there are 26 output ports in the system. But i am unable to visualise the required motion by the quadrotor. It seems to be following the x,y,z and roll pitch and yaw derivatives given as an input for the compass gait's output port. Is this an expected behaviour?
I experience a similar thing when I add 2 compass gait models and try to make them follow the same path. Even though I give the ports 14-27 the same inputs as i give to 0-13. The second robot is stuck near the origin while the first one moves fine as expected without any issues.
I needed some help or maybe some examples where I can get a better idea about visualising the motion for multiple robots.
[Updated] Please see note at the bottom.
drake::systems::DrakeVisualizer (which I assume you're using to publish your visualization messages) was designed to be connected to the state_output_port of drake::systems::RigidBodyPlant. According to the documentation for RigidBodyPlant,
The state vector, x, consists of generalized positions followed by generalized velocities.
That is, the generalized positions for all model instances come before the generalized velocities. When working with RigidBodyPlant and DrakeVisualizer this ordering is handled automatically.
From your question, however, I gather that you have separate, specialized systems for your quadrotor and compass-gait models (as per their respective examples). Each of these systems outputs its state as [q, v], where q is the generalized position vector and v is the generalized velocity vector. In that case you will need to use drake::systems::Demultiplexer and drake::systems::Multiplexer to split the outputs of the quadrotor and compass-gait systems and reassemble them in the required order:
+---------------+ +-------------+ q +-------------+
| | | +-------->+ |
| Compass-gait +-->+Demultiplexer| | |
| | | +-----+ v | |
+---------------+ +-------------+ | | |
+----->+ | +-----------------+
| | | | | |
| | | Multiplexer +-->+ DrakeVisualizer |
q| | | | | |
| +-->+ | +-----------------+
+---------------+ +-------------+ | | |
| | | +--+ | |
| Quadrotor +-->+Demultiplexer| | |
| | | +---+---->+ |
+---------------+ +-------------+ v +-------------+
Note: RigidBodyPlant and associated classes are being replaced by drake::multibody::MultibodyPlant and drake::geometry::SceneGraph. See run_quadrotor_lqr.cc for an example of using these new tools with a specialized plant.

neo4j query for chaining, 'knitting' pattern

I want to write a neo4j query, that finds a 'knitting' pattern. With that I basically mean a set of four nodes with three special edges between them. And continuing these four, there can be a next set of four nodes, that are connected by three other edges, like this (in some Cypher-like syntax with vertical edges.
(n1)-[:e1]-(n2)-[:e2]-(n3)-[:e3]-(n4)
| | | |
[:ew] [:ex] [:ey] [:ez]
| | | |
(n5)-[:e1]-(n6)-[:e2]-(n7)-[:e3]-(n8)
| | | |
[:ew] [:ex] [:ey] [:ez]
| | | |
(n?)-[:e3]-(n!)-[:e3]-(n&)-[:e3]-(n$)
. . . .
: : : :
I can write a query for exactly 8, 12 or 16... nodes, that are connected in this way. But I would like to write it more general to get the longest connected components, that are knitted like this.
Can you give me a hint, how to go along with that, because I'm totally new to neo4j?

Adding constraints to reusable UITableViewCell in Swift

I'm working on an app which displays sports results for different sports. The ranking table should have a dynamic width for its content, based on its length. Currently it's all fixed width, but once one of the columns has a lot of text, it gets cropped at the end:
+-----------------------------+
| Goals Diff Sc |
+--------+-------+-------+----+
| Team 1 | 152 | 15... | 53 | // Should be 152:xxx
+--------+-------+-------+----+
| Team 2 | 146 | 14... | 53 | // Should be 145:xxx
+--------+-------+-------+----+
| Team 3 | 41 | 41... | 53 | // Should be 41:xxx
+--------+-------+-------+----+
Instead, it should analyze the maximum cell width for each individual column and adjust its width based on that. In case the cells become too wide, they should move left, cropping the team's name instead (in fact, it will word wrap if too small).
+-----------------------------+
| Goa Diff Sc |
+--------+-----+---------+----+
| Team 1 | 152 | 152:xxx | 53 |
+--------+-----+---------+----+
| Team 2 | 146 | 145:xxx | 53 |
+--------+-----+---------+----+
| Team 3 | 41 | 41:xxx | 53 |
+--------+-----+---------+----+
I yet have to decide what exactly to do with the cell headers, but that's another problem.
I have already tried computing the cell widths, comparing them to one another and then creating an array of the maximum width per column, which works as it should. However, it requires quite a lot of computing, as it manually creates labels for each column in every row, calls sizeToFit() on it and then comparing its width against the maximum width so far. I can't believe this is the only way to do it.
Then I use this array of widths on each tableView(:cellForRowAtIndexPath:) to add constraints to the dequeued reusable table view cells (and one of the three/how ever many it is labels). Again, having to create 3 constraints in each call of the method doesn't seem optimal to me.
Is there any easier way? Is there already a inbuilt function I'm missing (or perhaps a library for just that)?

Behave - Common features between applications, avoiding duplication

I have many applications which I want to test, which have a largely overlapping set of features. Here is an oversimplified example of a scenario I might have:
Given <name> is playing a game,
When they shoot at a <color> target
Then they should <event>
Examples:
| name | color | event |
| Alice | red | hit |
| Alice | blue | miss |
| Bob | red | miss |
| Bob | blue | hit |
| Bob | green | hit |
It's a silly example, but suppose really I have a lot of players with different hit/miss conditions, and I want to run just the scenarios for a given name? Say, I only want to run the tests for Alice. There's still advantage to having all the hit/miss tests in a single Scenario Outline (since, after all, they're all closely related).
One approach would be to just duplicate the test for every name and tag them, so something like:
#Alice
Given Alice is playing a game
When she shoots at a <color> target
Then she should <event>
Examples:
| color | event |
| red | hit |
| blue | miss |
This way I can run behave --tags #Alice, But then I'm repeated the same scenario for every user, and that's a lot of duplication. Is there a good way to still compress all the examples into one scenario - but only selectively run some of them? What's the right approach here?
Version 1.2.5 introduced better ways to distinguish scenario outlines. It is now possible to uniquely distinguish them and thus select a unique scenario generated from an outline with --name= at the command line. For instance, suppose the following feature file:
Feature: test
Scenario Outline: test
Given <name> is playing a game,
When they shoot at a <color> target
Then they should <event>
Examples:
| name | color | event |
| Alice | red | hit |
| Alice | blue | miss |
| Bob | red | miss |
| Bob | blue | hit |
| Bob | green | hit |
Let's say I want to run only the test for Bob, red, miss. It is in the first table, 3rd row. So:
behave --name="#1.3"
will select this test. In version 1.2.5 and subsequent versions. A generated scenario gets a name which includes "#<table number>.<row number>" where <table number> is the number of the table (starting from 1) and <row number> is the number of the row.
This won't easily allow you to select all scenarios that pertain to a single user. However, you can achieve it in another way. You can split your examples in two:
Examples: Alice
| name | color | event |
| Alice | red | hit |
| Alice | blue | miss |
Examples: Bob
| name | color | event |
| Bob | red | miss |
| Bob | blue | hit |
| Bob | green | hit |
The table names will appear in the generated scenario names and you could ask behave to run all the tests associated with one table:
behave --name="Alice"
I do not know of a way to access the example name in steps and thus get rid of the first column.
The full set of details is in the release notes for 1.2.5.

Resources