Skip to content

Commit ea99ffa

Browse files
Merge branch 'main' into sankey
2 parents fd591f2 + 7ccc690 commit ea99ffa

File tree

2 files changed

+127
-0
lines changed
  • content
    • javascript/concepts/dom-manipulation/terms/removeChild
    • pytorch/concepts/tensor-operations/terms/acosh

2 files changed

+127
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
Title: '.removeChild()'
3+
Description: 'Removes a given child node from the DOM and returns the removed node.'
4+
Subjects:
5+
- 'Web Development'
6+
- 'Web Design'
7+
Tags:
8+
- 'DOM'
9+
- 'ES6'
10+
- 'Arguments'
11+
- 'Functions'
12+
CatalogContent:
13+
- 'introduction-to-javascript'
14+
- 'paths/front-end-engineer-career-path'
15+
---
16+
17+
The **`.removeChild()`** method in JavaScript is a key DOM (Document Object Model) manipulation tool that removes a specified child node from the DOM tree. It enables developers to dynamically modify a webpage's structure by removing elements from their parent nodes. When called on a parent node with a child node argument, it removes that child from the DOM and returns the removed node. The returned node can still be used for other purposes, such as being inserted elsewhere in the DOM.
18+
19+
## Syntax
20+
21+
```pseudo
22+
parentNode.removeChild(childNode);
23+
```
24+
25+
- `parentNode`: The parent DOM node from which the child will be removed.
26+
- `childNode`: The node to remove (must be a child of the parent node).
27+
28+
### Notes
29+
30+
- The removed node still exists in memory and can be reused, though it's no longer in the DOM.
31+
- If the specified child is not a child of the parent node, the method will throw an error.
32+
- The node must be a direct child of the parent node.
33+
34+
## Example
35+
36+
The following example shows how to use `.removeChild()` to remove a paragraph from a `<div>`.
37+
38+
Here's the HTML code:
39+
40+
```html
41+
<div id="container">
42+
<p id="removeme">This paragraph will be removed!</p>
43+
</div>
44+
```
45+
46+
Here's the JavaScript code:
47+
48+
```js
49+
// Select the parent node
50+
const parentDiv = document.getElementById('container');
51+
52+
// Select the paragraph to remove
53+
const paragraphToRemove = document.getElementById('removeme');
54+
55+
// Remove the paragraph
56+
const removedParagraph = parentDiv.removeChild(paragraphToRemove);
57+
58+
// Print the removed paragraph
59+
console.log(removedParagraph.textContent);
60+
```
61+
62+
The above code produces the following output:
63+
64+
```shell
65+
"This paragraph will be removed!"
66+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
Title: '.acosh()'
3+
Description: 'Computes the inverse hyperbolic cosine of elements in a PyTorch tensor.'
4+
Subjects:
5+
- 'Computer Science'
6+
- 'Data Science'
7+
Tags:
8+
- 'Deep Learning'
9+
- 'Programming'
10+
- 'PyTorch'
11+
CatalogContent:
12+
- 'intro-to-py-torch-and-neural-networks'
13+
- 'paths/data-science'
14+
---
15+
16+
The **`.acosh()`** method in PyTorch computes the inverse hyperbolic cosine of each element in a [tensor](https://www.codecademy.com/resources/docs/pytorch/tensors). This operation is applied element-wise and is commonly used in scientific computations involving hyperbolic functions.
17+
18+
## Syntax
19+
20+
```pseudo
21+
torch.acosh(input, *, out=None) → Tensor
22+
```
23+
24+
**Parameters:**
25+
26+
- `input`: The input tensor containing values greater than or equal to 1.
27+
- `out` (Optional): The output tensor to store the result. If not provided, a new tensor is created.
28+
29+
**Returns:**
30+
31+
A tensor with the inverse hyperbolic cosine of each element from the input tensor.
32+
33+
## Example
34+
35+
This example shows how to use `.acosh()` to compute the inverse hyperbolic cosine of a tensor:
36+
37+
```py
38+
import torch
39+
40+
# Define a tensor with values >= 1
41+
input_tensor = torch.tensor([1.0, 2.0, 3.0, 10.0])
42+
43+
# Compute the inverse hyperbolic cosine
44+
output_tensor = torch.acosh(input_tensor)
45+
46+
print("Input Tensor:")
47+
print(input_tensor)
48+
49+
print("\nOutput Tensor:")
50+
print(output_tensor)
51+
```
52+
53+
This example results in the following output:
54+
55+
```shell
56+
Input Tensor:
57+
tensor([ 1., 2., 3., 10.])
58+
59+
Output Tensor:
60+
tensor([0.0000, 1.3169, 1.7627, 2.9932])
61+
```

0 commit comments

Comments
 (0)