Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: JuliaPhysics/PeriodicTable.jl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.0
Choose a base ref
...
head repository: JuliaPhysics/PeriodicTable.jl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 389 additions and 184 deletions.
  1. +48 −0 .github/workflows/CI.yml
  2. +8 −2 .github/workflows/TagBot.yml
  3. +2 −0 .gitignore
  4. +0 −21 .travis.yml
  5. +7 −2 Project.toml
  6. +11 −13 README.md
  7. +0 −47 appveyor.yml
  8. +86 −4 src/PeriodicTable.jl
  9. +201 −91 src/elements.jl
  10. +26 −4 test/runtests.jl
48 changes: 48 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.0'
- '1.6'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
- x86
# 32-bit Julia binaries are not available on macOS
exclude:
- os: macOS-latest
arch: x86
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
10 changes: 8 additions & 2 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
issue_comment: # THIS BIT IS NEW
types:
- created
workflow_dispatch:
jobs:
TagBot:
# THIS 'if' LINE IS NEW
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
# NOTHING BELOW HAS CHANGED
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.jl.cov
*.jl.*.cov
*.jl.mem

Manifest.toml
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

9 changes: 7 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
name = "PeriodicTable"
uuid = "7b2266bf-644c-5ea3-82d8-af4bbd25a884"
version = "1.0.0"
version = "1.2.1"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
julia = "1"
Unitful = "1.0"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[![Build Status](https://github.com/JuliaPhysics/PeriodicTable.jl/workflows/CI/badge.svg)](https://github.com/JuliaPhysics/PeriodicTable.jl/actions)
[![codecov.io](http://codecov.io/github/JuliaPhysics/PeriodicTable.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaPhysics/PeriodicTable.jl?branch=master)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.org/rahulkp220/PeriodicTable.jl.svg?branch=master)](https://travis-ci.org/rahulkp220/PeriodicTable.jl)
[![codecov.io](http://codecov.io/github/rahulkp220/PeriodicTable.jl/coverage.svg?branch=master)](http://codecov.io/github/rahulkp220/PeriodicTable.jl?branch=master)
[![GitHub version](https://badge.fury.io/gh/JuliaPhysics%2FPeriodicTable.jl.svg)](https://github.com/JuliaPhysics/PeriodicTable.jl)
[![GitHub contributors](https://img.shields.io/github/contributors/rahulkp220/PeriodicTable.jl.svg)](https://github.com/rahulkp220/PeriodicTable.jl/graphs/contributors)
[![GitHub issues](https://img.shields.io/github/issues/rahulkp220/PeriodicTable.jl.svg)](https://github.com/rahulkp220/PeriodicTable.jl/issues/)
[![GitHub version](https://badge.fury.io/gh/rahulkp220%2FPeriodicTable.jl.svg)](https://github.com/rahulkp220/PeriodicTable.jl)

[![ForTheBadge built-with-science](http://ForTheBadge.com/images/badges/built-with-science.svg)](https://github.com/rahulkp220/)

@@ -81,14 +80,13 @@ julia> elements[1:4]
A nice interactive visualization of the periodic table, based on PeriodicTable.jl, can be found [here](https://github.com/lancebeet/julia-scripts#periodictabletoyjl).

### Data by
The data used for this package has been pulled up in parts from [here](https://github.com/Bowserinator/Periodic-Table-JSON).
Some information has been (and will be) added over time.
The data used for this package has been pulled up in parts from [here](https://github.com/Bowserinator/Periodic-Table-JSON). Atomic weights are from the [IUPAC 2021 tabulation](https://iupac.qmul.ac.uk/AtWt/)

### Developed together with
* [Steven G. Johnson](https://github.com/stevengj)
* [Jacob Wikmark](https://github.com/lancebeet)
* [Carsten Bauer](https://github.com/crstnbr)
### Related packages
[Mendeleev](https://github.com/Eben60/Mendeleev.jl) is [API compatible](https://eben60.github.io/Mendeleev.jl/#Compatibility-Issues) with the `PeriodicTable` and contains much broader range of data on chemical elements. [IsotopeTable](https://github.com/Gregstrq/IsotopeTable.jl), also inspired by `PeriodicTable`, provides data on various isotopes.

### Facing issues? :scream:
* Open a PR with the detailed expaination of the issue
* Reach me out [here](https://www.rahullakhanpal.in)
### Contributors ✨
<!-- markdownlint-disable -->
<a href="https://github.com/JuliaPhysics/PeriodicTable.jl/graphs/contributors">
<img src="https://contrib.rocks/image?repo=JuliaPhysics/PeriodicTable.jl" />
</a>
47 changes: 0 additions & 47 deletions appveyor.yml

This file was deleted.

90 changes: 86 additions & 4 deletions src/PeriodicTable.jl
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ struct Element
boil::typeof(1.0K)
category::String
color::String
cpk_hex::String
density::typeof(1.0g/cm^3)
discovered_by::String
el_config::String
@@ -47,6 +48,7 @@ Element(; name::AbstractString="",
boil::typeof(1.0K)=NaN*K,
category::AbstractString="",
color::AbstractString="",
cpk_hex::AbstractString="",
density::typeof(1.0g/cm^3)=NaN*g/cm^3,
discovered_by::AbstractString="",
el_config::AbstractString="",
@@ -63,7 +65,7 @@ Element(; name::AbstractString="",
xpos::Integer=-1,
ypos::Integer=-1,
shells::AbstractVector{<:Integer}=Int[]) =
Element(name, appearance, atomic_mass, boil, category, color, density,
Element(name, appearance, atomic_mass, boil, category, color, cpk_hex, density,
discovered_by, el_config, melt, molar_heat, named_by, number, period, phase,
source, spectral_img, summary, symbol, xpos, ypos, shells)

@@ -185,16 +187,96 @@ function Base.show(io::IO, ::MIME"text/plain", e::Elements)
for el in e
table[el.ypos, el.xpos] = rpad(el.symbol, 3)
end
for i = 1:size(table,1)
for j = 1:size(table, 2)
for i in axes(table, 1)
for j in axes(table, 2)
print(io, table[i,j])
end
println(io)
end
end

const _clrs = Dict(
"diatomic nonmetal" => ("#e2eeff", "#0060f0"),
"noble gas" => ("#ffe7eb", "#cd1d5e"),
"alkali metal" => ("#d8f8ff", "#00758c"),
"alkaline earth metal" => ("#ffe7e7", "#d60024"),
"metalloid" => ("#fef7e0", "#945700"),
"polyatomic nonmetal" => ("#e2eeff", "#0060f0"),
"post-transition metal" => ("#d6f9e8", "#227754"),
"transition metal" => ("#f3e8fd", "#6232ec"),
"lanthanide" => ("#dff3ff", "#003355"),
"actinide" => ("#ffe6d4", "#c73200"),
"unknown, probably transition metal" => ("#e7e7ea", "#3f374f"),
"unknown, probably post-transition metal" => ("#e7e7ea", "#3f374f"),
"unknown, probably metalloid" => ("#e7e7ea", "#3f374f"),
"unknown, predicted to be noble gas" => ("#e7e7ea", "#3f374f"),
"unknown, but predicted to be an alkali metal" => ("#e7e7ea", "#3f374f"),
)

function _fill_element_data(el::Element)
clr = _clrs[el.category]
return """
<td class="element" style="background-color:$(clr[1]);color:$(clr[2]);">
<div class="top">
<div>$(el.number)</div>
<div>$(round(el.atomic_mass.val; digits=3))</div>
</div>
<div class="symbol">$(el.symbol)</div>
<div>$(el.name)</div>
</td>
"""
end

# rich html periodic table
function Base.show(io::IO, ::MIME"text/html", e::PeriodicTable.Elements)
table = fill("<td></td>\n", 10, 18)
for el in e
table[el.ypos, el.xpos] = _fill_element_data(el)
end
print(
io,
"""
<table style="width:100%;empty-cells:hide;border:0px;background-color:#ffffff">
<style>
.element {
border: 5px solid #ffffff;
min-width: 100px;
height: 100%;
text-align: center;
font-size: 10px;
border-radius: 10px;
border-collapse: collapse;
}
.top {
display: flex;
justify-content: space-between;
}
.symbol {
text-align: center;
font-weight: bold;
# font-size: 5px;
}
</style>
"""
)
for i in axes(table, 1)
println(io, "\n<tr>")
for j in axes(table, 2)
print(io, table[i, j])
end
print(io, "</tr>")
end
print(io, "\n</table>")
end

# For Vscode
function Base.show(io::IO, ::MIME"juliavscode/html", e::PeriodicTable.Elements)
show(io, MIME"text/html"(), e)
end

# Since Element equality is determined by atomic number alone...
Base.isequal(elm1::Element, elm2::Element) = elm1.number == elm2.number
Base.:(==)(elm1::Element, elm2::Element) = elm1.number == elm2.number

# There is no need to use all the data in Element to calculated the hash
# since Element equality is determined by atomic number alone.
Loading